From 5b6edb79827a910d8e677e35e77bc12fdc7772b9 Mon Sep 17 00:00:00 2001 From: James Dong Date: Wed, 3 Nov 2010 17:27:58 -0700 Subject: Support rotation in media recorder o needs to be tested with camera hal and camcorder application Change-Id: Ie343185c8ad3ec55da8850efbdcf19cf98993232 --- .../libmediaplayerservice/StagefrightRecorder.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'media/libmediaplayerservice/StagefrightRecorder.cpp') diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index d37d83d..50d7f6d 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -462,6 +462,17 @@ status_t StagefrightRecorder::setParamVideoTimeScale(int32_t timeScale) { return OK; } +status_t StagefrightRecorder::setParamVideoRotation(int32_t degreesClockwise) { + LOGV("setParamVideoRotation: %d", degreesClockwise); + + if (degreesClockwise < 0 || degreesClockwise % 90 != 0) { + LOGE("Unsupported video rotation angle: %d", degreesClockwise); + return BAD_VALUE; + } + mClockwiseRotationDegrees = degreesClockwise; + return OK; +} + status_t StagefrightRecorder::setParamAudioTimeScale(int32_t timeScale) { LOGV("setParamAudioTimeScale: %d", timeScale); @@ -557,6 +568,11 @@ status_t StagefrightRecorder::setParameter( if (safe_strtoi32(value.string(), &timeScale)) { return setParamVideoTimeScale(timeScale); } + } else if (key == "video-param-clockwise-rotation-degrees") { + int32_t degrees; + if (safe_strtoi32(value.string(), °rees)) { + return setParamVideoRotation(degrees); + } } else { LOGE("setParameter: failed to find key %s", key.string()); } @@ -921,6 +937,12 @@ status_t StagefrightRecorder::setupCameraSource() { CameraParameters params(mCamera->getParameters()); params.setPreviewSize(mVideoWidth, mVideoHeight); params.setPreviewFrameRate(mFrameRate); + { + // Optional feature: setting the rotation degrees. + char degrees[4]; + snprintf(degrees, 4, "%d", mClockwiseRotationDegrees); + params.set(CameraParameters::KEY_ROTATION, degrees); + } String8 s = params.flatten(); if (OK != mCamera->setParameters(s)) { LOGE("Could not change settings." @@ -1188,6 +1210,7 @@ status_t StagefrightRecorder::reset() { mMaxFileSizeBytes = 0; mTrackEveryTimeDurationUs = 0; mEncoderProfiles = MediaProfiles::getInstance(); + mClockwiseRotationDegrees = 0; mOutputFd = -1; mFlags = 0; @@ -1261,6 +1284,8 @@ status_t StagefrightRecorder::dump( result.append(buffer); snprintf(buffer, SIZE, " Camera flags: %d\n", mFlags); result.append(buffer); + snprintf(buffer, SIZE, " Rotation (clockwise) degrees: %d\n", mClockwiseRotationDegrees); + result.append(buffer); snprintf(buffer, SIZE, " Encoder: %d\n", mVideoEncoder); result.append(buffer); snprintf(buffer, SIZE, " Encoder profile: %d\n", mVideoEncoderProfile); -- cgit v1.1