com.google.android.exoplayer2.source.dash.manifest.Representation Java Examples

The following examples show how to use com.google.android.exoplayer2.source.dash.manifest.Representation. 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: DefaultDashChunkSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
RepresentationHolder(
    long periodDurationUs,
    int trackType,
    Representation representation,
    boolean enableEventMessageTrack,
    List<Format> closedCaptionFormats,
    TrackOutput playerEmsgTrackOutput) {
  this(
      periodDurationUs,
      representation,
      createExtractorWrapper(
          trackType,
          representation,
          enableEventMessageTrack,
          closedCaptionFormats,
          playerEmsgTrackOutput),
      /* segmentNumShift= */ 0,
      representation.getIndex());
}
 
Example #2
Source File: DashUtil.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Loads {@link DrmInitData} for a given period in a DASH manifest.
 *
 * @param dataSource The {@link HttpDataSource} from which data should be loaded.
 * @param period The {@link Period}.
 * @return The loaded {@link DrmInitData}, or null if none is defined.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
@Nullable
public static DrmInitData loadDrmInitData(DataSource dataSource, Period period)
    throws IOException, InterruptedException {
  int primaryTrackType = C.TRACK_TYPE_VIDEO;
  Representation representation = getFirstRepresentation(period, primaryTrackType);
  if (representation == null) {
    primaryTrackType = C.TRACK_TYPE_AUDIO;
    representation = getFirstRepresentation(period, primaryTrackType);
    if (representation == null) {
      return null;
    }
  }
  Format manifestFormat = representation.format;
  Format sampleFormat = DashUtil.loadSampleFormat(dataSource, primaryTrackType, representation);
  return sampleFormat == null
      ? manifestFormat.drmInitData
      : sampleFormat.copyWithManifestFormatInfo(manifestFormat).drmInitData;
}
 
Example #3
Source File: DefaultDashChunkSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
RepresentationHolder(
    long periodDurationUs,
    int trackType,
    Representation representation,
    boolean enableEventMessageTrack,
    List<Format> closedCaptionFormats,
    @Nullable TrackOutput playerEmsgTrackOutput) {
  this(
      periodDurationUs,
      representation,
      createExtractorWrapper(
          trackType,
          representation,
          enableEventMessageTrack,
          closedCaptionFormats,
          playerEmsgTrackOutput),
      /* segmentNumShift= */ 0,
      representation.getIndex());
}
 
Example #4
Source File: DefaultDashChunkSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public void updateManifest(DashManifest newManifest, int newPeriodIndex) {
  try {
    manifest = newManifest;
    periodIndex = newPeriodIndex;
    long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
    List<Representation> representations = getRepresentations();
    for (int i = 0; i < representationHolders.length; i++) {
      Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
      representationHolders[i] =
          representationHolders[i].copyWithNewRepresentation(periodDurationUs, representation);
    }
  } catch (BehindLiveWindowException e) {
    fatalError = e;
  }
}
 
Example #5
Source File: DashUtil.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads {@link DrmInitData} for a given period in a DASH manifest.
 *
 * @param dataSource The {@link HttpDataSource} from which data should be loaded.
 * @param period The {@link Period}.
 * @return The loaded {@link DrmInitData}, or null if none is defined.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
public static @Nullable DrmInitData loadDrmInitData(DataSource dataSource, Period period)
    throws IOException, InterruptedException {
  int primaryTrackType = C.TRACK_TYPE_VIDEO;
  Representation representation = getFirstRepresentation(period, primaryTrackType);
  if (representation == null) {
    primaryTrackType = C.TRACK_TYPE_AUDIO;
    representation = getFirstRepresentation(period, primaryTrackType);
    if (representation == null) {
      return null;
    }
  }
  Format manifestFormat = representation.format;
  Format sampleFormat = DashUtil.loadSampleFormat(dataSource, primaryTrackType, representation);
  return sampleFormat == null
      ? manifestFormat.drmInitData
      : sampleFormat.copyWithManifestFormatInfo(manifestFormat).drmInitData;
}
 
