webrtc_m130/pc/track_media_info_map.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

293 lines
12 KiB
C++
Raw Normal View History

/*
* Copyright 2016 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "pc/track_media_info_map.h"
#include <cstdint>
Reland "Improve outbound-rtp statistics for simulcast" This reverts commit 9a925c9ce33a6ccdd11b545b11ba68e985c2a65d. Reason for revert: The original CL is updated in PS #2 to fix the googRtt issue which was that when the legacy sender stats were put in "aggregated_senders" we forgot to update rtt_ms the same way that we do it for "senders". Original change's description: > Revert "Improve outbound-rtp statistics for simulcast" > > This reverts commit da6cda839dac7d9d18eba8d365188fa94831e0b1. > > Reason for revert: Breaks googRtt in legacy getStats API > > Original change's description: > > Improve outbound-rtp statistics for simulcast > > > > Bug: webrtc:9547 > > Change-Id: Iec4eb976aa11ee743805425bedb77dcea7c2c9be > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168120 > > Reviewed-by: Sebastian Jansson <srte@webrtc.org> > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Commit-Queue: Eldar Rello <elrello@microsoft.com> > > Cr-Commit-Position: refs/heads/master@{#31097} > > TBR=hbos@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,srte@webrtc.org,hta@webrtc.org,elrello@microsoft.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: webrtc:9547 > Change-Id: I06673328c2a5293a7eef03b3aaf2ded9d13df1b3 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174443 > Reviewed-by: Henrik Boström <hbos@webrtc.org> > Commit-Queue: Henrik Boström <hbos@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#31165} TBR=hbos@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,srte@webrtc.org,hta@webrtc.org,elrello@microsoft.com # Not skipping CQ checks because this is a reland. Bug: webrtc:9547 Change-Id: I723744c496c3c65f95ab6a8940862c8b9f544338 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174480 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31169}
2020-05-05 15:54:46 +02:00
#include <set>
#include <type_traits>
#include <utility>
#include "api/media_types.h"
#include "api/rtp_parameters.h"
#include "media/base/stream_params.h"
#include "rtc_base/checks.h"
#include "rtc_base/thread.h"
namespace webrtc {
namespace {
template <typename K, typename V>
V FindValueOrNull(const std::map<K, V>& map, const K& key) {
auto it = map.find(key);
return (it != map.end()) ? it->second : nullptr;
}
template <typename K, typename V>
const V* FindAddressOrNull(const std::map<K, V>& map, const K& key) {
auto it = map.find(key);
return (it != map.end()) ? &it->second : nullptr;
}
void GetAudioAndVideoTrackBySsrc(
const std::vector<rtc::scoped_refptr<RtpSenderInternal>>& rtp_senders,
const std::vector<rtc::scoped_refptr<RtpReceiverInternal>>& rtp_receivers,
std::map<uint32_t, AudioTrackInterface*>* local_audio_track_by_ssrc,
std::map<uint32_t, VideoTrackInterface*>* local_video_track_by_ssrc,
std::map<uint32_t, AudioTrackInterface*>* remote_audio_track_by_ssrc,
std::map<uint32_t, VideoTrackInterface*>* remote_video_track_by_ssrc,
AudioTrackInterface** unsignaled_audio_track,
VideoTrackInterface** unsignaled_video_track) {
RTC_DCHECK(local_audio_track_by_ssrc->empty());
RTC_DCHECK(local_video_track_by_ssrc->empty());
RTC_DCHECK(remote_audio_track_by_ssrc->empty());
RTC_DCHECK(remote_video_track_by_ssrc->empty());
for (const auto& rtp_sender : rtp_senders) {
cricket::MediaType media_type = rtp_sender->media_type();
MediaStreamTrackInterface* track = rtp_sender->track();
if (!track) {
continue;
}
Reland "Use backticks not vertical bars to denote variables in comments for /pc" Original change's description: > Revert "Use backticks not vertical bars to denote variables in comments for /pc" > > This reverts commit 37ee0f5e594dd772ec6d620b5e5ea8a751b684f0. > > Reason for revert: Revert in order to be able to revert https://webrtc-review.googlesource.com/c/src/+/225642 > > Original change's description: > > Use backticks not vertical bars to denote variables in comments for /pc > > > > Bug: webrtc:12338 > > Change-Id: I88cf10afa5fc810b95d2a585ab2e895dcc163b63 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226953 > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Commit-Queue: Artem Titov <titovartem@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#34575} > > TBR=hta@webrtc.org,titovartem@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com > > Change-Id: I5eddd3a14e1f664bf831e5c294fbc4de5f6a88af > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:12338 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227082 > Reviewed-by: Björn Terelius <terelius@webrtc.org> > Commit-Queue: Björn Terelius <terelius@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#34577} Bug: webrtc:12338 Change-Id: I96bd229b73613c162d11d75fa4f5934e1b4295c7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227087 Commit-Queue: Artem Titov <titovartem@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34611}
2021-07-30 22:30:23 +02:00
// TODO(deadbeef): `ssrc` should be removed in favor of `GetParameters`.
uint32_t ssrc = rtp_sender->ssrc();
if (ssrc != 0) {
if (media_type == cricket::MEDIA_TYPE_AUDIO) {
RTC_DCHECK(local_audio_track_by_ssrc->find(ssrc) ==
local_audio_track_by_ssrc->end());
(*local_audio_track_by_ssrc)[ssrc] =
static_cast<AudioTrackInterface*>(track);
} else {
RTC_DCHECK(local_video_track_by_ssrc->find(ssrc) ==
local_video_track_by_ssrc->end());
(*local_video_track_by_ssrc)[ssrc] =
static_cast<VideoTrackInterface*>(track);
}
}
}
for (const auto& rtp_receiver : rtp_receivers) {
cricket::MediaType media_type = rtp_receiver->media_type();
MediaStreamTrackInterface* track = rtp_receiver->track();
RTC_DCHECK(track);
RtpParameters params = rtp_receiver->GetParameters();
for (const RtpEncodingParameters& encoding : params.encodings) {
if (!encoding.ssrc) {
if (media_type == cricket::MEDIA_TYPE_AUDIO) {
*unsignaled_audio_track = static_cast<AudioTrackInterface*>(track);
} else {
RTC_DCHECK(media_type == cricket::MEDIA_TYPE_VIDEO);
*unsignaled_video_track = static_cast<VideoTrackInterface*>(track);
}
continue;
}
if (media_type == cricket::MEDIA_TYPE_AUDIO) {
RTC_DCHECK(remote_audio_track_by_ssrc->find(*encoding.ssrc) ==
remote_audio_track_by_ssrc->end());
(*remote_audio_track_by_ssrc)[*encoding.ssrc] =
static_cast<AudioTrackInterface*>(track);
} else {
RTC_DCHECK(remote_video_track_by_ssrc->find(*encoding.ssrc) ==
remote_video_track_by_ssrc->end());
(*remote_video_track_by_ssrc)[*encoding.ssrc] =
static_cast<VideoTrackInterface*>(track);
}
}
}
}
} // namespace
TrackMediaInfoMap::TrackMediaInfoMap(
std::unique_ptr<cricket::VoiceMediaInfo> voice_media_info,
std::unique_ptr<cricket::VideoMediaInfo> video_media_info,
const std::vector<rtc::scoped_refptr<RtpSenderInternal>>& rtp_senders,
const std::vector<rtc::scoped_refptr<RtpReceiverInternal>>& rtp_receivers)
: voice_media_info_(std::move(voice_media_info)),
video_media_info_(std::move(video_media_info)) {
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
std::map<uint32_t, AudioTrackInterface*> local_audio_track_by_ssrc;
std::map<uint32_t, VideoTrackInterface*> local_video_track_by_ssrc;
std::map<uint32_t, AudioTrackInterface*> remote_audio_track_by_ssrc;
std::map<uint32_t, VideoTrackInterface*> remote_video_track_by_ssrc;
AudioTrackInterface* unsignaled_audio_track = nullptr;
VideoTrackInterface* unsignaled_video_track = nullptr;
GetAudioAndVideoTrackBySsrc(
rtp_senders, rtp_receivers, &local_audio_track_by_ssrc,
&local_video_track_by_ssrc, &remote_audio_track_by_ssrc,
&remote_video_track_by_ssrc, &unsignaled_audio_track,
&unsignaled_video_track);
for (const auto& sender : rtp_senders) {
attachment_id_by_track_[sender->track()] = sender->AttachmentId();
}
for (const auto& receiver : rtp_receivers) {
attachment_id_by_track_[receiver->track()] = receiver->AttachmentId();
}
if (voice_media_info_) {
for (auto& sender_info : voice_media_info_->senders) {
AudioTrackInterface* associated_track =
FindValueOrNull(local_audio_track_by_ssrc, sender_info.ssrc());
if (associated_track) {
// One sender is associated with at most one track.
// One track may be associated with multiple senders.
audio_track_by_sender_info_[&sender_info] = associated_track;
voice_infos_by_local_track_[associated_track].push_back(&sender_info);
}
if (sender_info.ssrc() == 0)
continue; // Unconnected SSRC. bugs.webrtc.org/8673
RTC_CHECK(voice_info_by_sender_ssrc_.count(sender_info.ssrc()) == 0)
<< "Duplicate voice sender SSRC: " << sender_info.ssrc();
voice_info_by_sender_ssrc_[sender_info.ssrc()] = &sender_info;
}
for (auto& receiver_info : voice_media_info_->receivers) {
AudioTrackInterface* associated_track =
FindValueOrNull(remote_audio_track_by_ssrc, receiver_info.ssrc());
if (associated_track) {
// One receiver is associated with at most one track, which is uniquely
// associated with that receiver.
audio_track_by_receiver_info_[&receiver_info] = associated_track;
RTC_DCHECK(voice_info_by_remote_track_.find(associated_track) ==
voice_info_by_remote_track_.end());
voice_info_by_remote_track_[associated_track] = &receiver_info;
} else if (unsignaled_audio_track) {
audio_track_by_receiver_info_[&receiver_info] = unsignaled_audio_track;
voice_info_by_remote_track_[unsignaled_audio_track] = &receiver_info;
}
RTC_CHECK(voice_info_by_receiver_ssrc_.count(receiver_info.ssrc()) == 0)
<< "Duplicate voice receiver SSRC: " << receiver_info.ssrc();
voice_info_by_receiver_ssrc_[receiver_info.ssrc()] = &receiver_info;
}
}
if (video_media_info_) {
for (auto& sender_info : video_media_info_->senders) {
Reland "Improve outbound-rtp statistics for simulcast" This reverts commit 9a925c9ce33a6ccdd11b545b11ba68e985c2a65d. Reason for revert: The original CL is updated in PS #2 to fix the googRtt issue which was that when the legacy sender stats were put in "aggregated_senders" we forgot to update rtt_ms the same way that we do it for "senders". Original change's description: > Revert "Improve outbound-rtp statistics for simulcast" > > This reverts commit da6cda839dac7d9d18eba8d365188fa94831e0b1. > > Reason for revert: Breaks googRtt in legacy getStats API > > Original change's description: > > Improve outbound-rtp statistics for simulcast > > > > Bug: webrtc:9547 > > Change-Id: Iec4eb976aa11ee743805425bedb77dcea7c2c9be > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168120 > > Reviewed-by: Sebastian Jansson <srte@webrtc.org> > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Commit-Queue: Eldar Rello <elrello@microsoft.com> > > Cr-Commit-Position: refs/heads/master@{#31097} > > TBR=hbos@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,srte@webrtc.org,hta@webrtc.org,elrello@microsoft.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: webrtc:9547 > Change-Id: I06673328c2a5293a7eef03b3aaf2ded9d13df1b3 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174443 > Reviewed-by: Henrik Boström <hbos@webrtc.org> > Commit-Queue: Henrik Boström <hbos@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#31165} TBR=hbos@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,srte@webrtc.org,hta@webrtc.org,elrello@microsoft.com # Not skipping CQ checks because this is a reland. Bug: webrtc:9547 Change-Id: I723744c496c3c65f95ab6a8940862c8b9f544338 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174480 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31169}
2020-05-05 15:54:46 +02:00
std::set<uint32_t> ssrcs;
ssrcs.insert(sender_info.ssrc());
for (auto& ssrc_group : sender_info.ssrc_groups) {
for (auto ssrc : ssrc_group.ssrcs) {
ssrcs.insert(ssrc);
}
}
Reland "Improve outbound-rtp statistics for simulcast" This reverts commit 9a925c9ce33a6ccdd11b545b11ba68e985c2a65d. Reason for revert: The original CL is updated in PS #2 to fix the googRtt issue which was that when the legacy sender stats were put in "aggregated_senders" we forgot to update rtt_ms the same way that we do it for "senders". Original change's description: > Revert "Improve outbound-rtp statistics for simulcast" > > This reverts commit da6cda839dac7d9d18eba8d365188fa94831e0b1. > > Reason for revert: Breaks googRtt in legacy getStats API > > Original change's description: > > Improve outbound-rtp statistics for simulcast > > > > Bug: webrtc:9547 > > Change-Id: Iec4eb976aa11ee743805425bedb77dcea7c2c9be > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168120 > > Reviewed-by: Sebastian Jansson <srte@webrtc.org> > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Commit-Queue: Eldar Rello <elrello@microsoft.com> > > Cr-Commit-Position: refs/heads/master@{#31097} > > TBR=hbos@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,srte@webrtc.org,hta@webrtc.org,elrello@microsoft.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: webrtc:9547 > Change-Id: I06673328c2a5293a7eef03b3aaf2ded9d13df1b3 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174443 > Reviewed-by: Henrik Boström <hbos@webrtc.org> > Commit-Queue: Henrik Boström <hbos@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#31165} TBR=hbos@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,srte@webrtc.org,hta@webrtc.org,elrello@microsoft.com # Not skipping CQ checks because this is a reland. Bug: webrtc:9547 Change-Id: I723744c496c3c65f95ab6a8940862c8b9f544338 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174480 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31169}
2020-05-05 15:54:46 +02:00
for (auto ssrc : ssrcs) {
VideoTrackInterface* associated_track =
FindValueOrNull(local_video_track_by_ssrc, ssrc);
if (associated_track) {
// One sender is associated with at most one track.
// One track may be associated with multiple senders.
video_track_by_sender_info_[&sender_info] = associated_track;
video_infos_by_local_track_[associated_track].push_back(&sender_info);
break;
}
}
}
for (auto& sender_info : video_media_info_->aggregated_senders) {
if (sender_info.ssrc() == 0)
continue; // Unconnected SSRC. bugs.webrtc.org/8673
RTC_DCHECK(video_info_by_sender_ssrc_.count(sender_info.ssrc()) == 0)
<< "Duplicate video sender SSRC: " << sender_info.ssrc();
video_info_by_sender_ssrc_[sender_info.ssrc()] = &sender_info;
Reland "Improve outbound-rtp statistics for simulcast" This reverts commit 9a925c9ce33a6ccdd11b545b11ba68e985c2a65d. Reason for revert: The original CL is updated in PS #2 to fix the googRtt issue which was that when the legacy sender stats were put in "aggregated_senders" we forgot to update rtt_ms the same way that we do it for "senders". Original change's description: > Revert "Improve outbound-rtp statistics for simulcast" > > This reverts commit da6cda839dac7d9d18eba8d365188fa94831e0b1. > > Reason for revert: Breaks googRtt in legacy getStats API > > Original change's description: > > Improve outbound-rtp statistics for simulcast > > > > Bug: webrtc:9547 > > Change-Id: Iec4eb976aa11ee743805425bedb77dcea7c2c9be > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168120 > > Reviewed-by: Sebastian Jansson <srte@webrtc.org> > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Commit-Queue: Eldar Rello <elrello@microsoft.com> > > Cr-Commit-Position: refs/heads/master@{#31097} > > TBR=hbos@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,srte@webrtc.org,hta@webrtc.org,elrello@microsoft.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: webrtc:9547 > Change-Id: I06673328c2a5293a7eef03b3aaf2ded9d13df1b3 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174443 > Reviewed-by: Henrik Boström <hbos@webrtc.org> > Commit-Queue: Henrik Boström <hbos@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#31165} TBR=hbos@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,srte@webrtc.org,hta@webrtc.org,elrello@microsoft.com # Not skipping CQ checks because this is a reland. Bug: webrtc:9547 Change-Id: I723744c496c3c65f95ab6a8940862c8b9f544338 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174480 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31169}
2020-05-05 15:54:46 +02:00
VideoTrackInterface* associated_track =
FindValueOrNull(local_video_track_by_ssrc, sender_info.ssrc());
if (associated_track) {
video_track_by_sender_info_[&sender_info] = associated_track;
}
}
for (auto& receiver_info : video_media_info_->receivers) {
VideoTrackInterface* associated_track =
FindValueOrNull(remote_video_track_by_ssrc, receiver_info.ssrc());
if (associated_track) {
// One receiver is associated with at most one track, which is uniquely
// associated with that receiver.
video_track_by_receiver_info_[&receiver_info] = associated_track;
RTC_DCHECK(video_info_by_remote_track_.find(associated_track) ==
video_info_by_remote_track_.end());
video_info_by_remote_track_[associated_track] = &receiver_info;
} else if (unsignaled_video_track) {
video_track_by_receiver_info_[&receiver_info] = unsignaled_video_track;
video_info_by_remote_track_[unsignaled_video_track] = &receiver_info;
}
RTC_DCHECK(video_info_by_receiver_ssrc_.count(receiver_info.ssrc()) == 0)
<< "Duplicate video receiver SSRC: " << receiver_info.ssrc();
video_info_by_receiver_ssrc_[receiver_info.ssrc()] = &receiver_info;
}
}
}
const std::vector<cricket::VoiceSenderInfo*>*
TrackMediaInfoMap::GetVoiceSenderInfos(
const AudioTrackInterface& local_audio_track) const {
return FindAddressOrNull(voice_infos_by_local_track_, &local_audio_track);
}
const cricket::VoiceReceiverInfo* TrackMediaInfoMap::GetVoiceReceiverInfo(
const AudioTrackInterface& remote_audio_track) const {
return FindValueOrNull(voice_info_by_remote_track_, &remote_audio_track);
}
const std::vector<cricket::VideoSenderInfo*>*
TrackMediaInfoMap::GetVideoSenderInfos(
const VideoTrackInterface& local_video_track) const {
return FindAddressOrNull(video_infos_by_local_track_, &local_video_track);
}
const cricket::VideoReceiverInfo* TrackMediaInfoMap::GetVideoReceiverInfo(
const VideoTrackInterface& remote_video_track) const {
return FindValueOrNull(video_info_by_remote_track_, &remote_video_track);
}
const cricket::VoiceSenderInfo* TrackMediaInfoMap::GetVoiceSenderInfoBySsrc(
uint32_t ssrc) const {
return FindValueOrNull(voice_info_by_sender_ssrc_, ssrc);
}
const cricket::VoiceReceiverInfo* TrackMediaInfoMap::GetVoiceReceiverInfoBySsrc(
uint32_t ssrc) const {
return FindValueOrNull(voice_info_by_receiver_ssrc_, ssrc);
}
const cricket::VideoSenderInfo* TrackMediaInfoMap::GetVideoSenderInfoBySsrc(
uint32_t ssrc) const {
return FindValueOrNull(video_info_by_sender_ssrc_, ssrc);
}
const cricket::VideoReceiverInfo* TrackMediaInfoMap::GetVideoReceiverInfoBySsrc(
uint32_t ssrc) const {
return FindValueOrNull(video_info_by_receiver_ssrc_, ssrc);
}
rtc::scoped_refptr<AudioTrackInterface> TrackMediaInfoMap::GetAudioTrack(
const cricket::VoiceSenderInfo& voice_sender_info) const {
return FindValueOrNull(audio_track_by_sender_info_, &voice_sender_info);
}
rtc::scoped_refptr<AudioTrackInterface> TrackMediaInfoMap::GetAudioTrack(
const cricket::VoiceReceiverInfo& voice_receiver_info) const {
return FindValueOrNull(audio_track_by_receiver_info_, &voice_receiver_info);
}
rtc::scoped_refptr<VideoTrackInterface> TrackMediaInfoMap::GetVideoTrack(
const cricket::VideoSenderInfo& video_sender_info) const {
return FindValueOrNull(video_track_by_sender_info_, &video_sender_info);
}
rtc::scoped_refptr<VideoTrackInterface> TrackMediaInfoMap::GetVideoTrack(
const cricket::VideoReceiverInfo& video_receiver_info) const {
return FindValueOrNull(video_track_by_receiver_info_, &video_receiver_info);
}
absl::optional<int> TrackMediaInfoMap::GetAttachmentIdByTrack(
const MediaStreamTrackInterface* track) const {
auto it = attachment_id_by_track_.find(track);
return it != attachment_id_by_track_.end() ? absl::optional<int>(it->second)
: absl::nullopt;
}
} // namespace webrtc