diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc index f32b478cc3..b032043206 100644 --- a/pc/peerconnection.cc +++ b/pc/peerconnection.cc @@ -2922,20 +2922,32 @@ void PeerConnection::SetAudioRecording(bool recording) { std::unique_ptr 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 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> +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 @@ void PeerConnection::OnMessage(rtc::Message* msg) { } } +cricket::VoiceMediaChannel* PeerConnection::voice_media_channel() const { + RTC_DCHECK(!IsUnifiedPlan()); + auto* voice_channel = static_cast( + 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( + 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 d788b1e76d..f1dc2996a8 100644 --- a/pc/peerconnection.h +++ b/pc/peerconnection.h @@ -203,26 +203,6 @@ class PeerConnection : public PeerConnectionInternal, 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( - 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( - GetVideoTransceiver()->internal()->channel()); - } - std::vector< rtc::scoped_refptr>> GetTransceiversInternal() const override { @@ -295,13 +275,10 @@ class PeerConnection : public PeerConnectionInternal, // 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>> GetSendersInternal() const; @@ -314,6 +291,9 @@ class PeerConnection : public PeerConnectionInternal, rtc::scoped_refptr> GetVideoTransceiver() const; + rtc::scoped_refptr> + GetFirstAudioTransceiver() const; + void CreateAudioReceiver(MediaStreamInterface* stream, const RtpSenderInfo& remote_sender_info); diff --git a/pc/peerconnectioninternal.h b/pc/peerconnectioninternal.h index c276b3d6b9..4bca65ee24 100644 --- a/pc/peerconnectioninternal.h +++ b/pc/peerconnectioninternal.h @@ -37,10 +37,6 @@ class PeerConnectionInternal : public PeerConnectionInterface { // 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>> GetTransceiversInternal() const = 0; diff --git a/pc/statscollector.cc b/pc/statscollector.cc index 5154cbc3e3..9a636b47b1 100644 --- a/pc/statscollector.cc +++ b/pc/statscollector.cc @@ -835,11 +835,21 @@ void StatsCollector::ExtractBweInfo() { 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(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 b1cee6d738..99964cbe2c 100644 --- a/pc/test/fakepeerconnectionbase.h +++ b/pc/test/fakepeerconnectionbase.h @@ -243,10 +243,6 @@ class FakePeerConnectionBase : public PeerConnectionInternal { 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>> GetTransceiversInternal() const override { diff --git a/pc/test/fakepeerconnectionforstats.h b/pc/test/fakepeerconnectionforstats.h index be8003e891..c198d1de5a 100644 --- a/pc/test/fakepeerconnectionforstats.h +++ b/pc/test/fakepeerconnectionforstats.h @@ -241,14 +241,6 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase { 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>> GetTransceiversInternal() const override {