Use demuxer_criteria_.mid() for content_name() in BaseChannel.
BaseChannel::content_name() is consistently used as the mid throughout
the code and the mid is stored in the demuxer criteria. Furthermore
there's a chance that the two variables might not be in sync if the
mid needs to be truncated, so it's better to use one source of truth.
Bug: webrtc:11993, webrtc:12230
Change-Id: Ia98443d8ee65fd0795651981acab27c29428ba0c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244092
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35622}
diff --git a/pc/channel.cc b/pc/channel.cc
index 032c735..36900c4 100644
--- a/pc/channel.cc
+++ b/pc/channel.cc
@@ -126,7 +126,6 @@
network_thread_(network_thread),
signaling_thread_(signaling_thread),
alive_(PendingTaskSafetyFlag::Create()),
- content_name_(content_name),
srtp_required_(srtp_required),
crypto_options_(crypto_options),
media_channel_(std::move(media_channel)),
@@ -150,7 +149,7 @@
std::string BaseChannel::ToString() const {
rtc::StringBuilder sb;
- sb << "{mid: " << content_name_;
+ sb << "{mid: " << content_name();
if (media_channel_) {
sb << ", media_type: " << MediaTypeToString(media_channel_->media_type());
}
@@ -595,23 +594,15 @@
// there is no straightforward way to identify those streams.
media_channel()->ResetUnsignaledRecvStream();
demuxer_criteria_.payload_types().clear();
- if (!RegisterRtpDemuxerSink_w()) {
- RTC_LOG(LS_ERROR) << "Failed to disable payload type demuxing for "
- << ToString();
- return false;
- }
} else if (!payload_types_.empty()) {
// TODO(tommi): Instead of 'insert', should this simply overwrite the value
// of the criteria?
demuxer_criteria_.payload_types().insert(payload_types_.begin(),
payload_types_.end());
- if (!RegisterRtpDemuxerSink_w()) {
- RTC_LOG(LS_ERROR) << "Failed to enable payload type demuxing for "
- << ToString();
- return false;
- }
}
- return true;
+
+ // Note: This synchronously hops to the network thread.
+ return RegisterRtpDemuxerSink_w();
}
bool BaseChannel::UpdateLocalStreams_w(const std::vector<StreamParams>& streams,
diff --git a/pc/channel.h b/pc/channel.h
index 7f7cfb9..452fe5a 100644
--- a/pc/channel.h
+++ b/pc/channel.h
@@ -122,7 +122,9 @@
rtc::Thread* worker_thread() const { return worker_thread_; }
rtc::Thread* network_thread() const { return network_thread_; }
- const std::string& content_name() const override { return content_name_; }
+ const std::string& content_name() const override {
+ return demuxer_criteria_.mid();
+ }
// TODO(deadbeef): This is redundant; remove this.
absl::string_view transport_name() const override {
RTC_DCHECK_RUN_ON(network_thread());
@@ -298,8 +300,6 @@
rtc::Thread* const signaling_thread_;
rtc::scoped_refptr<webrtc::PendingTaskSafetyFlag> alive_;
- const std::string content_name_;
-
std::function<void()> on_first_packet_received_
RTC_GUARDED_BY(network_thread());