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

The following examples show how to use com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy. 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: ProgressiveMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
ProgressiveMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    ExtractorsFactory extractorsFactory,
    LoadErrorHandlingPolicy loadableLoadErrorHandlingPolicy,
    @Nullable String customCacheKey,
    int continueLoadingCheckIntervalBytes,
    @Nullable Object tag) {
  this.uri = uri;
  this.dataSourceFactory = dataSourceFactory;
  this.extractorsFactory = extractorsFactory;
  this.loadableLoadErrorHandlingPolicy = loadableLoadErrorHandlingPolicy;
  this.customCacheKey = customCacheKey;
  this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes;
  this.timelineDurationUs = C.TIME_UNSET;
  this.tag = tag;
}
 
Example #2
Source File: DefaultDrmSessionManager.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("nullness:initialization.fields.uninitialized")
private DefaultDrmSessionManager(
    UUID uuid,
    ExoMediaDrm.Provider<T> exoMediaDrmProvider,
    MediaDrmCallback callback,
    HashMap<String, String> keyRequestParameters,
    boolean multiSession,
    int[] useDrmSessionsForClearContentTrackTypes,
    boolean playClearSamplesWithoutKeys,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
  Assertions.checkNotNull(uuid);
  Assertions.checkArgument(!C.COMMON_PSSH_UUID.equals(uuid), "Use C.CLEARKEY_UUID instead");
  this.uuid = uuid;
  this.exoMediaDrmProvider = exoMediaDrmProvider;
  this.callback = callback;
  this.keyRequestParameters = keyRequestParameters;
  this.eventDispatcher = new EventDispatcher<>();
  this.multiSession = multiSession;
  this.useDrmSessionsForClearContentTrackTypes = useDrmSessionsForClearContentTrackTypes;
  this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  provisioningManagerImpl = new ProvisioningManagerImpl();
  mode = MODE_PLAYBACK;
  sessions = new ArrayList<>();
  provisioningSessions = new ArrayList<>();
}
 
Example #3
Source File: ProgressiveMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
ProgressiveMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    ExtractorsFactory extractorsFactory,
    DrmSessionManager<?> drmSessionManager,
    LoadErrorHandlingPolicy loadableLoadErrorHandlingPolicy,
    @Nullable String customCacheKey,
    int continueLoadingCheckIntervalBytes,
    @Nullable Object tag) {
  this.uri = uri;
  this.dataSourceFactory = dataSourceFactory;
  this.extractorsFactory = extractorsFactory;
  this.drmSessionManager = drmSessionManager;
  this.loadableLoadErrorHandlingPolicy = loadableLoadErrorHandlingPolicy;
  this.customCacheKey = customCacheKey;
  this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes;
  this.timelineDurationUs = C.TIME_UNSET;
  this.tag = tag;
}
 
Example #4
Source File: ExtractorMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private ExtractorMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    ExtractorsFactory extractorsFactory,
    LoadErrorHandlingPolicy loadableLoadErrorHandlingPolicy,
    @Nullable String customCacheKey,
    int continueLoadingCheckIntervalBytes,
    @Nullable Object tag) {
  progressiveMediaSource =
      new ProgressiveMediaSource(
          uri,
          dataSourceFactory,
          extractorsFactory,
          loadableLoadErrorHandlingPolicy,
          customCacheKey,
          continueLoadingCheckIntervalBytes,
          tag);
}
 
Example #5
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 #6
Source File: ProgressiveMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
ProgressiveMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    ExtractorsFactory extractorsFactory,
    LoadErrorHandlingPolicy loadableLoadErrorHandlingPolicy,
    @Nullable String customCacheKey,
    int continueLoadingCheckIntervalBytes,
    @Nullable Object tag) {
  this.uri = uri;
  this.dataSourceFactory = dataSourceFactory;
  this.extractorsFactory = extractorsFactory;
  this.loadableLoadErrorHandlingPolicy = loadableLoadErrorHandlingPolicy;
  this.customCacheKey = customCacheKey;
  this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes;
  this.timelineDurationUs = C.TIME_UNSET;
  this.tag = tag;
}
 
Example #7
Source File: HlsMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private HlsMediaSource(
    Uri manifestUri,
    HlsDataSourceFactory dataSourceFactory,
    HlsExtractorFactory extractorFactory,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    DrmSessionManager<?> drmSessionManager,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    HlsPlaylistTracker playlistTracker,
    boolean allowChunklessPreparation,
    @MetadataType int metadataType,
    boolean useSessionKeys,
    @Nullable Object tag) {
  this.manifestUri = manifestUri;
  this.dataSourceFactory = dataSourceFactory;
  this.extractorFactory = extractorFactory;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  this.drmSessionManager = drmSessionManager;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.playlistTracker = playlistTracker;
  this.allowChunklessPreparation = allowChunklessPreparation;
  this.metadataType = metadataType;
  this.useSessionKeys = useSessionKeys;
  this.tag = tag;
}
 
