Search in sources :

Example 56 with CamcorderProfile

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;
}
Also used : CamcorderProfile(android.media.CamcorderProfile)

Example 57 with CamcorderProfile

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;
}
Also used : CamcorderProfile(android.media.CamcorderProfile) Camera(android.hardware.Camera)

Aggregations

CamcorderProfile (android.media.CamcorderProfile)57 MediaRecorder (android.media.MediaRecorder)21 IOException (java.io.IOException)17 Size (android.util.Size)15 SimpleCaptureCallback (com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleCaptureCallback)15 Point (android.graphics.Point)13 SurfaceHolder (android.view.SurfaceHolder)13 MediaPlayer (android.media.MediaPlayer)12 CaptureRequest (android.hardware.camera2.CaptureRequest)10 Range (android.util.Range)10 SimpleImageReaderListener (com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleImageReaderListener)10 ArrayList (java.util.ArrayList)10 Paint (android.graphics.Paint)7 LargeTest (android.test.suitebuilder.annotation.LargeTest)6 Camera (android.hardware.Camera)5 Image (android.media.Image)5 AssertionFailedError (junit.framework.AssertionFailedError)5 Activity (android.app.Activity)3 SuppressLint (android.annotation.SuppressLint)2 Uri (android.net.Uri)2