com.google.android.exoplayer2.source.hls.playlist.HlsMasterPlaylist Java Examples

The following examples show how to use com.google.android.exoplayer2.source.hls.playlist.HlsMasterPlaylist. 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: HlsDownloadHelper.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(playlist);
  if (playlist instanceof HlsMediaPlaylist) {
    renditionGroups = new int[0];
    return TrackGroupArray.EMPTY;
  }
  // TODO: Generate track groups as in playback. Reverse the mapping in getDownloadAction.
  HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) playlist;
  TrackGroup[] trackGroups = new TrackGroup[3];
  renditionGroups = new int[3];
  int trackGroupIndex = 0;
  if (!masterPlaylist.variants.isEmpty()) {
    renditionGroups[trackGroupIndex] = HlsMasterPlaylist.GROUP_INDEX_VARIANT;
    trackGroups[trackGroupIndex++] = new TrackGroup(toFormats(masterPlaylist.variants));
  }
  if (!masterPlaylist.audios.isEmpty()) {
    renditionGroups[trackGroupIndex] = HlsMasterPlaylist.GROUP_INDEX_AUDIO;
    trackGroups[trackGroupIndex++] = new TrackGroup(toFormats(masterPlaylist.audios));
  }
  if (!masterPlaylist.subtitles.isEmpty()) {
    renditionGroups[trackGroupIndex] = HlsMasterPlaylist.GROUP_INDEX_SUBTITLE;
    trackGroups[trackGroupIndex++] = new TrackGroup(toFormats(masterPlaylist.subtitles));
  }
  return new TrackGroupArray(Arrays.copyOf(trackGroups, trackGroupIndex));
}
 
Example #2
Source File: HlsDownloadHelper.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(playlist);
  if (playlist instanceof HlsMediaPlaylist) {
    renditionGroups = new int[0];
    return TrackGroupArray.EMPTY;
  }
  // TODO: Generate track groups as in playback. Reverse the mapping in getDownloadAction.
  HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) playlist;
  TrackGroup[] trackGroups = new TrackGroup[3];
  renditionGroups = new int[3];
  int trackGroupIndex = 0;
  if (!masterPlaylist.variants.isEmpty()) {
    renditionGroups[trackGroupIndex] = HlsMasterPlaylist.GROUP_INDEX_VARIANT;
    trackGroups[trackGroupIndex++] = new TrackGroup(toFormats(masterPlaylist.variants));
  }
  if (!masterPlaylist.audios.isEmpty()) {
    renditionGroups[trackGroupIndex] = HlsMasterPlaylist.GROUP_INDEX_AUDIO;
    trackGroups[trackGroupIndex++] = new TrackGroup(toFormats(masterPlaylist.audios));
  }
  if (!masterPlaylist.subtitles.isEmpty()) {
    renditionGroups[trackGroupIndex] = HlsMasterPlaylist.GROUP_INDEX_SUBTITLE;
    trackGroups[trackGroupIndex++] = new TrackGroup(toFormats(masterPlaylist.subtitles));
  }
  return new TrackGroupArray(Arrays.copyOf(trackGroups, trackGroupIndex));
}
 
Example #3
Source File: HlsDownloadHelper.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static Format[] toFormats(List<HlsMasterPlaylist.HlsUrl> hlsUrls) {
  Format[] formats = new Format[hlsUrls.size()];
  for (int i = 0; i < hlsUrls.size(); i++) {
    formats[i] = hlsUrls.get(i).format;
  }
  return formats;
}
 
Example #4
Source File: HlsSampleStreamWrapper.java    From K-Sonic with MIT License 5 votes vote down vote up
@Override
public boolean continueLoading(long positionUs) {
  if (loadingFinished || loader.isLoading()) {
    return false;
  }

  chunkSource.getNextChunk(mediaChunks.isEmpty() ? null : mediaChunks.getLast(),
      pendingResetPositionUs != C.TIME_UNSET ? pendingResetPositionUs : positionUs,
      nextChunkHolder);
  boolean endOfStream = nextChunkHolder.endOfStream;
  Chunk loadable = nextChunkHolder.chunk;
  HlsMasterPlaylist.HlsUrl playlistToLoad = nextChunkHolder.playlist;
  nextChunkHolder.clear();

  if (endOfStream) {
    loadingFinished = true;
    return true;
  }

  if (loadable == null) {
    if (playlistToLoad != null) {
      callback.onPlaylistRefreshRequired(playlistToLoad);
    }
    return false;
  }

  if (isMediaChunk(loadable)) {
    pendingResetPositionUs = C.TIME_UNSET;
    HlsMediaChunk mediaChunk = (HlsMediaChunk) loadable;
    mediaChunk.init(this);
    mediaChunks.add(mediaChunk);
  }
  long elapsedRealtimeMs = loader.startLoading(loadable, this, minLoadableRetryCount);
  eventDispatcher.loadStarted(loadable.dataSpec, loadable.type, trackType, loadable.trackFormat,
      loadable.trackSelectionReason, loadable.trackSelectionData, loadable.startTimeUs,
      loadable.endTimeUs, elapsedRealtimeMs);
  return true;
}
 
