blob: 3c538180609bb20414d06f44ac3992076e072218 [file] [log] [blame]
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +02001/*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "audio/audio_receive_stream.h"
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020012
13#include <string>
Tommif888bb52015-12-12 01:37:01 +010014#include <utility>
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020015
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "api/call/audio_sink.h"
17#include "audio/audio_send_stream.h"
18#include "audio/audio_state.h"
19#include "audio/conversion.h"
20#include "call/rtp_stream_receiver_controller_interface.h"
21#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
22#include "modules/rtp_rtcp/include/rtp_receiver.h"
23#include "modules/rtp_rtcp/include/rtp_rtcp.h"
24#include "rtc_base/checks.h"
25#include "rtc_base/logging.h"
26#include "rtc_base/timeutils.h"
27#include "voice_engine/channel_proxy.h"
28#include "voice_engine/include/voe_base.h"
29#include "voice_engine/voice_engine_impl.h"
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020030
31namespace webrtc {
Stefan Holmer3842c5c2016-01-12 13:55:00 +010032
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020033std::string AudioReceiveStream::Config::Rtp::ToString() const {
34 std::stringstream ss;
35 ss << "{remote_ssrc: " << remote_ssrc;
solenberg85a04962015-10-27 03:35:21 -070036 ss << ", local_ssrc: " << local_ssrc;
solenberg8189b022016-06-14 12:13:00 -070037 ss << ", transport_cc: " << (transport_cc ? "on" : "off");
38 ss << ", nack: " << nack.ToString();
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020039 ss << ", extensions: [";
40 for (size_t i = 0; i < extensions.size(); ++i) {
41 ss << extensions[i].ToString();
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020042 if (i != extensions.size() - 1) {
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020043 ss << ", ";
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020044 }
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020045 }
46 ss << ']';
47 ss << '}';
48 return ss.str();
49}
50
51std::string AudioReceiveStream::Config::ToString() const {
52 std::stringstream ss;
53 ss << "{rtp: " << rtp.ToString();
solenberg85a04962015-10-27 03:35:21 -070054 ss << ", rtcp_send_transport: "
deadbeef922246a2017-02-26 04:18:12 -080055 << (rtcp_send_transport ? "(Transport)" : "null");
pbos8fc7fa72015-07-15 08:02:58 -070056 ss << ", voe_channel_id: " << voe_channel_id;
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020057 if (!sync_group.empty()) {
pbos8fc7fa72015-07-15 08:02:58 -070058 ss << ", sync_group: " << sync_group;
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020059 }
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020060 ss << '}';
61 return ss.str();
62}
63
64namespace internal {
65AudioReceiveStream::AudioReceiveStream(
nisse0f15f922017-06-21 01:05:22 -070066 RtpStreamReceiverControllerInterface* receiver_controller,
nisse0245da02016-11-30 03:35:20 -080067 PacketRouter* packet_router,
solenberg566ef242015-11-06 15:34:49 -080068 const webrtc::AudioReceiveStream::Config& config,
ivoc14d5dbe2016-07-04 07:06:55 -070069 const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
70 webrtc::RtcEventLog* event_log)
Fredrik Solenberg3b903d02018-01-10 15:17:10 +010071 : audio_state_(audio_state) {
72 RTC_LOG(LS_INFO) << "AudioReceiveStream: " << config.ToString();
73 RTC_DCHECK_NE(config.voe_channel_id, -1);
solenberg566ef242015-11-06 15:34:49 -080074 RTC_DCHECK(audio_state_.get());
nisse0245da02016-11-30 03:35:20 -080075 RTC_DCHECK(packet_router);
solenberg7add0582015-11-20 09:59:34 -080076
solenberg3ebbcb52017-01-31 03:58:40 -080077 module_process_thread_checker_.DetachFromThread();
78
solenberg13725082015-11-25 08:16:52 -080079 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine());
Fredrik Solenberg3b903d02018-01-10 15:17:10 +010080 channel_proxy_ = voe_impl->GetChannelProxy(config.voe_channel_id);
mflodman3d7db262016-04-29 00:57:13 -070081
ossu29b1a8d2016-06-13 07:34:51 -070082 // TODO(ossu): This is where we'd like to set the decoder factory to
83 // use. However, since it needs to be included when constructing Channel, we
84 // cannot do that until we're able to move Channel ownership into the
85 // Audio{Send,Receive}Streams. The best we can do is check that we're not
86 // trying to use two different factories using the different interfaces.
87 RTC_CHECK(config.decoder_factory);
88 RTC_CHECK_EQ(config.decoder_factory,
89 channel_proxy_->GetAudioDecoderFactory());
90
Fredrik Solenberg3b903d02018-01-10 15:17:10 +010091 channel_proxy_->SetRtcEventLog(event_log);
solenberg1c239d42017-09-29 06:00:28 -070092 channel_proxy_->RegisterTransport(config.rtcp_send_transport);
kwibergd32bf752017-01-19 07:03:59 -080093
Stefan Holmer3842c5c2016-01-12 13:55:00 +010094 // Configure bandwidth estimation.
nisse0245da02016-11-30 03:35:20 -080095 channel_proxy_->RegisterReceiverCongestionControlObjects(packet_router);
nisse0f15f922017-06-21 01:05:22 -070096
97 // Register with transport.
98 rtp_stream_receiver_ =
Fredrik Solenberg3b903d02018-01-10 15:17:10 +010099 receiver_controller->CreateReceiver(config.rtp.remote_ssrc,
nisse0f15f922017-06-21 01:05:22 -0700100 channel_proxy_.get());
Fredrik Solenberg3b903d02018-01-10 15:17:10 +0100101
102 ConfigureStream(this, config, true);
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +0200103}
104
pbosa2f30de2015-10-15 05:22:13 -0700105AudioReceiveStream::~AudioReceiveStream() {
solenberg3ebbcb52017-01-31 03:58:40 -0800106 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
Mirko Bonadei675513b2017-11-09 11:09:25 +0100107 RTC_LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString();
Fredrik Solenbergd5247512017-12-18 22:41:03 +0100108 Stop();
solenberg7602aab2016-11-14 11:30:07 -0800109 channel_proxy_->DisassociateSendChannel();
solenberg1c239d42017-09-29 06:00:28 -0700110 channel_proxy_->RegisterTransport(nullptr);
nissefdbfdc92017-03-31 05:44:52 -0700111 channel_proxy_->ResetReceiverCongestionControlObjects();
ivoc14d5dbe2016-07-04 07:06:55 -0700112 channel_proxy_->SetRtcEventLog(nullptr);
pbosa2f30de2015-10-15 05:22:13 -0700113}
114
Fredrik Solenberg3b903d02018-01-10 15:17:10 +0100115void AudioReceiveStream::Reconfigure(
116 const webrtc::AudioReceiveStream::Config& config) {
117 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
118 RTC_LOG(LS_INFO) << "AudioReceiveStream::Reconfigure: " << config_.ToString();
119 ConfigureStream(this, config, false);
120}
121
solenberg7add0582015-11-20 09:59:34 -0800122void AudioReceiveStream::Start() {
solenberg3ebbcb52017-01-31 03:58:40 -0800123 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
aleloi04c07222016-11-22 06:42:53 -0800124 if (playing_) {
125 return;
126 }
Fredrik Solenbergd5247512017-12-18 22:41:03 +0100127 channel_proxy_->StartPlayout();
aleloi04c07222016-11-22 06:42:53 -0800128 playing_ = true;
Fredrik Solenbergd5247512017-12-18 22:41:03 +0100129 audio_state()->AddReceivingStream(this);
solenberg7add0582015-11-20 09:59:34 -0800130}
131
132void AudioReceiveStream::Stop() {
solenberg3ebbcb52017-01-31 03:58:40 -0800133 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
aleloi04c07222016-11-22 06:42:53 -0800134 if (!playing_) {
135 return;
136 }
Fredrik Solenbergd5247512017-12-18 22:41:03 +0100137 channel_proxy_->StopPlayout();
aleloi04c07222016-11-22 06:42:53 -0800138 playing_ = false;
Fredrik Solenbergd5247512017-12-18 22:41:03 +0100139 audio_state()->RemoveReceivingStream(this);
solenberg7add0582015-11-20 09:59:34 -0800140}
141
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200142webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const {
solenberg3ebbcb52017-01-31 03:58:40 -0800143 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +0200144 webrtc::AudioReceiveStream::Stats stats;
145 stats.remote_ssrc = config_.rtp.remote_ssrc;
solenberg8b85de22015-11-16 09:48:04 -0800146
solenberg358057b2015-11-27 10:46:42 -0800147 webrtc::CallStatistics call_stats = channel_proxy_->GetRTCPStatistics();
solenbergbd9a77f2017-02-06 12:53:57 -0800148 // TODO(solenberg): Don't return here if we can't get the codec - return the
149 // stats we *can* get.
solenberg85a04962015-10-27 03:35:21 -0700150 webrtc::CodecInst codec_inst = {0};
solenbergbd9a77f2017-02-06 12:53:57 -0800151 if (!channel_proxy_->GetRecCodec(&codec_inst)) {
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +0200152 return stats;
153 }
154
solenberg85a04962015-10-27 03:35:21 -0700155 stats.bytes_rcvd = call_stats.bytesReceived;
156 stats.packets_rcvd = call_stats.packetsReceived;
157 stats.packets_lost = call_stats.cumulativeLost;
158 stats.fraction_lost = Q8ToFloat(call_stats.fractionLost);
solenberg8b85de22015-11-16 09:48:04 -0800159 stats.capture_start_ntp_time_ms = call_stats.capture_start_ntp_time_ms_;
solenberg85a04962015-10-27 03:35:21 -0700160 if (codec_inst.pltype != -1) {
161 stats.codec_name = codec_inst.plname;
Oskar Sundbom2707fb22017-11-16 10:57:35 +0100162 stats.codec_payload_type = codec_inst.pltype;
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +0200163 }
solenberg85a04962015-10-27 03:35:21 -0700164 stats.ext_seqnum = call_stats.extendedMax;
165 if (codec_inst.plfreq / 1000 > 0) {
166 stats.jitter_ms = call_stats.jitterSamples / (codec_inst.plfreq / 1000);
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +0200167 }
solenberg358057b2015-11-27 10:46:42 -0800168 stats.delay_estimate_ms = channel_proxy_->GetDelayEstimate();
169 stats.audio_level = channel_proxy_->GetSpeechOutputLevelFullRange();
zsteine76bd3a2017-07-14 12:17:49 -0700170 stats.total_output_energy = channel_proxy_->GetTotalOutputEnergy();
171 stats.total_output_duration = channel_proxy_->GetTotalOutputDuration();
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +0200172
solenberg8b85de22015-11-16 09:48:04 -0800173 // Get jitter buffer and total delay (alg + jitter + playout) stats.
solenberg358057b2015-11-27 10:46:42 -0800174 auto ns = channel_proxy_->GetNetworkStatistics();
solenberg8b85de22015-11-16 09:48:04 -0800175 stats.jitter_buffer_ms = ns.currentBufferSize;
176 stats.jitter_buffer_preferred_ms = ns.preferredBufferSize;
Steve Anton2dbc69f2017-08-24 17:15:13 -0700177 stats.total_samples_received = ns.totalSamplesReceived;
178 stats.concealed_samples = ns.concealedSamples;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200179 stats.concealment_events = ns.concealmentEvents;
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200180 stats.jitter_buffer_delay_seconds =
181 static_cast<double>(ns.jitterBufferDelayMs) /
182 static_cast<double>(rtc::kNumMillisecsPerSec);
solenberg8b85de22015-11-16 09:48:04 -0800183 stats.expand_rate = Q14ToFloat(ns.currentExpandRate);
184 stats.speech_expand_rate = Q14ToFloat(ns.currentSpeechExpandRate);
185 stats.secondary_decoded_rate = Q14ToFloat(ns.currentSecondaryDecodedRate);
minyue-webrtc0e320ec2017-08-28 13:51:27 +0200186 stats.secondary_discarded_rate = Q14ToFloat(ns.currentSecondaryDiscardedRate);
solenberg8b85de22015-11-16 09:48:04 -0800187 stats.accelerate_rate = Q14ToFloat(ns.currentAccelerateRate);
188 stats.preemptive_expand_rate = Q14ToFloat(ns.currentPreemptiveRate);
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +0200189
solenberg358057b2015-11-27 10:46:42 -0800190 auto ds = channel_proxy_->GetDecodingCallStatistics();
solenberg8b85de22015-11-16 09:48:04 -0800191 stats.decoding_calls_to_silence_generator = ds.calls_to_silence_generator;
192 stats.decoding_calls_to_neteq = ds.calls_to_neteq;
193 stats.decoding_normal = ds.decoded_normal;
194 stats.decoding_plc = ds.decoded_plc;
195 stats.decoding_cng = ds.decoded_cng;
196 stats.decoding_plc_cng = ds.decoded_plc_cng;
henrik.lundin63489782016-09-20 01:47:12 -0700197 stats.decoding_muted_output = ds.decoded_muted_output;
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +0200198
199 return stats;
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200200}
201
solenberg796b8f92017-03-01 17:02:23 -0800202int AudioReceiveStream::GetOutputLevel() const {
203 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
204 return channel_proxy_->GetSpeechOutputLevel();
205}
206
kwibergfffa42b2016-02-23 10:46:32 -0800207void AudioReceiveStream::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
solenberg3ebbcb52017-01-31 03:58:40 -0800208 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
kwibergfffa42b2016-02-23 10:46:32 -0800209 channel_proxy_->SetSink(std::move(sink));
Tommif888bb52015-12-12 01:37:01 +0100210}
211
solenberg217fb662016-06-17 08:30:54 -0700212void AudioReceiveStream::SetGain(float gain) {
solenberg3ebbcb52017-01-31 03:58:40 -0800213 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
solenberg217fb662016-06-17 08:30:54 -0700214 channel_proxy_->SetChannelOutputVolumeScaling(gain);
215}
216
hbos8d609f62017-04-10 07:39:05 -0700217std::vector<RtpSource> AudioReceiveStream::GetSources() const {
218 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
219 return channel_proxy_->GetSources();
220}
221
solenberg3ebbcb52017-01-31 03:58:40 -0800222AudioMixer::Source::AudioFrameInfo AudioReceiveStream::GetAudioFrameWithInfo(
223 int sample_rate_hz,
224 AudioFrame* audio_frame) {
225 return channel_proxy_->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
226}
227
228int AudioReceiveStream::Ssrc() const {
229 return config_.rtp.remote_ssrc;
230}
231
232int AudioReceiveStream::PreferredSampleRate() const {
solenberg2397b9a2017-09-22 06:48:10 -0700233 return channel_proxy_->PreferredSampleRate();
solenberg3ebbcb52017-01-31 03:58:40 -0800234}
235
236int AudioReceiveStream::id() const {
237 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
238 return config_.rtp.remote_ssrc;
239}
240
241rtc::Optional<Syncable::Info> AudioReceiveStream::GetInfo() const {
242 RTC_DCHECK_RUN_ON(&module_process_thread_checker_);
243 Syncable::Info info;
244
245 RtpRtcp* rtp_rtcp = nullptr;
246 RtpReceiver* rtp_receiver = nullptr;
247 channel_proxy_->GetRtpRtcp(&rtp_rtcp, &rtp_receiver);
248 RTC_DCHECK(rtp_rtcp);
249 RTC_DCHECK(rtp_receiver);
250
Niels Möllerc3fa8e12017-10-03 15:28:26 +0200251 if (!rtp_receiver->GetLatestTimestamps(
252 &info.latest_received_capture_timestamp,
253 &info.latest_receive_time_ms)) {
Oskar Sundbom2707fb22017-11-16 10:57:35 +0100254 return rtc::nullopt;
solenberg3ebbcb52017-01-31 03:58:40 -0800255 }
256 if (rtp_rtcp->RemoteNTP(&info.capture_time_ntp_secs,
257 &info.capture_time_ntp_frac,
258 nullptr,
259 nullptr,
260 &info.capture_time_source_clock) != 0) {
Oskar Sundbom2707fb22017-11-16 10:57:35 +0100261 return rtc::nullopt;
solenberg3ebbcb52017-01-31 03:58:40 -0800262 }
263
solenberg08b19df2017-02-15 00:42:31 -0800264 info.current_delay_ms = channel_proxy_->GetDelayEstimate();
Oskar Sundbom2707fb22017-11-16 10:57:35 +0100265 return info;
solenberg3ebbcb52017-01-31 03:58:40 -0800266}
267
268uint32_t AudioReceiveStream::GetPlayoutTimestamp() const {
269 // Called on video capture thread.
270 return channel_proxy_->GetPlayoutTimestamp();
271}
272
273void AudioReceiveStream::SetMinimumPlayoutDelay(int delay_ms) {
274 RTC_DCHECK_RUN_ON(&module_process_thread_checker_);
275 return channel_proxy_->SetMinimumPlayoutDelay(delay_ms);
pbosa2f30de2015-10-15 05:22:13 -0700276}
277
solenberg7602aab2016-11-14 11:30:07 -0800278void AudioReceiveStream::AssociateSendStream(AudioSendStream* send_stream) {
solenberg3ebbcb52017-01-31 03:58:40 -0800279 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
solenberg7602aab2016-11-14 11:30:07 -0800280 if (send_stream) {
281 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine());
282 std::unique_ptr<voe::ChannelProxy> send_channel_proxy =
eladalonabbc4302017-07-26 02:09:44 -0700283 voe_impl->GetChannelProxy(send_stream->GetConfig().voe_channel_id);
solenberg7602aab2016-11-14 11:30:07 -0800284 channel_proxy_->AssociateSendChannel(*send_channel_proxy.get());
285 } else {
286 channel_proxy_->DisassociateSendChannel();
287 }
288}
289
pbos1ba8d392016-05-01 20:18:34 -0700290void AudioReceiveStream::SignalNetworkState(NetworkState state) {
solenberg3ebbcb52017-01-31 03:58:40 -0800291 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
pbos1ba8d392016-05-01 20:18:34 -0700292}
293
294bool AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) {
295 // TODO(solenberg): Tests call this function on a network thread, libjingle
296 // calls on the worker thread. We should move towards always using a network
297 // thread. Then this check can be enabled.
298 // RTC_DCHECK(!thread_checker_.CalledOnValidThread());
299 return channel_proxy_->ReceivedRTCPPacket(packet, length);
300}
301
nisse657bab22017-02-21 06:28:10 -0800302void AudioReceiveStream::OnRtpPacket(const RtpPacketReceived& packet) {
pbos1ba8d392016-05-01 20:18:34 -0700303 // TODO(solenberg): Tests call this function on a network thread, libjingle
304 // calls on the worker thread. We should move towards always using a network
305 // thread. Then this check can be enabled.
306 // RTC_DCHECK(!thread_checker_.CalledOnValidThread());
nisse657bab22017-02-21 06:28:10 -0800307 channel_proxy_->OnRtpPacket(packet);
pbos1ba8d392016-05-01 20:18:34 -0700308}
309
solenberg3ebbcb52017-01-31 03:58:40 -0800310const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const {
311 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
312 return config_;
aleloi04c07222016-11-22 06:42:53 -0800313}
314
solenberg7add0582015-11-20 09:59:34 -0800315VoiceEngine* AudioReceiveStream::voice_engine() const {
aleloi04c07222016-11-22 06:42:53 -0800316 auto* voice_engine = audio_state()->voice_engine();
solenberg7add0582015-11-20 09:59:34 -0800317 RTC_DCHECK(voice_engine);
318 return voice_engine;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +0200319}
aleloi04c07222016-11-22 06:42:53 -0800320
solenberg3ebbcb52017-01-31 03:58:40 -0800321internal::AudioState* AudioReceiveStream::audio_state() const {
322 auto* audio_state = static_cast<internal::AudioState*>(audio_state_.get());
323 RTC_DCHECK(audio_state);
324 return audio_state;
325}
Fredrik Solenberg3b903d02018-01-10 15:17:10 +0100326
327AudioReceiveStream::ExtensionIds AudioReceiveStream::FindExtensionIds(
328 const std::vector<RtpExtension>& extensions) {
329 ExtensionIds ids;
330 for (const auto& extension : extensions) {
331 if (extension.uri == RtpExtension::kAudioLevelUri) {
332 ids.audio_level = extension.id;
333 } else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) {
334 ids.transport_sequence_number = extension.id;
335 }
336 }
337 return ids;
338}
339
340void AudioReceiveStream::ConfigureStream(AudioReceiveStream* stream,
341 const Config& new_config,
342 bool first_time) {
343 RTC_DCHECK(stream);
344 const auto& channel_proxy = stream->channel_proxy_;
345 const auto& old_config = stream->config_;
346
347 // Configuration parameters which cannot be changed.
348 RTC_DCHECK(first_time ||
349 old_config.voe_channel_id == new_config.voe_channel_id);
350 RTC_DCHECK(first_time ||
351 old_config.rtp.remote_ssrc == new_config.rtp.remote_ssrc);
352 RTC_DCHECK(first_time ||
353 old_config.rtcp_send_transport == new_config.rtcp_send_transport);
354 // Decoder factory cannot be changed because it is configured at
355 // voe::Channel construction time.
356 RTC_DCHECK(first_time ||
357 old_config.decoder_factory == new_config.decoder_factory);
358
359 if (first_time || old_config.rtp.local_ssrc != new_config.rtp.local_ssrc) {
360 channel_proxy->SetLocalSSRC(new_config.rtp.local_ssrc);
361 }
362 // TODO(solenberg): Config NACK history window (which is a packet count),
363 // using the actual packet size for the configured codec.
364 if (first_time || old_config.rtp.nack.rtp_history_ms !=
365 new_config.rtp.nack.rtp_history_ms) {
366 channel_proxy->SetNACKStatus(new_config.rtp.nack.rtp_history_ms != 0,
367 new_config.rtp.nack.rtp_history_ms / 20);
368 }
369 if (first_time || old_config.decoder_map != new_config.decoder_map) {
370 channel_proxy->SetReceiveCodecs(new_config.decoder_map);
371 }
372
373 // RTP Header Extensions.
374 const ExtensionIds old_ids = FindExtensionIds(old_config.rtp.extensions);
375 const ExtensionIds new_ids = FindExtensionIds(new_config.rtp.extensions);
376 if (first_time || new_ids.audio_level != old_ids.audio_level) {
377 channel_proxy->SetReceiveAudioLevelIndicationStatus(
378 new_ids.audio_level != 0, new_ids.audio_level);
379 }
380 if (first_time || new_ids.transport_sequence_number !=
381 old_ids.transport_sequence_number) {
382 channel_proxy->EnableReceiveTransportSequenceNumber(
383 new_ids.transport_sequence_number);
384 }
385
386 stream->config_ = new_config;
387}
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +0200388} // namespace internal
389} // namespace webrtc