Example #6
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void updateManifest(DashManifest newManifest, int newPeriodIndex) {
  try {
    manifest = newManifest;
    periodIndex = newPeriodIndex;
    long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
    List<Representation> representations = getRepresentations();
    for (int i = 0; i < representationHolders.length; i++) {
      Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
      representationHolders[i] =
          representationHolders[i].copyWithNewRepresentation(periodDurationUs, representation);
    }
  } catch (BehindLiveWindowException e) {
    fatalError = e;
  }
}
 
Example #7
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
RepresentationHolder(
    long periodDurationUs,
    int trackType,
    Representation representation,
    boolean enableEventMessageTrack,
    boolean enableCea608Track,
    TrackOutput playerEmsgTrackOutput) {
  this(
      periodDurationUs,
      representation,
      createExtractorWrapper(
          trackType,
          representation,
          enableEventMessageTrack,
          enableCea608Track,
          playerEmsgTrackOutput),
      /* segmentNumShift= */ 0,
      representation.getIndex());
}
 
Example #8
Source File: DashUtil.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads {@link DrmInitData} for a given period in a DASH manifest.
 *
 * @param dataSource The {@link HttpDataSource} from which data should be loaded.
 * @param period The {@link Period}.
 * @return The loaded {@link DrmInitData}, or null if none is defined.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
public static @Nullable DrmInitData loadDrmInitData(DataSource dataSource, Period period)
    throws IOException, InterruptedException {
  int primaryTrackType = C.TRACK_TYPE_VIDEO;
  Representation representation = getFirstRepresentation(period, primaryTrackType);
  if (representation == null) {
    primaryTrackType = C.TRACK_TYPE_AUDIO;
    representation = getFirstRepresentation(period, primaryTrackType);
    if (representation == null) {
      return null;
    }
  }
  Format manifestFormat = representation.format;
  Format sampleFormat = DashUtil.loadSampleFormat(dataSource, primaryTrackType, representation);
  return sampleFormat == null
      ? manifestFormat.drmInitData
      : sampleFormat.copyWithManifestFormatInfo(manifestFormat).drmInitData;
}
 
Example #9
Source File: DashUtil.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads {@link DrmInitData} for a given period in a DASH manifest.
 *
 * @param dataSource The {@link HttpDataSource} from which data should be loaded.
 * @param period The {@link Period}.
 * @return The loaded {@link DrmInitData}, or null if none is defined.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
public static @Nullable DrmInitData loadDrmInitData(DataSource dataSource, Period period)
    throws IOException, InterruptedException {
  int primaryTrackType = C.TRACK_TYPE_VIDEO;
  Representation representation = getFirstRepresentation(period, primaryTrackType);
  if (representation == null) {
    primaryTrackType = C.TRACK_TYPE_AUDIO;
    representation = getFirstRepresentation(period, primaryTrackType);
    if (representation == null) {
      return null;
    }
  }
  Format manifestFormat = representation.format;
  Format sampleFormat = DashUtil.loadSampleFormat(dataSource, primaryTrackType, representation);
  return sampleFormat == null
      ? manifestFormat.drmInitData
      : sampleFormat.copyWithManifestFormatInfo(manifestFormat).drmInitData;
}
 
Example #10
Source File: DashDownloadHelper.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public TrackGroupArray getTrackGroups(int periodIndex) {
  Assertions.checkNotNull(manifest);
  List<AdaptationSet> adaptationSets = manifest.getPeriod(periodIndex).adaptationSets;
  TrackGroup[] trackGroups = new TrackGroup[adaptationSets.size()];
  for (int i = 0; i < trackGroups.length; i++) {
    List<Representation> representations = adaptationSets.get(i).representations;
    Format[] formats = new Format[representations.size()];
    int representationsCount = representations.size();
    for (int j = 0; j < representationsCount; j++) {
      formats[j] = representations.get(j).format;
    }
    trackGroups[i] = new TrackGroup(formats);
  }
  return new TrackGroupArray(trackGroups);
}
 
