@ -1,5 +1,6 @@ 
			
		
	
		
			
				
					package  com.otaliastudios.cameraview ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					import  android.annotation.TargetApi ;  
			
		
	
		
			
				
					import  android.graphics.ImageFormat ;  
			
		
	
		
			
				
					import  android.graphics.PointF ;  
			
		
	
		
			
				
					import  android.graphics.Rect ;  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -9,6 +10,7 @@ import android.hardware.Camera; 
			
		
	
		
			
				
					import  android.location.Location ;  
			
		
	
		
			
				
					import  android.media.CamcorderProfile ;  
			
		
	
		
			
				
					import  android.media.MediaRecorder ;  
			
		
	
		
			
				
					import  android.os.Build ;  
			
		
	
		
			
				
					import  android.support.annotation.NonNull ;  
			
		
	
		
			
				
					import  android.support.annotation.Nullable ;  
			
		
	
		
			
				
					import  android.support.annotation.WorkerThread ;  
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -178,6 +180,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera 
			
		
	
		
			
				
					            mergeLocation ( params ,  null ) ;   
			
		
	
		
			
				
					            mergeWhiteBalance ( params ,  WhiteBalance . DEFAULT ) ;   
			
		
	
		
			
				
					            mergeHdr ( params ,  Hdr . DEFAULT ) ;   
			
		
	
		
			
				
					            mergePlaySound ( mPlaySounds ) ;   
			
		
	
		
			
				
					            params . setRecordingHint ( mSessionType  = =  SessionType . VIDEO ) ;   
			
		
	
		
			
				
					            mCamera . setParameters ( params ) ;   
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -366,6 +369,23 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera 
			
		
	
		
			
				
					        return  false ;   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    @TargetApi ( 17 )   
			
		
	
		
			
				
					    private  boolean  mergePlaySound ( boolean  oldPlaySound )  {   
			
		
	
		
			
				
					        if  ( Build . VERSION . SDK_INT  > =  Build . VERSION_CODES . JELLY_BEAN_MR1 )  {   
			
		
	
		
			
				
					            Camera . CameraInfo  info  =  new  Camera . CameraInfo ( ) ;   
			
		
	
		
			
				
					            Camera . getCameraInfo ( mCameraId ,  info ) ;   
			
		
	
		
			
				
					            if  ( info . canDisableShutterSound )  {   
			
		
	
		
			
				
					                mCamera . enableShutterSound ( mPlaySounds ) ;   
			
		
	
		
			
				
					                return  true ;   
			
		
	
		
			
				
					            }   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					        if  ( mPlaySounds )  {   
			
		
	
		
			
				
					            return  true ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					        mPlaySounds  =  oldPlaySound ;   
			
		
	
		
			
				
					        return  false ;   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    @Override   
			
		
	
		
			
				
					    void  setAudio ( Audio  audio )  {   
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -572,15 +592,19 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera 
			
		
	
		
			
				
					    private  boolean  isCameraAvailable ( )  {   
			
		
	
		
			
				
					        switch  ( mState )  {   
			
		
	
		
			
				
					            // If we are stopped, don't.
   
			
		
	
		
			
				
					            case  STATE_STOPPED :  return  false ;   
			
		
	
		
			
				
					            case  STATE_STOPPED :   
			
		
	
		
			
				
					                return  false ;   
			
		
	
		
			
				
					            // If we are going to be closed, don't act on camera.
   
			
		
	
		
			
				
					            // Even if mCamera != null, it might have been released.
   
			
		
	
		
			
				
					            case  STATE_STOPPING :  return  false ;   
			
		
	
		
			
				
					            case  STATE_STOPPING :   
			
		
	
		
			
				
					                return  false ;   
			
		
	
		
			
				
					            // If we are started, mCamera should never be null.
   
			
		
	
		
			
				
					            case  STATE_STARTED :  return  true ;   
			
		
	
		
			
				
					            case  STATE_STARTED :   
			
		
	
		
			
				
					                return  true ;   
			
		
	
		
			
				
					            // If we are starting, theoretically we could act.
   
			
		
	
		
			
				
					            // Just check that camera is available.
   
			
		
	
		
			
				
					            case  STATE_STARTING :  return  mCamera  ! =  null ;   
			
		
	
		
			
				
					            case  STATE_STARTING :   
			
		
	
		
			
				
					                return  mCamera  ! =  null ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					        return  false ;   
			
		
	
		
			
				
					    }   
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -678,15 +702,15 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera 
			
		
	
		
			
				
					        mMediaRecorder . setOrientationHint ( computeSensorToOutputOffset ( ) ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        //If the user sets a max file size, set it to the max file size
   
			
		
	
		
			
				
					        if ( mVideoMaxSizeInBytes  >  0 )  {   
			
		
	
		
			
				
					        if   ( mVideoMaxSizeInBytes  >  0 )  {   
			
		
	
		
			
				
					            mMediaRecorder . setMaxFileSize ( mVideoMaxSizeInBytes ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            //Attach a listener to the media recorder to listen for file size notifications
   
			
		
	
		
			
				
					            mMediaRecorder . setOnInfoListener ( new  MediaRecorder . OnInfoListener ( )  {   
			
		
	
		
			
				
					                @Override   
			
		
	
		
			
				
					                public  void  onInfo ( MediaRecorder  mediaRecorder ,  int  i ,  int  i1 )  {   
			
		
	
		
			
				
					                    switch  ( i ) {   
			
		
	
		
			
				
					                        case  MediaRecorder . MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED : {   
			
		
	
		
			
				
					                    switch  ( i )   {   
			
		
	
		
			
				
					                        case  MediaRecorder . MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED :   {   
			
		
	
		
			
				
					                            endVideoImmediately ( ) ;   
			
		
	
		
			
				
					                            break ;   
			
		
	
		
			
				
					                        }   
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -858,6 +882,18 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera 
			
		
	
		
			
				
					        mVideoMaxSizeInBytes  =  videoMaxSizeInBytes ;   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    @Override   
			
		
	
		
			
				
					    void  setPlaySounds ( boolean  playSounds )  {   
			
		
	
		
			
				
					        final  boolean  old  =  mPlaySounds ;   
			
		
	
		
			
				
					        mPlaySounds  =  playSounds ;   
			
		
	
		
			
				
					        schedule ( mPlaySoundsTask ,  true ,  new  Runnable ( )  {   
			
		
	
		
			
				
					            @Override   
			
		
	
		
			
				
					            public  void  run ( )  {   
			
		
	
		
			
				
					                mergePlaySound ( old ) ;   
			
		
	
		
			
				
					            }   
			
		
	
		
			
				
					        } ) ;   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    // -----------------
   
			
		
	
		
			
				
					    // Additional helper info
   
			
		
	
		
			
				
					}