Java Code Examples for com.google.android.exoplayer2.source.dash.manifest.DashManifest#getPeriodDurationUs()

The following examples show how to use com.google.android.exoplayer2.source.dash.manifest.DashManifest#getPeriodDurationUs() . 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: DashDownloader.java    From Telegram with GNU General Public License v2.0 7 votes vote down vote up
@Override
protected List<Segment> getSegments(
    DataSource dataSource, DashManifest manifest, boolean allowIncompleteList)
    throws InterruptedException, IOException {
  ArrayList<Segment> segments = new ArrayList<>();
  for (int i = 0; i < manifest.getPeriodCount(); i++) {
    Period period = manifest.getPeriod(i);
    long periodStartUs = C.msToUs(period.startMs);
    long periodDurationUs = manifest.getPeriodDurationUs(i);
    List<AdaptationSet> adaptationSets = period.adaptationSets;
    for (int j = 0; j < adaptationSets.size(); j++) {
      addSegmentsForAdaptationSet(
          dataSource,
          adaptationSets.get(j),
          periodStartUs,
          periodDurationUs,
          allowIncompleteList,
          segments);
    }
  }
  return segments;
}
 
Example 2
Source File: DashDownloader.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
protected List<Segment> getSegments(
    DataSource dataSource, DashManifest manifest, boolean allowIncompleteList)
    throws InterruptedException, IOException {
  ArrayList<Segment> segments = new ArrayList<>();
  for (int i = 0; i < manifest.getPeriodCount(); i++) {
    Period period = manifest.getPeriod(i);
    long periodStartUs = C.msToUs(period.startMs);
    long periodDurationUs = manifest.getPeriodDurationUs(i);
    List<AdaptationSet> adaptationSets = period.adaptationSets;
    for (int j = 0; j < adaptationSets.size(); j++) {
      addSegmentsForAdaptationSet(
          dataSource,
          adaptationSets.get(j),
          periodStartUs,
          periodDurationUs,
          allowIncompleteList,
          segments);
    }
  }
  return segments;
}
 
Example 3
Source File: DashDownloader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected List<Segment> getSegments(
    DataSource dataSource, DashManifest manifest, boolean allowIncompleteList)
    throws InterruptedException, IOException {
  ArrayList<Segment> segments = new ArrayList<>();
  for (int i = 0; i < manifest.getPeriodCount(); i++) {
    Period period = manifest.getPeriod(i);
    long periodStartUs = C.msToUs(period.startMs);
    long periodDurationUs = manifest.getPeriodDurationUs(i);
    List<AdaptationSet> adaptationSets = period.adaptationSets;
    for (int j = 0; j < adaptationSets.size(); j++) {
      addSegmentsForAdaptationSet(
          dataSource,
          adaptationSets.get(j),
          periodStartUs,
          periodDurationUs,
          allowIncompleteList,
          segments);
    }
  }
  return segments;
}
 
Example 4
Source File: DashDownloader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected List<Segment> getSegments(
    DataSource dataSource, DashManifest manifest, boolean allowIncompleteList)
    throws InterruptedException, IOException {
  ArrayList<Segment> segments = new ArrayList<>();
  for (int i = 0; i < manifest.getPeriodCount(); i++) {
    Period period = manifest.getPeriod(i);
    long periodStartUs = C.msToUs(period.startMs);
    long periodDurationUs = manifest.getPeriodDurationUs(i);
    List<AdaptationSet> adaptationSets = period.adaptationSets;
    for (int j = 0; j < adaptationSets.size(); j++) {
      addSegmentsForAdaptationSet(
          dataSource,
          adaptationSets.get(j),
          periodStartUs,
          periodDurationUs,
          allowIncompleteList,
          segments);
    }
  }
  return segments;
}
 
Example 5
Source File: DefaultDashChunkSource.java    From K-Sonic with MIT License 6 votes vote down vote up
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the period in the manifest.
 * @param adaptationSetIndex The index of the adaptation set in the period.
 * @param trackSelection The track selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between
 *     server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified
 *     as the server's unix time minus the local elapsed time. If unknown, set to 0.
 * @param maxSegmentsPerLoad The maximum number of segments to combine into a single request.
 *     Note that segments will only be combined if their {@link Uri}s are the same and if their
 *     data ranges are adjacent.
 * @param enableEventMessageTrack Whether the chunks generated by the source may output an event
 *     message track.
 * @param enableEventMessageTrack Whether the chunks generated by the source may output a CEA-608
 *     track.
 */
public DefaultDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest, int periodIndex, int adaptationSetIndex, TrackSelection trackSelection,
    DataSource dataSource, long elapsedRealtimeOffsetMs, int maxSegmentsPerLoad,
    boolean enableEventMessageTrack, boolean enableCea608Track) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.adaptationSetIndex = adaptationSetIndex;
  this.trackSelection = trackSelection;
  this.dataSource = dataSource;
  this.periodIndex = periodIndex;
  this.elapsedRealtimeOffsetMs = elapsedRealtimeOffsetMs;
  this.maxSegmentsPerLoad = maxSegmentsPerLoad;

  long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
  AdaptationSet adaptationSet = getAdaptationSet();
  List<Representation> representations = adaptationSet.representations;
  representationHolders = new RepresentationHolder[trackSelection.length()];
  for (int i = 0; i < representationHolders.length; i++) {
    Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
    representationHolders[i] = new RepresentationHolder(periodDurationUs, representation,
        enableEventMessageTrack, enableCea608Track, adaptationSet.type);
  }
}
 
Example 6
Source File: DashDownloader.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected List<Segment> getSegments(
    DataSource dataSource, DashManifest manifest, boolean allowIncompleteList)
    throws InterruptedException, IOException {
  ArrayList<Segment> segments = new ArrayList<>();
  for (int i = 0; i < manifest.getPeriodCount(); i++) {
    Period period = manifest.getPeriod(i);
    long periodStartUs = C.msToUs(period.startMs);
    long periodDurationUs = manifest.getPeriodDurationUs(i);
    List<AdaptationSet> adaptationSets = period.adaptationSets;
    for (int j = 0; j < adaptationSets.size(); j++) {
      addSegmentsForAdaptationSet(
          dataSource,
          adaptationSets.get(j),
          periodStartUs,
          periodDurationUs,
          allowIncompleteList,
          segments);
    }
  }
  return segments;
}
 
Example 7
Source File: DefaultDashChunkSource.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the period in the manifest.
 * @param adaptationSetIndices The indices of the adaptation sets in the period.
 * @param trackSelection The track selection.
 * @param trackType The type of the tracks in the selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between
 *     server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified
 *     as the server's unix time minus the local elapsed time. If unknown, set to 0.
 * @param maxSegmentsPerLoad The maximum number of segments to combine into a single request. Note
 *     that segments will only be combined if their {@link Uri}s are the same and if their data
 *     ranges are adjacent.
 * @param enableEventMessageTrack Whether to output an event message track.
 * @param closedCaptionFormats The {@link Format Formats} of closed caption tracks to be output.
 * @param playerTrackEmsgHandler The {@link PlayerTrackEmsgHandler} instance to handle emsg
 *     messages targeting the player. Maybe null if this is not necessary.
 */
public DefaultDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int trackType,
    DataSource dataSource,
    long elapsedRealtimeOffsetMs,
    int maxSegmentsPerLoad,
    boolean enableEventMessageTrack,
    List<Format> closedCaptionFormats,
    @Nullable PlayerTrackEmsgHandler playerTrackEmsgHandler) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.adaptationSetIndices = adaptationSetIndices;
  this.trackSelection = trackSelection;
  this.trackType = trackType;
  this.dataSource = dataSource;
  this.periodIndex = periodIndex;
  this.elapsedRealtimeOffsetMs = elapsedRealtimeOffsetMs;
  this.maxSegmentsPerLoad = maxSegmentsPerLoad;
  this.playerTrackEmsgHandler = playerTrackEmsgHandler;

  long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
  liveEdgeTimeUs = C.TIME_UNSET;

  List<Representation> representations = getRepresentations();
  representationHolders = new RepresentationHolder[trackSelection.length()];
  for (int i = 0; i < representationHolders.length; i++) {
    Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
    representationHolders[i] =
        new RepresentationHolder(
            periodDurationUs,
            trackType,
            representation,
            enableEventMessageTrack,
            closedCaptionFormats,
            playerTrackEmsgHandler);
  }
}
 
