Java Code Examples for com.google.android.exoplayer2.source.dash.manifest.Period#getAdaptationSetIndex()

The following examples show how to use com.google.android.exoplayer2.source.dash.manifest.Period#getAdaptationSetIndex() . 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: DashUtil.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Nullable
private static 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 2
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 3
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 4
Source File: OfflineLicenseHelper.java    From K-Sonic with MIT License 5 votes vote down vote up
/**
 * Downloads an offline license.
 *
 * @param dataSource The {@link HttpDataSource} to be used for download.
 * @param dashManifest The {@link DashManifest} of the DASH content.
 * @return The downloaded offline license key set id.
 * @throws IOException If an error occurs reading data from the stream.
 * @throws InterruptedException If the thread has been interrupted.
 * @throws DrmSessionException Thrown when there is an error during DRM session.
 */
public byte[] download(HttpDataSource dataSource, DashManifest dashManifest)
    throws IOException, InterruptedException, DrmSessionException {
  // Get DrmInitData
  // Prefer drmInitData obtained from the manifest over drmInitData obtained from the stream,
  // as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
  if (dashManifest.getPeriodCount() < 1) {
    return null;
  }
  Period period = dashManifest.getPeriod(0);
  int adaptationSetIndex = period.getAdaptationSetIndex(C.TRACK_TYPE_VIDEO);
  if (adaptationSetIndex == C.INDEX_UNSET) {
    adaptationSetIndex = period.getAdaptationSetIndex(C.TRACK_TYPE_AUDIO);
    if (adaptationSetIndex == C.INDEX_UNSET) {
      return null;
    }
  }
  AdaptationSet adaptationSet = period.adaptationSets.get(adaptationSetIndex);
  if (adaptationSet.representations.isEmpty()) {
    return null;
  }
  Representation representation = adaptationSet.representations.get(0);
  DrmInitData drmInitData = representation.format.drmInitData;
  if (drmInitData == null) {
    Format sampleFormat = DashUtil.loadSampleFormat(dataSource, representation);
    if (sampleFormat != null) {
      drmInitData = sampleFormat.drmInitData;
    }
    if (drmInitData == null) {
      return null;
    }
  }
  blockingKeyRequest(DefaultDrmSessionManager.MODE_DOWNLOAD, null, drmInitData);
  return drmSessionManager.getOfflineLicenseKeySetId();
}
 
Example 5
Source File: DashUtil.java    From Telegram-FOSS 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 6
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);
}