com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler Java Examples

The following examples show how to use com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler. 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 MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public DashChunkSource createDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int trackType,
    long elapsedRealtimeOffsetMs,
    boolean enableEventMessageTrack,
    List<Format> closedCaptionFormats,
    @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
    @Nullable TransferListener transferListener) {
  DataSource dataSource = dataSourceFactory.createDataSource();
  if (transferListener != null) {
    dataSource.addTransferListener(transferListener);
  }
  return new DefaultDashChunkSource(
      manifestLoaderErrorThrower,
      manifest,
      periodIndex,
      adaptationSetIndices,
      trackSelection,
      trackType,
      dataSource,
      elapsedRealtimeOffsetMs,
      maxSegmentsPerLoad,
      enableEventMessageTrack,
      closedCaptionFormats,
      playerEmsgHandler);
}
 
Example #2
Source File: DashMediaPeriod.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void onSampleStreamReleased(ChunkSampleStream<DashChunkSource> stream) {
  PlayerTrackEmsgHandler trackEmsgHandler = trackEmsgHandlerBySampleStream.remove(stream);
  if (trackEmsgHandler != null) {
    trackEmsgHandler.release();
  }
}
 
Example #3
Source File: DashMediaPeriod.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void onSampleStreamReleased(ChunkSampleStream<DashChunkSource> stream) {
  PlayerTrackEmsgHandler trackEmsgHandler = trackEmsgHandlerBySampleStream.remove(stream);
  if (trackEmsgHandler != null) {
    trackEmsgHandler.release();
  }
}
 
Example #4
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public DashChunkSource createDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int trackType,
    long elapsedRealtimeOffsetMs,
    boolean enableEventMessageTrack,
    boolean enableCea608Track,
    @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
    @Nullable TransferListener transferListener) {
  DataSource dataSource = dataSourceFactory.createDataSource();
  if (transferListener != null) {
    dataSource.addTransferListener(transferListener);
  }
  return new DefaultDashChunkSource(
      manifestLoaderErrorThrower,
      manifest,
      periodIndex,
      adaptationSetIndices,
      trackSelection,
      trackType,
      dataSource,
      elapsedRealtimeOffsetMs,
      maxSegmentsPerLoad,
      enableEventMessageTrack,
      enableCea608Track,
      playerEmsgHandler);
}
 
Example #5
Source File: DefaultDashChunkSource.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public DashChunkSource createDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int trackType,
    long elapsedRealtimeOffsetMs,
    boolean enableEventMessageTrack,
    List<Format> closedCaptionFormats,
    @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
    @Nullable TransferListener transferListener) {
  DataSource dataSource = dataSourceFactory.createDataSource();
  if (transferListener != null) {
    dataSource.addTransferListener(transferListener);
  }
  return new DefaultDashChunkSource(
      manifestLoaderErrorThrower,
      manifest,
      periodIndex,
      adaptationSetIndices,
      trackSelection,
      trackType,
      dataSource,
      elapsedRealtimeOffsetMs,
      maxSegmentsPerLoad,
      enableEventMessageTrack,
      closedCaptionFormats,
      playerEmsgHandler);
}
 
Example #6
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void onSampleStreamReleased(ChunkSampleStream<DashChunkSource> stream) {
  PlayerTrackEmsgHandler trackEmsgHandler = trackEmsgHandlerBySampleStream.remove(stream);
  if (trackEmsgHandler != null) {
    trackEmsgHandler.release();
  }
}
 
Example #7
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public DashChunkSource createDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int trackType,
    long elapsedRealtimeOffsetMs,
    boolean enableEventMessageTrack,
    boolean enableCea608Track,
    @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
    @Nullable TransferListener transferListener) {
  DataSource dataSource = dataSourceFactory.createDataSource();
  if (transferListener != null) {
    dataSource.addTransferListener(transferListener);
  }
  return new DefaultDashChunkSource(
      manifestLoaderErrorThrower,
      manifest,
      periodIndex,
      adaptationSetIndices,
      trackSelection,
      trackType,
      dataSource,
      elapsedRealtimeOffsetMs,
      maxSegmentsPerLoad,
      enableEventMessageTrack,
      enableCea608Track,
      playerEmsgHandler);
}
 
