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

The following examples show how to use com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy. 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: SsMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be live or
 * on-demand.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param manifestParser A parser for loaded manifest data.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param livePresentationDelayMs For live playbacks, the duration in milliseconds by which the
 *     default start position should precede the end of the live window.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public SsMediaSource(
    Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory,
    ParsingLoadable.Parser<? extends SsManifest> manifestParser,
    SsChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount,
    long livePresentationDelayMs,
    Handler eventHandler,
    MediaSourceEventListener eventListener) {
  this(
      /* manifest= */ null,
      manifestUri,
      manifestDataSourceFactory,
      manifestParser,
      chunkSourceFactory,
      new DefaultCompositeSequenceableLoaderFactory(),
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      livePresentationDelayMs,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, eventListener);
  }
}
 
Example #2
Source File: DashMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be dynamic or
 * static.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param chunkSourceFactory A factory for {@link DashChunkSource} instances.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public DashMediaSource(
    Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory,
    DashChunkSource.Factory chunkSourceFactory,
    @Nullable Handler eventHandler,
    @Nullable MediaSourceEventListener eventListener) {
  this(
      manifestUri,
      manifestDataSourceFactory,
      chunkSourceFactory,
      DefaultLoadErrorHandlingPolicy.DEFAULT_MIN_LOADABLE_RETRY_COUNT,
      DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS,
      eventHandler,
      eventListener);
}
 
Example #3
Source File: DashMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance to play a given {@link DashManifest}, which must be static.
 *
 * @param manifest The manifest. {@link DashManifest#dynamic} must be false.
 * @param chunkSourceFactory A factory for {@link DashChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public DashMediaSource(
    DashManifest manifest,
    DashChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount,
    @Nullable Handler eventHandler,
    @Nullable MediaSourceEventListener eventListener) {
  this(
      manifest,
      /* manifestUri= */ null,
      /* manifestDataSourceFactory= */ null,
      /* manifestParser= */ null,
      chunkSourceFactory,
      new DefaultCompositeSequenceableLoaderFactory(),
      DrmSessionManager.getDummyDrmSessionManager(),
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      DEFAULT_LIVE_PRESENTATION_DELAY_MS,
      /* livePresentationDelayOverridesManifest= */ false,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, eventListener);
  }
}
 
Example #4
Source File: SingleSampleMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * @param uri The {@link Uri} of the media stream.
 * @param dataSourceFactory The factory from which the {@link DataSource} to read the media will
 *     be obtained.
 * @param format The {@link Format} associated with the output track.
 * @param durationUs The duration of the media stream in microseconds.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param eventSourceId An identifier that gets passed to {@code eventListener} methods.
 * @param treatLoadErrorsAsEndOfStream If true, load errors will not be propagated by sample
 *     streams, treating them as ended instead. If false, load errors will be propagated normally
 *     by {@link SampleStream#maybeThrowError()}.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public SingleSampleMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    Format format,
    long durationUs,
    int minLoadableRetryCount,
    Handler eventHandler,
    EventListener eventListener,
    int eventSourceId,
    boolean treatLoadErrorsAsEndOfStream) {
  this(
      uri,
      dataSourceFactory,
      format,
      durationUs,
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      treatLoadErrorsAsEndOfStream,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, new EventListenerWrapper(eventListener, eventSourceId));
  }
}
 
Example #5
Source File: SingleSampleMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * @param uri The {@link Uri} of the media stream.
 * @param dataSourceFactory The factory from which the {@link DataSource} to read the media will
 *     be obtained.
 * @param format The {@link Format} associated with the output track.
 * @param durationUs The duration of the media stream in microseconds.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public SingleSampleMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    Format format,
    long durationUs,
    int minLoadableRetryCount) {
  this(
      uri,
      dataSourceFactory,
      format,
      durationUs,
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      /* treatLoadErrorsAsEndOfStream= */ false,
      /* tag= */ null);
}
 
