Search in sources :

Example 11 with MediaLoadData

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

the class DefaultAnalyticsCollector method onLoadError.

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

Example 12 with MediaLoadData

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

the class DefaultAnalyticsCollector method onLoadCompleted.

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

Example 13 with MediaLoadData

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

the class HlsSampleStreamWrapper method onLoadError.

@Override
public LoadErrorAction onLoadError(Chunk loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error, int errorCount) {
    boolean isMediaChunk = isMediaChunk(loadable);
    if (isMediaChunk && !((HlsMediaChunk) loadable).isPublished() && error instanceof HttpDataSource.InvalidResponseCodeException) {
        int responseCode = ((HttpDataSource.InvalidResponseCodeException) error).responseCode;
        if (responseCode == 410 || responseCode == 404) {
            // streams with HTTP 410 (Gone) also.
            return Loader.RETRY;
        }
    }
    long bytesLoaded = loadable.bytesLoaded();
    boolean exclusionSucceeded = false;
    LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, bytesLoaded);
    MediaLoadData mediaLoadData = new MediaLoadData(loadable.type, trackType, loadable.trackFormat, loadable.trackSelectionReason, loadable.trackSelectionData, Util.usToMs(loadable.startTimeUs), Util.usToMs(loadable.endTimeUs));
    LoadErrorInfo loadErrorInfo = new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount);
    LoadErrorAction loadErrorAction;
    @Nullable LoadErrorHandlingPolicy.FallbackSelection fallbackSelection = loadErrorHandlingPolicy.getFallbackSelectionFor(createFallbackOptions(chunkSource.getTrackSelection()), loadErrorInfo);
    if (fallbackSelection != null && fallbackSelection.type == LoadErrorHandlingPolicy.FALLBACK_TYPE_TRACK) {
        exclusionSucceeded = chunkSource.maybeExcludeTrack(loadable, fallbackSelection.exclusionDurationMs);
    }
    if (exclusionSucceeded) {
        if (isMediaChunk && bytesLoaded == 0) {
            HlsMediaChunk removed = mediaChunks.remove(mediaChunks.size() - 1);
            Assertions.checkState(removed == loadable);
            if (mediaChunks.isEmpty()) {
                pendingResetPositionUs = lastSeekPositionUs;
            } else {
                Iterables.getLast(mediaChunks).invalidateExtractor();
            }
        }
        loadErrorAction = Loader.DONT_RETRY;
    } else /* did not exclude */
    {
        long retryDelayMs = loadErrorHandlingPolicy.getRetryDelayMsFor(loadErrorInfo);
        loadErrorAction = retryDelayMs != C.TIME_UNSET ? Loader.createRetryAction(/* resetErrorCount= */
        false, retryDelayMs) : Loader.DONT_RETRY_FATAL;
    }
    boolean wasCanceled = !loadErrorAction.isRetry();
    mediaSourceEventDispatcher.loadError(loadEventInfo, loadable.type, trackType, loadable.trackFormat, loadable.trackSelectionReason, loadable.trackSelectionData, loadable.startTimeUs, loadable.endTimeUs, error, wasCanceled);
    if (wasCanceled) {
        loadingChunk = null;
        loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    }
    if (exclusionSucceeded) {
        if (!prepared) {
            continueLoading(lastSeekPositionUs);
        } else {
            callback.onContinueLoadingRequested(this);
        }
    }
    return loadErrorAction;
}
Also used : MediaLoadData(com.google.android.exoplayer2.source.MediaLoadData) LoadErrorInfo(com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy.LoadErrorInfo) LoadErrorHandlingPolicy(com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy) LoadEventInfo(com.google.android.exoplayer2.source.LoadEventInfo) HttpDataSource(com.google.android.exoplayer2.upstream.HttpDataSource) Nullable(androidx.annotation.Nullable) LoadErrorAction(com.google.android.exoplayer2.upstream.Loader.LoadErrorAction)

Example 14 with MediaLoadData

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

the class DefaultHlsPlaylistTracker method onLoadError.

@Override
public LoadErrorAction onLoadError(ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error, int errorCount) {
    LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded());
    MediaLoadData mediaLoadData = new MediaLoadData(loadable.type);
    long retryDelayMs = loadErrorHandlingPolicy.getRetryDelayMsFor(new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount));
    boolean isFatal = retryDelayMs == C.TIME_UNSET;
    eventDispatcher.loadError(loadEventInfo, loadable.type, error, isFatal);
    if (isFatal) {
        loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    }
    return isFatal ? Loader.DONT_RETRY_FATAL : Loader.createRetryAction(/* resetErrorCount= */
    false, retryDelayMs);
}
Also used : LoadEventInfo(com.google.android.exoplayer2.source.LoadEventInfo) MediaLoadData(com.google.android.exoplayer2.source.MediaLoadData) LoadErrorInfo(com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy.LoadErrorInfo)

Example 15 with MediaLoadData

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

the class DefaultDashChunkSourceTest method createFakeLoadErrorInfo.

private LoadErrorHandlingPolicy.LoadErrorInfo createFakeLoadErrorInfo(DataSpec dataSpec, int httpResponseCode, int errorCount) {
    LoadEventInfo loadEventInfo = new LoadEventInfo(/* loadTaskId= */
    0, dataSpec, SystemClock.elapsedRealtime());
    MediaLoadData mediaLoadData = new MediaLoadData(C.DATA_TYPE_MEDIA);
    HttpDataSource.InvalidResponseCodeException invalidResponseCodeException = new HttpDataSource.InvalidResponseCodeException(httpResponseCode, /* responseMessage= */
    null, /* cause= */
    null, ImmutableMap.of(), dataSpec, new byte[0]);
    return new LoadErrorHandlingPolicy.LoadErrorInfo(loadEventInfo, mediaLoadData, invalidResponseCodeException, errorCount);
}
Also used : LoadEventInfo(com.google.android.exoplayer2.source.LoadEventInfo) MediaLoadData(com.google.android.exoplayer2.source.MediaLoadData) HttpDataSource(com.google.android.exoplayer2.upstream.HttpDataSource)

Aggregations

LoadEventInfo (com.google.android.exoplayer2.source.LoadEventInfo)7 MediaLoadData (com.google.android.exoplayer2.source.MediaLoadData)7 LoadErrorInfo (com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy.LoadErrorInfo)7 EventTime (com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)6 LoadErrorAction (com.google.android.exoplayer2.upstream.Loader.LoadErrorAction)6 Nullable (androidx.annotation.Nullable)2 HttpDataSource (com.google.android.exoplayer2.upstream.HttpDataSource)2 StatsDataSource (com.google.android.exoplayer2.upstream.StatsDataSource)2 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 LoadErrorHandlingPolicy (com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy)1 HashSet (java.util.HashSet)1