summaryrefslogtreecommitdiffstats
path: root/media/libmediaplayerservice
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-06-24 19:04:27 -0700
committerJames Dong <jdong@google.com>2010-06-25 16:20:42 -0700
commit09936ed19263854e937198af03d9805a8b669ca1 (patch)
tree42f5150672ab2cdb3ab27c3f19a9a5cec92dc798 /media/libmediaplayerservice
parent1cb3fdc91e1b82a5afe064714a1b530cc05577a7 (diff)
downloadframeworks_base-09936ed19263854e937198af03d9805a8b669ca1.zip
frameworks_base-09936ed19263854e937198af03d9805a8b669ca1.tar.gz
frameworks_base-09936ed19263854e937198af03d9805a8b669ca1.tar.bz2
Provide progress status report during authoring
- Track either the number of A/V frames authored, or the time elapsed - Track the completion of the authoring - Add multiple camera support for authoring by accepting a camera id parameter - Set file type based on the OUTPUT_FORMAT requested Change-Id: I0f9d31b3b7a8fa43eb53f572410fb0ebd4fa0bb7
Diffstat (limited to 'media/libmediaplayerservice')
-rw-r--r--media/libmediaplayerservice/StagefrightRecorder.cpp81
-rw-r--r--media/libmediaplayerservice/StagefrightRecorder.h10
2 files changed, 75 insertions, 16 deletions
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp
index 6834491..1e20f7e 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.cpp
+++ b/media/libmediaplayerservice/StagefrightRecorder.cpp
@@ -310,8 +310,8 @@ status_t StagefrightRecorder::setParamInterleaveDuration(int32_t durationUs) {
// If interval < 0, only the first frame is I frame, and rest are all P frames
// If interval == 0, all frames are encoded as I frames. No P frames
// If interval > 0, it is the time spacing between 2 neighboring I frames
-status_t StagefrightRecorder::setParamIFramesInterval(int32_t interval) {
- LOGV("setParamIFramesInterval: %d seconds", interval);
+status_t StagefrightRecorder::setParamVideoIFramesInterval(int32_t interval) {
+ LOGV("setParamVideoIFramesInterval: %d seconds", interval);
mIFramesInterval = interval;
return OK;
}
@@ -323,6 +323,33 @@ status_t StagefrightRecorder::setParam64BitFileOffset(bool use64Bit) {
return OK;
}
+status_t StagefrightRecorder::setParamVideoCameraId(int32_t cameraId) {
+ LOGV("setParamVideoCameraId: %d", cameraId);
+ if (cameraId < 0) {
+ return BAD_VALUE;
+ }
+ mCameraId = cameraId;
+ return OK;
+}
+
+status_t StagefrightRecorder::setParamTrackFrameStatus(int32_t nFrames) {
+ LOGV("setParamTrackFrameStatus: %d", nFrames);
+ if (nFrames <= 0) {
+ return BAD_VALUE;
+ }
+ mTrackEveryNumberOfFrames = nFrames;
+ return OK;
+}
+
+status_t StagefrightRecorder::setParamTrackTimeStatus(int64_t timeDurationUs) {
+ LOGV("setParamTrackTimeStatus: %lld", timeDurationUs);
+ if (timeDurationUs < 20000) { // Infeasible if shorter than 20 ms?
+ return BAD_VALUE;
+ }
+ mTrackEveryTimeDurationUs = timeDurationUs;
+ return OK;
+}
+
status_t StagefrightRecorder::setParameter(
const String8 &key, const String8 &value) {
LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string());
@@ -338,6 +365,26 @@ status_t StagefrightRecorder::setParameter(
return setParamMaxDurationOrFileSize(
max_filesize_bytes, false /* limit is filesize */);
}
+ } else if (key == "interleave-duration-us") {
+ int32_t durationUs;
+ if (safe_strtoi32(value.string(), &durationUs)) {
+ return setParamInterleaveDuration(durationUs);
+ }
+ } else if (key == "param-use-64bit-offset") {
+ int32_t use64BitOffset;
+ if (safe_strtoi32(value.string(), &use64BitOffset)) {
+ return setParam64BitFileOffset(use64BitOffset != 0);
+ }
+ } else if (key == "param-track-frame-status") {
+ int32_t nFrames;
+ if (safe_strtoi32(value.string(), &nFrames)) {
+ return setParamTrackFrameStatus(nFrames);
+ }
+ } else if (key == "param-track-time-status") {
+ int64_t timeDurationUs;
+ if (safe_strtoi64(value.string(), &timeDurationUs)) {
+ return setParamTrackTimeStatus(timeDurationUs);
+ }
} else if (key == "audio-param-sampling-rate") {
int32_t sampling_rate;
if (safe_strtoi32(value.string(), &sampling_rate)) {
@@ -358,20 +405,15 @@ status_t StagefrightRecorder::setParameter(
if (safe_strtoi32(value.string(), &video_bitrate)) {
return setParamVideoEncodingBitRate(video_bitrate);
}
- } else if (key == "param-interleave-duration-us") {
- int32_t durationUs;
- if (safe_strtoi32(value.string(), &durationUs)) {
- return setParamInterleaveDuration(durationUs);
- }
- } else if (key == "param-i-frames-interval") {
+ } else if (key == "video-param-i-frames-interval") {
int32_t interval;
if (safe_strtoi32(value.string(), &interval)) {
- return setParamIFramesInterval(interval);
+ return setParamVideoIFramesInterval(interval);
}
- } else if (key == "param-use-64bit-offset") {
- int32_t use64BitOffset;
- if (safe_strtoi32(value.string(), &use64BitOffset)) {
- return setParam64BitFileOffset(use64BitOffset != 0);
+ } else if (key == "video-param-camera-id") {
+ int32_t cameraId;
+ if (safe_strtoi32(value.string(), &cameraId)) {
+ return setParamVideoCameraId(cameraId);
}
} else {
LOGE("setParameter: failed to find key %s", key.string());
@@ -677,7 +719,7 @@ status_t StagefrightRecorder::startMPEG4Recording() {
int64_t token = IPCThreadState::self()->clearCallingIdentity();
if (mCamera == 0) {
- mCamera = Camera::connect(0);
+ mCamera = Camera::connect(mCameraId);
mCamera->lock();
}
@@ -778,8 +820,16 @@ status_t StagefrightRecorder::startMPEG4Recording() {
}
mWriter->setListener(mListener);
sp<MetaData> meta = new MetaData;
+ meta->setInt64(kKeyTime, systemTime() / 1000);
+ meta->setInt32(kKeyFileType, mOutputFormat);
meta->setInt32(kKeyBitRate, totalBitRate);
meta->setInt32(kKey64BitFileOffset, mUse64BitFileOffset);
+ if (mTrackEveryNumberOfFrames > 0) {
+ meta->setInt32(kKeyTrackFrameStatus, mTrackEveryNumberOfFrames);
+ }
+ if (mTrackEveryTimeDurationUs > 0) {
+ meta->setInt64(kKeyTrackTimeStatus, mTrackEveryTimeDurationUs);
+ }
mWriter->start(meta.get());
return OK;
}
@@ -842,6 +892,9 @@ status_t StagefrightRecorder::reset() {
mIFramesInterval = 1;
mAudioSourceNode = 0;
mUse64BitFileOffset = false;
+ mCameraId = 0;
+ mTrackEveryNumberOfFrames = 0;
+ mTrackEveryTimeDurationUs = 0;
mEncoderProfiles = MediaProfiles::getInstance();
mOutputFd = -1;
diff --git a/media/libmediaplayerservice/StagefrightRecorder.h b/media/libmediaplayerservice/StagefrightRecorder.h
index 2943e97..9fb7e8f 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.h
+++ b/media/libmediaplayerservice/StagefrightRecorder.h
@@ -81,8 +81,11 @@ private:
int32_t mSampleRate;
int32_t mInterleaveDurationUs;
int32_t mIFramesInterval;
+ int32_t mCameraId;
int64_t mMaxFileSizeBytes;
int64_t mMaxFileDurationUs;
+ int32_t mTrackEveryNumberOfFrames;
+ int64_t mTrackEveryTimeDurationUs;
String8 mParams;
int mOutputFd;
@@ -95,12 +98,15 @@ private:
status_t startAACRecording();
sp<MediaSource> createAudioSource();
status_t setParameter(const String8 &key, const String8 &value);
- status_t setParamVideoEncodingBitRate(int32_t bitRate);
status_t setParamAudioEncodingBitRate(int32_t bitRate);
status_t setParamAudioNumberOfChannels(int32_t channles);
status_t setParamAudioSamplingRate(int32_t sampleRate);
+ status_t setParamVideoEncodingBitRate(int32_t bitRate);
+ status_t setParamVideoIFramesInterval(int32_t interval);
+ status_t setParamVideoCameraId(int32_t cameraId);
+ status_t setParamTrackTimeStatus(int64_t timeDurationUs);
+ status_t setParamTrackFrameStatus(int32_t nFrames);
status_t setParamInterleaveDuration(int32_t durationUs);
- status_t setParamIFramesInterval(int32_t interval);
status_t setParam64BitFileOffset(bool use64BitFileOffset);
status_t setParamMaxDurationOrFileSize(int64_t limit, bool limit_is_duration);
void clipVideoBitRate();