Example #6
Source File: DefaultDrmSessionManager.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * @param uuid The UUID of the drm scheme.
 * @param exoMediaDrm An underlying {@link ExoMediaDrm} for use by the manager.
 * @param callback Performs key and provisioning requests.
 * @param keyRequestParameters An optional map of parameters to pass as the last argument to
 *     {@link ExoMediaDrm#getKeyRequest(byte[], List, int, HashMap)}. May be null.
 * @param multiSession A boolean that specify whether multiple key session support is enabled.
 *     Default is false.
 * @param initialDrmRequestRetryCount The number of times to retry for initial provisioning and
 *     key request before reporting error.
 * @deprecated Use {@link Builder} instead.
 */
@Deprecated
public DefaultDrmSessionManager(
    UUID uuid,
    ExoMediaDrm<T> exoMediaDrm,
    MediaDrmCallback callback,
    @Nullable HashMap<String, String> keyRequestParameters,
    boolean multiSession,
    int initialDrmRequestRetryCount) {
  this(
      uuid,
      new ExoMediaDrm.AppManagedProvider<>(exoMediaDrm),
      callback,
      keyRequestParameters == null ? new HashMap<>() : keyRequestParameters,
      multiSession,
      /* useDrmSessionsForClearContentTrackTypes= */ new int[0],
      /* playClearSamplesWithoutKeys= */ false,
      new DefaultLoadErrorHandlingPolicy(initialDrmRequestRetryCount));
}
 
Example #7
Source File: ExtractorMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * @param uri The {@link Uri} of the media stream.
 * @param dataSourceFactory A factory for {@link DataSource}s to read the media.
 * @param extractorsFactory A factory for {@link Extractor}s to process the media stream. If the
 *     possible formats are known, pass a factory that instantiates extractors for those formats.
 *     Otherwise, pass a {@link DefaultExtractorsFactory} to use default extractors.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param customCacheKey A custom key that uniquely identifies the original stream. Used for cache
 *     indexing. May be null.
 * @param continueLoadingCheckIntervalBytes The number of bytes that should be loaded between each
 *     invocation of {@link MediaPeriod.Callback#onContinueLoadingRequested(SequenceableLoader)}.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public ExtractorMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    ExtractorsFactory extractorsFactory,
    @Nullable Handler eventHandler,
    @Nullable EventListener eventListener,
    @Nullable String customCacheKey,
    int continueLoadingCheckIntervalBytes) {
  this(
      uri,
      dataSourceFactory,
      extractorsFactory,
      new DefaultLoadErrorHandlingPolicy(),
      customCacheKey,
      continueLoadingCheckIntervalBytes,
      /* tag= */ null);
  if (eventListener != null && eventHandler != null) {
    addEventListener(eventHandler, new EventListenerWrapper(eventListener));
  }
}
 
Example #8
Source File: SsMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance to play a given {@link SsManifest}, which must not be live.
 *
 * @param manifest The manifest. {@link SsManifest#isLive} must be false.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public SsMediaSource(
    SsManifest manifest,
    SsChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount,
    @Nullable Handler eventHandler,
    @Nullable MediaSourceEventListener eventListener) {
  this(
      manifest,
      /* manifestUri= */ null,
      /* manifestDataSourceFactory= */ null,
      /* manifestParser= */ null,
      chunkSourceFactory,
      new DefaultCompositeSequenceableLoaderFactory(),
      DrmSessionManager.getDummyDrmSessionManager(),
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      DEFAULT_LIVE_PRESENTATION_DELAY_MS,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, eventListener);
  }
}
 
Example #9
Source File: SsMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be live or
 * on-demand.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public SsMediaSource(
    Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory,
    SsChunkSource.Factory chunkSourceFactory,
    @Nullable Handler eventHandler,
    @Nullable MediaSourceEventListener eventListener) {
  this(
      manifestUri,
      manifestDataSourceFactory,
      chunkSourceFactory,
      DefaultLoadErrorHandlingPolicy.DEFAULT_MIN_LOADABLE_RETRY_COUNT,
      DEFAULT_LIVE_PRESENTATION_DELAY_MS,
      eventHandler,
      eventListener);
}
 
