com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SegmentTemplate Java Examples

The following examples show how to use com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SegmentTemplate. 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 with GNU General Public License v2.0 6 votes vote down vote up
protected SegmentTemplate buildSegmentTemplate(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long endNumber,
    long duration,
    List<SegmentTimelineElement> timeline,
    UrlTemplate initializationTemplate,
    UrlTemplate mediaTemplate) {
  return new SegmentTemplate(
      initialization,
      timescale,
      presentationTimeOffset,
      startNumber,
      endNumber,
      duration,
      timeline,
      initializationTemplate,
      mediaTemplate);
}
 
Example #2
Source File: DashManifestParser.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
protected SegmentTemplate buildSegmentTemplate(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long endNumber,
    long duration,
    List<SegmentTimelineElement> timeline,
    @Nullable UrlTemplate initializationTemplate,
    @Nullable UrlTemplate mediaTemplate) {
  return new SegmentTemplate(
      initialization,
      timescale,
      presentationTimeOffset,
      startNumber,
      endNumber,
      duration,
      timeline,
      initializationTemplate,
      mediaTemplate);
}
 
Example #3
Source File: DashManifestParser.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
protected SegmentTemplate buildSegmentTemplate(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long endNumber,
    long duration,
    List<SegmentTimelineElement> timeline,
    UrlTemplate initializationTemplate,
    UrlTemplate mediaTemplate) {
  return new SegmentTemplate(
      initialization,
      timescale,
      presentationTimeOffset,
      startNumber,
      endNumber,
      duration,
      timeline,
      initializationTemplate,
      mediaTemplate);
}
 
Example #4
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 #5
Source File: DashManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
protected SegmentTemplate buildSegmentTemplate(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long duration,
    List<SegmentTimelineElement> timeline,
    UrlTemplate initializationTemplate,
    UrlTemplate mediaTemplate) {
  return new SegmentTemplate(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, initializationTemplate, mediaTemplate);
}
 
Example #6
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 #7
Source File: DashManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
protected SegmentTemplate buildSegmentTemplate(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long duration,
    List<SegmentTimelineElement> timeline,
    UrlTemplate initializationTemplate,
    UrlTemplate mediaTemplate) {
  return new SegmentTemplate(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, initializationTemplate, mediaTemplate);
}
 
Example #8
Source File: DashManifestParser.java    From K-Sonic with MIT License 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);
  int startNumber = parseInt(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 #9
Source File: DashManifestParser.java    From K-Sonic with MIT License 5 votes vote down vote up
protected SegmentTemplate buildSegmentTemplate(RangedUri initialization, long timescale,
    long presentationTimeOffset, int startNumber, long duration,
    List<SegmentTimelineElement> timeline, UrlTemplate initializationTemplate,
    UrlTemplate mediaTemplate) {
  return new SegmentTemplate(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, initializationTemplate, mediaTemplate);
}
 
Example #10
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);
}
 
Example #11
Source File: DashManifestParser.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
protected SegmentTemplate parseSegmentTemplate(
    XmlPullParser xpp,
    SegmentTemplate parent,
    List<Descriptor> adaptationSetSupplementalProperties)
    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);
  long endNumber =
      parseLastSegmentNumberSupplementalProperty(adaptationSetSupplementalProperties);

  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);
    } else {
      maybeSkipTag(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,
      endNumber,
      duration,
      timeline,
      initializationTemplate,
      mediaTemplate);
}
 
Example #12
Source File: DashManifestParser.java    From Telegram 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 #13
Source File: DashManifestParser.java    From Telegram 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 #14
Source File: DashManifestParser.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
protected SegmentTemplate parseSegmentTemplate(
    XmlPullParser xpp,
    SegmentTemplate parent,
    List<Descriptor> adaptationSetSupplementalProperties)
    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);
  long endNumber =
      parseLastSegmentNumberSupplementalProperty(adaptationSetSupplementalProperties);

  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);
    } else {
      maybeSkipTag(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,
      endNumber,
      duration,
      timeline,
      initializationTemplate,
      mediaTemplate);
}
 
Example #15
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 #16
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 #17
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 #18
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 #19
Source File: DashManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
protected RepresentationInfo parseRepresentation(
    XmlPullParser xpp,
    String baseUrl,
    String label,
    String adaptationSetMimeType,
    String adaptationSetCodecs,
    int adaptationSetWidth,
    int adaptationSetHeight,
    float adaptationSetFrameRate,
    int adaptationSetAudioChannels,
    int adaptationSetAudioSamplingRate,
    String adaptationSetLanguage,
    @C.SelectionFlags int adaptationSetSelectionFlags,
    List<Descriptor> 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);
  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);
    } 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"));
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "Representation"));

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

  return new RepresentationInfo(format, baseUrl, segmentBase, drmSchemeType, drmSchemeDatas,
      inbandEventStreams, Representation.REVISION_ID_DEFAULT);
}
 
Example #20
Source File: DashManifestParser.java    From TelePlus-Android 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> supplementalProperties = 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")) {
      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")) {
      selectionFlags |= parseRole(xpp);
    } 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,
              label,
              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(parseDescriptor(xpp, "InbandEventStream"));
    } 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,
        drmSchemeType, drmSchemeDatas, inbandEventStreams));
  }

  return buildAdaptationSet(id, contentType, representations, accessibilityDescriptors,
      supplementalProperties);
}
 
Example #21
Source File: DashManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
protected RepresentationInfo parseRepresentation(
    XmlPullParser xpp,
    String baseUrl,
    String label,
    String adaptationSetMimeType,
    String adaptationSetCodecs,
    int adaptationSetWidth,
    int adaptationSetHeight,
    float adaptationSetFrameRate,
    int adaptationSetAudioChannels,
    int adaptationSetAudioSamplingRate,
    String adaptationSetLanguage,
    @C.SelectionFlags int adaptationSetSelectionFlags,
    List<Descriptor> 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);
  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);
    } 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"));
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "Representation"));

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

  return new RepresentationInfo(format, baseUrl, segmentBase, drmSchemeType, drmSchemeDatas,
      inbandEventStreams, Representation.REVISION_ID_DEFAULT);
}
 
Example #22
Source File: DashManifestParser.java    From TelePlus-Android 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> supplementalProperties = 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")) {
      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")) {
      selectionFlags |= parseRole(xpp);
    } 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,
              label,
              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(parseDescriptor(xpp, "InbandEventStream"));
    } 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,
        drmSchemeType, drmSchemeDatas, inbandEventStreams));
  }

  return buildAdaptationSet(id, contentType, representations, accessibilityDescriptors,
      supplementalProperties);
}
 
Example #23
Source File: DashManifestParser.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
protected SegmentTemplate parseSegmentTemplate(
    XmlPullParser xpp,
    @Nullable SegmentTemplate parent,
    List<Descriptor> adaptationSetSupplementalProperties,
    long periodDurationMs)
    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);
  long endNumber =
      parseLastSegmentNumberSupplementalProperty(adaptationSetSupplementalProperties);

  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, timescale, periodDurationMs);
    } else {
      maybeSkipTag(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,
      endNumber,
      duration,
      timeline,
      initializationTemplate,
      mediaTemplate);
}