Java Code Examples for com.google.android.exoplayer2.util.XmlPullParserUtil#isStartTag()

The following examples show how to use com.google.android.exoplayer2.util.XmlPullParserUtil#isStartTag() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DashManifestParser.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
protected List<SegmentTimelineElement> parseSegmentTimeline(XmlPullParser xpp)
    throws XmlPullParserException, IOException {
  List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
  long elapsedTime = 0;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "S")) {
      elapsedTime = parseLong(xpp, "t", elapsedTime);
      long duration = parseLong(xpp, "d", C.TIME_UNSET);
      int count = 1 + parseInt(xpp, "r", 0);
      for (int i = 0; i < count; i++) {
        segmentTimeline.add(buildSegmentTimelineElement(elapsedTime, duration));
        elapsedTime += duration;
      }
    } else {
      maybeSkipTag(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentTimeline"));
  return segmentTimeline;
}
 
Example 2
Source File: DashManifestParser.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
protected List<SegmentTimelineElement> parseSegmentTimeline(XmlPullParser xpp)
    throws XmlPullParserException, IOException {
  List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
  long elapsedTime = 0;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "S")) {
      elapsedTime = parseLong(xpp, "t", elapsedTime);
      long duration = parseLong(xpp, "d", C.TIME_UNSET);
      int count = 1 + parseInt(xpp, "r", 0);
      for (int i = 0; i < count; i++) {
        segmentTimeline.add(buildSegmentTimelineElement(elapsedTime, duration));
        elapsedTime += duration;
      }
    } else {
      maybeSkipTag(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentTimeline"));
  return segmentTimeline;
}
 
Example 3
Source File: DashManifestParser.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
protected ProgramInformation parseProgramInformation(XmlPullParser xpp)
    throws IOException, XmlPullParserException {
  String title = null;
  String source = null;
  String copyright = null;
  String moreInformationURL = parseString(xpp, "moreInformationURL", null);
  String lang = parseString(xpp, "lang", null);
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "Title")) {
      title = xpp.nextText();
    } else if (XmlPullParserUtil.isStartTag(xpp, "Source")) {
      source = xpp.nextText();
    } else if (XmlPullParserUtil.isStartTag(xpp, "Copyright")) {
      copyright = xpp.nextText();
    } else {
      maybeSkipTag(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "ProgramInformation"));
  return new ProgramInformation(title, source, copyright, moreInformationURL, lang);
}
 
