1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker *
4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker */
10*d9f75844SAndroid Build Coastguard Worker
11*d9f75844SAndroid Build Coastguard Worker #include "audio/audio_receive_stream.h"
12*d9f75844SAndroid Build Coastguard Worker
13*d9f75844SAndroid Build Coastguard Worker #include <string>
14*d9f75844SAndroid Build Coastguard Worker #include <utility>
15*d9f75844SAndroid Build Coastguard Worker
16*d9f75844SAndroid Build Coastguard Worker #include "absl/memory/memory.h"
17*d9f75844SAndroid Build Coastguard Worker #include "api/array_view.h"
18*d9f75844SAndroid Build Coastguard Worker #include "api/audio_codecs/audio_format.h"
19*d9f75844SAndroid Build Coastguard Worker #include "api/call/audio_sink.h"
20*d9f75844SAndroid Build Coastguard Worker #include "api/rtp_parameters.h"
21*d9f75844SAndroid Build Coastguard Worker #include "api/sequence_checker.h"
22*d9f75844SAndroid Build Coastguard Worker #include "audio/audio_send_stream.h"
23*d9f75844SAndroid Build Coastguard Worker #include "audio/audio_state.h"
24*d9f75844SAndroid Build Coastguard Worker #include "audio/channel_receive.h"
25*d9f75844SAndroid Build Coastguard Worker #include "audio/conversion.h"
26*d9f75844SAndroid Build Coastguard Worker #include "call/rtp_config.h"
27*d9f75844SAndroid Build Coastguard Worker #include "call/rtp_stream_receiver_controller_interface.h"
28*d9f75844SAndroid Build Coastguard Worker #include "modules/rtp_rtcp/source/rtp_packet_received.h"
29*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/checks.h"
30*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/logging.h"
31*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/strings/string_builder.h"
32*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/time_utils.h"
33*d9f75844SAndroid Build Coastguard Worker
34*d9f75844SAndroid Build Coastguard Worker namespace webrtc {
35*d9f75844SAndroid Build Coastguard Worker
ToString() const36*d9f75844SAndroid Build Coastguard Worker std::string AudioReceiveStreamInterface::Config::Rtp::ToString() const {
37*d9f75844SAndroid Build Coastguard Worker char ss_buf[1024];
38*d9f75844SAndroid Build Coastguard Worker rtc::SimpleStringBuilder ss(ss_buf);
39*d9f75844SAndroid Build Coastguard Worker ss << "{remote_ssrc: " << remote_ssrc;
40*d9f75844SAndroid Build Coastguard Worker ss << ", local_ssrc: " << local_ssrc;
41*d9f75844SAndroid Build Coastguard Worker ss << ", transport_cc: " << (transport_cc ? "on" : "off");
42*d9f75844SAndroid Build Coastguard Worker ss << ", nack: " << nack.ToString();
43*d9f75844SAndroid Build Coastguard Worker ss << ", extensions: [";
44*d9f75844SAndroid Build Coastguard Worker for (size_t i = 0; i < extensions.size(); ++i) {
45*d9f75844SAndroid Build Coastguard Worker ss << extensions[i].ToString();
46*d9f75844SAndroid Build Coastguard Worker if (i != extensions.size() - 1) {
47*d9f75844SAndroid Build Coastguard Worker ss << ", ";
48*d9f75844SAndroid Build Coastguard Worker }
49*d9f75844SAndroid Build Coastguard Worker }
50*d9f75844SAndroid Build Coastguard Worker ss << ']';
51*d9f75844SAndroid Build Coastguard Worker ss << '}';
52*d9f75844SAndroid Build Coastguard Worker return ss.str();
53*d9f75844SAndroid Build Coastguard Worker }
54*d9f75844SAndroid Build Coastguard Worker
ToString() const55*d9f75844SAndroid Build Coastguard Worker std::string AudioReceiveStreamInterface::Config::ToString() const {
56*d9f75844SAndroid Build Coastguard Worker char ss_buf[1024];
57*d9f75844SAndroid Build Coastguard Worker rtc::SimpleStringBuilder ss(ss_buf);
58*d9f75844SAndroid Build Coastguard Worker ss << "{rtp: " << rtp.ToString();
59*d9f75844SAndroid Build Coastguard Worker ss << ", rtcp_send_transport: "
60*d9f75844SAndroid Build Coastguard Worker << (rtcp_send_transport ? "(Transport)" : "null");
61*d9f75844SAndroid Build Coastguard Worker if (!sync_group.empty()) {
62*d9f75844SAndroid Build Coastguard Worker ss << ", sync_group: " << sync_group;
63*d9f75844SAndroid Build Coastguard Worker }
64*d9f75844SAndroid Build Coastguard Worker ss << '}';
65*d9f75844SAndroid Build Coastguard Worker return ss.str();
66*d9f75844SAndroid Build Coastguard Worker }
67*d9f75844SAndroid Build Coastguard Worker
68*d9f75844SAndroid Build Coastguard Worker namespace {
CreateChannelReceive(Clock * clock,webrtc::AudioState * audio_state,NetEqFactory * neteq_factory,const webrtc::AudioReceiveStreamInterface::Config & config,RtcEventLog * event_log)69*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive(
70*d9f75844SAndroid Build Coastguard Worker Clock* clock,
71*d9f75844SAndroid Build Coastguard Worker webrtc::AudioState* audio_state,
72*d9f75844SAndroid Build Coastguard Worker NetEqFactory* neteq_factory,
73*d9f75844SAndroid Build Coastguard Worker const webrtc::AudioReceiveStreamInterface::Config& config,
74*d9f75844SAndroid Build Coastguard Worker RtcEventLog* event_log) {
75*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK(audio_state);
76*d9f75844SAndroid Build Coastguard Worker internal::AudioState* internal_audio_state =
77*d9f75844SAndroid Build Coastguard Worker static_cast<internal::AudioState*>(audio_state);
78*d9f75844SAndroid Build Coastguard Worker return voe::CreateChannelReceive(
79*d9f75844SAndroid Build Coastguard Worker clock, neteq_factory, internal_audio_state->audio_device_module(),
80*d9f75844SAndroid Build Coastguard Worker config.rtcp_send_transport, event_log, config.rtp.local_ssrc,
81*d9f75844SAndroid Build Coastguard Worker config.rtp.remote_ssrc, config.jitter_buffer_max_packets,
82*d9f75844SAndroid Build Coastguard Worker config.jitter_buffer_fast_accelerate, config.jitter_buffer_min_delay_ms,
83*d9f75844SAndroid Build Coastguard Worker config.enable_non_sender_rtt, config.decoder_factory,
84*d9f75844SAndroid Build Coastguard Worker config.codec_pair_id, std::move(config.frame_decryptor),
85*d9f75844SAndroid Build Coastguard Worker config.crypto_options, std::move(config.frame_transformer));
86*d9f75844SAndroid Build Coastguard Worker }
87*d9f75844SAndroid Build Coastguard Worker } // namespace
88*d9f75844SAndroid Build Coastguard Worker
AudioReceiveStreamImpl(Clock * clock,PacketRouter * packet_router,NetEqFactory * neteq_factory,const webrtc::AudioReceiveStreamInterface::Config & config,const rtc::scoped_refptr<webrtc::AudioState> & audio_state,webrtc::RtcEventLog * event_log)89*d9f75844SAndroid Build Coastguard Worker AudioReceiveStreamImpl::AudioReceiveStreamImpl(
90*d9f75844SAndroid Build Coastguard Worker Clock* clock,
91*d9f75844SAndroid Build Coastguard Worker PacketRouter* packet_router,
92*d9f75844SAndroid Build Coastguard Worker NetEqFactory* neteq_factory,
93*d9f75844SAndroid Build Coastguard Worker const webrtc::AudioReceiveStreamInterface::Config& config,
94*d9f75844SAndroid Build Coastguard Worker const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
95*d9f75844SAndroid Build Coastguard Worker webrtc::RtcEventLog* event_log)
96*d9f75844SAndroid Build Coastguard Worker : AudioReceiveStreamImpl(clock,
97*d9f75844SAndroid Build Coastguard Worker packet_router,
98*d9f75844SAndroid Build Coastguard Worker config,
99*d9f75844SAndroid Build Coastguard Worker audio_state,
100*d9f75844SAndroid Build Coastguard Worker event_log,
101*d9f75844SAndroid Build Coastguard Worker CreateChannelReceive(clock,
102*d9f75844SAndroid Build Coastguard Worker audio_state.get(),
103*d9f75844SAndroid Build Coastguard Worker neteq_factory,
104*d9f75844SAndroid Build Coastguard Worker config,
105*d9f75844SAndroid Build Coastguard Worker event_log)) {}
106*d9f75844SAndroid Build Coastguard Worker
AudioReceiveStreamImpl(Clock * clock,PacketRouter * packet_router,const webrtc::AudioReceiveStreamInterface::Config & config,const rtc::scoped_refptr<webrtc::AudioState> & audio_state,webrtc::RtcEventLog * event_log,std::unique_ptr<voe::ChannelReceiveInterface> channel_receive)107*d9f75844SAndroid Build Coastguard Worker AudioReceiveStreamImpl::AudioReceiveStreamImpl(
108*d9f75844SAndroid Build Coastguard Worker Clock* clock,
109*d9f75844SAndroid Build Coastguard Worker PacketRouter* packet_router,
110*d9f75844SAndroid Build Coastguard Worker const webrtc::AudioReceiveStreamInterface::Config& config,
111*d9f75844SAndroid Build Coastguard Worker const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
112*d9f75844SAndroid Build Coastguard Worker webrtc::RtcEventLog* event_log,
113*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<voe::ChannelReceiveInterface> channel_receive)
114*d9f75844SAndroid Build Coastguard Worker : config_(config),
115*d9f75844SAndroid Build Coastguard Worker audio_state_(audio_state),
116*d9f75844SAndroid Build Coastguard Worker source_tracker_(clock),
117*d9f75844SAndroid Build Coastguard Worker channel_receive_(std::move(channel_receive)) {
118*d9f75844SAndroid Build Coastguard Worker RTC_LOG(LS_INFO) << "AudioReceiveStreamImpl: " << config.rtp.remote_ssrc;
119*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK(config.decoder_factory);
120*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK(config.rtcp_send_transport);
121*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK(audio_state_);
122*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK(channel_receive_);
123*d9f75844SAndroid Build Coastguard Worker
124*d9f75844SAndroid Build Coastguard Worker packet_sequence_checker_.Detach();
125*d9f75844SAndroid Build Coastguard Worker
126*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK(packet_router);
127*d9f75844SAndroid Build Coastguard Worker // Configure bandwidth estimation.
128*d9f75844SAndroid Build Coastguard Worker channel_receive_->RegisterReceiverCongestionControlObjects(packet_router);
129*d9f75844SAndroid Build Coastguard Worker
130*d9f75844SAndroid Build Coastguard Worker // When output is muted, ChannelReceive will directly notify the source
131*d9f75844SAndroid Build Coastguard Worker // tracker of "delivered" frames, so RtpReceiver information will continue to
132*d9f75844SAndroid Build Coastguard Worker // be updated.
133*d9f75844SAndroid Build Coastguard Worker channel_receive_->SetSourceTracker(&source_tracker_);
134*d9f75844SAndroid Build Coastguard Worker
135*d9f75844SAndroid Build Coastguard Worker // Complete configuration.
136*d9f75844SAndroid Build Coastguard Worker // TODO(solenberg): Config NACK history window (which is a packet count),
137*d9f75844SAndroid Build Coastguard Worker // using the actual packet size for the configured codec.
138*d9f75844SAndroid Build Coastguard Worker channel_receive_->SetNACKStatus(config.rtp.nack.rtp_history_ms != 0,
139*d9f75844SAndroid Build Coastguard Worker config.rtp.nack.rtp_history_ms / 20);
140*d9f75844SAndroid Build Coastguard Worker channel_receive_->SetReceiveCodecs(config.decoder_map);
141*d9f75844SAndroid Build Coastguard Worker // `frame_transformer` and `frame_decryptor` have been given to
142*d9f75844SAndroid Build Coastguard Worker // `channel_receive_` already.
143*d9f75844SAndroid Build Coastguard Worker }
144*d9f75844SAndroid Build Coastguard Worker
~AudioReceiveStreamImpl()145*d9f75844SAndroid Build Coastguard Worker AudioReceiveStreamImpl::~AudioReceiveStreamImpl() {
146*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
147*d9f75844SAndroid Build Coastguard Worker RTC_LOG(LS_INFO) << "~AudioReceiveStreamImpl: " << remote_ssrc();
148*d9f75844SAndroid Build Coastguard Worker Stop();
149*d9f75844SAndroid Build Coastguard Worker channel_receive_->SetAssociatedSendChannel(nullptr);
150*d9f75844SAndroid Build Coastguard Worker channel_receive_->ResetReceiverCongestionControlObjects();
151*d9f75844SAndroid Build Coastguard Worker }
152*d9f75844SAndroid Build Coastguard Worker
RegisterWithTransport(RtpStreamReceiverControllerInterface * receiver_controller)153*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::RegisterWithTransport(
154*d9f75844SAndroid Build Coastguard Worker RtpStreamReceiverControllerInterface* receiver_controller) {
155*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
156*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK(!rtp_stream_receiver_);
157*d9f75844SAndroid Build Coastguard Worker rtp_stream_receiver_ = receiver_controller->CreateReceiver(
158*d9f75844SAndroid Build Coastguard Worker remote_ssrc(), channel_receive_.get());
159*d9f75844SAndroid Build Coastguard Worker }
160*d9f75844SAndroid Build Coastguard Worker
UnregisterFromTransport()161*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::UnregisterFromTransport() {
162*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
163*d9f75844SAndroid Build Coastguard Worker rtp_stream_receiver_.reset();
164*d9f75844SAndroid Build Coastguard Worker }
165*d9f75844SAndroid Build Coastguard Worker
ReconfigureForTesting(const webrtc::AudioReceiveStreamInterface::Config & config)166*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::ReconfigureForTesting(
167*d9f75844SAndroid Build Coastguard Worker const webrtc::AudioReceiveStreamInterface::Config& config) {
168*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
169*d9f75844SAndroid Build Coastguard Worker
170*d9f75844SAndroid Build Coastguard Worker // SSRC can't be changed mid-stream.
171*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_EQ(remote_ssrc(), config.rtp.remote_ssrc);
172*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_EQ(local_ssrc(), config.rtp.local_ssrc);
173*d9f75844SAndroid Build Coastguard Worker
174*d9f75844SAndroid Build Coastguard Worker // Configuration parameters which cannot be changed.
175*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_EQ(config_.rtcp_send_transport, config.rtcp_send_transport);
176*d9f75844SAndroid Build Coastguard Worker // Decoder factory cannot be changed because it is configured at
177*d9f75844SAndroid Build Coastguard Worker // voe::Channel construction time.
178*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_EQ(config_.decoder_factory, config.decoder_factory);
179*d9f75844SAndroid Build Coastguard Worker
180*d9f75844SAndroid Build Coastguard Worker // TODO(solenberg): Config NACK history window (which is a packet count),
181*d9f75844SAndroid Build Coastguard Worker // using the actual packet size for the configured codec.
182*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_EQ(config_.rtp.nack.rtp_history_ms, config.rtp.nack.rtp_history_ms)
183*d9f75844SAndroid Build Coastguard Worker << "Use SetUseTransportCcAndNackHistory";
184*d9f75844SAndroid Build Coastguard Worker
185*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK(config_.decoder_map == config.decoder_map) << "Use SetDecoderMap";
186*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_EQ(config_.frame_transformer, config.frame_transformer)
187*d9f75844SAndroid Build Coastguard Worker << "Use SetDepacketizerToDecoderFrameTransformer";
188*d9f75844SAndroid Build Coastguard Worker
189*d9f75844SAndroid Build Coastguard Worker config_ = config;
190*d9f75844SAndroid Build Coastguard Worker }
191*d9f75844SAndroid Build Coastguard Worker
Start()192*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::Start() {
193*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
194*d9f75844SAndroid Build Coastguard Worker if (playing_) {
195*d9f75844SAndroid Build Coastguard Worker return;
196*d9f75844SAndroid Build Coastguard Worker }
197*d9f75844SAndroid Build Coastguard Worker channel_receive_->StartPlayout();
198*d9f75844SAndroid Build Coastguard Worker playing_ = true;
199*d9f75844SAndroid Build Coastguard Worker audio_state()->AddReceivingStream(this);
200*d9f75844SAndroid Build Coastguard Worker }
201*d9f75844SAndroid Build Coastguard Worker
Stop()202*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::Stop() {
203*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
204*d9f75844SAndroid Build Coastguard Worker if (!playing_) {
205*d9f75844SAndroid Build Coastguard Worker return;
206*d9f75844SAndroid Build Coastguard Worker }
207*d9f75844SAndroid Build Coastguard Worker channel_receive_->StopPlayout();
208*d9f75844SAndroid Build Coastguard Worker playing_ = false;
209*d9f75844SAndroid Build Coastguard Worker audio_state()->RemoveReceivingStream(this);
210*d9f75844SAndroid Build Coastguard Worker }
211*d9f75844SAndroid Build Coastguard Worker
transport_cc() const212*d9f75844SAndroid Build Coastguard Worker bool AudioReceiveStreamImpl::transport_cc() const {
213*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
214*d9f75844SAndroid Build Coastguard Worker return config_.rtp.transport_cc;
215*d9f75844SAndroid Build Coastguard Worker }
216*d9f75844SAndroid Build Coastguard Worker
SetTransportCc(bool transport_cc)217*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::SetTransportCc(bool transport_cc) {
218*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
219*d9f75844SAndroid Build Coastguard Worker config_.rtp.transport_cc = transport_cc;
220*d9f75844SAndroid Build Coastguard Worker }
221*d9f75844SAndroid Build Coastguard Worker
IsRunning() const222*d9f75844SAndroid Build Coastguard Worker bool AudioReceiveStreamImpl::IsRunning() const {
223*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
224*d9f75844SAndroid Build Coastguard Worker return playing_;
225*d9f75844SAndroid Build Coastguard Worker }
226*d9f75844SAndroid Build Coastguard Worker
SetDepacketizerToDecoderFrameTransformer(rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer)227*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::SetDepacketizerToDecoderFrameTransformer(
228*d9f75844SAndroid Build Coastguard Worker rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer) {
229*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
230*d9f75844SAndroid Build Coastguard Worker channel_receive_->SetDepacketizerToDecoderFrameTransformer(
231*d9f75844SAndroid Build Coastguard Worker std::move(frame_transformer));
232*d9f75844SAndroid Build Coastguard Worker }
233*d9f75844SAndroid Build Coastguard Worker
SetDecoderMap(std::map<int,SdpAudioFormat> decoder_map)234*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::SetDecoderMap(
235*d9f75844SAndroid Build Coastguard Worker std::map<int, SdpAudioFormat> decoder_map) {
236*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
237*d9f75844SAndroid Build Coastguard Worker config_.decoder_map = std::move(decoder_map);
238*d9f75844SAndroid Build Coastguard Worker channel_receive_->SetReceiveCodecs(config_.decoder_map);
239*d9f75844SAndroid Build Coastguard Worker }
240*d9f75844SAndroid Build Coastguard Worker
SetNackHistory(int history_ms)241*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::SetNackHistory(int history_ms) {
242*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
243*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_GE(history_ms, 0);
244*d9f75844SAndroid Build Coastguard Worker
245*d9f75844SAndroid Build Coastguard Worker if (config_.rtp.nack.rtp_history_ms == history_ms)
246*d9f75844SAndroid Build Coastguard Worker return;
247*d9f75844SAndroid Build Coastguard Worker
248*d9f75844SAndroid Build Coastguard Worker config_.rtp.nack.rtp_history_ms = history_ms;
249*d9f75844SAndroid Build Coastguard Worker // TODO(solenberg): Config NACK history window (which is a packet count),
250*d9f75844SAndroid Build Coastguard Worker // using the actual packet size for the configured codec.
251*d9f75844SAndroid Build Coastguard Worker channel_receive_->SetNACKStatus(history_ms != 0, history_ms / 20);
252*d9f75844SAndroid Build Coastguard Worker }
253*d9f75844SAndroid Build Coastguard Worker
SetNonSenderRttMeasurement(bool enabled)254*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::SetNonSenderRttMeasurement(bool enabled) {
255*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
256*d9f75844SAndroid Build Coastguard Worker config_.enable_non_sender_rtt = enabled;
257*d9f75844SAndroid Build Coastguard Worker channel_receive_->SetNonSenderRttMeasurement(enabled);
258*d9f75844SAndroid Build Coastguard Worker }
259*d9f75844SAndroid Build Coastguard Worker
SetFrameDecryptor(rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor)260*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::SetFrameDecryptor(
261*d9f75844SAndroid Build Coastguard Worker rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor) {
262*d9f75844SAndroid Build Coastguard Worker // TODO(bugs.webrtc.org/11993): This is called via WebRtcAudioReceiveStream,
263*d9f75844SAndroid Build Coastguard Worker // expect to be called on the network thread.
264*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
265*d9f75844SAndroid Build Coastguard Worker channel_receive_->SetFrameDecryptor(std::move(frame_decryptor));
266*d9f75844SAndroid Build Coastguard Worker }
267*d9f75844SAndroid Build Coastguard Worker
SetRtpExtensions(std::vector<RtpExtension> extensions)268*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::SetRtpExtensions(
269*d9f75844SAndroid Build Coastguard Worker std::vector<RtpExtension> extensions) {
270*d9f75844SAndroid Build Coastguard Worker // TODO(bugs.webrtc.org/11993): This is called via WebRtcAudioReceiveStream,
271*d9f75844SAndroid Build Coastguard Worker // expect to be called on the network thread.
272*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
273*d9f75844SAndroid Build Coastguard Worker config_.rtp.extensions = std::move(extensions);
274*d9f75844SAndroid Build Coastguard Worker }
275*d9f75844SAndroid Build Coastguard Worker
GetRtpExtensions() const276*d9f75844SAndroid Build Coastguard Worker const std::vector<RtpExtension>& AudioReceiveStreamImpl::GetRtpExtensions()
277*d9f75844SAndroid Build Coastguard Worker const {
278*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
279*d9f75844SAndroid Build Coastguard Worker return config_.rtp.extensions;
280*d9f75844SAndroid Build Coastguard Worker }
281*d9f75844SAndroid Build Coastguard Worker
GetRtpExtensionMap() const282*d9f75844SAndroid Build Coastguard Worker RtpHeaderExtensionMap AudioReceiveStreamImpl::GetRtpExtensionMap() const {
283*d9f75844SAndroid Build Coastguard Worker return RtpHeaderExtensionMap(config_.rtp.extensions);
284*d9f75844SAndroid Build Coastguard Worker }
285*d9f75844SAndroid Build Coastguard Worker
GetStats(bool get_and_clear_legacy_stats) const286*d9f75844SAndroid Build Coastguard Worker webrtc::AudioReceiveStreamInterface::Stats AudioReceiveStreamImpl::GetStats(
287*d9f75844SAndroid Build Coastguard Worker bool get_and_clear_legacy_stats) const {
288*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
289*d9f75844SAndroid Build Coastguard Worker webrtc::AudioReceiveStreamInterface::Stats stats;
290*d9f75844SAndroid Build Coastguard Worker stats.remote_ssrc = remote_ssrc();
291*d9f75844SAndroid Build Coastguard Worker
292*d9f75844SAndroid Build Coastguard Worker webrtc::CallReceiveStatistics call_stats =
293*d9f75844SAndroid Build Coastguard Worker channel_receive_->GetRTCPStatistics();
294*d9f75844SAndroid Build Coastguard Worker // TODO(solenberg): Don't return here if we can't get the codec - return the
295*d9f75844SAndroid Build Coastguard Worker // stats we *can* get.
296*d9f75844SAndroid Build Coastguard Worker auto receive_codec = channel_receive_->GetReceiveCodec();
297*d9f75844SAndroid Build Coastguard Worker if (!receive_codec) {
298*d9f75844SAndroid Build Coastguard Worker return stats;
299*d9f75844SAndroid Build Coastguard Worker }
300*d9f75844SAndroid Build Coastguard Worker
301*d9f75844SAndroid Build Coastguard Worker stats.payload_bytes_rcvd = call_stats.payload_bytes_rcvd;
302*d9f75844SAndroid Build Coastguard Worker stats.header_and_padding_bytes_rcvd =
303*d9f75844SAndroid Build Coastguard Worker call_stats.header_and_padding_bytes_rcvd;
304*d9f75844SAndroid Build Coastguard Worker stats.packets_rcvd = call_stats.packetsReceived;
305*d9f75844SAndroid Build Coastguard Worker stats.packets_lost = call_stats.cumulativeLost;
306*d9f75844SAndroid Build Coastguard Worker stats.nacks_sent = call_stats.nacks_sent;
307*d9f75844SAndroid Build Coastguard Worker stats.capture_start_ntp_time_ms = call_stats.capture_start_ntp_time_ms_;
308*d9f75844SAndroid Build Coastguard Worker stats.last_packet_received_timestamp_ms =
309*d9f75844SAndroid Build Coastguard Worker call_stats.last_packet_received_timestamp_ms;
310*d9f75844SAndroid Build Coastguard Worker stats.codec_name = receive_codec->second.name;
311*d9f75844SAndroid Build Coastguard Worker stats.codec_payload_type = receive_codec->first;
312*d9f75844SAndroid Build Coastguard Worker int clockrate_khz = receive_codec->second.clockrate_hz / 1000;
313*d9f75844SAndroid Build Coastguard Worker if (clockrate_khz > 0) {
314*d9f75844SAndroid Build Coastguard Worker stats.jitter_ms = call_stats.jitterSamples / clockrate_khz;
315*d9f75844SAndroid Build Coastguard Worker }
316*d9f75844SAndroid Build Coastguard Worker stats.delay_estimate_ms = channel_receive_->GetDelayEstimate();
317*d9f75844SAndroid Build Coastguard Worker stats.audio_level = channel_receive_->GetSpeechOutputLevelFullRange();
318*d9f75844SAndroid Build Coastguard Worker stats.total_output_energy = channel_receive_->GetTotalOutputEnergy();
319*d9f75844SAndroid Build Coastguard Worker stats.total_output_duration = channel_receive_->GetTotalOutputDuration();
320*d9f75844SAndroid Build Coastguard Worker stats.estimated_playout_ntp_timestamp_ms =
321*d9f75844SAndroid Build Coastguard Worker channel_receive_->GetCurrentEstimatedPlayoutNtpTimestampMs(
322*d9f75844SAndroid Build Coastguard Worker rtc::TimeMillis());
323*d9f75844SAndroid Build Coastguard Worker
324*d9f75844SAndroid Build Coastguard Worker // Get jitter buffer and total delay (alg + jitter + playout) stats.
325*d9f75844SAndroid Build Coastguard Worker auto ns = channel_receive_->GetNetworkStatistics(get_and_clear_legacy_stats);
326*d9f75844SAndroid Build Coastguard Worker stats.packets_discarded = ns.packetsDiscarded;
327*d9f75844SAndroid Build Coastguard Worker stats.fec_packets_received = ns.fecPacketsReceived;
328*d9f75844SAndroid Build Coastguard Worker stats.fec_packets_discarded = ns.fecPacketsDiscarded;
329*d9f75844SAndroid Build Coastguard Worker stats.jitter_buffer_ms = ns.currentBufferSize;
330*d9f75844SAndroid Build Coastguard Worker stats.jitter_buffer_preferred_ms = ns.preferredBufferSize;
331*d9f75844SAndroid Build Coastguard Worker stats.total_samples_received = ns.totalSamplesReceived;
332*d9f75844SAndroid Build Coastguard Worker stats.concealed_samples = ns.concealedSamples;
333*d9f75844SAndroid Build Coastguard Worker stats.silent_concealed_samples = ns.silentConcealedSamples;
334*d9f75844SAndroid Build Coastguard Worker stats.concealment_events = ns.concealmentEvents;
335*d9f75844SAndroid Build Coastguard Worker stats.jitter_buffer_delay_seconds =
336*d9f75844SAndroid Build Coastguard Worker static_cast<double>(ns.jitterBufferDelayMs) /
337*d9f75844SAndroid Build Coastguard Worker static_cast<double>(rtc::kNumMillisecsPerSec);
338*d9f75844SAndroid Build Coastguard Worker stats.jitter_buffer_emitted_count = ns.jitterBufferEmittedCount;
339*d9f75844SAndroid Build Coastguard Worker stats.jitter_buffer_target_delay_seconds =
340*d9f75844SAndroid Build Coastguard Worker static_cast<double>(ns.jitterBufferTargetDelayMs) /
341*d9f75844SAndroid Build Coastguard Worker static_cast<double>(rtc::kNumMillisecsPerSec);
342*d9f75844SAndroid Build Coastguard Worker stats.jitter_buffer_minimum_delay_seconds =
343*d9f75844SAndroid Build Coastguard Worker static_cast<double>(ns.jitterBufferMinimumDelayMs) /
344*d9f75844SAndroid Build Coastguard Worker static_cast<double>(rtc::kNumMillisecsPerSec);
345*d9f75844SAndroid Build Coastguard Worker stats.inserted_samples_for_deceleration = ns.insertedSamplesForDeceleration;
346*d9f75844SAndroid Build Coastguard Worker stats.removed_samples_for_acceleration = ns.removedSamplesForAcceleration;
347*d9f75844SAndroid Build Coastguard Worker stats.expand_rate = Q14ToFloat(ns.currentExpandRate);
348*d9f75844SAndroid Build Coastguard Worker stats.speech_expand_rate = Q14ToFloat(ns.currentSpeechExpandRate);
349*d9f75844SAndroid Build Coastguard Worker stats.secondary_decoded_rate = Q14ToFloat(ns.currentSecondaryDecodedRate);
350*d9f75844SAndroid Build Coastguard Worker stats.secondary_discarded_rate = Q14ToFloat(ns.currentSecondaryDiscardedRate);
351*d9f75844SAndroid Build Coastguard Worker stats.accelerate_rate = Q14ToFloat(ns.currentAccelerateRate);
352*d9f75844SAndroid Build Coastguard Worker stats.preemptive_expand_rate = Q14ToFloat(ns.currentPreemptiveRate);
353*d9f75844SAndroid Build Coastguard Worker stats.jitter_buffer_flushes = ns.packetBufferFlushes;
354*d9f75844SAndroid Build Coastguard Worker stats.delayed_packet_outage_samples = ns.delayedPacketOutageSamples;
355*d9f75844SAndroid Build Coastguard Worker stats.relative_packet_arrival_delay_seconds =
356*d9f75844SAndroid Build Coastguard Worker static_cast<double>(ns.relativePacketArrivalDelayMs) /
357*d9f75844SAndroid Build Coastguard Worker static_cast<double>(rtc::kNumMillisecsPerSec);
358*d9f75844SAndroid Build Coastguard Worker stats.interruption_count = ns.interruptionCount;
359*d9f75844SAndroid Build Coastguard Worker stats.total_interruption_duration_ms = ns.totalInterruptionDurationMs;
360*d9f75844SAndroid Build Coastguard Worker
361*d9f75844SAndroid Build Coastguard Worker auto ds = channel_receive_->GetDecodingCallStatistics();
362*d9f75844SAndroid Build Coastguard Worker stats.decoding_calls_to_silence_generator = ds.calls_to_silence_generator;
363*d9f75844SAndroid Build Coastguard Worker stats.decoding_calls_to_neteq = ds.calls_to_neteq;
364*d9f75844SAndroid Build Coastguard Worker stats.decoding_normal = ds.decoded_normal;
365*d9f75844SAndroid Build Coastguard Worker stats.decoding_plc = ds.decoded_neteq_plc;
366*d9f75844SAndroid Build Coastguard Worker stats.decoding_codec_plc = ds.decoded_codec_plc;
367*d9f75844SAndroid Build Coastguard Worker stats.decoding_cng = ds.decoded_cng;
368*d9f75844SAndroid Build Coastguard Worker stats.decoding_plc_cng = ds.decoded_plc_cng;
369*d9f75844SAndroid Build Coastguard Worker stats.decoding_muted_output = ds.decoded_muted_output;
370*d9f75844SAndroid Build Coastguard Worker
371*d9f75844SAndroid Build Coastguard Worker stats.last_sender_report_timestamp_ms =
372*d9f75844SAndroid Build Coastguard Worker call_stats.last_sender_report_timestamp_ms;
373*d9f75844SAndroid Build Coastguard Worker stats.last_sender_report_remote_timestamp_ms =
374*d9f75844SAndroid Build Coastguard Worker call_stats.last_sender_report_remote_timestamp_ms;
375*d9f75844SAndroid Build Coastguard Worker stats.sender_reports_packets_sent = call_stats.sender_reports_packets_sent;
376*d9f75844SAndroid Build Coastguard Worker stats.sender_reports_bytes_sent = call_stats.sender_reports_bytes_sent;
377*d9f75844SAndroid Build Coastguard Worker stats.sender_reports_reports_count = call_stats.sender_reports_reports_count;
378*d9f75844SAndroid Build Coastguard Worker stats.round_trip_time = call_stats.round_trip_time;
379*d9f75844SAndroid Build Coastguard Worker stats.round_trip_time_measurements = call_stats.round_trip_time_measurements;
380*d9f75844SAndroid Build Coastguard Worker stats.total_round_trip_time = call_stats.total_round_trip_time;
381*d9f75844SAndroid Build Coastguard Worker
382*d9f75844SAndroid Build Coastguard Worker return stats;
383*d9f75844SAndroid Build Coastguard Worker }
384*d9f75844SAndroid Build Coastguard Worker
SetSink(AudioSinkInterface * sink)385*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::SetSink(AudioSinkInterface* sink) {
386*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
387*d9f75844SAndroid Build Coastguard Worker channel_receive_->SetSink(sink);
388*d9f75844SAndroid Build Coastguard Worker }
389*d9f75844SAndroid Build Coastguard Worker
SetGain(float gain)390*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::SetGain(float gain) {
391*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
392*d9f75844SAndroid Build Coastguard Worker channel_receive_->SetChannelOutputVolumeScaling(gain);
393*d9f75844SAndroid Build Coastguard Worker }
394*d9f75844SAndroid Build Coastguard Worker
SetBaseMinimumPlayoutDelayMs(int delay_ms)395*d9f75844SAndroid Build Coastguard Worker bool AudioReceiveStreamImpl::SetBaseMinimumPlayoutDelayMs(int delay_ms) {
396*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
397*d9f75844SAndroid Build Coastguard Worker return channel_receive_->SetBaseMinimumPlayoutDelayMs(delay_ms);
398*d9f75844SAndroid Build Coastguard Worker }
399*d9f75844SAndroid Build Coastguard Worker
GetBaseMinimumPlayoutDelayMs() const400*d9f75844SAndroid Build Coastguard Worker int AudioReceiveStreamImpl::GetBaseMinimumPlayoutDelayMs() const {
401*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
402*d9f75844SAndroid Build Coastguard Worker return channel_receive_->GetBaseMinimumPlayoutDelayMs();
403*d9f75844SAndroid Build Coastguard Worker }
404*d9f75844SAndroid Build Coastguard Worker
GetSources() const405*d9f75844SAndroid Build Coastguard Worker std::vector<RtpSource> AudioReceiveStreamImpl::GetSources() const {
406*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
407*d9f75844SAndroid Build Coastguard Worker return source_tracker_.GetSources();
408*d9f75844SAndroid Build Coastguard Worker }
409*d9f75844SAndroid Build Coastguard Worker
410*d9f75844SAndroid Build Coastguard Worker AudioMixer::Source::AudioFrameInfo
GetAudioFrameWithInfo(int sample_rate_hz,AudioFrame * audio_frame)411*d9f75844SAndroid Build Coastguard Worker AudioReceiveStreamImpl::GetAudioFrameWithInfo(int sample_rate_hz,
412*d9f75844SAndroid Build Coastguard Worker AudioFrame* audio_frame) {
413*d9f75844SAndroid Build Coastguard Worker AudioMixer::Source::AudioFrameInfo audio_frame_info =
414*d9f75844SAndroid Build Coastguard Worker channel_receive_->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
415*d9f75844SAndroid Build Coastguard Worker if (audio_frame_info != AudioMixer::Source::AudioFrameInfo::kError) {
416*d9f75844SAndroid Build Coastguard Worker source_tracker_.OnFrameDelivered(audio_frame->packet_infos_);
417*d9f75844SAndroid Build Coastguard Worker }
418*d9f75844SAndroid Build Coastguard Worker return audio_frame_info;
419*d9f75844SAndroid Build Coastguard Worker }
420*d9f75844SAndroid Build Coastguard Worker
Ssrc() const421*d9f75844SAndroid Build Coastguard Worker int AudioReceiveStreamImpl::Ssrc() const {
422*d9f75844SAndroid Build Coastguard Worker return remote_ssrc();
423*d9f75844SAndroid Build Coastguard Worker }
424*d9f75844SAndroid Build Coastguard Worker
PreferredSampleRate() const425*d9f75844SAndroid Build Coastguard Worker int AudioReceiveStreamImpl::PreferredSampleRate() const {
426*d9f75844SAndroid Build Coastguard Worker return channel_receive_->PreferredSampleRate();
427*d9f75844SAndroid Build Coastguard Worker }
428*d9f75844SAndroid Build Coastguard Worker
id() const429*d9f75844SAndroid Build Coastguard Worker uint32_t AudioReceiveStreamImpl::id() const {
430*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
431*d9f75844SAndroid Build Coastguard Worker return remote_ssrc();
432*d9f75844SAndroid Build Coastguard Worker }
433*d9f75844SAndroid Build Coastguard Worker
GetInfo() const434*d9f75844SAndroid Build Coastguard Worker absl::optional<Syncable::Info> AudioReceiveStreamImpl::GetInfo() const {
435*d9f75844SAndroid Build Coastguard Worker // TODO(bugs.webrtc.org/11993): This is called via RtpStreamsSynchronizer,
436*d9f75844SAndroid Build Coastguard Worker // expect to be called on the network thread.
437*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
438*d9f75844SAndroid Build Coastguard Worker return channel_receive_->GetSyncInfo();
439*d9f75844SAndroid Build Coastguard Worker }
440*d9f75844SAndroid Build Coastguard Worker
GetPlayoutRtpTimestamp(uint32_t * rtp_timestamp,int64_t * time_ms) const441*d9f75844SAndroid Build Coastguard Worker bool AudioReceiveStreamImpl::GetPlayoutRtpTimestamp(uint32_t* rtp_timestamp,
442*d9f75844SAndroid Build Coastguard Worker int64_t* time_ms) const {
443*d9f75844SAndroid Build Coastguard Worker // Called on video capture thread.
444*d9f75844SAndroid Build Coastguard Worker return channel_receive_->GetPlayoutRtpTimestamp(rtp_timestamp, time_ms);
445*d9f75844SAndroid Build Coastguard Worker }
446*d9f75844SAndroid Build Coastguard Worker
SetEstimatedPlayoutNtpTimestampMs(int64_t ntp_timestamp_ms,int64_t time_ms)447*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::SetEstimatedPlayoutNtpTimestampMs(
448*d9f75844SAndroid Build Coastguard Worker int64_t ntp_timestamp_ms,
449*d9f75844SAndroid Build Coastguard Worker int64_t time_ms) {
450*d9f75844SAndroid Build Coastguard Worker // Called on video capture thread.
451*d9f75844SAndroid Build Coastguard Worker channel_receive_->SetEstimatedPlayoutNtpTimestampMs(ntp_timestamp_ms,
452*d9f75844SAndroid Build Coastguard Worker time_ms);
453*d9f75844SAndroid Build Coastguard Worker }
454*d9f75844SAndroid Build Coastguard Worker
SetMinimumPlayoutDelay(int delay_ms)455*d9f75844SAndroid Build Coastguard Worker bool AudioReceiveStreamImpl::SetMinimumPlayoutDelay(int delay_ms) {
456*d9f75844SAndroid Build Coastguard Worker // TODO(bugs.webrtc.org/11993): This is called via RtpStreamsSynchronizer,
457*d9f75844SAndroid Build Coastguard Worker // expect to be called on the network thread.
458*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&worker_thread_checker_);
459*d9f75844SAndroid Build Coastguard Worker return channel_receive_->SetMinimumPlayoutDelay(delay_ms);
460*d9f75844SAndroid Build Coastguard Worker }
461*d9f75844SAndroid Build Coastguard Worker
AssociateSendStream(internal::AudioSendStream * send_stream)462*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::AssociateSendStream(
463*d9f75844SAndroid Build Coastguard Worker internal::AudioSendStream* send_stream) {
464*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
465*d9f75844SAndroid Build Coastguard Worker channel_receive_->SetAssociatedSendChannel(
466*d9f75844SAndroid Build Coastguard Worker send_stream ? send_stream->GetChannel() : nullptr);
467*d9f75844SAndroid Build Coastguard Worker associated_send_stream_ = send_stream;
468*d9f75844SAndroid Build Coastguard Worker }
469*d9f75844SAndroid Build Coastguard Worker
DeliverRtcp(const uint8_t * packet,size_t length)470*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::DeliverRtcp(const uint8_t* packet, size_t length) {
471*d9f75844SAndroid Build Coastguard Worker // TODO(solenberg): Tests call this function on a network thread, libjingle
472*d9f75844SAndroid Build Coastguard Worker // calls on the worker thread. We should move towards always using a network
473*d9f75844SAndroid Build Coastguard Worker // thread. Then this check can be enabled.
474*d9f75844SAndroid Build Coastguard Worker // RTC_DCHECK(!thread_checker_.IsCurrent());
475*d9f75844SAndroid Build Coastguard Worker channel_receive_->ReceivedRTCPPacket(packet, length);
476*d9f75844SAndroid Build Coastguard Worker }
477*d9f75844SAndroid Build Coastguard Worker
SetSyncGroup(absl::string_view sync_group)478*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::SetSyncGroup(absl::string_view sync_group) {
479*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
480*d9f75844SAndroid Build Coastguard Worker config_.sync_group = std::string(sync_group);
481*d9f75844SAndroid Build Coastguard Worker }
482*d9f75844SAndroid Build Coastguard Worker
SetLocalSsrc(uint32_t local_ssrc)483*d9f75844SAndroid Build Coastguard Worker void AudioReceiveStreamImpl::SetLocalSsrc(uint32_t local_ssrc) {
484*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
485*d9f75844SAndroid Build Coastguard Worker // TODO(tommi): Consider storing local_ssrc in one place.
486*d9f75844SAndroid Build Coastguard Worker config_.rtp.local_ssrc = local_ssrc;
487*d9f75844SAndroid Build Coastguard Worker channel_receive_->OnLocalSsrcChange(local_ssrc);
488*d9f75844SAndroid Build Coastguard Worker }
489*d9f75844SAndroid Build Coastguard Worker
local_ssrc() const490*d9f75844SAndroid Build Coastguard Worker uint32_t AudioReceiveStreamImpl::local_ssrc() const {
491*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
492*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_EQ(config_.rtp.local_ssrc, channel_receive_->GetLocalSsrc());
493*d9f75844SAndroid Build Coastguard Worker return config_.rtp.local_ssrc;
494*d9f75844SAndroid Build Coastguard Worker }
495*d9f75844SAndroid Build Coastguard Worker
sync_group() const496*d9f75844SAndroid Build Coastguard Worker const std::string& AudioReceiveStreamImpl::sync_group() const {
497*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
498*d9f75844SAndroid Build Coastguard Worker return config_.sync_group;
499*d9f75844SAndroid Build Coastguard Worker }
500*d9f75844SAndroid Build Coastguard Worker
501*d9f75844SAndroid Build Coastguard Worker const AudioSendStream*
GetAssociatedSendStreamForTesting() const502*d9f75844SAndroid Build Coastguard Worker AudioReceiveStreamImpl::GetAssociatedSendStreamForTesting() const {
503*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
504*d9f75844SAndroid Build Coastguard Worker return associated_send_stream_;
505*d9f75844SAndroid Build Coastguard Worker }
506*d9f75844SAndroid Build Coastguard Worker
audio_state() const507*d9f75844SAndroid Build Coastguard Worker internal::AudioState* AudioReceiveStreamImpl::audio_state() const {
508*d9f75844SAndroid Build Coastguard Worker auto* audio_state = static_cast<internal::AudioState*>(audio_state_.get());
509*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK(audio_state);
510*d9f75844SAndroid Build Coastguard Worker return audio_state;
511*d9f75844SAndroid Build Coastguard Worker }
512*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc
513