diff options
| author | 2010-08-19 13:52:47 -0700 | |
|---|---|---|
| committer | 2010-08-19 14:04:04 -0700 | |
| commit | 62948fa4de09c38f07e4b1853c5711f12bb1c596 (patch) | |
| tree | 917deac4ef1a6c7348e6b8f9fb7388f03848cfaf | |
| parent | cbd038fe207f183bc7e0a610973473f7c2e9d118 (diff) | |
Return error from MPEG4Writer stop() if the check on codec specific data failed
Change-Id: Icbd08eec9b4201facbad56ff2040f0830cfb0115
| -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 6bb54bdd4f49..0d0a998921d5 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; |