diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc index 6f43576eec..165bfaffdd 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc @@ -257,26 +257,12 @@ int AudioReceiveStream::id() const { absl::optional AudioReceiveStream::GetInfo() const { RTC_DCHECK_RUN_ON(&module_process_thread_checker_); - Syncable::Info info; + absl::optional info = channel_proxy_->GetSyncInfo(); - RtpRtcp* rtp_rtcp = nullptr; - RtpReceiver* rtp_receiver = nullptr; - channel_proxy_->GetRtpRtcp(&rtp_rtcp, &rtp_receiver); - RTC_DCHECK(rtp_rtcp); - RTC_DCHECK(rtp_receiver); - - if (!rtp_receiver->GetLatestTimestamps( - &info.latest_received_capture_timestamp, - &info.latest_receive_time_ms)) { + if (!info) return absl::nullopt; - } - if (rtp_rtcp->RemoteNTP(&info.capture_time_ntp_secs, - &info.capture_time_ntp_frac, nullptr, nullptr, - &info.capture_time_source_clock) != 0) { - return absl::nullopt; - } - info.current_delay_ms = channel_proxy_->GetDelayEstimate(); + info->current_delay_ms = channel_proxy_->GetDelayEstimate(); return info; } diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index de1be2c36c..6df653add7 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -141,8 +141,7 @@ AudioSendStream::AudioSendStream( channel_proxy_->SetRtcEventLog(event_log_); channel_proxy_->SetRTCPStatus(true); - RtpReceiver* rtpReceiver = nullptr; // Unused, but required for call. - channel_proxy_->GetRtpRtcp(&rtp_rtcp_module_, &rtpReceiver); + rtp_rtcp_module_ = channel_proxy_->GetRtpRtcp(); RTC_DCHECK(rtp_rtcp_module_); ConfigureStream(this, config, true); diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc index 2341d4efcd..dba1f5c230 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc @@ -189,12 +189,9 @@ struct ConfigHelper { void SetupDefaultChannelProxy(bool audio_bwe_enabled) { EXPECT_TRUE(channel_proxy_ == nullptr); channel_proxy_ = new testing::StrictMock(); - EXPECT_CALL(*channel_proxy_, GetRtpRtcp(_, _)) - .WillRepeatedly(Invoke( - [this](RtpRtcp** rtp_rtcp_module, RtpReceiver** rtp_receiver) { - *rtp_rtcp_module = &this->rtp_rtcp_; - *rtp_receiver = nullptr; // Not deemed necessary for tests yet. - })); + EXPECT_CALL(*channel_proxy_, GetRtpRtcp()).WillRepeatedly(Invoke([this]() { + return &this->rtp_rtcp_; + })); EXPECT_CALL(*channel_proxy_, SetRTCPStatus(true)).Times(1); EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kSsrc)).Times(1); EXPECT_CALL(*channel_proxy_, SetRTCP_CNAME(StrEq(kCName))).Times(1); diff --git a/audio/channel.cc b/audio/channel.cc index 971d68b831..e0cb7c4277 100644 --- a/audio/channel.cc +++ b/audio/channel.cc @@ -1342,11 +1342,24 @@ int Channel::GetPlayoutTimestamp(unsigned int& timestamp) { return 0; } -int Channel::GetRtpRtcp(RtpRtcp** rtpRtcpModule, - RtpReceiver** rtp_receiver) const { - *rtpRtcpModule = _rtpRtcpModule.get(); - *rtp_receiver = rtp_receiver_.get(); - return 0; +RtpRtcp* Channel::GetRtpRtcp() const { + return _rtpRtcpModule.get(); +} + +absl::optional Channel::GetSyncInfo() const { + Syncable::Info info; + if (!rtp_receiver_->GetLatestTimestamps( + &info.latest_received_capture_timestamp, + &info.latest_receive_time_ms)) { + return absl::nullopt; + } + if (_rtpRtcpModule->RemoteNTP(&info.capture_time_ntp_secs, + &info.capture_time_ntp_frac, nullptr, nullptr, + &info.capture_time_source_clock) != 0) { + return absl::nullopt; + } + + return info; } void Channel::UpdatePlayoutTimestamp(bool rtcp) { diff --git a/audio/channel.h b/audio/channel.h index 9816e2928f..5ffd6b1153 100644 --- a/audio/channel.h +++ b/audio/channel.h @@ -22,6 +22,7 @@ #include "api/call/audio_sink.h" #include "api/call/transport.h" #include "audio/audio_level.h" +#include "call/syncable.h" #include "common_types.h" // NOLINT(build/include) #include "modules/audio_coding/include/audio_coding_module.h" #include "modules/audio_processing/rms_level.h" @@ -209,8 +210,12 @@ class Channel uint32_t GetDelayEstimate() const; int SetMinimumPlayoutDelay(int delayMs); int GetPlayoutTimestamp(unsigned int& timestamp); // NOLINT - int GetRtpRtcp(RtpRtcp** rtpRtcpModule, RtpReceiver** rtp_receiver) const; + // Used by AudioSendStream. + RtpRtcp* GetRtpRtcp() const; + + // Produces the transport-related timestamps; current_delay_ms is left unset. + absl::optional GetSyncInfo() const; // DTMF. int SendTelephoneEventOutband(int event, int duration_ms); int SetSendTelephoneEventPayloadType(int payload_type, int payload_frequency); diff --git a/audio/channel_proxy.cc b/audio/channel_proxy.cc index bac681f3b7..f034f07116 100644 --- a/audio/channel_proxy.cc +++ b/audio/channel_proxy.cc @@ -265,13 +265,14 @@ void ChannelProxy::DisassociateSendChannel() { channel_->SetAssociatedSendChannel(nullptr); } -void ChannelProxy::GetRtpRtcp(RtpRtcp** rtp_rtcp, - RtpReceiver** rtp_receiver) const { +RtpRtcp* ChannelProxy::GetRtpRtcp() const { RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); - RTC_DCHECK(rtp_rtcp); - RTC_DCHECK(rtp_receiver); - int error = channel_->GetRtpRtcp(rtp_rtcp, rtp_receiver); - RTC_DCHECK_EQ(0, error); + return channel_->GetRtpRtcp(); +} + +absl::optional ChannelProxy::GetSyncInfo() const { + RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); + return channel_->GetSyncInfo(); } uint32_t ChannelProxy::GetPlayoutTimestamp() const { diff --git a/audio/channel_proxy.h b/audio/channel_proxy.h index 00298512eb..6175d6cc31 100644 --- a/audio/channel_proxy.h +++ b/audio/channel_proxy.h @@ -108,7 +108,10 @@ class ChannelProxy : public RtpPacketSinkInterface { virtual void SetTransportOverhead(int transport_overhead_per_packet); virtual void AssociateSendChannel(const ChannelProxy& send_channel_proxy); virtual void DisassociateSendChannel(); - virtual void GetRtpRtcp(RtpRtcp** rtp_rtcp, RtpReceiver** rtp_receiver) const; + virtual RtpRtcp* GetRtpRtcp() const; + + // Produces the transport-related timestamps; current_delay_ms is left unset. + absl::optional GetSyncInfo() const; virtual uint32_t GetPlayoutTimestamp() const; virtual void SetMinimumPlayoutDelay(int delay_ms); virtual bool GetRecCodec(CodecInst* codec_inst) const; diff --git a/audio/mock_voe_channel_proxy.h b/audio/mock_voe_channel_proxy.h index 7396dd1840..e09373bf84 100644 --- a/audio/mock_voe_channel_proxy.h +++ b/audio/mock_voe_channel_proxy.h @@ -83,8 +83,7 @@ class MockVoEChannelProxy : public voe::ChannelProxy { MOCK_METHOD1(AssociateSendChannel, void(const ChannelProxy& send_channel_proxy)); MOCK_METHOD0(DisassociateSendChannel, void()); - MOCK_CONST_METHOD2(GetRtpRtcp, - void(RtpRtcp** rtp_rtcp, RtpReceiver** rtp_receiver)); + MOCK_CONST_METHOD0(GetRtpRtcp, RtpRtcp*()); MOCK_CONST_METHOD0(GetPlayoutTimestamp, uint32_t()); MOCK_METHOD1(SetMinimumPlayoutDelay, void(int delay_ms)); MOCK_CONST_METHOD1(GetRecCodec, bool(CodecInst* codec_inst));