From de6e1b4ffde48b8f646e7449a0bcabb2c77db76b Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Mon, 3 Jan 2022 22:43:54 +0000 Subject: [PATCH] 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 Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#35622} --- pc/channel.cc | 17 ++++------------- pc/channel.h | 6 +++--- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/pc/channel.cc b/pc/channel.cc index 032c7356f4..36900c4cfc 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -126,7 +126,6 @@ BaseChannel::BaseChannel(rtc::Thread* worker_thread, 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 @@ BaseChannel::~BaseChannel() { 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 @@ bool BaseChannel::SetPayloadTypeDemuxingEnabled_w(bool enabled) { // 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& streams, diff --git a/pc/channel.h b/pc/channel.h index 7f7cfb9b8e..452fe5a31a 100644 --- a/pc/channel.h +++ b/pc/channel.h @@ -122,7 +122,9 @@ class BaseChannel : public ChannelInterface, 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 @@ class BaseChannel : public ChannelInterface, rtc::Thread* const signaling_thread_; rtc::scoped_refptr alive_; - const std::string content_name_; - std::function on_first_packet_received_ RTC_GUARDED_BY(network_thread());