Search in sources :

Example 1 with LoadEventInfo

use of com.google.android.exoplayer2.source.LoadEventInfo in project ExoPlayer by google.

the class DefaultAnalyticsCollector method onLoadCanceled.

@Override
public final void onLoadCanceled(int windowIndex, @Nullable MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {
    EventTime eventTime = generateMediaPeriodEventTime(windowIndex, mediaPeriodId);
    sendEvent(eventTime, AnalyticsListener.EVENT_LOAD_CANCELED, listener -> listener.onLoadCanceled(eventTime, loadEventInfo, mediaLoadData));
}
Also used : EventTime(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)

Example 2 with LoadEventInfo

use of com.google.android.exoplayer2.source.LoadEventInfo in project ExoPlayer by google.

the class DefaultAnalyticsCollector method onLoadStarted.

// MediaSourceEventListener implementation.
@Override
public final void onLoadStarted(int windowIndex, @Nullable MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {
    EventTime eventTime = generateMediaPeriodEventTime(windowIndex, mediaPeriodId);
    sendEvent(eventTime, AnalyticsListener.EVENT_LOAD_STARTED, listener -> listener.onLoadStarted(eventTime, loadEventInfo, mediaLoadData));
}
Also used : EventTime(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)

Example 3 with LoadEventInfo

use of com.google.android.exoplayer2.source.LoadEventInfo in project ExoPlayer by google.

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(com.google.android.exoplayer2.upstream.StatsDataSource)

Example 4 with LoadEventInfo

use of com.google.android.exoplayer2.source.LoadEventInfo in project ExoPlayer by google.

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(com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy.LoadErrorInfo) StatsDataSource(com.google.android.exoplayer2.upstream.StatsDataSource) LoadErrorAction(com.google.android.exoplayer2.upstream.Loader.LoadErrorAction)

Example 5 with LoadEventInfo

use of com.google.android.exoplayer2.source.LoadEventInfo in project ExoPlayer by google.

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(com.google.android.exoplayer2.upstream.StatsDataSource)

Aggregations

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