com.google.android.exoplayer2.upstream.TransferListener Java Examples

The following examples show how to use com.google.android.exoplayer2.upstream.TransferListener. 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: ConcatenatingMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public final synchronized void prepareSourceInternal(
    ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
  this.player = player;
  playerApplicationHandler = new Handler(player.getApplicationLooper());
  if (mediaSourcesPublic.isEmpty()) {
    notifyListener();
  } else {
    shuffleOrder = shuffleOrder.cloneAndInsert(0, mediaSourcesPublic.size());
    addMediaSourcesInternal(0, mediaSourcesPublic);
    scheduleListenerNotification(/* actionOnCompletion= */ null);
  }
}
 
Example #2
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 #3
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 #4
Source File: BaseMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public final void prepareSource(
    MediaSourceCaller caller, @Nullable TransferListener mediaTransferListener) {
  Looper looper = Looper.myLooper();
  Assertions.checkArgument(this.looper == null || this.looper == looper);
  Timeline timeline = this.timeline;
  mediaSourceCallers.add(caller);
  if (this.looper == null) {
    this.looper = looper;
    enabledMediaSourceCallers.add(caller);
    prepareSourceInternal(mediaTransferListener);
  } else if (timeline != null) {
    enable(caller);
    caller.onSourceInfoRefreshed(/* source= */ this, timeline);
  }
}
 
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: SsMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void prepareSourceInternal(
    ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  this.mediaTransferListener = mediaTransferListener;
  if (sideloadedManifest) {
    manifestLoaderErrorThrower = new LoaderErrorThrower.Dummy();
    processManifest();
  } else {
    manifestDataSource = manifestDataSourceFactory.createDataSource();
    manifestLoader = new Loader("Loader:Manifest");
    manifestLoaderErrorThrower = manifestLoader;
    manifestRefreshHandler = new Handler();
    startLoadingManifest();
  }
}
 
Example #7
Source File: AdsMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void prepareSourceInternal(
    final ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
  Assertions.checkArgument(isTopLevelSource);
  final ComponentListener componentListener = new ComponentListener();
  this.componentListener = componentListener;
  prepareChildSource(DUMMY_CONTENT_MEDIA_PERIOD_ID, contentMediaSource);
  mainHandler.post(new Runnable() {
    @Override
    public void run() {
      adsLoader.attachPlayer(player, componentListener, adUiViewGroup);
    }
  });
}
 
Example #8
Source File: SsMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void prepareSourceInternal(
    ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  this.mediaTransferListener = mediaTransferListener;
  if (sideloadedManifest) {
    manifestLoaderErrorThrower = new LoaderErrorThrower.Dummy();
    processManifest();
  } else {
    manifestDataSource = manifestDataSourceFactory.createDataSource();
    manifestLoader = new Loader("Loader:Manifest");
    manifestLoaderErrorThrower = manifestLoader;
    manifestRefreshHandler = new Handler();
    startLoadingManifest();
  }
}
 
Example #9
Source File: AdsMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void prepareSourceInternal(
    final ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
  Assertions.checkArgument(isTopLevelSource);
  final ComponentListener componentListener = new ComponentListener();
  this.componentListener = componentListener;
  prepareChildSource(DUMMY_CONTENT_MEDIA_PERIOD_ID, contentMediaSource);
  mainHandler.post(new Runnable() {
    @Override
    public void run() {
      adsLoader.attachPlayer(player, componentListener, adUiViewGroup);
    }
  });
}
 
Example #10
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 #11
Source File: HlsChunkSource.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * @param extractorFactory An {@link HlsExtractorFactory} from which to obtain the extractors for
 *     media chunks.
 * @param playlistTracker The {@link HlsPlaylistTracker} from which to obtain media playlists.
 * @param playlistUrls The {@link Uri}s of the media playlists that can be adapted between by this
 *     chunk source.
 * @param playlistFormats The {@link Format Formats} corresponding to the media playlists.
 * @param dataSourceFactory An {@link HlsDataSourceFactory} to create {@link DataSource}s for the
 *     chunks.
 * @param mediaTransferListener The transfer listener which should be informed of any media data
 *     transfers. May be null if no listener is available.
 * @param timestampAdjusterProvider A provider of {@link TimestampAdjuster} instances. If multiple
 *     {@link HlsChunkSource}s are used for a single playback, they should all share the same
 *     provider.
 * @param muxedCaptionFormats List of muxed caption {@link Format}s. Null if no closed caption
 *     information is available in the master playlist.
 */