Example #10
Source File: SsMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be live or
 * on-demand.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param manifestParser A parser for loaded manifest data.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param livePresentationDelayMs For live playbacks, the duration in milliseconds by which the
 *     default start position should precede the end of the live window.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public SsMediaSource(
    Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory,
    ParsingLoadable.Parser<? extends SsManifest> manifestParser,
    SsChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount,
    long livePresentationDelayMs,
    @Nullable Handler eventHandler,
    @Nullable MediaSourceEventListener eventListener) {
  this(
      /* manifest= */ null,
      manifestUri,
      manifestDataSourceFactory,
      manifestParser,
      chunkSourceFactory,
      new DefaultCompositeSequenceableLoaderFactory(),
      DrmSessionManager.getDummyDrmSessionManager(),
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      livePresentationDelayMs,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, eventListener);
  }
}
 
Example #11
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 #12
Source File: SingleSampleMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param uri The {@link Uri} of the media stream.
 * @param dataSourceFactory The factory from which the {@link DataSource} to read the media will
 *     be obtained.
 * @param format The {@link Format} associated with the output track.
 * @param durationUs The duration of the media stream in microseconds.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public SingleSampleMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    Format format,
    long durationUs,
    int minLoadableRetryCount) {
  this(
      uri,
      dataSourceFactory,
      format,
      durationUs,
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      /* treatLoadErrorsAsEndOfStream= */ false,
      /* tag= */ null);
}
 
Example #13
Source File: SingleSampleMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param uri The {@link Uri} of the media stream.
 * @param dataSourceFactory The factory from which the {@link DataSource} to read the media will
 *     be obtained.
 * @param format The {@link Format} associated with the output track.
 * @param durationUs The duration of the media stream in microseconds.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param eventSourceId An identifier that gets passed to {@code eventListener} methods.
 * @param treatLoadErrorsAsEndOfStream If true, load errors will not be propagated by sample
 *     streams, treating them as ended instead. If false, load errors will be propagated normally
 *     by {@link SampleStream#maybeThrowError()}.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public SingleSampleMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    Format format,
    long durationUs,
    int minLoadableRetryCount,
    Handler eventHandler,
    EventListener eventListener,
    int eventSourceId,
    boolean treatLoadErrorsAsEndOfStream) {
  this(
      uri,
      dataSourceFactory,
      format,
      durationUs,
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      treatLoadErrorsAsEndOfStream,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, new EventListenerWrapper(eventListener, eventSourceId));
  }
}
 
Example #14
Source File: DashMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance to play a given {@link DashManifest}, which must be static.
 *
 * @param manifest The manifest. {@link DashManifest#dynamic} must be false.
 * @param chunkSourceFactory A factory for {@link DashChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public DashMediaSource(
    DashManifest manifest,
    DashChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount,
    Handler eventHandler,
    MediaSourceEventListener eventListener) {
  this(
      manifest,
      /* manifestUri= */ null,
      /* manifestDataSourceFactory= */ null,
      /* manifestParser= */ null,
      chunkSourceFactory,
      new DefaultCompositeSequenceableLoaderFactory(),
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      DEFAULT_LIVE_PRESENTATION_DELAY_MS,
      /* livePresentationDelayOverridesManifest= */ false,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, eventListener);
  }
}
 
Example #15
Source File: DashMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be dynamic or
 * static.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param chunkSourceFactory A factory for {@link DashChunkSource} instances.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public DashMediaSource(
    Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory,
    DashChunkSource.Factory chunkSourceFactory,
    Handler eventHandler,
    MediaSourceEventListener eventListener) {
  this(
      manifestUri,
      manifestDataSourceFactory,
      chunkSourceFactory,
      DefaultLoadErrorHandlingPolicy.DEFAULT_MIN_LOADABLE_RETRY_COUNT,
      DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS,
      eventHandler,
      eventListener);
}
 
Example #16
Source File: SsMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance to play a given {@link SsManifest}, which must not be live.
 *
 * @param manifest The manifest. {@link SsManifest#isLive} must be false.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public SsMediaSource(
    SsManifest manifest,
    SsChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount,
    Handler eventHandler,
    MediaSourceEventListener eventListener) {
  this(
      manifest,
      /* manifestUri= */ null,
      /* manifestDataSourceFactory= */ null,
      /* manifestParser= */ null,
      chunkSourceFactory,
      new DefaultCompositeSequenceableLoaderFactory(),
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      DEFAULT_LIVE_PRESENTATION_DELAY_MS,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, eventListener);
  }
}
 
