summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeena Winterrowd <lenhardw@codeaurora.org>2014-09-10 15:12:28 -0700
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:24:08 -0600
commit113cdc07a29a741ea6cb845551917e6c3c0a3eae (patch)
treecad522c9e4273c59c9ebee2abcfbf83d9a18c8e5
parentfb0040833c39c77312ceacf83f3454bbaef28c9d (diff)
downloadframeworks_av-113cdc07a29a741ea6cb845551917e6c3c0a3eae.zip
frameworks_av-113cdc07a29a741ea6cb845551917e6c3c0a3eae.tar.gz
frameworks_av-113cdc07a29a741ea6cb845551917e6c3c0a3eae.tar.bz2
libstagefright: Use 3gp4 ftyp box when AMR audio is present
mp42 boxes do not support the 'damr' box type whereas 3gp4 boxes explicitly support it. Using mp42 makes clips with AMR incompliant with mpeg4 standards and unplayable by many media players. To ensure interoperability, use a 3gp4 box if the recorded clip contains AMR audio. CRs-Fixed: 721883 Change-Id: I75e3558cd5088d05d36104abfb04a3c0c1d1a4e7
-rw-r--r--include/media/stagefright/MPEG4Writer.h3
-rw-r--r--media/libstagefright/MPEG4Writer.cpp10
2 files changed, 10 insertions, 3 deletions
diff --git a/include/media/stagefright/MPEG4Writer.h b/include/media/stagefright/MPEG4Writer.h
index a195fe8..0cd1d57 100644
--- a/include/media/stagefright/MPEG4Writer.h
+++ b/include/media/stagefright/MPEG4Writer.h
@@ -181,6 +181,9 @@ private:
// By default, real time recording is on.
bool isRealTimeRecording() const;
+ // To use 3gp4 box for clips with AMR audio
+ bool mIsAudioAMR;
+
void lock();
void unlock();
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index d4ac2e8..fdc58af 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -385,7 +385,8 @@ MPEG4Writer::MPEG4Writer(int fd)
mLongitudex10000(0),
mAreGeoTagsAvailable(false),
mStartTimeOffsetMs(-1),
- mMetaKeys(new AMessage()) {
+ mMetaKeys(new AMessage()),
+ mIsAudioAMR(false) {
addDeviceMeta();
// Verify mFd is seekable
@@ -492,6 +493,9 @@ status_t MPEG4Writer::addSource(const sp<MediaSource> &source) {
ALOGE("Unsupported mime '%s'", mime);
return ERROR_UNSUPPORTED;
}
+ mIsAudioAMR = isAudio && (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_NB, mime) ||
+ !strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_WB, mime));
+
// At this point, we know the track to be added is either
// video or audio. Thus, we only need to check whether it
@@ -1047,8 +1051,8 @@ void MPEG4Writer::writeFtypBox(MetaData *param) {
beginBox("ftyp");
int32_t fileType;
- if (param && param->findInt32(kKeyFileType, &fileType) &&
- fileType != OUTPUT_FORMAT_MPEG_4) {
+ if (mIsAudioAMR || (param && param->findInt32(kKeyFileType, &fileType) &&
+ fileType != OUTPUT_FORMAT_MPEG_4)) {
writeFourcc("3gp4");
writeInt32(0);
writeFourcc("isom");