diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 46364e50f7..89f209633e 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -42,6 +42,9 @@ * Fix container type detection for segments with incorrect file extension or HTTP Content-Type ([#8733](https://github.com/google/ExoPlayer/issues/8733)). +* Extractors: + * Add support for `GContainer` and `GContainerItem` XMP namespace prefixes + in JPEG motion photo parsing. * Remove deprecated symbols: * Remove `Player.DefaultEventListener`. Use `Player.EventListener` instead. diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/jpeg/XmpMotionPhotoDescriptionParser.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/jpeg/XmpMotionPhotoDescriptionParser.java index 3273edc2d7..0972c00567 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/jpeg/XmpMotionPhotoDescriptionParser.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/jpeg/XmpMotionPhotoDescriptionParser.java @@ -100,7 +100,9 @@ import org.xmlpull.v1.XmlPullParserFactory; parseMotionPhotoPresentationTimestampUsFromDescription(xpp); containerItems = parseMicroVideoOffsetFromDescription(xpp); } else if (XmlPullParserUtil.isStartTag(xpp, "Container:Directory")) { - containerItems = parseMotionPhotoV1Directory(xpp); + containerItems = parseMotionPhotoV1Directory(xpp, "Container", "Item"); + } else if (XmlPullParserUtil.isStartTag(xpp, "GContainer:Directory")) { + containerItems = parseMotionPhotoV1Directory(xpp, "GContainer", "GContainerItem"); } } while (!XmlPullParserUtil.isEndTag(xpp, "x:xmpmeta")); if (containerItems.isEmpty()) { @@ -154,16 +156,23 @@ import org.xmlpull.v1.XmlPullParserFactory; } private static ImmutableList parseMotionPhotoV1Directory( - XmlPullParser xpp) throws XmlPullParserException, IOException { + XmlPullParser xpp, String containerNamespacePrefix, String itemNamespacePrefix) + throws XmlPullParserException, IOException { ImmutableList.Builder containerItems = ImmutableList.builder(); + String itemTagName = containerNamespacePrefix + ":Item"; + String directoryTagName = containerNamespacePrefix + ":Directory"; do { xpp.next(); - if (XmlPullParserUtil.isStartTag(xpp, "Container:Item")) { - @Nullable String mime = XmlPullParserUtil.getAttributeValue(xpp, "Item:Mime"); - @Nullable String semantic = XmlPullParserUtil.getAttributeValue(xpp, "Item:Semantic"); - @Nullable String length = XmlPullParserUtil.getAttributeValue(xpp, "Item:Length"); - @Nullable String padding = XmlPullParserUtil.getAttributeValue(xpp, "Item:Padding"); + if (XmlPullParserUtil.isStartTag(xpp, itemTagName)) { + String mimeAttributeName = itemNamespacePrefix + ":Mime"; + String semanticAttributeName = itemNamespacePrefix + ":Semantic"; + String lengthAttributeName = itemNamespacePrefix + ":Length"; + String paddinghAttributeName = itemNamespacePrefix + ":Padding"; + @Nullable String mime = XmlPullParserUtil.getAttributeValue(xpp, mimeAttributeName); + @Nullable String semantic = XmlPullParserUtil.getAttributeValue(xpp, semanticAttributeName); + @Nullable String length = XmlPullParserUtil.getAttributeValue(xpp, lengthAttributeName); + @Nullable String padding = XmlPullParserUtil.getAttributeValue(xpp, paddinghAttributeName); if (mime == null || semantic == null) { // Required values are missing. return ImmutableList.of(); @@ -175,7 +184,7 @@ import org.xmlpull.v1.XmlPullParserFactory; length != null ? Long.parseLong(length) : 0, padding != null ? Long.parseLong(padding) : 0)); } - } while (!XmlPullParserUtil.isEndTag(xpp, "Container:Directory")); + } while (!XmlPullParserUtil.isEndTag(xpp, directoryTagName)); return containerItems.build(); }