com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher Java Examples

The following examples show how to use com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher. 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: SsMediaPeriod.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public SsMediaPeriod(
    SsManifest manifest,
    SsChunkSource.Factory chunkSourceFactory,
    @Nullable TransferListener transferListener,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    EventDispatcher eventDispatcher,
    LoaderErrorThrower manifestLoaderErrorThrower,
    Allocator allocator) {
  this.manifest = manifest;
  this.chunkSourceFactory = chunkSourceFactory;
  this.transferListener = transferListener;
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.eventDispatcher = eventDispatcher;
  this.allocator = allocator;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  trackGroups = buildTrackGroups(manifest);
  sampleStreams = newSampleStreamArray(0);
  compositeSequenceableLoader =
      compositeSequenceableLoaderFactory.createCompositeSequenceableLoader(sampleStreams);
  eventDispatcher.mediaPeriodCreated();
}
 
Example #2
Source File: DashMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(
    MediaPeriodId periodId, Allocator allocator, long startPositionUs) {
  int periodIndex = (Integer) periodId.periodUid - firstPeriodId;
  EventDispatcher periodEventDispatcher =
      createEventDispatcher(periodId, manifest.getPeriod(periodIndex).startMs);
  DashMediaPeriod mediaPeriod =
      new DashMediaPeriod(
          firstPeriodId + periodIndex,
          manifest,
          periodIndex,
          chunkSourceFactory,
          mediaTransferListener,
          drmSessionManager,
          loadErrorHandlingPolicy,
          periodEventDispatcher,
          elapsedRealtimeOffsetMs,
          manifestLoadErrorThrower,
          allocator,
          compositeSequenceableLoaderFactory,
          playerEmsgCallback);
  periodsById.put(mediaPeriod.id, mediaPeriod);
  return mediaPeriod;
}
 
Example #3
Source File: SingleSampleMediaPeriod.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
public SingleSampleMediaPeriod(
    DataSpec dataSpec,
    DataSource.Factory dataSourceFactory,
    @Nullable TransferListener transferListener,
    Format format,
    long durationUs,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    EventDispatcher eventDispatcher,
    boolean treatLoadErrorsAsEndOfStream) {
  this.dataSpec = dataSpec;
  this.dataSourceFactory = dataSourceFactory;
  this.transferListener = transferListener;
  this.format = format;
  this.durationUs = durationUs;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.eventDispatcher = eventDispatcher;
  this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream;
  tracks = new TrackGroupArray(new TrackGroup(format));
  sampleStreams = new ArrayList<>();
  loader = new Loader("Loader:SingleSampleMediaPeriod");
  eventDispatcher.mediaPeriodCreated();
}
 
Example #4
Source File: SsMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs) {
  EventDispatcher eventDispatcher = createEventDispatcher(id);
  SsMediaPeriod period =
      new SsMediaPeriod(
          manifest,
          chunkSourceFactory,
          mediaTransferListener,
          compositeSequenceableLoaderFactory,
          drmSessionManager,
          loadErrorHandlingPolicy,
          eventDispatcher,
          manifestLoaderErrorThrower,
          allocator);
  mediaPeriods.add(period);
  return period;
}
 
Example #5
Source File: SsMediaPeriod.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
public SsMediaPeriod(
    SsManifest manifest,
    SsChunkSource.Factory chunkSourceFactory,
    @Nullable TransferListener transferListener,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    DrmSessionManager<?> drmSessionManager,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    EventDispatcher eventDispatcher,
    LoaderErrorThrower manifestLoaderErrorThrower,
    Allocator allocator) {
  this.manifest = manifest;
  this.chunkSourceFactory = chunkSourceFactory;
  this.transferListener = transferListener;
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.drmSessionManager = drmSessionManager;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.eventDispatcher = eventDispatcher;
  this.allocator = allocator;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  trackGroups = buildTrackGroups(manifest, drmSessionManager);
  sampleStreams = newSampleStreamArray(0);
  compositeSequenceableLoader =
      compositeSequenceableLoaderFactory.createCompositeSequenceableLoader(sampleStreams);
  eventDispatcher.mediaPeriodCreated();
}
 
