Tweak ChannelReceive interface, to make it closer to ChannelReceiveProxy

This is a preparation for deleting ChannelReceiveProxy, Changes
signature of some methods, and demotes methods OnData and
OnReceivedPayloadData to private.

Bug: webrtc:9801
Change-Id: Ib00a80c6482ed5238f3cc8233860c70f11484df9
Reviewed-on: https://webrtc-review.googlesource.com/c/110606
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25599}
This commit is contained in:
Niels Möller
2018-11-12 13:22:47 +01:00
committed by Commit Bot
parent 140b1d94dc
commit 80c6762a37
3 changed files with 56 additions and 82 deletions

View File

@ -372,29 +372,25 @@ void ChannelReceive::SetSink(AudioSinkInterface* sink) {
audio_sink_ = sink; audio_sink_ = sink;
} }
int32_t ChannelReceive::StartPlayout() { void ChannelReceive::StartPlayout() {
if (channel_state_.Get().playing) { if (channel_state_.Get().playing) {
return 0; return;
} }
channel_state_.SetPlaying(true); channel_state_.SetPlaying(true);
return 0;
} }
int32_t ChannelReceive::StopPlayout() { void ChannelReceive::StopPlayout() {
if (!channel_state_.Get().playing) { if (!channel_state_.Get().playing) {
return 0; return;
} }
channel_state_.SetPlaying(false); channel_state_.SetPlaying(false);
_outputAudioLevel.Clear(); _outputAudioLevel.Clear();
return 0;
} }
int32_t ChannelReceive::GetRecCodec(CodecInst& codec) { bool ChannelReceive::GetRecCodec(CodecInst* codec) {
return (audio_coding_->ReceiveCodec(&codec)); return (audio_coding_->ReceiveCodec(codec) == 0);
} }
std::vector<webrtc::RtpSource> ChannelReceive::GetSources() const { std::vector<webrtc::RtpSource> ChannelReceive::GetSources() const {
@ -513,7 +509,8 @@ bool ChannelReceive::ReceivePacket(const uint8_t* packet,
&webrtc_rtp_header); &webrtc_rtp_header);
} }
int32_t ChannelReceive::ReceivedRTCPPacket(const uint8_t* data, size_t length) { // TODO(nisse): Drop always-true return value.
bool ChannelReceive::ReceivedRTCPPacket(const uint8_t* data, size_t length) {
// Store playout timestamp for the received RTCP packet // Store playout timestamp for the received RTCP packet
UpdatePlayoutTimestamp(true); UpdatePlayoutTimestamp(true);
@ -523,7 +520,7 @@ int32_t ChannelReceive::ReceivedRTCPPacket(const uint8_t* data, size_t length) {
int64_t rtt = GetRTT(); int64_t rtt = GetRTT();
if (rtt == 0) { if (rtt == 0) {
// Waiting for valid RTT. // Waiting for valid RTT.
return 0; return true;
} }
int64_t nack_window_ms = rtt; int64_t nack_window_ms = rtt;
@ -539,14 +536,14 @@ int32_t ChannelReceive::ReceivedRTCPPacket(const uint8_t* data, size_t length) {
if (0 != _rtpRtcpModule->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL, if (0 != _rtpRtcpModule->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL,
&rtp_timestamp)) { &rtp_timestamp)) {
// Waiting for RTCP. // Waiting for RTCP.
return 0; return true;
} }
{ {
rtc::CritScope lock(&ts_stats_lock_); rtc::CritScope lock(&ts_stats_lock_);
ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp);
} }
return 0; return true;
} }
int ChannelReceive::GetSpeechOutputLevelFullRange() const { int ChannelReceive::GetSpeechOutputLevelFullRange() const {
@ -566,9 +563,8 @@ void ChannelReceive::SetChannelOutputVolumeScaling(float scaling) {
_outputGain = scaling; _outputGain = scaling;
} }
int ChannelReceive::SetLocalSSRC(unsigned int ssrc) { void ChannelReceive::SetLocalSSRC(unsigned int ssrc) {
_rtpRtcpModule->SetSSRC(ssrc); _rtpRtcpModule->SetSSRC(ssrc);
return 0;
} }
// TODO(nisse): Pass ssrc in return value instead. // TODO(nisse): Pass ssrc in return value instead.
@ -592,8 +588,9 @@ void ChannelReceive::ResetReceiverCongestionControlObjects() {
packet_router_ = nullptr; packet_router_ = nullptr;
} }
int ChannelReceive::GetRTPStatistics(CallReceiveStatistics& stats) { CallReceiveStatistics ChannelReceive::GetRTCPStatistics() {
// --- RtcpStatistics // --- RtcpStatistics
CallReceiveStatistics stats;
// The jitter statistics is updated for each received RTP packet and is // The jitter statistics is updated for each received RTP packet and is
// based on received packets. // based on received packets.
@ -630,7 +627,7 @@ int ChannelReceive::GetRTPStatistics(CallReceiveStatistics& stats) {
rtc::CritScope lock(&ts_stats_lock_); rtc::CritScope lock(&ts_stats_lock_);
stats.capture_start_ntp_time_ms_ = capture_start_ntp_time_ms_; stats.capture_start_ntp_time_ms_ = capture_start_ntp_time_ms_;
} }
return 0; return stats;
} }
void ChannelReceive::SetNACKStatus(bool enable, int maxNumberOfPackets) { void ChannelReceive::SetNACKStatus(bool enable, int maxNumberOfPackets) {
@ -653,13 +650,17 @@ void ChannelReceive::SetAssociatedSendChannel(ChannelSend* channel) {
associated_send_channel_ = channel; associated_send_channel_ = channel;
} }
int ChannelReceive::GetNetworkStatistics(NetworkStatistics& stats) { NetworkStatistics ChannelReceive::GetNetworkStatistics() const {
return audio_coding_->GetNetworkStatistics(&stats); NetworkStatistics stats;
int error = audio_coding_->GetNetworkStatistics(&stats);
RTC_DCHECK_EQ(0, error);
return stats;
} }
void ChannelReceive::GetDecodingCallStatistics( AudioDecodingCallStats ChannelReceive::GetDecodingCallStatistics() const {
AudioDecodingCallStats* stats) const { AudioDecodingCallStats stats;
audio_coding_->GetDecodingCallStatistics(stats); audio_coding_->GetDecodingCallStatistics(&stats);
return stats;
} }
uint32_t ChannelReceive::GetDelayEstimate() const { uint32_t ChannelReceive::GetDelayEstimate() const {
@ -667,32 +668,23 @@ uint32_t ChannelReceive::GetDelayEstimate() const {
return audio_coding_->FilteredCurrentDelayMs() + playout_delay_ms_; return audio_coding_->FilteredCurrentDelayMs() + playout_delay_ms_;
} }
int ChannelReceive::SetMinimumPlayoutDelay(int delayMs) { void ChannelReceive::SetMinimumPlayoutDelay(int delayMs) {
if ((delayMs < kVoiceEngineMinMinPlayoutDelayMs) || if ((delayMs < kVoiceEngineMinMinPlayoutDelayMs) ||
(delayMs > kVoiceEngineMaxMinPlayoutDelayMs)) { (delayMs > kVoiceEngineMaxMinPlayoutDelayMs)) {
RTC_DLOG(LS_ERROR) << "SetMinimumPlayoutDelay() invalid min delay"; RTC_DLOG(LS_ERROR) << "SetMinimumPlayoutDelay() invalid min delay";
return -1; return;
} }
if (audio_coding_->SetMinimumPlayoutDelay(delayMs) != 0) { if (audio_coding_->SetMinimumPlayoutDelay(delayMs) != 0) {
RTC_DLOG(LS_ERROR) RTC_DLOG(LS_ERROR)
<< "SetMinimumPlayoutDelay() failed to set min playout delay"; << "SetMinimumPlayoutDelay() failed to set min playout delay";
return -1;
} }
return 0;
} }
int ChannelReceive::GetPlayoutTimestamp(unsigned int& timestamp) { uint32_t ChannelReceive::GetPlayoutTimestamp() {
uint32_t playout_timestamp_rtp = 0;
{ {
rtc::CritScope lock(&video_sync_lock_); rtc::CritScope lock(&video_sync_lock_);
playout_timestamp_rtp = playout_timestamp_rtp_; return playout_timestamp_rtp_;
} }
if (playout_timestamp_rtp == 0) {
RTC_DLOG(LS_ERROR) << "GetPlayoutTimestamp() failed to retrieve timestamp";
return -1;
}
timestamp = playout_timestamp_rtp;
return 0;
} }
absl::optional<Syncable::Info> ChannelReceive::GetSyncInfo() const { absl::optional<Syncable::Info> ChannelReceive::GetSyncInfo() const {

View File

@ -127,15 +127,14 @@ class ChannelReceive : public RtpData, public MediaTransportAudioSinkInterface {
// API methods // API methods
// VoEBase void StartPlayout();
int32_t StartPlayout(); void StopPlayout();
int32_t StopPlayout();
// Codecs // Codecs
int32_t GetRecCodec(CodecInst& codec); // NOLINT bool GetRecCodec(CodecInst* codec);
// TODO(nisse, solenberg): Delete when VoENetwork is deleted. // TODO(nisse, solenberg): Delete when VoENetwork is deleted.
int32_t ReceivedRTCPPacket(const uint8_t* data, size_t length); bool ReceivedRTCPPacket(const uint8_t* data, size_t length);
void OnRtpPacket(const RtpPacketReceived& packet); void OnRtpPacket(const RtpPacketReceived& packet);
// Muting, Volume and Level. // Muting, Volume and Level.
@ -147,35 +146,26 @@ class ChannelReceive : public RtpData, public MediaTransportAudioSinkInterface {
double GetTotalOutputDuration() const; double GetTotalOutputDuration() const;
// Stats. // Stats.
int GetNetworkStatistics(NetworkStatistics& stats); // NOLINT NetworkStatistics GetNetworkStatistics() const;
void GetDecodingCallStatistics(AudioDecodingCallStats* stats) const; AudioDecodingCallStats GetDecodingCallStatistics() const;
// Audio+Video Sync. // Audio+Video Sync.
uint32_t GetDelayEstimate() const; uint32_t GetDelayEstimate() const;
int SetMinimumPlayoutDelay(int delayMs); void SetMinimumPlayoutDelay(int delayMs);
int GetPlayoutTimestamp(unsigned int& timestamp); // NOLINT uint32_t GetPlayoutTimestamp();
// Produces the transport-related timestamps; current_delay_ms is left unset. // Produces the transport-related timestamps; current_delay_ms is left unset.
absl::optional<Syncable::Info> GetSyncInfo() const; absl::optional<Syncable::Info> GetSyncInfo() const;
// RTP+RTCP // RTP+RTCP
int SetLocalSSRC(unsigned int ssrc); void SetLocalSSRC(unsigned int ssrc);
void RegisterReceiverCongestionControlObjects(PacketRouter* packet_router); void RegisterReceiverCongestionControlObjects(PacketRouter* packet_router);
void ResetReceiverCongestionControlObjects(); void ResetReceiverCongestionControlObjects();
int GetRTPStatistics(CallReceiveStatistics& stats); // NOLINT CallReceiveStatistics GetRTCPStatistics();
void SetNACKStatus(bool enable, int maxNumberOfPackets); void SetNACKStatus(bool enable, int maxNumberOfPackets);
// MediaTransportAudioSinkInterface override;
void OnData(uint64_t channel_id,
MediaTransportEncodedAudioFrame frame) override;
// From RtpData in the RTP/RTCP module
int32_t OnReceivedPayloadData(const uint8_t* payloadData,
size_t payloadSize,
const WebRtcRTPHeader* rtpHeader) override;
// From AudioMixer::Source. // From AudioMixer::Source.
AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo( AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo(
int sample_rate_hz, int sample_rate_hz,
@ -204,6 +194,15 @@ class ChannelReceive : public RtpData, public MediaTransportAudioSinkInterface {
int GetRtpTimestampRateHz() const; int GetRtpTimestampRateHz() const;
int64_t GetRTT() const; int64_t GetRTT() const;
// MediaTransportAudioSinkInterface override;
void OnData(uint64_t channel_id,
MediaTransportEncodedAudioFrame frame) override;
// From RtpData in the RTP/RTCP module
int32_t OnReceivedPayloadData(const uint8_t* payloadData,
size_t payloadSize,
const WebRtcRTPHeader* rtpHeader) override;
rtc::CriticalSection _callbackCritSect; rtc::CriticalSection _callbackCritSect;
rtc::CriticalSection volume_settings_critsect_; rtc::CriticalSection volume_settings_critsect_;

View File

@ -33,8 +33,7 @@ ChannelReceiveProxy::~ChannelReceiveProxy() {}
void ChannelReceiveProxy::SetLocalSSRC(uint32_t ssrc) { void ChannelReceiveProxy::SetLocalSSRC(uint32_t ssrc) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
int error = channel_->SetLocalSSRC(ssrc); channel_->SetLocalSSRC(ssrc);
RTC_DCHECK_EQ(0, error);
} }
void ChannelReceiveProxy::SetNACKStatus(bool enable, int max_packets) { void ChannelReceiveProxy::SetNACKStatus(bool enable, int max_packets) {
@ -44,10 +43,7 @@ void ChannelReceiveProxy::SetNACKStatus(bool enable, int max_packets) {
CallReceiveStatistics ChannelReceiveProxy::GetRTCPStatistics() const { CallReceiveStatistics ChannelReceiveProxy::GetRTCPStatistics() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
CallReceiveStatistics stats = {0}; return channel_->GetRTCPStatistics();
int error = channel_->GetRTPStatistics(stats);
RTC_DCHECK_EQ(0, error);
return stats;
} }
bool ChannelReceiveProxy::ReceivedRTCPPacket(const uint8_t* packet, bool ChannelReceiveProxy::ReceivedRTCPPacket(const uint8_t* packet,
@ -69,17 +65,12 @@ void ChannelReceiveProxy::ResetReceiverCongestionControlObjects() {
NetworkStatistics ChannelReceiveProxy::GetNetworkStatistics() const { NetworkStatistics ChannelReceiveProxy::GetNetworkStatistics() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
NetworkStatistics stats = {0}; return channel_->GetNetworkStatistics();
int error = channel_->GetNetworkStatistics(stats);
RTC_DCHECK_EQ(0, error);
return stats;
} }
AudioDecodingCallStats ChannelReceiveProxy::GetDecodingCallStatistics() const { AudioDecodingCallStats ChannelReceiveProxy::GetDecodingCallStatistics() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
AudioDecodingCallStats stats; return channel_->GetDecodingCallStatistics();
channel_->GetDecodingCallStatistics(&stats);
return stats;
} }
int ChannelReceiveProxy::GetSpeechOutputLevelFullRange() const { int ChannelReceiveProxy::GetSpeechOutputLevelFullRange() const {
@ -154,10 +145,7 @@ absl::optional<Syncable::Info> ChannelReceiveProxy::GetSyncInfo() const {
uint32_t ChannelReceiveProxy::GetPlayoutTimestamp() const { uint32_t ChannelReceiveProxy::GetPlayoutTimestamp() const {
RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_); RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_);
unsigned int timestamp = 0; return channel_->GetPlayoutTimestamp();
int error = channel_->GetPlayoutTimestamp(timestamp);
RTC_DCHECK(!error || timestamp == 0);
return timestamp;
} }
void ChannelReceiveProxy::SetMinimumPlayoutDelay(int delay_ms) { void ChannelReceiveProxy::SetMinimumPlayoutDelay(int delay_ms) {
@ -165,15 +153,12 @@ void ChannelReceiveProxy::SetMinimumPlayoutDelay(int delay_ms) {
// Limit to range accepted by both VoE and ACM, so we're at least getting as // Limit to range accepted by both VoE and ACM, so we're at least getting as
// close as possible, instead of failing. // close as possible, instead of failing.
delay_ms = rtc::SafeClamp(delay_ms, 0, 10000); delay_ms = rtc::SafeClamp(delay_ms, 0, 10000);
int error = channel_->SetMinimumPlayoutDelay(delay_ms); channel_->SetMinimumPlayoutDelay(delay_ms);
if (0 != error) {
RTC_LOG(LS_WARNING) << "Error setting minimum playout delay.";
}
} }
bool ChannelReceiveProxy::GetRecCodec(CodecInst* codec_inst) const { bool ChannelReceiveProxy::GetRecCodec(CodecInst* codec_inst) const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
return channel_->GetRecCodec(*codec_inst) == 0; return channel_->GetRecCodec(codec_inst);
} }
std::vector<RtpSource> ChannelReceiveProxy::GetSources() const { std::vector<RtpSource> ChannelReceiveProxy::GetSources() const {
@ -183,14 +168,12 @@ std::vector<RtpSource> ChannelReceiveProxy::GetSources() const {
void ChannelReceiveProxy::StartPlayout() { void ChannelReceiveProxy::StartPlayout() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
int error = channel_->StartPlayout(); channel_->StartPlayout();
RTC_DCHECK_EQ(0, error);
} }
void ChannelReceiveProxy::StopPlayout() { void ChannelReceiveProxy::StopPlayout() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
int error = channel_->StopPlayout(); channel_->StopPlayout();
RTC_DCHECK_EQ(0, error);
} }
} // namespace voe } // namespace voe
} // namespace webrtc } // namespace webrtc