Example 4
Source File: DashManifestParser.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
protected SegmentList parseSegmentList(XmlPullParser xpp, SegmentList parent)
    throws XmlPullParserException, IOException {

  long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
  long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
      parent != null ? parent.presentationTimeOffset : 0);
  long duration = parseLong(xpp, "duration", parent != null ? parent.duration : C.TIME_UNSET);
  long startNumber = parseLong(xpp, "startNumber", parent != null ? parent.startNumber : 1);

  RangedUri initialization = null;
  List<SegmentTimelineElement> timeline = null;
  List<RangedUri> segments = null;

  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTimeline")) {
      timeline = parseSegmentTimeline(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentURL")) {
      if (segments == null) {
        segments = new ArrayList<>();
      }
      segments.add(parseSegmentUrl(xpp));
    } else {
      maybeSkipTag(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentList"));

  if (parent != null) {
    initialization = initialization != null ? initialization : parent.initialization;
    timeline = timeline != null ? timeline : parent.segmentTimeline;
    segments = segments != null ? segments : parent.mediaSegments;
  }

  return buildSegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
 
Example 5
Source File: DashManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
protected SingleSegmentBase parseSegmentBase(XmlPullParser xpp, SingleSegmentBase parent)
    throws XmlPullParserException, IOException {

  long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
  long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
      parent != null ? parent.presentationTimeOffset : 0);

  long indexStart = parent != null ? parent.indexStart : 0;
  long indexLength = parent != null ? parent.indexLength : 0;
  String indexRangeText = xpp.getAttributeValue(null, "indexRange");
  if (indexRangeText != null) {
    String[] indexRange = indexRangeText.split("-");
    indexStart = Long.parseLong(indexRange[0]);
    indexLength = Long.parseLong(indexRange[1]) - indexStart + 1;
  }

  RangedUri initialization = parent != null ? parent.initialization : null;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentBase"));

  return buildSingleSegmentBase(initialization, timescale, presentationTimeOffset, indexStart,
      indexLength);
}
 
Example 6
Source File: DashManifestParser.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
protected SegmentList parseSegmentList(XmlPullParser xpp, SegmentList parent)
    throws XmlPullParserException, IOException {

  long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
  long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
      parent != null ? parent.presentationTimeOffset : 0);
  long duration = parseLong(xpp, "duration", parent != null ? parent.duration : C.TIME_UNSET);
  long startNumber = parseLong(xpp, "startNumber", parent != null ? parent.startNumber : 1);

  RangedUri initialization = null;
  List<SegmentTimelineElement> timeline = null;
  List<RangedUri> segments = null;

  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTimeline")) {
      timeline = parseSegmentTimeline(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentURL")) {
      if (segments == null) {
        segments = new ArrayList<>();
      }
      segments.add(parseSegmentUrl(xpp));
    } else {
      maybeSkipTag(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentList"));

  if (parent != null) {
    initialization = initialization != null ? initialization : parent.initialization;
    timeline = timeline != null ? timeline : parent.segmentTimeline;
    segments = segments != null ? segments : parent.mediaSegments;
  }

  return buildSegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
 
Example 7
Source File: TtmlDecoder.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private Map<String, TtmlStyle> parseHeader(
    XmlPullParser xmlParser,
    Map<String, TtmlStyle> globalStyles,
    CellResolution cellResolution,
    TtsExtent ttsExtent,
    Map<String, TtmlRegion> globalRegions,
    Map<String, String> imageMap)
    throws IOException, XmlPullParserException {
  do {
    xmlParser.next();
    if (XmlPullParserUtil.isStartTag(xmlParser, TtmlNode.TAG_STYLE)) {
      String parentStyleId = XmlPullParserUtil.getAttributeValue(xmlParser, ATTR_STYLE);
      TtmlStyle style = parseStyleAttributes(xmlParser, new TtmlStyle());
      if (parentStyleId != null) {
        for (String id : parseStyleIds(parentStyleId)) {
          style.chain(globalStyles.get(id));
        }
      }
      if (style.getId() != null) {
        globalStyles.put(style.getId(), style);
      }
    } else if (XmlPullParserUtil.isStartTag(xmlParser, TtmlNode.TAG_REGION)) {
      TtmlRegion ttmlRegion = parseRegionAttributes(xmlParser, cellResolution, ttsExtent);
      if (ttmlRegion != null) {
        globalRegions.put(ttmlRegion.id, ttmlRegion);
      }
    } else if (XmlPullParserUtil.isStartTag(xmlParser, TtmlNode.TAG_METADATA)) {
      parseMetadata(xmlParser, imageMap);
    }
  } while (!XmlPullParserUtil.isEndTag(xmlParser, TtmlNode.TAG_HEAD));
  return globalStyles;
}
 
Example 8
Source File: TtmlDecoder.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private Map<String, TtmlStyle> parseHeader(
    XmlPullParser xmlParser,
    Map<String, TtmlStyle> globalStyles,
    Map<String, TtmlRegion> globalRegions,
    CellResolution cellResolution)
    throws IOException, XmlPullParserException {
  do {
    xmlParser.next();
    if (XmlPullParserUtil.isStartTag(xmlParser, TtmlNode.TAG_STYLE)) {
      String parentStyleId = XmlPullParserUtil.getAttributeValue(xmlParser, ATTR_STYLE);
      TtmlStyle style = parseStyleAttributes(xmlParser, new TtmlStyle());
      if (parentStyleId != null) {
        for (String id : parseStyleIds(parentStyleId)) {
          style.chain(globalStyles.get(id));
        }
      }
      if (style.getId() != null) {
        globalStyles.put(style.getId(), style);
      }
    } else if (XmlPullParserUtil.isStartTag(xmlParser, TtmlNode.TAG_REGION)) {
      TtmlRegion ttmlRegion = parseRegionAttributes(xmlParser, cellResolution);
      if (ttmlRegion != null) {
        globalRegions.put(ttmlRegion.id, ttmlRegion);
      }
    }
  } while (!XmlPullParserUtil.isEndTag(xmlParser, TtmlNode.TAG_HEAD));
  return globalStyles;
}
 
Example 9
Source File: DashManifestParser.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
protected SingleSegmentBase parseSegmentBase(
    XmlPullParser xpp, @Nullable SingleSegmentBase parent)
    throws XmlPullParserException, IOException {

  long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
  long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
      parent != null ? parent.presentationTimeOffset : 0);

  long indexStart = parent != null ? parent.indexStart : 0;
  long indexLength = parent != null ? parent.indexLength : 0;
  String indexRangeText = xpp.getAttributeValue(null, "indexRange");
  if (indexRangeText != null) {
    String[] indexRange = indexRangeText.split("-");
    indexStart = Long.parseLong(indexRange[0]);
    indexLength = Long.parseLong(indexRange[1]) - indexStart + 1;
  }

  RangedUri initialization = parent != null ? parent.initialization : null;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp);
    } else {
      maybeSkipTag(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentBase"));

  return buildSingleSegmentBase(initialization, timescale, presentationTimeOffset, indexStart,
      indexLength);
}
 
Example 10
Source File: DashManifestParser.java    From K-Sonic with MIT License 5 votes vote down vote up
protected Pair<Period, Long> parsePeriod(XmlPullParser xpp, String baseUrl, long defaultStartMs)
    throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  long startMs = parseDuration(xpp, "start", defaultStartMs);
  long durationMs = parseDuration(xpp, "duration", C.TIME_UNSET);
  SegmentBase segmentBase = null;
  List<AdaptationSet> adaptationSets = new ArrayList<>();
  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "AdaptationSet")) {
      adaptationSets.add(parseAdaptationSet(xpp, baseUrl, segmentBase));
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, null);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, null);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, null);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "Period"));

  return Pair.create(buildPeriod(id, startMs, adaptationSets), durationMs);
}
 