public HlsChunkSource(
    HlsExtractorFactory extractorFactory,
    HlsPlaylistTracker playlistTracker,
    Uri[] playlistUrls,
    Format[] playlistFormats,
    HlsDataSourceFactory dataSourceFactory,
    @Nullable TransferListener mediaTransferListener,
    TimestampAdjusterProvider timestampAdjusterProvider,
    @Nullable List<Format> muxedCaptionFormats) {
  this.extractorFactory = extractorFactory;
  this.playlistTracker = playlistTracker;
  this.playlistUrls = playlistUrls;
  this.playlistFormats = playlistFormats;
  this.timestampAdjusterProvider = timestampAdjusterProvider;
  this.muxedCaptionFormats = muxedCaptionFormats;
  keyCache = new FullSegmentEncryptionKeyCache(KEY_CACHE_SIZE);
  scratchSpace = Util.EMPTY_BYTE_ARRAY;
  liveEdgeInPeriodTimeUs = C.TIME_UNSET;
  mediaDataSource = dataSourceFactory.createDataSource(C.DATA_TYPE_MEDIA);
  if (mediaTransferListener != null) {
    mediaDataSource.addTransferListener(mediaTransferListener);
  }
  encryptionDataSource = dataSourceFactory.createDataSource(C.DATA_TYPE_DRM);
  trackGroup = new TrackGroup(playlistFormats);
  int[] initialTrackSelection = new int[playlistUrls.length];
  for (int i = 0; i < playlistUrls.length; i++) {
    initialTrackSelection[i] = i;
  }
  trackSelection = new InitializationTrackSelection(trackGroup, initialTrackSelection);
}
 
Example #12
Source File: HlsMediaSource.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener) {
  this.mediaTransferListener = mediaTransferListener;
  drmSessionManager.prepare();
  EventDispatcher eventDispatcher = createEventDispatcher(/* mediaPeriodId= */ null);
  playlistTracker.start(manifestUri, eventDispatcher, /* listener= */ this);
}
 
Example #13
Source File: DashMediaSource.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener) {
  this.mediaTransferListener = mediaTransferListener;
  drmSessionManager.prepare();
  if (sideloadedManifest) {
    processManifest(false);
  } else {
    dataSource = manifestDataSourceFactory.createDataSource();
    loader = new Loader("Loader:DashMediaSource");
    handler = new Handler();
    startLoadingManifest();
  }
}
 
Example #14
Source File: BaseMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void prepareSource(
    ExoPlayer player,
    boolean isTopLevelSource,
    SourceInfoRefreshListener listener,
    @Nullable TransferListener mediaTransferListener) {
  Assertions.checkArgument(this.player == null || this.player == player);
  sourceInfoListeners.add(listener);
  if (this.player == null) {
    this.player = player;
    prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
  } else if (timeline != null) {
    listener.onSourceInfoRefreshed(/* source= */ this, timeline, manifest);
  }
}
 
Example #15
Source File: HlsMediaPeriod.java    From TelePlus-Android 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 chunkLoadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy} for chunk loads.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @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.
 */
public HlsMediaPeriod(
    HlsExtractorFactory extractorFactory,
    HlsPlaylistTracker playlistTracker,
    HlsDataSourceFactory dataSourceFactory,
    @Nullable TransferListener mediaTransferListener,
    LoadErrorHandlingPolicy<Chunk> chunkLoadErrorHandlingPolicy,
    int minLoadableRetryCount,
    EventDispatcher eventDispatcher,
    Allocator allocator,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    boolean allowChunklessPreparation) {
  this.extractorFactory = extractorFactory;
  this.playlistTracker = playlistTracker;
  this.dataSourceFactory = dataSourceFactory;
  this.mediaTransferListener = mediaTransferListener;
  this.chunkLoadErrorHandlingPolicy = chunkLoadErrorHandlingPolicy;
  this.minLoadableRetryCount = minLoadableRetryCount;
  this.eventDispatcher = eventDispatcher;
  this.allocator = allocator;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  this.allowChunklessPreparation = allowChunklessPreparation;
  compositeSequenceableLoader =
      compositeSequenceableLoaderFactory.createCompositeSequenceableLoader();
  streamWrapperIndices = new IdentityHashMap<>();
  timestampAdjusterProvider = new TimestampAdjusterProvider();
  sampleStreamWrappers = new HlsSampleStreamWrapper[0];
  enabledSampleStreamWrappers = new HlsSampleStreamWrapper[0];
  eventDispatcher.mediaPeriodCreated();
}
 
Example #16
Source File: LoopingMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void prepareSourceInternal(
    ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
  prepareChildSource(/* id= */ null, childSource);
}
 
Example #17
Source File: DashMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void prepareSourceInternal(
    ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  this.mediaTransferListener = mediaTransferListener;
  if (sideloadedManifest) {
    processManifest(false);
  } else {
    dataSource = manifestDataSourceFactory.createDataSource();
    loader = new Loader("Loader:DashMediaSource");
    handler = new Handler();
    startLoadingManifest();
  }
}
 
