blob: 370e6007de3715b1e466c2dee8830f405466036b [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +00001/*
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
pbos@webrtc.org471ae722013-05-21 13:52:32 +000011#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"
solenberg@webrtc.orgfec6b6e2014-03-24 10:38:25 +000014#include "webrtc/video_engine/include/vie_network.h"
pbos@webrtc.org471ae722013-05-21 13:52:32 +000015#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"
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000018
pbos@webrtc.org471ae722013-05-21 13:52:32 +000019#include "webrtc/voice_engine/channel.h"
20#include "webrtc/voice_engine/transmit_mixer.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000021
22namespace webrtc {
23
24VoERTP_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 }
tommi@webrtc.orgb9e5a3d2013-02-15 15:07:32 +000033 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000034 s->AddRef();
35 return s;
36#endif
37}
38
39#ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
40
41VoERTP_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
47VoERTP_RTCPImpl::~VoERTP_RTCPImpl()
48{
49 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
50 "VoERTP_RTCPImpl::~VoERTP_RTCPImpl() - dtor");
51}
52
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000053int 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 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +000062 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
63 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000064 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
73int 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 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +000082 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
83 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000084 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
93int 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 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000102 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
103 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000104 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
wu@webrtc.org9a823222014-03-06 23:49:08 +0000113int VoERTP_RTCPImpl::SetSendAudioLevelIndicationStatus(int channel,
114 bool enable,
115 unsigned char id)
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000116{
117 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
wu@webrtc.org9a823222014-03-06 23:49:08 +0000118 "SetSendAudioLevelIndicationStatus(channel=%d, enable=%d,"
119 " ID=%u)", channel, enable, id);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000120 if (!_shared->statistics().Initialized())
121 {
122 _shared->SetLastError(VE_NOT_INITED, kTraceError);
123 return -1;
124 }
wu@webrtc.org9a823222014-03-06 23:49:08 +0000125 if (enable && (id < kVoiceEngineMinRtpExtensionId ||
126 id > kVoiceEngineMaxRtpExtensionId))
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000127 {
wu@webrtc.org9a823222014-03-06 23:49:08 +0000128 // [RFC5285] The 4-bit id is the local identifier of this element in
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000129 // the range 1-14 inclusive.
130 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
wu@webrtc.org9a823222014-03-06 23:49:08 +0000131 "SetSendAudioLevelIndicationStatus() invalid ID parameter");
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000132 return -1;
133 }
134
wu@webrtc.org9a823222014-03-06 23:49:08 +0000135 // Set state and id for the specified channel.
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000136 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
137 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000138 if (channelPtr == NULL)
139 {
140 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
wu@webrtc.org9a823222014-03-06 23:49:08 +0000141 "SetSendAudioLevelIndicationStatus() failed to locate channel");
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000142 return -1;
143 }
wu@webrtc.org9a823222014-03-06 23:49:08 +0000144 return channelPtr->SetSendAudioLevelIndicationStatus(enable, id);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000145}
146
wu@webrtc.org47e54ba2014-04-24 20:33:08 +0000147int 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
wu@webrtc.org9a823222014-03-06 23:49:08 +0000177int 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
206int 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);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000233}
234
235int 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 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000244 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
245 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000246 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
255int 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 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000264 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
265 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000266 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
275int 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 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000284 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
285 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000286 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
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000295int VoERTP_RTCPImpl::GetRemoteRTCP_CNAME(int channel, char cName[256])
296{
297 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
298 "GetRemoteRTCP_CNAME(channel=%d, cName=?)", channel);
299 if (!_shared->statistics().Initialized())
300 {
301 _shared->SetLastError(VE_NOT_INITED, kTraceError);
302 return -1;
303 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000304 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
305 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000306 if (channelPtr == NULL)
307 {
308 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
309 "GetRemoteRTCP_CNAME() failed to locate channel");
310 return -1;
311 }
312 return channelPtr->GetRemoteRTCP_CNAME(cName);
313}
314
315int VoERTP_RTCPImpl::GetRemoteRTCPData(
316 int channel,
317 unsigned int& NTPHigh, // from sender info in SR
318 unsigned int& NTPLow, // from sender info in SR
319 unsigned int& timestamp, // from sender info in SR
320 unsigned int& playoutTimestamp, // derived locally
321 unsigned int* jitter, // from report block 1 in SR/RR
322 unsigned short* fractionLost) // from report block 1 in SR/RR
323{
324 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
325 "GetRemoteRTCPData(channel=%d,...)", channel);
326 if (!_shared->statistics().Initialized())
327 {
328 _shared->SetLastError(VE_NOT_INITED, kTraceError);
329 return -1;
330 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000331 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
332 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000333 if (channelPtr == NULL)
334 {
335 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
336 "GetRemoteRTCP_CNAME() failed to locate channel");
337 return -1;
338 }
339 return channelPtr->GetRemoteRTCPData(NTPHigh,
340 NTPLow,
341 timestamp,
342 playoutTimestamp,
343 jitter,
344 fractionLost);
345}
346
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000347int VoERTP_RTCPImpl::GetRTPStatistics(int channel,
348 unsigned int& averageJitterMs,
349 unsigned int& maxJitterMs,
350 unsigned int& discardedPackets)
351{
352 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
353 "GetRTPStatistics(channel=%d,....)", channel);
354 if (!_shared->statistics().Initialized())
355 {
356 _shared->SetLastError(VE_NOT_INITED, kTraceError);
357 return -1;
358 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000359 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
360 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000361 if (channelPtr == NULL)
362 {
363 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
364 "GetRTPStatistics() failed to locate channel");
365 return -1;
366 }
367 return channelPtr->GetRTPStatistics(averageJitterMs,
368 maxJitterMs,
369 discardedPackets);
370}
371
372int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats)
373{
374 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
375 "GetRTCPStatistics(channel=%d)", channel);
376 if (!_shared->statistics().Initialized())
377 {
378 _shared->SetLastError(VE_NOT_INITED, kTraceError);
379 return -1;
380 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000381 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
382 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000383 if (channelPtr == NULL)
384 {
385 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
386 "GetRTPStatistics() failed to locate channel");
387 return -1;
388 }
389 return channelPtr->GetRTPStatistics(stats);
390}
391
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000392int VoERTP_RTCPImpl::GetRemoteRTCPReportBlocks(
393 int channel, std::vector<ReportBlock>* report_blocks) {
394 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
395 "GetRemoteRTCPReportBlocks(channel=%d)", channel);
396 if (!_shared->statistics().Initialized()) {
397 _shared->SetLastError(VE_NOT_INITED, kTraceError);
398 return -1;
399 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000400 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
401 voe::Channel* channel_ptr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000402 if (channel_ptr == NULL) {
403 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
404 "GetRemoteRTCPReportBlocks() failed to locate channel");
405 return -1;
406 }
407 return channel_ptr->GetRemoteRTCPReportBlocks(report_blocks);
408}
409
minyue@webrtc.orgdd671de2014-05-28 09:52:06 +0000410int VoERTP_RTCPImpl::SetREDStatus(int channel, bool enable, int redPayloadtype)
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000411{
412 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
minyue@webrtc.orgdd671de2014-05-28 09:52:06 +0000413 "SetREDStatus(channel=%d, enable=%d, redPayloadtype=%d)",
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000414 channel, enable, redPayloadtype);
415#ifdef WEBRTC_CODEC_RED
416 if (!_shared->statistics().Initialized())
417 {
418 _shared->SetLastError(VE_NOT_INITED, kTraceError);
419 return -1;
420 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000421 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
422 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000423 if (channelPtr == NULL)
424 {
425 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
minyue@webrtc.orgdd671de2014-05-28 09:52:06 +0000426 "SetREDStatus() failed to locate channel");
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000427 return -1;
428 }
minyue@webrtc.orgdd671de2014-05-28 09:52:06 +0000429 return channelPtr->SetREDStatus(enable, redPayloadtype);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000430#else
431 _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
minyue@webrtc.orgdd671de2014-05-28 09:52:06 +0000432 "SetREDStatus() RED is not supported");
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000433 return -1;
434#endif
435}
436
minyue@webrtc.orgdd671de2014-05-28 09:52:06 +0000437int VoERTP_RTCPImpl::GetREDStatus(int channel,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000438 bool& enabled,
439 int& redPayloadtype)
440{
441 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
minyue@webrtc.orgdd671de2014-05-28 09:52:06 +0000442 "GetREDStatus(channel=%d, enabled=?, redPayloadtype=?)",
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000443 channel);
444#ifdef WEBRTC_CODEC_RED
445 if (!_shared->statistics().Initialized())
446 {
447 _shared->SetLastError(VE_NOT_INITED, kTraceError);
448 return -1;
449 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000450 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
451 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000452 if (channelPtr == NULL)
453 {
454 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
minyue@webrtc.orgdd671de2014-05-28 09:52:06 +0000455 "GetREDStatus() failed to locate channel");
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000456 return -1;
457 }
minyue@webrtc.orgdd671de2014-05-28 09:52:06 +0000458 return channelPtr->GetREDStatus(enabled, redPayloadtype);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000459#else
460 _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
minyue@webrtc.orgdd671de2014-05-28 09:52:06 +0000461 "GetREDStatus() RED is not supported");
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000462 return -1;
463#endif
464}
465
niklas.enbom@webrtc.org2753b762013-05-31 21:13:52 +0000466int VoERTP_RTCPImpl::SetNACKStatus(int channel,
467 bool enable,
468 int maxNoPackets)
469{
470 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
471 "SetNACKStatus(channel=%d, enable=%d, maxNoPackets=%d)",
472 channel, enable, maxNoPackets);
pwestin@webrtc.orgb8171ff2013-06-05 15:33:20 +0000473
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000474 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
475 voe::Channel* channelPtr = ch.channel();
pwestin@webrtc.orgb8171ff2013-06-05 15:33:20 +0000476 if (channelPtr == NULL)
477 {
478 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
479 "SetNACKStatus() failed to locate channel");
480 return -1;
481 }
482 channelPtr->SetNACKStatus(enable, maxNoPackets);
niklas.enbom@webrtc.org2753b762013-05-31 21:13:52 +0000483 return 0;
484}
485
486
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000487int VoERTP_RTCPImpl::StartRTPDump(int channel,
488 const char fileNameUTF8[1024],
489 RTPDirections direction)
490{
491 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
492 "StartRTPDump(channel=%d, fileNameUTF8=%s, direction=%d)",
493 channel, fileNameUTF8, direction);
494 assert(1024 == FileWrapper::kMaxFileNameSize);
495 if (!_shared->statistics().Initialized())
496 {
497 _shared->SetLastError(VE_NOT_INITED, kTraceError);
498 return -1;
499 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000500 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
501 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000502 if (channelPtr == NULL)
503 {
504 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
505 "StartRTPDump() failed to locate channel");
506 return -1;
507 }
508 return channelPtr->StartRTPDump(fileNameUTF8, direction);
509}
510
511int VoERTP_RTCPImpl::StopRTPDump(int channel, RTPDirections direction)
512{
513 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
514 "StopRTPDump(channel=%d, direction=%d)", channel, direction);
515 if (!_shared->statistics().Initialized())
516 {
517 _shared->SetLastError(VE_NOT_INITED, kTraceError);
518 return -1;
519 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000520 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
521 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000522 if (channelPtr == NULL)
523 {
524 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
525 "StopRTPDump() failed to locate channel");
526 return -1;
527 }
528 return channelPtr->StopRTPDump(direction);
529}
530
531int VoERTP_RTCPImpl::RTPDumpIsActive(int channel, RTPDirections direction)
532{
533 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
534 "RTPDumpIsActive(channel=%d, direction=%d)",
535 channel, direction);
536 if (!_shared->statistics().Initialized())
537 {
538 _shared->SetLastError(VE_NOT_INITED, kTraceError);
539 return -1;
540 }
pbos@webrtc.orgb3ada152013-08-07 17:57:36 +0000541 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
542 voe::Channel* channelPtr = ch.channel();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000543 if (channelPtr == NULL)
544 {
545 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
546 "StopRTPDump() failed to locate channel");
547 return -1;
548 }
549 return channelPtr->RTPDumpIsActive(direction);
550}
551
solenberg@webrtc.orgfec6b6e2014-03-24 10:38:25 +0000552int VoERTP_RTCPImpl::SetVideoEngineBWETarget(int channel,
553 ViENetwork* vie_network,
554 int video_channel) {
555 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
556 "SetVideoEngineBWETarget(channel=%d, vie_network=?, video_channel=%d)",
557 channel, vie_network, video_channel);
558
559 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
560 voe::Channel* channelPtr = ch.channel();
561 if (channelPtr == NULL) {
562 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
563 "SetVideoEngineBWETarget() failed to locate channel");
564 if (vie_network) {
565 vie_network->Release();
566 }
567 return -1;
568 }
569 channelPtr->SetVideoEngineBWETarget(vie_network, video_channel);
570 return 0;
571}
572
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000573#endif // #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
574
575} // namespace webrtc