|
|
|
@ -8,7 +8,6 @@ import android.media.MediaRecorder; |
|
|
|
|
import android.view.MotionEvent; |
|
|
|
|
import android.view.SurfaceHolder; |
|
|
|
|
import android.view.View; |
|
|
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.IOException; |
|
|
|
@ -59,6 +58,9 @@ public class Camera1 extends CameraImpl { |
|
|
|
|
@Zoom |
|
|
|
|
private int mZoom; |
|
|
|
|
|
|
|
|
|
@VideoQuality |
|
|
|
|
private int mVideoQuality; |
|
|
|
|
|
|
|
|
|
Camera1(CameraListener callback, PreviewImpl preview) { |
|
|
|
|
super(callback, preview); |
|
|
|
|
preview.setCallback(new PreviewImpl.Callback() { |
|
|
|
@ -192,6 +194,11 @@ public class Camera1 extends CameraImpl { |
|
|
|
|
this.mZoom = zoom; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
void setVideoQuality(int videoQuality) { |
|
|
|
|
this.mVideoQuality = videoQuality; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
void captureImage() { |
|
|
|
|
switch (mMethod) { |
|
|
|
@ -402,7 +409,8 @@ public class Camera1 extends CameraImpl { |
|
|
|
|
|
|
|
|
|
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); |
|
|
|
|
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT); |
|
|
|
|
mMediaRecorder.setProfile(CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_HIGH)); |
|
|
|
|
|
|
|
|
|
mMediaRecorder.setProfile(getCamcorderProfile(mVideoQuality)); |
|
|
|
|
|
|
|
|
|
mVideoFile = new File(mPreview.getView().getContext().getExternalFilesDir(null), "video.mp4"); |
|
|
|
|
mMediaRecorder.setOutputFile(mVideoFile.getAbsolutePath()); |
|
|
|
@ -419,6 +427,53 @@ public class Camera1 extends CameraImpl { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private CamcorderProfile getCamcorderProfile(@VideoQuality int videoQuality) { |
|
|
|
|
CamcorderProfile camcorderProfile = null; |
|
|
|
|
switch (videoQuality) { |
|
|
|
|
case CameraKit.Constants.VIDEO_QUALITY_480P: |
|
|
|
|
if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_480P)) { |
|
|
|
|
camcorderProfile = CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_480P); |
|
|
|
|
} else { |
|
|
|
|
return getCamcorderProfile(CameraKit.Constants.VIDEO_QUALITY_LOWEST); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case CameraKit.Constants.VIDEO_QUALITY_720P: |
|
|
|
|
if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_720P)) { |
|
|
|
|
camcorderProfile = CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_720P); |
|
|
|
|
} else { |
|
|
|
|
return getCamcorderProfile(CameraKit.Constants.VIDEO_QUALITY_480P); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case CameraKit.Constants.VIDEO_QUALITY_1080P: |
|
|
|
|
if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_1080P)) { |
|
|
|
|
camcorderProfile = CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_1080P); |
|
|
|
|
} else { |
|
|
|
|
return getCamcorderProfile(CameraKit.Constants.VIDEO_QUALITY_720P); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case CameraKit.Constants.VIDEO_QUALITY_2160P: |
|
|
|
|
try { |
|
|
|
|
camcorderProfile = CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_2160P); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return getCamcorderProfile(CameraKit.Constants.VIDEO_QUALITY_HIGHEST); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case CameraKit.Constants.VIDEO_QUALITY_HIGHEST: |
|
|
|
|
camcorderProfile = CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_HIGH); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case CameraKit.Constants.VIDEO_QUALITY_LOWEST: |
|
|
|
|
camcorderProfile = CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_LOW); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return camcorderProfile; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void setTapToAutofocusListener(Camera.AutoFocusCallback callback) { |
|
|
|
|
if (this.mFocus != FOCUS_TAP) { |
|
|
|
|
throw new IllegalArgumentException("Please set the camera to FOCUS_TAP."); |
|
|
|
|