Example #5
Source File: HlsDownloadHelper.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static Format[] toFormats(List<HlsMasterPlaylist.HlsUrl> hlsUrls) {
  Format[] formats = new Format[hlsUrls.size()];
  for (int i = 0; i < hlsUrls.size(); i++) {
    formats[i] = hlsUrls.get(i).format;
  }
  return formats;
}
 
Example #6
Source File: HlsMediaPeriod.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public List<StreamKey> getStreamKeys(List<TrackSelection> trackSelections) {
  // See HlsMasterPlaylist.copy for interpretation of StreamKeys.
  HlsMasterPlaylist masterPlaylist = Assertions.checkNotNull(playlistTracker.getMasterPlaylist());
  boolean hasVariants = !masterPlaylist.variants.isEmpty();
  int audioWrapperOffset = hasVariants ? 1 : 0;
  // Subtitle sample stream wrappers are held last.
  int subtitleWrapperOffset = sampleStreamWrappers.length - masterPlaylist.subtitles.size();

  TrackGroupArray mainWrapperTrackGroups;
  int mainWrapperPrimaryGroupIndex;
  int[] mainWrapperVariantIndices;
  if (hasVariants) {
    HlsSampleStreamWrapper mainWrapper = sampleStreamWrappers[0];
    mainWrapperVariantIndices = manifestUrlIndicesPerWrapper[0];
    mainWrapperTrackGroups = mainWrapper.getTrackGroups();
    mainWrapperPrimaryGroupIndex = mainWrapper.getPrimaryTrackGroupIndex();
  } else {
    mainWrapperVariantIndices = new int[0];
    mainWrapperTrackGroups = TrackGroupArray.EMPTY;
    mainWrapperPrimaryGroupIndex = 0;
  }

  List<StreamKey> streamKeys = new ArrayList<>();
  boolean needsPrimaryTrackGroupSelection = false;
  boolean hasPrimaryTrackGroupSelection = false;
  for (TrackSelection trackSelection : trackSelections) {
    TrackGroup trackSelectionGroup = trackSelection.getTrackGroup();
    int mainWrapperTrackGroupIndex = mainWrapperTrackGroups.indexOf(trackSelectionGroup);
    if (mainWrapperTrackGroupIndex != C.INDEX_UNSET) {
      if (mainWrapperTrackGroupIndex == mainWrapperPrimaryGroupIndex) {
        // Primary group in main wrapper.
        hasPrimaryTrackGroupSelection = true;
        for (int i = 0; i < trackSelection.length(); i++) {
          int variantIndex = mainWrapperVariantIndices[trackSelection.getIndexInTrackGroup(i)];
          streamKeys.add(new StreamKey(HlsMasterPlaylist.GROUP_INDEX_VARIANT, variantIndex));
        }
      } else {
        // Embedded group in main wrapper.
        needsPrimaryTrackGroupSelection = true;
      }
    } else {
      // Audio or subtitle group.
      for (int i = audioWrapperOffset; i < sampleStreamWrappers.length; i++) {
        TrackGroupArray wrapperTrackGroups = sampleStreamWrappers[i].getTrackGroups();
        int selectedTrackGroupIndex = wrapperTrackGroups.indexOf(trackSelectionGroup);
        if (selectedTrackGroupIndex != C.INDEX_UNSET) {
          int groupIndexType =
              i < subtitleWrapperOffset
                  ? HlsMasterPlaylist.GROUP_INDEX_AUDIO
                  : HlsMasterPlaylist.GROUP_INDEX_SUBTITLE;
          int[] selectedWrapperUrlIndices = manifestUrlIndicesPerWrapper[i];
          for (int trackIndex = 0; trackIndex < trackSelection.length(); trackIndex++) {
            int renditionIndex =
                selectedWrapperUrlIndices[trackSelection.getIndexInTrackGroup(trackIndex)];
            streamKeys.add(new StreamKey(groupIndexType, renditionIndex));
          }
          break;
        }
      }
    }
  }
  if (needsPrimaryTrackGroupSelection && !hasPrimaryTrackGroupSelection) {
    // A track selection includes a variant-embedded track, but no variant is added yet. We use
    // the valid variant with the lowest bitrate to reduce overhead.
    int lowestBitrateIndex = mainWrapperVariantIndices[0];
    int lowestBitrate = masterPlaylist.variants.get(mainWrapperVariantIndices[0]).format.bitrate;
    for (int i = 1; i < mainWrapperVariantIndices.length; i++) {
      int variantBitrate =
          masterPlaylist.variants.get(mainWrapperVariantIndices[i]).format.bitrate;
      if (variantBitrate < lowestBitrate) {
        lowestBitrate = variantBitrate;
        lowestBitrateIndex = mainWrapperVariantIndices[i];
      }
    }
    streamKeys.add(new StreamKey(HlsMasterPlaylist.GROUP_INDEX_VARIANT, lowestBitrateIndex));
  }
  return streamKeys;
}
 
