Revert "Update local_ssrc without needing to recreate video streams."

This reverts commit 16a8b25d80.

Reason for revert: Checking if this is blocking the Chromium autoroller.

Original change's description:
> Update local_ssrc without needing to recreate video streams.
>
> This is comparable to this change done previously for for audio streams:
> https://webrtc-review.googlesource.com/c/src/+/222042
>
> Bug: webrtc:11993
> Change-Id: Ic953f816a8f7c56d1c3dc9a16d85bef3696a663d
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261960
> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#36876}

Bug: webrtc:11993
Change-Id: I3a8d2f6a7e89b6784754d8e891a4e01479807c2d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/262422
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#36892}
This commit is contained in:
Tomas Gunnarsson 2022-05-13 22:29:25 +00:00 committed by WebRTC LUCI CQ
parent 9d80fb7d3e
commit c92ee5f3c3
14 changed files with 48 additions and 142 deletions

View file

@ -266,10 +266,6 @@ class Call final : public webrtc::Call,
void OnLocalSsrcUpdated(webrtc::AudioReceiveStream& stream,
uint32_t local_ssrc) override;
void OnLocalSsrcUpdated(VideoReceiveStream& stream,
uint32_t local_ssrc) override;
void OnLocalSsrcUpdated(FlexfecReceiveStream& stream,
uint32_t local_ssrc) override;
void OnUpdateSyncGroup(webrtc::AudioReceiveStream& stream,
const std::string& sync_group) override;
@ -419,8 +415,6 @@ class Call final : public webrtc::Call,
RTC_GUARDED_BY(&receive_11993_checker_);
// Audio and Video send streams are owned by the client that creates them.
// TODO(bugs.webrtc.org/11993): `audio_send_ssrcs_` and `video_send_ssrcs_`
// should be accessed on the network thread.
std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_
RTC_GUARDED_BY(worker_thread_);
std::map<uint32_t, VideoSendStream*> video_send_ssrcs_
@ -1391,17 +1385,6 @@ void Call::OnLocalSsrcUpdated(webrtc::AudioReceiveStream& stream,
: nullptr);
}
void Call::OnLocalSsrcUpdated(VideoReceiveStream& stream, uint32_t local_ssrc) {
RTC_DCHECK_RUN_ON(worker_thread_);
static_cast<VideoReceiveStream2&>(stream).SetLocalSsrc(local_ssrc);
}
void Call::OnLocalSsrcUpdated(FlexfecReceiveStream& stream,
uint32_t local_ssrc) {
RTC_DCHECK_RUN_ON(worker_thread_);
static_cast<FlexfecReceiveStreamImpl&>(stream).SetLocalSsrc(local_ssrc);
}
void Call::OnUpdateSyncGroup(webrtc::AudioReceiveStream& stream,
const std::string& sync_group) {
RTC_DCHECK_RUN_ON(worker_thread_);

View file

@ -165,10 +165,6 @@ class Call {
// send streams needs to be updated.
virtual void OnLocalSsrcUpdated(AudioReceiveStream& stream,
uint32_t local_ssrc) = 0;
virtual void OnLocalSsrcUpdated(VideoReceiveStream& stream,
uint32_t local_ssrc) = 0;
virtual void OnLocalSsrcUpdated(FlexfecReceiveStream& stream,
uint32_t local_ssrc) = 0;
virtual void OnUpdateSyncGroup(AudioReceiveStream& stream,
const std::string& sync_group) = 0;

View file

@ -304,16 +304,6 @@ void DegradedCall::OnLocalSsrcUpdated(AudioReceiveStream& stream,
call_->OnLocalSsrcUpdated(stream, local_ssrc);
}
void DegradedCall::OnLocalSsrcUpdated(VideoReceiveStream& stream,
uint32_t local_ssrc) {
call_->OnLocalSsrcUpdated(stream, local_ssrc);
}
void DegradedCall::OnLocalSsrcUpdated(FlexfecReceiveStream& stream,
uint32_t local_ssrc) {
call_->OnLocalSsrcUpdated(stream, local_ssrc);
}
void DegradedCall::OnUpdateSyncGroup(AudioReceiveStream& stream,
const std::string& sync_group) {
call_->OnUpdateSyncGroup(stream, sync_group);

View file

@ -100,10 +100,6 @@ class DegradedCall : public Call, private PacketReceiver {
int transport_overhead_per_packet) override;
void OnLocalSsrcUpdated(AudioReceiveStream& stream,
uint32_t local_ssrc) override;
void OnLocalSsrcUpdated(VideoReceiveStream& stream,
uint32_t local_ssrc) override;
void OnLocalSsrcUpdated(FlexfecReceiveStream& stream,
uint32_t local_ssrc) override;
void OnUpdateSyncGroup(AudioReceiveStream& stream,
const std::string& sync_group) override;
void OnSentPacket(const rtc::SentPacket& sent_packet) override;

View file

@ -213,14 +213,4 @@ RtpHeaderExtensionMap FlexfecReceiveStreamImpl::GetRtpExtensionMap() const {
return extension_map_;
}
void FlexfecReceiveStreamImpl::SetLocalSsrc(uint32_t local_ssrc) {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
if (local_ssrc == config_.rtp.local_ssrc)
return;
auto& c = const_cast<Config&>(config_);
c.rtp.local_ssrc = local_ssrc;
rtp_rtcp_->SetLocalSsrc(local_ssrc);
}
} // namespace webrtc

View file

@ -62,10 +62,6 @@ class FlexfecReceiveStreamImpl : public FlexfecReceiveStream {
void SetRtpExtensions(std::vector<RtpExtension> extensions) override;
RtpHeaderExtensionMap GetRtpExtensionMap() const override;
// Updates the `rtp_video_stream_receiver_`'s `local_ssrc` when the default
// sender has been created, changed or removed.
void SetLocalSsrc(uint32_t local_ssrc);
uint32_t remote_ssrc() const { return config_.rtp.remote_ssrc; }
bool transport_cc() const override {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
@ -77,8 +73,8 @@ class FlexfecReceiveStreamImpl : public FlexfecReceiveStream {
RtpHeaderExtensionMap extension_map_;
// Config. Mostly const, local_ssrc may change, which is an exception
// case that's specifically handled in `SetLocalSsrc`, which must be
// Config. Mostly const, header extensions may change, which is an exception
// case that's specifically handled in `SetRtpExtensions`, which must be
// called on the `packet_sequence_checker` thread.
const Config config_;

View file

@ -715,18 +715,6 @@ void FakeCall::OnLocalSsrcUpdated(webrtc::AudioReceiveStream& stream,
fake_stream.SetLocalSsrc(local_ssrc);
}
void FakeCall::OnLocalSsrcUpdated(webrtc::VideoReceiveStream& stream,
uint32_t local_ssrc) {
auto& fake_stream = static_cast<FakeVideoReceiveStream&>(stream);
fake_stream.SetLocalSsrc(local_ssrc);
}
void FakeCall::OnLocalSsrcUpdated(webrtc::FlexfecReceiveStream& stream,
uint32_t local_ssrc) {
auto& fake_stream = static_cast<FakeFlexfecReceiveStream&>(stream);
fake_stream.SetLocalSsrc(local_ssrc);
}
void FakeCall::OnUpdateSyncGroup(webrtc::AudioReceiveStream& stream,
const std::string& sync_group) {
auto& fake_stream = static_cast<FakeAudioReceiveStream&>(stream);

View file

@ -250,10 +250,6 @@ class FakeVideoReceiveStream final : public webrtc::VideoReceiveStream {
return base_mininum_playout_delay_ms_;
}
void SetLocalSsrc(uint32_t local_ssrc) {
config_.rtp.local_ssrc = local_ssrc;
}
void SetFrameDecryptor(rtc::scoped_refptr<webrtc::FrameDecryptorInterface>
frame_decryptor) override {}
@ -299,10 +295,6 @@ class FakeFlexfecReceiveStream final : public webrtc::FlexfecReceiveStream {
explicit FakeFlexfecReceiveStream(
const webrtc::FlexfecReceiveStream::Config config);
void SetLocalSsrc(uint32_t local_ssrc) {
config_.rtp.local_ssrc = local_ssrc;
}
void SetRtpExtensions(std::vector<webrtc::RtpExtension> extensions) override;
webrtc::RtpHeaderExtensionMap GetRtpExtensionMap() const override;
bool transport_cc() const override { return config_.rtp.transport_cc; }
@ -419,10 +411,6 @@ class FakeCall final : public webrtc::Call, public webrtc::PacketReceiver {
int transport_overhead_per_packet) override;
void OnLocalSsrcUpdated(webrtc::AudioReceiveStream& stream,
uint32_t local_ssrc) override;
void OnLocalSsrcUpdated(webrtc::VideoReceiveStream& stream,
uint32_t local_ssrc) override;
void OnLocalSsrcUpdated(webrtc::FlexfecReceiveStream& stream,
uint32_t local_ssrc) override;
void OnUpdateSyncGroup(webrtc::AudioReceiveStream& stream,
const std::string& sync_group) override;
void OnSentPacket(const rtc::SentPacket& sent_packet) override;

View file

@ -1240,20 +1240,6 @@ std::string WebRtcVideoChannel::CodecSettingsVectorToString(
return out.Release();
}
// RTC_RUN_ON(&thread_checker_)
void WebRtcVideoChannel::SetReceiverReportSsrc(uint32_t ssrc) {
if (ssrc == rtcp_receiver_report_ssrc_)
return;
rtcp_receiver_report_ssrc_ = ssrc;
for (auto& [unused, receive_stream] : receive_streams_) {
call_->OnLocalSsrcUpdated(receive_stream->stream(), ssrc);
webrtc::FlexfecReceiveStream* flex_fec = receive_stream->flexfec_stream();
if (flex_fec)
call_->OnLocalSsrcUpdated(*flex_fec, ssrc);
}
}
bool WebRtcVideoChannel::GetSendCodec(VideoCodec* codec) {
RTC_DCHECK_RUN_ON(&thread_checker_);
if (!send_codec_) {
@ -1366,9 +1352,13 @@ bool WebRtcVideoChannel::AddSendStream(const StreamParams& sp) {
send_streams_[ssrc] = stream;
if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) {
SetReceiverReportSsrc(ssrc);
rtcp_receiver_report_ssrc_ = ssrc;
RTC_LOG(LS_INFO)
<< "SetLocalSsrc on all the receive streams because we added "
"a send stream.";
for (auto& kv : receive_streams_)
kv.second->SetLocalSsrc(ssrc);
}
if (sending_) {
stream->SetSend(true);
}
@ -1395,8 +1385,15 @@ bool WebRtcVideoChannel::RemoveSendStream(uint32_t ssrc) {
// Switch receiver report SSRCs, the one in use is no longer valid.
if (rtcp_receiver_report_ssrc_ == ssrc) {
SetReceiverReportSsrc(send_streams_.empty() ? kDefaultRtcpReceiverReportSsrc
: send_streams_.begin()->first);
rtcp_receiver_report_ssrc_ = send_streams_.empty()
? kDefaultRtcpReceiverReportSsrc
: send_streams_.begin()->first;
RTC_LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because the "
"previous local SSRC was removed.";
for (auto& kv : receive_streams_) {
kv.second->SetLocalSsrc(rtcp_receiver_report_ssrc_);
}
}
delete removed_stream;
@ -2808,7 +2805,7 @@ WebRtcVideoChannel::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream(
config_.renderer = this;
ConfigureCodecs(recv_codecs);
flexfec_config_.payload_type = flexfec_config.payload_type;
RecreateReceiveStream();
RecreateWebRtcVideoStream();
}
WebRtcVideoChannel::WebRtcVideoReceiveStream::~WebRtcVideoReceiveStream() {
@ -2817,17 +2814,6 @@ WebRtcVideoChannel::WebRtcVideoReceiveStream::~WebRtcVideoReceiveStream() {
call_->DestroyFlexfecReceiveStream(flexfec_stream_);
}
webrtc::VideoReceiveStream&
WebRtcVideoChannel::WebRtcVideoReceiveStream::stream() {
RTC_DCHECK(stream_);
return *stream_;
}
webrtc::FlexfecReceiveStream*
WebRtcVideoChannel::WebRtcVideoReceiveStream::flexfec_stream() {
return flexfec_stream_;
}
const std::vector<uint32_t>&
WebRtcVideoChannel::WebRtcVideoReceiveStream::GetSsrcs() const {
return stream_params_.ssrcs;
@ -2937,6 +2923,27 @@ bool WebRtcVideoChannel::WebRtcVideoReceiveStream::ConfigureCodecs(
return recreate_needed;
}
void WebRtcVideoChannel::WebRtcVideoReceiveStream::SetLocalSsrc(
uint32_t local_ssrc) {
// TODO(pbos): Consider turning this sanity check into a RTC_DCHECK. You
// should not be able to create a sender with the same SSRC as a receiver, but
// right now this can't be done due to unittests depending on receiving what
// they are sending from the same MediaChannel.
if (local_ssrc == config_.rtp.local_ssrc) {
RTC_DLOG(LS_INFO) << "Ignoring call to SetLocalSsrc because parameters are "
"unchanged; local_ssrc="
<< local_ssrc;
return;
}
config_.rtp.local_ssrc = local_ssrc;
flexfec_config_.rtp.local_ssrc = local_ssrc;
RTC_LOG(LS_INFO)
<< "RecreateWebRtcVideoStream (recv) because of SetLocalSsrc; local_ssrc="
<< local_ssrc;
RecreateWebRtcVideoStream();
}
void WebRtcVideoChannel::WebRtcVideoReceiveStream::SetFeedbackParameters(
bool lntf_enabled,
bool nack_enabled,
@ -2965,10 +2972,10 @@ void WebRtcVideoChannel::WebRtcVideoReceiveStream::SetFeedbackParameters(
// based on the rtcp-fb for the FlexFEC codec, not the media codec.
flexfec_config_.rtp.transport_cc = config_.rtp.transport_cc;
flexfec_config_.rtcp_mode = config_.rtp.rtcp_mode;
RTC_LOG(LS_INFO) << "RecreateReceiveStream (recv) because of "
RTC_LOG(LS_INFO) << "RecreateWebRtcVideoStream (recv) because of "
"SetFeedbackParameters; nack="
<< nack_enabled << ", transport_cc=" << transport_cc_enabled;
RecreateReceiveStream();
RecreateWebRtcVideoStream();
}
void WebRtcVideoChannel::WebRtcVideoReceiveStream::SetRecvParameters(
@ -3007,11 +3014,11 @@ void WebRtcVideoChannel::WebRtcVideoReceiveStream::SetRecvParameters(
video_needs_recreation = true;
}
if (video_needs_recreation) {
RecreateReceiveStream();
RecreateWebRtcVideoStream();
}
}
void WebRtcVideoChannel::WebRtcVideoReceiveStream::RecreateReceiveStream() {
void WebRtcVideoChannel::WebRtcVideoReceiveStream::RecreateWebRtcVideoStream() {
absl::optional<int> base_minimum_playout_delay_ms;
absl::optional<webrtc::VideoReceiveStream::RecordingState> recording_state;
if (stream_) {

View file

@ -316,10 +316,6 @@ class WebRtcVideoChannel : public VideoMediaChannel,
static std::string CodecSettingsVectorToString(
const std::vector<VideoCodecSettings>& codecs);
// Called when the local ssrc changes. Sets `rtcp_receiver_report_ssrc_` and
// updates the receive streams.
void SetReceiverReportSsrc(uint32_t ssrc) RTC_RUN_ON(&thread_checker_);
// Wrapper for the sender part.
class WebRtcVideoSendStream {
public:
@ -442,10 +438,6 @@ class WebRtcVideoChannel : public VideoMediaChannel,
const webrtc::FlexfecReceiveStream::Config& flexfec_config);
~WebRtcVideoReceiveStream();
webrtc::VideoReceiveStream& stream();
// Return value may be nullptr.
webrtc::FlexfecReceiveStream* flexfec_stream();
const std::vector<uint32_t>& GetSsrcs() const;
std::vector<webrtc::RtpSource> GetSources();
@ -453,6 +445,7 @@ class WebRtcVideoChannel : public VideoMediaChannel,
// Does not return codecs, they are filled by the owning WebRtcVideoChannel.
webrtc::RtpParameters GetRtpParameters() const;
void SetLocalSsrc(uint32_t local_ssrc);
// TODO(deadbeef): Move these feedback parameters into the recv parameters.
void SetFeedbackParameters(bool lntf_enabled,
bool nack_enabled,
@ -485,7 +478,7 @@ class WebRtcVideoChannel : public VideoMediaChannel,
frame_transformer);
private:
void RecreateReceiveStream();
void RecreateWebRtcVideoStream();
// Applies a new receive codecs configration to `config_`. Returns true
// if the internal stream needs to be reconstructed, or false if no changes

View file

@ -923,11 +923,6 @@ void RtpVideoStreamReceiver2::UpdateRtt(int64_t max_rtt_ms) {
nack_module_->UpdateRtt(max_rtt_ms);
}
void RtpVideoStreamReceiver2::OnLocalSsrcChange(uint32_t local_ssrc) {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
rtp_rtcp_->SetLocalSsrc(local_ssrc);
}
absl::optional<int64_t> RtpVideoStreamReceiver2::LastReceivedPacketMs() const {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
if (last_received_rtp_system_time_) {

View file

@ -184,9 +184,6 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
// Called by VideoReceiveStream when stats are updated.
void UpdateRtt(int64_t max_rtt_ms);
// Called when the local_ssrc is changed to match with a sender.
void OnLocalSsrcChange(uint32_t local_ssrc);
absl::optional<int64_t> LastReceivedPacketMs() const;
absl::optional<int64_t> LastReceivedKeyframePacketMs() const;

View file

@ -341,16 +341,6 @@ void VideoReceiveStream2::SetSync(Syncable* audio_syncable) {
rtp_stream_sync_.ConfigureSync(audio_syncable);
}
void VideoReceiveStream2::SetLocalSsrc(uint32_t local_ssrc) {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
if (config_.rtp.local_ssrc == local_ssrc)
return;
// TODO(tommi): Make sure we don't rely on local_ssrc via the config struct.
const_cast<uint32_t&>(config_.rtp.local_ssrc) = local_ssrc;
rtp_video_stream_receiver_.OnLocalSsrcChange(local_ssrc);
}
void VideoReceiveStream2::Start() {
RTC_DCHECK_RUN_ON(&worker_sequence_checker_);
@ -486,8 +476,9 @@ void VideoReceiveStream2::SetRtpExtensions(
// and guarded by `packet_sequence_checker_`. However the scope of that state
// is huge (the whole Config struct), and would require all methods that touch
// the struct to abide the needs of the `extensions` member.
const_cast<std::vector<RtpExtension>&>(config_.rtp.extensions) =
std::move(extensions);
VideoReceiveStream::Config& c =
const_cast<VideoReceiveStream::Config&>(config_);
c.rtp.extensions = std::move(extensions);
}
RtpHeaderExtensionMap VideoReceiveStream2::GetRtpExtensionMap() const {

View file

@ -131,10 +131,6 @@ class VideoReceiveStream2
void SetSync(Syncable* audio_syncable);
// Updates the `rtp_video_stream_receiver_`'s `local_ssrc` when the default
// sender has been created, changed or removed.
void SetLocalSsrc(uint32_t local_ssrc);
// Implements webrtc::VideoReceiveStream.
void Start() override;
void Stop() override;