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

The following examples show how to use com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SegmentTimelineElement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DashManifestParser.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
protected 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 TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
protected List<SegmentTimelineElement> parseSegmentTimeline(XmlPullParser xpp)
    throws XmlPullParserException, IOException {
  List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
  long elapsedTime = 0;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "S")) {
      elapsedTime = parseLong(xpp, "t", elapsedTime);
      long duration = parseLong(xpp, "d", C.TIME_UNSET);
      int count = 1 + parseInt(xpp, "r", 0);
      for (int i = 0; i < count; i++) {
        segmentTimeline.add(buildSegmentTimelineElement(elapsedTime, duration));
        elapsedTime += duration;
      }
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentTimeline"));
  return segmentTimeline;
}
 
Example #3
Source File: DashManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
protected List<SegmentTimelineElement> parseSegmentTimeline(XmlPullParser xpp)
    throws XmlPullParserException, IOException {
  List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
  long elapsedTime = 0;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "S")) {
      elapsedTime = parseLong(xpp, "t", elapsedTime);
      long duration = parseLong(xpp, "d", C.TIME_UNSET);
      int count = 1 + parseInt(xpp, "r", 0);
      for (int i = 0; i < count; i++) {
        segmentTimeline.add(buildSegmentTimelineElement(elapsedTime, duration));
        elapsedTime += duration;
      }
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentTimeline"));
  return segmentTimeline;
}
 
Example #4
Source File: DashManifestParser.java    From K-Sonic with MIT License 6 votes vote down vote up
protected List<SegmentTimelineElement> parseSegmentTimeline(XmlPullParser xpp)
    throws XmlPullParserException, IOException {
  List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
  long elapsedTime = 0;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "S")) {
      elapsedTime = parseLong(xpp, "t", elapsedTime);
      long duration = parseLong(xpp, "d", C.TIME_UNSET);
      int count = 1 + parseInt(xpp, "r", 0);
      for (int i = 0; i < count; i++) {
        segmentTimeline.add(buildSegmentTimelineElement(elapsedTime, duration));
        elapsedTime += duration;
      }
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentTimeline"));
  return segmentTimeline;
}
 