Example #17
Source File: SsMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be live or
 * on-demand.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public SsMediaSource(
    Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory,
    SsChunkSource.Factory chunkSourceFactory,
    Handler eventHandler,
    MediaSourceEventListener eventListener) {
  this(
      manifestUri,
      manifestDataSourceFactory,
      chunkSourceFactory,
      DefaultLoadErrorHandlingPolicy.DEFAULT_MIN_LOADABLE_RETRY_COUNT,
      DEFAULT_LIVE_PRESENTATION_DELAY_MS,
      eventHandler,
      eventListener);
}
 
Example #18
Source File: SsMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be live or
 * on-demand.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param manifestParser A parser for loaded manifest data.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param livePresentationDelayMs For live playbacks, the duration in milliseconds by which the
 *     default start position should precede the end of the live window.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public SsMediaSource(
    Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory,
    ParsingLoadable.Parser<? extends SsManifest> manifestParser,
    SsChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount,
    long livePresentationDelayMs,
    Handler eventHandler,
    MediaSourceEventListener eventListener) {
  this(
      /* manifest= */ null,
      manifestUri,
      manifestDataSourceFactory,
      manifestParser,
      chunkSourceFactory,
      new DefaultCompositeSequenceableLoaderFactory(),
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      livePresentationDelayMs,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, eventListener);
  }
}
 
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: SingleSampleMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param uri The {@link Uri} of the media stream.
 * @param dataSourceFactory The factory from which the {@link DataSource} to read the media will
 *     be obtained.
 * @param format The {@link Format} associated with the output track.
 * @param durationUs The duration of the media stream in microseconds.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public SingleSampleMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    Format format,
    long durationUs,
    int minLoadableRetryCount) {
  this(
      uri,
      dataSourceFactory,
      format,
      durationUs,
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      /* treatLoadErrorsAsEndOfStream= */ false,
      /* tag= */ null);
}
 
Example #21
Source File: SingleSampleMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param uri The {@link Uri} of the media stream.
 * @param dataSourceFactory The factory from which the {@link DataSource} to read the media will
 *     be obtained.
 * @param format The {@link Format} associated with the output track.
 * @param durationUs The duration of the media stream in microseconds.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param eventSourceId An identifier that gets passed to {@code eventListener} methods.
 * @param treatLoadErrorsAsEndOfStream If true, load errors will not be propagated by sample
 *     streams, treating them as ended instead. If false, load errors will be propagated normally
 *     by {@link SampleStream#maybeThrowError()}.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public SingleSampleMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    Format format,
    long durationUs,
    int minLoadableRetryCount,
    Handler eventHandler,
    EventListener eventListener,
    int eventSourceId,
    boolean treatLoadErrorsAsEndOfStream) {
  this(
      uri,
      dataSourceFactory,
      format,
      durationUs,
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      treatLoadErrorsAsEndOfStream,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, new EventListenerWrapper(eventListener, eventSourceId));
  }
}
 
