package com.perchlive.broadcast.sdk.av;

import com.perchlive.broadcast.sdk.view.GLCameraView;

import java.io.IOException;

/**
 * Records an Audio / Video stream to disk.
 * <p/>
 * Example usage:
 * <ul>
 * <li>AVRecorder recorder = new AVRecorder(mSessionConfig);</li>
 * <li>recorder.setPreviewDisplay(mPreviewDisplay);</li>
 * <li>recorder.startRecording();</li>
 * <li>recorder.stopRecording();</li>
 * <li>(Optional) recorder.reset(mNewSessionConfig);</li>
 * <li>(Optional) recorder.startRecording();</li>
 * <li>(Optional) recorder.stopRecording();</li>
 * <li>recorder.release();</li>
 * </ul>
 *
 * @hide
 */
public class AVRecorder {

    protected CameraEncoder     mCamEncoder;
    protected MicrophoneEncoder mMicEncoder;
    private   SessionConfig     mConfig;
    private   boolean           mIsRecording;

    public AVRecorder(SessionConfig config) throws IOException {
        init(config);
    }

    private void init(SessionConfig config) throws IOException {
        mCamEncoder = new CameraEncoder(config);
        mMicEncoder = new MicrophoneEncoder(config);
        mConfig = config;
        mIsRecording = false;
    }

    public void setPreviewDisplay(GLCameraView display) {
        mCamEncoder.setPreviewDisplay(display);
    }

    public void applyFilter(int filter) {
        mCamEncoder.applyFilter(filter);
    }

    public void requestOtherCamera() {
        mCamEncoder.requestOtherCamera();
    }

    public void requestCamera(int camera) {
        mCamEncoder.requestCamera(camera);
    }

    public void toggleFlash() {
        mCamEncoder.toggleFlashMode();
    }

    public void adjustVideoBitrate(int targetBitRate) {
        mCamEncoder.adjustBitrate(targetBitRate);
    }

    /**
     * Signal that the recorder should treat
     * incoming video frames as Vertical Video, rotating
     * and cropping them for proper display.
     * <p/>
     * This method only has effect if {@link io.kickflip.sdk.av.SessionConfig#setConvertVerticalVideo(boolean)}
     * has been set true for the current recording session.
     */
    public void signalVerticalVideo(FullFrameRect.SCREEN_ROTATION orientation) {
        mCamEncoder.signalVerticalVideo(orientation);
    }

    public void startRecording() {
        mIsRecording = true;
        mMicEncoder.startRecording();
        mCamEncoder.startRecording();
    }

    public boolean isRecording() {
        return mIsRecording;
    }

    public void stopRecording() {
        mIsRecording = false;
        mMicEncoder.stopRecording();
        mCamEncoder.stopRecording();
    }

    /**
     * Prepare for a subsequent recording. Must be called after {@link #stopRecording()}
     * and before {@link #release()}
     *
     * @param config
     */
    public void reset(SessionConfig config) throws IOException {
        mCamEncoder.reset(config);
        mMicEncoder.reset(config);
        mConfig = config;
        mIsRecording = false;
    }

    /**
     * Release resources. Must be called after {@link #stopRecording()} After this call
     * this instance may no longer be used.
     */
    public void release() {
        mCamEncoder.release();
        // MicrophoneEncoder releases all it's resources when stopRecording is called
        // because it doesn't have any meaningful state
        // between recordings. It might someday if we decide to present
        // persistent audio volume meters etc.
        // Until then, we don't need to write MicrophoneEncoder.release()
    }

    public void onHostActivityPaused() {
        mCamEncoder.onHostActivityPaused();
    }

    public void onHostActivityResumed() {
        mCamEncoder.onHostActivityResumed();
    }
}

@@ -1935,27 +1935,8 @@
 ink 
-io.kickflip.sdk.av.
 Sess

Fix javadoc link