// Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraView.java
// public class GLCameraView extends GLSurfaceView {
//     private static final String TAG = "GLCameraView";
// 
//     protected ScaleGestureDetector mScaleGestureDetector;
//     private Camera mCamera;
//     private int mMaxZoom;
// 
//     public GLCameraView(Context context) {
//         super(context);
//         init(context);
//     }
// 
//     public GLCameraView(Context context, AttributeSet attrs) {
//         super(context, attrs);
//         init(context);
//     }
// 
//     private void init(Context context){
//         mMaxZoom = 0;
// 
//     }
// 
//     public void setCamera(Camera camera){
//         mCamera = camera;
//         Camera.Parameters camParams = mCamera.getParameters();
//         if(camParams.isZoomSupported()){
//             mMaxZoom = camParams.getMaxZoom();
//             mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener);
//         }
//     }
// 
//     public void releaseCamera(){
//         mCamera = null;
//         mScaleGestureDetector = null;
//     }
// 
//     private ScaleGestureDetector.SimpleOnScaleGestureListener mScaleListener = new ScaleGestureDetector.SimpleOnScaleGestureListener(){
// 
//         int mZoomWhenScaleBegan = 0;
//         int mCurrentZoom = 0;
// 
//         @Override
//         public boolean onScale(ScaleGestureDetector detector) {
//             if(mCamera != null){
//                 Camera.Parameters params = mCamera.getParameters();
//                 mCurrentZoom = (int) (mZoomWhenScaleBegan + (mMaxZoom * (detector.getScaleFactor() - 1)));
//                 mCurrentZoom = Math.min(mCurrentZoom, mMaxZoom);
//                 mCurrentZoom = Math.max(0, mCurrentZoom);
//                 params.setZoom(mCurrentZoom);
//                 mCamera.setParameters(params);
//             }
// 
//             return false;
//         }
// 
//         @Override
//         public boolean onScaleBegin(ScaleGestureDetector detector) {
//             mZoomWhenScaleBegan =  mCamera.getParameters().getZoom();
//             return true;
//         }
// 
//         @Override
//         public void onScaleEnd(ScaleGestureDetector detector) {
//         }
//     };
// 
//     @Override
//     public boolean onTouchEvent(MotionEvent ev) {
//         if(mScaleGestureDetector != null){
//             if(!mScaleGestureDetector.onTouchEvent(ev)){
//                 // No scale gesture detected
// 
//             }
//         }
//         return true;
//     }
// 
// 
// }


import java.io.IOException;
import io.kickflip.sdk.view.GLCameraView;
package io.kickflip.sdk.av;



/**
 * Records an Audio / Video stream to disk.
 *
 * 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;
    }

// Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraView.java
// public class GLCameraView extends GLSurfaceView {
//     private static final String TAG = "GLCameraView";
// 
//     protected ScaleGestureDetector mScaleGestureDetector;
//     private Camera mCamera;
//     private int mMaxZoom;
// 
//     public GLCameraView(Context context) {
//         super(context);
//         init(context);
//     }
// 
//     public GLCameraView(Context context, AttributeSet attrs) {
//         super(context, attrs);
//         init(context);
//     }
// 
//     private void init(Context context){
//         mMaxZoom = 0;
// 
//     }
// 
//     public void setCamera(Camera camera){
//         mCamera = camera;
//         Camera.Parameters camParams = mCamera.getParameters();
//         if(camParams.isZoomSupported()){
//             mMaxZoom = camParams.getMaxZoom();
//             mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener);
//         }
//     }
// 
//     public void releaseCamera(){
//         mCamera = null;
//         mScaleGestureDetector = null;
//     }
// 
//     private ScaleGestureDetector.SimpleOnScaleGestureListener mScaleListener = new ScaleGestureDetector.SimpleOnScaleGestureListener(){
// 
//         int mZoomWhenScaleBegan = 0;
//         int mCurrentZoom = 0;
// 
//         @Override
//         public boolean onScale(ScaleGestureDetector detector) {
//             if(mCamera != null){
//                 Camera.Parameters params = mCamera.getParameters();
//                 mCurrentZoom = (int) (mZoomWhenScaleBegan + (mMaxZoom * (detector.getScaleFactor() - 1)));
//                 mCurrentZoom = Math.min(mCurrentZoom, mMaxZoom);
//                 mCurrentZoom = Math.max(0, mCurrentZoom);
//                 params.setZoom(mCurrentZoom);
//                 mCamera.setParameters(params);
//             }
// 
//             return false;
//         }
// 
//         @Override
//         public boolean onScaleBegin(ScaleGestureDetector detector) {
//             mZoomWhenScaleBegan =  mCamera.getParameters().getZoom();
//             return true;
//         }
// 
//         @Override
//         public void onScaleEnd(ScaleGestureDetector detector) {
//         }
//     };
// 
//     @Override
//     public boolean onTouchEvent(MotionEvent ev) {
//         if(mScaleGestureDetector != null){
//             if(!mScaleGestureDetector.onTouchEvent(ev)){
//                 // No scale gesture detected
// 
//             }
//         }
//         return true;
//     }
// 
// 
// }


// Path: sdk/src/main/java/io/kickflip/sdk/av/AVRecorder.java
import java.io.IOException;
import io.kickflip.sdk.view.GLCameraView;

package io.kickflip.sdk.av;



/**
 * Records an Audio / Video stream to disk.
 *
 * 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){