Example #8
Source File: DashMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void onSampleStreamReleased(ChunkSampleStream<DashChunkSource> stream) {
  PlayerTrackEmsgHandler trackEmsgHandler = trackEmsgHandlerBySampleStream.remove(stream);
  if (trackEmsgHandler != null) {
    trackEmsgHandler.release();
  }
}
 
Example #9
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void onSampleStreamReleased(ChunkSampleStream<DashChunkSource> stream) {
  PlayerTrackEmsgHandler trackEmsgHandler = trackEmsgHandlerBySampleStream.remove(stream);
  if (trackEmsgHandler != null) {
    trackEmsgHandler.release();
  }
}
 
Example #10
Source File: DefaultDashChunkSource.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public DashChunkSource createDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int trackType,
    long elapsedRealtimeOffsetMs,
    boolean enableEventMessageTrack,
    List<Format> closedCaptionFormats,
    @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
    @Nullable TransferListener transferListener) {
  DataSource dataSource = dataSourceFactory.createDataSource();
  if (transferListener != null) {
    dataSource.addTransferListener(transferListener);
  }
  return new DefaultDashChunkSource(
      manifestLoaderErrorThrower,
      manifest,
      periodIndex,
      adaptationSetIndices,
      trackSelection,
      trackType,
      dataSource,
      elapsedRealtimeOffsetMs,
      maxSegmentsPerLoad,
      enableEventMessageTrack,
      closedCaptionFormats,
      playerEmsgHandler);
}
 
Example #11
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 #12
Source File: DashMediaPeriod.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private ChunkSampleStream<DashChunkSource> buildSampleStream(TrackGroupInfo trackGroupInfo,
    TrackSelection selection, long positionUs) {
  int embeddedTrackCount = 0;
  boolean enableEventMessageTrack =
      trackGroupInfo.embeddedEventMessageTrackGroupIndex != C.INDEX_UNSET;
  TrackGroup embeddedEventMessageTrackGroup = null;
  if (enableEventMessageTrack) {
    embeddedEventMessageTrackGroup =
        trackGroups.get(trackGroupInfo.embeddedEventMessageTrackGroupIndex);
    embeddedTrackCount++;
  }
  boolean enableCea608Tracks = trackGroupInfo.embeddedCea608TrackGroupIndex != C.INDEX_UNSET;
  TrackGroup embeddedCea608TrackGroup = null;
  if (enableCea608Tracks) {
    embeddedCea608TrackGroup = trackGroups.get(trackGroupInfo.embeddedCea608TrackGroupIndex);
    embeddedTrackCount += embeddedCea608TrackGroup.length;
  }

  Format[] embeddedTrackFormats = new Format[embeddedTrackCount];
  int[] embeddedTrackTypes = new int[embeddedTrackCount];
  embeddedTrackCount = 0;
  if (enableEventMessageTrack) {
    embeddedTrackFormats[embeddedTrackCount] = embeddedEventMessageTrackGroup.getFormat(0);
    embeddedTrackTypes[embeddedTrackCount] = C.TRACK_TYPE_METADATA;
    embeddedTrackCount++;
  }
  List<Format> embeddedCea608TrackFormats = new ArrayList<>();
  if (enableCea608Tracks) {
    for (int i = 0; i < embeddedCea608TrackGroup.length; i++) {
      embeddedTrackFormats[embeddedTrackCount] = embeddedCea608TrackGroup.getFormat(i);
      embeddedTrackTypes[embeddedTrackCount] = C.TRACK_TYPE_TEXT;
      embeddedCea608TrackFormats.add(embeddedTrackFormats[embeddedTrackCount]);
      embeddedTrackCount++;
    }
  }

  PlayerTrackEmsgHandler trackPlayerEmsgHandler =
      manifest.dynamic && enableEventMessageTrack
          ? playerEmsgHandler.newPlayerTrackEmsgHandler()
          : null;
  DashChunkSource chunkSource =
      chunkSourceFactory.createDashChunkSource(
          manifestLoaderErrorThrower,
          manifest,
          periodIndex,
          trackGroupInfo.adaptationSetIndices,
          selection,
          trackGroupInfo.trackType,
          elapsedRealtimeOffsetMs,
          enableEventMessageTrack,
          embeddedCea608TrackFormats,
          trackPlayerEmsgHandler,
          transferListener);
  ChunkSampleStream<DashChunkSource> stream =
      new ChunkSampleStream<>(
          trackGroupInfo.trackType,
          embeddedTrackTypes,
          embeddedTrackFormats,
          chunkSource,
          this,
          allocator,
          positionUs,
          loadErrorHandlingPolicy,
          eventDispatcher);
  synchronized (this) {
    // The map is also accessed on the loading thread so synchronize access.
    trackEmsgHandlerBySampleStream.put(stream, trackPlayerEmsgHandler);
  }
  return stream;
}
 