Example #8
Source File: SingleSampleMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private SingleSampleMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    Format format,
    long durationUs,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    boolean treatLoadErrorsAsEndOfStream,
    @Nullable Object tag) {
  this.dataSourceFactory = dataSourceFactory;
  this.format = format;
  this.durationUs = durationUs;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream;
  this.tag = tag;
  dataSpec = new DataSpec(uri, DataSpec.FLAG_ALLOW_GZIP);
  timeline =
      new SinglePeriodTimeline(durationUs, /* isSeekable= */ true, /* isDynamic= */ false, tag);
}
 
Example #9
Source File: SingleSampleMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private SingleSampleMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    Format format,
    long durationUs,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    boolean treatLoadErrorsAsEndOfStream,
    @Nullable Object tag) {
  this.dataSourceFactory = dataSourceFactory;
  this.format = format;
  this.durationUs = durationUs;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream;
  this.tag = tag;
  dataSpec = new DataSpec(uri, DataSpec.FLAG_ALLOW_GZIP);
  timeline =
      new SinglePeriodTimeline(
          durationUs,
          /* isSeekable= */ true,
          /* isDynamic= */ false,
          /* isLive= */ false,
          /* manifest= */ null,
          tag);
}
 
Example #10
Source File: HlsMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private HlsMediaSource(
    Uri manifestUri,
    HlsDataSourceFactory dataSourceFactory,
    HlsExtractorFactory extractorFactory,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    HlsPlaylistTracker playlistTracker,
    boolean allowChunklessPreparation,
    @HlsMetadataType int metadataType,
    boolean useSessionKeys,
    @Nullable Object tag) {
  this.manifestUri = manifestUri;
  this.dataSourceFactory = dataSourceFactory;
  this.extractorFactory = extractorFactory;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.playlistTracker = playlistTracker;
  this.allowChunklessPreparation = allowChunklessPreparation;
  this.metadataType = metadataType;
  this.useSessionKeys = useSessionKeys;
  this.tag = tag;
}
 
Example #11
Source File: ExtractorMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private ExtractorMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    ExtractorsFactory extractorsFactory,
    LoadErrorHandlingPolicy loadableLoadErrorHandlingPolicy,
    @Nullable String customCacheKey,
    int continueLoadingCheckIntervalBytes,
    @Nullable Object tag) {
  progressiveMediaSource =
      new ProgressiveMediaSource(
          uri,
          dataSourceFactory,
          extractorsFactory,
          DrmSessionManager.getDummyDrmSessionManager(),
          loadableLoadErrorHandlingPolicy,
          customCacheKey,
          continueLoadingCheckIntervalBytes,
          tag);
}
 
Example #12
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 #13
Source File: SsMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private SsMediaSource(
    @Nullable SsManifest manifest,
    @Nullable Uri manifestUri,
    @Nullable DataSource.Factory manifestDataSourceFactory,
    @Nullable ParsingLoadable.Parser<? extends SsManifest> manifestParser,
    SsChunkSource.Factory chunkSourceFactory,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    DrmSessionManager<?> drmSessionManager,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    long livePresentationDelayMs,
    @Nullable Object tag) {
  Assertions.checkState(manifest == null || !manifest.isLive);
  this.manifest = manifest;
  this.manifestUri = manifestUri == null ? null : SsUtil.fixManifestUri(manifestUri);
  this.manifestDataSourceFactory = manifestDataSourceFactory;
  this.manifestParser = manifestParser;
  this.chunkSourceFactory = chunkSourceFactory;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  this.drmSessionManager = drmSessionManager;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.livePresentationDelayMs = livePresentationDelayMs;
  this.manifestEventDispatcher = createEventDispatcher(/* mediaPeriodId= */ null);
  this.tag = tag;
  sideloadedManifest = manifest != null;
  mediaPeriods = new ArrayList<>();
}
 
Example #14
Source File: SsMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private SsMediaSource(
    SsManifest manifest,
    Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory,
    ParsingLoadable.Parser<? extends SsManifest> manifestParser,
    SsChunkSource.Factory chunkSourceFactory,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    long livePresentationDelayMs,
    @Nullable Object tag) {
  Assertions.checkState(manifest == null || !manifest.isLive);
  this.manifest = manifest;
  this.manifestUri = manifestUri == null ? null : SsUtil.fixManifestUri(manifestUri);
  this.manifestDataSourceFactory = manifestDataSourceFactory;
  this.manifestParser = manifestParser;
  this.chunkSourceFactory = chunkSourceFactory;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.livePresentationDelayMs = livePresentationDelayMs;
  this.manifestEventDispatcher = createEventDispatcher(/* mediaPeriodId= */ null);
  this.tag = tag;
  sideloadedManifest = manifest != null;
  mediaPeriods = new ArrayList<>();
}
 