Example #6
Source File: HlsMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator) {
  Assertions.checkArgument(id.periodIndex == 0);
  EventDispatcher eventDispatcher = createEventDispatcher(id);
  return new HlsMediaPeriod(
      extractorFactory,
      playlistTracker,
      dataSourceFactory,
      mediaTransferListener,
      chunkLoadErrorHandlingPolicy,
      minLoadableRetryCount,
      eventDispatcher,
      allocator,
      compositeSequenceableLoaderFactory,
      allowChunklessPreparation);
}
 
Example #7
Source File: HlsMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs) {
  EventDispatcher eventDispatcher = createEventDispatcher(id);
  return new HlsMediaPeriod(
      extractorFactory,
      playlistTracker,
      dataSourceFactory,
      mediaTransferListener,
      drmSessionManager,
      loadErrorHandlingPolicy,
      eventDispatcher,
      allocator,
      compositeSequenceableLoaderFactory,
      allowChunklessPreparation,
      metadataType,
      useSessionKeys);
}
 
Example #8
Source File: SingleSampleMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public SingleSampleMediaPeriod(
    DataSpec dataSpec,
    DataSource.Factory dataSourceFactory,
    @Nullable TransferListener transferListener,
    Format format,
    long durationUs,
    int minLoadableRetryCount,
    EventDispatcher eventDispatcher,
    boolean treatLoadErrorsAsEndOfStream) {
  this.dataSpec = dataSpec;
  this.dataSourceFactory = dataSourceFactory;
  this.transferListener = transferListener;
  this.format = format;
  this.durationUs = durationUs;
  this.minLoadableRetryCount = minLoadableRetryCount;
  this.eventDispatcher = eventDispatcher;
  this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream;
  tracks = new TrackGroupArray(new TrackGroup(format));
  sampleStreams = new ArrayList<>();
  loader = new Loader("Loader:SingleSampleMediaPeriod");
  eventDispatcher.mediaPeriodCreated();
}
 
Example #9
Source File: DashMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(MediaPeriodId periodId, Allocator allocator) {
  int periodIndex = periodId.periodIndex;
  EventDispatcher periodEventDispatcher =
      createEventDispatcher(periodId, manifest.getPeriod(periodIndex).startMs);
  DashMediaPeriod mediaPeriod =
      new DashMediaPeriod(
          firstPeriodId + periodIndex,
          manifest,
          periodIndex,
          chunkSourceFactory,
          mediaTransferListener,
          minLoadableRetryCount,
          periodEventDispatcher,
          elapsedRealtimeOffsetMs,
          manifestLoadErrorThrower,
          allocator,
          compositeSequenceableLoaderFactory,
          playerEmsgCallback);
  periodsById.put(mediaPeriod.id, mediaPeriod);
  return mediaPeriod;
}
 
Example #10
Source File: SsMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator) {
  Assertions.checkArgument(id.periodIndex == 0);
  EventDispatcher eventDispatcher = createEventDispatcher(id);
  SsMediaPeriod period =
      new SsMediaPeriod(
          manifest,
          chunkSourceFactory,
          mediaTransferListener,
          compositeSequenceableLoaderFactory,
          minLoadableRetryCount,
          eventDispatcher,
          manifestLoaderErrorThrower,
          allocator);
  mediaPeriods.add(period);
  return period;
}
 
Example #11
Source File: HlsMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator) {
  Assertions.checkArgument(id.periodIndex == 0);
  EventDispatcher eventDispatcher = createEventDispatcher(id);
  return new HlsMediaPeriod(
      extractorFactory,
      playlistTracker,
      dataSourceFactory,
      mediaTransferListener,
      chunkLoadErrorHandlingPolicy,
      minLoadableRetryCount,
      eventDispatcher,
      allocator,
      compositeSequenceableLoaderFactory,
      allowChunklessPreparation);
}
 
Example #12
Source File: DashMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(MediaPeriodId periodId, Allocator allocator) {
  int periodIndex = periodId.periodIndex;
  EventDispatcher periodEventDispatcher =
      createEventDispatcher(periodId, manifest.getPeriod(periodIndex).startMs);
  DashMediaPeriod mediaPeriod =
      new DashMediaPeriod(
          firstPeriodId + periodIndex,
          manifest,
          periodIndex,
          chunkSourceFactory,
          mediaTransferListener,
          minLoadableRetryCount,
          periodEventDispatcher,
          elapsedRealtimeOffsetMs,
          manifestLoadErrorThrower,
          allocator,
          compositeSequenceableLoaderFactory,
          playerEmsgCallback);
  periodsById.put(mediaPeriod.id, mediaPeriod);
  return mediaPeriod;
}
 