Example #13
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);
  }
}
 
Example #14
Source File: DashMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private ChunkSampleStream<DashChunkSource> buildSampleStream(TrackGroupInfo trackGroupInfo,
    TrackSelection selection, long positionUs) {
  int embeddedTrackCount = 0;
  boolean enableEventMessageTrack =
      trackGroupInfo.embeddedEventMessageTrackGroupIndex != C.INDEX_UNSET;
  TrackGroup embeddedEventMessageTrackGroup = null;
  if (enableEventMessageTrack) {
    embeddedEventMessageTrackGroup =
        trackGroups.get(trackGroupInfo.embeddedEventMessageTrackGroupIndex);
    embeddedTrackCount++;
  }
  boolean enableCea608Tracks = trackGroupInfo.embeddedCea608TrackGroupIndex != C.INDEX_UNSET;
  TrackGroup embeddedCea608TrackGroup = null;
  if (enableCea608Tracks) {
    embeddedCea608TrackGroup = trackGroups.get(trackGroupInfo.embeddedCea608TrackGroupIndex);
    embeddedTrackCount += embeddedCea608TrackGroup.length;
  }

  Format[] embeddedTrackFormats = new Format[embeddedTrackCount];
  int[] embeddedTrackTypes = new int[embeddedTrackCount];
  embeddedTrackCount = 0;
  if (enableEventMessageTrack) {
    embeddedTrackFormats[embeddedTrackCount] = embeddedEventMessageTrackGroup.getFormat(0);
    embeddedTrackTypes[embeddedTrackCount] = C.TRACK_TYPE_METADATA;
    embeddedTrackCount++;
  }
  List<Format> embeddedCea608TrackFormats = new ArrayList<>();
  if (enableCea608Tracks) {
    for (int i = 0; i < embeddedCea608TrackGroup.length; i++) {
      embeddedTrackFormats[embeddedTrackCount] = embeddedCea608TrackGroup.getFormat(i);
      embeddedTrackTypes[embeddedTrackCount] = C.TRACK_TYPE_TEXT;
      embeddedCea608TrackFormats.add(embeddedTrackFormats[embeddedTrackCount]);
      embeddedTrackCount++;
    }
  }

  PlayerTrackEmsgHandler trackPlayerEmsgHandler =
      manifest.dynamic && enableEventMessageTrack
          ? playerEmsgHandler.newPlayerTrackEmsgHandler()
          : null;
  DashChunkSource chunkSource =
      chunkSourceFactory.createDashChunkSource(
          manifestLoaderErrorThrower,
          manifest,
          periodIndex,
          trackGroupInfo.adaptationSetIndices,
          selection,
          trackGroupInfo.trackType,
          elapsedRealtimeOffsetMs,
          enableEventMessageTrack,
          embeddedCea608TrackFormats,
          trackPlayerEmsgHandler,
          transferListener);
  ChunkSampleStream<DashChunkSource> stream =
      new ChunkSampleStream<>(
          trackGroupInfo.trackType,
          embeddedTrackTypes,
          embeddedTrackFormats,
          chunkSource,
          this,
          allocator,
          positionUs,
          loadErrorHandlingPolicy,
          eventDispatcher);
  synchronized (this) {
    // The map is also accessed on the loading thread so synchronize access.
    trackEmsgHandlerBySampleStream.put(stream, trackPlayerEmsgHandler);
  }
  return stream;
}
 
