Set local ssrc at construction of Rtp module
The SetSSRC() method is slated for removal, make sure we set the local
SSRC at construction time.
Bug: webrtc:10774
Change-Id: I431e828caf60c5e0134adbe82d1d3345745cc6ae
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/149827
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28926}
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc
index c4abea0..c093342 100644
--- a/audio/audio_receive_stream.cc
+++ b/audio/audio_receive_stream.cc
@@ -78,8 +78,9 @@
return voe::CreateChannelReceive(
clock, module_process_thread, internal_audio_state->audio_device_module(),
config.media_transport_config, config.rtcp_send_transport, event_log,
- config.rtp.remote_ssrc, config.jitter_buffer_max_packets,
- config.jitter_buffer_fast_accelerate, config.jitter_buffer_min_delay_ms,
+ config.rtp.local_ssrc, config.rtp.remote_ssrc,
+ config.jitter_buffer_max_packets, config.jitter_buffer_fast_accelerate,
+ config.jitter_buffer_min_delay_ms,
config.jitter_buffer_enable_rtx_handling, config.decoder_factory,
config.codec_pair_id, config.frame_decryptor, config.crypto_options);
}
@@ -381,12 +382,9 @@
RTC_DCHECK(first_time ||
old_config.decoder_factory == new_config.decoder_factory);
- if (first_time || old_config.rtp.local_ssrc != new_config.rtp.local_ssrc) {
- channel_receive->SetLocalSSRC(new_config.rtp.local_ssrc);
- }
-
if (!first_time) {
- // Remote ssrc can't be changed mid-stream.
+ // SSRC can't be changed mid-stream.
+ RTC_DCHECK_EQ(old_config.rtp.local_ssrc, new_config.rtp.local_ssrc);
RTC_DCHECK_EQ(old_config.rtp.remote_ssrc, new_config.rtp.remote_ssrc);
}
diff --git a/audio/audio_receive_stream_unittest.cc b/audio/audio_receive_stream_unittest.cc
index 12e779d..7e1da6d 100644
--- a/audio/audio_receive_stream_unittest.cc
+++ b/audio/audio_receive_stream_unittest.cc
@@ -88,7 +88,6 @@
audio_state_ = AudioState::Create(config);
channel_receive_ = new ::testing::StrictMock<MockChannelReceive>();
- EXPECT_CALL(*channel_receive_, SetLocalSSRC(kLocalSsrc)).Times(1);
EXPECT_CALL(*channel_receive_, SetNACKStatus(true, 15)).Times(1);
EXPECT_CALL(*channel_receive_,
RegisterReceiverCongestionControlObjects(&packet_router_))
@@ -365,7 +364,6 @@
auto recv_stream = helper.CreateAudioReceiveStream();
auto new_config = helper.config();
- new_config.rtp.local_ssrc = kLocalSsrc + 1;
new_config.rtp.nack.rtp_history_ms = 300 + 20;
new_config.rtp.extensions.clear();
new_config.rtp.extensions.push_back(
@@ -376,7 +374,6 @@
new_config.decoder_map.emplace(1, SdpAudioFormat("foo", 8000, 1));
MockChannelReceive& channel_receive = *helper.channel_receive();
- EXPECT_CALL(channel_receive, SetLocalSSRC(kLocalSsrc + 1)).Times(1);
EXPECT_CALL(channel_receive, SetNACKStatus(true, 15 + 1)).Times(1);
EXPECT_CALL(channel_receive, SetReceiveCodecs(new_config.decoder_map));
diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc
index 4ee5109..9daefe5 100644
--- a/audio/audio_send_stream.cc
+++ b/audio/audio_send_stream.cc
@@ -243,12 +243,8 @@
// Configuration parameters which cannot be changed.
RTC_DCHECK(first_time ||
old_config.send_transport == new_config.send_transport);
-
- if (old_config.rtp.ssrc != new_config.rtp.ssrc) {
- channel_send->SetLocalSSRC(new_config.rtp.ssrc);
- }
- if (stream->suspended_rtp_state_ &&
- (first_time || old_config.rtp.ssrc != new_config.rtp.ssrc)) {
+ RTC_DCHECK(first_time || old_config.rtp.ssrc == new_config.rtp.ssrc);
+ if (stream->suspended_rtp_state_ && first_time) {
stream->rtp_rtcp_module_->SetRtpState(*stream->suspended_rtp_state_);
}
if (first_time || old_config.rtp.c_name != new_config.rtp.c_name) {
diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc
index 94bc34c..9f0504c 100644
--- a/audio/audio_send_stream_unittest.cc
+++ b/audio/audio_send_stream_unittest.cc
@@ -208,7 +208,7 @@
EXPECT_CALL(*channel_send_, GetRtpRtcp()).WillRepeatedly(Invoke([this]() {
return &this->rtp_rtcp_;
}));
- EXPECT_CALL(*channel_send_, SetLocalSSRC(kSsrc)).Times(1);
+ EXPECT_CALL(rtp_rtcp_, SSRC).WillRepeatedly(Return(kSsrc));
EXPECT_CALL(*channel_send_, SetRTCP_CNAME(StrEq(kCName))).Times(1);
EXPECT_CALL(*channel_send_, SetFrameEncryptor(_)).Times(1);
EXPECT_CALL(*channel_send_, SetExtmapAllowMixed(false)).Times(1);
diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc
index d114391..3b4e9be 100644
--- a/audio/channel_receive.cc
+++ b/audio/channel_receive.cc
@@ -102,6 +102,7 @@
const MediaTransportConfig& media_transport_config,
Transport* rtcp_send_transport,
RtcEventLog* rtc_event_log,
+ uint32_t local_ssrc,
uint32_t remote_ssrc,
size_t jitter_buffer_max_packets,
bool jitter_buffer_fast_playout,
@@ -155,9 +156,6 @@
// Produces the transport-related timestamps; current_delay_ms is left unset.
absl::optional<Syncable::Info> GetSyncInfo() const override;
- // RTP+RTCP
- void SetLocalSSRC(unsigned int ssrc) override;
-
void RegisterReceiverCongestionControlObjects(
PacketRouter* packet_router) override;
void ResetReceiverCongestionControlObjects() override;
@@ -456,6 +454,7 @@
const MediaTransportConfig& media_transport_config,
Transport* rtcp_send_transport,
RtcEventLog* rtc_event_log,
+ uint32_t local_ssrc,
uint32_t remote_ssrc,
size_t jitter_buffer_max_packets,
bool jitter_buffer_fast_playout,
@@ -508,8 +507,8 @@
configuration.receiver_only = true;
configuration.outgoing_transport = rtcp_send_transport;
configuration.receive_statistics = rtp_receive_statistics_.get();
-
configuration.event_log = event_log_;
+ configuration.local_media_ssrc = local_ssrc;
_rtpRtcpModule = RtpRtcp::Create(configuration);
_rtpRtcpModule->SetSendingMediaStatus(false);
@@ -701,11 +700,6 @@
_outputGain = scaling;
}
-void ChannelReceive::SetLocalSSRC(uint32_t ssrc) {
- RTC_DCHECK(worker_thread_checker_.IsCurrent());
- _rtpRtcpModule->SetSSRC(ssrc);
-}
-
void ChannelReceive::RegisterReceiverCongestionControlObjects(
PacketRouter* packet_router) {
RTC_DCHECK(worker_thread_checker_.IsCurrent());
@@ -959,6 +953,7 @@
const MediaTransportConfig& media_transport_config,
Transport* rtcp_send_transport,
RtcEventLog* rtc_event_log,
+ uint32_t local_ssrc,
uint32_t remote_ssrc,
size_t jitter_buffer_max_packets,
bool jitter_buffer_fast_playout,
@@ -970,7 +965,7 @@
const webrtc::CryptoOptions& crypto_options) {
return absl::make_unique<ChannelReceive>(
clock, module_process_thread, audio_device_module, media_transport_config,
- rtcp_send_transport, rtc_event_log, remote_ssrc,
+ rtcp_send_transport, rtc_event_log, local_ssrc, remote_ssrc,
jitter_buffer_max_packets, jitter_buffer_fast_playout,
jitter_buffer_min_delay_ms, jitter_buffer_enable_rtx_handling,
decoder_factory, codec_pair_id, frame_decryptor, crypto_options);
diff --git a/audio/channel_receive.h b/audio/channel_receive.h
index 1fe64b9..dadeab3 100644
--- a/audio/channel_receive.h
+++ b/audio/channel_receive.h
@@ -116,9 +116,6 @@
// Produces the transport-related timestamps; current_delay_ms is left unset.
virtual absl::optional<Syncable::Info> GetSyncInfo() const = 0;
- // RTP+RTCP
- virtual void SetLocalSSRC(uint32_t ssrc) = 0;
-
virtual void RegisterReceiverCongestionControlObjects(
PacketRouter* packet_router) = 0;
virtual void ResetReceiverCongestionControlObjects() = 0;
@@ -145,6 +142,7 @@
const MediaTransportConfig& media_transport_config,
Transport* rtcp_send_transport,
RtcEventLog* rtc_event_log,
+ uint32_t local_ssrc,
uint32_t remote_ssrc,
size_t jitter_buffer_max_packets,
bool jitter_buffer_fast_playout,
diff --git a/audio/channel_send.cc b/audio/channel_send.cc
index 876ee69..f57858c 100644
--- a/audio/channel_send.cc
+++ b/audio/channel_send.cc
@@ -142,7 +142,6 @@
int payload_frequency) override;
// RTP+RTCP
- void SetLocalSSRC(uint32_t ssrc) override;
void SetRid(const std::string& rid,
int extension_id,
int repaired_extension_id) override;
@@ -279,7 +278,7 @@
int media_transport_sequence_number_ RTC_GUARDED_BY(encoder_queue_) = 0;
rtc::CriticalSection media_transport_lock_;
- // Currently set by SetLocalSSRC.
+ // Currently set to local SSRC at construction.
uint64_t media_transport_channel_id_ RTC_GUARDED_BY(&media_transport_lock_) =
0;
// Cache payload type and sampling frequency from most recent call to
@@ -702,6 +701,10 @@
configuration.rtcp_report_interval_ms = rtcp_report_interval_ms;
configuration.local_media_ssrc = ssrc;
+ if (media_transport_config_.media_transport) {
+ rtc::CritScope cs(&media_transport_lock_);
+ media_transport_channel_id_ = ssrc;
+ }
_rtpRtcpModule = RtpRtcp::Create(configuration);
_rtpRtcpModule->SetSendingMediaStatus(false);
@@ -951,17 +954,6 @@
payload_frequency, 0, 0);
}
-void ChannelSend::SetLocalSSRC(uint32_t ssrc) {
- RTC_DCHECK_RUN_ON(&worker_thread_checker_);
- RTC_DCHECK(!sending_);
-
- if (media_transport_config_.media_transport) {
- rtc::CritScope cs(&media_transport_lock_);
- media_transport_channel_id_ = ssrc;
- }
- _rtpRtcpModule->SetSSRC(ssrc);
-}
-
void ChannelSend::SetRid(const std::string& rid,
int extension_id,
int repaired_extension_id) {
diff --git a/audio/channel_send.h b/audio/channel_send.h
index a9df5e7..575f71f 100644
--- a/audio/channel_send.h
+++ b/audio/channel_send.h
@@ -77,7 +77,6 @@
rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) = 0;
virtual void CallEncoder(rtc::FunctionView<void(AudioEncoder*)> modifier) = 0;
- virtual void SetLocalSSRC(uint32_t ssrc) = 0;
// Use 0 to indicate that the extension should not be registered.
virtual void SetRid(const std::string& rid,
int extension_id,
diff --git a/audio/mock_voe_channel_proxy.h b/audio/mock_voe_channel_proxy.h
index cf2fe88..e666bf2 100644
--- a/audio/mock_voe_channel_proxy.h
+++ b/audio/mock_voe_channel_proxy.h
@@ -28,7 +28,6 @@
class MockChannelReceive : public voe::ChannelReceiveInterface {
public:
- MOCK_METHOD1(SetLocalSSRC, void(uint32_t ssrc));
MOCK_METHOD2(SetNACKStatus, void(bool enable, int max_packets));
MOCK_METHOD1(RegisterReceiverCongestionControlObjects,
void(PacketRouter* packet_router));
@@ -83,7 +82,6 @@
int extension_id,
int repaired_extension_id));
MOCK_METHOD2(SetMid, void(const std::string& mid, int extension_id));
- MOCK_METHOD1(SetLocalSSRC, void(uint32_t ssrc));
MOCK_METHOD1(SetRTCP_CNAME, void(absl::string_view c_name));
MOCK_METHOD1(SetExtmapAllowMixed, void(bool extmap_allow_mixed));
MOCK_METHOD2(SetSendAudioLevelIndicationStatus, void(bool enable, int id));
diff --git a/media/engine/webrtc_voice_engine.cc b/media/engine/webrtc_voice_engine.cc
index 07be793..72976bf 100644
--- a/media/engine/webrtc_voice_engine.cc
+++ b/media/engine/webrtc_voice_engine.cc
@@ -1065,8 +1065,10 @@
void SetLocalSsrc(uint32_t local_ssrc) {
RTC_DCHECK(worker_thread_checker_.IsCurrent());
- config_.rtp.local_ssrc = local_ssrc;
- ReconfigureAudioReceiveStream();
+ if (local_ssrc != config_.rtp.local_ssrc) {
+ config_.rtp.local_ssrc = local_ssrc;
+ RecreateAudioReceiveStream();
+ }
}
void SetUseTransportCcAndRecreateStream(bool use_transport_cc,