Example 11
Source File: DashManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
protected SegmentTemplate parseSegmentTemplate(XmlPullParser xpp, SegmentTemplate parent)
    throws XmlPullParserException, IOException {
  long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
  long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
      parent != null ? parent.presentationTimeOffset : 0);
  long duration = parseLong(xpp, "duration", parent != null ? parent.duration : C.TIME_UNSET);
  long startNumber = parseLong(xpp, "startNumber", parent != null ? parent.startNumber : 1);
  UrlTemplate mediaTemplate = parseUrlTemplate(xpp, "media",
      parent != null ? parent.mediaTemplate : null);
  UrlTemplate initializationTemplate = parseUrlTemplate(xpp, "initialization",
      parent != null ? parent.initializationTemplate : null);

  RangedUri initialization = null;
  List<SegmentTimelineElement> timeline = null;

  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTimeline")) {
      timeline = parseSegmentTimeline(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentTemplate"));

  if (parent != null) {
    initialization = initialization != null ? initialization : parent.initialization;
    timeline = timeline != null ? timeline : parent.segmentTimeline;
  }

  return buildSegmentTemplate(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, initializationTemplate, mediaTemplate);
}
 
Example 12
Source File: TtmlDecoder.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private Map<String, TtmlStyle> parseHeader(
    XmlPullParser xmlParser,
    Map<String, TtmlStyle> globalStyles,
    Map<String, TtmlRegion> globalRegions,
    CellResolution cellResolution)
    throws IOException, XmlPullParserException {
  do {
    xmlParser.next();
    if (XmlPullParserUtil.isStartTag(xmlParser, TtmlNode.TAG_STYLE)) {
      String parentStyleId = XmlPullParserUtil.getAttributeValue(xmlParser, ATTR_STYLE);
      TtmlStyle style = parseStyleAttributes(xmlParser, new TtmlStyle());
      if (parentStyleId != null) {
        for (String id : parseStyleIds(parentStyleId)) {
          style.chain(globalStyles.get(id));
        }
      }
      if (style.getId() != null) {
        globalStyles.put(style.getId(), style);
      }
    } else if (XmlPullParserUtil.isStartTag(xmlParser, TtmlNode.TAG_REGION)) {
      TtmlRegion ttmlRegion = parseRegionAttributes(xmlParser, cellResolution);
      if (ttmlRegion != null) {
        globalRegions.put(ttmlRegion.id, ttmlRegion);
      }
    }
  } while (!XmlPullParserUtil.isEndTag(xmlParser, TtmlNode.TAG_HEAD));
  return globalStyles;
}
 
Example 13
Source File: DashManifestParser.java    From K-Sonic with MIT License 4 votes vote down vote up
protected RepresentationInfo parseRepresentation(XmlPullParser xpp, String baseUrl,
    String adaptationSetMimeType, String adaptationSetCodecs, int adaptationSetWidth,
    int adaptationSetHeight, float adaptationSetFrameRate, int adaptationSetAudioChannels,
    int adaptationSetAudioSamplingRate, String adaptationSetLanguage,
    @C.SelectionFlags int adaptationSetSelectionFlags,
    List<SchemeValuePair> adaptationSetAccessibilityDescriptors, SegmentBase segmentBase)
    throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth", Format.NO_VALUE);

  String mimeType = parseString(xpp, "mimeType", adaptationSetMimeType);
  String codecs = parseString(xpp, "codecs", adaptationSetCodecs);
  int width = parseInt(xpp, "width", adaptationSetWidth);
  int height = parseInt(xpp, "height", adaptationSetHeight);
  float frameRate = parseFrameRate(xpp, adaptationSetFrameRate);
  int audioChannels = adaptationSetAudioChannels;
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate", adaptationSetAudioSamplingRate);
  ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
  ArrayList<SchemeValuePair> inbandEventStreams = new ArrayList<>();

  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "AudioChannelConfiguration")) {
      audioChannels = parseAudioChannelConfiguration(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, (SingleSegmentBase) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, (SegmentList) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, (SegmentTemplate) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentProtection")) {
      SchemeData contentProtection = parseContentProtection(xpp);
      if (contentProtection != null) {
        drmSchemeDatas.add(contentProtection);
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "InbandEventStream")) {
      inbandEventStreams.add(parseInbandEventStream(xpp));
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "Representation"));

  Format format = buildFormat(id, mimeType, width, height, frameRate, audioChannels,
      audioSamplingRate, bandwidth, adaptationSetLanguage, adaptationSetSelectionFlags,
      adaptationSetAccessibilityDescriptors, codecs);
  segmentBase = segmentBase != null ? segmentBase : new SingleSegmentBase();

  return new RepresentationInfo(format, baseUrl, segmentBase, drmSchemeDatas, inbandEventStreams);
}
 