Example #18
Source File: CompositeMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
@CallSuper
public void prepareSourceInternal(
    ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  this.player = player;
  this.mediaTransferListener = mediaTransferListener;
  eventHandler = new Handler();
}
 
Example #19
Source File: ExtractorMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void prepareSourceInternal(
    ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  transferListener = mediaTransferListener;
  notifySourceInfoRefreshed(timelineDurationUs, /* isSeekable= */ false);
}
 
Example #20
Source File: AttachmentDataSourceFactory.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
public AttachmentDataSourceFactory(@NonNull MasterSecret masterSecret,
                                   @NonNull DefaultDataSourceFactory defaultDataSourceFactory,
                                   @Nullable TransferListener<? super DataSource> listener)
{
  this.masterSecret             = masterSecret;
  this.defaultDataSourceFactory = defaultDataSourceFactory;
  this.listener                 = listener;
}
 
Example #21
Source File: HlsChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param extractorFactory An {@link HlsExtractorFactory} from which to obtain the extractors for
 *     media chunks.
 * @param playlistTracker The {@link HlsPlaylistTracker} from which to obtain media playlists.
 * @param variants The available variants.
 * @param dataSourceFactory An {@link HlsDataSourceFactory} to create {@link DataSource}s for the
 *     chunks.
 * @param mediaTransferListener The transfer listener which should be informed of any media data
 *     transfers. May be null if no listener is available.
 * @param timestampAdjusterProvider A provider of {@link TimestampAdjuster} instances. If multiple
 *     {@link HlsChunkSource}s are used for a single playback, they should all share the same
 *     provider.
 * @param muxedCaptionFormats List of muxed caption {@link Format}s. Null if no closed caption
 *     information is available in the master playlist.
 */
public HlsChunkSource(
    HlsExtractorFactory extractorFactory,
    HlsPlaylistTracker playlistTracker,
    HlsUrl[] variants,
    HlsDataSourceFactory dataSourceFactory,
    @Nullable TransferListener mediaTransferListener,
    TimestampAdjusterProvider timestampAdjusterProvider,
    List<Format> muxedCaptionFormats) {
  this.extractorFactory = extractorFactory;
  this.playlistTracker = playlistTracker;
  this.variants = variants;
  this.timestampAdjusterProvider = timestampAdjusterProvider;
  this.muxedCaptionFormats = muxedCaptionFormats;
  liveEdgeInPeriodTimeUs = C.TIME_UNSET;
  Format[] variantFormats = new Format[variants.length];
  int[] initialTrackSelection = new int[variants.length];
  for (int i = 0; i < variants.length; i++) {
    variantFormats[i] = variants[i].format;
    initialTrackSelection[i] = i;
  }
  mediaDataSource = dataSourceFactory.createDataSource(C.DATA_TYPE_MEDIA);
  if (mediaTransferListener != null) {
    mediaDataSource.addTransferListener(mediaTransferListener);
  }
  encryptionDataSource = dataSourceFactory.createDataSource(C.DATA_TYPE_DRM);
  trackGroup = new TrackGroup(variantFormats);
  trackSelection = new InitializationTrackSelection(trackGroup, initialTrackSelection);
}
 
Example #22
Source File: ExtendedDefaultDataSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a new instance that delegates to a provided {@link DataSource} for URI schemes other
 * than file, asset and content.
 *
 * @param context        A context.
 * @param listener       An optional listener.
 * @param baseDataSource A {@link DataSource} to use for URI schemes other than file, asset and
 *                       content. This {@link DataSource} should normally support at least http(s).
 */
public ExtendedDefaultDataSource(Context context, TransferListener listener,
                                 DataSource baseDataSource) {
    this.baseDataSource = Assertions.checkNotNull(baseDataSource);
    this.fileDataSource = new FileDataSource(listener);
    this.encryptedFileDataSource = new EncryptedFileDataSource(listener);
    this.assetDataSource = new AssetDataSource(context, listener);
    this.contentDataSource = new ContentDataSource(context, listener);
    this.listener = listener;
}
 
Example #23
Source File: SingleSampleMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void prepareSourceInternal(
    ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  transferListener = mediaTransferListener;
  refreshSourceInfo(timeline, /* manifest= */ null);
}
 
Example #24
Source File: ClippingMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void prepareSourceInternal(
    ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
  prepareChildSource(/* id= */ null, mediaSource);
}
 
Example #25
Source File: HlsMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void prepareSourceInternal(
    ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  this.mediaTransferListener = mediaTransferListener;
  EventDispatcher eventDispatcher = createEventDispatcher(/* mediaPeriodId= */ null);
  playlistTracker.start(manifestUri, eventDispatcher, /* listener= */ this);
}
 
