diff options
-rw-r--r-- | media/libstagefright/MPEG4Extractor.cpp | 9 | ||||
-rw-r--r-- | media/libstagefright/MetaData.cpp | 3 |
2 files changed, 9 insertions, 3 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index 8368b39..8cf5026 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -1370,9 +1370,6 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return err; } - const char *mime; - CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); - if (max_size != 0) { // Assume that a given buffer only contains at most 10 chunks, // each chunk originally prefixed with a 2 byte length will @@ -1389,6 +1386,8 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { height = 1080; } + const char *mime; + CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); if (!strcmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)) { // AVC requires compression ratio of at least 2, and uses // macroblocks @@ -1402,6 +1401,10 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { } *offset += chunk_size; + // NOTE: setting another piece of metadata invalidates any pointers (such as the + // mimetype) previously obtained, so don't cache them. + const char *mime; + CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); // Calculate average frame rate. if (!strncasecmp("video/", mime, 6)) { size_t nSamples = mLastTrack->sampleTable->countSamples(); diff --git a/media/libstagefright/MetaData.cpp b/media/libstagefright/MetaData.cpp index ae6ae2d..7b60afc 100644 --- a/media/libstagefright/MetaData.cpp +++ b/media/libstagefright/MetaData.cpp @@ -89,6 +89,9 @@ bool MetaData::setRect( return setData(key, TYPE_RECT, &r, sizeof(r)); } +/** + * Note that the returned pointer becomes invalid when additional metadata is set. + */ bool MetaData::findCString(uint32_t key, const char **value) { uint32_t type; const void *data; |