blob: 6f43576eeca9746b9d469016ecac5dad43747c1a [file] [log] [blame]
Fredrik Solenberg23fba1f2015-04-29 13:24:011/*
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 04:47:3111#include "audio/audio_receive_stream.h"
Fredrik Solenberg23fba1f2015-04-29 13:24:0112
13#include <string>
Tommif888bb52015-12-12 00:37:0114#include <utility>
Fredrik Solenberg23fba1f2015-04-29 13:24:0115
Mirko Bonadei92ea95e2017-09-15 04:47:3116#include "api/call/audio_sink.h"
17#include "audio/audio_send_stream.h"
18#include "audio/audio_state.h"
Fredrik Solenberga8b7c7f2018-01-17 10:18:3119#include "audio/channel_proxy.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3120#include "audio/conversion.h"
21#include "call/rtp_stream_receiver_controller_interface.h"
22#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
23#include "modules/rtp_rtcp/include/rtp_receiver.h"
24#include "modules/rtp_rtcp/include/rtp_rtcp.h"
25#include "rtc_base/checks.h"
26#include "rtc_base/logging.h"
Tommifef05002018-02-27 12:51:0827#include "rtc_base/strings/string_builder.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3128#include "rtc_base/timeutils.h"
Fredrik Solenberg23fba1f2015-04-29 13:24:0129
30namespace webrtc {
Stefan Holmer3842c5c2016-01-12 12:55:0031
Fredrik Solenberg23fba1f2015-04-29 13:24:0132std::string AudioReceiveStream::Config::Rtp::ToString() const {
Karl Wiberg881f1682018-03-08 14:03:2333 char ss_buf[1024];
34 rtc::SimpleStringBuilder ss(ss_buf);
Fredrik Solenberg23fba1f2015-04-29 13:24:0135 ss << "{remote_ssrc: " << remote_ssrc;
solenberg85a04962015-10-27 10:35:2136 ss << ", local_ssrc: " << local_ssrc;
solenberg8189b022016-06-14 19:13:0037 ss << ", transport_cc: " << (transport_cc ? "on" : "off");
38 ss << ", nack: " << nack.ToString();
Fredrik Solenberg23fba1f2015-04-29 13:24:0139 ss << ", extensions: [";
40 for (size_t i = 0; i < extensions.size(); ++i) {
41 ss << extensions[i].ToString();
Fredrik Solenberg4f4ec0a2015-10-22 08:49:2742 if (i != extensions.size() - 1) {
Fredrik Solenberg23fba1f2015-04-29 13:24:0143 ss << ", ";
Fredrik Solenberg4f4ec0a2015-10-22 08:49:2744 }
Fredrik Solenberg23fba1f2015-04-29 13:24:0145 }
46 ss << ']';
47 ss << '}';
48 return ss.str();
49}
50
51std::string AudioReceiveStream::Config::ToString() const {
Karl Wiberg881f1682018-03-08 14:03:2352 char ss_buf[1024];
53 rtc::SimpleStringBuilder ss(ss_buf);
Fredrik Solenberg23fba1f2015-04-29 13:24:0154 ss << "{rtp: " << rtp.ToString();
solenberg85a04962015-10-27 10:35:2155 ss << ", rtcp_send_transport: "
deadbeef922246a2017-02-26 12:18:1256 << (rtcp_send_transport ? "(Transport)" : "null");
Fredrik Solenberg4f4ec0a2015-10-22 08:49:2757 if (!sync_group.empty()) {
pbos8fc7fa72015-07-15 15:02:5858 ss << ", sync_group: " << sync_group;
Fredrik Solenberg4f4ec0a2015-10-22 08:49:2759 }
Fredrik Solenberg23fba1f2015-04-29 13:24:0160 ss << '}';
61 return ss.str();
62}
63
64namespace internal {
Fredrik Solenberg8f5787a2018-01-11 12:52:3065namespace {
66std::unique_ptr<voe::ChannelProxy> CreateChannelAndProxy(
67 webrtc::AudioState* audio_state,
68 ProcessThread* module_process_thread,
69 const webrtc::AudioReceiveStream::Config& config) {
70 RTC_DCHECK(audio_state);
71 internal::AudioState* internal_audio_state =
72 static_cast<internal::AudioState*>(audio_state);
Karl Wiberg08126342018-03-20 18:18:5573 return std::unique_ptr<voe::ChannelProxy>(
74 new voe::ChannelProxy(std::unique_ptr<voe::Channel>(new voe::Channel(
75 module_process_thread, internal_audio_state->audio_device_module(),
Tommi5f223652018-03-26 11:28:2676 nullptr /* RtcpRttStats */, config.jitter_buffer_max_packets,
Karl Wiberg08126342018-03-20 18:18:5577 config.jitter_buffer_fast_accelerate, config.decoder_factory,
78 config.codec_pair_id))));
Fredrik Solenberg8f5787a2018-01-11 12:52:3079}
80} // namespace
81
82AudioReceiveStream::AudioReceiveStream(
83 RtpStreamReceiverControllerInterface* receiver_controller,
84 PacketRouter* packet_router,
85 ProcessThread* module_process_thread,
86 const webrtc::AudioReceiveStream::Config& config,
87 const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
88 webrtc::RtcEventLog* event_log)
89 : AudioReceiveStream(receiver_controller,
90 packet_router,
91 config,
92 audio_state,
93 event_log,
94 CreateChannelAndProxy(audio_state.get(),
95 module_process_thread,
96 config)) {}
97
Fredrik Solenberg23fba1f2015-04-29 13:24:0198AudioReceiveStream::AudioReceiveStream(
nisse0f15f922017-06-21 08:05:2299 RtpStreamReceiverControllerInterface* receiver_controller,
nisse0245da02016-11-30 11:35:20100 PacketRouter* packet_router,
solenberg566ef242015-11-06 23:34:49101 const webrtc::AudioReceiveStream::Config& config,
ivoc14d5dbe2016-07-04 14:06:55102 const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
Fredrik Solenberg8f5787a2018-01-11 12:52:30103 webrtc::RtcEventLog* event_log,
104 std::unique_ptr<voe::ChannelProxy> channel_proxy)
Yves Gerey665174f2018-06-19 13:03:05105 : audio_state_(audio_state), channel_proxy_(std::move(channel_proxy)) {
Jonas Olsson24ea8222018-01-25 09:14:29106 RTC_LOG(LS_INFO) << "AudioReceiveStream: " << config.rtp.remote_ssrc;
Fredrik Solenberg8f5787a2018-01-11 12:52:30107 RTC_DCHECK(receiver_controller);
nisse0245da02016-11-30 11:35:20108 RTC_DCHECK(packet_router);
Fredrik Solenberg8f5787a2018-01-11 12:52:30109 RTC_DCHECK(config.decoder_factory);
110 RTC_DCHECK(audio_state_);
111 RTC_DCHECK(channel_proxy_);
solenberg7add0582015-11-20 17:59:34112
solenberg3ebbcb52017-01-31 11:58:40113 module_process_thread_checker_.DetachFromThread();
114
Fredrik Solenberg3b903d02018-01-10 14:17:10115 channel_proxy_->SetRtcEventLog(event_log);
solenberg1c239d42017-09-29 13:00:28116 channel_proxy_->RegisterTransport(config.rtcp_send_transport);
kwibergd32bf752017-01-19 15:03:59117
Stefan Holmer3842c5c2016-01-12 12:55:00118 // Configure bandwidth estimation.
nisse0245da02016-11-30 11:35:20119 channel_proxy_->RegisterReceiverCongestionControlObjects(packet_router);
nisse0f15f922017-06-21 08:05:22120
121 // Register with transport.
Yves Gerey665174f2018-06-19 13:03:05122 rtp_stream_receiver_ = receiver_controller->CreateReceiver(
123 config.rtp.remote_ssrc, channel_proxy_.get());
Fredrik Solenberg3b903d02018-01-10 14:17:10124
125 ConfigureStream(this, config, true);
Fredrik Solenberg23fba1f2015-04-29 13:24:01126}
127
pbosa2f30de2015-10-15 12:22:13128AudioReceiveStream::~AudioReceiveStream() {
solenberg3ebbcb52017-01-31 11:58:40129 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
Jonas Olsson24ea8222018-01-25 09:14:29130 RTC_LOG(LS_INFO) << "~AudioReceiveStream: " << config_.rtp.remote_ssrc;
Fredrik Solenbergd5247512017-12-18 21:41:03131 Stop();
solenberg7602aab2016-11-14 19:30:07132 channel_proxy_->DisassociateSendChannel();
solenberg1c239d42017-09-29 13:00:28133 channel_proxy_->RegisterTransport(nullptr);
nissefdbfdc92017-03-31 12:44:52134 channel_proxy_->ResetReceiverCongestionControlObjects();
ivoc14d5dbe2016-07-04 14:06:55135 channel_proxy_->SetRtcEventLog(nullptr);
pbosa2f30de2015-10-15 12:22:13136}
137
Fredrik Solenberg3b903d02018-01-10 14:17:10138void AudioReceiveStream::Reconfigure(
139 const webrtc::AudioReceiveStream::Config& config) {
140 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
Fredrik Solenberg3b903d02018-01-10 14:17:10141 ConfigureStream(this, config, false);
142}
143
solenberg7add0582015-11-20 17:59:34144void AudioReceiveStream::Start() {
solenberg3ebbcb52017-01-31 11:58:40145 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
aleloi04c07222016-11-22 14:42:53146 if (playing_) {
147 return;
148 }
Fredrik Solenbergd5247512017-12-18 21:41:03149 channel_proxy_->StartPlayout();
aleloi04c07222016-11-22 14:42:53150 playing_ = true;
Fredrik Solenbergd5247512017-12-18 21:41:03151 audio_state()->AddReceivingStream(this);
solenberg7add0582015-11-20 17:59:34152}
153
154void AudioReceiveStream::Stop() {
solenberg3ebbcb52017-01-31 11:58:40155 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
aleloi04c07222016-11-22 14:42:53156 if (!playing_) {
157 return;
158 }
Fredrik Solenbergd5247512017-12-18 21:41:03159 channel_proxy_->StopPlayout();
aleloi04c07222016-11-22 14:42:53160 playing_ = false;
Fredrik Solenbergd5247512017-12-18 21:41:03161 audio_state()->RemoveReceivingStream(this);
solenberg7add0582015-11-20 17:59:34162}
163
Fredrik Solenberg04f49312015-06-08 11:04:56164webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const {
solenberg3ebbcb52017-01-31 11:58:40165 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
Fredrik Solenberg4f4ec0a2015-10-22 08:49:27166 webrtc::AudioReceiveStream::Stats stats;
167 stats.remote_ssrc = config_.rtp.remote_ssrc;
solenberg8b85de22015-11-16 17:48:04168
solenberg358057b2015-11-27 18:46:42169 webrtc::CallStatistics call_stats = channel_proxy_->GetRTCPStatistics();
solenbergbd9a77f2017-02-06 20:53:57170 // TODO(solenberg): Don't return here if we can't get the codec - return the
171 // stats we *can* get.
solenberg85a04962015-10-27 10:35:21172 webrtc::CodecInst codec_inst = {0};
solenbergbd9a77f2017-02-06 20:53:57173 if (!channel_proxy_->GetRecCodec(&codec_inst)) {
Fredrik Solenberg4f4ec0a2015-10-22 08:49:27174 return stats;
175 }
176
solenberg85a04962015-10-27 10:35:21177 stats.bytes_rcvd = call_stats.bytesReceived;
178 stats.packets_rcvd = call_stats.packetsReceived;
179 stats.packets_lost = call_stats.cumulativeLost;
180 stats.fraction_lost = Q8ToFloat(call_stats.fractionLost);
solenberg8b85de22015-11-16 17:48:04181 stats.capture_start_ntp_time_ms = call_stats.capture_start_ntp_time_ms_;
solenberg85a04962015-10-27 10:35:21182 if (codec_inst.pltype != -1) {
183 stats.codec_name = codec_inst.plname;
Oskar Sundbom2707fb22017-11-16 09:57:35184 stats.codec_payload_type = codec_inst.pltype;
Fredrik Solenberg4f4ec0a2015-10-22 08:49:27185 }
solenberg85a04962015-10-27 10:35:21186 stats.ext_seqnum = call_stats.extendedMax;
187 if (codec_inst.plfreq / 1000 > 0) {
188 stats.jitter_ms = call_stats.jitterSamples / (codec_inst.plfreq / 1000);
Fredrik Solenberg4f4ec0a2015-10-22 08:49:27189 }
solenberg358057b2015-11-27 18:46:42190 stats.delay_estimate_ms = channel_proxy_->GetDelayEstimate();
191 stats.audio_level = channel_proxy_->GetSpeechOutputLevelFullRange();
zsteine76bd3a2017-07-14 19:17:49192 stats.total_output_energy = channel_proxy_->GetTotalOutputEnergy();
193 stats.total_output_duration = channel_proxy_->GetTotalOutputDuration();
Fredrik Solenberg4f4ec0a2015-10-22 08:49:27194
solenberg8b85de22015-11-16 17:48:04195 // Get jitter buffer and total delay (alg + jitter + playout) stats.
solenberg358057b2015-11-27 18:46:42196 auto ns = channel_proxy_->GetNetworkStatistics();
solenberg8b85de22015-11-16 17:48:04197 stats.jitter_buffer_ms = ns.currentBufferSize;
198 stats.jitter_buffer_preferred_ms = ns.preferredBufferSize;
Steve Anton2dbc69f2017-08-25 00:15:13199 stats.total_samples_received = ns.totalSamplesReceived;
200 stats.concealed_samples = ns.concealedSamples;
Gustaf Ullberg9a2e9062017-09-18 07:28:20201 stats.concealment_events = ns.concealmentEvents;
Gustaf Ullbergb0a02072017-10-02 10:00:34202 stats.jitter_buffer_delay_seconds =
203 static_cast<double>(ns.jitterBufferDelayMs) /
204 static_cast<double>(rtc::kNumMillisecsPerSec);
solenberg8b85de22015-11-16 17:48:04205 stats.expand_rate = Q14ToFloat(ns.currentExpandRate);
206 stats.speech_expand_rate = Q14ToFloat(ns.currentSpeechExpandRate);
207 stats.secondary_decoded_rate = Q14ToFloat(ns.currentSecondaryDecodedRate);
minyue-webrtc0e320ec2017-08-28 11:51:27208 stats.secondary_discarded_rate = Q14ToFloat(ns.currentSecondaryDiscardedRate);
solenberg8b85de22015-11-16 17:48:04209 stats.accelerate_rate = Q14ToFloat(ns.currentAccelerateRate);
210 stats.preemptive_expand_rate = Q14ToFloat(ns.currentPreemptiveRate);
Fredrik Solenberg4f4ec0a2015-10-22 08:49:27211
solenberg358057b2015-11-27 18:46:42212 auto ds = channel_proxy_->GetDecodingCallStatistics();
solenberg8b85de22015-11-16 17:48:04213 stats.decoding_calls_to_silence_generator = ds.calls_to_silence_generator;
214 stats.decoding_calls_to_neteq = ds.calls_to_neteq;
215 stats.decoding_normal = ds.decoded_normal;
216 stats.decoding_plc = ds.decoded_plc;
217 stats.decoding_cng = ds.decoded_cng;
218 stats.decoding_plc_cng = ds.decoded_plc_cng;
henrik.lundin63489782016-09-20 08:47:12219 stats.decoding_muted_output = ds.decoded_muted_output;
Fredrik Solenberg4f4ec0a2015-10-22 08:49:27220
221 return stats;
Fredrik Solenberg04f49312015-06-08 11:04:56222}
223
Fredrik Solenberg8f5787a2018-01-11 12:52:30224void AudioReceiveStream::SetSink(AudioSinkInterface* sink) {
solenberg3ebbcb52017-01-31 11:58:40225 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
Fredrik Solenberg8f5787a2018-01-11 12:52:30226 channel_proxy_->SetSink(sink);
Tommif888bb52015-12-12 00:37:01227}
228
solenberg217fb662016-06-17 15:30:54229void AudioReceiveStream::SetGain(float gain) {
solenberg3ebbcb52017-01-31 11:58:40230 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
solenberg217fb662016-06-17 15:30:54231 channel_proxy_->SetChannelOutputVolumeScaling(gain);
232}
233
hbos8d609f62017-04-10 14:39:05234std::vector<RtpSource> AudioReceiveStream::GetSources() const {
235 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
236 return channel_proxy_->GetSources();
237}
238
solenberg3ebbcb52017-01-31 11:58:40239AudioMixer::Source::AudioFrameInfo AudioReceiveStream::GetAudioFrameWithInfo(
240 int sample_rate_hz,
241 AudioFrame* audio_frame) {
242 return channel_proxy_->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
243}
244
245int AudioReceiveStream::Ssrc() const {
246 return config_.rtp.remote_ssrc;
247}
248
249int AudioReceiveStream::PreferredSampleRate() const {
solenberg2397b9a2017-09-22 13:48:10250 return channel_proxy_->PreferredSampleRate();
solenberg3ebbcb52017-01-31 11:58:40251}
252
253int AudioReceiveStream::id() const {
254 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
255 return config_.rtp.remote_ssrc;
256}
257
Danil Chapovalovb9b146c2018-06-15 10:28:07258absl::optional<Syncable::Info> AudioReceiveStream::GetInfo() const {
solenberg3ebbcb52017-01-31 11:58:40259 RTC_DCHECK_RUN_ON(&module_process_thread_checker_);
260 Syncable::Info info;
261
262 RtpRtcp* rtp_rtcp = nullptr;
263 RtpReceiver* rtp_receiver = nullptr;
264 channel_proxy_->GetRtpRtcp(&rtp_rtcp, &rtp_receiver);
265 RTC_DCHECK(rtp_rtcp);
266 RTC_DCHECK(rtp_receiver);
267
Niels Möllerc3fa8e12017-10-03 13:28:26268 if (!rtp_receiver->GetLatestTimestamps(
269 &info.latest_received_capture_timestamp,
270 &info.latest_receive_time_ms)) {
Danil Chapovalovb9b146c2018-06-15 10:28:07271 return absl::nullopt;
solenberg3ebbcb52017-01-31 11:58:40272 }
273 if (rtp_rtcp->RemoteNTP(&info.capture_time_ntp_secs,
Yves Gerey665174f2018-06-19 13:03:05274 &info.capture_time_ntp_frac, nullptr, nullptr,
solenberg3ebbcb52017-01-31 11:58:40275 &info.capture_time_source_clock) != 0) {
Danil Chapovalovb9b146c2018-06-15 10:28:07276 return absl::nullopt;
solenberg3ebbcb52017-01-31 11:58:40277 }
278
solenberg08b19df2017-02-15 08:42:31279 info.current_delay_ms = channel_proxy_->GetDelayEstimate();
Oskar Sundbom2707fb22017-11-16 09:57:35280 return info;
solenberg3ebbcb52017-01-31 11:58:40281}
282
283uint32_t AudioReceiveStream::GetPlayoutTimestamp() const {
284 // Called on video capture thread.
285 return channel_proxy_->GetPlayoutTimestamp();
286}
287
288void AudioReceiveStream::SetMinimumPlayoutDelay(int delay_ms) {
289 RTC_DCHECK_RUN_ON(&module_process_thread_checker_);
290 return channel_proxy_->SetMinimumPlayoutDelay(delay_ms);
pbosa2f30de2015-10-15 12:22:13291}
292
solenberg7602aab2016-11-14 19:30:07293void AudioReceiveStream::AssociateSendStream(AudioSendStream* send_stream) {
solenberg3ebbcb52017-01-31 11:58:40294 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
solenberg7602aab2016-11-14 19:30:07295 if (send_stream) {
Fredrik Solenberg8f5787a2018-01-11 12:52:30296 channel_proxy_->AssociateSendChannel(send_stream->GetChannelProxy());
solenberg7602aab2016-11-14 19:30:07297 } else {
298 channel_proxy_->DisassociateSendChannel();
299 }
Fredrik Solenberg8f5787a2018-01-11 12:52:30300 associated_send_stream_ = send_stream;
solenberg7602aab2016-11-14 19:30:07301}
302
pbos1ba8d392016-05-02 03:18:34303void AudioReceiveStream::SignalNetworkState(NetworkState state) {
solenberg3ebbcb52017-01-31 11:58:40304 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
pbos1ba8d392016-05-02 03:18:34305}
306
307bool AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) {
308 // TODO(solenberg): Tests call this function on a network thread, libjingle
309 // calls on the worker thread. We should move towards always using a network
310 // thread. Then this check can be enabled.
311 // RTC_DCHECK(!thread_checker_.CalledOnValidThread());
312 return channel_proxy_->ReceivedRTCPPacket(packet, length);
313}
314
nisse657bab22017-02-21 14:28:10315void AudioReceiveStream::OnRtpPacket(const RtpPacketReceived& packet) {
pbos1ba8d392016-05-02 03:18:34316 // TODO(solenberg): Tests call this function on a network thread, libjingle
317 // calls on the worker thread. We should move towards always using a network
318 // thread. Then this check can be enabled.
319 // RTC_DCHECK(!thread_checker_.CalledOnValidThread());
nisse657bab22017-02-21 14:28:10320 channel_proxy_->OnRtpPacket(packet);
pbos1ba8d392016-05-02 03:18:34321}
322
solenberg3ebbcb52017-01-31 11:58:40323const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const {
324 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
325 return config_;
aleloi04c07222016-11-22 14:42:53326}
327
Yves Gerey665174f2018-06-19 13:03:05328const AudioSendStream* AudioReceiveStream::GetAssociatedSendStreamForTesting()
329 const {
Fredrik Solenberg8f5787a2018-01-11 12:52:30330 RTC_DCHECK_RUN_ON(&worker_thread_checker_);
331 return associated_send_stream_;
Fredrik Solenberg23fba1f2015-04-29 13:24:01332}
aleloi04c07222016-11-22 14:42:53333
solenberg3ebbcb52017-01-31 11:58:40334internal::AudioState* AudioReceiveStream::audio_state() const {
335 auto* audio_state = static_cast<internal::AudioState*>(audio_state_.get());
336 RTC_DCHECK(audio_state);
337 return audio_state;
338}
Fredrik Solenberg3b903d02018-01-10 14:17:10339
Fredrik Solenberg3b903d02018-01-10 14:17:10340void AudioReceiveStream::ConfigureStream(AudioReceiveStream* stream,
341 const Config& new_config,
342 bool first_time) {
Jonas Olsson24ea8222018-01-25 09:14:29343 RTC_LOG(LS_INFO) << "AudioReceiveStream::ConfigureStream: "
344 << new_config.ToString();
Fredrik Solenberg3b903d02018-01-10 14:17:10345 RTC_DCHECK(stream);
346 const auto& channel_proxy = stream->channel_proxy_;
347 const auto& old_config = stream->config_;
348
349 // Configuration parameters which cannot be changed.
350 RTC_DCHECK(first_time ||
Fredrik Solenberg3b903d02018-01-10 14:17:10351 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 }
Niels Möllerf7824922018-05-25 11:41:10362
363 if (first_time) {
364 channel_proxy->SetRemoteSSRC(new_config.rtp.remote_ssrc);
365 } else {
366 // Remote ssrc can't be changed mid-stream.
367 RTC_DCHECK_EQ(old_config.rtp.remote_ssrc, new_config.rtp.remote_ssrc);
368 }
369
Fredrik Solenberg3b903d02018-01-10 14:17:10370 // TODO(solenberg): Config NACK history window (which is a packet count),
371 // using the actual packet size for the configured codec.
372 if (first_time || old_config.rtp.nack.rtp_history_ms !=
373 new_config.rtp.nack.rtp_history_ms) {
374 channel_proxy->SetNACKStatus(new_config.rtp.nack.rtp_history_ms != 0,
375 new_config.rtp.nack.rtp_history_ms / 20);
376 }
377 if (first_time || old_config.decoder_map != new_config.decoder_map) {
378 channel_proxy->SetReceiveCodecs(new_config.decoder_map);
379 }
380
Fredrik Solenberg3b903d02018-01-10 14:17:10381 stream->config_ = new_config;
382}
Fredrik Solenberg23fba1f2015-04-29 13:24:01383} // namespace internal
384} // namespace webrtc