use of androidx.media3.common.PlaybackException in project media by androidx.
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));
}
use of androidx.media3.common.PlaybackException in project media by androidx.
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 androidx.media3.common.PlaybackException in project media by androidx.
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 androidx.media3.common.PlaybackException in project media by androidx.
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 androidx.media3.common.PlaybackException in project media by androidx.
the class MediaCodecRenderer method render.
@Override
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
if (pendingOutputEndOfStream) {
pendingOutputEndOfStream = false;
processEndOfStream();
}
if (pendingPlaybackException != null) {
ExoPlaybackException playbackException = pendingPlaybackException;
pendingPlaybackException = null;
throw playbackException;
}
try {
if (outputStreamEnded) {
renderToEndOfStream();
return;
}
if (inputFormat == null && !readSourceOmittingSampleData(FLAG_REQUIRE_FORMAT)) {
// We still don't have a format and can't make progress without one.
return;
}
// We have a format.
maybeInitCodecOrBypass();
if (bypassEnabled) {
TraceUtil.beginSection("bypassRender");
while (bypassRender(positionUs, elapsedRealtimeUs)) {
}
TraceUtil.endSection();
} else if (codec != null) {
long renderStartTimeMs = SystemClock.elapsedRealtime();
TraceUtil.beginSection("drainAndFeed");
while (drainOutputBuffer(positionUs, elapsedRealtimeUs) && shouldContinueRendering(renderStartTimeMs)) {
}
while (feedInputBuffer() && shouldContinueRendering(renderStartTimeMs)) {
}
TraceUtil.endSection();
} else {
decoderCounters.skippedInputBufferCount += skipSource(positionUs);
// We need to read any format changes despite not having a codec so that drmSession can be
// updated, and so that we have the most recent format should the codec be initialized. We
// may also reach the end of the stream. FLAG_PEEK is used because we don't want to advance
// the source further than skipSource has already done.
readSourceOmittingSampleData(FLAG_PEEK);
}
decoderCounters.ensureUpdated();
} catch (IllegalStateException e) {
if (isMediaCodecException(e)) {
onCodecError(e);
boolean isRecoverable = Util.SDK_INT >= 21 && isRecoverableMediaCodecExceptionV21(e);
if (isRecoverable) {
releaseCodec();
}
throw createRendererException(createDecoderException(e, getCodecInfo()), inputFormat, isRecoverable, PlaybackException.ERROR_CODE_DECODING_FAILED);
}
throw e;
}
}
Aggregations