Example #15
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 #16
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private ChunkSampleStream<DashChunkSource> buildSampleStream(TrackGroupInfo trackGroupInfo,
    TrackSelection selection, long positionUs) {
  int embeddedTrackCount = 0;
  int[] embeddedTrackTypes = new int[2];
  Format[] embeddedTrackFormats = new Format[2];
  boolean enableEventMessageTrack =
      trackGroupInfo.embeddedEventMessageTrackGroupIndex != C.INDEX_UNSET;
  if (enableEventMessageTrack) {
    embeddedTrackFormats[embeddedTrackCount] =
        trackGroups.get(trackGroupInfo.embeddedEventMessageTrackGroupIndex).getFormat(0);
    embeddedTrackTypes[embeddedTrackCount++] = C.TRACK_TYPE_METADATA;
  }
  boolean enableCea608Track = trackGroupInfo.embeddedCea608TrackGroupIndex != C.INDEX_UNSET;
  if (enableCea608Track) {
    embeddedTrackFormats[embeddedTrackCount] =
        trackGroups.get(trackGroupInfo.embeddedCea608TrackGroupIndex).getFormat(0);
    embeddedTrackTypes[embeddedTrackCount++] = C.TRACK_TYPE_TEXT;
  }
  if (embeddedTrackCount < embeddedTrackTypes.length) {
    embeddedTrackFormats = Arrays.copyOf(embeddedTrackFormats, embeddedTrackCount);
    embeddedTrackTypes = Arrays.copyOf(embeddedTrackTypes, embeddedTrackCount);
  }
  PlayerTrackEmsgHandler trackPlayerEmsgHandler =
      manifest.dynamic && enableEventMessageTrack
          ? playerEmsgHandler.newPlayerTrackEmsgHandler()
          : null;
  DashChunkSource chunkSource =
      chunkSourceFactory.createDashChunkSource(
          manifestLoaderErrorThrower,
          manifest,
          periodIndex,
          trackGroupInfo.adaptationSetIndices,
          selection,
          trackGroupInfo.trackType,
          elapsedRealtimeOffset,
          enableEventMessageTrack,
          enableCea608Track,
          trackPlayerEmsgHandler,
          transferListener);
  ChunkSampleStream<DashChunkSource> stream =
      new ChunkSampleStream<>(
          trackGroupInfo.trackType,
          embeddedTrackTypes,
          embeddedTrackFormats,
          chunkSource,
          this,
          allocator,
          positionUs,
          minLoadableRetryCount,
          eventDispatcher);
  synchronized (this) {
    // The map is also accessed on the loading thread so synchronize access.
    trackEmsgHandlerBySampleStream.put(stream, trackPlayerEmsgHandler);
  }
  return stream;
}
 
Example #17
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 #18
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private ChunkSampleStream<DashChunkSource> buildSampleStream(TrackGroupInfo trackGroupInfo,
    TrackSelection selection, long positionUs) {
  int embeddedTrackCount = 0;
  int[] embeddedTrackTypes = new int[2];
  Format[] embeddedTrackFormats = new Format[2];
  boolean enableEventMessageTrack =
      trackGroupInfo.embeddedEventMessageTrackGroupIndex != C.INDEX_UNSET;
  if (enableEventMessageTrack) {
    embeddedTrackFormats[embeddedTrackCount] =
        trackGroups.get(trackGroupInfo.embeddedEventMessageTrackGroupIndex).getFormat(0);
    embeddedTrackTypes[embeddedTrackCount++] = C.TRACK_TYPE_METADATA;
  }
  boolean enableCea608Track = trackGroupInfo.embeddedCea608TrackGroupIndex != C.INDEX_UNSET;
  if (enableCea608Track) {
    embeddedTrackFormats[embeddedTrackCount] =
        trackGroups.get(trackGroupInfo.embeddedCea608TrackGroupIndex).getFormat(0);
    embeddedTrackTypes[embeddedTrackCount++] = C.TRACK_TYPE_TEXT;
  }
  if (embeddedTrackCount < embeddedTrackTypes.length) {
    embeddedTrackFormats = Arrays.copyOf(embeddedTrackFormats, embeddedTrackCount);
    embeddedTrackTypes = Arrays.copyOf(embeddedTrackTypes, embeddedTrackCount);
  }
  PlayerTrackEmsgHandler trackPlayerEmsgHandler =
      manifest.dynamic && enableEventMessageTrack
          ? playerEmsgHandler.newPlayerTrackEmsgHandler()
          : null;
  DashChunkSource chunkSource =
      chunkSourceFactory.createDashChunkSource(
          manifestLoaderErrorThrower,
          manifest,
          periodIndex,
          trackGroupInfo.adaptationSetIndices,
          selection,
          trackGroupInfo.trackType,
          elapsedRealtimeOffset,
          enableEventMessageTrack,
          enableCea608Track,
          trackPlayerEmsgHandler,
          transferListener);
  ChunkSampleStream<DashChunkSource> stream =
      new ChunkSampleStream<>(
          trackGroupInfo.trackType,
          embeddedTrackTypes,
          embeddedTrackFormats,
          chunkSource,
          this,
          allocator,
          positionUs,
          minLoadableRetryCount,
          eventDispatcher);
  synchronized (this) {
    // The map is also accessed on the loading thread so synchronize access.
    trackEmsgHandlerBySampleStream.put(stream, trackPlayerEmsgHandler);
  }
  return stream;
}
 