Example 14
Source File: DashManifestParser.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses a ContentProtection element.
 *
 * @param xpp The parser from which to read.
 * @throws XmlPullParserException If an error occurs parsing the element.
 * @throws IOException If an error occurs reading the element.
 * @return The scheme type and/or {@link SchemeData} parsed from the ContentProtection element.
 *     Either or both may be null, depending on the ContentProtection element being parsed.
 */
protected Pair<String, SchemeData> parseContentProtection(XmlPullParser xpp)
    throws XmlPullParserException, IOException {
  String schemeType = null;
  String licenseServerUrl = null;
  byte[] data = null;
  UUID uuid = null;
  boolean requiresSecureDecoder = false;

  String schemeIdUri = xpp.getAttributeValue(null, "schemeIdUri");
  if (schemeIdUri != null) {
    switch (Util.toLowerInvariant(schemeIdUri)) {
      case "urn:mpeg:dash:mp4protection:2011":
        schemeType = xpp.getAttributeValue(null, "value");
        String defaultKid = XmlPullParserUtil.getAttributeValueIgnorePrefix(xpp, "default_KID");
        if (!TextUtils.isEmpty(defaultKid)
            && !"00000000-0000-0000-0000-000000000000".equals(defaultKid)) {
          String[] defaultKidStrings = defaultKid.split("\\s+");
          UUID[] defaultKids = new UUID[defaultKidStrings.length];
          for (int i = 0; i < defaultKidStrings.length; i++) {
            defaultKids[i] = UUID.fromString(defaultKidStrings[i]);
          }
          data = PsshAtomUtil.buildPsshAtom(C.COMMON_PSSH_UUID, defaultKids, null);
          uuid = C.COMMON_PSSH_UUID;
        }
        break;
      case "urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":
        uuid = C.PLAYREADY_UUID;
        break;
      case "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":
        uuid = C.WIDEVINE_UUID;
        break;
      default:
        break;
    }
  }

  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "ms:laurl")) {
      licenseServerUrl = xpp.getAttributeValue(null, "licenseUrl");
    } else if (XmlPullParserUtil.isStartTag(xpp, "widevine:license")) {
      String robustnessLevel = xpp.getAttributeValue(null, "robustness_level");
      requiresSecureDecoder = robustnessLevel != null && robustnessLevel.startsWith("HW");
    } else if (data == null
        && XmlPullParserUtil.isStartTagIgnorePrefix(xpp, "pssh")
        && xpp.next() == XmlPullParser.TEXT) {
      // The cenc:pssh element is defined in 23001-7:2015.
      data = Base64.decode(xpp.getText(), Base64.DEFAULT);
      uuid = PsshAtomUtil.parseUuid(data);
      if (uuid == null) {
        Log.w(TAG, "Skipping malformed cenc:pssh data");
        data = null;
      }
    } else if (data == null
        && C.PLAYREADY_UUID.equals(uuid)
        && XmlPullParserUtil.isStartTag(xpp, "mspr:pro")
        && xpp.next() == XmlPullParser.TEXT) {
      // The mspr:pro element is defined in DASH Content Protection using Microsoft PlayReady.
      data =
          PsshAtomUtil.buildPsshAtom(
              C.PLAYREADY_UUID, Base64.decode(xpp.getText(), Base64.DEFAULT));
    } else {
      maybeSkipTag(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "ContentProtection"));
  SchemeData schemeData =
      uuid != null
          ? new SchemeData(
              uuid, licenseServerUrl, MimeTypes.VIDEO_MP4, data, requiresSecureDecoder)
          : null;
  return Pair.create(schemeType, schemeData);
}
 
