OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "webrtc/base/event.h" | 21 #include "webrtc/base/event.h" |
22 #include "webrtc/base/function_view.h" | 22 #include "webrtc/base/function_view.h" |
23 #include "webrtc/base/logging.h" | 23 #include "webrtc/base/logging.h" |
24 #include "webrtc/base/task_queue.h" | 24 #include "webrtc/base/task_queue.h" |
25 #include "webrtc/base/timeutils.h" | 25 #include "webrtc/base/timeutils.h" |
26 #include "webrtc/call/rtp_transport_controller_send_interface.h" | 26 #include "webrtc/call/rtp_transport_controller_send_interface.h" |
27 #include "webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h" | 27 #include "webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h" |
28 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 28 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
29 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont
roller.h" | 29 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont
roller.h" |
30 #include "webrtc/modules/pacing/paced_sender.h" | 30 #include "webrtc/modules/pacing/paced_sender.h" |
31 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | |
32 #include "webrtc/voice_engine/channel_proxy.h" | 31 #include "webrtc/voice_engine/channel_proxy.h" |
33 #include "webrtc/voice_engine/include/voe_base.h" | 32 #include "webrtc/voice_engine/include/voe_base.h" |
34 #include "webrtc/voice_engine/transmit_mixer.h" | 33 #include "webrtc/voice_engine/transmit_mixer.h" |
35 #include "webrtc/voice_engine/voice_engine_impl.h" | 34 #include "webrtc/voice_engine/voice_engine_impl.h" |
36 | 35 |
37 namespace webrtc { | 36 namespace webrtc { |
38 | 37 |
39 namespace internal { | 38 namespace internal { |
40 // TODO(elad.alon): Subsequent CL will make these values experiment-dependent. | 39 // TODO(elad.alon): Subsequent CL will make these values experiment-dependent. |
41 constexpr size_t kPacketLossTrackerMaxWindowSizeMs = 15000; | 40 constexpr size_t kPacketLossTrackerMaxWindowSizeMs = 15000; |
(...skipping 10 matching lines...) Expand all Loading... |
52 } | 51 } |
53 } // namespace | 52 } // namespace |
54 | 53 |
55 AudioSendStream::AudioSendStream( | 54 AudioSendStream::AudioSendStream( |
56 const webrtc::AudioSendStream::Config& config, | 55 const webrtc::AudioSendStream::Config& config, |
57 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, | 56 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, |
58 rtc::TaskQueue* worker_queue, | 57 rtc::TaskQueue* worker_queue, |
59 RtpTransportControllerSendInterface* transport, | 58 RtpTransportControllerSendInterface* transport, |
60 BitrateAllocator* bitrate_allocator, | 59 BitrateAllocator* bitrate_allocator, |
61 RtcEventLog* event_log, | 60 RtcEventLog* event_log, |
62 RtcpRttStats* rtcp_rtt_stats) | 61 RtcpRttStats* rtcp_rtt_stats, |
| 62 const rtc::Optional<RtpState>& suspended_rtp_state) |
63 : worker_queue_(worker_queue), | 63 : worker_queue_(worker_queue), |
64 config_(Config(nullptr)), | 64 config_(Config(nullptr)), |
65 audio_state_(audio_state), | 65 audio_state_(audio_state), |
66 event_log_(event_log), | 66 event_log_(event_log), |
67 bitrate_allocator_(bitrate_allocator), | 67 bitrate_allocator_(bitrate_allocator), |
68 transport_(transport), | 68 transport_(transport), |
69 packet_loss_tracker_(kPacketLossTrackerMaxWindowSizeMs, | 69 packet_loss_tracker_(kPacketLossTrackerMaxWindowSizeMs, |
70 kPacketLossRateMinNumAckedPackets, | 70 kPacketLossRateMinNumAckedPackets, |
71 kRecoverablePacketLossRateMinNumAckedPairs) { | 71 kRecoverablePacketLossRateMinNumAckedPairs), |
| 72 rtp_rtcp_module_(nullptr), |
| 73 suspended_rtp_state_(suspended_rtp_state) { |
72 LOG(LS_INFO) << "AudioSendStream: " << config.ToString(); | 74 LOG(LS_INFO) << "AudioSendStream: " << config.ToString(); |
73 RTC_DCHECK_NE(config.voe_channel_id, -1); | 75 RTC_DCHECK_NE(config.voe_channel_id, -1); |
74 RTC_DCHECK(audio_state_.get()); | 76 RTC_DCHECK(audio_state_.get()); |
75 RTC_DCHECK(transport); | 77 RTC_DCHECK(transport); |
76 RTC_DCHECK(transport->send_side_cc()); | 78 RTC_DCHECK(transport->send_side_cc()); |
77 | 79 |
78 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); | 80 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); |
79 channel_proxy_ = voe_impl->GetChannelProxy(config.voe_channel_id); | 81 channel_proxy_ = voe_impl->GetChannelProxy(config.voe_channel_id); |
80 channel_proxy_->SetRtcEventLog(event_log_); | 82 channel_proxy_->SetRtcEventLog(event_log_); |
81 channel_proxy_->SetRtcpRttStats(rtcp_rtt_stats); | 83 channel_proxy_->SetRtcpRttStats(rtcp_rtt_stats); |
82 channel_proxy_->SetRTCPStatus(true); | 84 channel_proxy_->SetRTCPStatus(true); |
83 transport_->send_side_cc()->RegisterPacketFeedbackObserver(this); | 85 transport_->send_side_cc()->RegisterPacketFeedbackObserver(this); |
| 86 RtpReceiver* rtpReceiver = nullptr; // Unused, but required for call. |
| 87 channel_proxy_->GetRtpRtcp(&rtp_rtcp_module_, &rtpReceiver); |
| 88 RTC_DCHECK(rtp_rtcp_module_); |
84 | 89 |
85 ConfigureStream(this, config, true); | 90 ConfigureStream(this, config, true); |
86 | 91 |
87 pacer_thread_checker_.DetachFromThread(); | 92 pacer_thread_checker_.DetachFromThread(); |
88 } | 93 } |
89 | 94 |
90 AudioSendStream::~AudioSendStream() { | 95 AudioSendStream::~AudioSendStream() { |
91 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 96 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
92 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); | 97 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); |
93 transport_->send_side_cc()->DeRegisterPacketFeedbackObserver(this); | 98 transport_->send_side_cc()->DeRegisterPacketFeedbackObserver(this); |
(...skipping 11 matching lines...) Expand all Loading... |
105 void AudioSendStream::ConfigureStream( | 110 void AudioSendStream::ConfigureStream( |
106 webrtc::internal::AudioSendStream* stream, | 111 webrtc::internal::AudioSendStream* stream, |
107 const webrtc::AudioSendStream::Config& new_config, | 112 const webrtc::AudioSendStream::Config& new_config, |
108 bool first_time) { | 113 bool first_time) { |
109 LOG(LS_INFO) << "AudioSendStream::Configuring: " << new_config.ToString(); | 114 LOG(LS_INFO) << "AudioSendStream::Configuring: " << new_config.ToString(); |
110 const auto& channel_proxy = stream->channel_proxy_; | 115 const auto& channel_proxy = stream->channel_proxy_; |
111 const auto& old_config = stream->config_; | 116 const auto& old_config = stream->config_; |
112 | 117 |
113 if (first_time || old_config.rtp.ssrc != new_config.rtp.ssrc) { | 118 if (first_time || old_config.rtp.ssrc != new_config.rtp.ssrc) { |
114 channel_proxy->SetLocalSSRC(new_config.rtp.ssrc); | 119 channel_proxy->SetLocalSSRC(new_config.rtp.ssrc); |
| 120 if (stream->suspended_rtp_state_) { |
| 121 stream->rtp_rtcp_module_->SetRtpState(*stream->suspended_rtp_state_); |
| 122 } |
115 } | 123 } |
116 if (first_time || old_config.rtp.c_name != new_config.rtp.c_name) { | 124 if (first_time || old_config.rtp.c_name != new_config.rtp.c_name) { |
117 channel_proxy->SetRTCP_CNAME(new_config.rtp.c_name); | 125 channel_proxy->SetRTCP_CNAME(new_config.rtp.c_name); |
118 } | 126 } |
119 // TODO(solenberg): Config NACK history window (which is a packet count), | 127 // TODO(solenberg): Config NACK history window (which is a packet count), |
120 // using the actual packet size for the configured codec. | 128 // using the actual packet size for the configured codec. |
121 if (first_time || old_config.rtp.nack.rtp_history_ms != | 129 if (first_time || old_config.rtp.nack.rtp_history_ms != |
122 new_config.rtp.nack.rtp_history_ms) { | 130 new_config.rtp.nack.rtp_history_ms) { |
123 channel_proxy->SetNACKStatus(new_config.rtp.nack.rtp_history_ms != 0, | 131 channel_proxy->SetNACKStatus(new_config.rtp.nack.rtp_history_ms != 0, |
124 new_config.rtp.nack.rtp_history_ms / 20); | 132 new_config.rtp.nack.rtp_history_ms / 20); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 return config_; | 376 return config_; |
369 } | 377 } |
370 | 378 |
371 void AudioSendStream::SetTransportOverhead(int transport_overhead_per_packet) { | 379 void AudioSendStream::SetTransportOverhead(int transport_overhead_per_packet) { |
372 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 380 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
373 transport_->send_side_cc()->SetTransportOverhead( | 381 transport_->send_side_cc()->SetTransportOverhead( |
374 transport_overhead_per_packet); | 382 transport_overhead_per_packet); |
375 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet); | 383 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet); |
376 } | 384 } |
377 | 385 |
| 386 RtpState AudioSendStream::GetRtpState() const { |
| 387 return rtp_rtcp_module_->GetRtpState(); |
| 388 } |
| 389 |
378 VoiceEngine* AudioSendStream::voice_engine() const { | 390 VoiceEngine* AudioSendStream::voice_engine() const { |
379 internal::AudioState* audio_state = | 391 internal::AudioState* audio_state = |
380 static_cast<internal::AudioState*>(audio_state_.get()); | 392 static_cast<internal::AudioState*>(audio_state_.get()); |
381 VoiceEngine* voice_engine = audio_state->voice_engine(); | 393 VoiceEngine* voice_engine = audio_state->voice_engine(); |
382 RTC_DCHECK(voice_engine); | 394 RTC_DCHECK(voice_engine); |
383 return voice_engine; | 395 return voice_engine; |
384 } | 396 } |
385 | 397 |
386 // Apply current codec settings to a single voe::Channel used for sending. | 398 // Apply current codec settings to a single voe::Channel used for sending. |
387 bool AudioSendStream::SetupSendCodec(AudioSendStream* stream, | 399 bool AudioSendStream::SetupSendCodec(AudioSendStream* stream, |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 rtc::Event thread_sync_event(false /* manual_reset */, false); | 593 rtc::Event thread_sync_event(false /* manual_reset */, false); |
582 worker_queue_->PostTask([this, &thread_sync_event] { | 594 worker_queue_->PostTask([this, &thread_sync_event] { |
583 bitrate_allocator_->RemoveObserver(this); | 595 bitrate_allocator_->RemoveObserver(this); |
584 thread_sync_event.Set(); | 596 thread_sync_event.Set(); |
585 }); | 597 }); |
586 thread_sync_event.Wait(rtc::Event::kForever); | 598 thread_sync_event.Wait(rtc::Event::kForever); |
587 } | 599 } |
588 | 600 |
589 void AudioSendStream::RegisterCngPayloadType(int payload_type, | 601 void AudioSendStream::RegisterCngPayloadType(int payload_type, |
590 int clockrate_hz) { | 602 int clockrate_hz) { |
591 RtpRtcp* rtpRtcpModule = nullptr; | |
592 RtpReceiver* rtpReceiver = nullptr; // Unused, but required for call. | |
593 channel_proxy_->GetRtpRtcp(&rtpRtcpModule, &rtpReceiver); | |
594 const CodecInst codec = {payload_type, "CN", clockrate_hz, 0, 1, 0}; | 603 const CodecInst codec = {payload_type, "CN", clockrate_hz, 0, 1, 0}; |
595 if (rtpRtcpModule->RegisterSendPayload(codec) != 0) { | 604 if (rtp_rtcp_module_->RegisterSendPayload(codec) != 0) { |
596 rtpRtcpModule->DeRegisterSendPayload(codec.pltype); | 605 rtp_rtcp_module_->DeRegisterSendPayload(codec.pltype); |
597 if (rtpRtcpModule->RegisterSendPayload(codec) != 0) { | 606 if (rtp_rtcp_module_->RegisterSendPayload(codec) != 0) { |
598 LOG(LS_ERROR) << "RegisterCngPayloadType() failed to register CN to " | 607 LOG(LS_ERROR) << "RegisterCngPayloadType() failed to register CN to " |
599 "RTP/RTCP module"; | 608 "RTP/RTCP module"; |
600 } | 609 } |
601 } | 610 } |
602 } | 611 } |
603 | 612 |
604 | 613 |
605 } // namespace internal | 614 } // namespace internal |
606 } // namespace webrtc | 615 } // namespace webrtc |
OLD | NEW |