diff options
author | James Dong <jdong@google.com> | 2010-08-19 18:02:23 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-08-19 18:02:23 -0700 |
commit | 439fe407ff75b2c0fc21c66b430cd76e9f29ac90 (patch) | |
tree | 9dbacfc41dfd4fb00da117e2135e68d71f364a2b | |
parent | d018a0ce72124f668d859b19fe3e73f5637d3c7c (diff) | |
parent | 62948fa4de09c38f07e4b1853c5711f12bb1c596 (diff) | |
download | frameworks_base-439fe407ff75b2c0fc21c66b430cd76e9f29ac90.zip frameworks_base-439fe407ff75b2c0fc21c66b430cd76e9f29ac90.tar.gz frameworks_base-439fe407ff75b2c0fc21c66b430cd76e9f29ac90.tar.bz2 |
Merge "Return error from MPEG4Writer stop() if the check on codec specific data failed" into gingerbread
-rw-r--r-- | media/libstagefright/MPEG4Writer.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp index 6bb54bd..0d0a998 100644 --- a/media/libstagefright/MPEG4Writer.cpp +++ b/media/libstagefright/MPEG4Writer.cpp @@ -174,6 +174,9 @@ private: // value, the user-supplied time scale will be used. void setTimeScale(); + // Simple validation on the codec specific data + status_t checkCodecSpecificData() const; + Track(const Track &); Track &operator=(const Track &); }; @@ -1624,6 +1627,8 @@ status_t MPEG4Writer::Track::threadEntry() { if (mSampleSizes.empty()) { err = ERROR_MALFORMED; + } else if (OK != checkCodecSpecificData()) { + err = ERROR_MALFORMED; } mOwner->trackProgressStatus(this, -1, err); @@ -1833,6 +1838,27 @@ int64_t MPEG4Writer::Track::getEstimatedTrackSizeBytes() const { return mEstimatedTrackSizeBytes; } +status_t MPEG4Writer::Track::checkCodecSpecificData() const { + const char *mime; + CHECK(mMeta->findCString(kKeyMIMEType, &mime)); + if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AAC, mime) || + !strcasecmp(MEDIA_MIMETYPE_VIDEO_MPEG4, mime) || + !strcasecmp(MEDIA_MIMETYPE_VIDEO_AVC, mime)) { + if (!mCodecSpecificData || + mCodecSpecificDataSize <= 0) { + // Missing codec specific data + return ERROR_MALFORMED; + } + } else { + if (mCodecSpecificData || + mCodecSpecificDataSize > 0) { + // Unexepected codec specific data found + return ERROR_MALFORMED; + } + } + return OK; +} + void MPEG4Writer::Track::writeTrackHeader( int32_t trackID, bool use32BitOffset) { const char *mime; |