Reland "Remove stopped_ from AudioRtpReceiver and VideoRtpReceiver."

This is a reland of bb57e2d7aa9b36843233d1394422f03d12d9c31f

The difference from the original CL is that a check for
`state_ == kLive` inside of RemoteAudioSource::AddSink has been removed.
This caused a side effect that registering the sink while the source
was in an "initializing" state, failed. The last remaining state
however, is `kEnded` - but since there's no logic in the class around
the expected value of the states, the check inside of AddSink()
doesn't provide an additional value - it's rather a surprise for
developers if it doesn't succeed. So, now removed.

Original change's description:
> Remove `stopped_` from AudioRtpReceiver and VideoRtpReceiver.
>
> This simplifies the logic in these classes a bit, which makes upcoming
> change easier. The `stopped_` flag in these classes was essentially
> the same thing as `media_channel_ == nullptr`, which is what's
> consistently used now for the same checks.
>
> Bug: webrtc:13540
> Change-Id: Ib60bfad9f28d5ddee8a8d5170c3f2a7ef017a5ca
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250163
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#35907}

Bug: webrtc:13540
Change-Id: I3e5b3046fae11cb56b50c38c5f08972a6f283dd5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251326
Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35958}
This commit is contained in:
Tommi
2022-02-08 21:12:15 +01:00
committed by WebRTC LUCI CQ
parent f4cad8ac51
commit 3ed36c0521
10 changed files with 44 additions and 87 deletions

View File

@ -55,7 +55,7 @@ RemoteAudioSource::RemoteAudioSource(
: main_thread_(rtc::Thread::Current()),
worker_thread_(worker_thread),
on_audio_channel_gone_action_(on_audio_channel_gone_action),
state_(MediaSourceInterface::kLive) {
state_(MediaSourceInterface::kInitializing) {
RTC_DCHECK(main_thread_);
RTC_DCHECK(worker_thread_);
}
@ -134,11 +134,6 @@ void RemoteAudioSource::AddSink(AudioTrackSinkInterface* sink) {
RTC_DCHECK_RUN_ON(main_thread_);
RTC_DCHECK(sink);
if (state_ != MediaSourceInterface::kLive) {
RTC_LOG(LS_ERROR) << "Can't register sink as the source isn't live.";
return;
}
MutexLock lock(&sink_lock_);
RTC_DCHECK(!absl::c_linear_search(sinks_, sink));
sinks_.push_back(sink);