Example #13
Source File: SsMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator) {
  Assertions.checkArgument(id.periodIndex == 0);
  EventDispatcher eventDispatcher = createEventDispatcher(id);
  SsMediaPeriod period =
      new SsMediaPeriod(
          manifest,
          chunkSourceFactory,
          mediaTransferListener,
          compositeSequenceableLoaderFactory,
          minLoadableRetryCount,
          eventDispatcher,
          manifestLoaderErrorThrower,
          allocator);
  mediaPeriods.add(period);
  return period;
}
 
Example #14
Source File: ChunkSampleStream.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param primaryTrackType The type of the primary track. One of the {@link C} {@code
 *     TRACK_TYPE_*} constants.
 * @param embeddedTrackTypes The types of any embedded tracks, or null.
 * @param embeddedTrackFormats The formats of the embedded tracks, or null.
 * @param chunkSource A {@link ChunkSource} from which chunks to load are obtained.
 * @param callback An {@link Callback} for the stream.
 * @param allocator An {@link Allocator} from which allocations can be obtained.
 * @param positionUs The position from which to start loading media.
 * @param minLoadableRetryCount The minimum number of times that the source should retry a load
 *     before propagating an error.
 * @param eventDispatcher A dispatcher to notify of events.
 * @deprecated Use {@link #ChunkSampleStream(int, int[], Format[], ChunkSource, Callback,
 *     Allocator, long, LoadErrorHandlingPolicy, EventDispatcher)} instead.
 */
@Deprecated
public ChunkSampleStream(
    int primaryTrackType,
    int[] embeddedTrackTypes,
    Format[] embeddedTrackFormats,
    T chunkSource,
    Callback<ChunkSampleStream<T>> callback,
    Allocator allocator,
    long positionUs,
    int minLoadableRetryCount,
    EventDispatcher eventDispatcher) {
  this(
      primaryTrackType,
      embeddedTrackTypes,
      embeddedTrackFormats,
      chunkSource,
      callback,
      allocator,
      positionUs,
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      eventDispatcher);
}
 
Example #15
Source File: SingleSampleMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public SingleSampleMediaPeriod(
    DataSpec dataSpec,
    DataSource.Factory dataSourceFactory,
    @Nullable TransferListener transferListener,
    Format format,
    long durationUs,
    int minLoadableRetryCount,
    EventDispatcher eventDispatcher,
    boolean treatLoadErrorsAsEndOfStream) {
  this.dataSpec = dataSpec;
  this.dataSourceFactory = dataSourceFactory;
  this.transferListener = transferListener;
  this.format = format;
  this.durationUs = durationUs;
  this.minLoadableRetryCount = minLoadableRetryCount;
  this.eventDispatcher = eventDispatcher;
  this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream;
  tracks = new TrackGroupArray(new TrackGroup(format));
  sampleStreams = new ArrayList<>();
  loader = new Loader("Loader:SingleSampleMediaPeriod");
  eventDispatcher.mediaPeriodCreated();
}
 
Example #16
Source File: SsMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs) {
  EventDispatcher eventDispatcher = createEventDispatcher(id);
  SsMediaPeriod period =
      new SsMediaPeriod(
          manifest,
          chunkSourceFactory,
          mediaTransferListener,
          compositeSequenceableLoaderFactory,
          loadErrorHandlingPolicy,
          eventDispatcher,
          manifestLoaderErrorThrower,
          allocator);
  mediaPeriods.add(period);
  return period;
}
 
Example #17
Source File: DashMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(
    MediaPeriodId periodId, Allocator allocator, long startPositionUs) {
  int periodIndex = (Integer) periodId.periodUid - firstPeriodId;
  EventDispatcher periodEventDispatcher =
      createEventDispatcher(periodId, manifest.getPeriod(periodIndex).startMs);
  DashMediaPeriod mediaPeriod =
      new DashMediaPeriod(
          firstPeriodId + periodIndex,
          manifest,
          periodIndex,
          chunkSourceFactory,
          mediaTransferListener,
          loadErrorHandlingPolicy,
          periodEventDispatcher,
          elapsedRealtimeOffsetMs,
          manifestLoadErrorThrower,
          allocator,
          compositeSequenceableLoaderFactory,
          playerEmsgCallback);
  periodsById.put(mediaPeriod.id, mediaPeriod);
  return mediaPeriod;
}
 