Example 8
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the period in the manifest.
 * @param adaptationSetIndices The indices of the adaptation sets in the period.
 * @param trackSelection The track selection.
 * @param trackType The type of the tracks in the selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between
 *     server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified
 *     as the server's unix time minus the local elapsed time. If unknown, set to 0.
 * @param maxSegmentsPerLoad The maximum number of segments to combine into a single request. Note
 *     that segments will only be combined if their {@link Uri}s are the same and if their data
 *     ranges are adjacent.
 * @param enableEventMessageTrack Whether the chunks generated by the source may output an event
 *     message track.
 * @param enableCea608Track Whether the chunks generated by the source may output a CEA-608 track.
 * @param playerTrackEmsgHandler The {@link PlayerTrackEmsgHandler} instance to handle emsg
 *     messages targeting the player. Maybe null if this is not necessary.
 */
public DefaultDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int trackType,
    DataSource dataSource,
    long elapsedRealtimeOffsetMs,
    int maxSegmentsPerLoad,
    boolean enableEventMessageTrack,
    boolean enableCea608Track,
    @Nullable PlayerTrackEmsgHandler playerTrackEmsgHandler) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.adaptationSetIndices = adaptationSetIndices;
  this.trackSelection = trackSelection;
  this.trackType = trackType;
  this.dataSource = dataSource;
  this.periodIndex = periodIndex;
  this.elapsedRealtimeOffsetMs = elapsedRealtimeOffsetMs;
  this.maxSegmentsPerLoad = maxSegmentsPerLoad;
  this.playerTrackEmsgHandler = playerTrackEmsgHandler;

  long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
  liveEdgeTimeUs = C.TIME_UNSET;

  List<Representation> representations = getRepresentations();
  representationHolders = new RepresentationHolder[trackSelection.length()];
  for (int i = 0; i < representationHolders.length; i++) {
    Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
    representationHolders[i] =
        new RepresentationHolder(
            periodDurationUs,
            trackType,
            representation,
            enableEventMessageTrack,
            enableCea608Track,
            playerTrackEmsgHandler);
  }
}
 
Example 9
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the period in the manifest.
 * @param adaptationSetIndices The indices of the adaptation sets in the period.
 * @param trackSelection The track selection.
 * @param trackType The type of the tracks in the selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between
 *     server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified
 *     as the server's unix time minus the local elapsed time. If unknown, set to 0.
 * @param maxSegmentsPerLoad The maximum number of segments to combine into a single request. Note
 *     that segments will only be combined if their {@link Uri}s are the same and if their data
 *     ranges are adjacent.
 * @param enableEventMessageTrack Whether the chunks generated by the source may output an event
 *     message track.
 * @param enableCea608Track Whether the chunks generated by the source may output a CEA-608 track.
 * @param playerTrackEmsgHandler The {@link PlayerTrackEmsgHandler} instance to handle emsg
 *     messages targeting the player. Maybe null if this is not necessary.
 */
public DefaultDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int trackType,
    DataSource dataSource,
    long elapsedRealtimeOffsetMs,
    int maxSegmentsPerLoad,
    boolean enableEventMessageTrack,
    boolean enableCea608Track,
    @Nullable PlayerTrackEmsgHandler playerTrackEmsgHandler) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.adaptationSetIndices = adaptationSetIndices;
  this.trackSelection = trackSelection;
  this.trackType = trackType;
  this.dataSource = dataSource;
  this.periodIndex = periodIndex;
  this.elapsedRealtimeOffsetMs = elapsedRealtimeOffsetMs;
  this.maxSegmentsPerLoad = maxSegmentsPerLoad;
  this.playerTrackEmsgHandler = playerTrackEmsgHandler;

  long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
  liveEdgeTimeUs = C.TIME_UNSET;

  List<Representation> representations = getRepresentations();
  representationHolders = new RepresentationHolder[trackSelection.length()];
  for (int i = 0; i < representationHolders.length; i++) {
    Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
    representationHolders[i] =
        new RepresentationHolder(
            periodDurationUs,
            trackType,
            representation,
            enableEventMessageTrack,
            enableCea608Track,
            playerTrackEmsgHandler);
  }
}
 