Example #22
Source File: ExtractorMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param uri The {@link Uri} of the media stream.
 * @param dataSourceFactory A factory for {@link DataSource}s to read the media.
 * @param extractorsFactory A factory for {@link Extractor}s to process the media stream. If the
 *     possible formats are known, pass a factory that instantiates extractors for those formats.
 *     Otherwise, pass a {@link DefaultExtractorsFactory} to use default extractors.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param customCacheKey A custom key that uniquely identifies the original stream. Used for cache
 *     indexing. May be null.
 * @param continueLoadingCheckIntervalBytes The number of bytes that should be loaded between each
 *     invocation of {@link MediaPeriod.Callback#onContinueLoadingRequested(SequenceableLoader)}.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public ExtractorMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    ExtractorsFactory extractorsFactory,
    Handler eventHandler,
    EventListener eventListener,
    String customCacheKey,
    int continueLoadingCheckIntervalBytes) {
  this(
      uri,
      dataSourceFactory,
      extractorsFactory,
      new DefaultLoadErrorHandlingPolicy(),
      customCacheKey,
      continueLoadingCheckIntervalBytes,
      /* tag= */ null);
  if (eventListener != null && eventHandler != null) {
    addEventListener(eventHandler, new EventListenerWrapper(eventListener));
  }
}
 
Example #23
Source File: DashMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance to play a given {@link DashManifest}, which must be static.
 *
 * @param manifest The manifest. {@link DashManifest#dynamic} must be false.
 * @param chunkSourceFactory A factory for {@link DashChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public DashMediaSource(
    DashManifest manifest,
    DashChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount,
    Handler eventHandler,
    MediaSourceEventListener eventListener) {
  this(
      manifest,
      /* manifestUri= */ null,
      /* manifestDataSourceFactory= */ null,
      /* manifestParser= */ null,
      chunkSourceFactory,
      new DefaultCompositeSequenceableLoaderFactory(),
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      DEFAULT_LIVE_PRESENTATION_DELAY_MS,
      /* livePresentationDelayOverridesManifest= */ false,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, eventListener);
  }
}
 
Example #24
Source File: DashMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be dynamic or
 * static.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param chunkSourceFactory A factory for {@link DashChunkSource} instances.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public DashMediaSource(
    Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory,
    DashChunkSource.Factory chunkSourceFactory,
    Handler eventHandler,
    MediaSourceEventListener eventListener) {
  this(
      manifestUri,
      manifestDataSourceFactory,
      chunkSourceFactory,
      DefaultLoadErrorHandlingPolicy.DEFAULT_MIN_LOADABLE_RETRY_COUNT,
      DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS,
      eventHandler,
      eventListener);
}
 
Example #25
Source File: SsMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance to play a given {@link SsManifest}, which must not be live.
 *
 * @param manifest The manifest. {@link SsManifest#isLive} must be false.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public SsMediaSource(
    SsManifest manifest,
    SsChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount,
    Handler eventHandler,
    MediaSourceEventListener eventListener) {
  this(
      manifest,
      /* manifestUri= */ null,
      /* manifestDataSourceFactory= */ null,
      /* manifestParser= */ null,
      chunkSourceFactory,
      new DefaultCompositeSequenceableLoaderFactory(),
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      DEFAULT_LIVE_PRESENTATION_DELAY_MS,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, eventListener);
  }
}
 
Example #26
Source File: SsMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be live or
 * on-demand.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public SsMediaSource(
    Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory,
    SsChunkSource.Factory chunkSourceFactory,
    Handler eventHandler,
    MediaSourceEventListener eventListener) {
  this(
      manifestUri,
      manifestDataSourceFactory,
      chunkSourceFactory,
      DefaultLoadErrorHandlingPolicy.DEFAULT_MIN_LOADABLE_RETRY_COUNT,
      DEFAULT_LIVE_PRESENTATION_DELAY_MS,
      eventHandler,
      eventListener);
}
 