Example #18
Source File: SingleSampleMediaPeriod.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public SingleSampleMediaPeriod(
    DataSpec dataSpec,
    DataSource.Factory dataSourceFactory,
    @Nullable TransferListener transferListener,
    Format format,
    long durationUs,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    EventDispatcher eventDispatcher,
    boolean treatLoadErrorsAsEndOfStream) {
  this.dataSpec = dataSpec;
  this.dataSourceFactory = dataSourceFactory;
  this.transferListener = transferListener;
  this.format = format;
  this.durationUs = durationUs;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.eventDispatcher = eventDispatcher;
  this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream;
  tracks = new TrackGroupArray(new TrackGroup(format));
  sampleStreams = new ArrayList<>();
  loader = new Loader("Loader:SingleSampleMediaPeriod");
  eventDispatcher.mediaPeriodCreated();
}
 
Example #19
Source File: ChunkSampleStream.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param primaryTrackType The type of the primary track. One of the {@link C} {@code
 *     TRACK_TYPE_*} constants.
 * @param embeddedTrackTypes The types of any embedded tracks, or null.
 * @param embeddedTrackFormats The formats of the embedded tracks, or null.
 * @param chunkSource A {@link ChunkSource} from which chunks to load are obtained.
 * @param callback An {@link Callback} for the stream.
 * @param allocator An {@link Allocator} from which allocations can be obtained.
 * @param positionUs The position from which to start loading media.
 * @param minLoadableRetryCount The minimum number of times that the source should retry a load
 *     before propagating an error.
 * @param eventDispatcher A dispatcher to notify of events.
 * @deprecated Use {@link #ChunkSampleStream(int, int[], Format[], ChunkSource, Callback,
 *     Allocator, long, LoadErrorHandlingPolicy, EventDispatcher)} instead.
 */
@Deprecated
public ChunkSampleStream(
    int primaryTrackType,
    int[] embeddedTrackTypes,
    Format[] embeddedTrackFormats,
    T chunkSource,
    Callback<ChunkSampleStream<T>> callback,
    Allocator allocator,
    long positionUs,
    int minLoadableRetryCount,
    EventDispatcher eventDispatcher) {
  this(
      primaryTrackType,
      embeddedTrackTypes,
      embeddedTrackFormats,
      chunkSource,
      callback,
      allocator,
      positionUs,
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      eventDispatcher);
}
 
Example #20
Source File: HlsMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs) {
  EventDispatcher eventDispatcher = createEventDispatcher(id);
  return new HlsMediaPeriod(
      extractorFactory,
      playlistTracker,
      dataSourceFactory,
      mediaTransferListener,
      loadErrorHandlingPolicy,
      eventDispatcher,
      allocator,
      compositeSequenceableLoaderFactory,
      allowChunklessPreparation,
      metadataType,
      useSessionKeys);
}
 
Example #21
Source File: SsMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public SsMediaPeriod(
    SsManifest manifest,
    SsChunkSource.Factory chunkSourceFactory,
    @Nullable TransferListener transferListener,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    EventDispatcher eventDispatcher,
    LoaderErrorThrower manifestLoaderErrorThrower,
    Allocator allocator) {
  this.manifest = manifest;
  this.chunkSourceFactory = chunkSourceFactory;
  this.transferListener = transferListener;
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.eventDispatcher = eventDispatcher;
  this.allocator = allocator;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  trackGroups = buildTrackGroups(manifest);
  sampleStreams = newSampleStreamArray(0);
  compositeSequenceableLoader =
      compositeSequenceableLoaderFactory.createCompositeSequenceableLoader(sampleStreams);
  eventDispatcher.mediaPeriodCreated();
}
 
Example #22
Source File: SsMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs) {
  EventDispatcher eventDispatcher = createEventDispatcher(id);
  SsMediaPeriod period =
      new SsMediaPeriod(
          manifest,
          chunkSourceFactory,
          mediaTransferListener,
          compositeSequenceableLoaderFactory,
          loadErrorHandlingPolicy,
          eventDispatcher,
          manifestLoaderErrorThrower,
          allocator);
  mediaPeriods.add(period);
  return period;
}
 