Example 15
Source File: DashManifestParser.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String baseUrl,
    SegmentBase segmentBase) throws XmlPullParserException, IOException {
  int id = parseInt(xpp, "id", AdaptationSet.ID_UNSET);
  int contentType = parseContentType(xpp);

  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String codecs = xpp.getAttributeValue(null, "codecs");
  int width = parseInt(xpp, "width", Format.NO_VALUE);
  int height = parseInt(xpp, "height", Format.NO_VALUE);
  float frameRate = parseFrameRate(xpp, Format.NO_VALUE);
  int audioChannels = Format.NO_VALUE;
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate", Format.NO_VALUE);
  String language = xpp.getAttributeValue(null, "lang");
  String label = xpp.getAttributeValue(null, "label");
  String drmSchemeType = null;
  ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
  ArrayList<Descriptor> inbandEventStreams = new ArrayList<>();
  ArrayList<Descriptor> accessibilityDescriptors = new ArrayList<>();
  ArrayList<Descriptor> roleDescriptors = new ArrayList<>();
  ArrayList<Descriptor> supplementalProperties = new ArrayList<>();
  List<RepresentationInfo> representationInfos = new ArrayList<>();

  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentProtection")) {
      Pair<String, SchemeData> contentProtection = parseContentProtection(xpp);
      if (contentProtection.first != null) {
        drmSchemeType = contentProtection.first;
      }
      if (contentProtection.second != null) {
        drmSchemeDatas.add(contentProtection.second);
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentComponent")) {
      language = checkLanguageConsistency(language, xpp.getAttributeValue(null, "lang"));
      contentType = checkContentTypeConsistency(contentType, parseContentType(xpp));
    } else if (XmlPullParserUtil.isStartTag(xpp, "Role")) {
      roleDescriptors.add(parseDescriptor(xpp, "Role"));
    } else if (XmlPullParserUtil.isStartTag(xpp, "AudioChannelConfiguration")) {
      audioChannels = parseAudioChannelConfiguration(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "Accessibility")) {
      accessibilityDescriptors.add(parseDescriptor(xpp, "Accessibility"));
    } else if (XmlPullParserUtil.isStartTag(xpp, "SupplementalProperty")) {
      supplementalProperties.add(parseDescriptor(xpp, "SupplementalProperty"));
    } else if (XmlPullParserUtil.isStartTag(xpp, "Representation")) {
      RepresentationInfo representationInfo =
          parseRepresentation(
              xpp,
              baseUrl,
              mimeType,
              codecs,
              width,
              height,
              frameRate,
              audioChannels,
              audioSamplingRate,
              language,
              roleDescriptors,
              accessibilityDescriptors,
              supplementalProperties,
              segmentBase);
      contentType = checkContentTypeConsistency(contentType,
          getContentType(representationInfo.format));
      representationInfos.add(representationInfo);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, (SingleSegmentBase) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, (SegmentList) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
      segmentBase =
          parseSegmentTemplate(xpp, (SegmentTemplate) segmentBase, supplementalProperties);
    } else if (XmlPullParserUtil.isStartTag(xpp, "InbandEventStream")) {
      inbandEventStreams.add(parseDescriptor(xpp, "InbandEventStream"));
    } else if (XmlPullParserUtil.isStartTag(xpp, "Label")) {
      label = parseLabel(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "AdaptationSet"));

  // Build the representations.
  List<Representation> representations = new ArrayList<>(representationInfos.size());
  for (int i = 0; i < representationInfos.size(); i++) {
    representations.add(
        buildRepresentation(
            representationInfos.get(i),
            label,
            drmSchemeType,
            drmSchemeDatas,
            inbandEventStreams));
  }

  return buildAdaptationSet(id, contentType, representations, accessibilityDescriptors,
      supplementalProperties);
}
 