Example #5
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 #6
Source File: DashManifestParser.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Adds timeline elements for one S tag to the segment timeline.
 *
 * @param startTime Start time of the first timeline element.
 * @param elementDuration Duration of one timeline element.
 * @param elementRepeatCount Number of timeline elements minus one. May be negative to indicate
 *     that the count is determined by the total duration and the element duration.
 * @param endTime End time of the last timeline element for this S tag, or {@link C#TIME_UNSET} if
 *     unknown. Only needed if {@code repeatCount} is negative.
 * @return Calculated next start time.
 */
private long addSegmentTimelineElementsToList(
    List<SegmentTimelineElement> segmentTimeline,
    long startTime,
    long elementDuration,
    int elementRepeatCount,
    long endTime) {
  int count =
      elementRepeatCount >= 0
          ? 1 + elementRepeatCount
          : (int) Util.ceilDivide(endTime - startTime, elementDuration);
  for (int i = 0; i < count; i++) {
    segmentTimeline.add(buildSegmentTimelineElement(startTime, elementDuration));
    startTime += elementDuration;
  }
  return startTime;
}
 
Example #7
Source File: DashManifestParser.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
protected List<SegmentTimelineElement> parseSegmentTimeline(XmlPullParser xpp)
    throws XmlPullParserException, IOException {
  List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
  long elapsedTime = 0;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "S")) {
      elapsedTime = parseLong(xpp, "t", elapsedTime);
      long duration = parseLong(xpp, "d", C.TIME_UNSET);
      int count = 1 + parseInt(xpp, "r", 0);
      for (int i = 0; i < count; i++) {
        segmentTimeline.add(buildSegmentTimelineElement(elapsedTime, duration));
        elapsedTime += duration;
      }
    } else {
      maybeSkipTag(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentTimeline"));
  return segmentTimeline;
}
 
Example #8
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 #9
Source File: DashManifestParser.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
protected List<SegmentTimelineElement> parseSegmentTimeline(XmlPullParser xpp)
    throws XmlPullParserException, IOException {
  List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
  long elapsedTime = 0;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "S")) {
      elapsedTime = parseLong(xpp, "t", elapsedTime);
      long duration = parseLong(xpp, "d", C.TIME_UNSET);
      int count = 1 + parseInt(xpp, "r", 0);
      for (int i = 0; i < count; i++) {
        segmentTimeline.add(buildSegmentTimelineElement(elapsedTime, duration));
        elapsedTime += duration;
      }
    } else {
      maybeSkipTag(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentTimeline"));
  return segmentTimeline;
}
 
Example #10
Source File: DashManifestParser.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
protected SegmentList buildSegmentList(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long duration,
    List<SegmentTimelineElement> timeline,
    List<RangedUri> segments) {
  return new SegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
 
Example #11
Source File: DashManifestParser.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
protected SegmentList parseSegmentList(XmlPullParser xpp, SegmentList parent)
    throws XmlPullParserException, IOException {

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

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

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

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

  return buildSegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
 
Example #12
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 #13
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 #14
Source File: DashManifestParser.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
protected SegmentList parseSegmentList(XmlPullParser xpp, SegmentList parent)
    throws XmlPullParserException, IOException {

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

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

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

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

  return buildSegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
 
Example #15
Source File: DashManifestParser.java    From K-Sonic with MIT License 5 votes vote down vote up
protected SegmentList parseSegmentList(XmlPullParser xpp, SegmentList parent)
    throws XmlPullParserException, IOException {

  long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
  long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
      parent != null ? parent.presentationTimeOffset : 0);
  long duration = parseLong(xpp, "duration", parent != null ? parent.duration : C.TIME_UNSET);
  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 (XmlPullParserUtil.isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTimeline")) {
      timeline = parseSegmentTimeline(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentURL")) {
      if (segments == null) {
        segments = new ArrayList<>();
      }
      segments.add(parseSegmentUrl(xpp));
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentList"));

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

  return buildSegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
 
Example #16
Source File: DashManifestParser.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
protected SegmentList buildSegmentList(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long duration,
    List<SegmentTimelineElement> timeline,
    List<RangedUri> segments) {
  return new SegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
 
Example #17
Source File: DashManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
protected SegmentList buildSegmentList(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long duration,
    List<SegmentTimelineElement> timeline,
    List<RangedUri> segments) {
  return new SegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
 
Example #18
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 #19
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 #20
Source File: DashManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
protected SegmentList parseSegmentList(XmlPullParser xpp, SegmentList parent)
    throws XmlPullParserException, IOException {

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

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

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

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

  return buildSegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
 
Example #21
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 #22
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 #23
Source File: DashManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
protected SegmentList buildSegmentList(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long duration,
    List<SegmentTimelineElement> timeline,
    List<RangedUri> segments) {
  return new SegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
 
Example #24
Source File: DashManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
protected SegmentList parseSegmentList(XmlPullParser xpp, SegmentList parent)
    throws XmlPullParserException, IOException {

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

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

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

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

  return buildSegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
 
Example #25
Source File: DashManifestParser.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
protected SegmentList parseSegmentList(
    XmlPullParser xpp, @Nullable 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 : C.TIME_UNSET);
  long startNumber = parseLong(xpp, "startNumber", parent != null ? parent.startNumber : 1);

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

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

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

  return buildSegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
 
Example #26
Source File: DashManifestParser.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
protected SegmentList buildSegmentList(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long duration,
    @Nullable List<SegmentTimelineElement> timeline,
    @Nullable List<RangedUri> segments) {
  return new SegmentList(initialization, timescale, presentationTimeOffset,
      startNumber, duration, timeline, segments);
}
 
Example #27
Source File: DashManifestParser.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
protected SegmentTimelineElement buildSegmentTimelineElement(long elapsedTime, long duration) {
  return new SegmentTimelineElement(elapsedTime, duration);
}
 
Example #28
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 #29
Source File: DashManifestParser.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
protected SegmentTimelineElement buildSegmentTimelineElement(long elapsedTime, long duration) {
  return new SegmentTimelineElement(elapsedTime, duration);
}
 
Example #30
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);
}