Example #7
Source File: HlsManifest.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
/**
 * @param masterPlaylist The master playlist.
 * @param mediaPlaylist The media playlist.
 */
HlsManifest(HlsMasterPlaylist masterPlaylist, HlsMediaPlaylist mediaPlaylist) {
  this.masterPlaylist = masterPlaylist;
  this.mediaPlaylist = mediaPlaylist;
}
 
Example #8
Source File: HlsManifest.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param masterPlaylist The master playlist.
 * @param mediaPlaylist The media playlist.
 */
HlsManifest(HlsMasterPlaylist masterPlaylist, HlsMediaPlaylist mediaPlaylist) {
  this.masterPlaylist = masterPlaylist;
  this.mediaPlaylist = mediaPlaylist;
}
 
Example #9
Source File: HlsMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public List<StreamKey> getStreamKeys(List<TrackSelection> trackSelections) {
  // See HlsMasterPlaylist.copy for interpretation of StreamKeys.
  HlsMasterPlaylist masterPlaylist = Assertions.checkNotNull(playlistTracker.getMasterPlaylist());
  boolean hasVariants = !masterPlaylist.variants.isEmpty();
  int audioWrapperOffset = hasVariants ? 1 : 0;
  // Subtitle sample stream wrappers are held last.
  int subtitleWrapperOffset = sampleStreamWrappers.length - masterPlaylist.subtitles.size();

  TrackGroupArray mainWrapperTrackGroups;
  int mainWrapperPrimaryGroupIndex;
  int[] mainWrapperVariantIndices;
  if (hasVariants) {
    HlsSampleStreamWrapper mainWrapper = sampleStreamWrappers[0];
    mainWrapperVariantIndices = manifestUrlIndicesPerWrapper[0];
    mainWrapperTrackGroups = mainWrapper.getTrackGroups();
    mainWrapperPrimaryGroupIndex = mainWrapper.getPrimaryTrackGroupIndex();
  } else {
    mainWrapperVariantIndices = new int[0];
    mainWrapperTrackGroups = TrackGroupArray.EMPTY;
    mainWrapperPrimaryGroupIndex = 0;
  }

  List<StreamKey> streamKeys = new ArrayList<>();
  boolean needsPrimaryTrackGroupSelection = false;
  boolean hasPrimaryTrackGroupSelection = false;
  for (TrackSelection trackSelection : trackSelections) {
    TrackGroup trackSelectionGroup = trackSelection.getTrackGroup();
    int mainWrapperTrackGroupIndex = mainWrapperTrackGroups.indexOf(trackSelectionGroup);
    if (mainWrapperTrackGroupIndex != C.INDEX_UNSET) {
      if (mainWrapperTrackGroupIndex == mainWrapperPrimaryGroupIndex) {
        // Primary group in main wrapper.
        hasPrimaryTrackGroupSelection = true;
        for (int i = 0; i < trackSelection.length(); i++) {
          int variantIndex = mainWrapperVariantIndices[trackSelection.getIndexInTrackGroup(i)];
          streamKeys.add(new StreamKey(HlsMasterPlaylist.GROUP_INDEX_VARIANT, variantIndex));
        }
      } else {
        // Embedded group in main wrapper.
        needsPrimaryTrackGroupSelection = true;
      }
    } else {
      // Audio or subtitle group.
      for (int i = audioWrapperOffset; i < sampleStreamWrappers.length; i++) {
        TrackGroupArray wrapperTrackGroups = sampleStreamWrappers[i].getTrackGroups();
        int selectedTrackGroupIndex = wrapperTrackGroups.indexOf(trackSelectionGroup);
        if (selectedTrackGroupIndex != C.INDEX_UNSET) {
          int groupIndexType =
              i < subtitleWrapperOffset
                  ? HlsMasterPlaylist.GROUP_INDEX_AUDIO
                  : HlsMasterPlaylist.GROUP_INDEX_SUBTITLE;
          int[] selectedWrapperUrlIndices = manifestUrlIndicesPerWrapper[i];
          for (int trackIndex = 0; trackIndex < trackSelection.length(); trackIndex++) {
            int renditionIndex =
                selectedWrapperUrlIndices[trackSelection.getIndexInTrackGroup(trackIndex)];
            streamKeys.add(new StreamKey(groupIndexType, renditionIndex));
          }
          break;
        }
      }
    }
  }
  if (needsPrimaryTrackGroupSelection && !hasPrimaryTrackGroupSelection) {
    // A track selection includes a variant-embedded track, but no variant is added yet. We use
    // the valid variant with the lowest bitrate to reduce overhead.
    int lowestBitrateIndex = mainWrapperVariantIndices[0];
    int lowestBitrate = masterPlaylist.variants.get(mainWrapperVariantIndices[0]).format.bitrate;
    for (int i = 1; i < mainWrapperVariantIndices.length; i++) {
      int variantBitrate =
          masterPlaylist.variants.get(mainWrapperVariantIndices[i]).format.bitrate;
      if (variantBitrate < lowestBitrate) {
        lowestBitrate = variantBitrate;
        lowestBitrateIndex = mainWrapperVariantIndices[i];
      }
    }
    streamKeys.add(new StreamKey(HlsMasterPlaylist.GROUP_INDEX_VARIANT, lowestBitrateIndex));
  }
  return streamKeys;
}
 