Example 16
Source File: DashManifestParser.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
protected RepresentationInfo parseRepresentation(
    XmlPullParser xpp,
    String baseUrl,
    @Nullable String adaptationSetMimeType,
    @Nullable String adaptationSetCodecs,
    int adaptationSetWidth,
    int adaptationSetHeight,
    float adaptationSetFrameRate,
    int adaptationSetAudioChannels,
    int adaptationSetAudioSamplingRate,
    @Nullable String adaptationSetLanguage,
    List<Descriptor> adaptationSetRoleDescriptors,
    List<Descriptor> adaptationSetAccessibilityDescriptors,
    List<Descriptor> adaptationSetSupplementalProperties,
    @Nullable SegmentBase segmentBase,
    long periodDurationMs)
    throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth", Format.NO_VALUE);

  String mimeType = parseString(xpp, "mimeType", adaptationSetMimeType);
  String codecs = parseString(xpp, "codecs", adaptationSetCodecs);
  int width = parseInt(xpp, "width", adaptationSetWidth);
  int height = parseInt(xpp, "height", adaptationSetHeight);
  float frameRate = parseFrameRate(xpp, adaptationSetFrameRate);
  int audioChannels = adaptationSetAudioChannels;
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate", adaptationSetAudioSamplingRate);
  String drmSchemeType = null;
  ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
  ArrayList<Descriptor> inbandEventStreams = new ArrayList<>();
  ArrayList<Descriptor> supplementalProperties = new ArrayList<>();

  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "AudioChannelConfiguration")) {
      audioChannels = parseAudioChannelConfiguration(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, (SingleSegmentBase) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, (SegmentList) segmentBase, periodDurationMs);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
      segmentBase =
          parseSegmentTemplate(
              xpp,
              (SegmentTemplate) segmentBase,
              adaptationSetSupplementalProperties,
              periodDurationMs);
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentProtection")) {
      Pair<String, SchemeData> contentProtection = parseContentProtection(xpp);
      if (contentProtection.first != null) {
        drmSchemeType = contentProtection.first;
      }
      if (contentProtection.second != null) {
        drmSchemeDatas.add(contentProtection.second);
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "InbandEventStream")) {
      inbandEventStreams.add(parseDescriptor(xpp, "InbandEventStream"));
    } else if (XmlPullParserUtil.isStartTag(xpp, "SupplementalProperty")) {
      supplementalProperties.add(parseDescriptor(xpp, "SupplementalProperty"));
    } else {
      maybeSkipTag(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "Representation"));

  Format format =
      buildFormat(
          id,
          mimeType,
          width,
          height,
          frameRate,
          audioChannels,
          audioSamplingRate,
          bandwidth,
          adaptationSetLanguage,
          adaptationSetRoleDescriptors,
          adaptationSetAccessibilityDescriptors,
          codecs,
          supplementalProperties);
  segmentBase = segmentBase != null ? segmentBase : new SingleSegmentBase();

  return new RepresentationInfo(format, baseUrl, segmentBase, drmSchemeType, drmSchemeDatas,
      inbandEventStreams, Representation.REVISION_ID_DEFAULT);
}
 
Example 17
Source File: DashManifestParser.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
protected RepresentationInfo parseRepresentation(
    XmlPullParser xpp,
    String baseUrl,
    String adaptationSetMimeType,
    String adaptationSetCodecs,
    int adaptationSetWidth,
    int adaptationSetHeight,
    float adaptationSetFrameRate,
    int adaptationSetAudioChannels,
    int adaptationSetAudioSamplingRate,
    String adaptationSetLanguage,
    List<Descriptor> adaptationSetRoleDescriptors,
    List<Descriptor> adaptationSetAccessibilityDescriptors,
    List<Descriptor> adaptationSetSupplementalProperties,
    SegmentBase segmentBase)
    throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth", Format.NO_VALUE);

  String mimeType = parseString(xpp, "mimeType", adaptationSetMimeType);
  String codecs = parseString(xpp, "codecs", adaptationSetCodecs);
  int width = parseInt(xpp, "width", adaptationSetWidth);
  int height = parseInt(xpp, "height", adaptationSetHeight);
  float frameRate = parseFrameRate(xpp, adaptationSetFrameRate);
  int audioChannels = adaptationSetAudioChannels;
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate", adaptationSetAudioSamplingRate);
  String drmSchemeType = null;
  ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
  ArrayList<Descriptor> inbandEventStreams = new ArrayList<>();
  ArrayList<Descriptor> supplementalProperties = new ArrayList<>();

  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "AudioChannelConfiguration")) {
      audioChannels = parseAudioChannelConfiguration(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, (SingleSegmentBase) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, (SegmentList) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
      segmentBase =
          parseSegmentTemplate(
              xpp, (SegmentTemplate) segmentBase, adaptationSetSupplementalProperties);
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentProtection")) {
      Pair<String, SchemeData> contentProtection = parseContentProtection(xpp);
      if (contentProtection.first != null) {
        drmSchemeType = contentProtection.first;
      }
      if (contentProtection.second != null) {
        drmSchemeDatas.add(contentProtection.second);
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "InbandEventStream")) {
      inbandEventStreams.add(parseDescriptor(xpp, "InbandEventStream"));
    } else if (XmlPullParserUtil.isStartTag(xpp, "SupplementalProperty")) {
      supplementalProperties.add(parseDescriptor(xpp, "SupplementalProperty"));
    } else {
      maybeSkipTag(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "Representation"));

  Format format =
      buildFormat(
          id,
          mimeType,
          width,
          height,
          frameRate,
          audioChannels,
          audioSamplingRate,
          bandwidth,
          adaptationSetLanguage,
          adaptationSetRoleDescriptors,
          adaptationSetAccessibilityDescriptors,
          codecs,
          supplementalProperties);
  segmentBase = segmentBase != null ? segmentBase : new SingleSegmentBase();

  return new RepresentationInfo(format, baseUrl, segmentBase, drmSchemeType, drmSchemeDatas,
      inbandEventStreams, Representation.REVISION_ID_DEFAULT);
}
 
