use of android.media.CamcorderProfile in project android-aosp-mms by slvn.
the class MessageUtils method getVideoCaptureDurationLimit.
// Public for until tests
public static int getVideoCaptureDurationLimit(long bytesAvailable) {
CamcorderProfile camcorder = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
if (camcorder == null) {
return 0;
}
// convert to bits
bytesAvailable *= 8;
long seconds = bytesAvailable / (camcorder.audioBitRate + camcorder.videoBitRate);
// Find the best match for one of the fixed durations
for (int i = sVideoDuration.length - 1; i >= 0; i--) {
if (seconds >= sVideoDuration[i]) {
return sVideoDuration[i];
}
}
return 0;
}
use of android.media.CamcorderProfile in project react-native-camera by react-native-community.
the class RCTCamera method setCaptureVideoQuality.
public CamcorderProfile setCaptureVideoQuality(int cameraType, String captureQuality) {
Camera camera = this.acquireCameraInstance(cameraType);
if (camera == null) {
return null;
}
Camera.Size videoSize = null;
List<Camera.Size> supportedSizes = getSupportedVideoSizes(camera);
CamcorderProfile cm = null;
switch(captureQuality) {
case RCTCameraModule.RCT_CAMERA_CAPTURE_QUALITY_LOW:
videoSize = getSmallestSize(supportedSizes);
cm = CamcorderProfile.get(_cameraTypeToIndex.get(cameraType), CamcorderProfile.QUALITY_480P);
break;
case RCTCameraModule.RCT_CAMERA_CAPTURE_QUALITY_MEDIUM:
videoSize = supportedSizes.get(supportedSizes.size() / 2);
cm = CamcorderProfile.get(_cameraTypeToIndex.get(cameraType), CamcorderProfile.QUALITY_720P);
break;
case RCTCameraModule.RCT_CAMERA_CAPTURE_QUALITY_HIGH:
videoSize = getBestSize(supportedSizes, Integer.MAX_VALUE, Integer.MAX_VALUE);
cm = CamcorderProfile.get(_cameraTypeToIndex.get(cameraType), CamcorderProfile.QUALITY_HIGH);
break;
case RCTCameraModule.RCT_CAMERA_CAPTURE_QUALITY_480P:
videoSize = getBestSize(supportedSizes, RESOLUTION_480P.width, RESOLUTION_480P.height);
cm = CamcorderProfile.get(_cameraTypeToIndex.get(cameraType), CamcorderProfile.QUALITY_480P);
break;
case RCTCameraModule.RCT_CAMERA_CAPTURE_QUALITY_720P:
videoSize = getBestSize(supportedSizes, RESOLUTION_720P.width, RESOLUTION_720P.height);
cm = CamcorderProfile.get(_cameraTypeToIndex.get(cameraType), CamcorderProfile.QUALITY_720P);
break;
case RCTCameraModule.RCT_CAMERA_CAPTURE_QUALITY_1080P:
videoSize = getBestSize(supportedSizes, RESOLUTION_1080P.width, RESOLUTION_1080P.height);
cm = CamcorderProfile.get(_cameraTypeToIndex.get(cameraType), CamcorderProfile.QUALITY_1080P);
break;
}
if (cm == null) {
return null;
}
if (videoSize != null) {
cm.videoFrameHeight = videoSize.height;
cm.videoFrameWidth = videoSize.width;
}
return cm;
}
Aggregations