solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "voice_engine/channel_proxy.h" |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 12 | |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 13 | #include <utility> |
| 14 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 15 | #include "api/call/audio_sink.h" |
| 16 | #include "call/rtp_transport_controller_send_interface.h" |
| 17 | #include "rtc_base/checks.h" |
| 18 | #include "rtc_base/logging.h" |
| 19 | #include "rtc_base/safe_minmax.h" |
| 20 | #include "voice_engine/channel.h" |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | namespace voe { |
| 24 | ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {} |
| 25 | |
| 26 | ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) : |
| 27 | channel_owner_(channel_owner) { |
| 28 | RTC_CHECK(channel_owner_.channel()); |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 29 | module_process_thread_checker_.DetachFromThread(); |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 30 | } |
| 31 | |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 32 | ChannelProxy::~ChannelProxy() {} |
| 33 | |
ossu | 1ffbd6c | 2017-04-06 12:05:04 -0700 | [diff] [blame] | 34 | bool ChannelProxy::SetEncoder(int payload_type, |
| 35 | std::unique_ptr<AudioEncoder> encoder) { |
| 36 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 37 | return channel()->SetEncoder(payload_type, std::move(encoder)); |
| 38 | } |
| 39 | |
ossu | 20a4b3f | 2017-04-27 02:08:52 -0700 | [diff] [blame] | 40 | void ChannelProxy::ModifyEncoder( |
| 41 | rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) { |
| 42 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 43 | channel()->ModifyEncoder(modifier); |
| 44 | } |
| 45 | |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 46 | void ChannelProxy::SetRTCPStatus(bool enable) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 47 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 48 | channel()->SetRTCPStatus(enable); |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | void ChannelProxy::SetLocalSSRC(uint32_t ssrc) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 52 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 53 | int error = channel()->SetLocalSSRC(ssrc); |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 54 | RTC_DCHECK_EQ(0, error); |
| 55 | } |
| 56 | |
| 57 | void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 58 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 59 | // Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array. |
| 60 | std::string c_name_limited = c_name.substr(0, 255); |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 61 | int error = channel()->SetRTCP_CNAME(c_name_limited.c_str()); |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 62 | RTC_DCHECK_EQ(0, error); |
| 63 | } |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 64 | |
solenberg | 971cab0 | 2016-06-14 10:02:41 -0700 | [diff] [blame] | 65 | void ChannelProxy::SetNACKStatus(bool enable, int max_packets) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 66 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 971cab0 | 2016-06-14 10:02:41 -0700 | [diff] [blame] | 67 | channel()->SetNACKStatus(enable, max_packets); |
| 68 | } |
| 69 | |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 70 | void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 71 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 72 | int error = channel()->SetSendAudioLevelIndicationStatus(enable, id); |
| 73 | RTC_DCHECK_EQ(0, error); |
| 74 | } |
| 75 | |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 76 | void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 77 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 78 | int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id); |
| 79 | RTC_DCHECK_EQ(0, error); |
| 80 | } |
| 81 | |
stefan | 3313ec9 | 2016-01-21 06:32:43 -0800 | [diff] [blame] | 82 | void ChannelProxy::EnableSendTransportSequenceNumber(int id) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 83 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
stefan | 3313ec9 | 2016-01-21 06:32:43 -0800 | [diff] [blame] | 84 | channel()->EnableSendTransportSequenceNumber(id); |
| 85 | } |
| 86 | |
| 87 | void ChannelProxy::EnableReceiveTransportSequenceNumber(int id) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 88 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
stefan | 3313ec9 | 2016-01-21 06:32:43 -0800 | [diff] [blame] | 89 | channel()->EnableReceiveTransportSequenceNumber(id); |
| 90 | } |
| 91 | |
stefan | bba9dec | 2016-02-01 04:39:55 -0800 | [diff] [blame] | 92 | void ChannelProxy::RegisterSenderCongestionControlObjects( |
nisse | b8f9a32 | 2017-03-27 05:36:15 -0700 | [diff] [blame] | 93 | RtpTransportControllerSendInterface* transport, |
stefan | 7de8d64 | 2017-02-07 07:14:08 -0800 | [diff] [blame] | 94 | RtcpBandwidthObserver* bandwidth_observer) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 95 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
nisse | b8f9a32 | 2017-03-27 05:36:15 -0700 | [diff] [blame] | 96 | channel()->RegisterSenderCongestionControlObjects(transport, |
| 97 | bandwidth_observer); |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame] | 98 | } |
| 99 | |
stefan | bba9dec | 2016-02-01 04:39:55 -0800 | [diff] [blame] | 100 | void ChannelProxy::RegisterReceiverCongestionControlObjects( |
| 101 | PacketRouter* packet_router) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 102 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
stefan | bba9dec | 2016-02-01 04:39:55 -0800 | [diff] [blame] | 103 | channel()->RegisterReceiverCongestionControlObjects(packet_router); |
| 104 | } |
| 105 | |
nisse | fdbfdc9 | 2017-03-31 05:44:52 -0700 | [diff] [blame] | 106 | void ChannelProxy::ResetSenderCongestionControlObjects() { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 107 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
nisse | fdbfdc9 | 2017-03-31 05:44:52 -0700 | [diff] [blame] | 108 | channel()->ResetSenderCongestionControlObjects(); |
| 109 | } |
| 110 | |
| 111 | void ChannelProxy::ResetReceiverCongestionControlObjects() { |
| 112 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 113 | channel()->ResetReceiverCongestionControlObjects(); |
stefan | bba9dec | 2016-02-01 04:39:55 -0800 | [diff] [blame] | 114 | } |
| 115 | |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 116 | CallStatistics ChannelProxy::GetRTCPStatistics() const { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 117 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 118 | CallStatistics stats = {0}; |
| 119 | int error = channel()->GetRTPStatistics(stats); |
| 120 | RTC_DCHECK_EQ(0, error); |
| 121 | return stats; |
| 122 | } |
| 123 | |
| 124 | std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 125 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 126 | std::vector<webrtc::ReportBlock> blocks; |
| 127 | int error = channel()->GetRemoteRTCPReportBlocks(&blocks); |
| 128 | RTC_DCHECK_EQ(0, error); |
| 129 | return blocks; |
| 130 | } |
| 131 | |
| 132 | NetworkStatistics ChannelProxy::GetNetworkStatistics() const { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 133 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 134 | NetworkStatistics stats = {0}; |
| 135 | int error = channel()->GetNetworkStatistics(stats); |
| 136 | RTC_DCHECK_EQ(0, error); |
| 137 | return stats; |
| 138 | } |
| 139 | |
| 140 | AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 141 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 142 | AudioDecodingCallStats stats; |
| 143 | channel()->GetDecodingCallStatistics(&stats); |
| 144 | return stats; |
| 145 | } |
| 146 | |
ivoc | e1198e0 | 2017-09-08 08:13:19 -0700 | [diff] [blame] | 147 | ANAStats ChannelProxy::GetANAStatistics() const { |
| 148 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 149 | return channel()->GetANAStatistics(); |
| 150 | } |
| 151 | |
solenberg | 8d73f8c | 2017-03-08 01:52:20 -0800 | [diff] [blame] | 152 | int ChannelProxy::GetSpeechOutputLevel() const { |
solenberg | 796b8f9 | 2017-03-01 17:02:23 -0800 | [diff] [blame] | 153 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 8d73f8c | 2017-03-08 01:52:20 -0800 | [diff] [blame] | 154 | return channel()->GetSpeechOutputLevel(); |
solenberg | 796b8f9 | 2017-03-01 17:02:23 -0800 | [diff] [blame] | 155 | } |
| 156 | |
solenberg | 8d73f8c | 2017-03-08 01:52:20 -0800 | [diff] [blame] | 157 | int ChannelProxy::GetSpeechOutputLevelFullRange() const { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 158 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 8d73f8c | 2017-03-08 01:52:20 -0800 | [diff] [blame] | 159 | return channel()->GetSpeechOutputLevelFullRange(); |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 160 | } |
| 161 | |
zstein | e76bd3a | 2017-07-14 12:17:49 -0700 | [diff] [blame] | 162 | double ChannelProxy::GetTotalOutputEnergy() const { |
| 163 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 164 | return channel()->GetTotalOutputEnergy(); |
| 165 | } |
| 166 | |
| 167 | double ChannelProxy::GetTotalOutputDuration() const { |
| 168 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 169 | return channel()->GetTotalOutputDuration(); |
| 170 | } |
| 171 | |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 172 | uint32_t ChannelProxy::GetDelayEstimate() const { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 173 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() || |
| 174 | module_process_thread_checker_.CalledOnValidThread()); |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 175 | return channel()->GetDelayEstimate(); |
| 176 | } |
| 177 | |
solenberg | ffbbcac | 2016-11-17 05:25:37 -0800 | [diff] [blame] | 178 | bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type, |
| 179 | int payload_frequency) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 180 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | ffbbcac | 2016-11-17 05:25:37 -0800 | [diff] [blame] | 181 | return channel()->SetSendTelephoneEventPayloadType(payload_type, |
| 182 | payload_frequency) == 0; |
Fredrik Solenberg | b572768 | 2015-12-04 15:22:19 +0100 | [diff] [blame] | 183 | } |
| 184 | |
solenberg | 8842c3e | 2016-03-11 03:06:41 -0800 | [diff] [blame] | 185 | bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 186 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 8842c3e | 2016-03-11 03:06:41 -0800 | [diff] [blame] | 187 | return channel()->SendTelephoneEventOutband(event, duration_ms) == 0; |
Fredrik Solenberg | b572768 | 2015-12-04 15:22:19 +0100 | [diff] [blame] | 188 | } |
| 189 | |
minyue | 78b4d56 | 2016-11-30 04:47:39 -0800 | [diff] [blame] | 190 | void ChannelProxy::SetBitrate(int bitrate_bps, int64_t probing_interval_ms) { |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 191 | // This method can be called on the worker thread, module process thread |
| 192 | // or on a TaskQueue via VideoSendStreamImpl::OnEncoderConfigurationChanged. |
| 193 | // TODO(solenberg): Figure out a good way to check this or enforce calling |
| 194 | // rules. |
| 195 | // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() || |
| 196 | // module_process_thread_checker_.CalledOnValidThread()); |
minyue | 78b4d56 | 2016-11-30 04:47:39 -0800 | [diff] [blame] | 197 | channel()->SetBitRate(bitrate_bps, probing_interval_ms); |
mflodman | 86cc6ff | 2016-07-26 04:44:06 -0700 | [diff] [blame] | 198 | } |
| 199 | |
kwiberg | 1c07c70 | 2017-03-27 07:15:49 -0700 | [diff] [blame] | 200 | void ChannelProxy::SetReceiveCodecs( |
| 201 | const std::map<int, SdpAudioFormat>& codecs) { |
| 202 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 203 | channel()->SetReceiveCodecs(codecs); |
| 204 | } |
| 205 | |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 206 | void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 207 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
deadbeef | 2d110be | 2016-01-13 12:00:26 -0800 | [diff] [blame] | 208 | channel()->SetSink(std::move(sink)); |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 209 | } |
| 210 | |
solenberg | 9421853 | 2016-06-16 10:53:22 -0700 | [diff] [blame] | 211 | void ChannelProxy::SetInputMute(bool muted) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 212 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 8d73f8c | 2017-03-08 01:52:20 -0800 | [diff] [blame] | 213 | channel()->SetInputMute(muted); |
solenberg | 9421853 | 2016-06-16 10:53:22 -0700 | [diff] [blame] | 214 | } |
| 215 | |
solenberg | 1c239d4 | 2017-09-29 06:00:28 -0700 | [diff] [blame] | 216 | void ChannelProxy::RegisterTransport(Transport* transport) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 217 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 1c239d4 | 2017-09-29 06:00:28 -0700 | [diff] [blame] | 218 | channel()->RegisterTransport(transport); |
mflodman | 3d7db26 | 2016-04-29 00:57:13 -0700 | [diff] [blame] | 219 | } |
| 220 | |
nisse | 657bab2 | 2017-02-21 06:28:10 -0800 | [diff] [blame] | 221 | void ChannelProxy::OnRtpPacket(const RtpPacketReceived& packet) { |
mflodman | 3d7db26 | 2016-04-29 00:57:13 -0700 | [diff] [blame] | 222 | // May be called on either worker thread or network thread. |
nisse | 657bab2 | 2017-02-21 06:28:10 -0800 | [diff] [blame] | 223 | channel()->OnRtpPacket(packet); |
mflodman | 3d7db26 | 2016-04-29 00:57:13 -0700 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) { |
| 227 | // May be called on either worker thread or network thread. |
| 228 | return channel()->ReceivedRTCPPacket(packet, length) == 0; |
| 229 | } |
| 230 | |
ossu | 29b1a8d | 2016-06-13 07:34:51 -0700 | [diff] [blame] | 231 | const rtc::scoped_refptr<AudioDecoderFactory>& |
solenberg | 217fb66 | 2016-06-17 08:30:54 -0700 | [diff] [blame] | 232 | ChannelProxy::GetAudioDecoderFactory() const { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 233 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
ossu | 29b1a8d | 2016-06-13 07:34:51 -0700 | [diff] [blame] | 234 | return channel()->GetAudioDecoderFactory(); |
| 235 | } |
| 236 | |
solenberg | 217fb66 | 2016-06-17 08:30:54 -0700 | [diff] [blame] | 237 | void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 238 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 8d73f8c | 2017-03-08 01:52:20 -0800 | [diff] [blame] | 239 | channel()->SetChannelOutputVolumeScaling(scaling); |
solenberg | 217fb66 | 2016-06-17 08:30:54 -0700 | [diff] [blame] | 240 | } |
| 241 | |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 242 | void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 243 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 244 | channel()->SetRtcEventLog(event_log); |
| 245 | } |
| 246 | |
aleloi | 6c27849 | 2016-10-20 14:24:39 -0700 | [diff] [blame] | 247 | AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo( |
| 248 | int sample_rate_hz, |
| 249 | AudioFrame* audio_frame) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 250 | RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); |
aleloi | 6c27849 | 2016-10-20 14:24:39 -0700 | [diff] [blame] | 251 | return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame); |
aleloi | aed581a | 2016-10-20 06:32:39 -0700 | [diff] [blame] | 252 | } |
| 253 | |
solenberg | 2397b9a | 2017-09-22 06:48:10 -0700 | [diff] [blame] | 254 | int ChannelProxy::PreferredSampleRate() const { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 255 | RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); |
solenberg | 2397b9a | 2017-09-22 06:48:10 -0700 | [diff] [blame] | 256 | return channel()->PreferredSampleRate(); |
aleloi | 051f678 | 2016-10-31 03:26:40 -0700 | [diff] [blame] | 257 | } |
| 258 | |
michaelt | 79e0588 | 2016-11-08 02:50:09 -0800 | [diff] [blame] | 259 | void ChannelProxy::SetTransportOverhead(int transport_overhead_per_packet) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 260 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
michaelt | 79e0588 | 2016-11-08 02:50:09 -0800 | [diff] [blame] | 261 | channel()->SetTransportOverhead(transport_overhead_per_packet); |
| 262 | } |
| 263 | |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 264 | void ChannelProxy::AssociateSendChannel( |
| 265 | const ChannelProxy& send_channel_proxy) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 266 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 267 | channel()->set_associate_send_channel(send_channel_proxy.channel_owner_); |
| 268 | } |
| 269 | |
| 270 | void ChannelProxy::DisassociateSendChannel() { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 271 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 272 | channel()->set_associate_send_channel(ChannelOwner(nullptr)); |
| 273 | } |
| 274 | |
solenberg | 3ebbcb5 | 2017-01-31 03:58:40 -0800 | [diff] [blame] | 275 | void ChannelProxy::GetRtpRtcp(RtpRtcp** rtp_rtcp, |
| 276 | RtpReceiver** rtp_receiver) const { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 277 | RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); |
solenberg | 3ebbcb5 | 2017-01-31 03:58:40 -0800 | [diff] [blame] | 278 | RTC_DCHECK(rtp_rtcp); |
| 279 | RTC_DCHECK(rtp_receiver); |
| 280 | int error = channel()->GetRtpRtcp(rtp_rtcp, rtp_receiver); |
| 281 | RTC_DCHECK_EQ(0, error); |
| 282 | } |
| 283 | |
solenberg | 3ebbcb5 | 2017-01-31 03:58:40 -0800 | [diff] [blame] | 284 | uint32_t ChannelProxy::GetPlayoutTimestamp() const { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 285 | RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_); |
solenberg | 3ebbcb5 | 2017-01-31 03:58:40 -0800 | [diff] [blame] | 286 | unsigned int timestamp = 0; |
| 287 | int error = channel()->GetPlayoutTimestamp(timestamp); |
| 288 | RTC_DCHECK(!error || timestamp == 0); |
| 289 | return timestamp; |
| 290 | } |
| 291 | |
| 292 | void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 293 | RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); |
solenberg | 3ebbcb5 | 2017-01-31 03:58:40 -0800 | [diff] [blame] | 294 | // Limit to range accepted by both VoE and ACM, so we're at least getting as |
| 295 | // close as possible, instead of failing. |
kwiberg | 0703856 | 2017-06-12 11:40:47 -0700 | [diff] [blame] | 296 | delay_ms = rtc::SafeClamp(delay_ms, 0, 10000); |
solenberg | 3ebbcb5 | 2017-01-31 03:58:40 -0800 | [diff] [blame] | 297 | int error = channel()->SetMinimumPlayoutDelay(delay_ms); |
solenberg | 0335e6c | 2017-02-22 07:07:04 -0800 | [diff] [blame] | 298 | if (0 != error) { |
| 299 | LOG(LS_WARNING) << "Error setting minimum playout delay."; |
| 300 | } |
solenberg | 3ebbcb5 | 2017-01-31 03:58:40 -0800 | [diff] [blame] | 301 | } |
| 302 | |
michaelt | 9332b7d | 2016-11-30 07:51:13 -0800 | [diff] [blame] | 303 | void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 304 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
michaelt | 9332b7d | 2016-11-30 07:51:13 -0800 | [diff] [blame] | 305 | channel()->SetRtcpRttStats(rtcp_rtt_stats); |
| 306 | } |
| 307 | |
solenberg | bd9a77f | 2017-02-06 12:53:57 -0800 | [diff] [blame] | 308 | bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const { |
solenberg | 08b19df | 2017-02-15 00:42:31 -0800 | [diff] [blame] | 309 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
solenberg | bd9a77f | 2017-02-06 12:53:57 -0800 | [diff] [blame] | 310 | return channel()->GetRecCodec(*codec_inst) == 0; |
| 311 | } |
| 312 | |
elad.alon | d12a8e1 | 2017-03-23 11:04:48 -0700 | [diff] [blame] | 313 | void ChannelProxy::OnTwccBasedUplinkPacketLossRate(float packet_loss_rate) { |
eladalon | 27e812e | 2017-08-25 01:50:58 -0700 | [diff] [blame] | 314 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
elad.alon | d12a8e1 | 2017-03-23 11:04:48 -0700 | [diff] [blame] | 315 | channel()->OnTwccBasedUplinkPacketLossRate(packet_loss_rate); |
| 316 | } |
| 317 | |
elad.alon | dadb4dc | 2017-03-23 15:29:50 -0700 | [diff] [blame] | 318 | void ChannelProxy::OnRecoverableUplinkPacketLossRate( |
| 319 | float recoverable_packet_loss_rate) { |
eladalon | 27e812e | 2017-08-25 01:50:58 -0700 | [diff] [blame] | 320 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
elad.alon | dadb4dc | 2017-03-23 15:29:50 -0700 | [diff] [blame] | 321 | channel()->OnRecoverableUplinkPacketLossRate(recoverable_packet_loss_rate); |
| 322 | } |
| 323 | |
hbos | 8d609f6 | 2017-04-10 07:39:05 -0700 | [diff] [blame] | 324 | std::vector<RtpSource> ChannelProxy::GetSources() const { |
| 325 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 326 | return channel()->GetSources(); |
| 327 | } |
| 328 | |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 329 | Channel* ChannelProxy::channel() const { |
| 330 | RTC_DCHECK(channel_owner_.channel()); |
| 331 | return channel_owner_.channel(); |
| 332 | } |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame] | 333 | |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 334 | } // namespace voe |
| 335 | } // namespace webrtc |