diff options
author | Nipun Kwatra <nkwatra@google.com> | 2010-07-20 21:33:31 -0700 |
---|---|---|
committer | Nipun Kwatra <nkwatra@google.com> | 2010-07-22 17:02:12 -0700 |
commit | e4e0a6994d39c4a7cba09c5fff442b2dca1df8f8 (patch) | |
tree | 545e3cbc6bbd5c6b78a5adb2d00eeb5b16abb6a4 /media/libmediaplayerservice | |
parent | 55cb2b8319e6b36e88658de121c534e95cd240b4 (diff) | |
download | frameworks_av-e4e0a6994d39c4a7cba09c5fff442b2dca1df8f8.zip frameworks_av-e4e0a6994d39c4a7cba09c5fff442b2dca1df8f8.tar.gz frameworks_av-e4e0a6994d39c4a7cba09c5fff442b2dca1df8f8.tar.bz2 |
Allowing setting of time lapse parameters through MediaRecorder.java
added setTimeLapseParameters() to MediaRecorder.java and SetParameter support
in StagefrightRecorder to allow enabling time lapse and setting the corresponding
parameters.
Change-Id: I509040aa71f8d3fc37337b0894a81d9c0fd7a40a
Diffstat (limited to 'media/libmediaplayerservice')
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.cpp | 67 | ||||
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.h | 3 |
2 files changed, 62 insertions, 8 deletions
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index 3dbcfd5..f747f90 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -473,6 +473,32 @@ status_t StagefrightRecorder::setParamAudioTimeScale(int32_t timeScale) { return OK; } +status_t StagefrightRecorder::setParamTimeLapseEnable(int32_t timeLapseEnable) { + LOGV("setParamTimeLapseEnable: %d", timeLapseEnable); + + if(timeLapseEnable == 0) { + mCaptureTimeLapse = false; + } else if (timeLapseEnable == 1) { + mCaptureTimeLapse = true; + } else { + return BAD_VALUE; + } + return OK; +} + +status_t StagefrightRecorder::setParamTimeBetweenTimeLapseFrameCapture(int64_t timeUs) { + LOGV("setParamTimeBetweenTimeLapseFrameCapture: %lld us", timeUs); + + // Not allowing time more than a day + if (timeUs <= 0 || timeUs > 86400*1E6) { + LOGE("Time between time lapse frame capture (%lld) is out of range [0, 1 Day]", timeUs); + return BAD_VALUE; + } + + mTimeBetweenTimeLapseFrameCaptureUs = timeUs; + return OK; +} + status_t StagefrightRecorder::setParameter( const String8 &key, const String8 &value) { LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string()); @@ -556,6 +582,17 @@ status_t StagefrightRecorder::setParameter( if (safe_strtoi32(value.string(), &timeScale)) { return setParamVideoTimeScale(timeScale); } + } else if (key == "time-lapse-enable") { + int32_t timeLapseEnable; + if (safe_strtoi32(value.string(), &timeLapseEnable)) { + return setParamTimeLapseEnable(timeLapseEnable); + } + } else if (key == "time-between-time-lapse-frame-capture") { + int64_t timeBetweenTimeLapseFrameCaptureMs; + if (safe_strtoi64(value.string(), &timeBetweenTimeLapseFrameCaptureMs)) { + return setParamTimeBetweenTimeLapseFrameCapture( + 1000LL * timeBetweenTimeLapseFrameCaptureMs); + } } else { LOGE("setParameter: failed to find key %s", key.string()); } @@ -813,10 +850,14 @@ void StagefrightRecorder::clipVideoFrameWidth() { } status_t StagefrightRecorder::setupCameraSource() { - clipVideoBitRate(); - clipVideoFrameRate(); - clipVideoFrameWidth(); - clipVideoFrameHeight(); + if(!mCaptureTimeLapse) { + // Dont clip for time lapse capture as encoder will have enough + // time to encode because of slow capture rate of time lapse. + clipVideoBitRate(); + clipVideoFrameRate(); + clipVideoFrameWidth(); + clipVideoFrameHeight(); + } int64_t token = IPCThreadState::self()->clearCallingIdentity(); if (mCamera == 0) { @@ -831,7 +872,13 @@ status_t StagefrightRecorder::setupCameraSource() { // Set the actual video recording frame size CameraParameters params(mCamera->getParameters()); - params.setPreviewSize(mVideoWidth, mVideoHeight); + + // dont change the preview size for time lapse as mVideoWidth, mVideoHeight + // may correspond to HD resolution not supported by video camera. + if (!mCaptureTimeLapse) { + params.setPreviewSize(mVideoWidth, mVideoHeight); + } + params.setPreviewFrameRate(mFrameRate); String8 s = params.flatten(); CHECK_EQ(OK, mCamera->setParameters(s)); @@ -840,8 +887,9 @@ status_t StagefrightRecorder::setupCameraSource() { // Check on video frame size int frameWidth = 0, frameHeight = 0; newCameraParams.getPreviewSize(&frameWidth, &frameHeight); - if (frameWidth < 0 || frameWidth != mVideoWidth || - frameHeight < 0 || frameHeight != mVideoHeight) { + if (!mCaptureTimeLapse && + (frameWidth < 0 || frameWidth != mVideoWidth || + frameHeight < 0 || frameHeight != mVideoHeight)) { LOGE("Failed to set the video frame size to %dx%d", mVideoWidth, mVideoHeight); IPCThreadState::self()->restoreCallingIdentity(token); @@ -882,7 +930,8 @@ status_t StagefrightRecorder::setupVideoEncoder(const sp<MediaWriter>& writer) { if (err != OK) return err; sp<CameraSource> cameraSource = (mCaptureTimeLapse) ? - CameraSourceTimeLapse::CreateFromCamera(mCamera, true, 3E6, mFrameRate): + CameraSourceTimeLapse::CreateFromCamera(mCamera, true, + mTimeBetweenTimeLapseFrameCaptureUs, mVideoWidth, mVideoHeight, mFrameRate): CameraSource::CreateFromCamera(mCamera); CHECK(cameraSource != NULL); @@ -934,6 +983,7 @@ status_t StagefrightRecorder::setupVideoEncoder(const sp<MediaWriter>& writer) { OMXClient client; CHECK_EQ(client.connect(), OK); + // Use software codec for time lapse uint32_t encoder_flags = (mCaptureTimeLapse) ? OMXCodec::kPreferSoftwareCodecs : 0; sp<MediaSource> encoder = OMXCodec::Create( client.interface(), enc_meta, @@ -1081,6 +1131,7 @@ status_t StagefrightRecorder::reset() { mMaxFileSizeBytes = 0; mTrackEveryTimeDurationUs = 0; mCaptureTimeLapse = false; + mTimeBetweenTimeLapseFrameCaptureUs = -1; mEncoderProfiles = MediaProfiles::getInstance(); mOutputFd = -1; diff --git a/media/libmediaplayerservice/StagefrightRecorder.h b/media/libmediaplayerservice/StagefrightRecorder.h index 232fc0e..fc287a2 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.h +++ b/media/libmediaplayerservice/StagefrightRecorder.h @@ -93,6 +93,7 @@ private: int64_t mTrackEveryTimeDurationUs; bool mCaptureTimeLapse; + int64_t mTimeBetweenTimeLapseFrameCaptureUs; String8 mParams; int mOutputFd; @@ -114,6 +115,8 @@ private: status_t setParamAudioNumberOfChannels(int32_t channles); status_t setParamAudioSamplingRate(int32_t sampleRate); status_t setParamAudioTimeScale(int32_t timeScale); + status_t setParamTimeLapseEnable(int32_t timeLapseEnable); + status_t setParamTimeBetweenTimeLapseFrameCapture(int64_t timeUs); status_t setParamVideoEncodingBitRate(int32_t bitRate); status_t setParamVideoIFramesInterval(int32_t seconds); status_t setParamVideoEncoderProfile(int32_t profile); |