Example #19
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 #20
Source File: DashMediaPeriod.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
private ChunkSampleStream<DashChunkSource> buildSampleStream(TrackGroupInfo trackGroupInfo,
    TrackSelection selection, long positionUs) {
  int embeddedTrackCount = 0;
  boolean enableEventMessageTrack =
      trackGroupInfo.embeddedEventMessageTrackGroupIndex != C.INDEX_UNSET;
  TrackGroup embeddedEventMessageTrackGroup = null;
  if (enableEventMessageTrack) {
    embeddedEventMessageTrackGroup =
        trackGroups.get(trackGroupInfo.embeddedEventMessageTrackGroupIndex);
    embeddedTrackCount++;
  }
  boolean enableCea608Tracks = trackGroupInfo.embeddedCea608TrackGroupIndex != C.INDEX_UNSET;
  TrackGroup embeddedCea608TrackGroup = null;
  if (enableCea608Tracks) {
    embeddedCea608TrackGroup = trackGroups.get(trackGroupInfo.embeddedCea608TrackGroupIndex);
    embeddedTrackCount += embeddedCea608TrackGroup.length;
  }

  Format[] embeddedTrackFormats = new Format[embeddedTrackCount];
  int[] embeddedTrackTypes = new int[embeddedTrackCount];
  embeddedTrackCount = 0;
  if (enableEventMessageTrack) {
    embeddedTrackFormats[embeddedTrackCount] = embeddedEventMessageTrackGroup.getFormat(0);
    embeddedTrackTypes[embeddedTrackCount] = C.TRACK_TYPE_METADATA;
    embeddedTrackCount++;
  }
  List<Format> embeddedCea608TrackFormats = new ArrayList<>();
  if (enableCea608Tracks) {
    for (int i = 0; i < embeddedCea608TrackGroup.length; i++) {
      embeddedTrackFormats[embeddedTrackCount] = embeddedCea608TrackGroup.getFormat(i);
      embeddedTrackTypes[embeddedTrackCount] = C.TRACK_TYPE_TEXT;
      embeddedCea608TrackFormats.add(embeddedTrackFormats[embeddedTrackCount]);
      embeddedTrackCount++;
    }
  }

  PlayerTrackEmsgHandler trackPlayerEmsgHandler =
      manifest.dynamic && enableEventMessageTrack
          ? playerEmsgHandler.newPlayerTrackEmsgHandler()
          : null;
  DashChunkSource chunkSource =
      chunkSourceFactory.createDashChunkSource(
          manifestLoaderErrorThrower,
          manifest,
          periodIndex,
          trackGroupInfo.adaptationSetIndices,
          selection,
          trackGroupInfo.trackType,
          elapsedRealtimeOffsetMs,
          enableEventMessageTrack,
          embeddedCea608TrackFormats,
          trackPlayerEmsgHandler,
          transferListener);
  ChunkSampleStream<DashChunkSource> stream =
      new ChunkSampleStream<>(
          trackGroupInfo.trackType,
          embeddedTrackTypes,
          embeddedTrackFormats,
          chunkSource,
          this,
          allocator,
          positionUs,
          drmSessionManager,
          loadErrorHandlingPolicy,
          eventDispatcher);
  synchronized (this) {
    // The map is also accessed on the loading thread so synchronize access.
    trackEmsgHandlerBySampleStream.put(stream, trackPlayerEmsgHandler);
  }
  return stream;
}
 