Example #11
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void updateManifest(DashManifest newManifest, int newPeriodIndex) {
  try {
    manifest = newManifest;
    periodIndex = newPeriodIndex;
    long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
    List<Representation> representations = getRepresentations();
    for (int i = 0; i < representationHolders.length; i++) {
      Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
      representationHolders[i] =
          representationHolders[i].copyWithNewRepresentation(periodDurationUs, representation);
    }
  } catch (BehindLiveWindowException e) {
    fatalError = e;
  }
}
 
Example #12
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
RepresentationHolder(
    long periodDurationUs,
    int trackType,
    Representation representation,
    boolean enableEventMessageTrack,
    boolean enableCea608Track,
    TrackOutput playerEmsgTrackOutput) {
  this(
      periodDurationUs,
      representation,
      createExtractorWrapper(
          trackType,
          representation,
          enableEventMessageTrack,
          enableCea608Track,
          playerEmsgTrackOutput),
      /* segmentNumShift= */ 0,
      representation.getIndex());
}
 
Example #13
Source File: DashDownloadHelper.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public TrackGroupArray getTrackGroups(int periodIndex) {
  Assertions.checkNotNull(manifest);
  List<AdaptationSet> adaptationSets = manifest.getPeriod(periodIndex).adaptationSets;
  TrackGroup[] trackGroups = new TrackGroup[adaptationSets.size()];
  for (int i = 0; i < trackGroups.length; i++) {
    List<Representation> representations = adaptationSets.get(i).representations;
    Format[] formats = new Format[representations.size()];
    int representationsCount = representations.size();
    for (int j = 0; j < representationsCount; j++) {
      formats[j] = representations.get(j).format;
    }
    trackGroups[i] = new TrackGroup(formats);
  }
  return new TrackGroupArray(trackGroups);
}
 
Example #14
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 #15
Source File: DefaultDashChunkSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void updateManifest(DashManifest newManifest, int newPeriodIndex) {
  try {
    manifest = newManifest;
    periodIndex = newPeriodIndex;
    long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
    List<Representation> representations = getRepresentations();
    for (int i = 0; i < representationHolders.length; i++) {
      Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
      representationHolders[i] =
          representationHolders[i].copyWithNewRepresentation(periodDurationUs, representation);
    }
  } catch (BehindLiveWindowException e) {
    fatalError = e;
  }
}
 
Example #16
Source File: DefaultDashChunkSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
RepresentationHolder(
    long periodDurationUs,
    int trackType,
    Representation representation,
    boolean enableEventMessageTrack,
    List<Format> closedCaptionFormats,
    TrackOutput playerEmsgTrackOutput) {
  this(
      periodDurationUs,
      representation,
      createExtractorWrapper(
          trackType,
          representation,
          enableEventMessageTrack,
          closedCaptionFormats,
          playerEmsgTrackOutput),
      /* segmentNumShift= */ 0,
      representation.getIndex());
}
 
Example #17
Source File: DashUtil.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads {@link DrmInitData} for a given period in a DASH manifest.
 *
 * @param dataSource The {@link HttpDataSource} from which data should be loaded.
 * @param period The {@link Period}.
 * @return The loaded {@link DrmInitData}, or null if none is defined.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
public static @Nullable DrmInitData loadDrmInitData(DataSource dataSource, Period period)
    throws IOException, InterruptedException {
  int primaryTrackType = C.TRACK_TYPE_VIDEO;
  Representation representation = getFirstRepresentation(period, primaryTrackType);
  if (representation == null) {
    primaryTrackType = C.TRACK_TYPE_AUDIO;
    representation = getFirstRepresentation(period, primaryTrackType);
    if (representation == null) {
      return null;
    }
  }
  Format manifestFormat = representation.format;
  Format sampleFormat = DashUtil.loadSampleFormat(dataSource, primaryTrackType, representation);
  return sampleFormat == null
      ? manifestFormat.drmInitData
      : sampleFormat.copyWithManifestFormatInfo(manifestFormat).drmInitData;
}
 
Example #18
Source File: DefaultDashChunkSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void updateManifest(DashManifest newManifest, int newPeriodIndex) {
  try {
    manifest = newManifest;
    periodIndex = newPeriodIndex;
    long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
    List<Representation> representations = getRepresentations();
    for (int i = 0; i < representationHolders.length; i++) {
      Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
      representationHolders[i] =
          representationHolders[i].copyWithNewRepresentation(periodDurationUs, representation);
    }
  } catch (BehindLiveWindowException e) {
    fatalError = e;
  }
}
 
