use of androidx.media3.exoplayer.rtsp.RtspMediaSource.RtspPlaybackException 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();
}
}
Aggregations