Example #21
Source File: DashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the corresponding period in the manifest.
 * @param adaptationSetIndices The indices of the corresponding adaptation sets in the period.
 * @param trackSelection The track selection.
 * @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 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 transferListener The transfer listener which should be informed of any data transfers.
 *     May be null if no listener is available.
 * @return The created {@link DashChunkSource}.
 */
DashChunkSource createDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int type,
    long elapsedRealtimeOffsetMs,
    boolean enableEventMessageTrack,
    boolean enableCea608Track,
    @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
    @Nullable TransferListener transferListener);
 
Example #22
Source File: DashChunkSource.java    From Telegram-FOSS with GNU General Public License v2.0 3 votes vote down vote up
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the corresponding period in the manifest.
 * @param adaptationSetIndices The indices of the corresponding adaptation sets in the period.
 * @param trackSelection The track selection.
 * @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 enableEventMessageTrack Whether to output an event message track.
 * @param closedCaptionFormats The {@link Format Formats} of closed caption tracks to be output.
 * @param transferListener The transfer listener which should be informed of any data transfers.
 *     May be null if no listener is available.
 * @return The created {@link DashChunkSource}.
 */
DashChunkSource createDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int type,
    long elapsedRealtimeOffsetMs,
    boolean enableEventMessageTrack,
    List<Format> closedCaptionFormats,
    @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
    @Nullable TransferListener transferListener);
 
Example #23
Source File: DashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the corresponding period in the manifest.
 * @param adaptationSetIndices The indices of the corresponding adaptation sets in the period.
 * @param trackSelection The track selection.
 * @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 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 transferListener The transfer listener which should be informed of any data transfers.
 *     May be null if no listener is available.
 * @return The created {@link DashChunkSource}.
 */
DashChunkSource createDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int type,
    long elapsedRealtimeOffsetMs,
    boolean enableEventMessageTrack,
    boolean enableCea608Track,
    @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
    @Nullable TransferListener transferListener);
 
Example #24
Source File: DashChunkSource.java    From Telegram with GNU General Public License v2.0 3 votes vote down vote up
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the corresponding period in the manifest.
 * @param adaptationSetIndices The indices of the corresponding adaptation sets in the period.
 * @param trackSelection The track selection.
 * @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 enableEventMessageTrack Whether to output an event message track.
 * @param closedCaptionFormats The {@link Format Formats} of closed caption tracks to be output.
 * @param transferListener The transfer listener which should be informed of any data transfers.
 *     May be null if no listener is available.
 * @return The created {@link DashChunkSource}.
 */
DashChunkSource createDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int type,
    long elapsedRealtimeOffsetMs,
    boolean enableEventMessageTrack,
    List<Format> closedCaptionFormats,
    @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
    @Nullable TransferListener transferListener);
 
Example #25
Source File: DashChunkSource.java    From MediaSDK with Apache License 2.0 3 votes vote down vote up
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the corresponding period in the manifest.
 * @param adaptationSetIndices The indices of the corresponding adaptation sets in the period.
 * @param trackSelection The track selection.
 * @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 enableEventMessageTrack Whether to output an event message track.
 * @param closedCaptionFormats The {@link Format Formats} of closed caption tracks to be output.
 * @param transferListener The transfer listener which should be informed of any data transfers.
 *     May be null if no listener is available.
 * @return The created {@link DashChunkSource}.
 */
DashChunkSource createDashChunkSource(
    LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest,
    int periodIndex,
    int[] adaptationSetIndices,
    TrackSelection trackSelection,
    int type,
    long elapsedRealtimeOffsetMs,
    boolean enableEventMessageTrack,
    List<Format> closedCaptionFormats,
    @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
    @Nullable TransferListener transferListener);