Example #15
Source File: HlsMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private HlsMediaSource(
    Uri manifestUri,
    HlsDataSourceFactory dataSourceFactory,
    HlsExtractorFactory extractorFactory,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    LoadErrorHandlingPolicy<Chunk> chunkLoadErrorHandlingPolicy,
    int minLoadableRetryCount,
    HlsPlaylistTracker playlistTracker,
    boolean allowChunklessPreparation,
    @Nullable Object tag) {
  this.manifestUri = manifestUri;
  this.dataSourceFactory = dataSourceFactory;
  this.extractorFactory = extractorFactory;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  this.chunkLoadErrorHandlingPolicy = chunkLoadErrorHandlingPolicy;
  this.minLoadableRetryCount = minLoadableRetryCount;
  this.playlistTracker = playlistTracker;
  this.allowChunklessPreparation = allowChunklessPreparation;
  this.tag = tag;
}
 
Example #16
Source File: HlsMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private HlsMediaSource(
    Uri manifestUri,
    HlsDataSourceFactory dataSourceFactory,
    HlsExtractorFactory extractorFactory,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    LoadErrorHandlingPolicy<Chunk> chunkLoadErrorHandlingPolicy,
    int minLoadableRetryCount,
    HlsPlaylistTracker playlistTracker,
    boolean allowChunklessPreparation,
    @Nullable Object tag) {
  this.manifestUri = manifestUri;
  this.dataSourceFactory = dataSourceFactory;
  this.extractorFactory = extractorFactory;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  this.chunkLoadErrorHandlingPolicy = chunkLoadErrorHandlingPolicy;
  this.minLoadableRetryCount = minLoadableRetryCount;
  this.playlistTracker = playlistTracker;
  this.allowChunklessPreparation = allowChunklessPreparation;
  this.tag = tag;
}
 
Example #17
Source File: ExtractorMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private ExtractorMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    ExtractorsFactory extractorsFactory,
    LoadErrorHandlingPolicy loadableLoadErrorHandlingPolicy,
    @Nullable String customCacheKey,
    int continueLoadingCheckIntervalBytes,
    @Nullable Object tag) {
  progressiveMediaSource =
      new ProgressiveMediaSource(
          uri,
          dataSourceFactory,
          extractorsFactory,
          loadableLoadErrorHandlingPolicy,
          customCacheKey,
          continueLoadingCheckIntervalBytes,
          tag);
}
 
Example #18
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 #19
Source File: SingleSampleMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private SingleSampleMediaSource(
    Uri uri,
    DataSource.Factory dataSourceFactory,
    Format format,
    long durationUs,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    boolean treatLoadErrorsAsEndOfStream,
    @Nullable Object tag) {
  this.dataSourceFactory = dataSourceFactory;
  this.format = format;
  this.durationUs = durationUs;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream;
  this.tag = tag;
  dataSpec = new DataSpec(uri, DataSpec.FLAG_ALLOW_GZIP);
  timeline =
      new SinglePeriodTimeline(durationUs, /* isSeekable= */ true, /* isDynamic= */ false, tag);
}
 
Example #20
Source File: SsMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private SsMediaSource(
    SsManifest manifest,
    Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory,
    ParsingLoadable.Parser<? extends SsManifest> manifestParser,
    SsChunkSource.Factory chunkSourceFactory,
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    long livePresentationDelayMs,
    @Nullable Object tag) {
  Assertions.checkState(manifest == null || !manifest.isLive);
  this.manifest = manifest;
  this.manifestUri = manifestUri == null ? null : SsUtil.fixManifestUri(manifestUri);
  this.manifestDataSourceFactory = manifestDataSourceFactory;
  this.manifestParser = manifestParser;
  this.chunkSourceFactory = chunkSourceFactory;
  this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.livePresentationDelayMs = livePresentationDelayMs;
  this.manifestEventDispatcher = createEventDispatcher(/* mediaPeriodId= */ null);
  this.tag = tag;
  sideloadedManifest = manifest != null;
  mediaPeriods = new ArrayList<>();
}
 
