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();
}
}
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.");
}
}
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;
}
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));
}
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));
}
Aggregations