Example #10
Source File: HlsManifest.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param masterPlaylist The master playlist.
 * @param mediaPlaylist The media playlist.
 */
HlsManifest(HlsMasterPlaylist masterPlaylist, HlsMediaPlaylist mediaPlaylist) {
  this.masterPlaylist = masterPlaylist;
  this.mediaPlaylist = mediaPlaylist;
}
 
Example #11
Source File: HlsManifest.java    From K-Sonic with MIT License 4 votes vote down vote up
/**
 * @param masterPlaylist The master playlist.
 * @param mediaPlaylist The media playlist.
 */
HlsManifest(HlsMasterPlaylist masterPlaylist, HlsMediaPlaylist mediaPlaylist) {
  this.masterPlaylist = masterPlaylist;
  this.mediaPlaylist = mediaPlaylist;
}
 
Example #12
Source File: HlsSampleStreamWrapper.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean continueLoading(long positionUs) {
  if (loadingFinished || loader.isLoading()) {
    return false;
  }

  List<HlsMediaChunk> chunkQueue;
  long loadPositionUs;
  if (isPendingReset()) {
    chunkQueue = Collections.emptyList();
    loadPositionUs = pendingResetPositionUs;
  } else {
    chunkQueue = readOnlyMediaChunks;
    loadPositionUs = getLastMediaChunk().endTimeUs;
  }
  chunkSource.getNextChunk(positionUs, loadPositionUs, chunkQueue, nextChunkHolder);
  boolean endOfStream = nextChunkHolder.endOfStream;
  Chunk loadable = nextChunkHolder.chunk;
  HlsMasterPlaylist.HlsUrl playlistToLoad = nextChunkHolder.playlist;
  nextChunkHolder.clear();

  if (endOfStream) {
    pendingResetPositionUs = C.TIME_UNSET;
    loadingFinished = true;
    return true;
  }

  if (loadable == null) {
    if (playlistToLoad != null) {
      callback.onPlaylistRefreshRequired(playlistToLoad);
    }
    return false;
  }

  if (isMediaChunk(loadable)) {
    pendingResetPositionUs = C.TIME_UNSET;
    HlsMediaChunk mediaChunk = (HlsMediaChunk) loadable;
    mediaChunk.init(this);
    mediaChunks.add(mediaChunk);
    upstreamTrackFormat = mediaChunk.trackFormat;
  }
  long elapsedRealtimeMs = loader.startLoading(loadable, this, minLoadableRetryCount);
  eventDispatcher.loadStarted(
      loadable.dataSpec,
      loadable.dataSpec.uri,
      loadable.type,
      trackType,
      loadable.trackFormat,
      loadable.trackSelectionReason,
      loadable.trackSelectionData,
      loadable.startTimeUs,
      loadable.endTimeUs,
      elapsedRealtimeMs);
  return true;
}
 
