Search in sources :

Example 6 with PlaybackException

use of com.google.android.exoplayer2.PlaybackException in project ExoPlayer by google.

the class RtspMediaPeriod method retryWithRtpTcp.

private void retryWithRtpTcp() {
    rtspClient.retryWithRtpTcp();
    @Nullable RtpDataChannel.Factory fallbackRtpDataChannelFactory = rtpDataChannelFactory.createFallbackDataChannelFactory();
    if (fallbackRtpDataChannelFactory == null) {
        playbackException = new RtspPlaybackException("No fallback data channel factory for TCP retry");
        return;
    }
    ArrayList<RtspLoaderWrapper> newLoaderWrappers = new ArrayList<>(rtspLoaderWrappers.size());
    ArrayList<RtpLoadInfo> newSelectedLoadInfos = new ArrayList<>(selectedLoadInfos.size());
    // newLoaderWrappers' elements and orders must match those of rtspLoaderWrappers'.
    for (int i = 0; i < rtspLoaderWrappers.size(); i++) {
        RtspLoaderWrapper loaderWrapper = rtspLoaderWrappers.get(i);
        if (!loaderWrapper.canceled) {
            RtspLoaderWrapper newLoaderWrapper = new RtspLoaderWrapper(loaderWrapper.loadInfo.mediaTrack, /* trackId= */
            i, fallbackRtpDataChannelFactory);
            newLoaderWrappers.add(newLoaderWrapper);
            newLoaderWrapper.startLoading();
            if (selectedLoadInfos.contains(loaderWrapper.loadInfo)) {
                newSelectedLoadInfos.add(newLoaderWrapper.loadInfo);
            }
        } else {
            newLoaderWrappers.add(loaderWrapper);
        }
    }
    // Switch to new LoaderWrappers.
    ImmutableList<RtspLoaderWrapper> oldRtspLoaderWrappers = ImmutableList.copyOf(rtspLoaderWrappers);
    rtspLoaderWrappers.clear();
    rtspLoaderWrappers.addAll(newLoaderWrappers);
    selectedLoadInfos.clear();
    selectedLoadInfos.addAll(newSelectedLoadInfos);
    // active sample queues.
    for (int i = 0; i < oldRtspLoaderWrappers.size(); i++) {
        oldRtspLoaderWrappers.get(i).cancelLoad();
    }
}
Also used : RtspPlaybackException(com.google.android.exoplayer2.source.rtsp.RtspMediaSource.RtspPlaybackException) ArrayList(java.util.ArrayList) Nullable(androidx.annotation.Nullable)

Example 7 with PlaybackException

use of com.google.android.exoplayer2.PlaybackException in project ExoPlayer by google.

the class RtspPlaybackTest method prepare_noSupportedTrack_throwsPreparationError.

@Test
public void prepare_noSupportedTrack_throwsPreparationError() throws Exception {
    try (RtspServer rtspServer = new RtspServer(new ResponseProvider(clock, ImmutableList.of(mp4aLatmRtpPacketStreamDump), fakeRtpDataChannel))) {
        ExoPlayer player = createExoPlayer(rtspServer.startAndGetPortNumber(), rtpDataChannelFactory);
        AtomicReference<Throwable> playbackError = new AtomicReference<>();
        player.prepare();
        player.addListener(new Listener() {

            @Override
            public void onPlayerError(PlaybackException error) {
                playbackError.set(error);
            }
        });
        RobolectricUtil.runMainLooperUntil(() -> playbackError.get() != null);
        player.release();
        assertThat(playbackError.get()).hasCauseThat().hasMessageThat().contains("No playable track.");
    }
}
Also used : PlaybackException(com.google.android.exoplayer2.PlaybackException) Listener(com.google.android.exoplayer2.Player.Listener) AtomicReference(java.util.concurrent.atomic.AtomicReference) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) Test(org.junit.Test)

Example 8 with PlaybackException

use of com.google.android.exoplayer2.PlaybackException in project ExoPlayer by google.

the class MediaMetricsListener method maybeReportPlaybackError.

private void maybeReportPlaybackError(long realtimeMs) {
    @Nullable PlaybackException error = pendingPlayerError;
    if (error == null) {
        return;
    }
    ErrorInfo errorInfo = getErrorInfo(error, context, /* lastIoErrorForManifest= */
    ioErrorType == C.DATA_TYPE_MANIFEST);
    playbackSession.reportPlaybackErrorEvent(new PlaybackErrorEvent.Builder().setTimeSinceCreatedMillis(realtimeMs - startTimeMs).setErrorCode(errorInfo.errorCode).setSubErrorCode(errorInfo.subErrorCode).setException(error).build());
    reportedEventsForCurrentSession = true;
    pendingPlayerError = null;
}
Also used : ExoPlaybackException(com.google.android.exoplayer2.ExoPlaybackException) PlaybackException(com.google.android.exoplayer2.PlaybackException) Nullable(androidx.annotation.Nullable)

Example 9 with PlaybackException

use of com.google.android.exoplayer2.PlaybackException in project ExoPlayer by google.

the class DefaultAnalyticsCollector method onPlayerError.

@Override
public final void onPlayerError(PlaybackException error) {
    EventTime eventTime = getEventTimeForErrorEvent(error);
    sendEvent(eventTime, AnalyticsListener.EVENT_PLAYER_ERROR, listener -> listener.onPlayerError(eventTime, error));
}
Also used : EventTime(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)

Example 10 with PlaybackException

use of com.google.android.exoplayer2.PlaybackException in project ExoPlayer by google.

the class DefaultAnalyticsCollector method onPlayerErrorChanged.

@Override
public void onPlayerErrorChanged(@Nullable PlaybackException error) {
    EventTime eventTime = getEventTimeForErrorEvent(error);
    sendEvent(eventTime, AnalyticsListener.EVENT_PLAYER_ERROR, listener -> listener.onPlayerErrorChanged(eventTime, error));
}
Also used : EventTime(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)

Aggregations

PlaybackException (com.google.android.exoplayer2.PlaybackException)8 Nullable (androidx.annotation.Nullable)7 ExoPlaybackException (com.google.android.exoplayer2.ExoPlaybackException)4 Test (org.junit.Test)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)2 MediaItem (com.google.android.exoplayer2.MediaItem)2 Player (com.google.android.exoplayer2.Player)2 EventTime (com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)2 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)2 SuppressLint (android.annotation.SuppressLint)1 DeniedByServerException (android.media.DeniedByServerException)1 MediaCodec (android.media.MediaCodec)1 MediaDrm (android.media.MediaDrm)1 MediaDrmResetException (android.media.MediaDrmResetException)1 NotProvisionedException (android.media.NotProvisionedException)1 Bundle (android.os.Bundle)1 PlaybackStateCompat (android.support.v4.media.session.PlaybackStateCompat)1 ErrnoException (android.system.ErrnoException)1 Pair (android.util.Pair)1