[Unified Plan] Don't end audio tracks when SSRC changes.
The RemoteAudioSource has an AudioDataProxy that acts as a sink, passing
along data from AudioRecvStreams to the RemoteAudioSource. If an SSRC is
changed (or other reconfiguration happens) with SDP, the recv stream and
proxy get recreated.
In Plan B, because remote tracks maps 1:1 with SSRCs, it made sense to
end remote track/audio source in response to this. In Plan B, a new
receiver, with a new track and a new proxy would be created for the new
SSRC.
In Unified Plan however, remote tracks correspond to m= sections. The
remote track should only end on port:0 (or RTCP BYE or timeout, etc),
not because the recv stream of an m= section is recreated. The code
already supports changing SSRC and this is working correctly, but
because ~AudioDataProxy() would end the source this would cause the
MediaStreamTrack of the receiver to end (even though the media engine
is still processing the remote audio stream correctly under the hood).
This issue only happened on audio tracks, and because of timing of
PostTasks the track would kEnd in Chromium *after* promise.then().
This CL fixes that issue by not ending the source when the proxy is
destroyed. Destroying a recv stream is a temporary action in Unified
Plan, unless stopped. Tests are added ensuring tracks are kLive.
I have manually verified that this CL fixes the issue and that both
audio and video is flowing through the entire pipeline:
https://jsfiddle.net/henbos/h21xec97/122/
Bug: chromium:1121454
Change-Id: Ic21ac8ea263ccf021b96a14d3e4e3b24eb756c86
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/214136
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33645}
diff --git a/pc/audio_rtp_receiver.cc b/pc/audio_rtp_receiver.cc
index e8fad28..48553ba 100644
--- a/pc/audio_rtp_receiver.cc
+++ b/pc/audio_rtp_receiver.cc
@@ -28,18 +28,25 @@
AudioRtpReceiver::AudioRtpReceiver(rtc::Thread* worker_thread,
std::string receiver_id,
- std::vector<std::string> stream_ids)
+ std::vector<std::string> stream_ids,
+ bool is_unified_plan)
: AudioRtpReceiver(worker_thread,
receiver_id,
- CreateStreamsFromIds(std::move(stream_ids))) {}
+ CreateStreamsFromIds(std::move(stream_ids)),
+ is_unified_plan) {}
AudioRtpReceiver::AudioRtpReceiver(
rtc::Thread* worker_thread,
const std::string& receiver_id,
- const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams)
+ const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams,
+ bool is_unified_plan)
: worker_thread_(worker_thread),
id_(receiver_id),
- source_(new rtc::RefCountedObject<RemoteAudioSource>(worker_thread)),
+ source_(new rtc::RefCountedObject<RemoteAudioSource>(
+ worker_thread,
+ is_unified_plan
+ ? RemoteAudioSource::OnAudioChannelGoneAction::kSurvive
+ : RemoteAudioSource::OnAudioChannelGoneAction::kEnd)),
track_(AudioTrackProxyWithInternal<AudioTrack>::Create(
rtc::Thread::Current(),
AudioTrack::Create(receiver_id, source_))),
@@ -137,6 +144,7 @@
if (stopped_) {
return;
}
+ source_->SetState(MediaSourceInterface::kEnded);
if (media_channel_) {
// Allow that SetOutputVolume fail. This is the normal case when the
// underlying media channel has already been deleted.