Search in sources :

Example 31 with LoadEventInfo

use of com.google.android.exoplayer2.source.LoadEventInfo 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)

Example 32 with LoadEventInfo

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

the class SsMediaSource method onLoadError.

@Override
public LoadErrorAction onLoadError(ParsingLoadable<SsManifest> 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));
    LoadErrorAction loadErrorAction = retryDelayMs == C.TIME_UNSET ? Loader.DONT_RETRY_FATAL : Loader.createRetryAction(/* resetErrorCount= */
    false, retryDelayMs);
    boolean wasCanceled = !loadErrorAction.isRetry();
    manifestEventDispatcher.loadError(loadEventInfo, loadable.type, error, wasCanceled);
    if (wasCanceled) {
        loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    }
    return loadErrorAction;
}
Also used : LoadEventInfo(com.google.android.exoplayer2.source.LoadEventInfo) MediaLoadData(com.google.android.exoplayer2.source.MediaLoadData) LoadErrorInfo(com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy.LoadErrorInfo) LoadErrorAction(com.google.android.exoplayer2.upstream.Loader.LoadErrorAction)

Example 33 with LoadEventInfo

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

the class SsMediaSource method onLoadCanceled.

@Override
public void onLoadCanceled(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs, boolean released) {
    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(com.google.android.exoplayer2.source.LoadEventInfo)

Example 34 with LoadEventInfo

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

the class DashMediaSource method onManifestLoadCompleted.

// Loadable callbacks.
/* package */
void onManifestLoadCompleted(ParsingLoadable<DashManifest> 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.loadCompleted(loadEventInfo, loadable.type);
    DashManifest newManifest = loadable.getResult();
    int oldPeriodCount = manifest == null ? 0 : manifest.getPeriodCount();
    int removedPeriodCount = 0;
    long newFirstPeriodStartTimeMs = newManifest.getPeriod(0).startMs;
    while (removedPeriodCount < oldPeriodCount && manifest.getPeriod(removedPeriodCount).startMs < newFirstPeriodStartTimeMs) {
        removedPeriodCount++;
    }
    if (newManifest.dynamic) {
        boolean isManifestStale = false;
        if (oldPeriodCount - removedPeriodCount > newManifest.getPeriodCount()) {
            // After discarding old periods, we should never have more periods than listed in the new
            // manifest. That would mean that a previously announced period is no longer advertised. If
            // this condition occurs, assume that we are hitting a manifest server that is out of sync
            // and
            // behind.
            Log.w(TAG, "Loaded out of sync manifest");
            isManifestStale = true;
        } else if (expiredManifestPublishTimeUs != C.TIME_UNSET && newManifest.publishTimeMs * 1000 <= expiredManifestPublishTimeUs) {
            // If we receive a dynamic manifest that's older than expected (i.e. its publish time has
            // expired, or it's dynamic and we know the presentation has ended), then this manifest is
            // stale.
            Log.w(TAG, "Loaded stale dynamic manifest: " + newManifest.publishTimeMs + ", " + expiredManifestPublishTimeUs);
            isManifestStale = true;
        }
        if (isManifestStale) {
            if (staleManifestReloadAttempt++ < loadErrorHandlingPolicy.getMinimumLoadableRetryCount(loadable.type)) {
                scheduleManifestRefresh(getManifestLoadRetryDelayMillis());
            } else {
                manifestFatalError = new DashManifestStaleException();
            }
            return;
        }
        staleManifestReloadAttempt = 0;
    }
    manifest = newManifest;
    manifestLoadPending &= manifest.dynamic;
    manifestLoadStartTimestampMs = elapsedRealtimeMs - loadDurationMs;
    manifestLoadEndTimestampMs = elapsedRealtimeMs;
    synchronized (manifestUriLock) {
        // Checks whether replaceManifestUri(Uri) was called to manually replace the URI between the
        // start and end of this load. If it was then isSameUriInstance evaluates to false, and we
        // prefer the manual replacement to one derived from the previous request.
        @SuppressWarnings("ReferenceEquality") boolean isSameUriInstance = loadable.dataSpec.uri == manifestUri;
        if (isSameUriInstance) {
            // Replace the manifest URI with one specified by a manifest Location element (if present),
            // or with the final (possibly redirected) URI. This follows the recommendation in
            // DASH-IF-IOP 4.3, section 3.2.15.3. See: https://dashif.org/docs/DASH-IF-IOP-v4.3.pdf.
            manifestUri = manifest.location != null ? manifest.location : loadable.getUri();
        }
    }
    if (oldPeriodCount == 0) {
        if (manifest.dynamic) {
            if (manifest.utcTiming != null) {
                resolveUtcTimingElement(manifest.utcTiming);
            } else {
                loadNtpTimeOffset();
            }
        } else {
            processManifest(true);
        }
    } else {
        firstPeriodId += removedPeriodCount;
        processManifest(true);
    }
}
Also used : LoadEventInfo(com.google.android.exoplayer2.source.LoadEventInfo) DashManifest(com.google.android.exoplayer2.source.dash.manifest.DashManifest)

Example 35 with LoadEventInfo

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

the class DashMediaSource method onUtcTimestampLoadError.

/* package */
LoadErrorAction onUtcTimestampLoadError(ParsingLoadable<Long> loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error) {
    manifestEventDispatcher.loadError(new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()), loadable.type, error, /* wasCanceled= */
    true);
    loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    onUtcTimestampResolutionError(error);
    return Loader.DONT_RETRY;
}
Also used : LoadEventInfo(com.google.android.exoplayer2.source.LoadEventInfo)

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