Example 18
Source File: DashManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses a ContentProtection element.
 *
 * @param xpp The parser from which to read.
 * @throws XmlPullParserException If an error occurs parsing the element.
 * @throws IOException If an error occurs reading the element.
 * @return The scheme type and/or {@link SchemeData} parsed from the ContentProtection element.
 *     Either or both may be null, depending on the ContentProtection element being parsed.
 */
protected Pair<String, SchemeData> parseContentProtection(XmlPullParser xpp)
    throws XmlPullParserException, IOException {
  String schemeType = null;
  String licenseServerUrl = null;
  byte[] data = null;
  UUID uuid = null;
  boolean requiresSecureDecoder = false;

  String schemeIdUri = xpp.getAttributeValue(null, "schemeIdUri");
  if (schemeIdUri != null) {
    switch (Util.toLowerInvariant(schemeIdUri)) {
      case "urn:mpeg:dash:mp4protection:2011":
        schemeType = xpp.getAttributeValue(null, "value");
        String defaultKid = xpp.getAttributeValue(null, "cenc:default_KID");
        if (!TextUtils.isEmpty(defaultKid)
            && !"00000000-0000-0000-0000-000000000000".equals(defaultKid)) {
          String[] defaultKidStrings = defaultKid.split("\\s+");
          UUID[] defaultKids = new UUID[defaultKidStrings.length];
          for (int i = 0; i < defaultKidStrings.length; i++) {
            defaultKids[i] = UUID.fromString(defaultKidStrings[i]);
          }
          data = PsshAtomUtil.buildPsshAtom(C.COMMON_PSSH_UUID, defaultKids, null);
          uuid = C.COMMON_PSSH_UUID;
        }
        break;
      case "urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":
        uuid = C.PLAYREADY_UUID;
        break;
      case "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":
        uuid = C.WIDEVINE_UUID;
        break;
      default:
        break;
    }
  }

  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "ms:laurl")) {
      licenseServerUrl = xpp.getAttributeValue(null, "licenseUrl");
    } else if (XmlPullParserUtil.isStartTag(xpp, "widevine:license")) {
      String robustnessLevel = xpp.getAttributeValue(null, "robustness_level");
      requiresSecureDecoder = robustnessLevel != null && robustnessLevel.startsWith("HW");
    } else if (data == null) {
      if (XmlPullParserUtil.isStartTag(xpp, "cenc:pssh") && xpp.next() == XmlPullParser.TEXT) {
        // The cenc:pssh element is defined in 23001-7:2015.
        data = Base64.decode(xpp.getText(), Base64.DEFAULT);
        uuid = PsshAtomUtil.parseUuid(data);
        if (uuid == null) {
          Log.w(TAG, "Skipping malformed cenc:pssh data");
          data = null;
        }
      } else if (C.PLAYREADY_UUID.equals(uuid) && XmlPullParserUtil.isStartTag(xpp, "mspr:pro")
          && xpp.next() == XmlPullParser.TEXT) {
        // The mspr:pro element is defined in DASH Content Protection using Microsoft PlayReady.
        data = PsshAtomUtil.buildPsshAtom(C.PLAYREADY_UUID,
            Base64.decode(xpp.getText(), Base64.DEFAULT));
      }
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "ContentProtection"));
  SchemeData schemeData =
      uuid != null
          ? new SchemeData(
              uuid, licenseServerUrl, MimeTypes.VIDEO_MP4, data, requiresSecureDecoder)
          : null;
  return Pair.create(schemeType, schemeData);
}
 
