Search in sources :

Example 26 with LoadEventInfo

use of androidx.media3.exoplayer.source.LoadEventInfo in project media by androidx.

the class DashMediaSource method onLoadCanceled.

/* package */
void onLoadCanceled(ParsingLoadable<?> loadable, long elapsedRealtimeMs, long loadDurationMs) {
    LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded());
    loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    manifestEventDispatcher.loadCanceled(loadEventInfo, loadable.type);
}
Also used : LoadEventInfo(androidx.media3.exoplayer.source.LoadEventInfo)

Example 27 with LoadEventInfo

use of androidx.media3.exoplayer.source.LoadEventInfo in project media by androidx.

the class ProgressiveMediaPeriod method startLoading.

private void startLoading() {
    ExtractingLoadable loadable = new ExtractingLoadable(uri, dataSource, progressiveMediaExtractor, /* extractorOutput= */
    this, loadCondition);
    if (prepared) {
        Assertions.checkState(isPendingReset());
        if (durationUs != C.TIME_UNSET && pendingResetPositionUs > durationUs) {
            loadingFinished = true;
            pendingResetPositionUs = C.TIME_UNSET;
            return;
        }
        loadable.setLoadPosition(Assertions.checkNotNull(seekMap).getSeekPoints(pendingResetPositionUs).first.position, pendingResetPositionUs);
        for (SampleQueue sampleQueue : sampleQueues) {
            sampleQueue.setStartTimeUs(pendingResetPositionUs);
        }
        pendingResetPositionUs = C.TIME_UNSET;
    }
    extractedSamplesCountAtStartOfLoad = getExtractedSamplesCount();
    long elapsedRealtimeMs = loader.startLoading(loadable, this, loadErrorHandlingPolicy.getMinimumLoadableRetryCount(dataType));
    DataSpec dataSpec = loadable.dataSpec;
    mediaSourceEventDispatcher.loadStarted(new LoadEventInfo(loadable.loadTaskId, dataSpec, elapsedRealtimeMs), C.DATA_TYPE_MEDIA, C.TRACK_TYPE_UNKNOWN, /* trackFormat= */
    null, C.SELECTION_REASON_UNKNOWN, /* trackSelectionData= */
    null, /* mediaStartTimeUs= */
    loadable.seekTimeUs, durationUs);
}
Also used : DataSpec(androidx.media3.datasource.DataSpec)

Example 28 with LoadEventInfo

use of androidx.media3.exoplayer.source.LoadEventInfo in project media by androidx.

the class ProgressiveMediaPeriod method onLoadCompleted.

// Loader.Callback implementation.
@Override
public void onLoadCompleted(ExtractingLoadable loadable, long elapsedRealtimeMs, long loadDurationMs) {
    if (durationUs == C.TIME_UNSET && seekMap != null) {
        boolean isSeekable = seekMap.isSeekable();
        long largestQueuedTimestampUs = getLargestQueuedTimestampUs();
        durationUs = largestQueuedTimestampUs == Long.MIN_VALUE ? 0 : largestQueuedTimestampUs + DEFAULT_LAST_SAMPLE_DURATION_US;
        listener.onSourceInfoRefreshed(durationUs, isSeekable, isLive);
    }
    StatsDataSource dataSource = loadable.dataSource;
    LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, dataSource.getLastOpenedUri(), dataSource.getLastResponseHeaders(), elapsedRealtimeMs, loadDurationMs, dataSource.getBytesRead());
    loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    mediaSourceEventDispatcher.loadCompleted(loadEventInfo, C.DATA_TYPE_MEDIA, C.TRACK_TYPE_UNKNOWN, /* trackFormat= */
    null, C.SELECTION_REASON_UNKNOWN, /* trackSelectionData= */
    null, /* mediaStartTimeUs= */
    loadable.seekTimeUs, durationUs);
    copyLengthFromLoader(loadable);
    loadingFinished = true;
    Assertions.checkNotNull(callback).onContinueLoadingRequested(this);
}
Also used : StatsDataSource(androidx.media3.datasource.StatsDataSource)

Example 29 with LoadEventInfo

use of androidx.media3.exoplayer.source.LoadEventInfo in project media by androidx.

the class ProgressiveMediaPeriod method onLoadError.

