1 /*
2 * Copyright (c) 2012 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
11 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
12 #include "webrtc/system_wrappers/interface/file_wrapper.h"
13 #include "webrtc/system_wrappers/interface/trace.h"
14 #include "webrtc/video_engine/include/vie_network.h"
15 #include "webrtc/voice_engine/include/voe_errors.h"
16 #include "webrtc/voice_engine/voe_rtp_rtcp_impl.h"
17 #include "webrtc/voice_engine/voice_engine_impl.h"
18
19 #include "webrtc/voice_engine/channel.h"
20 #include "webrtc/voice_engine/transmit_mixer.h"
21
22 namespace webrtc {
23
GetInterface(VoiceEngine * voiceEngine)24 VoERTP_RTCP* VoERTP_RTCP::GetInterface(VoiceEngine* voiceEngine)
25 {
26 #ifndef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
27 return NULL;
28 #else
29 if (NULL == voiceEngine)
30 {
31 return NULL;
32 }
33 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
34 s->AddRef();
35 return s;
36 #endif
37 }
38
39 #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
40
VoERTP_RTCPImpl(voe::SharedData * shared)41 VoERTP_RTCPImpl::VoERTP_RTCPImpl(voe::SharedData* shared) : _shared(shared)
42 {
43 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
44 "VoERTP_RTCPImpl::VoERTP_RTCPImpl() - ctor");
45 }
46
~VoERTP_RTCPImpl()47 VoERTP_RTCPImpl::~VoERTP_RTCPImpl()
48 {
49 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
50 "VoERTP_RTCPImpl::~VoERTP_RTCPImpl() - dtor");
51 }
52
SetLocalSSRC(int channel,unsigned int ssrc)53 int VoERTP_RTCPImpl::SetLocalSSRC(int channel, unsigned int ssrc)
54 {
55 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
56 "SetLocalSSRC(channel=%d, %lu)", channel, ssrc);
57 if (!_shared->statistics().Initialized())
58 {
59 _shared->SetLastError(VE_NOT_INITED, kTraceError);
60 return -1;
61 }
62 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
63 voe::Channel* channelPtr = ch.channel();
64 if (channelPtr == NULL)
65 {
66 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
67 "SetLocalSSRC() failed to locate channel");
68 return -1;
69 }
70 return channelPtr->SetLocalSSRC(ssrc);
71 }
72
GetLocalSSRC(int channel,unsigned int & ssrc)73 int VoERTP_RTCPImpl::GetLocalSSRC(int channel, unsigned int& ssrc)
74 {
75 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
76 "GetLocalSSRC(channel=%d, ssrc=?)", channel);
77 if (!_shared->statistics().Initialized())
78 {
79 _shared->SetLastError(VE_NOT_INITED, kTraceError);
80 return -1;
81 }
82 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
83 voe::Channel* channelPtr = ch.channel();
84 if (channelPtr == NULL)
85 {
86 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
87 "GetLocalSSRC() failed to locate channel");
88 return -1;
89 }
90 return channelPtr->GetLocalSSRC(ssrc);
91 }
92
GetRemoteSSRC(int channel,unsigned int & ssrc)93 int VoERTP_RTCPImpl::GetRemoteSSRC(int channel, unsigned int& ssrc)
94 {
95 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
96 "GetRemoteSSRC(channel=%d, ssrc=?)", channel);
97 if (!_shared->statistics().Initialized())
98 {
99 _shared->SetLastError(VE_NOT_INITED, kTraceError);
100 return -1;
101 }
102 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
103 voe::Channel* channelPtr = ch.channel();
104 if (channelPtr == NULL)
105 {
106 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
107 "GetRemoteSSRC() failed to locate channel");
108 return -1;
109 }
110 return channelPtr->GetRemoteSSRC(ssrc);
111 }
112
SetSendAudioLevelIndicationStatus(int channel,bool enable,unsigned char id)113 int VoERTP_RTCPImpl::SetSendAudioLevelIndicationStatus(int channel,
114 bool enable,
115 unsigned char id)
116 {
117 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
118 "SetSendAudioLevelIndicationStatus(channel=%d, enable=%d,"
119 " ID=%u)", channel, enable, id);
120 if (!_shared->statistics().Initialized())
121 {
122 _shared->SetLastError(VE_NOT_INITED, kTraceError);
123 return -1;
124 }
125 if (enable && (id < kVoiceEngineMinRtpExtensionId ||
126 id > kVoiceEngineMaxRtpExtensionId))
127 {
128 // [RFC5285] The 4-bit id is the local identifier of this element in
129 // the range 1-14 inclusive.
130 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
131 "SetSendAudioLevelIndicationStatus() invalid ID parameter");
132 return -1;
133 }
134
135 // Set state and id for the specified channel.
136 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
137 voe::Channel* channelPtr = ch.channel();
138 if (channelPtr == NULL)
139 {
140 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
141 "SetSendAudioLevelIndicationStatus() failed to locate channel");
142 return -1;
143 }
144 return channelPtr->SetSendAudioLevelIndicationStatus(enable, id);
145 }
146
SetReceiveAudioLevelIndicationStatus(int channel,bool enable,unsigned char id)147 int VoERTP_RTCPImpl::SetReceiveAudioLevelIndicationStatus(int channel,
148 bool enable,
149 unsigned char id) {
150 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
151 "SetReceiveAudioLevelIndicationStatus(channel=%d, enable=%d, id=%u)",
152 channel, enable, id);
153 if (!_shared->statistics().Initialized()) {
154 _shared->SetLastError(VE_NOT_INITED, kTraceError);
155 return -1;
156 }
157 if (enable &&
158 (id < kVoiceEngineMinRtpExtensionId ||
159 id > kVoiceEngineMaxRtpExtensionId)) {
160 // [RFC5285] The 4-bit id is the local identifier of this element in
161 // the range 1-14 inclusive.
162 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
163 "SetReceiveAbsoluteSenderTimeStatus() invalid id parameter");
164 return -1;
165 }
166 // Set state and id for the specified channel.
167 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
168 voe::Channel* channel_ptr = ch.channel();
169 if (channel_ptr == NULL) {
170 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
171 "SetReceiveAudioLevelIndicationStatus() failed to locate channel");
172 return -1;
173 }
174 return channel_ptr->SetReceiveAudioLevelIndicationStatus(enable, id);
175 }
176
SetSendAbsoluteSenderTimeStatus(int channel,bool enable,unsigned char id)177 int VoERTP_RTCPImpl::SetSendAbsoluteSenderTimeStatus(int channel,
178 bool enable,
179 unsigned char id) {
180 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
181 "SetSendAbsoluteSenderTimeStatus(channel=%d, enable=%d, id=%u)",
182 channel, enable, id);
183 if (!_shared->statistics().Initialized()) {
184 _shared->SetLastError(VE_NOT_INITED, kTraceError);
185 return -1;
186 }
187 if (enable && (id < kVoiceEngineMinRtpExtensionId ||
188 id > kVoiceEngineMaxRtpExtensionId)) {
189 // [RFC5285] The 4-bit id is the local identifier of this element in
190 // the range 1-14 inclusive.
191 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
192 "SetSendAbsoluteSenderTimeStatus() invalid id parameter");
193 return -1;
194 }
195 // Set state and id for the specified channel.
196 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
197 voe::Channel* channelPtr = ch.channel();
198 if (channelPtr == NULL) {
199 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
200 "SetSendAbsoluteSenderTimeStatus() failed to locate channel");
201 return -1;
202 }
203 return channelPtr->SetSendAbsoluteSenderTimeStatus(enable, id);
204 }
205
SetReceiveAbsoluteSenderTimeStatus(int channel,bool enable,unsigned char id)206 int VoERTP_RTCPImpl::SetReceiveAbsoluteSenderTimeStatus(int channel,
207 bool enable,
208 unsigned char id) {
209 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
210 "SetReceiveAbsoluteSenderTimeStatus(channel=%d, enable=%d, id=%u)",
211 channel, enable, id);
212 if (!_shared->statistics().Initialized()) {
213 _shared->SetLastError(VE_NOT_INITED, kTraceError);
214 return -1;
215 }
216 if (enable && (id < kVoiceEngineMinRtpExtensionId ||
217 id > kVoiceEngineMaxRtpExtensionId)) {
218 // [RFC5285] The 4-bit id is the local identifier of this element in
219 // the range 1-14 inclusive.
220 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
221 "SetReceiveAbsoluteSenderTimeStatus() invalid id parameter");
222 return -1;
223 }
224 // Set state and id for the specified channel.
225 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
226 voe::Channel* channelPtr = ch.channel();
227 if (channelPtr == NULL) {
228 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
229 "SetReceiveAbsoluteSenderTimeStatus() failed to locate channel");
230 return -1;
231 }
232 return channelPtr->SetReceiveAbsoluteSenderTimeStatus(enable, id);
233 }
234
SetRTCPStatus(int channel,bool enable)235 int VoERTP_RTCPImpl::SetRTCPStatus(int channel, bool enable)
236 {
237 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
238 "SetRTCPStatus(channel=%d, enable=%d)", channel, enable);
239 if (!_shared->statistics().Initialized())
240 {
241 _shared->SetLastError(VE_NOT_INITED, kTraceError);
242 return -1;
243 }
244 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
245 voe::Channel* channelPtr = ch.channel();
246 if (channelPtr == NULL)
247 {
248 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
249 "SetRTCPStatus() failed to locate channel");
250 return -1;
251 }
252 return channelPtr->SetRTCPStatus(enable);
253 }
254
GetRTCPStatus(int channel,bool & enabled)255 int VoERTP_RTCPImpl::GetRTCPStatus(int channel, bool& enabled)
256 {
257 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
258 "GetRTCPStatus(channel=%d)", channel);
259 if (!_shared->statistics().Initialized())
260 {
261 _shared->SetLastError(VE_NOT_INITED, kTraceError);
262 return -1;
263 }
264 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
265 voe::Channel* channelPtr = ch.channel();
266 if (channelPtr == NULL)
267 {
268 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
269 "GetRTCPStatus() failed to locate channel");
270 return -1;
271 }
272 return channelPtr->GetRTCPStatus(enabled);
273 }
274
SetRTCP_CNAME(int channel,const char cName[256])275 int VoERTP_RTCPImpl::SetRTCP_CNAME(int channel, const char cName[256])
276 {
277 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
278 "SetRTCP_CNAME(channel=%d, cName=%s)", channel, cName);
279 if (!_shared->statistics().Initialized())
280 {
281 _shared->SetLastError(VE_NOT_INITED, kTraceError);
282 return -1;
283 }
284 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
285 voe::Channel* channelPtr = ch.channel();
286 if (channelPtr == NULL)
287 {
288 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
289 "SetRTCP_CNAME() failed to locate channel");
290 return -1;
291 }
292 return channelPtr->SetRTCP_CNAME(cName);
293 }
294
GetRTCP_CNAME(int channel,char cName[256])295 int VoERTP_RTCPImpl::GetRTCP_CNAME(int channel, char cName[256])
296 {
297 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
298 "GetRTCP_CNAME(channel=%d, cName=?)", channel);
299 if (!_shared->statistics().Initialized())
300 {
301 _shared->SetLastError(VE_NOT_INITED, kTraceError);
302 return -1;
303 }
304 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
305 voe::Channel* channelPtr = ch.channel();
306 if (channelPtr == NULL)
307 {
308 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
309 "GetRTCP_CNAME() failed to locate channel");
310 return -1;
311 }
312 return channelPtr->GetRTCP_CNAME(cName);
313 }
314
GetRemoteRTCP_CNAME(int channel,char cName[256])315 int VoERTP_RTCPImpl::GetRemoteRTCP_CNAME(int channel, char cName[256])
316 {
317 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
318 "GetRemoteRTCP_CNAME(channel=%d, cName=?)", channel);
319 if (!_shared->statistics().Initialized())
320 {
321 _shared->SetLastError(VE_NOT_INITED, kTraceError);
322 return -1;
323 }
324 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
325 voe::Channel* channelPtr = ch.channel();
326 if (channelPtr == NULL)
327 {
328 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
329 "GetRemoteRTCP_CNAME() failed to locate channel");
330 return -1;
331 }
332 return channelPtr->GetRemoteRTCP_CNAME(cName);
333 }
334
GetRemoteRTCPData(int channel,unsigned int & NTPHigh,unsigned int & NTPLow,unsigned int & timestamp,unsigned int & playoutTimestamp,unsigned int * jitter,unsigned short * fractionLost)335 int VoERTP_RTCPImpl::GetRemoteRTCPData(
336 int channel,
337 unsigned int& NTPHigh, // from sender info in SR
338 unsigned int& NTPLow, // from sender info in SR
339 unsigned int& timestamp, // from sender info in SR
340 unsigned int& playoutTimestamp, // derived locally
341 unsigned int* jitter, // from report block 1 in SR/RR
342 unsigned short* fractionLost) // from report block 1 in SR/RR
343 {
344 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
345 "GetRemoteRTCPData(channel=%d,...)", channel);
346 if (!_shared->statistics().Initialized())
347 {
348 _shared->SetLastError(VE_NOT_INITED, kTraceError);
349 return -1;
350 }
351 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
352 voe::Channel* channelPtr = ch.channel();
353 if (channelPtr == NULL)
354 {
355 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
356 "GetRemoteRTCP_CNAME() failed to locate channel");
357 return -1;
358 }
359 return channelPtr->GetRemoteRTCPData(NTPHigh,
360 NTPLow,
361 timestamp,
362 playoutTimestamp,
363 jitter,
364 fractionLost);
365 }
366
GetRTPStatistics(int channel,unsigned int & averageJitterMs,unsigned int & maxJitterMs,unsigned int & discardedPackets)367 int VoERTP_RTCPImpl::GetRTPStatistics(int channel,
368 unsigned int& averageJitterMs,
369 unsigned int& maxJitterMs,
370 unsigned int& discardedPackets)
371 {
372 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
373 "GetRTPStatistics(channel=%d,....)", channel);
374 if (!_shared->statistics().Initialized())
375 {
376 _shared->SetLastError(VE_NOT_INITED, kTraceError);
377 return -1;
378 }
379 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
380 voe::Channel* channelPtr = ch.channel();
381 if (channelPtr == NULL)
382 {
383 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
384 "GetRTPStatistics() failed to locate channel");
385 return -1;
386 }
387 return channelPtr->GetRTPStatistics(averageJitterMs,
388 maxJitterMs,
389 discardedPackets);
390 }
391
GetRTCPStatistics(int channel,CallStatistics & stats)392 int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats)
393 {
394 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
395 "GetRTCPStatistics(channel=%d)", channel);
396 if (!_shared->statistics().Initialized())
397 {
398 _shared->SetLastError(VE_NOT_INITED, kTraceError);
399 return -1;
400 }
401 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
402 voe::Channel* channelPtr = ch.channel();
403 if (channelPtr == NULL)
404 {
405 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
406 "GetRTPStatistics() failed to locate channel");
407 return -1;
408 }
409 return channelPtr->GetRTPStatistics(stats);
410 }
411
GetRemoteRTCPReportBlocks(int channel,std::vector<ReportBlock> * report_blocks)412 int VoERTP_RTCPImpl::GetRemoteRTCPReportBlocks(
413 int channel, std::vector<ReportBlock>* report_blocks) {
414 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
415 "GetRemoteRTCPReportBlocks(channel=%d)", channel);
416 if (!_shared->statistics().Initialized()) {
417 _shared->SetLastError(VE_NOT_INITED, kTraceError);
418 return -1;
419 }
420 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
421 voe::Channel* channel_ptr = ch.channel();
422 if (channel_ptr == NULL) {
423 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
424 "GetRemoteRTCPReportBlocks() failed to locate channel");
425 return -1;
426 }
427 return channel_ptr->GetRemoteRTCPReportBlocks(report_blocks);
428 }
429
SetREDStatus(int channel,bool enable,int redPayloadtype)430 int VoERTP_RTCPImpl::SetREDStatus(int channel, bool enable, int redPayloadtype)
431 {
432 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
433 "SetREDStatus(channel=%d, enable=%d, redPayloadtype=%d)",
434 channel, enable, redPayloadtype);
435 #ifdef WEBRTC_CODEC_RED
436 if (!_shared->statistics().Initialized())
437 {
438 _shared->SetLastError(VE_NOT_INITED, kTraceError);
439 return -1;
440 }
441 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
442 voe::Channel* channelPtr = ch.channel();
443 if (channelPtr == NULL)
444 {
445 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
446 "SetREDStatus() failed to locate channel");
447 return -1;
448 }
449 return channelPtr->SetREDStatus(enable, redPayloadtype);
450 #else
451 _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
452 "SetREDStatus() RED is not supported");
453 return -1;
454 #endif
455 }
456
GetREDStatus(int channel,bool & enabled,int & redPayloadtype)457 int VoERTP_RTCPImpl::GetREDStatus(int channel,
458 bool& enabled,
459 int& redPayloadtype)
460 {
461 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
462 "GetREDStatus(channel=%d, enabled=?, redPayloadtype=?)",
463 channel);
464 #ifdef WEBRTC_CODEC_RED
465 if (!_shared->statistics().Initialized())
466 {
467 _shared->SetLastError(VE_NOT_INITED, kTraceError);
468 return -1;
469 }
470 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
471 voe::Channel* channelPtr = ch.channel();
472 if (channelPtr == NULL)
473 {
474 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
475 "GetREDStatus() failed to locate channel");
476 return -1;
477 }
478 return channelPtr->GetREDStatus(enabled, redPayloadtype);
479 #else
480 _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
481 "GetREDStatus() RED is not supported");
482 return -1;
483 #endif
484 }
485
SetNACKStatus(int channel,bool enable,int maxNoPackets)486 int VoERTP_RTCPImpl::SetNACKStatus(int channel,
487 bool enable,
488 int maxNoPackets)
489 {
490 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
491 "SetNACKStatus(channel=%d, enable=%d, maxNoPackets=%d)",
492 channel, enable, maxNoPackets);
493
494 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
495 voe::Channel* channelPtr = ch.channel();
496 if (channelPtr == NULL)
497 {
498 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
499 "SetNACKStatus() failed to locate channel");
500 return -1;
501 }
502 channelPtr->SetNACKStatus(enable, maxNoPackets);
503 return 0;
504 }
505
506
StartRTPDump(int channel,const char fileNameUTF8[1024],RTPDirections direction)507 int VoERTP_RTCPImpl::StartRTPDump(int channel,
508 const char fileNameUTF8[1024],
509 RTPDirections direction)
510 {
511 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
512 "StartRTPDump(channel=%d, fileNameUTF8=%s, direction=%d)",
513 channel, fileNameUTF8, direction);
514 assert(1024 == FileWrapper::kMaxFileNameSize);
515 if (!_shared->statistics().Initialized())
516 {
517 _shared->SetLastError(VE_NOT_INITED, kTraceError);
518 return -1;
519 }
520 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
521 voe::Channel* channelPtr = ch.channel();
522 if (channelPtr == NULL)
523 {
524 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
525 "StartRTPDump() failed to locate channel");
526 return -1;
527 }
528 return channelPtr->StartRTPDump(fileNameUTF8, direction);
529 }
530
StopRTPDump(int channel,RTPDirections direction)531 int VoERTP_RTCPImpl::StopRTPDump(int channel, RTPDirections direction)
532 {
533 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
534 "StopRTPDump(channel=%d, direction=%d)", channel, direction);
535 if (!_shared->statistics().Initialized())
536 {
537 _shared->SetLastError(VE_NOT_INITED, kTraceError);
538 return -1;
539 }
540 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
541 voe::Channel* channelPtr = ch.channel();
542 if (channelPtr == NULL)
543 {
544 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
545 "StopRTPDump() failed to locate channel");
546 return -1;
547 }
548 return channelPtr->StopRTPDump(direction);
549 }
550
RTPDumpIsActive(int channel,RTPDirections direction)551 int VoERTP_RTCPImpl::RTPDumpIsActive(int channel, RTPDirections direction)
552 {
553 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
554 "RTPDumpIsActive(channel=%d, direction=%d)",
555 channel, direction);
556 if (!_shared->statistics().Initialized())
557 {
558 _shared->SetLastError(VE_NOT_INITED, kTraceError);
559 return -1;
560 }
561 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
562 voe::Channel* channelPtr = ch.channel();
563 if (channelPtr == NULL)
564 {
565 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
566 "StopRTPDump() failed to locate channel");
567 return -1;
568 }
569 return channelPtr->RTPDumpIsActive(direction);
570 }
571
SetVideoEngineBWETarget(int channel,ViENetwork * vie_network,int video_channel)572 int VoERTP_RTCPImpl::SetVideoEngineBWETarget(int channel,
573 ViENetwork* vie_network,
574 int video_channel) {
575 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
576 "SetVideoEngineBWETarget(channel=%d, vie_network=?, video_channel=%d)",
577 channel, vie_network, video_channel);
578
579 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
580 voe::Channel* channelPtr = ch.channel();
581 if (channelPtr == NULL) {
582 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
583 "SetVideoEngineBWETarget() failed to locate channel");
584 if (vie_network) {
585 vie_network->Release();
586 }
587 return -1;
588 }
589 channelPtr->SetVideoEngineBWETarget(vie_network, video_channel);
590 return 0;
591 }
592
593 #endif // #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
594
595 } // namespace webrtc
596