Loading include/media/stagefright/MetaData.h +7 −4 Original line number Diff line number Diff line Loading @@ -30,10 +30,13 @@ namespace android { // The following keys map to int32_t data unless indicated otherwise. enum { kKeyMIMEType = 'mime', // cstring kKeyWidth = 'widt', kKeyHeight = 'heig', kKeyChannelCount = '#chn', kKeySampleRate = 'srte', kKeyWidth = 'widt', // int32_t kKeyHeight = 'heig', // int32_t kKeyIFramesInterval = 'ifiv', // int32_t kKeyStride = 'strd', // int32_t kKeySliceHeight = 'slht', // int32_t kKeyChannelCount = '#chn', // int32_t kKeySampleRate = 'srte', // int32_t kKeyBitRate = 'brte', // int32_t (bps) kKeyESDS = 'esds', // raw data kKeyAVCC = 'avcc', // raw data Loading include/media/stagefright/OMXCodec.h +3 −4 Original line number Diff line number Diff line Loading @@ -166,11 +166,10 @@ private: OMX_COLOR_FORMATTYPE colorFormat); void setVideoInputFormat( const char *mime, OMX_U32 width, OMX_U32 height, OMX_U32 frameRate, OMX_U32 bitRate); const char *mime, const sp<MetaData>& meta); status_t setupMPEG4EncoderParameters(); status_t setupAVCEncoderParameters(); status_t setupMPEG4EncoderParameters(const sp<MetaData>& meta); status_t setupAVCEncoderParameters(const sp<MetaData>& meta); status_t setVideoOutputFormat( const char *mime, OMX_U32 width, OMX_U32 height); Loading media/libmediaplayerservice/StagefrightRecorder.cpp +31 −2 Original line number Diff line number Diff line Loading @@ -287,14 +287,32 @@ status_t StagefrightRecorder::setParamMaxDurationOrFileSize(int64_t limit, status_t StagefrightRecorder::setParamInterleaveDuration(int32_t durationUs) { LOGV("setParamInterleaveDuration: %d", durationUs); if (durationUs <= 20000) { // XXX: 20 ms if (durationUs <= 500000) { // 500 ms // If interleave duration is too small, it is very inefficient to do // interleaving since the metadata overhead will count for a significant // portion of the saved contents LOGE("Audio/video interleave duration is too small: %d us", durationUs); return BAD_VALUE; } else if (durationUs >= 10000000) { // 10 seconds // If interleaving duration is too large, it can cause the recording // session to use too much memory since we have to save the output // data before we write them out LOGE("Audio/video interleave duration is too large: %d us", durationUs); return BAD_VALUE; } mInterleaveDurationUs = durationUs; return OK; } // 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); mIFramesInterval = interval; return OK; } status_t StagefrightRecorder::setParameter( const String8 &key, const String8 &value) { LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string()); Loading Loading @@ -335,6 +353,11 @@ status_t StagefrightRecorder::setParameter( if (safe_strtoi32(value.string(), &durationUs)) { return setParamInterleaveDuration(durationUs); } } else if (key == "param-i-frames-interval") { int32_t interval; if (safe_strtoi32(value.string(), &interval)) { return setParamIFramesInterval(interval); } } else { LOGE("setParameter: failed to find key %s", key.string()); } Loading Loading @@ -619,12 +642,17 @@ status_t StagefrightRecorder::startMPEG4Recording() { sp<MetaData> meta = cameraSource->getFormat(); int32_t width, height; int32_t width, height, stride, sliceHeight; CHECK(meta->findInt32(kKeyWidth, &width)); CHECK(meta->findInt32(kKeyHeight, &height)); CHECK(meta->findInt32(kKeyStride, &stride)); CHECK(meta->findInt32(kKeySliceHeight, &sliceHeight)); enc_meta->setInt32(kKeyWidth, width); enc_meta->setInt32(kKeyHeight, height); enc_meta->setInt32(kKeyIFramesInterval, mIFramesInterval); enc_meta->setInt32(kKeyStride, stride); enc_meta->setInt32(kKeySliceHeight, sliceHeight); OMXClient client; CHECK_EQ(client.connect(), OK); Loading Loading @@ -702,6 +730,7 @@ status_t StagefrightRecorder::reset() { mAudioChannels = 1; mAudioBitRate = 12200; mInterleaveDurationUs = 0; mIFramesInterval = 1; mOutputFd = -1; mFlags = 0; Loading media/libmediaplayerservice/StagefrightRecorder.h +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ private: int32_t mAudioChannels; int32_t mSampleRate; int32_t mInterleaveDurationUs; int32_t mIFramesInterval; int64_t mMaxFileSizeBytes; int64_t mMaxFileDurationUs; Loading @@ -92,6 +93,7 @@ private: status_t setParamAudioNumberOfChannels(int32_t channles); status_t setParamAudioSamplingRate(int32_t sampleRate); status_t setParamInterleaveDuration(int32_t durationUs); status_t setParamIFramesInterval(int32_t interval); status_t setParamMaxDurationOrFileSize(int64_t limit, bool limit_is_duration); StagefrightRecorder(const StagefrightRecorder &); Loading media/libstagefright/CameraSource.cpp +9 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ CameraSource::CameraSource(const sp<Camera> &camera) String8 s = mCamera->getParameters(); printf("params: \"%s\"\n", s.string()); int32_t width, height; int32_t width, height, stride, sliceHeight; CameraParameters params(s); params.getPreviewSize(&width, &height); Loading @@ -136,11 +136,19 @@ CameraSource::CameraSource(const sp<Camera> &camera) CHECK(colorFormatStr != NULL); int32_t colorFormat = getColorFormat(colorFormatStr); // XXX: query camera for the stride and slice height // when the capability becomes available. stride = width; sliceHeight = height; mMeta = new MetaData; mMeta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_RAW); mMeta->setInt32(kKeyColorFormat, colorFormat); mMeta->setInt32(kKeyWidth, width); mMeta->setInt32(kKeyHeight, height); mMeta->setInt32(kKeyStride, stride); mMeta->setInt32(kKeySliceHeight, sliceHeight); } CameraSource::~CameraSource() { Loading Loading
include/media/stagefright/MetaData.h +7 −4 Original line number Diff line number Diff line Loading @@ -30,10 +30,13 @@ namespace android { // The following keys map to int32_t data unless indicated otherwise. enum { kKeyMIMEType = 'mime', // cstring kKeyWidth = 'widt', kKeyHeight = 'heig', kKeyChannelCount = '#chn', kKeySampleRate = 'srte', kKeyWidth = 'widt', // int32_t kKeyHeight = 'heig', // int32_t kKeyIFramesInterval = 'ifiv', // int32_t kKeyStride = 'strd', // int32_t kKeySliceHeight = 'slht', // int32_t kKeyChannelCount = '#chn', // int32_t kKeySampleRate = 'srte', // int32_t kKeyBitRate = 'brte', // int32_t (bps) kKeyESDS = 'esds', // raw data kKeyAVCC = 'avcc', // raw data Loading
include/media/stagefright/OMXCodec.h +3 −4 Original line number Diff line number Diff line Loading @@ -166,11 +166,10 @@ private: OMX_COLOR_FORMATTYPE colorFormat); void setVideoInputFormat( const char *mime, OMX_U32 width, OMX_U32 height, OMX_U32 frameRate, OMX_U32 bitRate); const char *mime, const sp<MetaData>& meta); status_t setupMPEG4EncoderParameters(); status_t setupAVCEncoderParameters(); status_t setupMPEG4EncoderParameters(const sp<MetaData>& meta); status_t setupAVCEncoderParameters(const sp<MetaData>& meta); status_t setVideoOutputFormat( const char *mime, OMX_U32 width, OMX_U32 height); Loading
media/libmediaplayerservice/StagefrightRecorder.cpp +31 −2 Original line number Diff line number Diff line Loading @@ -287,14 +287,32 @@ status_t StagefrightRecorder::setParamMaxDurationOrFileSize(int64_t limit, status_t StagefrightRecorder::setParamInterleaveDuration(int32_t durationUs) { LOGV("setParamInterleaveDuration: %d", durationUs); if (durationUs <= 20000) { // XXX: 20 ms if (durationUs <= 500000) { // 500 ms // If interleave duration is too small, it is very inefficient to do // interleaving since the metadata overhead will count for a significant // portion of the saved contents LOGE("Audio/video interleave duration is too small: %d us", durationUs); return BAD_VALUE; } else if (durationUs >= 10000000) { // 10 seconds // If interleaving duration is too large, it can cause the recording // session to use too much memory since we have to save the output // data before we write them out LOGE("Audio/video interleave duration is too large: %d us", durationUs); return BAD_VALUE; } mInterleaveDurationUs = durationUs; return OK; } // 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); mIFramesInterval = interval; return OK; } status_t StagefrightRecorder::setParameter( const String8 &key, const String8 &value) { LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string()); Loading Loading @@ -335,6 +353,11 @@ status_t StagefrightRecorder::setParameter( if (safe_strtoi32(value.string(), &durationUs)) { return setParamInterleaveDuration(durationUs); } } else if (key == "param-i-frames-interval") { int32_t interval; if (safe_strtoi32(value.string(), &interval)) { return setParamIFramesInterval(interval); } } else { LOGE("setParameter: failed to find key %s", key.string()); } Loading Loading @@ -619,12 +642,17 @@ status_t StagefrightRecorder::startMPEG4Recording() { sp<MetaData> meta = cameraSource->getFormat(); int32_t width, height; int32_t width, height, stride, sliceHeight; CHECK(meta->findInt32(kKeyWidth, &width)); CHECK(meta->findInt32(kKeyHeight, &height)); CHECK(meta->findInt32(kKeyStride, &stride)); CHECK(meta->findInt32(kKeySliceHeight, &sliceHeight)); enc_meta->setInt32(kKeyWidth, width); enc_meta->setInt32(kKeyHeight, height); enc_meta->setInt32(kKeyIFramesInterval, mIFramesInterval); enc_meta->setInt32(kKeyStride, stride); enc_meta->setInt32(kKeySliceHeight, sliceHeight); OMXClient client; CHECK_EQ(client.connect(), OK); Loading Loading @@ -702,6 +730,7 @@ status_t StagefrightRecorder::reset() { mAudioChannels = 1; mAudioBitRate = 12200; mInterleaveDurationUs = 0; mIFramesInterval = 1; mOutputFd = -1; mFlags = 0; Loading
media/libmediaplayerservice/StagefrightRecorder.h +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ private: int32_t mAudioChannels; int32_t mSampleRate; int32_t mInterleaveDurationUs; int32_t mIFramesInterval; int64_t mMaxFileSizeBytes; int64_t mMaxFileDurationUs; Loading @@ -92,6 +93,7 @@ private: status_t setParamAudioNumberOfChannels(int32_t channles); status_t setParamAudioSamplingRate(int32_t sampleRate); status_t setParamInterleaveDuration(int32_t durationUs); status_t setParamIFramesInterval(int32_t interval); status_t setParamMaxDurationOrFileSize(int64_t limit, bool limit_is_duration); StagefrightRecorder(const StagefrightRecorder &); Loading
media/libstagefright/CameraSource.cpp +9 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ CameraSource::CameraSource(const sp<Camera> &camera) String8 s = mCamera->getParameters(); printf("params: \"%s\"\n", s.string()); int32_t width, height; int32_t width, height, stride, sliceHeight; CameraParameters params(s); params.getPreviewSize(&width, &height); Loading @@ -136,11 +136,19 @@ CameraSource::CameraSource(const sp<Camera> &camera) CHECK(colorFormatStr != NULL); int32_t colorFormat = getColorFormat(colorFormatStr); // XXX: query camera for the stride and slice height // when the capability becomes available. stride = width; sliceHeight = height; mMeta = new MetaData; mMeta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_RAW); mMeta->setInt32(kKeyColorFormat, colorFormat); mMeta->setInt32(kKeyWidth, width); mMeta->setInt32(kKeyHeight, height); mMeta->setInt32(kKeyStride, stride); mMeta->setInt32(kKeySliceHeight, sliceHeight); } CameraSource::~CameraSource() { Loading