diff options
author | Chong Zhang <chz@google.com> | 2014-09-08 18:55:34 -0700 |
---|---|---|
committer | Chong Zhang <chz@google.com> | 2014-09-11 12:13:09 -0700 |
commit | 54ef1bae010f12dfe6a40ff4452695b1b11ff449 (patch) | |
tree | b558274fe2e0db696df99145d37becb520e97a85 /media/libmediaplayerservice | |
parent | e4c8b32f1123aa639f46d234203ad5c5e7926628 (diff) | |
download | frameworks_av-54ef1bae010f12dfe6a40ff4452695b1b11ff449.zip frameworks_av-54ef1bae010f12dfe6a40ff4452695b1b11ff449.tar.gz frameworks_av-54ef1bae010f12dfe6a40ff4452695b1b11ff449.tar.bz2 |
StagefrightRecorder: default to codec and fps from camcorder low profile
Bug: 16870964
Change-Id: I18425af630d3f041a3bcf77fbae3f07856fe8af2
Diffstat (limited to 'media/libmediaplayerservice')
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.cpp | 38 | ||||
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.h | 1 |
2 files changed, 33 insertions, 6 deletions
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index e2bcb1e..b904aa8 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -183,11 +183,7 @@ status_t StagefrightRecorder::setVideoEncoder(video_encoder ve) { return BAD_VALUE; } - if (ve == VIDEO_ENCODER_DEFAULT) { - mVideoEncoder = VIDEO_ENCODER_H263; - } else { - mVideoEncoder = ve; - } + mVideoEncoder = ve; return OK; } @@ -1033,6 +1029,7 @@ status_t StagefrightRecorder::setupRTPRecording() { if (mAudioSource != AUDIO_SOURCE_CNT) { source = createAudioSource(); } else { + setDefaultVideoEncoderIfNecessary(); sp<MediaSource> mediaSource; status_t err = setupMediaSource(&mediaSource); @@ -1074,6 +1071,7 @@ status_t StagefrightRecorder::setupMPEG2TSRecording() { if (mVideoSource < VIDEO_SOURCE_LIST_END) { if (mVideoEncoder != VIDEO_ENCODER_H264) { + ALOGE("MPEG2TS recording only supports H.264 encoding!"); return ERROR_UNSUPPORTED; } @@ -1108,6 +1106,12 @@ status_t StagefrightRecorder::setupMPEG2TSRecording() { void StagefrightRecorder::clipVideoFrameRate() { ALOGV("clipVideoFrameRate: encoder %d", mVideoEncoder); + if (mFrameRate == -1) { + mFrameRate = mEncoderProfiles->getCamcorderProfileParamByName( + "vid.fps", mCameraId, CAMCORDER_QUALITY_LOW); + ALOGW("Using default video fps %d", mFrameRate); + } + int minFrameRate = mEncoderProfiles->getVideoEncoderParamByName( "enc.vid.fps.min", mVideoEncoder); int maxFrameRate = mEncoderProfiles->getVideoEncoderParamByName( @@ -1243,6 +1247,27 @@ void StagefrightRecorder::setDefaultProfileIfNecessary() { } } +void StagefrightRecorder::setDefaultVideoEncoderIfNecessary() { + if (mVideoEncoder == VIDEO_ENCODER_DEFAULT) { + if (mOutputFormat == OUTPUT_FORMAT_WEBM) { + // default to VP8 for WEBM recording + mVideoEncoder = VIDEO_ENCODER_VP8; + } else { + // pick the default encoder for CAMCORDER_QUALITY_LOW + int videoCodec = mEncoderProfiles->getCamcorderProfileParamByName( + "vid.codec", mCameraId, CAMCORDER_QUALITY_LOW); + + if (videoCodec > VIDEO_ENCODER_DEFAULT && + videoCodec < VIDEO_ENCODER_LIST_END) { + mVideoEncoder = (video_encoder)videoCodec; + } else { + // default to H.264 if camcorder profile not available + mVideoEncoder = VIDEO_ENCODER_H264; + } + } + } +} + status_t StagefrightRecorder::checkAudioEncoderCapabilities() { clipAudioBitRate(); clipAudioSampleRate(); @@ -1562,6 +1587,7 @@ status_t StagefrightRecorder::setupMPEG4orWEBMRecording() { } if (mVideoSource < VIDEO_SOURCE_LIST_END) { + setDefaultVideoEncoderIfNecessary(); sp<MediaSource> mediaSource; err = setupMediaSource(&mediaSource); @@ -1721,7 +1747,7 @@ status_t StagefrightRecorder::reset() { // Default parameters mOutputFormat = OUTPUT_FORMAT_THREE_GPP; mAudioEncoder = AUDIO_ENCODER_AMR_NB; - mVideoEncoder = VIDEO_ENCODER_H263; + mVideoEncoder = VIDEO_ENCODER_DEFAULT; mVideoWidth = 176; mVideoHeight = 144; mFrameRate = -1; diff --git a/media/libmediaplayerservice/StagefrightRecorder.h b/media/libmediaplayerservice/StagefrightRecorder.h index 9062f30..54c38d3 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.h +++ b/media/libmediaplayerservice/StagefrightRecorder.h @@ -178,6 +178,7 @@ private: void clipAudioSampleRate(); void clipNumberOfAudioChannels(); void setDefaultProfileIfNecessary(); + void setDefaultVideoEncoderIfNecessary(); StagefrightRecorder(const StagefrightRecorder &); |