Example #27
Source File: ExtractorMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param uri The {@link Uri} of the media stream.
 * @param dataSourceFactory A factory for {@link DataSource}s to read the media.
 * @param extractorsFactory A factory for {@link Extractor}s to process the media stream. If the
 *     possible formats are known, pass a factory that instantiates extractors for those formats.
 *     Otherwise, pass a {@link DefaultExtractorsFactory} to use default extractors.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param customCacheKey A custom key that uniquely identifies the original stream. Used for cache
 *     indexing. May be null.
 * @param continueLoadingCheckIntervalBytes The number of bytes that should be loaded between each
 *     invocation of {@link MediaPeriod.Callback#onContinueLoadingRequested(SequenceableLoader)}.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public ExtractorMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    ExtractorsFactory extractorsFactory,
    Handler eventHandler,
    EventListener eventListener,
    String customCacheKey,
    int continueLoadingCheckIntervalBytes) {
  this(
      uri,
      dataSourceFactory,
      extractorsFactory,
      new DefaultLoadErrorHandlingPolicy(),
      customCacheKey,
      continueLoadingCheckIntervalBytes,
      /* tag= */ null);
  if (eventListener != null && eventHandler != null) {
    addEventListener(eventHandler, new EventListenerWrapper(eventListener));
  }
}
 
Example #28
Source File: SingleSampleMediaSource.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param uri The {@link Uri} of the media stream.
 * @param dataSourceFactory The factory from which the {@link DataSource} to read the media will
 *     be obtained.
 * @param format The {@link Format} associated with the output track.
 * @param durationUs The duration of the media stream in microseconds.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public SingleSampleMediaSource(
    Uri uri, DataSource.Factory dataSourceFactory, Format format, long durationUs) {
  this(
      uri,
      dataSourceFactory,
      format,
      durationUs,
      DefaultLoadErrorHandlingPolicy.DEFAULT_MIN_LOADABLE_RETRY_COUNT);
}
 
Example #29
Source File: DashMediaSource.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be dynamic or
 * static.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param manifestParser A parser for loaded manifest data.
 * @param chunkSourceFactory A factory for {@link DashChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param livePresentationDelayMs For live playbacks, the duration in milliseconds by which the
 *     default start position should precede the end of the live window. Use {@link
 *     #DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS} to use the value specified by the
 *     manifest, if present.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public DashMediaSource(
    Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory,
    ParsingLoadable.Parser<? extends DashManifest> manifestParser,
    DashChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount,
    long livePresentationDelayMs,
    @Nullable Handler eventHandler,
    @Nullable MediaSourceEventListener eventListener) {
  this(
      /* manifest= */ null,
      manifestUri,
      manifestDataSourceFactory,
      manifestParser,
      chunkSourceFactory,
      new DefaultCompositeSequenceableLoaderFactory(),
      DrmSessionManager.getDummyDrmSessionManager(),
      new DefaultLoadErrorHandlingPolicy(minLoadableRetryCount),
      livePresentationDelayMs == DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS
          ? DEFAULT_LIVE_PRESENTATION_DELAY_MS
          : livePresentationDelayMs,
      livePresentationDelayMs != DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, eventListener);
  }
}
 
Example #30
Source File: ProgressiveMediaSource.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new factory for {@link ProgressiveMediaSource}s.
 *
 * @param dataSourceFactory A factory for {@link DataSource}s to read the media.
 * @param extractorsFactory A factory for extractors used to extract media from its container.
 */
public Factory(DataSource.Factory dataSourceFactory, ExtractorsFactory extractorsFactory) {
  this.dataSourceFactory = dataSourceFactory;
  this.extractorsFactory = extractorsFactory;
  loadErrorHandlingPolicy = new DefaultLoadErrorHandlingPolicy();
  continueLoadingCheckIntervalBytes = DEFAULT_LOADING_CHECK_INTERVAL_BYTES;
}