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:
@ -372,29 +372,25 @@ void ChannelReceive::SetSink(AudioSinkInterface* sink) {
|
||||
audio_sink_ = sink;
|
||||
}
|
||||
|
||||
int32_t ChannelReceive::StartPlayout() {
|
||||
void ChannelReceive::StartPlayout() {
|
||||
if (channel_state_.Get().playing) {
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
channel_state_.SetPlaying(true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ChannelReceive::StopPlayout() {
|
||||
void ChannelReceive::StopPlayout() {
|
||||
if (!channel_state_.Get().playing) {
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
channel_state_.SetPlaying(false);
|
||||
_outputAudioLevel.Clear();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ChannelReceive::GetRecCodec(CodecInst& codec) {
|
||||
return (audio_coding_->ReceiveCodec(&codec));
|
||||
bool ChannelReceive::GetRecCodec(CodecInst* codec) {
|
||||
return (audio_coding_->ReceiveCodec(codec) == 0);
|
||||
}
|
||||
|
||||
std::vector<webrtc::RtpSource> ChannelReceive::GetSources() const {
|
||||
@ -513,7 +509,8 @@ bool ChannelReceive::ReceivePacket(const uint8_t* packet,
|
||||
&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
|
||||
UpdatePlayoutTimestamp(true);
|
||||
|
||||
@ -523,7 +520,7 @@ int32_t ChannelReceive::ReceivedRTCPPacket(const uint8_t* data, size_t length) {
|
||||
int64_t rtt = GetRTT();
|
||||
if (rtt == 0) {
|
||||
// Waiting for valid RTT.
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
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,
|
||||
&rtp_timestamp)) {
|
||||
// Waiting for RTCP.
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
{
|
||||
rtc::CritScope lock(&ts_stats_lock_);
|
||||
ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int ChannelReceive::GetSpeechOutputLevelFullRange() const {
|
||||
@ -566,9 +563,8 @@ void ChannelReceive::SetChannelOutputVolumeScaling(float scaling) {
|
||||
_outputGain = scaling;
|
||||
}
|
||||
|
||||
int ChannelReceive::SetLocalSSRC(unsigned int ssrc) {
|
||||
void ChannelReceive::SetLocalSSRC(unsigned int ssrc) {
|
||||
_rtpRtcpModule->SetSSRC(ssrc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO(nisse): Pass ssrc in return value instead.
|
||||
@ -592,8 +588,9 @@ void ChannelReceive::ResetReceiverCongestionControlObjects() {
|
||||
packet_router_ = nullptr;
|
||||
}
|
||||
|
||||
int ChannelReceive::GetRTPStatistics(CallReceiveStatistics& stats) {
|
||||
CallReceiveStatistics ChannelReceive::GetRTCPStatistics() {
|
||||
// --- RtcpStatistics
|
||||
CallReceiveStatistics stats;
|
||||
|
||||
// The jitter statistics is updated for each received RTP packet and is
|
||||
// based on received packets.
|
||||
@ -630,7 +627,7 @@ int ChannelReceive::GetRTPStatistics(CallReceiveStatistics& stats) {
|
||||
rtc::CritScope lock(&ts_stats_lock_);
|
||||
stats.capture_start_ntp_time_ms_ = capture_start_ntp_time_ms_;
|
||||
}
|
||||
return 0;
|
||||
return stats;
|
||||
}
|
||||
|
||||
void ChannelReceive::SetNACKStatus(bool enable, int maxNumberOfPackets) {
|
||||
@ -653,13 +650,17 @@ void ChannelReceive::SetAssociatedSendChannel(ChannelSend* channel) {
|
||||
associated_send_channel_ = channel;
|
||||
}
|
||||
|
||||
int ChannelReceive::GetNetworkStatistics(NetworkStatistics& stats) {
|
||||
return audio_coding_->GetNetworkStatistics(&stats);
|
||||
NetworkStatistics ChannelReceive::GetNetworkStatistics() const {
|
||||
NetworkStatistics stats;
|
||||
int error = audio_coding_->GetNetworkStatistics(&stats);
|
||||
RTC_DCHECK_EQ(0, error);
|
||||
return stats;
|
||||
}
|
||||
|
||||
void ChannelReceive::GetDecodingCallStatistics(
|
||||
AudioDecodingCallStats* stats) const {
|
||||
audio_coding_->GetDecodingCallStatistics(stats);
|
||||
AudioDecodingCallStats ChannelReceive::GetDecodingCallStatistics() const {
|
||||
AudioDecodingCallStats stats;
|
||||
audio_coding_->GetDecodingCallStatistics(&stats);
|
||||
return stats;
|
||||
}
|
||||
|
||||
uint32_t ChannelReceive::GetDelayEstimate() const {
|
||||
@ -667,32 +668,23 @@ uint32_t ChannelReceive::GetDelayEstimate() const {
|
||||
return audio_coding_->FilteredCurrentDelayMs() + playout_delay_ms_;
|
||||
}
|
||||
|
||||
int ChannelReceive::SetMinimumPlayoutDelay(int delayMs) {
|
||||
void ChannelReceive::SetMinimumPlayoutDelay(int delayMs) {
|
||||
if ((delayMs < kVoiceEngineMinMinPlayoutDelayMs) ||
|
||||
(delayMs > kVoiceEngineMaxMinPlayoutDelayMs)) {
|
||||
RTC_DLOG(LS_ERROR) << "SetMinimumPlayoutDelay() invalid min delay";
|
||||
return -1;
|
||||
return;
|
||||
}
|
||||
if (audio_coding_->SetMinimumPlayoutDelay(delayMs) != 0) {
|
||||
RTC_DLOG(LS_ERROR)
|
||||
<< "SetMinimumPlayoutDelay() failed to set min playout delay";
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ChannelReceive::GetPlayoutTimestamp(unsigned int& timestamp) {
|
||||
uint32_t playout_timestamp_rtp = 0;
|
||||
uint32_t ChannelReceive::GetPlayoutTimestamp() {
|
||||
{
|
||||
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 {
|
||||
|
||||
@ -127,15 +127,14 @@ class ChannelReceive : public RtpData, public MediaTransportAudioSinkInterface {
|
||||
|
||||
// API methods
|
||||
|
||||
// VoEBase
|
||||
int32_t StartPlayout();
|
||||
int32_t StopPlayout();
|
||||
void StartPlayout();
|
||||
void StopPlayout();
|
||||
|
||||
// Codecs
|
||||
int32_t GetRecCodec(CodecInst& codec); // NOLINT
|
||||
bool GetRecCodec(CodecInst* codec);
|
||||
|
||||
// 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);
|
||||
|
||||
// Muting, Volume and Level.
|
||||
@ -147,35 +146,26 @@ class ChannelReceive : public RtpData, public MediaTransportAudioSinkInterface {
|
||||
double GetTotalOutputDuration() const;
|
||||
|
||||
// Stats.
|
||||
int GetNetworkStatistics(NetworkStatistics& stats); // NOLINT
|
||||
void GetDecodingCallStatistics(AudioDecodingCallStats* stats) const;
|
||||
NetworkStatistics GetNetworkStatistics() const;
|
||||
AudioDecodingCallStats GetDecodingCallStatistics() const;
|
||||
|
||||
// Audio+Video Sync.
|
||||
uint32_t GetDelayEstimate() const;
|
||||
int SetMinimumPlayoutDelay(int delayMs);
|
||||
int GetPlayoutTimestamp(unsigned int& timestamp); // NOLINT
|
||||
void SetMinimumPlayoutDelay(int delayMs);
|
||||
uint32_t GetPlayoutTimestamp();
|
||||
|
||||
// Produces the transport-related timestamps; current_delay_ms is left unset.
|
||||
absl::optional<Syncable::Info> GetSyncInfo() const;
|
||||
|
||||
// RTP+RTCP
|
||||
int SetLocalSSRC(unsigned int ssrc);
|
||||
void SetLocalSSRC(unsigned int ssrc);
|
||||
|
||||
void RegisterReceiverCongestionControlObjects(PacketRouter* packet_router);
|
||||
void ResetReceiverCongestionControlObjects();
|
||||
|
||||
int GetRTPStatistics(CallReceiveStatistics& stats); // NOLINT
|
||||
CallReceiveStatistics GetRTCPStatistics();
|
||||
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.
|
||||
AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo(
|
||||
int sample_rate_hz,
|
||||
@ -204,6 +194,15 @@ class ChannelReceive : public RtpData, public MediaTransportAudioSinkInterface {
|
||||
int GetRtpTimestampRateHz() 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 volume_settings_critsect_;
|
||||
|
||||
|
||||
@ -33,8 +33,7 @@ ChannelReceiveProxy::~ChannelReceiveProxy() {}
|
||||
|
||||
void ChannelReceiveProxy::SetLocalSSRC(uint32_t ssrc) {
|
||||
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
||||
int error = channel_->SetLocalSSRC(ssrc);
|
||||
RTC_DCHECK_EQ(0, error);
|
||||
channel_->SetLocalSSRC(ssrc);
|
||||
}
|
||||
|
||||
void ChannelReceiveProxy::SetNACKStatus(bool enable, int max_packets) {
|
||||
@ -44,10 +43,7 @@ void ChannelReceiveProxy::SetNACKStatus(bool enable, int max_packets) {
|
||||
|
||||
CallReceiveStatistics ChannelReceiveProxy::GetRTCPStatistics() const {
|
||||
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
||||
CallReceiveStatistics stats = {0};
|
||||
int error = channel_->GetRTPStatistics(stats);
|
||||
RTC_DCHECK_EQ(0, error);
|
||||
return stats;
|
||||
return channel_->GetRTCPStatistics();
|
||||
}
|
||||
|
||||
bool ChannelReceiveProxy::ReceivedRTCPPacket(const uint8_t* packet,
|
||||
@ -69,17 +65,12 @@ void ChannelReceiveProxy::ResetReceiverCongestionControlObjects() {
|
||||
|
||||
NetworkStatistics ChannelReceiveProxy::GetNetworkStatistics() const {
|
||||
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
||||
NetworkStatistics stats = {0};
|
||||
int error = channel_->GetNetworkStatistics(stats);
|
||||
RTC_DCHECK_EQ(0, error);
|
||||
return stats;
|
||||
return channel_->GetNetworkStatistics();
|
||||
}
|
||||
|
||||
AudioDecodingCallStats ChannelReceiveProxy::GetDecodingCallStatistics() const {
|
||||
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
||||
AudioDecodingCallStats stats;
|
||||
channel_->GetDecodingCallStatistics(&stats);
|
||||
return stats;
|
||||
return channel_->GetDecodingCallStatistics();
|
||||
}
|
||||
|
||||
int ChannelReceiveProxy::GetSpeechOutputLevelFullRange() const {
|
||||
@ -154,10 +145,7 @@ absl::optional<Syncable::Info> ChannelReceiveProxy::GetSyncInfo() const {
|
||||
|
||||
uint32_t ChannelReceiveProxy::GetPlayoutTimestamp() const {
|
||||
RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_);
|
||||
unsigned int timestamp = 0;
|
||||
int error = channel_->GetPlayoutTimestamp(timestamp);
|
||||
RTC_DCHECK(!error || timestamp == 0);
|
||||
return timestamp;
|
||||
return channel_->GetPlayoutTimestamp();
|
||||
}
|
||||
|
||||
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
|
||||
// close as possible, instead of failing.
|
||||
delay_ms = rtc::SafeClamp(delay_ms, 0, 10000);
|
||||
int error = channel_->SetMinimumPlayoutDelay(delay_ms);
|
||||
if (0 != error) {
|
||||
RTC_LOG(LS_WARNING) << "Error setting minimum playout delay.";
|
||||
}
|
||||
channel_->SetMinimumPlayoutDelay(delay_ms);
|
||||
}
|
||||
|
||||
bool ChannelReceiveProxy::GetRecCodec(CodecInst* codec_inst) const {
|
||||
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
||||
return channel_->GetRecCodec(*codec_inst) == 0;
|
||||
return channel_->GetRecCodec(codec_inst);
|
||||
}
|
||||
|
||||
std::vector<RtpSource> ChannelReceiveProxy::GetSources() const {
|
||||
@ -183,14 +168,12 @@ std::vector<RtpSource> ChannelReceiveProxy::GetSources() const {
|
||||
|
||||
void ChannelReceiveProxy::StartPlayout() {
|
||||
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
||||
int error = channel_->StartPlayout();
|
||||
RTC_DCHECK_EQ(0, error);
|
||||
channel_->StartPlayout();
|
||||
}
|
||||
|
||||
void ChannelReceiveProxy::StopPlayout() {
|
||||
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
||||
int error = channel_->StopPlayout();
|
||||
RTC_DCHECK_EQ(0, error);
|
||||
channel_->StopPlayout();
|
||||
}
|
||||
} // namespace voe
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user