Example #13
Source File: HlsManifest.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param masterPlaylist The master playlist.
 * @param mediaPlaylist The media playlist.
 */
HlsManifest(HlsMasterPlaylist masterPlaylist, HlsMediaPlaylist mediaPlaylist) {
  this.masterPlaylist = masterPlaylist;
  this.mediaPlaylist = mediaPlaylist;
}
 
Example #14
Source File: HlsSampleStreamWrapper.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean continueLoading(long positionUs) {
  if (loadingFinished || loader.isLoading()) {
    return false;
  }

  List<HlsMediaChunk> chunkQueue;
  long loadPositionUs;
  if (isPendingReset()) {
    chunkQueue = Collections.emptyList();
    loadPositionUs = pendingResetPositionUs;
  } else {
    chunkQueue = readOnlyMediaChunks;
    loadPositionUs = getLastMediaChunk().endTimeUs;
  }
  chunkSource.getNextChunk(positionUs, loadPositionUs, chunkQueue, nextChunkHolder);
  boolean endOfStream = nextChunkHolder.endOfStream;
  Chunk loadable = nextChunkHolder.chunk;
  HlsMasterPlaylist.HlsUrl playlistToLoad = nextChunkHolder.playlist;
  nextChunkHolder.clear();

  if (endOfStream) {
    pendingResetPositionUs = C.TIME_UNSET;
    loadingFinished = true;
    return true;
  }

  if (loadable == null) {
    if (playlistToLoad != null) {
      callback.onPlaylistRefreshRequired(playlistToLoad);
    }
    return false;
  }

  if (isMediaChunk(loadable)) {
    pendingResetPositionUs = C.TIME_UNSET;
    HlsMediaChunk mediaChunk = (HlsMediaChunk) loadable;
    mediaChunk.init(this);
    mediaChunks.add(mediaChunk);
    upstreamTrackFormat = mediaChunk.trackFormat;
  }
  long elapsedRealtimeMs = loader.startLoading(loadable, this, minLoadableRetryCount);
  eventDispatcher.loadStarted(
      loadable.dataSpec,
      loadable.dataSpec.uri,
      loadable.type,
      trackType,
      loadable.trackFormat,
      loadable.trackSelectionReason,
      loadable.trackSelectionData,
      loadable.startTimeUs,
      loadable.endTimeUs,
      elapsedRealtimeMs);
  return true;
}
 
Example #15
Source File: HlsManifest.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param masterPlaylist The master playlist.
 * @param mediaPlaylist The media playlist.
 */
HlsManifest(HlsMasterPlaylist masterPlaylist, HlsMediaPlaylist mediaPlaylist) {
  this.masterPlaylist = masterPlaylist;
  this.mediaPlaylist = mediaPlaylist;
}
 
