Java 类com.google.android.exoplayer.dash.mpd.SegmentBase.SegmentList 实例源码

项目:ExoPlayer-Demo    文件:DashChunkSourceTest.java   
private static Representation buildSegmentTimelineRepresentation(long timelineDurationMs,
    long timelineStartTimeMs) {
  List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
  List<RangedUri> mediaSegments = new ArrayList<>();
  long segmentStartTimeMs = timelineStartTimeMs;
  long byteStart = 0;
  // Create all but the last segment with LIVE_SEGMENT_DURATION_MS.
  int segmentCount = (int) Util.ceilDivide(timelineDurationMs, LIVE_SEGMENT_DURATION_MS);
  for (int i = 0; i < segmentCount - 1; i++) {
    segmentTimeline.add(new SegmentTimelineElement(segmentStartTimeMs, LIVE_SEGMENT_DURATION_MS));
    mediaSegments.add(new RangedUri("", "", byteStart, 500L));
    segmentStartTimeMs += LIVE_SEGMENT_DURATION_MS;
    byteStart += 500;
  }
  // The final segment duration is calculated so that the total duration is timelineDurationMs.
  long finalSegmentDurationMs = (timelineStartTimeMs + timelineDurationMs) - segmentStartTimeMs;
  segmentTimeline.add(new SegmentTimelineElement(segmentStartTimeMs, finalSegmentDurationMs));
  mediaSegments.add(new RangedUri("", "", byteStart, 500L));
  segmentStartTimeMs += finalSegmentDurationMs;
  byteStart += 500;
  // Construct the list.
  MultiSegmentBase segmentBase = new SegmentList(null, 1000, 0, 0, 0, segmentTimeline,
      mediaSegments);
  return Representation.newInstance(null, 0, REGULAR_VIDEO, segmentBase);
}
项目:ExoPlayer    文件:DashChunkSourceTest.java   
private static Representation generateSegmentTimelineRepresentation(long segmentStartMs,
    long periodStartMs, long duration) {
  List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
  List<RangedUri> mediaSegments = new ArrayList<>();
  long segmentStartTimeMs = segmentStartMs;
  long byteStart = 0;
  for (int i = 0; i < (duration / LIVE_SEGMENT_DURATION_MS); i++) {
    segmentTimeline.add(new SegmentTimelineElement(segmentStartTimeMs, LIVE_SEGMENT_DURATION_MS));
    mediaSegments.add(new RangedUri("", "", byteStart, 500L));
    segmentStartTimeMs += LIVE_SEGMENT_DURATION_MS;
    byteStart += 500;
  }

  int startNumber = (int) ((periodStartMs + segmentStartMs) / LIVE_SEGMENT_DURATION_MS);
  MultiSegmentBase segmentBase = new SegmentList(null, 1000, 0,
      TrackRenderer.UNKNOWN_TIME_US, startNumber, TrackRenderer.UNKNOWN_TIME_US, segmentTimeline,
      mediaSegments);
  return Representation.newInstance(periodStartMs, TrackRenderer.UNKNOWN_TIME_US, null, 0,
      REGULAR_VIDEO, segmentBase);
}
项目:miku    文件:MediaPresentationDescriptionParser.java   
protected SegmentList parseSegmentList(XmlPullParser xpp, String baseUrl, SegmentList parent,
    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 : -1);
  int startNumber = parseInt(xpp, "startNumber", parent != null ? parent.startNumber : 1);

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

  do {
    xpp.next();
    if (isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp, baseUrl);
    } else if (isStartTag(xpp, "SegmentTimeline")) {
      timeline = parseSegmentTimeline(xpp);
    } else if (isStartTag(xpp, "SegmentURL")) {
      if (segments == null) {
        segments = new ArrayList<>();
      }
      segments.add(parseSegmentUrl(xpp, baseUrl));
    }
  } while (!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, periodDurationMs,
      startNumber, duration, timeline, segments);
}
项目:ExoPlayer-Demo    文件:MediaPresentationDescriptionParser.java   
protected SegmentList parseSegmentList(XmlPullParser xpp, String baseUrl, 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 : -1);
  int startNumber = parseInt(xpp, "startNumber", parent != null ? parent.startNumber : 1);

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

  do {
    xpp.next();
    if (ParserUtil.isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp, baseUrl);
    } else if (ParserUtil.isStartTag(xpp, "SegmentTimeline")) {
      timeline = parseSegmentTimeline(xpp);
    } else if (ParserUtil.isStartTag(xpp, "SegmentURL")) {
      if (segments == null) {
        segments = new ArrayList<>();
      }
      segments.add(parseSegmentUrl(xpp, baseUrl));
    }
  } while (!ParserUtil.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);
}
项目:android-exoplayer    文件:MediaPresentationDescriptionParser.java   
protected Representation parseRepresentation(XmlPullParser xpp, String contentId, Uri baseUrl,
    long periodStartMs, long periodDurationMs, String mimeType, String language,
    SegmentBase segmentBase) throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth");
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate");
  int width = parseInt(xpp, "width");
  int height = parseInt(xpp, "height");
  mimeType = parseString(xpp, "mimeType", mimeType);

  int numChannels = -1;
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "AudioChannelConfiguration")) {
      numChannels = Integer.parseInt(xpp.getAttributeValue(null, "value"));
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    }
  } while (!isEndTag(xpp, "Representation"));

  Format format = buildFormat(id, mimeType, width, height, numChannels, audioSamplingRate,
      bandwidth, language);
  return buildRepresentation(periodStartMs, periodDurationMs, contentId, -1, format,
      segmentBase);
}
项目:android-exoplayer    文件:MediaPresentationDescriptionParser.java   
protected SegmentList parseSegmentList(XmlPullParser xpp, Uri baseUrl, SegmentList parent,
    long periodDuration) 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 : -1);
  int startNumber = parseInt(xpp, "startNumber", parent != null ? parent.startNumber : 1);

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

  do {
    xpp.next();
    if (isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp, baseUrl);
    } else if (isStartTag(xpp, "SegmentTimeline")) {
      timeline = parseSegmentTimeline(xpp);
    } else if (isStartTag(xpp, "SegmentURL")) {
      if (segments == null) {
        segments = new ArrayList<RangedUri>();
      }
      segments.add(parseSegmentUrl(xpp, baseUrl));
    }
  } while (!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, periodDuration,
      startNumber, duration, timeline, segments);
}
项目:Exoplayer_VLC    文件:MediaPresentationDescriptionParser.java   
protected Representation parseRepresentation(XmlPullParser xpp, String contentId, Uri baseUrl,
    long periodStartMs, long periodDurationMs, String mimeType, String language,
    SegmentBase segmentBase) throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth");
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate");
  int width = parseInt(xpp, "width");
  int height = parseInt(xpp, "height");
  mimeType = parseString(xpp, "mimeType", mimeType);
  String codecs = parseString(xpp, "codecs", null);

  int numChannels = -1;
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "AudioChannelConfiguration")) {
      numChannels = Integer.parseInt(xpp.getAttributeValue(null, "value"));
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    }
  } while (!isEndTag(xpp, "Representation"));

  Format format = buildFormat(id, mimeType, width, height, numChannels, audioSamplingRate,
      bandwidth, language, codecs);
  return buildRepresentation(periodStartMs, periodDurationMs, contentId, -1, format,
      segmentBase != null ? segmentBase : new SingleSegmentBase(baseUrl));
}
项目:Exoplayer_VLC    文件:MediaPresentationDescriptionParser.java   
protected SegmentList parseSegmentList(XmlPullParser xpp, Uri baseUrl, SegmentList parent,
    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 : -1);
  int startNumber = parseInt(xpp, "startNumber", parent != null ? parent.startNumber : 1);

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

  do {
    xpp.next();
    if (isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp, baseUrl);
    } else if (isStartTag(xpp, "SegmentTimeline")) {
      timeline = parseSegmentTimeline(xpp);
    } else if (isStartTag(xpp, "SegmentURL")) {
      if (segments == null) {
        segments = new ArrayList<RangedUri>();
      }
      segments.add(parseSegmentUrl(xpp, baseUrl));
    }
  } while (!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, periodDurationMs,
      startNumber, duration, timeline, segments);
}
项目:edx-app-android    文件:MediaPresentationDescriptionParser.java   
private Representation parseRepresentation(XmlPullParser xpp, String contentId, Uri baseUrl,
    long periodStartMs, long periodDurationMs, String mimeType, String language,
    SegmentBase segmentBase) throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth");
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate");
  int width = parseInt(xpp, "width");
  int height = parseInt(xpp, "height");
  mimeType = parseString(xpp, "mimeType", mimeType);

  int numChannels = -1;
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "AudioChannelConfiguration")) {
      numChannels = Integer.parseInt(xpp.getAttributeValue(null, "value"));
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    }
  } while (!isEndTag(xpp, "Representation"));

  Format format = new Format(id, mimeType, width, height, numChannels, audioSamplingRate,
      bandwidth, language);
  return Representation.newInstance(periodStartMs, periodDurationMs, contentId, -1, format,
      segmentBase);
}
项目:edx-app-android    文件:MediaPresentationDescriptionParser.java   
private SegmentList parseSegmentList(XmlPullParser xpp, Uri baseUrl, SegmentList parent,
    long periodDuration) 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 : -1);
  int startNumber = parseInt(xpp, "startNumber", parent != null ? parent.startNumber : 0);

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

  do {
    xpp.next();
    if (isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp, baseUrl);
    } else if (isStartTag(xpp, "SegmentTimeline")) {
      timeline = parseSegmentTimeline(xpp);
    } else if (isStartTag(xpp, "SegmentURL")) {
      if (segments == null) {
        segments = new ArrayList<RangedUri>();
      }
      segments.add(parseSegmentUrl(xpp, baseUrl));
    }
  } while (!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 new SegmentList(initialization, timescale, presentationTimeOffset, periodDuration,
      startNumber, duration, timeline, segments);
}
项目:ExoPlayer    文件:MediaPresentationDescriptionParser.java   
protected SegmentList parseSegmentList(XmlPullParser xpp, String baseUrl, SegmentList parent,
    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 : -1);
  int startNumber = parseInt(xpp, "startNumber", parent != null ? parent.startNumber : 1);

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

  do {
    xpp.next();
    if (isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp, baseUrl);
    } else if (isStartTag(xpp, "SegmentTimeline")) {
      timeline = parseSegmentTimeline(xpp);
    } else if (isStartTag(xpp, "SegmentURL")) {
      if (segments == null) {
        segments = new ArrayList<>();
      }
      segments.add(parseSegmentUrl(xpp, baseUrl));
    }
  } while (!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, periodDurationMs,
      startNumber, duration, timeline, segments);
}
项目:miku    文件:MediaPresentationDescriptionParser.java   
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String baseUrl, long periodStartMs,
    long periodDurationMs, SegmentBase segmentBase) throws XmlPullParserException, IOException {

  int id = parseInt(xpp, "id", -1);
  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String language = xpp.getAttributeValue(null, "lang");
  int contentType = parseAdaptationSetType(xpp.getAttributeValue(null, "contentType"));
  if (contentType == AdaptationSet.TYPE_UNKNOWN) {
    contentType = parseAdaptationSetTypeFromMimeType(xpp.getAttributeValue(null, "mimeType"));
  }

  ContentProtectionsBuilder contentProtectionsBuilder = new ContentProtectionsBuilder();
  List<Representation> representations = new ArrayList<>();
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "ContentProtection")) {
      contentProtectionsBuilder.addAdaptationSetProtection(parseContentProtection(xpp));
    } else if (isStartTag(xpp, "ContentComponent")) {
      language = checkLanguageConsistency(language, xpp.getAttributeValue(null, "lang"));
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetType(xpp.getAttributeValue(null, "contentType")));
    } else if (isStartTag(xpp, "Representation")) {
      Representation representation = parseRepresentation(xpp, baseUrl, periodStartMs,
          periodDurationMs, mimeType, language, segmentBase, contentProtectionsBuilder);
      contentProtectionsBuilder.endRepresentation();
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetTypeFromMimeType(representation.format.mimeType));
      representations.add(representation);
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    } else if (isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!isEndTag(xpp, "AdaptationSet"));

  return buildAdaptationSet(id, contentType, representations, contentProtectionsBuilder.build());
}
项目:miku    文件:MediaPresentationDescriptionParser.java   
protected Representation parseRepresentation(XmlPullParser xpp, String baseUrl,
    long periodStartMs, long periodDurationMs, String mimeType, String language,
    SegmentBase segmentBase, ContentProtectionsBuilder contentProtectionsBuilder)
    throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth");
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate");
  int width = parseInt(xpp, "width");
  int height = parseInt(xpp, "height");

  float frameRate = -1;
  String frameRateAttribute = xpp.getAttributeValue(null, "frameRate");
  if (frameRateAttribute != null) {
    Matcher frameRateMatcher = FRAME_RATE_PATTERN.matcher(frameRateAttribute);
    if (frameRateMatcher.matches()) {
      int numerator = Integer.parseInt(frameRateMatcher.group(1));
      String denominatorString = frameRateMatcher.group(2);
      if (!TextUtils.isEmpty(denominatorString)) {
        frameRate = (float) numerator / Integer.parseInt(denominatorString);
      } else {
        frameRate = numerator;
      }
    }
  }

  mimeType = parseString(xpp, "mimeType", mimeType);
  String codecs = parseString(xpp, "codecs", null);

  int numChannels = -1;
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "AudioChannelConfiguration")) {
      numChannels = Integer.parseInt(xpp.getAttributeValue(null, "value"));
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    } else if (isStartTag(xpp, "ContentProtection")) {
      contentProtectionsBuilder.addRepresentationProtection(parseContentProtection(xpp));
    }
  } while (!isEndTag(xpp, "Representation"));

  Format format = buildFormat(id, mimeType, width, height, frameRate, numChannels,
      audioSamplingRate, bandwidth, language, codecs);
  return buildRepresentation(periodStartMs, periodDurationMs, contentId, -1, format,
      segmentBase != null ? segmentBase : new SingleSegmentBase(baseUrl));
}
项目:miku    文件:MediaPresentationDescriptionParser.java   
protected SegmentList buildSegmentList(RangedUri initialization, long timescale,
    long presentationTimeOffset, long periodDurationMs, int startNumber, long duration,
    List<SegmentTimelineElement> timeline, List<RangedUri> segments) {
  return new SegmentList(initialization, timescale, presentationTimeOffset, periodDurationMs,
      startNumber, duration, timeline, segments);
}
项目:ExoPlayer-Demo    文件:MediaPresentationDescriptionParser.java   
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String baseUrl,
    SegmentBase segmentBase) throws XmlPullParserException, IOException {
  int id = parseInt(xpp, "id", -1);
  int contentType = parseContentType(xpp);

  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String codecs = xpp.getAttributeValue(null, "codecs");
  int width = parseInt(xpp, "width", -1);
  int height = parseInt(xpp, "height", -1);
  float frameRate = parseFrameRate(xpp, -1);
  int audioChannels = -1;
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate", -1);
  String language = xpp.getAttributeValue(null, "lang");

  ContentProtectionsBuilder contentProtectionsBuilder = new ContentProtectionsBuilder();
  List<Representation> representations = new ArrayList<>();
  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (ParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (ParserUtil.isStartTag(xpp, "ContentProtection")) {
      ContentProtection contentProtection = parseContentProtection(xpp);
      if (contentProtection != null) {
        contentProtectionsBuilder.addAdaptationSetProtection(contentProtection);
      }
    } else if (ParserUtil.isStartTag(xpp, "ContentComponent")) {
      language = checkLanguageConsistency(language, xpp.getAttributeValue(null, "lang"));
      contentType = checkContentTypeConsistency(contentType, parseContentType(xpp));
    } else if (ParserUtil.isStartTag(xpp, "Representation")) {
      Representation representation = parseRepresentation(xpp, baseUrl, mimeType, codecs, width,
          height, frameRate, audioChannels, audioSamplingRate, language, segmentBase,
          contentProtectionsBuilder);
      contentProtectionsBuilder.endRepresentation();
      contentType = checkContentTypeConsistency(contentType, getContentType(representation));
      representations.add(representation);
    } else if (ParserUtil.isStartTag(xpp, "AudioChannelConfiguration")) {
      audioChannels = parseAudioChannelConfiguration(xpp);
    } else if (ParserUtil.isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (ParserUtil.isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase);
    } else if (ParserUtil.isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase);
    } else if (ParserUtil.isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!ParserUtil.isEndTag(xpp, "AdaptationSet"));

  return buildAdaptationSet(id, contentType, representations, contentProtectionsBuilder.build());
}
项目:ExoPlayer-Demo    文件:MediaPresentationDescriptionParser.java   
protected Representation parseRepresentation(XmlPullParser xpp, String baseUrl,
    String adaptationSetMimeType, String adaptationSetCodecs, int adaptationSetWidth,
    int adaptationSetHeight, float adaptationSetFrameRate, int adaptationSetAudioChannels,
    int adaptationSetAudioSamplingRate, String adaptationSetLanguage, SegmentBase segmentBase,
    ContentProtectionsBuilder contentProtectionsBuilder)
    throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth");

  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 language = adaptationSetLanguage;

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

  Format format = buildFormat(id, mimeType, width, height, frameRate, audioChannels,
      audioSamplingRate, bandwidth, language, codecs);
  return buildRepresentation(contentId, -1, format,
      segmentBase != null ? segmentBase : new SingleSegmentBase(baseUrl));
}
项目:ExoPlayer-Demo    文件:MediaPresentationDescriptionParser.java   
protected SegmentList buildSegmentList(RangedUri initialization, long timescale,
    long presentationTimeOffset, int startNumber, long duration,
    List<SegmentTimelineElement> timeline, List<RangedUri> segments) {
  return new SegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
项目:android-exoplayer    文件:MediaPresentationDescriptionParser.java   
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String contentId, Uri baseUrl,
    long periodStartMs, long periodDurationMs, SegmentBase segmentBase)
    throws XmlPullParserException, IOException {

  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String language = xpp.getAttributeValue(null, "lang");
  int contentType = parseAdaptationSetTypeFromMimeType(mimeType);

  int id = -1;
  List<ContentProtection> contentProtections = null;
  List<Representation> representations = new ArrayList<Representation>();
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "ContentProtection")) {
      if (contentProtections == null) {
        contentProtections = new ArrayList<ContentProtection>();
      }
      contentProtections.add(parseContentProtection(xpp));
    } else if (isStartTag(xpp, "ContentComponent")) {
      id = Integer.parseInt(xpp.getAttributeValue(null, "id"));
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetType(xpp.getAttributeValue(null, "contentType")));
    } else if (isStartTag(xpp, "Representation")) {
      Representation representation = parseRepresentation(xpp, contentId, baseUrl, periodStartMs,
          periodDurationMs, mimeType, language, segmentBase);
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetTypeFromMimeType(representation.format.mimeType));
      representations.add(representation);
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    } else if (isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!isEndTag(xpp, "AdaptationSet"));

  return buildAdaptationSet(id, contentType, representations, contentProtections);
}
项目:android-exoplayer    文件:MediaPresentationDescriptionParser.java   
protected SegmentList buildSegmentList(RangedUri initialization, long timescale,
    long presentationTimeOffset, long periodDuration, int startNumber, long duration,
    List<SegmentTimelineElement> timeline, List<RangedUri> segments) {
  return new SegmentList(initialization, timescale, presentationTimeOffset, periodDuration,
      startNumber, duration, timeline, segments);
}
项目:Exoplayer_VLC    文件:MediaPresentationDescriptionParser.java   
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String contentId, Uri baseUrl,
    long periodStartMs, long periodDurationMs, SegmentBase segmentBase)
    throws XmlPullParserException, IOException {

  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String language = xpp.getAttributeValue(null, "lang");
  int contentType = parseAdaptationSetTypeFromMimeType(mimeType);

  int id = -1;
  List<ContentProtection> contentProtections = null;
  List<Representation> representations = new ArrayList<Representation>();
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "ContentProtection")) {
      if (contentProtections == null) {
        contentProtections = new ArrayList<ContentProtection>();
      }
      contentProtections.add(parseContentProtection(xpp));
    } else if (isStartTag(xpp, "ContentComponent")) {
      id = Integer.parseInt(xpp.getAttributeValue(null, "id"));
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetType(xpp.getAttributeValue(null, "contentType")));
    } else if (isStartTag(xpp, "Representation")) {
      Representation representation = parseRepresentation(xpp, contentId, baseUrl, periodStartMs,
          periodDurationMs, mimeType, language, segmentBase);
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetTypeFromMimeType(representation.format.mimeType));
      representations.add(representation);
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    } else if (isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!isEndTag(xpp, "AdaptationSet"));

  return buildAdaptationSet(id, contentType, representations, contentProtections);
}
项目:Exoplayer_VLC    文件:MediaPresentationDescriptionParser.java   
protected SegmentList buildSegmentList(RangedUri initialization, long timescale,
    long presentationTimeOffset, long periodDurationMs, int startNumber, long duration,
    List<SegmentTimelineElement> timeline, List<RangedUri> segments) {
  return new SegmentList(initialization, timescale, presentationTimeOffset, periodDurationMs,
      startNumber, duration, timeline, segments);
}
项目:edx-app-android    文件:MediaPresentationDescriptionParser.java   
private AdaptationSet parseAdaptationSet(XmlPullParser xpp, String contentId, Uri baseUrl,
    long periodStartMs, long periodDurationMs, SegmentBase segmentBase)
    throws XmlPullParserException, IOException {

  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String language = xpp.getAttributeValue(null, "lang");
  int contentType = parseAdaptationSetTypeFromMimeType(mimeType);

  int id = -1;
  List<ContentProtection> contentProtections = null;
  List<Representation> representations = new ArrayList<Representation>();
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "ContentProtection")) {
      if (contentProtections == null) {
        contentProtections = new ArrayList<ContentProtection>();
      }
      contentProtections.add(parseContentProtection(xpp));
    } else if (isStartTag(xpp, "ContentComponent")) {
      id = Integer.parseInt(xpp.getAttributeValue(null, "id"));
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetType(xpp.getAttributeValue(null, "contentType")));
    } else if (isStartTag(xpp, "Representation")) {
      Representation representation = parseRepresentation(xpp, contentId, baseUrl, periodStartMs,
          periodDurationMs, mimeType, language, segmentBase);
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetTypeFromMimeType(representation.format.mimeType));
      representations.add(representation);
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    }
  } while (!isEndTag(xpp, "AdaptationSet"));

  return new AdaptationSet(id, contentType, representations, contentProtections);
}
项目:ExoPlayer    文件:MediaPresentationDescriptionParser.java   
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String baseUrl, long periodStartMs,
    long periodDurationMs, SegmentBase segmentBase) throws XmlPullParserException, IOException {

  int id = parseInt(xpp, "id", -1);
  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String language = xpp.getAttributeValue(null, "lang");
  int contentType = parseAdaptationSetType(xpp.getAttributeValue(null, "contentType"));
  if (contentType == AdaptationSet.TYPE_UNKNOWN) {
    contentType = parseAdaptationSetTypeFromMimeType(xpp.getAttributeValue(null, "mimeType"));
  }

  ContentProtectionsBuilder contentProtectionsBuilder = new ContentProtectionsBuilder();
  List<Representation> representations = new ArrayList<>();
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "ContentProtection")) {
      contentProtectionsBuilder.addAdaptationSetProtection(parseContentProtection(xpp));
    } else if (isStartTag(xpp, "ContentComponent")) {
      language = checkLanguageConsistency(language, xpp.getAttributeValue(null, "lang"));
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetType(xpp.getAttributeValue(null, "contentType")));
    } else if (isStartTag(xpp, "Representation")) {
      Representation representation = parseRepresentation(xpp, baseUrl, periodStartMs,
          periodDurationMs, mimeType, language, segmentBase, contentProtectionsBuilder);
      contentProtectionsBuilder.endRepresentation();
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetTypeFromMimeType(representation.format.mimeType));
      representations.add(representation);
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    } else if (isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!isEndTag(xpp, "AdaptationSet"));

  return buildAdaptationSet(id, contentType, representations, contentProtectionsBuilder.build());
}
项目:ExoPlayer    文件:MediaPresentationDescriptionParser.java   
protected Representation parseRepresentation(XmlPullParser xpp, String baseUrl,
    long periodStartMs, long periodDurationMs, String mimeType, String language,
    SegmentBase segmentBase, ContentProtectionsBuilder contentProtectionsBuilder)
    throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth");
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate");
  int width = parseInt(xpp, "width");
  int height = parseInt(xpp, "height");

  float frameRate = -1;
  String frameRateAttribute = xpp.getAttributeValue(null, "frameRate");
  if (frameRateAttribute != null) {
    Matcher frameRateMatcher = FRAME_RATE_PATTERN.matcher(frameRateAttribute);
    if (frameRateMatcher.matches()) {
      int numerator = Integer.parseInt(frameRateMatcher.group(1));
      String denominatorString = frameRateMatcher.group(2);
      if (!TextUtils.isEmpty(denominatorString)) {
        frameRate = (float) numerator / Integer.parseInt(denominatorString);
      } else {
        frameRate = numerator;
      }
    }
  }

  mimeType = parseString(xpp, "mimeType", mimeType);
  String codecs = parseString(xpp, "codecs", null);

  int numChannels = -1;
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "AudioChannelConfiguration")) {
      numChannels = Integer.parseInt(xpp.getAttributeValue(null, "value"));
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    } else if (isStartTag(xpp, "ContentProtection")) {
      contentProtectionsBuilder.addRepresentationProtection(parseContentProtection(xpp));
    }
  } while (!isEndTag(xpp, "Representation"));

  Format format = buildFormat(id, mimeType, width, height, frameRate, numChannels,
      audioSamplingRate, bandwidth, language, codecs);
  return buildRepresentation(periodStartMs, periodDurationMs, contentId, -1, format,
      segmentBase != null ? segmentBase : new SingleSegmentBase(baseUrl));
}
项目:ExoPlayer    文件:MediaPresentationDescriptionParser.java   
protected SegmentList buildSegmentList(RangedUri initialization, long timescale,
    long presentationTimeOffset, long periodDurationMs, int startNumber, long duration,
    List<SegmentTimelineElement> timeline, List<RangedUri> segments) {
  return new SegmentList(initialization, timescale, presentationTimeOffset, periodDurationMs,
      startNumber, duration, timeline, segments);
}