JpegExtractor: read GContainer and GContainerItem XMP prefixes

#minor-release

PiperOrigin-RevId: 363859522
This commit is contained in:
kimvde 2021-03-19 10:54:39 +00:00 committed by Ian Baker
parent adffd43194
commit ef2f8b7ae6
2 changed files with 20 additions and 8 deletions

View File

@ -42,6 +42,9 @@
* Fix container type detection for segments with incorrect file extension * Fix container type detection for segments with incorrect file extension
or HTTP Content-Type or HTTP Content-Type
([#8733](https://github.com/google/ExoPlayer/issues/8733)). ([#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 deprecated symbols:
* Remove `Player.DefaultEventListener`. Use `Player.EventListener` * Remove `Player.DefaultEventListener`. Use `Player.EventListener`
instead. instead.

View File

@ -100,7 +100,9 @@ import org.xmlpull.v1.XmlPullParserFactory;
parseMotionPhotoPresentationTimestampUsFromDescription(xpp); parseMotionPhotoPresentationTimestampUsFromDescription(xpp);
containerItems = parseMicroVideoOffsetFromDescription(xpp); containerItems = parseMicroVideoOffsetFromDescription(xpp);
} else if (XmlPullParserUtil.isStartTag(xpp, "Container:Directory")) { } 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")); } while (!XmlPullParserUtil.isEndTag(xpp, "x:xmpmeta"));
if (containerItems.isEmpty()) { if (containerItems.isEmpty()) {
@ -154,16 +156,23 @@ import org.xmlpull.v1.XmlPullParserFactory;
} }
private static ImmutableList<MotionPhotoDescription.ContainerItem> parseMotionPhotoV1Directory( private static ImmutableList<MotionPhotoDescription.ContainerItem> parseMotionPhotoV1Directory(
XmlPullParser xpp) throws XmlPullParserException, IOException { XmlPullParser xpp, String containerNamespacePrefix, String itemNamespacePrefix)
throws XmlPullParserException, IOException {
ImmutableList.Builder<MotionPhotoDescription.ContainerItem> containerItems = ImmutableList.Builder<MotionPhotoDescription.ContainerItem> containerItems =
ImmutableList.builder(); ImmutableList.builder();
String itemTagName = containerNamespacePrefix + ":Item";
String directoryTagName = containerNamespacePrefix + ":Directory";
do { do {
xpp.next(); xpp.next();
if (XmlPullParserUtil.isStartTag(xpp, "Container:Item")) { if (XmlPullParserUtil.isStartTag(xpp, itemTagName)) {
@Nullable String mime = XmlPullParserUtil.getAttributeValue(xpp, "Item:Mime"); String mimeAttributeName = itemNamespacePrefix + ":Mime";
@Nullable String semantic = XmlPullParserUtil.getAttributeValue(xpp, "Item:Semantic"); String semanticAttributeName = itemNamespacePrefix + ":Semantic";
@Nullable String length = XmlPullParserUtil.getAttributeValue(xpp, "Item:Length"); String lengthAttributeName = itemNamespacePrefix + ":Length";
@Nullable String padding = XmlPullParserUtil.getAttributeValue(xpp, "Item:Padding"); 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) { if (mime == null || semantic == null) {
// Required values are missing. // Required values are missing.
return ImmutableList.of(); return ImmutableList.of();
@ -175,7 +184,7 @@ import org.xmlpull.v1.XmlPullParserFactory;
length != null ? Long.parseLong(length) : 0, length != null ? Long.parseLong(length) : 0,
padding != null ? Long.parseLong(padding) : 0)); padding != null ? Long.parseLong(padding) : 0));
} }
} while (!XmlPullParserUtil.isEndTag(xpp, "Container:Directory")); } while (!XmlPullParserUtil.isEndTag(xpp, directoryTagName));
return containerItems.build(); return containerItems.build();
} }