@Override
public LoadErrorAction onLoadError(ExtractingLoadable loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error, int errorCount) {
    copyLengthFromLoader(loadable);
    StatsDataSource dataSource = loadable.dataSource;
    LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, dataSource.getLastOpenedUri(), dataSource.getLastResponseHeaders(), elapsedRealtimeMs, loadDurationMs, dataSource.getBytesRead());
    MediaLoadData mediaLoadData = new MediaLoadData(C.DATA_TYPE_MEDIA, C.TRACK_TYPE_UNKNOWN, /* trackFormat= */
    null, C.SELECTION_REASON_UNKNOWN, /* trackSelectionData= */
    null, /* mediaStartTimeMs= */
    Util.usToMs(loadable.seekTimeUs), Util.usToMs(durationUs));
    LoadErrorAction loadErrorAction;
    long retryDelayMs = loadErrorHandlingPolicy.getRetryDelayMsFor(new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount));
    if (retryDelayMs == C.TIME_UNSET) {
        loadErrorAction = Loader.DONT_RETRY_FATAL;
    } else /* the load should be retried */
    {
        int extractedSamplesCount = getExtractedSamplesCount();
        boolean madeProgress = extractedSamplesCount > extractedSamplesCountAtStartOfLoad;
        loadErrorAction = configureRetry(loadable, extractedSamplesCount) ? Loader.createRetryAction(/* resetErrorCount= */
        madeProgress, retryDelayMs) : Loader.DONT_RETRY;
    }
    boolean wasCanceled = !loadErrorAction.isRetry();
    mediaSourceEventDispatcher.loadError(loadEventInfo, C.DATA_TYPE_MEDIA, C.TRACK_TYPE_UNKNOWN, /* trackFormat= */
    null, C.SELECTION_REASON_UNKNOWN, /* trackSelectionData= */
    null, /* mediaStartTimeUs= */
    loadable.seekTimeUs, durationUs, error, wasCanceled);
    if (wasCanceled) {
        loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    }
    return loadErrorAction;
}
Also used : LoadErrorInfo(androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy.LoadErrorInfo) StatsDataSource(androidx.media3.datasource.StatsDataSource) LoadErrorAction(androidx.media3.exoplayer.upstream.Loader.LoadErrorAction)

Example 30 with LoadEventInfo

use of androidx.media3.exoplayer.source.LoadEventInfo in project media by androidx.

the class ProgressiveMediaPeriod method onLoadCanceled.

@Override
public void onLoadCanceled(ExtractingLoadable loadable, long elapsedRealtimeMs, long loadDurationMs, boolean released) {
    StatsDataSource dataSource = loadable.dataSource;
    LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, dataSource.getLastOpenedUri(), dataSource.getLastResponseHeaders(), elapsedRealtimeMs, loadDurationMs, dataSource.getBytesRead());
    loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    mediaSourceEventDispatcher.loadCanceled(loadEventInfo, C.DATA_TYPE_MEDIA, C.TRACK_TYPE_UNKNOWN, /* trackFormat= */
    null, C.SELECTION_REASON_UNKNOWN, /* trackSelectionData= */
    null, /* mediaStartTimeUs= */
    loadable.seekTimeUs, durationUs);
    if (!released) {
        copyLengthFromLoader(loadable);
        for (SampleQueue sampleQueue : sampleQueues) {
            sampleQueue.reset();
        }
        if (enabledTrackCount > 0) {
            Assertions.checkNotNull(callback).onContinueLoadingRequested(this);
        }
    }
}
Also used : StatsDataSource(androidx.media3.datasource.StatsDataSource)

Aggregations

LoadEventInfo (androidx.media3.exoplayer.source.LoadEventInfo)27 StatsDataSource (androidx.media3.datasource.StatsDataSource)7 MediaLoadData (androidx.media3.exoplayer.source.MediaLoadData)7 LoadErrorInfo (androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy.LoadErrorInfo)7 LoadErrorAction (androidx.media3.exoplayer.upstream.Loader.LoadErrorAction)6 Nullable (androidx.annotation.Nullable)4 EventTime (androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime)4 HttpDataSource (androidx.media3.datasource.HttpDataSource)2 SampleQueue (androidx.media3.exoplayer.source.SampleQueue)2 ParsingLoadable (androidx.media3.exoplayer.upstream.ParsingLoadable)2 Uri (android.net.Uri)1 Timeline (androidx.media3.common.Timeline)1 DataSource (androidx.media3.datasource.DataSource)1 DataSpec (androidx.media3.datasource.DataSpec)1 DashManifest (androidx.media3.exoplayer.dash.manifest.DashManifest)1 SsManifest (androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest)1 MediaPeriod (androidx.media3.exoplayer.source.MediaPeriod)1 MediaPeriodId (androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)1 MediaSourceEventListener (androidx.media3.exoplayer.source.MediaSourceEventListener)1 Chunk (androidx.media3.exoplayer.source.chunk.Chunk)1