am c181a082: Merge "Support rotation in media recorder" into gingerbread
* commit 'c181a08209dc85c80e4da5d20cd3980998def40d': Support rotation in media recorder
This commit is contained in:
@@ -284,6 +284,18 @@ public class MediaRecorder
|
|||||||
setAudioEncoder(profile.audioCodec);
|
setAudioEncoder(profile.audioCodec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the rotation degrees for the video recording. This method should be called
|
||||||
|
* before start().
|
||||||
|
*
|
||||||
|
* @param degrees the angle to be rotated clockwise.
|
||||||
|
*
|
||||||
|
* {@hide}
|
||||||
|
*/
|
||||||
|
public void setClockwiseRotation(int degrees) {
|
||||||
|
setParameter(String.format("video-param-clockwise-rotation-degrees=%d", degrees));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the format of the output file produced during recording. Call this
|
* Sets the format of the output file produced during recording. Call this
|
||||||
* after setAudioSource()/setVideoSource() but before prepare().
|
* after setAudioSource()/setVideoSource() but before prepare().
|
||||||
|
|||||||
@@ -462,6 +462,17 @@ status_t StagefrightRecorder::setParamVideoTimeScale(int32_t timeScale) {
|
|||||||
return OK;
|
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) {
|
status_t StagefrightRecorder::setParamAudioTimeScale(int32_t timeScale) {
|
||||||
LOGV("setParamAudioTimeScale: %d", timeScale);
|
LOGV("setParamAudioTimeScale: %d", timeScale);
|
||||||
|
|
||||||
@@ -557,6 +568,11 @@ status_t StagefrightRecorder::setParameter(
|
|||||||
if (safe_strtoi32(value.string(), &timeScale)) {
|
if (safe_strtoi32(value.string(), &timeScale)) {
|
||||||
return setParamVideoTimeScale(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 {
|
} else {
|
||||||
LOGE("setParameter: failed to find key %s", key.string());
|
LOGE("setParameter: failed to find key %s", key.string());
|
||||||
}
|
}
|
||||||
@@ -921,6 +937,12 @@ status_t StagefrightRecorder::setupCameraSource() {
|
|||||||
CameraParameters params(mCamera->getParameters());
|
CameraParameters params(mCamera->getParameters());
|
||||||
params.setPreviewSize(mVideoWidth, mVideoHeight);
|
params.setPreviewSize(mVideoWidth, mVideoHeight);
|
||||||
params.setPreviewFrameRate(mFrameRate);
|
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();
|
String8 s = params.flatten();
|
||||||
if (OK != mCamera->setParameters(s)) {
|
if (OK != mCamera->setParameters(s)) {
|
||||||
LOGE("Could not change settings."
|
LOGE("Could not change settings."
|
||||||
@@ -1188,6 +1210,7 @@ status_t StagefrightRecorder::reset() {
|
|||||||
mMaxFileSizeBytes = 0;
|
mMaxFileSizeBytes = 0;
|
||||||
mTrackEveryTimeDurationUs = 0;
|
mTrackEveryTimeDurationUs = 0;
|
||||||
mEncoderProfiles = MediaProfiles::getInstance();
|
mEncoderProfiles = MediaProfiles::getInstance();
|
||||||
|
mClockwiseRotationDegrees = 0;
|
||||||
|
|
||||||
mOutputFd = -1;
|
mOutputFd = -1;
|
||||||
mFlags = 0;
|
mFlags = 0;
|
||||||
@@ -1261,6 +1284,8 @@ status_t StagefrightRecorder::dump(
|
|||||||
result.append(buffer);
|
result.append(buffer);
|
||||||
snprintf(buffer, SIZE, " Camera flags: %d\n", mFlags);
|
snprintf(buffer, SIZE, " Camera flags: %d\n", mFlags);
|
||||||
result.append(buffer);
|
result.append(buffer);
|
||||||
|
snprintf(buffer, SIZE, " Rotation (clockwise) degrees: %d\n", mClockwiseRotationDegrees);
|
||||||
|
result.append(buffer);
|
||||||
snprintf(buffer, SIZE, " Encoder: %d\n", mVideoEncoder);
|
snprintf(buffer, SIZE, " Encoder: %d\n", mVideoEncoder);
|
||||||
result.append(buffer);
|
result.append(buffer);
|
||||||
snprintf(buffer, SIZE, " Encoder profile: %d\n", mVideoEncoderProfile);
|
snprintf(buffer, SIZE, " Encoder profile: %d\n", mVideoEncoderProfile);
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ private:
|
|||||||
int64_t mMaxFileSizeBytes;
|
int64_t mMaxFileSizeBytes;
|
||||||
int64_t mMaxFileDurationUs;
|
int64_t mMaxFileDurationUs;
|
||||||
int64_t mTrackEveryTimeDurationUs;
|
int64_t mTrackEveryTimeDurationUs;
|
||||||
|
int32_t mClockwiseRotationDegrees;
|
||||||
|
|
||||||
String8 mParams;
|
String8 mParams;
|
||||||
int mOutputFd;
|
int mOutputFd;
|
||||||
@@ -120,6 +121,7 @@ private:
|
|||||||
status_t setParamVideoEncoderLevel(int32_t level);
|
status_t setParamVideoEncoderLevel(int32_t level);
|
||||||
status_t setParamVideoCameraId(int32_t cameraId);
|
status_t setParamVideoCameraId(int32_t cameraId);
|
||||||
status_t setParamVideoTimeScale(int32_t timeScale);
|
status_t setParamVideoTimeScale(int32_t timeScale);
|
||||||
|
status_t setParamVideoRotation(int32_t degreesClockwise);
|
||||||
status_t setParamTrackTimeStatus(int64_t timeDurationUs);
|
status_t setParamTrackTimeStatus(int64_t timeDurationUs);
|
||||||
status_t setParamInterleaveDuration(int32_t durationUs);
|
status_t setParamInterleaveDuration(int32_t durationUs);
|
||||||
status_t setParam64BitFileOffset(bool use64BitFileOffset);
|
status_t setParam64BitFileOffset(bool use64BitFileOffset);
|
||||||
|
|||||||
Reference in New Issue
Block a user