Example #26
Source File: HlsMediaPeriod.java    From TelePlus-Android 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 chunkLoadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy} for chunk loads.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @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.
 */
public HlsMediaPeriod(
    HlsExtractorFactory extractorFactory,
    HlsPlaylistTracker playlistTracker,
    HlsDataSourceFactory dataSourceFactory,
    @Nullable TransferListener mediaTransferListener,
    LoadErrorHandlingPolicy<Chunk> chunkLoadErrorHandlingPolicy,
    int minLoadableRetryCount,
    EventDispatcher eventDispatcher,
    Allocator allocator,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    boolean allowChunklessPreparation) {
  this.extractorFactory = extractorFactory;
  this.playlistTracker = playlistTracker;
  this.dataSourceFactory = dataSourceFactory;
  this.mediaTransferListener = mediaTransferListener;
  this.chunkLoadErrorHandlingPolicy = chunkLoadErrorHandlingPolicy;
  this.minLoadableRetryCount = minLoadableRetryCount;
  this.eventDispatcher = eventDispatcher;
  this.allocator = allocator;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  this.allowChunklessPreparation = allowChunklessPreparation;
  compositeSequenceableLoader =
      compositeSequenceableLoaderFactory.createCompositeSequenceableLoader();
  streamWrapperIndices = new IdentityHashMap<>();
  timestampAdjusterProvider = new TimestampAdjusterProvider();
  sampleStreamWrappers = new HlsSampleStreamWrapper[0];
  enabledSampleStreamWrappers = new HlsSampleStreamWrapper[0];
  eventDispatcher.mediaPeriodCreated();
}
 
Example #27
Source File: HlsChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param extractorFactory An {@link HlsExtractorFactory} from which to obtain the extractors for
 *     media chunks.
 * @param playlistTracker The {@link HlsPlaylistTracker} from which to obtain media playlists.
 * @param variants The available variants.
 * @param dataSourceFactory An {@link HlsDataSourceFactory} to create {@link DataSource}s for the
 *     chunks.
 * @param mediaTransferListener The transfer listener which should be informed of any media data
 *     transfers. May be null if no listener is available.
 * @param timestampAdjusterProvider A provider of {@link TimestampAdjuster} instances. If multiple
 *     {@link HlsChunkSource}s are used for a single playback, they should all share the same
 *     provider.
 * @param muxedCaptionFormats List of muxed caption {@link Format}s. Null if no closed caption
 *     information is available in the master playlist.
 */
public HlsChunkSource(
    HlsExtractorFactory extractorFactory,
    HlsPlaylistTracker playlistTracker,
    HlsUrl[] variants,
    HlsDataSourceFactory dataSourceFactory,
    @Nullable TransferListener mediaTransferListener,
    TimestampAdjusterProvider timestampAdjusterProvider,
    List<Format> muxedCaptionFormats) {
  this.extractorFactory = extractorFactory;
  this.playlistTracker = playlistTracker;
  this.variants = variants;
  this.timestampAdjusterProvider = timestampAdjusterProvider;
  this.muxedCaptionFormats = muxedCaptionFormats;
  liveEdgeInPeriodTimeUs = C.TIME_UNSET;
  Format[] variantFormats = new Format[variants.length];
  int[] initialTrackSelection = new int[variants.length];
  for (int i = 0; i < variants.length; i++) {
    variantFormats[i] = variants[i].format;
    initialTrackSelection[i] = i;
  }
  mediaDataSource = dataSourceFactory.createDataSource(C.DATA_TYPE_MEDIA);
  if (mediaTransferListener != null) {
    mediaDataSource.addTransferListener(mediaTransferListener);
  }
  encryptionDataSource = dataSourceFactory.createDataSource(C.DATA_TYPE_DRM);
  trackGroup = new TrackGroup(variantFormats);
  trackSelection = new InitializationTrackSelection(trackGroup, initialTrackSelection);
}
 
Example #28
Source File: DashMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void prepareSourceInternal(
    ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  this.mediaTransferListener = mediaTransferListener;
  if (sideloadedManifest) {
    processManifest(false);
  } else {
    dataSource = manifestDataSourceFactory.createDataSource();
    loader = new Loader("Loader:DashMediaSource");
    handler = new Handler();
    startLoadingManifest();
  }
}
 
Example #29
Source File: SingleSampleMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void prepareSourceInternal(
    ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  transferListener = mediaTransferListener;
  refreshSourceInfo(timeline, /* manifest= */ null);
}
 
Example #30
Source File: ClippingMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void prepareSourceInternal(
    ExoPlayer player,
    boolean isTopLevelSource,
    @Nullable TransferListener mediaTransferListener) {
  super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
  prepareChildSource(/* id= */ null, mediaSource);
}