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 |
11 #include "webrtc/voice_engine/channel_proxy.h" | 11 #include "webrtc/voice_engine/channel_proxy.h" |
12 | 12 |
13 #include <utility> | 13 #include <utility> |
14 | 14 |
15 #include "webrtc/api/call/audio_sink.h" | 15 #include "webrtc/api/call/audio_sink.h" |
16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
17 #include "webrtc/voice_engine/channel.h" | 17 #include "webrtc/voice_engine/channel.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 namespace voe { | 20 namespace voe { |
21 ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {} | 21 ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {} |
22 | 22 |
23 ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) : | 23 ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) : |
24 channel_owner_(channel_owner) { | 24 channel_owner_(channel_owner) { |
25 RTC_CHECK(channel_owner_.channel()); | 25 RTC_CHECK(channel_owner_.channel()); |
| 26 module_process_thread_checker_.DetachFromThread(); |
26 } | 27 } |
27 | 28 |
28 ChannelProxy::~ChannelProxy() {} | 29 ChannelProxy::~ChannelProxy() {} |
29 | 30 |
30 void ChannelProxy::SetRTCPStatus(bool enable) { | 31 void ChannelProxy::SetRTCPStatus(bool enable) { |
| 32 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
31 channel()->SetRTCPStatus(enable); | 33 channel()->SetRTCPStatus(enable); |
32 } | 34 } |
33 | 35 |
34 void ChannelProxy::SetLocalSSRC(uint32_t ssrc) { | 36 void ChannelProxy::SetLocalSSRC(uint32_t ssrc) { |
35 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 37 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
36 int error = channel()->SetLocalSSRC(ssrc); | 38 int error = channel()->SetLocalSSRC(ssrc); |
37 RTC_DCHECK_EQ(0, error); | 39 RTC_DCHECK_EQ(0, error); |
38 } | 40 } |
39 | 41 |
40 void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) { | 42 void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) { |
41 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 43 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
42 // Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array. | 44 // Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array. |
43 std::string c_name_limited = c_name.substr(0, 255); | 45 std::string c_name_limited = c_name.substr(0, 255); |
44 int error = channel()->SetRTCP_CNAME(c_name_limited.c_str()); | 46 int error = channel()->SetRTCP_CNAME(c_name_limited.c_str()); |
45 RTC_DCHECK_EQ(0, error); | 47 RTC_DCHECK_EQ(0, error); |
46 } | 48 } |
47 | 49 |
48 void ChannelProxy::SetNACKStatus(bool enable, int max_packets) { | 50 void ChannelProxy::SetNACKStatus(bool enable, int max_packets) { |
49 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 51 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
50 channel()->SetNACKStatus(enable, max_packets); | 52 channel()->SetNACKStatus(enable, max_packets); |
51 } | 53 } |
52 | 54 |
53 void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) { | 55 void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) { |
54 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 56 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
55 int error = channel()->SetSendAudioLevelIndicationStatus(enable, id); | 57 int error = channel()->SetSendAudioLevelIndicationStatus(enable, id); |
56 RTC_DCHECK_EQ(0, error); | 58 RTC_DCHECK_EQ(0, error); |
57 } | 59 } |
58 | 60 |
59 void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id) { | 61 void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id) { |
60 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 62 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
61 int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id); | 63 int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id); |
62 RTC_DCHECK_EQ(0, error); | 64 RTC_DCHECK_EQ(0, error); |
63 } | 65 } |
64 | 66 |
65 void ChannelProxy::EnableSendTransportSequenceNumber(int id) { | 67 void ChannelProxy::EnableSendTransportSequenceNumber(int id) { |
66 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 68 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
67 channel()->EnableSendTransportSequenceNumber(id); | 69 channel()->EnableSendTransportSequenceNumber(id); |
68 } | 70 } |
69 | 71 |
70 void ChannelProxy::EnableReceiveTransportSequenceNumber(int id) { | 72 void ChannelProxy::EnableReceiveTransportSequenceNumber(int id) { |
71 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 73 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
72 channel()->EnableReceiveTransportSequenceNumber(id); | 74 channel()->EnableReceiveTransportSequenceNumber(id); |
73 } | 75 } |
74 | 76 |
75 void ChannelProxy::RegisterSenderCongestionControlObjects( | 77 void ChannelProxy::RegisterSenderCongestionControlObjects( |
76 RtpPacketSender* rtp_packet_sender, | 78 RtpPacketSender* rtp_packet_sender, |
77 TransportFeedbackObserver* transport_feedback_observer, | 79 TransportFeedbackObserver* transport_feedback_observer, |
78 PacketRouter* packet_router, | 80 PacketRouter* packet_router, |
79 RtcpBandwidthObserver* bandwidth_observer) { | 81 RtcpBandwidthObserver* bandwidth_observer) { |
80 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 82 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
81 channel()->RegisterSenderCongestionControlObjects( | 83 channel()->RegisterSenderCongestionControlObjects( |
82 rtp_packet_sender, transport_feedback_observer, packet_router, | 84 rtp_packet_sender, transport_feedback_observer, packet_router, |
83 bandwidth_observer); | 85 bandwidth_observer); |
84 } | 86 } |
85 | 87 |
86 void ChannelProxy::RegisterReceiverCongestionControlObjects( | 88 void ChannelProxy::RegisterReceiverCongestionControlObjects( |
87 PacketRouter* packet_router) { | 89 PacketRouter* packet_router) { |
88 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 90 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
89 channel()->RegisterReceiverCongestionControlObjects(packet_router); | 91 channel()->RegisterReceiverCongestionControlObjects(packet_router); |
90 } | 92 } |
91 | 93 |
92 void ChannelProxy::ResetCongestionControlObjects() { | 94 void ChannelProxy::ResetCongestionControlObjects() { |
93 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 95 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
94 channel()->ResetCongestionControlObjects(); | 96 channel()->ResetCongestionControlObjects(); |
95 } | 97 } |
96 | 98 |
97 CallStatistics ChannelProxy::GetRTCPStatistics() const { | 99 CallStatistics ChannelProxy::GetRTCPStatistics() const { |
98 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 100 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
99 CallStatistics stats = {0}; | 101 CallStatistics stats = {0}; |
100 int error = channel()->GetRTPStatistics(stats); | 102 int error = channel()->GetRTPStatistics(stats); |
101 RTC_DCHECK_EQ(0, error); | 103 RTC_DCHECK_EQ(0, error); |
102 return stats; | 104 return stats; |
103 } | 105 } |
104 | 106 |
105 std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const { | 107 std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const { |
106 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 108 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
107 std::vector<webrtc::ReportBlock> blocks; | 109 std::vector<webrtc::ReportBlock> blocks; |
108 int error = channel()->GetRemoteRTCPReportBlocks(&blocks); | 110 int error = channel()->GetRemoteRTCPReportBlocks(&blocks); |
109 RTC_DCHECK_EQ(0, error); | 111 RTC_DCHECK_EQ(0, error); |
110 return blocks; | 112 return blocks; |
111 } | 113 } |
112 | 114 |
113 NetworkStatistics ChannelProxy::GetNetworkStatistics() const { | 115 NetworkStatistics ChannelProxy::GetNetworkStatistics() const { |
114 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 116 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
115 NetworkStatistics stats = {0}; | 117 NetworkStatistics stats = {0}; |
116 int error = channel()->GetNetworkStatistics(stats); | 118 int error = channel()->GetNetworkStatistics(stats); |
117 RTC_DCHECK_EQ(0, error); | 119 RTC_DCHECK_EQ(0, error); |
118 return stats; | 120 return stats; |
119 } | 121 } |
120 | 122 |
121 AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const { | 123 AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const { |
122 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 124 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
123 AudioDecodingCallStats stats; | 125 AudioDecodingCallStats stats; |
124 channel()->GetDecodingCallStatistics(&stats); | 126 channel()->GetDecodingCallStatistics(&stats); |
125 return stats; | 127 return stats; |
126 } | 128 } |
127 | 129 |
128 int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const { | 130 int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const { |
129 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 131 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
130 uint32_t level = 0; | 132 uint32_t level = 0; |
131 int error = channel()->GetSpeechOutputLevelFullRange(level); | 133 int error = channel()->GetSpeechOutputLevelFullRange(level); |
132 RTC_DCHECK_EQ(0, error); | 134 RTC_DCHECK_EQ(0, error); |
133 return static_cast<int32_t>(level); | 135 return static_cast<int32_t>(level); |
134 } | 136 } |
135 | 137 |
136 uint32_t ChannelProxy::GetDelayEstimate() const { | 138 uint32_t ChannelProxy::GetDelayEstimate() const { |
137 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 139 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() || |
| 140 module_process_thread_checker_.CalledOnValidThread()); |
138 return channel()->GetDelayEstimate(); | 141 return channel()->GetDelayEstimate(); |
139 } | 142 } |
140 | 143 |
141 bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type, | 144 bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type, |
142 int payload_frequency) { | 145 int payload_frequency) { |
143 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 146 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
144 return channel()->SetSendTelephoneEventPayloadType(payload_type, | 147 return channel()->SetSendTelephoneEventPayloadType(payload_type, |
145 payload_frequency) == 0; | 148 payload_frequency) == 0; |
146 } | 149 } |
147 | 150 |
148 bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) { | 151 bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) { |
149 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 152 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
150 return channel()->SendTelephoneEventOutband(event, duration_ms) == 0; | 153 return channel()->SendTelephoneEventOutband(event, duration_ms) == 0; |
151 } | 154 } |
152 | 155 |
153 void ChannelProxy::SetBitrate(int bitrate_bps, int64_t probing_interval_ms) { | 156 void ChannelProxy::SetBitrate(int bitrate_bps, int64_t probing_interval_ms) { |
154 // May be called on different threads and needs to be handled by the channel. | 157 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() || |
| 158 module_process_thread_checker_.CalledOnValidThread()); |
155 channel()->SetBitRate(bitrate_bps, probing_interval_ms); | 159 channel()->SetBitRate(bitrate_bps, probing_interval_ms); |
156 } | 160 } |
157 | 161 |
158 void ChannelProxy::SetRecPayloadType(int payload_type, | 162 void ChannelProxy::SetRecPayloadType(int payload_type, |
159 const SdpAudioFormat& format) { | 163 const SdpAudioFormat& format) { |
160 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 164 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
161 const int result = channel()->SetRecPayloadType(payload_type, format); | 165 const int result = channel()->SetRecPayloadType(payload_type, format); |
162 RTC_DCHECK_EQ(0, result); | 166 RTC_DCHECK_EQ(0, result); |
163 } | 167 } |
164 | 168 |
165 void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) { | 169 void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) { |
166 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 170 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
167 channel()->SetSink(std::move(sink)); | 171 channel()->SetSink(std::move(sink)); |
168 } | 172 } |
169 | 173 |
170 void ChannelProxy::SetInputMute(bool muted) { | 174 void ChannelProxy::SetInputMute(bool muted) { |
171 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 175 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
172 int error = channel()->SetInputMute(muted); | 176 int error = channel()->SetInputMute(muted); |
173 RTC_DCHECK_EQ(0, error); | 177 RTC_DCHECK_EQ(0, error); |
174 } | 178 } |
175 | 179 |
176 void ChannelProxy::RegisterExternalTransport(Transport* transport) { | 180 void ChannelProxy::RegisterExternalTransport(Transport* transport) { |
177 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 181 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
178 int error = channel()->RegisterExternalTransport(transport); | 182 int error = channel()->RegisterExternalTransport(transport); |
179 RTC_DCHECK_EQ(0, error); | 183 RTC_DCHECK_EQ(0, error); |
180 } | 184 } |
181 | 185 |
182 void ChannelProxy::DeRegisterExternalTransport() { | 186 void ChannelProxy::DeRegisterExternalTransport() { |
183 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 187 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
184 channel()->DeRegisterExternalTransport(); | 188 channel()->DeRegisterExternalTransport(); |
185 } | 189 } |
186 | 190 |
187 bool ChannelProxy::ReceivedRTPPacket(const uint8_t* packet, | 191 bool ChannelProxy::ReceivedRTPPacket(const uint8_t* packet, |
188 size_t length, | 192 size_t length, |
189 const PacketTime& packet_time) { | 193 const PacketTime& packet_time) { |
190 // May be called on either worker thread or network thread. | 194 // May be called on either worker thread or network thread. |
191 return channel()->ReceivedRTPPacket(packet, length, packet_time) == 0; | 195 return channel()->ReceivedRTPPacket(packet, length, packet_time) == 0; |
192 } | 196 } |
193 | 197 |
194 bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) { | 198 bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) { |
195 // May be called on either worker thread or network thread. | 199 // May be called on either worker thread or network thread. |
196 return channel()->ReceivedRTCPPacket(packet, length) == 0; | 200 return channel()->ReceivedRTCPPacket(packet, length) == 0; |
197 } | 201 } |
198 | 202 |
199 const rtc::scoped_refptr<AudioDecoderFactory>& | 203 const rtc::scoped_refptr<AudioDecoderFactory>& |
200 ChannelProxy::GetAudioDecoderFactory() const { | 204 ChannelProxy::GetAudioDecoderFactory() const { |
201 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 205 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
202 return channel()->GetAudioDecoderFactory(); | 206 return channel()->GetAudioDecoderFactory(); |
203 } | 207 } |
204 | 208 |
205 void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) { | 209 void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) { |
206 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 210 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
207 int error = channel()->SetChannelOutputVolumeScaling(scaling); | 211 int error = channel()->SetChannelOutputVolumeScaling(scaling); |
208 RTC_DCHECK_EQ(0, error); | 212 RTC_DCHECK_EQ(0, error); |
209 } | 213 } |
210 | 214 |
211 void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) { | 215 void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) { |
212 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 216 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
213 channel()->SetRtcEventLog(event_log); | 217 channel()->SetRtcEventLog(event_log); |
214 } | 218 } |
215 | 219 |
216 void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) { | 220 void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) { |
217 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 221 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
218 bool ret = channel()->EnableAudioNetworkAdaptor(config_string); | 222 bool ret = channel()->EnableAudioNetworkAdaptor(config_string); |
219 RTC_DCHECK(ret); | 223 RTC_DCHECK(ret); |
220 ;} | 224 ;} |
221 | 225 |
222 void ChannelProxy::DisableAudioNetworkAdaptor() { | 226 void ChannelProxy::DisableAudioNetworkAdaptor() { |
223 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 227 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
224 channel()->DisableAudioNetworkAdaptor(); | 228 channel()->DisableAudioNetworkAdaptor(); |
225 } | 229 } |
226 | 230 |
227 void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms, | 231 void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms, |
228 int max_frame_length_ms) { | 232 int max_frame_length_ms) { |
229 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 233 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
230 channel()->SetReceiverFrameLengthRange(min_frame_length_ms, | 234 channel()->SetReceiverFrameLengthRange(min_frame_length_ms, |
231 max_frame_length_ms); | 235 max_frame_length_ms); |
232 } | 236 } |
233 | 237 |
234 AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo( | 238 AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo( |
235 int sample_rate_hz, | 239 int sample_rate_hz, |
236 AudioFrame* audio_frame) { | 240 AudioFrame* audio_frame) { |
237 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_); | 241 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); |
238 return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame); | 242 return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame); |
239 } | 243 } |
240 | 244 |
241 int ChannelProxy::NeededFrequency() const { | 245 int ChannelProxy::NeededFrequency() const { |
| 246 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); |
242 return static_cast<int>(channel()->NeededFrequency(-1)); | 247 return static_cast<int>(channel()->NeededFrequency(-1)); |
243 } | 248 } |
244 | 249 |
245 void ChannelProxy::SetTransportOverhead(int transport_overhead_per_packet) { | 250 void ChannelProxy::SetTransportOverhead(int transport_overhead_per_packet) { |
246 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 251 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
247 channel()->SetTransportOverhead(transport_overhead_per_packet); | 252 channel()->SetTransportOverhead(transport_overhead_per_packet); |
248 } | 253 } |
249 | 254 |
250 void ChannelProxy::AssociateSendChannel( | 255 void ChannelProxy::AssociateSendChannel( |
251 const ChannelProxy& send_channel_proxy) { | 256 const ChannelProxy& send_channel_proxy) { |
252 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 257 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
253 channel()->set_associate_send_channel(send_channel_proxy.channel_owner_); | 258 channel()->set_associate_send_channel(send_channel_proxy.channel_owner_); |
254 } | 259 } |
255 | 260 |
256 void ChannelProxy::DisassociateSendChannel() { | 261 void ChannelProxy::DisassociateSendChannel() { |
257 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 262 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
258 channel()->set_associate_send_channel(ChannelOwner(nullptr)); | 263 channel()->set_associate_send_channel(ChannelOwner(nullptr)); |
259 } | 264 } |
260 | 265 |
261 void ChannelProxy::GetRtpRtcp(RtpRtcp** rtp_rtcp, | 266 void ChannelProxy::GetRtpRtcp(RtpRtcp** rtp_rtcp, |
262 RtpReceiver** rtp_receiver) const { | 267 RtpReceiver** rtp_receiver) const { |
263 // Called on Call's module_process_thread_. | 268 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); |
264 RTC_DCHECK(rtp_rtcp); | 269 RTC_DCHECK(rtp_rtcp); |
265 RTC_DCHECK(rtp_receiver); | 270 RTC_DCHECK(rtp_receiver); |
266 int error = channel()->GetRtpRtcp(rtp_rtcp, rtp_receiver); | 271 int error = channel()->GetRtpRtcp(rtp_rtcp, rtp_receiver); |
267 RTC_DCHECK_EQ(0, error); | 272 RTC_DCHECK_EQ(0, error); |
268 } | 273 } |
269 | 274 |
270 void ChannelProxy::GetDelayEstimate(int* jitter_buffer_delay_ms, | |
271 int* playout_buffer_delay_ms) const { | |
272 // Called on Call's module_process_thread_. | |
273 RTC_DCHECK(jitter_buffer_delay_ms); | |
274 RTC_DCHECK(playout_buffer_delay_ms); | |
275 bool error = channel()->GetDelayEstimate(jitter_buffer_delay_ms, | |
276 playout_buffer_delay_ms); | |
277 RTC_DCHECK(error); | |
278 } | |
279 | |
280 uint32_t ChannelProxy::GetPlayoutTimestamp() const { | 275 uint32_t ChannelProxy::GetPlayoutTimestamp() const { |
281 // Called on video capture thread. | 276 RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_); |
282 unsigned int timestamp = 0; | 277 unsigned int timestamp = 0; |
283 int error = channel()->GetPlayoutTimestamp(timestamp); | 278 int error = channel()->GetPlayoutTimestamp(timestamp); |
284 RTC_DCHECK(!error || timestamp == 0); | 279 RTC_DCHECK(!error || timestamp == 0); |
285 return timestamp; | 280 return timestamp; |
286 } | 281 } |
287 | 282 |
288 void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) { | 283 void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) { |
289 // Called on Call's module_process_thread_. | 284 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); |
290 // Limit to range accepted by both VoE and ACM, so we're at least getting as | 285 // Limit to range accepted by both VoE and ACM, so we're at least getting as |
291 // close as possible, instead of failing. | 286 // close as possible, instead of failing. |
292 delay_ms = std::max(0, std::min(delay_ms, 10000)); | 287 delay_ms = std::max(0, std::min(delay_ms, 10000)); |
293 int error = channel()->SetMinimumPlayoutDelay(delay_ms); | 288 int error = channel()->SetMinimumPlayoutDelay(delay_ms); |
294 RTC_DCHECK_EQ(0, error); | 289 RTC_DCHECK_EQ(0, error); |
295 } | 290 } |
296 | 291 |
297 void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) { | 292 void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) { |
298 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 293 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
299 channel()->SetRtcpRttStats(rtcp_rtt_stats); | 294 channel()->SetRtcpRttStats(rtcp_rtt_stats); |
300 } | 295 } |
301 | 296 |
302 bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const { | 297 bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const { |
303 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 298 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
304 return channel()->GetRecCodec(*codec_inst) == 0; | 299 return channel()->GetRecCodec(*codec_inst) == 0; |
305 } | 300 } |
306 | 301 |
307 bool ChannelProxy::GetSendCodec(CodecInst* codec_inst) const { | 302 bool ChannelProxy::GetSendCodec(CodecInst* codec_inst) const { |
308 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 303 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
309 return channel()->GetSendCodec(*codec_inst) == 0; | 304 return channel()->GetSendCodec(*codec_inst) == 0; |
310 } | 305 } |
311 | 306 |
312 bool ChannelProxy::SetVADStatus(bool enable) { | 307 bool ChannelProxy::SetVADStatus(bool enable) { |
313 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 308 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
314 return channel()->SetVADStatus(enable, VADNormal, false) == 0; | 309 return channel()->SetVADStatus(enable, VADNormal, false) == 0; |
315 } | 310 } |
316 | 311 |
317 bool ChannelProxy::SetCodecFECStatus(bool enable) { | 312 bool ChannelProxy::SetCodecFECStatus(bool enable) { |
318 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 313 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
319 return channel()->SetCodecFECStatus(enable) == 0; | 314 return channel()->SetCodecFECStatus(enable) == 0; |
320 } | 315 } |
321 | 316 |
322 bool ChannelProxy::SetOpusDtx(bool enable) { | 317 bool ChannelProxy::SetOpusDtx(bool enable) { |
323 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 318 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
324 return channel()->SetOpusDtx(enable) == 0; | 319 return channel()->SetOpusDtx(enable) == 0; |
325 } | 320 } |
326 | 321 |
327 bool ChannelProxy::SetOpusMaxPlaybackRate(int frequency_hz) { | 322 bool ChannelProxy::SetOpusMaxPlaybackRate(int frequency_hz) { |
328 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 323 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
329 return channel()->SetOpusMaxPlaybackRate(frequency_hz) == 0; | 324 return channel()->SetOpusMaxPlaybackRate(frequency_hz) == 0; |
330 } | 325 } |
331 | 326 |
332 bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) { | 327 bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) { |
333 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 328 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
334 // Validation code copied from VoECodecImpl::SetSendCodec(). | 329 // Validation code copied from VoECodecImpl::SetSendCodec(). |
335 if ((STR_CASE_CMP(codec_inst.plname, "L16") == 0) && | 330 if ((STR_CASE_CMP(codec_inst.plname, "L16") == 0) && |
336 (codec_inst.pacsize >= 960)) { | 331 (codec_inst.pacsize >= 960)) { |
337 return false; | 332 return false; |
338 } | 333 } |
339 if (!STR_CASE_CMP(codec_inst.plname, "CN") || | 334 if (!STR_CASE_CMP(codec_inst.plname, "CN") || |
340 !STR_CASE_CMP(codec_inst.plname, "TELEPHONE-EVENT") || | 335 !STR_CASE_CMP(codec_inst.plname, "TELEPHONE-EVENT") || |
341 !STR_CASE_CMP(codec_inst.plname, "RED")) { | 336 !STR_CASE_CMP(codec_inst.plname, "RED")) { |
342 return false; | 337 return false; |
343 } | 338 } |
344 if ((codec_inst.channels != 1) && (codec_inst.channels != 2)) { | 339 if ((codec_inst.channels != 1) && (codec_inst.channels != 2)) { |
345 return false; | 340 return false; |
346 } | 341 } |
347 if (!AudioCodingModule::IsCodecValid(codec_inst)) { | 342 if (!AudioCodingModule::IsCodecValid(codec_inst)) { |
348 return false; | 343 return false; |
349 } | 344 } |
350 return channel()->SetSendCodec(codec_inst) == 0; | 345 return channel()->SetSendCodec(codec_inst) == 0; |
351 } | 346 } |
352 | 347 |
353 bool ChannelProxy::SetSendCNPayloadType(int type, | 348 bool ChannelProxy::SetSendCNPayloadType(int type, |
354 PayloadFrequencies frequency) { | 349 PayloadFrequencies frequency) { |
355 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 350 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
356 // Validation code copied from VoECodecImpl::SetSendCNPayloadType(). | 351 // Validation code copied from VoECodecImpl::SetSendCNPayloadType(). |
357 if (type < 96 || type > 127) { | 352 if (type < 96 || type > 127) { |
358 // Only allow dynamic range: 96 to 127 | 353 // Only allow dynamic range: 96 to 127 |
359 return false; | 354 return false; |
360 } | 355 } |
361 if ((frequency != kFreq16000Hz) && (frequency != kFreq32000Hz)) { | 356 if ((frequency != kFreq16000Hz) && (frequency != kFreq32000Hz)) { |
362 // It is not possible to modify the payload type for CN/8000. | 357 // It is not possible to modify the payload type for CN/8000. |
363 // We only allow modification of the CN payload type for CN/16000 | 358 // We only allow modification of the CN payload type for CN/16000 |
364 // and CN/32000. | 359 // and CN/32000. |
365 return false; | 360 return false; |
366 } | 361 } |
367 return channel()->SetSendCNPayloadType(type, frequency) == 0; | 362 return channel()->SetSendCNPayloadType(type, frequency) == 0; |
368 } | 363 } |
369 | 364 |
370 Channel* ChannelProxy::channel() const { | 365 Channel* ChannelProxy::channel() const { |
371 RTC_DCHECK(channel_owner_.channel()); | 366 RTC_DCHECK(channel_owner_.channel()); |
372 return channel_owner_.channel(); | 367 return channel_owner_.channel(); |
373 } | 368 } |
374 | 369 |
375 } // namespace voe | 370 } // namespace voe |
376 } // namespace webrtc | 371 } // namespace webrtc |
OLD | NEW |