Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 876e44df authored by James Dong's avatar James Dong Committed by Android (Google) Code Review
Browse files

Merge "Use video output if necessary for timelapse video recording"

parents 2cdee233 a1d2d8f7
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -182,10 +182,10 @@ private:
    // buffer.
    void fillLastReadBufferCopy(MediaBuffer& sourceBuffer);

    // If the passed in size (width x height) is a supported preview size,
    // the function sets the camera's preview size to it and returns true.
    // If the passed in size (width x height) is a supported video/preview size,
    // the function sets the camera's video/preview size to it and returns true.
    // Otherwise returns false.
    bool trySettingPreviewSize(int32_t width, int32_t height);
    bool trySettingVideoSize(int32_t width, int32_t height);

    // The still camera may not support the demanded video width and height.
    // We look for the supported picture sizes from the still camera and
+19 −9
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ CameraSourceTimeLapse::CameraSourceTimeLapse(
    mVideoWidth = videoSize.width;
    mVideoHeight = videoSize.height;

    if (trySettingPreviewSize(videoSize.width, videoSize.height)) {
    if (trySettingVideoSize(videoSize.width, videoSize.height)) {
        mUseStillCameraForTimeLapse = false;
    } else {
        // TODO: Add a check to see that mTimeBetweenTimeLapseFrameCaptureUs is greater
@@ -115,29 +115,39 @@ void CameraSourceTimeLapse::startQuickReadReturns() {
    }
}

bool CameraSourceTimeLapse::trySettingPreviewSize(int32_t width, int32_t height) {
    LOGV("trySettingPreviewSize: %dx%d", width, height);
bool CameraSourceTimeLapse::trySettingVideoSize(int32_t width, int32_t height) {
    LOGV("trySettingVideoSize: %dx%d", width, height);
    int64_t token = IPCThreadState::self()->clearCallingIdentity();
    String8 s = mCamera->getParameters();

    CameraParameters params(s);
    Vector<Size> supportedSizes;
    params.getSupportedVideoSizes(supportedSizes);
    bool videoOutputSupported = false;
    if (supportedSizes.size() == 0) {
        params.getSupportedPreviewSizes(supportedSizes);
    } else {
        videoOutputSupported = true;
    }

    bool previewSizeSupported = false;
    bool videoSizeSupported = false;
    for (uint32_t i = 0; i < supportedSizes.size(); ++i) {
        int32_t pictureWidth = supportedSizes[i].width;
        int32_t pictureHeight = supportedSizes[i].height;

        if ((pictureWidth == width) && (pictureHeight == height)) {
            previewSizeSupported = true;
            videoSizeSupported = true;
        }
    }

    bool isSuccessful = false;
    if (previewSizeSupported) {
        LOGV("Video size (%d, %d) is a supported preview size", width, height);
    if (videoSizeSupported) {
        LOGV("Video size (%d, %d) is supported", width, height);
        if (videoOutputSupported) {
            params.setVideoSize(width, height);
        } else {
            params.setPreviewSize(width, height);
        }
        if (mCamera->setParameters(params.flatten()) == OK) {
            isSuccessful = true;
        } else {