Example #19
Source File: DashMediaPeriod.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private static boolean hasEventMessageTrack(List<AdaptationSet> adaptationSets,
    int[] adaptationSetIndices) {
  for (int i : adaptationSetIndices) {
    List<Representation> representations = adaptationSets.get(i).representations;
    for (int j = 0; j < representations.size(); j++) {
      Representation representation = representations.get(j);
      if (!representation.inbandEventStreams.isEmpty()) {
        return true;
      }
    }
  }
  return false;
}
 
Example #20
Source File: DashUtil.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private static @Nullable Representation getFirstRepresentation(Period period, int type) {
  int index = period.getAdaptationSetIndex(type);
  if (index == C.INDEX_UNSET) {
    return null;
  }
  List<Representation> representations = period.adaptationSets.get(index).representations;
  return representations.isEmpty() ? null : representations.get(0);
}
 
Example #21
Source File: DashUtil.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static void loadInitializationData(DataSource dataSource,
    Representation representation, ChunkExtractorWrapper extractorWrapper, RangedUri requestUri)
    throws IOException, InterruptedException {
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(representation.baseUrl),
      requestUri.start, requestUri.length, representation.getCacheKey());
  InitializationChunk initializationChunk = new InitializationChunk(dataSource, dataSpec,
      representation.format, C.SELECTION_REASON_UNKNOWN, null /* trackSelectionData */,
      extractorWrapper);
  initializationChunk.load();
}
 
Example #22
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static boolean hasEventMessageTrack(List<AdaptationSet> adaptationSets,
    int[] adaptationSetIndices) {
  for (int i : adaptationSetIndices) {
    List<Representation> representations = adaptationSets.get(i).representations;
    for (int j = 0; j < representations.size(); j++) {
      Representation representation = representations.get(j);
      if (!representation.inbandEventStreams.isEmpty()) {
        return true;
      }
    }
  }
  return false;
}
 
Example #23
Source File: DashDownloader.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static @Nullable DashSegmentIndex getSegmentIndex(
    DataSource dataSource, int trackType, Representation representation)
    throws IOException, InterruptedException {
  DashSegmentIndex index = representation.getIndex();
  if (index != null) {
    return index;
  }
  ChunkIndex seekMap = DashUtil.loadChunkIndex(dataSource, trackType, representation);
  return seekMap == null
      ? null
      : new DashWrappingSegmentIndex(seekMap, representation.presentationTimeOffsetUs);
}
 
Example #24
Source File: DashUtil.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static @Nullable Representation getFirstRepresentation(Period period, int type) {
  int index = period.getAdaptationSetIndex(type);
  if (index == C.INDEX_UNSET) {
    return null;
  }
  List<Representation> representations = period.adaptationSets.get(index).representations;
  return representations.isEmpty() ? null : representations.get(0);
}
 
Example #25
Source File: DefaultDashChunkSource.java    From K-Sonic with MIT License 5 votes vote down vote up
@Override
public void updateManifest(DashManifest newManifest, int newPeriodIndex) {
  try {
    manifest = newManifest;
    periodIndex = newPeriodIndex;
    long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
    List<Representation> representations = getAdaptationSet().representations;
    for (int i = 0; i < representationHolders.length; i++) {
      Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
      representationHolders[i].updateRepresentation(periodDurationUs, representation);
    }
  } catch (BehindLiveWindowException e) {
    fatalError = e;
  }
}
 