Example 19
Source File: DashManifestParser.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
protected DashManifest parseMediaPresentationDescription(XmlPullParser xpp,
    String baseUrl) throws XmlPullParserException, IOException {
  long availabilityStartTime = parseDateTime(xpp, "availabilityStartTime", C.TIME_UNSET);
  long durationMs = parseDuration(xpp, "mediaPresentationDuration", C.TIME_UNSET);
  long minBufferTimeMs = parseDuration(xpp, "minBufferTime", C.TIME_UNSET);
  String typeString = xpp.getAttributeValue(null, "type");
  boolean dynamic = "dynamic".equals(typeString);
  long minUpdateTimeMs = dynamic ? parseDuration(xpp, "minimumUpdatePeriod", C.TIME_UNSET)
      : C.TIME_UNSET;
  long timeShiftBufferDepthMs = dynamic
      ? parseDuration(xpp, "timeShiftBufferDepth", C.TIME_UNSET) : C.TIME_UNSET;
  long suggestedPresentationDelayMs = dynamic
      ? parseDuration(xpp, "suggestedPresentationDelay", C.TIME_UNSET) : C.TIME_UNSET;
  long publishTimeMs = parseDateTime(xpp, "publishTime", C.TIME_UNSET);
  ProgramInformation programInformation = null;
  UtcTimingElement utcTiming = null;
  Uri location = null;

  List<Period> periods = new ArrayList<>();
  long nextPeriodStartMs = dynamic ? C.TIME_UNSET : 0;
  boolean seenEarlyAccessPeriod = false;
  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "ProgramInformation")) {
      programInformation = parseProgramInformation(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "UTCTiming")) {
      utcTiming = parseUtcTiming(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "Location")) {
      location = Uri.parse(xpp.nextText());
    } else if (XmlPullParserUtil.isStartTag(xpp, "Period") && !seenEarlyAccessPeriod) {
      Pair<Period, Long> periodWithDurationMs = parsePeriod(xpp, baseUrl, nextPeriodStartMs);
      Period period = periodWithDurationMs.first;
      if (period.startMs == C.TIME_UNSET) {
        if (dynamic) {
          // This is an early access period. Ignore it. All subsequent periods must also be
          // early access.
          seenEarlyAccessPeriod = true;
        } else {
          throw new ParserException("Unable to determine start of period " + periods.size());
        }
      } else {
        long periodDurationMs = periodWithDurationMs.second;
        nextPeriodStartMs = periodDurationMs == C.TIME_UNSET ? C.TIME_UNSET
            : (period.startMs + periodDurationMs);
        periods.add(period);
      }
    } else {
      maybeSkipTag(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "MPD"));

  if (durationMs == C.TIME_UNSET) {
    if (nextPeriodStartMs != C.TIME_UNSET) {
      // If we know the end time of the final period, we can use it as the duration.
      durationMs = nextPeriodStartMs;
    } else if (!dynamic) {
      throw new ParserException("Unable to determine duration of static manifest.");
    }
  }

  if (periods.isEmpty()) {
    throw new ParserException("No periods found.");
  }

  return buildMediaPresentationDescription(
      availabilityStartTime,
      durationMs,
      minBufferTimeMs,
      dynamic,
      minUpdateTimeMs,
      timeShiftBufferDepthMs,
      suggestedPresentationDelayMs,
      publishTimeMs,
      programInformation,
      utcTiming,
      location,
      periods);
}
 
Example 20
Source File: DashManifestParser.java    From K-Sonic with MIT License 4 votes vote down vote up
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String baseUrl,
    SegmentBase segmentBase) throws XmlPullParserException, IOException {
  int id = parseInt(xpp, "id", AdaptationSet.ID_UNSET);
  int contentType = parseContentType(xpp);

  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String codecs = xpp.getAttributeValue(null, "codecs");
  int width = parseInt(xpp, "width", Format.NO_VALUE);
  int height = parseInt(xpp, "height", Format.NO_VALUE);
  float frameRate = parseFrameRate(xpp, Format.NO_VALUE);
  int audioChannels = Format.NO_VALUE;
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate", Format.NO_VALUE);
  String language = xpp.getAttributeValue(null, "lang");
  ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
  ArrayList<SchemeValuePair> inbandEventStreams = new ArrayList<>();
  ArrayList<SchemeValuePair> accessibilityDescriptors = new ArrayList<>();
  List<RepresentationInfo> representationInfos = new ArrayList<>();
  @C.SelectionFlags int selectionFlags = 0;

  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentProtection")) {
      SchemeData contentProtection = parseContentProtection(xpp);
      if (contentProtection != null) {
        drmSchemeDatas.add(contentProtection);
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentComponent")) {
      language = checkLanguageConsistency(language, xpp.getAttributeValue(null, "lang"));
      contentType = checkContentTypeConsistency(contentType, parseContentType(xpp));
    } else if (XmlPullParserUtil.isStartTag(xpp, "Role")) {
      selectionFlags |= parseRole(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "AudioChannelConfiguration")) {
      audioChannels = parseAudioChannelConfiguration(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "Accessibility")) {
      accessibilityDescriptors.add(parseAccessibility(xpp));
    } else if (XmlPullParserUtil.isStartTag(xpp, "Representation")) {
      RepresentationInfo representationInfo = parseRepresentation(xpp, baseUrl, mimeType, codecs,
          width, height, frameRate, audioChannels, audioSamplingRate, language,
          selectionFlags, accessibilityDescriptors, segmentBase);
      contentType = checkContentTypeConsistency(contentType,
          getContentType(representationInfo.format));
      representationInfos.add(representationInfo);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, (SingleSegmentBase) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, (SegmentList) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, (SegmentTemplate) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "InbandEventStream")) {
      inbandEventStreams.add(parseInbandEventStream(xpp));
    } else if (XmlPullParserUtil.isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "AdaptationSet"));

  // Build the representations.
  List<Representation> representations = new ArrayList<>(representationInfos.size());
  for (int i = 0; i < representationInfos.size(); i++) {
    representations.add(buildRepresentation(representationInfos.get(i), contentId,
        drmSchemeDatas, inbandEventStreams));
  }

  return buildAdaptationSet(id, contentType, representations, accessibilityDescriptors);
}