2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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.
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"
19 #include "webrtc/voice_engine/channel.h"
20 #include "webrtc/voice_engine/transmit_mixer.h"
24 VoERTP_RTCP* VoERTP_RTCP::GetInterface(VoiceEngine* voiceEngine)
26 #ifndef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
29 if (NULL == voiceEngine)
33 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
39 #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
41 VoERTP_RTCPImpl::VoERTP_RTCPImpl(voe::SharedData* shared) : _shared(shared)
43 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
44 "VoERTP_RTCPImpl::VoERTP_RTCPImpl() - ctor");
47 VoERTP_RTCPImpl::~VoERTP_RTCPImpl()
49 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
50 "VoERTP_RTCPImpl::~VoERTP_RTCPImpl() - dtor");
53 int VoERTP_RTCPImpl::RegisterRTPObserver(int channel, VoERTPObserver& observer)
55 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
56 "RegisterRTPObserver(channel=%d observer=0x%x)",
58 if (!_shared->statistics().Initialized())
60 _shared->SetLastError(VE_NOT_INITED, kTraceError);
63 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
64 voe::Channel* channelPtr = ch.channel();
65 if (channelPtr == NULL)
67 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
68 "RegisterRTPObserver() failed to locate channel");
71 return channelPtr->RegisterRTPObserver(observer);
74 int VoERTP_RTCPImpl::DeRegisterRTPObserver(int channel)
76 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
77 "DeRegisterRTPObserver(channel=%d)", channel);
78 if (!_shared->statistics().Initialized())
80 _shared->SetLastError(VE_NOT_INITED, kTraceError);
83 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
84 voe::Channel* channelPtr = ch.channel();
85 if (channelPtr == NULL)
87 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
88 "DeRegisterRTPObserver() failed to locate channel");
91 return channelPtr->DeRegisterRTPObserver();
94 int VoERTP_RTCPImpl::RegisterRTCPObserver(int channel, VoERTCPObserver& observer)
96 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
97 "RegisterRTCPObserver(channel=%d observer=0x%x)",
99 if (!_shared->statistics().Initialized())
101 _shared->SetLastError(VE_NOT_INITED, kTraceError);
104 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
105 voe::Channel* channelPtr = ch.channel();
106 if (channelPtr == NULL)
108 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
109 "RegisterRTPObserver() failed to locate channel");
112 return channelPtr->RegisterRTCPObserver(observer);
115 int VoERTP_RTCPImpl::DeRegisterRTCPObserver(int channel)
117 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
118 "DeRegisterRTCPObserver(channel=%d)", channel);
119 if (!_shared->statistics().Initialized())
121 _shared->SetLastError(VE_NOT_INITED, kTraceError);
124 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
125 voe::Channel* channelPtr = ch.channel();
126 if (channelPtr == NULL)
128 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
129 "DeRegisterRTCPObserver() failed to locate channel");
132 return channelPtr->DeRegisterRTCPObserver();
135 int VoERTP_RTCPImpl::SetLocalSSRC(int channel, unsigned int ssrc)
137 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
138 "SetLocalSSRC(channel=%d, %lu)", channel, ssrc);
139 if (!_shared->statistics().Initialized())
141 _shared->SetLastError(VE_NOT_INITED, kTraceError);
144 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
145 voe::Channel* channelPtr = ch.channel();
146 if (channelPtr == NULL)
148 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
149 "SetLocalSSRC() failed to locate channel");
152 return channelPtr->SetLocalSSRC(ssrc);
155 int VoERTP_RTCPImpl::GetLocalSSRC(int channel, unsigned int& ssrc)
157 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
158 "GetLocalSSRC(channel=%d, ssrc=?)", channel);
159 if (!_shared->statistics().Initialized())
161 _shared->SetLastError(VE_NOT_INITED, kTraceError);
164 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
165 voe::Channel* channelPtr = ch.channel();
166 if (channelPtr == NULL)
168 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
169 "GetLocalSSRC() failed to locate channel");
172 return channelPtr->GetLocalSSRC(ssrc);
175 int VoERTP_RTCPImpl::GetRemoteSSRC(int channel, unsigned int& ssrc)
177 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
178 "GetRemoteSSRC(channel=%d, ssrc=?)", channel);
179 if (!_shared->statistics().Initialized())
181 _shared->SetLastError(VE_NOT_INITED, kTraceError);
184 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
185 voe::Channel* channelPtr = ch.channel();
186 if (channelPtr == NULL)
188 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
189 "GetRemoteSSRC() failed to locate channel");
192 return channelPtr->GetRemoteSSRC(ssrc);
195 int VoERTP_RTCPImpl::GetRemoteCSRCs(int channel, unsigned int arrCSRC[15])
197 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
198 "GetRemoteCSRCs(channel=%d, arrCSRC=?)", channel);
199 if (!_shared->statistics().Initialized())
201 _shared->SetLastError(VE_NOT_INITED, kTraceError);
204 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
205 voe::Channel* channelPtr = ch.channel();
206 if (channelPtr == NULL)
208 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
209 "GetRemoteCSRCs() failed to locate channel");
212 return channelPtr->GetRemoteCSRCs(arrCSRC);
215 int VoERTP_RTCPImpl::SetSendAudioLevelIndicationStatus(int channel,
219 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
220 "SetSendAudioLevelIndicationStatus(channel=%d, enable=%d,"
221 " ID=%u)", channel, enable, id);
222 if (!_shared->statistics().Initialized())
224 _shared->SetLastError(VE_NOT_INITED, kTraceError);
227 if (enable && (id < kVoiceEngineMinRtpExtensionId ||
228 id > kVoiceEngineMaxRtpExtensionId))
230 // [RFC5285] The 4-bit id is the local identifier of this element in
231 // the range 1-14 inclusive.
232 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
233 "SetSendAudioLevelIndicationStatus() invalid ID parameter");
237 // Set state and id for the specified channel.
238 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
239 voe::Channel* channelPtr = ch.channel();
240 if (channelPtr == NULL)
242 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
243 "SetSendAudioLevelIndicationStatus() failed to locate channel");
246 return channelPtr->SetSendAudioLevelIndicationStatus(enable, id);
249 int VoERTP_RTCPImpl::SetReceiveAudioLevelIndicationStatus(int channel,
252 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
253 "SetReceiveAudioLevelIndicationStatus(channel=%d, enable=%d, id=%u)",
254 channel, enable, id);
255 if (!_shared->statistics().Initialized()) {
256 _shared->SetLastError(VE_NOT_INITED, kTraceError);
260 (id < kVoiceEngineMinRtpExtensionId ||
261 id > kVoiceEngineMaxRtpExtensionId)) {
262 // [RFC5285] The 4-bit id is the local identifier of this element in
263 // the range 1-14 inclusive.
264 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
265 "SetReceiveAbsoluteSenderTimeStatus() invalid id parameter");
268 // Set state and id for the specified channel.
269 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
270 voe::Channel* channel_ptr = ch.channel();
271 if (channel_ptr == NULL) {
272 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
273 "SetReceiveAudioLevelIndicationStatus() failed to locate channel");
276 return channel_ptr->SetReceiveAudioLevelIndicationStatus(enable, id);
279 int VoERTP_RTCPImpl::SetSendAbsoluteSenderTimeStatus(int channel,
282 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
283 "SetSendAbsoluteSenderTimeStatus(channel=%d, enable=%d, id=%u)",
284 channel, enable, id);
285 if (!_shared->statistics().Initialized()) {
286 _shared->SetLastError(VE_NOT_INITED, kTraceError);
289 if (enable && (id < kVoiceEngineMinRtpExtensionId ||
290 id > kVoiceEngineMaxRtpExtensionId)) {
291 // [RFC5285] The 4-bit id is the local identifier of this element in
292 // the range 1-14 inclusive.
293 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
294 "SetSendAbsoluteSenderTimeStatus() invalid id parameter");
297 // Set state and id for the specified channel.
298 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
299 voe::Channel* channelPtr = ch.channel();
300 if (channelPtr == NULL) {
301 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
302 "SetSendAbsoluteSenderTimeStatus() failed to locate channel");
305 return channelPtr->SetSendAbsoluteSenderTimeStatus(enable, id);
308 int VoERTP_RTCPImpl::SetReceiveAbsoluteSenderTimeStatus(int channel,
311 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
312 "SetReceiveAbsoluteSenderTimeStatus(channel=%d, enable=%d, id=%u)",
313 channel, enable, id);
314 if (!_shared->statistics().Initialized()) {
315 _shared->SetLastError(VE_NOT_INITED, kTraceError);
318 if (enable && (id < kVoiceEngineMinRtpExtensionId ||
319 id > kVoiceEngineMaxRtpExtensionId)) {
320 // [RFC5285] The 4-bit id is the local identifier of this element in
321 // the range 1-14 inclusive.
322 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
323 "SetReceiveAbsoluteSenderTimeStatus() invalid id parameter");
326 // Set state and id for the specified channel.
327 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
328 voe::Channel* channelPtr = ch.channel();
329 if (channelPtr == NULL) {
330 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
331 "SetReceiveAbsoluteSenderTimeStatus() failed to locate channel");
334 return channelPtr->SetReceiveAbsoluteSenderTimeStatus(enable, id);
337 int VoERTP_RTCPImpl::SetRTCPStatus(int channel, bool enable)
339 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
340 "SetRTCPStatus(channel=%d, enable=%d)", channel, enable);
341 if (!_shared->statistics().Initialized())
343 _shared->SetLastError(VE_NOT_INITED, kTraceError);
346 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
347 voe::Channel* channelPtr = ch.channel();
348 if (channelPtr == NULL)
350 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
351 "SetRTCPStatus() failed to locate channel");
354 return channelPtr->SetRTCPStatus(enable);
357 int VoERTP_RTCPImpl::GetRTCPStatus(int channel, bool& enabled)
359 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
360 "GetRTCPStatus(channel=%d)", channel);
361 if (!_shared->statistics().Initialized())
363 _shared->SetLastError(VE_NOT_INITED, kTraceError);
366 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
367 voe::Channel* channelPtr = ch.channel();
368 if (channelPtr == NULL)
370 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
371 "GetRTCPStatus() failed to locate channel");
374 return channelPtr->GetRTCPStatus(enabled);
377 int VoERTP_RTCPImpl::SetRTCP_CNAME(int channel, const char cName[256])
379 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
380 "SetRTCP_CNAME(channel=%d, cName=%s)", channel, cName);
381 if (!_shared->statistics().Initialized())
383 _shared->SetLastError(VE_NOT_INITED, kTraceError);
386 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
387 voe::Channel* channelPtr = ch.channel();
388 if (channelPtr == NULL)
390 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
391 "SetRTCP_CNAME() failed to locate channel");
394 return channelPtr->SetRTCP_CNAME(cName);
397 int VoERTP_RTCPImpl::GetRTCP_CNAME(int channel, char cName[256])
399 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
400 "GetRTCP_CNAME(channel=%d, cName=?)", channel);
401 if (!_shared->statistics().Initialized())
403 _shared->SetLastError(VE_NOT_INITED, kTraceError);
406 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
407 voe::Channel* channelPtr = ch.channel();
408 if (channelPtr == NULL)
410 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
411 "GetRTCP_CNAME() failed to locate channel");
414 return channelPtr->GetRTCP_CNAME(cName);
417 int VoERTP_RTCPImpl::GetRemoteRTCP_CNAME(int channel, char cName[256])
419 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
420 "GetRemoteRTCP_CNAME(channel=%d, cName=?)", channel);
421 if (!_shared->statistics().Initialized())
423 _shared->SetLastError(VE_NOT_INITED, kTraceError);
426 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
427 voe::Channel* channelPtr = ch.channel();
428 if (channelPtr == NULL)
430 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
431 "GetRemoteRTCP_CNAME() failed to locate channel");
434 return channelPtr->GetRemoteRTCP_CNAME(cName);
437 int VoERTP_RTCPImpl::GetRemoteRTCPData(
439 unsigned int& NTPHigh, // from sender info in SR
440 unsigned int& NTPLow, // from sender info in SR
441 unsigned int& timestamp, // from sender info in SR
442 unsigned int& playoutTimestamp, // derived locally
443 unsigned int* jitter, // from report block 1 in SR/RR
444 unsigned short* fractionLost) // from report block 1 in SR/RR
446 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
447 "GetRemoteRTCPData(channel=%d,...)", channel);
448 if (!_shared->statistics().Initialized())
450 _shared->SetLastError(VE_NOT_INITED, kTraceError);
453 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
454 voe::Channel* channelPtr = ch.channel();
455 if (channelPtr == NULL)
457 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
458 "GetRemoteRTCP_CNAME() failed to locate channel");
461 return channelPtr->GetRemoteRTCPData(NTPHigh,
469 int VoERTP_RTCPImpl::SendApplicationDefinedRTCPPacket(
471 unsigned char subType,
474 unsigned short dataLengthInBytes)
476 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
477 "SendApplicationDefinedRTCPPacket(channel=%d, subType=%u,"
478 "name=%u, data=?, dataLengthInBytes=%u)",
479 channel, subType, name, dataLengthInBytes);
480 if (!_shared->statistics().Initialized())
482 _shared->SetLastError(VE_NOT_INITED, kTraceError);
485 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
486 voe::Channel* channelPtr = ch.channel();
487 if (channelPtr == NULL)
489 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
490 "SendApplicationDefinedRTCPPacket() failed to locate channel");
493 return channelPtr->SendApplicationDefinedRTCPPacket(subType,
499 int VoERTP_RTCPImpl::GetRTPStatistics(int channel,
500 unsigned int& averageJitterMs,
501 unsigned int& maxJitterMs,
502 unsigned int& discardedPackets)
504 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
505 "GetRTPStatistics(channel=%d,....)", channel);
506 if (!_shared->statistics().Initialized())
508 _shared->SetLastError(VE_NOT_INITED, kTraceError);
511 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
512 voe::Channel* channelPtr = ch.channel();
513 if (channelPtr == NULL)
515 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
516 "GetRTPStatistics() failed to locate channel");
519 return channelPtr->GetRTPStatistics(averageJitterMs,
524 int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats)
526 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
527 "GetRTCPStatistics(channel=%d)", channel);
528 if (!_shared->statistics().Initialized())
530 _shared->SetLastError(VE_NOT_INITED, kTraceError);
533 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
534 voe::Channel* channelPtr = ch.channel();
535 if (channelPtr == NULL)
537 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
538 "GetRTPStatistics() failed to locate channel");
541 return channelPtr->GetRTPStatistics(stats);
544 int VoERTP_RTCPImpl::GetRemoteRTCPSenderInfo(int channel,
545 SenderInfo* sender_info) {
546 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
547 "GetRemoteRTCPSenderInfo(channel=%d)", channel);
548 if (!_shared->statistics().Initialized()) {
549 _shared->SetLastError(VE_NOT_INITED, kTraceError);
552 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
553 voe::Channel* channel_ptr = ch.channel();
554 if (channel_ptr == NULL) {
555 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
556 "GetRemoteRTCPSenderInfo() failed to locate channel");
559 return channel_ptr->GetRemoteRTCPSenderInfo(sender_info);
562 int VoERTP_RTCPImpl::GetRemoteRTCPReportBlocks(
563 int channel, std::vector<ReportBlock>* report_blocks) {
564 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
565 "GetRemoteRTCPReportBlocks(channel=%d)", channel);
566 if (!_shared->statistics().Initialized()) {
567 _shared->SetLastError(VE_NOT_INITED, kTraceError);
570 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
571 voe::Channel* channel_ptr = ch.channel();
572 if (channel_ptr == NULL) {
573 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
574 "GetRemoteRTCPReportBlocks() failed to locate channel");
577 return channel_ptr->GetRemoteRTCPReportBlocks(report_blocks);
580 int VoERTP_RTCPImpl::SetFECStatus(int channel, bool enable, int redPayloadtype)
582 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
583 "SetFECStatus(channel=%d, enable=%d, redPayloadtype=%d)",
584 channel, enable, redPayloadtype);
585 #ifdef WEBRTC_CODEC_RED
586 if (!_shared->statistics().Initialized())
588 _shared->SetLastError(VE_NOT_INITED, kTraceError);
591 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
592 voe::Channel* channelPtr = ch.channel();
593 if (channelPtr == NULL)
595 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
596 "SetFECStatus() failed to locate channel");
599 return channelPtr->SetFECStatus(enable, redPayloadtype);
601 _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
602 "SetFECStatus() RED is not supported");
607 int VoERTP_RTCPImpl::GetFECStatus(int channel,
611 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
612 "GetFECStatus(channel=%d, enabled=?, redPayloadtype=?)",
614 #ifdef WEBRTC_CODEC_RED
615 if (!_shared->statistics().Initialized())
617 _shared->SetLastError(VE_NOT_INITED, kTraceError);
620 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
621 voe::Channel* channelPtr = ch.channel();
622 if (channelPtr == NULL)
624 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
625 "GetFECStatus() failed to locate channel");
628 return channelPtr->GetFECStatus(enabled, redPayloadtype);
630 _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
631 "GetFECStatus() RED is not supported");
637 int VoERTP_RTCPImpl::SetNACKStatus(int channel,
641 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
642 "SetNACKStatus(channel=%d, enable=%d, maxNoPackets=%d)",
643 channel, enable, maxNoPackets);
645 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
646 voe::Channel* channelPtr = ch.channel();
647 if (channelPtr == NULL)
649 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
650 "SetNACKStatus() failed to locate channel");
653 channelPtr->SetNACKStatus(enable, maxNoPackets);
658 int VoERTP_RTCPImpl::StartRTPDump(int channel,
659 const char fileNameUTF8[1024],
660 RTPDirections direction)
662 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
663 "StartRTPDump(channel=%d, fileNameUTF8=%s, direction=%d)",
664 channel, fileNameUTF8, direction);
665 assert(1024 == FileWrapper::kMaxFileNameSize);
666 if (!_shared->statistics().Initialized())
668 _shared->SetLastError(VE_NOT_INITED, kTraceError);
671 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
672 voe::Channel* channelPtr = ch.channel();
673 if (channelPtr == NULL)
675 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
676 "StartRTPDump() failed to locate channel");
679 return channelPtr->StartRTPDump(fileNameUTF8, direction);
682 int VoERTP_RTCPImpl::StopRTPDump(int channel, RTPDirections direction)
684 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
685 "StopRTPDump(channel=%d, direction=%d)", channel, direction);
686 if (!_shared->statistics().Initialized())
688 _shared->SetLastError(VE_NOT_INITED, kTraceError);
691 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
692 voe::Channel* channelPtr = ch.channel();
693 if (channelPtr == NULL)
695 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
696 "StopRTPDump() failed to locate channel");
699 return channelPtr->StopRTPDump(direction);
702 int VoERTP_RTCPImpl::RTPDumpIsActive(int channel, RTPDirections direction)
704 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
705 "RTPDumpIsActive(channel=%d, direction=%d)",
707 if (!_shared->statistics().Initialized())
709 _shared->SetLastError(VE_NOT_INITED, kTraceError);
712 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
713 voe::Channel* channelPtr = ch.channel();
714 if (channelPtr == NULL)
716 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
717 "StopRTPDump() failed to locate channel");
720 return channelPtr->RTPDumpIsActive(direction);
723 int VoERTP_RTCPImpl::GetLastRemoteTimeStamp(int channel,
724 uint32_t* timestamp) {
725 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
726 "GetLastRemoteTimeStamp(channel=%d, timestamp=?)", channel);
727 if (!_shared->statistics().Initialized())
729 _shared->SetLastError(VE_NOT_INITED, kTraceError);
732 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
733 voe::Channel* channelPtr = ch.channel();
734 if (channelPtr == NULL)
736 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
737 "GetLastRemoteTimeStamp() failed to locate channel");
740 *timestamp = channelPtr->LastRemoteTimeStamp();
744 int VoERTP_RTCPImpl::SetVideoEngineBWETarget(int channel,
745 ViENetwork* vie_network,
747 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
748 "SetVideoEngineBWETarget(channel=%d, vie_network=?, video_channel=%d)",
749 channel, vie_network, video_channel);
751 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
752 voe::Channel* channelPtr = ch.channel();
753 if (channelPtr == NULL) {
754 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
755 "SetVideoEngineBWETarget() failed to locate channel");
757 vie_network->Release();
761 channelPtr->SetVideoEngineBWETarget(vie_network, video_channel);
765 #endif // #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
767 } // namespace webrtc