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}
This commit is contained in:
Tomas Gunnarsson
2022-01-03 22:43:54 +00:00
committed by WebRTC LUCI CQ
parent 7df775a3ed
commit de6e1b4ffd
2 changed files with 7 additions and 16 deletions

View File

@ -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<StreamParams>& streams,

View File

@ -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<webrtc::PendingTaskSafetyFlag> alive_;
const std::string content_name_;
std::function<void()> on_first_packet_received_
RTC_GUARDED_BY(network_thread());