Example #26
Source File: DashUtil.java    From K-Sonic with MIT License 5 votes vote down vote up
/**
 * Loads initialization data for the {@code representation} and optionally index data then
 * returns a {@link ChunkExtractorWrapper} which contains the output.
 *
 * @param dataSource The source from which the data should be loaded.
 * @param representation The representation which initialization chunk belongs to.
 * @param loadIndex Whether to load index data too.
 * @return A {@link ChunkExtractorWrapper} for the {@code representation}, or null if no
 *     initialization or (if requested) index data exists.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
private static ChunkExtractorWrapper loadInitializationData(DataSource dataSource,
    Representation representation, boolean loadIndex)
    throws IOException, InterruptedException {
  RangedUri initializationUri = representation.getInitializationUri();
  if (initializationUri == null) {
    return null;
  }
  ChunkExtractorWrapper extractorWrapper = newWrappedExtractor(representation.format);
  RangedUri requestUri;
  if (loadIndex) {
    RangedUri indexUri = representation.getIndexUri();
    if (indexUri == null) {
      return null;
    }
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, representation.baseUrl);
    if (requestUri == null) {
      loadInitializationData(dataSource, representation, extractorWrapper, initializationUri);
      requestUri = indexUri;
    }
  } else {
    requestUri = initializationUri;
  }
  loadInitializationData(dataSource, representation, extractorWrapper, requestUri);
  return extractorWrapper;
}
 
Example #27
Source File: DashUtil.java    From K-Sonic with MIT License 5 votes vote down vote up
private static void loadInitializationData(DataSource dataSource,
    Representation representation, ChunkExtractorWrapper extractorWrapper, RangedUri requestUri)
    throws IOException, InterruptedException {
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(representation.baseUrl),
      requestUri.start, requestUri.length, representation.getCacheKey());
  InitializationChunk initializationChunk = new InitializationChunk(dataSource, dataSpec,
      representation.format, C.SELECTION_REASON_UNKNOWN, null /* trackSelectionData */,
      extractorWrapper);
  initializationChunk.load();
}
 
Example #28
Source File: DashMediaPeriod.java    From K-Sonic with MIT License 5 votes vote down vote up
private static boolean hasEventMessageTrack(AdaptationSet adaptationSet) {
  List<Representation> representations = adaptationSet.representations;
  for (int i = 0; i < representations.size(); i++) {
    Representation representation = representations.get(i);
    if (!representation.inbandEventStreams.isEmpty()) {
      return true;
    }
  }
  return false;
}
 
Example #29
Source File: DashUtil.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Loads initialization data for the {@code representation} and optionally index data then returns
 * a {@link ChunkExtractorWrapper} which contains the output.
 *
 * @param dataSource The source from which the data should be loaded.
 * @param trackType The type of the representation. Typically one of the {@link
 *     com.google.android.exoplayer2.C} {@code TRACK_TYPE_*} constants.
 * @param representation The representation which initialization chunk belongs to.
 * @param loadIndex Whether to load index data too.
 * @return A {@link ChunkExtractorWrapper} for the {@code representation}, or null if no
 *     initialization or (if requested) index data exists.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
private static @Nullable ChunkExtractorWrapper loadInitializationData(
    DataSource dataSource, int trackType, Representation representation, boolean loadIndex)
    throws IOException, InterruptedException {
  RangedUri initializationUri = representation.getInitializationUri();
  if (initializationUri == null) {
    return null;
  }
  ChunkExtractorWrapper extractorWrapper = newWrappedExtractor(trackType, representation.format);
  RangedUri requestUri;
  if (loadIndex) {
    RangedUri indexUri = representation.getIndexUri();
    if (indexUri == null) {
      return null;
    }
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, representation.baseUrl);
    if (requestUri == null) {
      loadInitializationData(dataSource, representation, extractorWrapper, initializationUri);
      requestUri = indexUri;
    }
  } else {
    requestUri = initializationUri;
  }
  loadInitializationData(dataSource, representation, extractorWrapper, requestUri);
  return extractorWrapper;
}
 
Example #30
Source File: DefaultDashChunkSource.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private RepresentationHolder(
    long periodDurationUs,
    Representation representation,
    @Nullable ChunkExtractorWrapper extractorWrapper,
    long segmentNumShift,
    @Nullable DashSegmentIndex segmentIndex) {
  this.periodDurationUs = periodDurationUs;
  this.representation = representation;
  this.segmentNumShift = segmentNumShift;
  this.extractorWrapper = extractorWrapper;
  this.segmentIndex = segmentIndex;
}