Remove PeerConnection voice_channel/video_channel methods
These methods no longer work with Unified Plan and have been
replaced by iterating over RtpTransceivers to get all the
VoiceChannels and VideoChannels.
Bug: webrtc:8587
Change-Id: I66ec282ee9f7eb987c32e30957733c13c6cf45b8
Reviewed-on: https://webrtc-review.googlesource.com/55760
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22110}
diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc
index f32b478..b032043 100644
--- a/pc/peerconnection.cc
+++ b/pc/peerconnection.cc
@@ -2922,20 +2922,32 @@
std::unique_ptr<rtc::SSLCertificate>
PeerConnection::GetRemoteAudioSSLCertificate() {
- if (!voice_channel()) {
+ auto audio_transceiver = GetFirstAudioTransceiver();
+ if (!audio_transceiver || !audio_transceiver->internal()->channel()) {
return nullptr;
}
- return GetRemoteSSLCertificate(voice_channel()->transport_name());
+ return GetRemoteSSLCertificate(
+ audio_transceiver->internal()->channel()->transport_name());
}
std::unique_ptr<rtc::SSLCertChain>
PeerConnection::GetRemoteAudioSSLCertChain() {
- if (!voice_channel()) {
+ auto audio_transceiver = GetFirstAudioTransceiver();
+ if (!audio_transceiver || !audio_transceiver->internal()->channel()) {
return nullptr;
}
-
return transport_controller_->GetRemoteSSLCertChain(
- voice_channel()->transport_name());
+ audio_transceiver->internal()->channel()->transport_name());
+}
+
+rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
+PeerConnection::GetFirstAudioTransceiver() const {
+ for (auto transceiver : transceivers_) {
+ if (transceiver->media_type() == cricket::MEDIA_TYPE_AUDIO) {
+ return transceiver;
+ }
+ }
+ return nullptr;
}
bool PeerConnection::StartRtcEventLog(rtc::PlatformFile file,
@@ -3073,6 +3085,28 @@
}
}
+cricket::VoiceMediaChannel* PeerConnection::voice_media_channel() const {
+ RTC_DCHECK(!IsUnifiedPlan());
+ auto* voice_channel = static_cast<cricket::VoiceChannel*>(
+ GetAudioTransceiver()->internal()->channel());
+ if (voice_channel) {
+ return voice_channel->media_channel();
+ } else {
+ return nullptr;
+ }
+}
+
+cricket::VideoMediaChannel* PeerConnection::video_media_channel() const {
+ RTC_DCHECK(!IsUnifiedPlan());
+ auto* video_channel = static_cast<cricket::VideoChannel*>(
+ GetVideoTransceiver()->internal()->channel());
+ if (video_channel) {
+ return video_channel->media_channel();
+ } else {
+ return nullptr;
+ }
+}
+
void PeerConnection::CreateAudioReceiver(
MediaStreamInterface* stream,
const RtpSenderInfo& remote_sender_info) {
diff --git a/pc/peerconnection.h b/pc/peerconnection.h
index d788b1e..f1dc299 100644
--- a/pc/peerconnection.h
+++ b/pc/peerconnection.h
@@ -203,26 +203,6 @@
return initial_offerer_ && *initial_offerer_;
}
- cricket::VoiceChannel* voice_channel() const override {
- if (IsUnifiedPlan()) {
- // TODO(bugs.webrtc.org/8764): Change stats collection to work with
- // transceivers.
- return nullptr;
- }
- return static_cast<cricket::VoiceChannel*>(
- GetAudioTransceiver()->internal()->channel());
- }
-
- cricket::VideoChannel* video_channel() const override {
- if (IsUnifiedPlan()) {
- // TODO(bugs.webrtc.org/8764): Change stats collection to work with
- // transceivers.
- return nullptr;
- }
- return static_cast<cricket::VideoChannel*>(
- GetVideoTransceiver()->internal()->channel());
- }
-
std::vector<
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
GetTransceiversInternal() const override {
@@ -295,13 +275,10 @@
// Implements MessageHandler.
void OnMessage(rtc::Message* msg) override;
- cricket::VoiceMediaChannel* voice_media_channel() const {
- return voice_channel() ? voice_channel()->media_channel() : nullptr;
- }
-
- cricket::VideoMediaChannel* video_media_channel() const {
- return video_channel() ? video_channel()->media_channel() : nullptr;
- }
+ // Plan B helpers for getting the voice/video media channels for the single
+ // audio/video transceiver, if it exists.
+ cricket::VoiceMediaChannel* voice_media_channel() const;
+ cricket::VideoMediaChannel* video_media_channel() const;
std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>>
GetSendersInternal() const;
@@ -314,6 +291,9 @@
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
GetVideoTransceiver() const;
+ rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
+ GetFirstAudioTransceiver() const;
+
void CreateAudioReceiver(MediaStreamInterface* stream,
const RtpSenderInfo& remote_sender_info);
diff --git a/pc/peerconnectioninternal.h b/pc/peerconnectioninternal.h
index c276b3d..4bca65e 100644
--- a/pc/peerconnectioninternal.h
+++ b/pc/peerconnectioninternal.h
@@ -37,10 +37,6 @@
// Returns true if we were the initial offerer.
virtual bool initial_offerer() const = 0;
- // TODO(steveanton): Remove these and replace with GetTransceiversInternal.
- virtual cricket::VoiceChannel* voice_channel() const = 0;
- virtual cricket::VideoChannel* video_channel() const = 0;
-
virtual std::vector<
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
GetTransceiversInternal() const = 0;
diff --git a/pc/statscollector.cc b/pc/statscollector.cc
index 5154cbc..9a636b4 100644
--- a/pc/statscollector.cc
+++ b/pc/statscollector.cc
@@ -835,11 +835,21 @@
bwe_info.available_send_bandwidth = call_stats.send_bandwidth_bps;
bwe_info.available_recv_bandwidth = call_stats.recv_bandwidth_bps;
bwe_info.bucket_delay = call_stats.pacer_delay_ms;
+
// Fill in target encoder bitrate, actual encoder bitrate, rtx bitrate, etc.
// TODO(holmer): Also fill this in for audio.
- if (pc_->video_channel()) {
- pc_->video_channel()->FillBitrateInfo(&bwe_info);
+ for (auto transceiver : pc_->GetTransceiversInternal()) {
+ if (transceiver->media_type() != cricket::MEDIA_TYPE_VIDEO) {
+ continue;
+ }
+ auto* video_channel =
+ static_cast<cricket::VideoChannel*>(transceiver->internal()->channel());
+ if (!video_channel) {
+ continue;
+ }
+ video_channel->FillBitrateInfo(&bwe_info);
}
+
StatsReport::Id report_id(StatsReport::NewBandwidthEstimationId());
StatsReport* report = reports_.FindOrAddNew(report_id);
ExtractStats(bwe_info, stats_gathering_started_, report);
diff --git a/pc/test/fakepeerconnectionbase.h b/pc/test/fakepeerconnectionbase.h
index b1cee6d..99964cb 100644
--- a/pc/test/fakepeerconnectionbase.h
+++ b/pc/test/fakepeerconnectionbase.h
@@ -243,10 +243,6 @@
bool initial_offerer() const override { return false; }
- cricket::VoiceChannel* voice_channel() const override { return nullptr; }
-
- cricket::VideoChannel* video_channel() const override { return nullptr; }
-
std::vector<
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
GetTransceiversInternal() const override {
diff --git a/pc/test/fakepeerconnectionforstats.h b/pc/test/fakepeerconnectionforstats.h
index be8003e..c198d1d 100644
--- a/pc/test/fakepeerconnectionforstats.h
+++ b/pc/test/fakepeerconnectionforstats.h
@@ -241,14 +241,6 @@
rtc::Thread* signaling_thread() const override { return signaling_thread_; }
- cricket::VoiceChannel* voice_channel() const override {
- return voice_channel_.get();
- }
-
- cricket::VideoChannel* video_channel() const override {
- return video_channel_.get();
- }
-
std::vector<
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
GetTransceiversInternal() const override {