Example #23
Source File: DashMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(
    MediaPeriodId periodId, Allocator allocator, long startPositionUs) {
  int periodIndex = (Integer) periodId.periodUid - firstPeriodId;
  EventDispatcher periodEventDispatcher =
      createEventDispatcher(periodId, manifest.getPeriod(periodIndex).startMs);
  DashMediaPeriod mediaPeriod =
      new DashMediaPeriod(
          firstPeriodId + periodIndex,
          manifest,
          periodIndex,
          chunkSourceFactory,
          mediaTransferListener,
          loadErrorHandlingPolicy,
          periodEventDispatcher,
          elapsedRealtimeOffsetMs,
          manifestLoadErrorThrower,
          allocator,
          compositeSequenceableLoaderFactory,
          playerEmsgCallback);
  periodsById.put(mediaPeriod.id, mediaPeriod);
  return mediaPeriod;
}
 
Example #24
Source File: SingleSampleMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public SingleSampleMediaPeriod(
    DataSpec dataSpec,
    DataSource.Factory dataSourceFactory,
    @Nullable TransferListener transferListener,
    Format format,
    long durationUs,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    EventDispatcher eventDispatcher,
    boolean treatLoadErrorsAsEndOfStream) {
  this.dataSpec = dataSpec;
  this.dataSourceFactory = dataSourceFactory;
  this.transferListener = transferListener;
  this.format = format;
  this.durationUs = durationUs;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.eventDispatcher = eventDispatcher;
  this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream;
  tracks = new TrackGroupArray(new TrackGroup(format));
  sampleStreams = new ArrayList<>();
  loader = new Loader("Loader:SingleSampleMediaPeriod");
  eventDispatcher.mediaPeriodCreated();
}
 
Example #25
Source File: HlsMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs) {
  EventDispatcher eventDispatcher = createEventDispatcher(id);
  return new HlsMediaPeriod(
      extractorFactory,
      playlistTracker,
      dataSourceFactory,
      mediaTransferListener,
      loadErrorHandlingPolicy,
      eventDispatcher,
      allocator,
      compositeSequenceableLoaderFactory,
      allowChunklessPreparation,
      metadataType,
      useSessionKeys);
}
 