Example #16
Source File: HlsMediaPeriod.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
public List<StreamKey> getStreamKeys(List<TrackSelection> trackSelections) {
  // See HlsMasterPlaylist.copy for interpretation of StreamKeys.
  HlsMasterPlaylist masterPlaylist = Assertions.checkNotNull(playlistTracker.getMasterPlaylist());
  boolean hasVariants = !masterPlaylist.variants.isEmpty();
  int audioWrapperOffset = hasVariants ? 1 : 0;
  // Subtitle sample stream wrappers are held last.
  int subtitleWrapperOffset = sampleStreamWrappers.length - masterPlaylist.subtitles.size();

  TrackGroupArray mainWrapperTrackGroups;
  int mainWrapperPrimaryGroupIndex;
  int[] mainWrapperVariantIndices;
  if (hasVariants) {
    HlsSampleStreamWrapper mainWrapper = sampleStreamWrappers[0];
    mainWrapperVariantIndices = manifestUrlIndicesPerWrapper[0];
    mainWrapperTrackGroups = mainWrapper.getTrackGroups();
    mainWrapperPrimaryGroupIndex = mainWrapper.getPrimaryTrackGroupIndex();
  } else {
    mainWrapperVariantIndices = new int[0];
    mainWrapperTrackGroups = TrackGroupArray.EMPTY;
    mainWrapperPrimaryGroupIndex = 0;
  }

  List<StreamKey> streamKeys = new ArrayList<>();
  boolean needsPrimaryTrackGroupSelection = false;
  boolean hasPrimaryTrackGroupSelection = false;
  for (TrackSelection trackSelection : trackSelections) {
    TrackGroup trackSelectionGroup = trackSelection.getTrackGroup();
    int mainWrapperTrackGroupIndex = mainWrapperTrackGroups.indexOf(trackSelectionGroup);
    if (mainWrapperTrackGroupIndex != C.INDEX_UNSET) {
      if (mainWrapperTrackGroupIndex == mainWrapperPrimaryGroupIndex) {
        // Primary group in main wrapper.
        hasPrimaryTrackGroupSelection = true;
        for (int i = 0; i < trackSelection.length(); i++) {
          int variantIndex = mainWrapperVariantIndices[trackSelection.getIndexInTrackGroup(i)];
          streamKeys.add(new StreamKey(HlsMasterPlaylist.GROUP_INDEX_VARIANT, variantIndex));
        }
      } else {
        // Embedded group in main wrapper.
        needsPrimaryTrackGroupSelection = true;
      }
    } else {
      // Audio or subtitle group.
      for (int i = audioWrapperOffset; i < sampleStreamWrappers.length; i++) {
        TrackGroupArray wrapperTrackGroups = sampleStreamWrappers[i].getTrackGroups();
        int selectedTrackGroupIndex = wrapperTrackGroups.indexOf(trackSelectionGroup);
        if (selectedTrackGroupIndex != C.INDEX_UNSET) {
          int groupIndexType =
              i < subtitleWrapperOffset
                  ? HlsMasterPlaylist.GROUP_INDEX_AUDIO
                  : HlsMasterPlaylist.GROUP_INDEX_SUBTITLE;
          int[] selectedWrapperUrlIndices = manifestUrlIndicesPerWrapper[i];
          for (int trackIndex = 0; trackIndex < trackSelection.length(); trackIndex++) {
            int renditionIndex =
                selectedWrapperUrlIndices[trackSelection.getIndexInTrackGroup(trackIndex)];
            streamKeys.add(new StreamKey(groupIndexType, renditionIndex));
          }
          break;
        }
      }
    }
  }
  if (needsPrimaryTrackGroupSelection && !hasPrimaryTrackGroupSelection) {
    // A track selection includes a variant-embedded track, but no variant is added yet. We use
    // the valid variant with the lowest bitrate to reduce overhead.
    int lowestBitrateIndex = mainWrapperVariantIndices[0];
    int lowestBitrate = masterPlaylist.variants.get(mainWrapperVariantIndices[0]).format.bitrate;
    for (int i = 1; i < mainWrapperVariantIndices.length; i++) {
      int variantBitrate =
          masterPlaylist.variants.get(mainWrapperVariantIndices[i]).format.bitrate;
      if (variantBitrate < lowestBitrate) {
        lowestBitrate = variantBitrate;
        lowestBitrateIndex = mainWrapperVariantIndices[i];
      }
    }
    streamKeys.add(new StreamKey(HlsMasterPlaylist.GROUP_INDEX_VARIANT, lowestBitrateIndex));
  }
  return streamKeys;
}
 
Example #17
Source File: HlsSampleStreamWrapper.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Called to schedule a {@link #continueLoading(long)} call when the playlist referred by the
 * given url changes.
 */
void onPlaylistRefreshRequired(HlsMasterPlaylist.HlsUrl playlistUrl);
 
Example #18
Source File: HlsSampleStreamWrapper.java    From K-Sonic with MIT License 2 votes vote down vote up
/**
 * Called to schedule a {@link #continueLoading(long)} call when the playlist referred by the
 * given url changes.
 */
void onPlaylistRefreshRequired(HlsMasterPlaylist.HlsUrl playlistUrl);
 
Example #19
Source File: HlsSampleStreamWrapper.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Called to schedule a {@link #continueLoading(long)} call when the playlist referred by the
 * given url changes.
 */
void onPlaylistRefreshRequired(HlsMasterPlaylist.HlsUrl playlistUrl);