Example #21
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 #22
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 #23
Source File: DefaultHlsPlaylistTracker.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an instance.
 *
 * @param dataSourceFactory A factory for {@link DataSource} instances.
 * @param loadErrorHandlingPolicy The {@link LoadErrorHandlingPolicy}.
 * @param playlistParserFactory An {@link HlsPlaylistParserFactory}.
 * @param playlistStuckTargetDurationCoefficient A coefficient to apply to the target duration of
 *     media playlists in order to determine that a non-changing playlist is stuck. Once a
 *     playlist is deemed stuck, a {@link PlaylistStuckException} is thrown via {@link
 *     #maybeThrowPlaylistRefreshError(Uri)}.
 */
public DefaultHlsPlaylistTracker(
    HlsDataSourceFactory dataSourceFactory,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    HlsPlaylistParserFactory playlistParserFactory,
    double playlistStuckTargetDurationCoefficient) {
  this.dataSourceFactory = dataSourceFactory;
  this.playlistParserFactory = playlistParserFactory;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.playlistStuckTargetDurationCoefficient = playlistStuckTargetDurationCoefficient;
  listeners = new ArrayList<>();
  playlistBundles = new HashMap<>();
  initialStartTimeUs = C.TIME_UNSET;
}
 
Example #24
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 #25
Source File: DefaultHlsPlaylistTracker.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an instance.
 *
 * @param dataSourceFactory A factory for {@link DataSource} instances.
 * @param loadErrorHandlingPolicy The {@link LoadErrorHandlingPolicy}.
 * @param playlistParserFactory An {@link HlsPlaylistParserFactory}.
 */
public DefaultHlsPlaylistTracker(
    HlsDataSourceFactory dataSourceFactory,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    HlsPlaylistParserFactory playlistParserFactory) {
  this(
      dataSourceFactory,
      loadErrorHandlingPolicy,
      playlistParserFactory,
      DEFAULT_PLAYLIST_STUCK_TARGET_DURATION_COEFFICIENT);
}
 
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: DashMediaPeriod.java    From Telegram 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 #28
Source File: HlsMediaSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param manifestUri The {@link Uri} of the HLS manifest.
 * @param dataSourceFactory An {@link HlsDataSourceFactory} for {@link DataSource}s for manifests,
 *     segments and keys.
 * @param extractorFactory An {@link HlsExtractorFactory} for {@link Extractor}s for the segments.
 * @param minLoadableRetryCount The minimum number of times loads must be retried before errors
 *     are propagated.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A {@link MediaSourceEventListener}. May be null if delivery of events is
 *     not required.
 * @param playlistParser A {@link ParsingLoadable.Parser} for HLS playlists.
 * @deprecated Use {@link Factory} instead.
 */
@Deprecated
public HlsMediaSource(
    Uri manifestUri,
    HlsDataSourceFactory dataSourceFactory,
    HlsExtractorFactory extractorFactory,
    int minLoadableRetryCount,
    Handler eventHandler,
    MediaSourceEventListener eventListener,
    ParsingLoadable.Parser<HlsPlaylist> playlistParser) {
  this(
      manifestUri,
      dataSourceFactory,
      extractorFactory,
      new DefaultCompositeSequenceableLoaderFactory(),
      LoadErrorHandlingPolicy.getDefault(),
      minLoadableRetryCount,
      new DefaultHlsPlaylistTracker(
          dataSourceFactory,
          LoadErrorHandlingPolicy.getDefault(),
          minLoadableRetryCount,
          playlistParser),
      /* allowChunklessPreparation= */ false,
      /* tag= */ null);
  if (eventHandler != null && eventListener != null) {
    addEventListener(eventHandler, eventListener);
  }
}
 
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: DefaultHlsPlaylistTracker.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance.
 *
 * @param dataSourceFactory A factory for {@link DataSource} instances.
 * @param loadErrorHandlingPolicy The {@link LoadErrorHandlingPolicy}.
 * @param playlistParserFactory An {@link HlsPlaylistParserFactory}.
 * @param playlistStuckTargetDurationCoefficient A coefficient to apply to the target duration of
 *     media playlists in order to determine that a non-changing playlist is stuck. Once a
 *     playlist is deemed stuck, a {@link PlaylistStuckException} is thrown via {@link
 *     #maybeThrowPlaylistRefreshError(Uri)}.
 */
public DefaultHlsPlaylistTracker(
    HlsDataSourceFactory dataSourceFactory,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    HlsPlaylistParserFactory playlistParserFactory,
    double playlistStuckTargetDurationCoefficient) {
  this.dataSourceFactory = dataSourceFactory;
  this.playlistParserFactory = playlistParserFactory;
  this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
  this.playlistStuckTargetDurationCoefficient = playlistStuckTargetDurationCoefficient;
  listeners = new ArrayList<>();
  playlistBundles = new HashMap<>();
  initialStartTimeUs = C.TIME_UNSET;
}