Example #26
Source File: HlsSampleStreamWrapper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param trackType The type of the track. One of the {@link C} {@code TRACK_TYPE_*} constants.
 * @param callback A callback for the wrapper.
 * @param chunkSource A {@link HlsChunkSource} from which chunks to load are obtained.
 * @param overridingDrmInitData Overriding {@link DrmInitData}, keyed by protection scheme type
 *     (i.e. {@link DrmInitData#schemeType}). If the stream has {@link DrmInitData} and uses a
 *     protection scheme type for which overriding {@link DrmInitData} is provided, then the
 *     stream's {@link DrmInitData} will be overridden.
 * @param allocator An {@link Allocator} from which to obtain media buffer allocations.
 * @param positionUs The position from which to start loading media.
 * @param muxedAudioFormat Optional muxed audio {@link Format} as defined by the master playlist.
 * @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}.
 * @param eventDispatcher A dispatcher to notify of events.
 */
public HlsSampleStreamWrapper(
    int trackType,
    Callback callback,
    HlsChunkSource chunkSource,
    Map<String, DrmInitData> overridingDrmInitData,
    Allocator allocator,
    long positionUs,
    Format muxedAudioFormat,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    EventDispatcher eventDispatcher,
    @HlsMetadataType int metadataType) {
  this.trackType = trackType;
  this.callback = callback;
  this.chunkSource = chunkSource;
  this.overridingDrmInitData = overridingDrmInitData;
  this.allocator = allocator;
  this.muxedAudioFormat = muxedAudioFormat;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.eventDispatcher = eventDispatcher;
  this.metadataType = metadataType;
  loader = new Loader("Loader:HlsSampleStreamWrapper");
  nextChunkHolder = new HlsChunkSource.HlsChunkHolder();
  sampleQueueTrackIds = new int[0];
  sampleQueueMappingDoneByType = new HashSet<>(MAPPABLE_TYPES.size());
  sampleQueueIndicesByType = new SparseIntArray(MAPPABLE_TYPES.size());
  sampleQueues = new SampleQueue[0];
  sampleQueueIsAudioVideoFlags = new boolean[0];
  sampleQueuesEnabledStates = new boolean[0];
  mediaChunks = new ArrayList<>();
  readOnlyMediaChunks = Collections.unmodifiableList(mediaChunks);
  hlsSampleStreams = new ArrayList<>();
  maybeFinishPrepareRunnable = this::maybeFinishPrepare;
  onTracksEndedRunnable = this::onTracksEnded;
  handler = new Handler();
  lastSeekPositionUs = positionUs;
  pendingResetPositionUs = positionUs;
}
 
Example #27
Source File: SsMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public SsMediaPeriod(
    SsManifest manifest,
    SsChunkSource.Factory chunkSourceFactory,
    @Nullable TransferListener transferListener,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    int minLoadableRetryCount,
    EventDispatcher eventDispatcher,
    LoaderErrorThrower manifestLoaderErrorThrower,
    Allocator allocator) {
  this.chunkSourceFactory = chunkSourceFactory;
  this.transferListener = transferListener;
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.minLoadableRetryCount = minLoadableRetryCount;
  this.eventDispatcher = eventDispatcher;
  this.allocator = allocator;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;

  trackGroups = buildTrackGroups(manifest);
  ProtectionElement protectionElement = manifest.protectionElement;
  if (protectionElement != null) {
    byte[] keyId = getProtectionElementKeyId(protectionElement.data);
    // We assume pattern encryption does not apply.
    trackEncryptionBoxes = new TrackEncryptionBox[] {
        new TrackEncryptionBox(true, null, INITIALIZATION_VECTOR_SIZE, keyId, 0, 0, null)};
  } else {
    trackEncryptionBoxes = null;
  }
  this.manifest = manifest;
  sampleStreams = newSampleStreamArray(0);
  compositeSequenceableLoader =
      compositeSequenceableLoaderFactory.createCompositeSequenceableLoader(sampleStreams);
  eventDispatcher.mediaPeriodCreated();
}
 
Example #28
Source File: HlsMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an HLS media period.
 *
 * @param extractorFactory An {@link HlsExtractorFactory} for {@link Extractor}s for the segments.
 * @param playlistTracker A tracker for HLS playlists.
 * @param dataSourceFactory An {@link HlsDataSourceFactory} for {@link DataSource}s for segments
 *     and keys.
 * @param mediaTransferListener The transfer listener to inform of any media data transfers. May
 *     be null if no listener is available.
 * @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}.
 * @param eventDispatcher A dispatcher to notify of events.
 * @param allocator An {@link Allocator} from which to obtain media buffer allocations.
 * @param compositeSequenceableLoaderFactory A factory to create composite {@link
 *     SequenceableLoader}s for when this media source loads data from multiple streams.
 * @param allowChunklessPreparation Whether chunkless preparation is allowed.
 * @param useSessionKeys Whether to use #EXT-X-SESSION-KEY tags.
 */
public HlsMediaPeriod(
    HlsExtractorFactory extractorFactory,
    HlsPlaylistTracker playlistTracker,
    HlsDataSourceFactory dataSourceFactory,
    @Nullable TransferListener mediaTransferListener,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    EventDispatcher eventDispatcher,
    Allocator allocator,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    boolean allowChunklessPreparation,
    @HlsMetadataType int metadataType,
    boolean useSessionKeys) {
  this.extractorFactory = extractorFactory;
  this.playlistTracker = playlistTracker;
  this.dataSourceFactory = dataSourceFactory;
  this.mediaTransferListener = mediaTransferListener;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.eventDispatcher = eventDispatcher;
  this.allocator = allocator;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  this.allowChunklessPreparation = allowChunklessPreparation;
  this.metadataType = metadataType;
  this.useSessionKeys = useSessionKeys;
  compositeSequenceableLoader =
      compositeSequenceableLoaderFactory.createCompositeSequenceableLoader();
  streamWrapperIndices = new IdentityHashMap<>();
  timestampAdjusterProvider = new TimestampAdjusterProvider();
  sampleStreamWrappers = new HlsSampleStreamWrapper[0];
  enabledSampleStreamWrappers = new HlsSampleStreamWrapper[0];
  manifestUrlIndicesPerWrapper = new int[0][];
  eventDispatcher.mediaPeriodCreated();
}
 
