diff options
author | James Dong <jdong@google.com> | 2011-11-09 00:48:56 -0800 |
---|---|---|
committer | James Dong <jdong@google.com> | 2011-11-10 11:40:11 -0800 |
commit | 4948818cb91176df74c972ac27b2f392b5d148bc (patch) | |
tree | e7aaec9695649fe12c95ab33c1aca7b686017622 /media/libstagefright | |
parent | 1dc0ab1d2e2c5f40193556ad1239e304563f3083 (diff) | |
download | frameworks_av-4948818cb91176df74c972ac27b2f392b5d148bc.zip frameworks_av-4948818cb91176df74c972ac27b2f392b5d148bc.tar.gz frameworks_av-4948818cb91176df74c972ac27b2f392b5d148bc.tar.bz2 |
Add support for retrieving location information in mp4/3gpp files
Change-Id: Ib8427704ef9ee5a4fa8fe1818c8a62d77b4ea687
related-to-bug: 5560253
Diffstat (limited to 'media/libstagefright')
-rw-r--r-- | media/libstagefright/MPEG4Extractor.cpp | 35 | ||||
-rw-r--r-- | media/libstagefright/StagefrightMetadataRetriever.cpp | 1 |
2 files changed, 36 insertions, 0 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index 1e24599..1ebf0a8 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -1136,6 +1136,41 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { break; } + // @xyz + case FOURCC('\xA9', 'x', 'y', 'z'): + { + // Best case the total data length inside "@xyz" box + // would be 8, for instance "@xyz" + "\x00\x04\x15\xc7" + "0+0/", + // where "\x00\x04" is the text string length with value = 4, + // "\0x15\xc7" is the language code = en, and "0+0" is a + // location (string) value with longitude = 0 and latitude = 0. + if (chunk_data_size < 8) { + return ERROR_MALFORMED; + } + + // Worst case the location string length would be 18, + // for instance +90.0000-180.0000, without the trailing "/" and + // the string length + language code. + char buffer[18]; + + // Substracting 5 from the data size is because the text string length + + // language code takes 4 bytes, and the trailing slash "/" takes 1 byte. + off64_t location_length = chunk_data_size - 5; + if (location_length >= (off64_t) sizeof(buffer)) { + return ERROR_MALFORMED; + } + + if (mDataSource->readAt( + data_offset + 4, buffer, location_length) < location_length) { + return ERROR_IO; + } + + buffer[location_length] = '\0'; + mFileMetaData->setCString(kKeyLocation, buffer); + *offset += chunk_size; + break; + } + case FOURCC('e', 's', 'd', 's'): { if (chunk_data_size < 4) { diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp index c74cb5a..4491c97 100644 --- a/media/libstagefright/StagefrightMetadataRetriever.cpp +++ b/media/libstagefright/StagefrightMetadataRetriever.cpp @@ -418,6 +418,7 @@ void StagefrightMetadataRetriever::parseMetaData() { { kKeyYear, METADATA_KEY_YEAR }, { kKeyWriter, METADATA_KEY_WRITER }, { kKeyCompilation, METADATA_KEY_COMPILATION }, + { kKeyLocation, METADATA_KEY_LOCATION }, }; static const size_t kNumMapEntries = sizeof(kMap) / sizeof(kMap[0]); |