Skip to content

Commit

Permalink
Change Channel::GetRtpRtcp to return only RtpRtcp, not RtpReceiver.
Browse files Browse the repository at this point in the history
For use in AudiReceiveStream, introduce a new method GetSyncInfo. This
change is analogous to https://webrtc-review.googlesource.com/91123,
doing the same for RtpVideoStreamReceiver. It's a preparation for
bypassing the RtpReceiver class.

Bug: webrtc:7135
Change-Id: I87c1c6f0a1f28b0baebe07c4181f6f0427afa314
Reviewed-on: https://webrtc-review.googlesource.com/93022
Reviewed-by: Oskar Sundbom <[email protected]>
Commit-Queue: Niels Moller <[email protected]>
Cr-Commit-Position: refs/heads/master@{#24228}
  • Loading branch information
Niels Möller authored and Commit Bot committed Aug 8, 2018
1 parent 43fa99c commit 848d6d3
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 40 deletions.
20 changes: 3 additions & 17 deletions audio/audio_receive_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,26 +257,12 @@ int AudioReceiveStream::id() const {

absl::optional<Syncable::Info> AudioReceiveStream::GetInfo() const {
RTC_DCHECK_RUN_ON(&module_process_thread_checker_);
Syncable::Info info;
absl::optional<Syncable::Info> 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)) {
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) {
if (!info)
return absl::nullopt;
}

info.current_delay_ms = channel_proxy_->GetDelayEstimate();
info->current_delay_ms = channel_proxy_->GetDelayEstimate();
return info;
}

Expand Down
3 changes: 1 addition & 2 deletions audio/audio_send_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 3 additions & 6 deletions audio/audio_send_stream_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,9 @@ struct ConfigHelper {
void SetupDefaultChannelProxy(bool audio_bwe_enabled) {
EXPECT_TRUE(channel_proxy_ == nullptr);
channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>();
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);
Expand Down
23 changes: 18 additions & 5 deletions audio/channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Syncable::Info> 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) {
Expand Down
7 changes: 6 additions & 1 deletion audio/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<Syncable::Info> GetSyncInfo() const;
// DTMF.
int SendTelephoneEventOutband(int event, int duration_ms);
int SetSendTelephoneEventPayloadType(int payload_type, int payload_frequency);
Expand Down
13 changes: 7 additions & 6 deletions audio/channel_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Syncable::Info> ChannelProxy::GetSyncInfo() const {
RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
return channel_->GetSyncInfo();
}

uint32_t ChannelProxy::GetPlayoutTimestamp() const {
Expand Down
5 changes: 4 additions & 1 deletion audio/channel_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Syncable::Info> GetSyncInfo() const;
virtual uint32_t GetPlayoutTimestamp() const;
virtual void SetMinimumPlayoutDelay(int delay_ms);
virtual bool GetRecCodec(CodecInst* codec_inst) const;
Expand Down
3 changes: 1 addition & 2 deletions audio/mock_voe_channel_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 848d6d3

Please sign in to comment.