Example #29
Source File: DashMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public DashMediaPeriod(
    int id,
    DashManifest manifest,
    int periodIndex,
    DashChunkSource.Factory chunkSourceFactory,
    @Nullable TransferListener transferListener,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    EventDispatcher eventDispatcher,
    long elapsedRealtimeOffsetMs,
    LoaderErrorThrower manifestLoaderErrorThrower,
    Allocator allocator,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    PlayerEmsgCallback playerEmsgCallback) {
  this.id = id;
  this.manifest = manifest;
  this.periodIndex = periodIndex;
  this.chunkSourceFactory = chunkSourceFactory;
  this.transferListener = transferListener;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.eventDispatcher = eventDispatcher;
  this.elapsedRealtimeOffsetMs = elapsedRealtimeOffsetMs;
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.allocator = allocator;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  playerEmsgHandler = new PlayerEmsgHandler(manifest, playerEmsgCallback, allocator);
  sampleStreams = newSampleStreamArray(0);
  eventSampleStreams = new EventSampleStream[0];
  trackEmsgHandlerBySampleStream = new IdentityHashMap<>();
  compositeSequenceableLoader =
      compositeSequenceableLoaderFactory.createCompositeSequenceableLoader(sampleStreams);
  Period period = manifest.getPeriod(periodIndex);
  eventStreams = period.eventStreams;
  Pair<TrackGroupArray, TrackGroupInfo[]> result = buildTrackGroups(period.adaptationSets,
      eventStreams);
  trackGroups = result.first;
  trackGroupInfos = result.second;
  eventDispatcher.mediaPeriodCreated();
}
 
Example #30
Source File: HlsMediaPeriod.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an HLS media period.
 *
 * @param extractorFactory An {@link HlsExtractorFactory} for {@link Extractor}s for the segments.
 * @param playlistTracker A tracker for HLS playlists.
 * @param dataSourceFactory An {@link HlsDataSourceFactory} for {@link DataSource}s for segments
 *     and keys.
 * @param mediaTransferListener The transfer listener to inform of any media data transfers. May
 *     be null if no listener is available.
 * @param drmSessionManager The {@link DrmSessionManager} to acquire {@link DrmSession
 *     DrmSessions} with.
 * @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}.
 * @param eventDispatcher A dispatcher to notify of events.
 * @param allocator An {@link Allocator} from which to obtain media buffer allocations.
 * @param compositeSequenceableLoaderFactory A factory to create composite {@link
 *     SequenceableLoader}s for when this media source loads data from multiple streams.
 * @param allowChunklessPreparation Whether chunkless preparation is allowed.
 * @param useSessionKeys Whether to use #EXT-X-SESSION-KEY tags.
 */
public HlsMediaPeriod(
    HlsExtractorFactory extractorFactory,
    HlsPlaylistTracker playlistTracker,
    HlsDataSourceFactory dataSourceFactory,
    @Nullable TransferListener mediaTransferListener,
    DrmSessionManager<?> drmSessionManager,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    EventDispatcher eventDispatcher,
    Allocator allocator,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    boolean allowChunklessPreparation,
    @HlsMediaSource.MetadataType int metadataType,
    boolean useSessionKeys) {
  this.extractorFactory = extractorFactory;
  this.playlistTracker = playlistTracker;
  this.dataSourceFactory = dataSourceFactory;
  this.mediaTransferListener = mediaTransferListener;
  this.drmSessionManager = drmSessionManager;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.eventDispatcher = eventDispatcher;
  this.allocator = allocator;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  this.allowChunklessPreparation = allowChunklessPreparation;
  this.metadataType = metadataType;
  this.useSessionKeys = useSessionKeys;
  compositeSequenceableLoader =
      compositeSequenceableLoaderFactory.createCompositeSequenceableLoader();
  streamWrapperIndices = new IdentityHashMap<>();
  timestampAdjusterProvider = new TimestampAdjusterProvider();
  sampleStreamWrappers = new HlsSampleStreamWrapper[0];
  enabledSampleStreamWrappers = new HlsSampleStreamWrapper[0];
  manifestUrlIndicesPerWrapper = new int[0][];
  eventDispatcher.mediaPeriodCreated();
}