Skip to content

Commit 08e4296

Browse files
James DongAndroid (Google) Code Review
authored andcommitted
Merge "Add support for retrieving location information in mp4/3gpp files" into ics-mr1
2 parents d00e75e + 77c500c commit 08e4296

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed

include/media/mediametadataretriever.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ enum {
5454
METADATA_KEY_BITRATE = 20,
5555
METADATA_KEY_TIMED_TEXT_LANGUAGES = 21,
5656
METADATA_KEY_IS_DRM = 22,
57+
METADATA_KEY_LOCATION = 23,
5758

5859
// Add more here...
5960
};

include/media/stagefright/MetaData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ enum {
8585
kKeyDate = 'date', // cstring
8686
kKeyWriter = 'writ', // cstring
8787
kKeyCompilation = 'cpil', // cstring
88+
kKeyLocation = 'loc ', // cstring
8889
kKeyTimeScale = 'tmsl', // int32_t
8990

9091
// video profile and level

media/java/android/media/MediaMetadataRetriever.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,5 +458,13 @@ protected void finalize() throws Throwable {
458458
* @hide
459459
*/
460460
public static final int METADATA_KEY_IS_DRM = 22;
461+
/**
462+
* This key retrieves the location information, if available.
463+
* The location should be specified according to ISO-6709 standard, under
464+
* a mp4/3gp box "@xyz". Location with longitude of -90 degrees and latitude
465+
* of 180 degrees will be retrieved as "-90.0000+180.0000", for instance.
466+
* @hide
467+
*/
468+
public static final int METADATA_KEY_LOCATION = 23;
461469
// Add more here...
462470
}

media/libstagefright/MPEG4Extractor.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,41 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
11361136
break;
11371137
}
11381138

1139+
// @xyz
1140+
case FOURCC('\xA9', 'x', 'y', 'z'):
1141+
{
1142+
// Best case the total data length inside "@xyz" box
1143+
// would be 8, for instance "@xyz" + "\x00\x04\x15\xc7" + "0+0/",
1144+
// where "\x00\x04" is the text string length with value = 4,
1145+
// "\0x15\xc7" is the language code = en, and "0+0" is a
1146+
// location (string) value with longitude = 0 and latitude = 0.
1147+
if (chunk_data_size < 8) {
1148+
return ERROR_MALFORMED;
1149+
}
1150+
1151+
// Worst case the location string length would be 18,
1152+
// for instance +90.0000-180.0000, without the trailing "/" and
1153+
// the string length + language code.
1154+
char buffer[18];
1155+
1156+
// Substracting 5 from the data size is because the text string length +
1157+
// language code takes 4 bytes, and the trailing slash "/" takes 1 byte.
1158+
off64_t location_length = chunk_data_size - 5;
1159+
if (location_length >= (off64_t) sizeof(buffer)) {
1160+
return ERROR_MALFORMED;
1161+
}
1162+
1163+
if (mDataSource->readAt(
1164+
data_offset + 4, buffer, location_length) < location_length) {
1165+
return ERROR_IO;
1166+
}
1167+
1168+
buffer[location_length] = '\0';
1169+
mFileMetaData->setCString(kKeyLocation, buffer);
1170+
*offset += chunk_size;
1171+
break;
1172+
}
1173+
11391174
case FOURCC('e', 's', 'd', 's'):
11401175
{
11411176
if (chunk_data_size < 4) {

media/libstagefright/StagefrightMetadataRetriever.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ void StagefrightMetadataRetriever::parseMetaData() {
418418
{ kKeyYear, METADATA_KEY_YEAR },
419419
{ kKeyWriter, METADATA_KEY_WRITER },
420420
{ kKeyCompilation, METADATA_KEY_COMPILATION },
421+
{ kKeyLocation, METADATA_KEY_LOCATION },
421422
};
422423
static const size_t kNumMapEntries = sizeof(kMap) / sizeof(kMap[0]);
423424

0 commit comments

Comments
 (0)