Example 10
Source File: DefaultDashChunkSource.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the period in the manifest.
 * @param adaptationSetIndices The indices of the adaptation sets in the period.
 * @param trackSelection The track selection.
 * @param trackType The type of the tracks in the selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between
 *     server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified
 *     as the server's unix time minus the local elapsed time. If unknown, set to 0.
 * @param maxSegmentsPerLoad The maximum number of segments to combine into a single request. Note
 *     that segments will only be combined if their {@link Uri}s are the same and if their data
 *     ranges are adjacent.
 * @param enableEventMessageTrack Whether to output an event message track.
 * @param closedCaptionFormats The {@link Format Formats} of closed caption tracks to be output.
 * @param playerTrackEmsgHandler The {@link PlayerTrackEmsgHandler} instance to handle emsg
 *     messages targeting the player. Maybe null if this is not necessary.
 */
public DefaultDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int trackType,
    DataSource dataSource,
    long elapsedRealtimeOffsetMs,
    int maxSegmentsPerLoad,
    boolean enableEventMessageTrack,
    List<Format> closedCaptionFormats,
    @Nullable PlayerTrackEmsgHandler playerTrackEmsgHandler) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.adaptationSetIndices = adaptationSetIndices;
  this.trackSelection = trackSelection;
  this.trackType = trackType;
  this.dataSource = dataSource;
  this.periodIndex = periodIndex;
  this.elapsedRealtimeOffsetMs = elapsedRealtimeOffsetMs;
  this.maxSegmentsPerLoad = maxSegmentsPerLoad;
  this.playerTrackEmsgHandler = playerTrackEmsgHandler;

  long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
  liveEdgeTimeUs = C.TIME_UNSET;

  List<Representation> representations = getRepresentations();
  representationHolders = new RepresentationHolder[trackSelection.length()];
  for (int i = 0; i < representationHolders.length; i++) {
    Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
    representationHolders[i] =
        new RepresentationHolder(
            periodDurationUs,
            trackType,
            representation,
            enableEventMessageTrack,
            closedCaptionFormats,
            playerTrackEmsgHandler);
  }
}
 
Example 11
Source File: DefaultDashChunkSource.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the period in the manifest.
 * @param adaptationSetIndices The indices of the adaptation sets in the period.
 * @param trackSelection The track selection.
 * @param trackType The type of the tracks in the selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between
 *     server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified
 *     as the server's unix time minus the local elapsed time. If unknown, set to 0.
 * @param maxSegmentsPerLoad The maximum number of segments to combine into a single request. Note
 *     that segments will only be combined if their {@link Uri}s are the same and if their data
 *     ranges are adjacent.
 * @param enableEventMessageTrack Whether to output an event message track.
 * @param closedCaptionFormats The {@link Format Formats} of closed caption tracks to be output.
 * @param playerTrackEmsgHandler The {@link PlayerTrackEmsgHandler} instance to handle emsg
 *     messages targeting the player. Maybe null if this is not necessary.
 */
public DefaultDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int trackType,
    DataSource dataSource,
    long elapsedRealtimeOffsetMs,
    int maxSegmentsPerLoad,
    boolean enableEventMessageTrack,
    List<Format> closedCaptionFormats,
    @Nullable PlayerTrackEmsgHandler playerTrackEmsgHandler) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.adaptationSetIndices = adaptationSetIndices;
  this.trackSelection = trackSelection;
  this.trackType = trackType;
  this.dataSource = dataSource;
  this.periodIndex = periodIndex;
  this.elapsedRealtimeOffsetMs = elapsedRealtimeOffsetMs;
  this.maxSegmentsPerLoad = maxSegmentsPerLoad;
  this.playerTrackEmsgHandler = playerTrackEmsgHandler;

  long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
  liveEdgeTimeUs = C.TIME_UNSET;

  List<Representation> representations = getRepresentations();
  representationHolders = new RepresentationHolder[trackSelection.length()];
  for (int i = 0; i < representationHolders.length; i++) {
    Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
    representationHolders[i] =
        new RepresentationHolder(
            periodDurationUs,
            trackType,
            representation,
            enableEventMessageTrack,
            closedCaptionFormats,
            playerTrackEmsgHandler);
  }
}