package net.heartshield.sensors;

import android.app.Activity;
import android.view.TextureView;

import net.heartshield.control.ReleaseConfig;

/**
 * @author David Madl (git@abanbytes.eu)
 * @date 2017-04-12
 */
public class SensorFactory implements ISensorFactory {
    private Activity mActivity;

    public SensorFactory(Activity activity) {
        mActivity = activity;
    }

    @Override
    public ISensor getAccelerationSensor() {
        return new AccelerationSensor(mActivity, 10.0);
    }

    @Override
    public IntensityDetector getIntensityDetector(TextureView cameraPreview) {
        /*
         * nice-to: benchmark the CPU and choose a resolution which we can process in the
         * time available between frames (30 ms)
         */
        return new Camera2Detector(mActivity, cameraPreview, 320, 240, /* stickyUiThread */ false);
    }

    @Override
    public IAudioSensor getAudioSensor() {
        /*
         * The event rate below controls the chunk size processed in the filter pipeline.
         * nice-to: decouple GUI updates from the chunk size being processed.
         * Instead, use a timer that fetches the required data from a FIFO buffer.
         */
        return ReleaseConfig.RECORD_ECG ? new AudioSensor(2.0) : new DummyAudioSensor();
    }
}
