blob: e25a933b86d1ddbcb39af7f3dab1fd24fcd3b247 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
leozwang@webrtc.org0975d212012-03-06 20:59:13 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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.org956aa7e2013-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.orgb1f50102014-03-24 10:38:25 +000014#include "webrtc/video_engine/include/vie_network.h"
pbos@webrtc.org956aa7e2013-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"
niklase@google.com470e71d2011-07-07 08:21:25 +000018
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000019#include "webrtc/voice_engine/channel.h"
20#include "webrtc/voice_engine/transmit_mixer.h"
niklase@google.com470e71d2011-07-07 08:21:25 +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.org0989fb72013-02-15 15:07:32 +000033 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
tommi@webrtc.orga990e122012-04-26 15:28:22 +000034 s->AddRef();
35 return s;
niklase@google.com470e71d2011-07-07 08:21:25 +000036#endif
37}
38
39#ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
40
tommi@webrtc.org851becd2012-04-04 14:57:19 +000041VoERTP_RTCPImpl::VoERTP_RTCPImpl(voe::SharedData* shared) : _shared(shared)
niklase@google.com470e71d2011-07-07 08:21:25 +000042{
tommi@webrtc.org851becd2012-04-04 14:57:19 +000043 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +000044 "VoERTP_RTCPImpl::VoERTP_RTCPImpl() - ctor");
45}
46
47VoERTP_RTCPImpl::~VoERTP_RTCPImpl()
48{
tommi@webrtc.org851becd2012-04-04 14:57:19 +000049 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +000050 "VoERTP_RTCPImpl::~VoERTP_RTCPImpl() - dtor");
51}
52
niklase@google.com470e71d2011-07-07 08:21:25 +000053int VoERTP_RTCPImpl::RegisterRTPObserver(int channel, VoERTPObserver& observer)
54{
tommi@webrtc.org851becd2012-04-04 14:57:19 +000055 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +000056 "RegisterRTPObserver(channel=%d observer=0x%x)",
57 channel, &observer);
tommi@webrtc.org851becd2012-04-04 14:57:19 +000058 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +000059 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +000060 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +000061 return -1;
62 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +000063 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
64 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +000065 if (channelPtr == NULL)
66 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +000067 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +000068 "RegisterRTPObserver() failed to locate channel");
69 return -1;
70 }
71 return channelPtr->RegisterRTPObserver(observer);
72}
73
74int VoERTP_RTCPImpl::DeRegisterRTPObserver(int channel)
75{
tommi@webrtc.org851becd2012-04-04 14:57:19 +000076 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +000077 "DeRegisterRTPObserver(channel=%d)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +000078 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +000079 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +000080 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +000081 return -1;
82 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +000083 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
84 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +000085 if (channelPtr == NULL)
86 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +000087 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +000088 "DeRegisterRTPObserver() failed to locate channel");
89 return -1;
90 }
91 return channelPtr->DeRegisterRTPObserver();
92}
93
94int VoERTP_RTCPImpl::RegisterRTCPObserver(int channel, VoERTCPObserver& observer)
95{
tommi@webrtc.org851becd2012-04-04 14:57:19 +000096 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +000097 "RegisterRTCPObserver(channel=%d observer=0x%x)",
98 channel, &observer);
tommi@webrtc.org851becd2012-04-04 14:57:19 +000099 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000100 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000101 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000102 return -1;
103 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000104 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
105 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000106 if (channelPtr == NULL)
107 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000108 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000109 "RegisterRTPObserver() failed to locate channel");
110 return -1;
111 }
112 return channelPtr->RegisterRTCPObserver(observer);
113}
114
115int VoERTP_RTCPImpl::DeRegisterRTCPObserver(int channel)
116{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000117 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000118 "DeRegisterRTCPObserver(channel=%d)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000119 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000120 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000121 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000122 return -1;
123 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000124 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
125 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000126 if (channelPtr == NULL)
127 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000128 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000129 "DeRegisterRTCPObserver() failed to locate channel");
130 return -1;
131 }
132 return channelPtr->DeRegisterRTCPObserver();
133}
134
135int VoERTP_RTCPImpl::SetLocalSSRC(int channel, unsigned int ssrc)
136{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000137 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000138 "SetLocalSSRC(channel=%d, %lu)", channel, ssrc);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000139 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000140 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000141 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000142 return -1;
143 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000144 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
145 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000146 if (channelPtr == NULL)
147 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000148 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000149 "SetLocalSSRC() failed to locate channel");
150 return -1;
151 }
152 return channelPtr->SetLocalSSRC(ssrc);
153}
154
155int VoERTP_RTCPImpl::GetLocalSSRC(int channel, unsigned int& ssrc)
156{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000157 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000158 "GetLocalSSRC(channel=%d, ssrc=?)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000159 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000160 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000161 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000162 return -1;
163 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000164 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
165 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000166 if (channelPtr == NULL)
167 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000168 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000169 "GetLocalSSRC() failed to locate channel");
170 return -1;
171 }
172 return channelPtr->GetLocalSSRC(ssrc);
173}
174
175int VoERTP_RTCPImpl::GetRemoteSSRC(int channel, unsigned int& ssrc)
176{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000177 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000178 "GetRemoteSSRC(channel=%d, ssrc=?)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000179 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000180 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000181 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000182 return -1;
183 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000184 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
185 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000186 if (channelPtr == NULL)
187 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000188 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000189 "GetRemoteSSRC() failed to locate channel");
190 return -1;
191 }
192 return channelPtr->GetRemoteSSRC(ssrc);
193}
194
195int VoERTP_RTCPImpl::GetRemoteCSRCs(int channel, unsigned int arrCSRC[15])
196{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000197 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000198 "GetRemoteCSRCs(channel=%d, arrCSRC=?)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000199 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000200 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000201 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000202 return -1;
203 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000204 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
205 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000206 if (channelPtr == NULL)
207 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000208 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000209 "GetRemoteCSRCs() failed to locate channel");
210 return -1;
211 }
212 return channelPtr->GetRemoteCSRCs(arrCSRC);
213}
214
wu@webrtc.orgebdb0e32014-03-06 23:49:08 +0000215int VoERTP_RTCPImpl::SetSendAudioLevelIndicationStatus(int channel,
216 bool enable,
217 unsigned char id)
niklase@google.com470e71d2011-07-07 08:21:25 +0000218{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000219 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
wu@webrtc.orgebdb0e32014-03-06 23:49:08 +0000220 "SetSendAudioLevelIndicationStatus(channel=%d, enable=%d,"
221 " ID=%u)", channel, enable, id);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000222 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000223 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000224 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000225 return -1;
226 }
wu@webrtc.orgebdb0e32014-03-06 23:49:08 +0000227 if (enable && (id < kVoiceEngineMinRtpExtensionId ||
228 id > kVoiceEngineMaxRtpExtensionId))
niklase@google.com470e71d2011-07-07 08:21:25 +0000229 {
wu@webrtc.orgebdb0e32014-03-06 23:49:08 +0000230 // [RFC5285] The 4-bit id is the local identifier of this element in
niklase@google.com470e71d2011-07-07 08:21:25 +0000231 // the range 1-14 inclusive.
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000232 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
wu@webrtc.orgebdb0e32014-03-06 23:49:08 +0000233 "SetSendAudioLevelIndicationStatus() invalid ID parameter");
niklase@google.com470e71d2011-07-07 08:21:25 +0000234 return -1;
235 }
236
wu@webrtc.orgebdb0e32014-03-06 23:49:08 +0000237 // Set state and id for the specified channel.
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000238 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
239 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000240 if (channelPtr == NULL)
241 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000242 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
wu@webrtc.orgebdb0e32014-03-06 23:49:08 +0000243 "SetSendAudioLevelIndicationStatus() failed to locate channel");
niklase@google.com470e71d2011-07-07 08:21:25 +0000244 return -1;
245 }
wu@webrtc.orgebdb0e32014-03-06 23:49:08 +0000246 return channelPtr->SetSendAudioLevelIndicationStatus(enable, id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000247}
248
wu@webrtc.org93fd25c2014-04-24 20:33:08 +0000249int VoERTP_RTCPImpl::SetReceiveAudioLevelIndicationStatus(int channel,
250 bool enable,
251 unsigned char id) {
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);
257 return -1;
258 }
259 if (enable &&
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");
266 return -1;
267 }
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");
274 return -1;
275 }
276 return channel_ptr->SetReceiveAudioLevelIndicationStatus(enable, id);
277}
278
wu@webrtc.orgebdb0e32014-03-06 23:49:08 +0000279int VoERTP_RTCPImpl::SetSendAbsoluteSenderTimeStatus(int channel,
280 bool enable,
281 unsigned char id) {
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);
287 return -1;
288 }
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");
295 return -1;
296 }
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");
303 return -1;
304 }
305 return channelPtr->SetSendAbsoluteSenderTimeStatus(enable, id);
306}
307
308int VoERTP_RTCPImpl::SetReceiveAbsoluteSenderTimeStatus(int channel,
309 bool enable,
310 unsigned char id) {
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);
316 return -1;
317 }
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");
324 return -1;
325 }
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");
332 return -1;
333 }
334 return channelPtr->SetReceiveAbsoluteSenderTimeStatus(enable, id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000335}
336
337int VoERTP_RTCPImpl::SetRTCPStatus(int channel, bool enable)
338{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000339 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000340 "SetRTCPStatus(channel=%d, enable=%d)", channel, enable);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000341 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000342 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000343 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000344 return -1;
345 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000346 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
347 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000348 if (channelPtr == NULL)
349 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000350 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000351 "SetRTCPStatus() failed to locate channel");
352 return -1;
353 }
354 return channelPtr->SetRTCPStatus(enable);
355}
356
357int VoERTP_RTCPImpl::GetRTCPStatus(int channel, bool& enabled)
358{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000359 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000360 "GetRTCPStatus(channel=%d)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000361 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000362 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000363 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000364 return -1;
365 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000366 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
367 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000368 if (channelPtr == NULL)
369 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000370 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000371 "GetRTCPStatus() failed to locate channel");
372 return -1;
373 }
374 return channelPtr->GetRTCPStatus(enabled);
375}
376
377int VoERTP_RTCPImpl::SetRTCP_CNAME(int channel, const char cName[256])
378{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000379 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000380 "SetRTCP_CNAME(channel=%d, cName=%s)", channel, cName);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000381 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000382 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000383 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000384 return -1;
385 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000386 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
387 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000388 if (channelPtr == NULL)
389 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000390 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000391 "SetRTCP_CNAME() failed to locate channel");
392 return -1;
393 }
394 return channelPtr->SetRTCP_CNAME(cName);
395}
396
397int VoERTP_RTCPImpl::GetRTCP_CNAME(int channel, char cName[256])
398{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000399 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000400 "GetRTCP_CNAME(channel=%d, cName=?)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000401 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000402 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000403 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000404 return -1;
405 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000406 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
407 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000408 if (channelPtr == NULL)
409 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000410 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000411 "GetRTCP_CNAME() failed to locate channel");
412 return -1;
413 }
414 return channelPtr->GetRTCP_CNAME(cName);
415}
416
417int VoERTP_RTCPImpl::GetRemoteRTCP_CNAME(int channel, char cName[256])
418{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000419 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000420 "GetRemoteRTCP_CNAME(channel=%d, cName=?)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000421 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000422 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000423 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000424 return -1;
425 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000426 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
427 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000428 if (channelPtr == NULL)
429 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000430 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000431 "GetRemoteRTCP_CNAME() failed to locate channel");
432 return -1;
433 }
434 return channelPtr->GetRemoteRTCP_CNAME(cName);
435}
436
437int VoERTP_RTCPImpl::GetRemoteRTCPData(
438 int channel,
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
445{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000446 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000447 "GetRemoteRTCPData(channel=%d,...)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000448 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000449 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000450 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000451 return -1;
452 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000453 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
454 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000455 if (channelPtr == NULL)
456 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000457 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000458 "GetRemoteRTCP_CNAME() failed to locate channel");
459 return -1;
460 }
461 return channelPtr->GetRemoteRTCPData(NTPHigh,
462 NTPLow,
463 timestamp,
464 playoutTimestamp,
465 jitter,
466 fractionLost);
467}
468
469int VoERTP_RTCPImpl::SendApplicationDefinedRTCPPacket(
470 int channel,
pbos@webrtc.org92135212013-05-14 08:31:39 +0000471 unsigned char subType,
niklase@google.com470e71d2011-07-07 08:21:25 +0000472 unsigned int name,
473 const char* data,
474 unsigned short dataLengthInBytes)
475{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000476 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000477 "SendApplicationDefinedRTCPPacket(channel=%d, subType=%u,"
478 "name=%u, data=?, dataLengthInBytes=%u)",
479 channel, subType, name, dataLengthInBytes);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000480 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000481 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000482 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000483 return -1;
484 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000485 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
486 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000487 if (channelPtr == NULL)
488 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000489 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000490 "SendApplicationDefinedRTCPPacket() failed to locate channel");
491 return -1;
492 }
493 return channelPtr->SendApplicationDefinedRTCPPacket(subType,
494 name,
495 data,
496 dataLengthInBytes);
497}
498
499int VoERTP_RTCPImpl::GetRTPStatistics(int channel,
500 unsigned int& averageJitterMs,
501 unsigned int& maxJitterMs,
502 unsigned int& discardedPackets)
503{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000504 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000505 "GetRTPStatistics(channel=%d,....)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000506 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000507 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000508 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000509 return -1;
510 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000511 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
512 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000513 if (channelPtr == NULL)
514 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000515 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000516 "GetRTPStatistics() failed to locate channel");
517 return -1;
518 }
519 return channelPtr->GetRTPStatistics(averageJitterMs,
520 maxJitterMs,
521 discardedPackets);
522}
523
524int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats)
525{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000526 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000527 "GetRTCPStatistics(channel=%d)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000528 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000529 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000530 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000531 return -1;
532 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000533 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
534 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000535 if (channelPtr == NULL)
536 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000537 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000538 "GetRTPStatistics() failed to locate channel");
539 return -1;
540 }
541 return channelPtr->GetRTPStatistics(stats);
542}
543
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +0000544int 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);
550 return -1;
551 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000552 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
553 voe::Channel* channel_ptr = ch.channel();
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +0000554 if (channel_ptr == NULL) {
555 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
556 "GetRemoteRTCPSenderInfo() failed to locate channel");
557 return -1;
558 }
559 return channel_ptr->GetRemoteRTCPSenderInfo(sender_info);
560}
561
562int 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);
568 return -1;
569 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000570 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
571 voe::Channel* channel_ptr = ch.channel();
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +0000572 if (channel_ptr == NULL) {
573 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
574 "GetRemoteRTCPReportBlocks() failed to locate channel");
575 return -1;
576 }
577 return channel_ptr->GetRemoteRTCPReportBlocks(report_blocks);
578}
579
niklase@google.com470e71d2011-07-07 08:21:25 +0000580int VoERTP_RTCPImpl::SetFECStatus(int channel, bool enable, int redPayloadtype)
581{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000582 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000583 "SetFECStatus(channel=%d, enable=%d, redPayloadtype=%d)",
584 channel, enable, redPayloadtype);
585#ifdef WEBRTC_CODEC_RED
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000586 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000587 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000588 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000589 return -1;
590 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000591 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
592 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000593 if (channelPtr == NULL)
594 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000595 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000596 "SetFECStatus() failed to locate channel");
597 return -1;
598 }
599 return channelPtr->SetFECStatus(enable, redPayloadtype);
600#else
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000601 _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
602 "SetFECStatus() RED is not supported");
niklase@google.com470e71d2011-07-07 08:21:25 +0000603 return -1;
604#endif
605}
606
607int VoERTP_RTCPImpl::GetFECStatus(int channel,
608 bool& enabled,
609 int& redPayloadtype)
610{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000611 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000612 "GetFECStatus(channel=%d, enabled=?, redPayloadtype=?)",
613 channel);
614#ifdef WEBRTC_CODEC_RED
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000615 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000616 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000617 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000618 return -1;
619 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000620 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
621 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000622 if (channelPtr == NULL)
623 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000624 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000625 "GetFECStatus() failed to locate channel");
626 return -1;
627 }
628 return channelPtr->GetFECStatus(enabled, redPayloadtype);
629#else
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000630 _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
631 "GetFECStatus() RED is not supported");
niklase@google.com470e71d2011-07-07 08:21:25 +0000632 return -1;
633#endif
634}
635
niklas.enbom@webrtc.orgb35d2e32013-05-31 21:13:52 +0000636
637int VoERTP_RTCPImpl::SetNACKStatus(int channel,
638 bool enable,
639 int maxNoPackets)
640{
641 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
642 "SetNACKStatus(channel=%d, enable=%d, maxNoPackets=%d)",
643 channel, enable, maxNoPackets);
pwestin@webrtc.orgdb249952013-06-05 15:33:20 +0000644
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000645 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
646 voe::Channel* channelPtr = ch.channel();
pwestin@webrtc.orgdb249952013-06-05 15:33:20 +0000647 if (channelPtr == NULL)
648 {
649 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
650 "SetNACKStatus() failed to locate channel");
651 return -1;
652 }
653 channelPtr->SetNACKStatus(enable, maxNoPackets);
niklas.enbom@webrtc.orgb35d2e32013-05-31 21:13:52 +0000654 return 0;
655}
656
657
niklase@google.com470e71d2011-07-07 08:21:25 +0000658int VoERTP_RTCPImpl::StartRTPDump(int channel,
659 const char fileNameUTF8[1024],
660 RTPDirections direction)
661{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000662 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000663 "StartRTPDump(channel=%d, fileNameUTF8=%s, direction=%d)",
664 channel, fileNameUTF8, direction);
665 assert(1024 == FileWrapper::kMaxFileNameSize);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000666 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000667 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000668 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000669 return -1;
670 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000671 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
672 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000673 if (channelPtr == NULL)
674 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000675 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000676 "StartRTPDump() failed to locate channel");
677 return -1;
678 }
679 return channelPtr->StartRTPDump(fileNameUTF8, direction);
680}
681
682int VoERTP_RTCPImpl::StopRTPDump(int channel, RTPDirections direction)
683{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000684 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000685 "StopRTPDump(channel=%d, direction=%d)", channel, direction);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000686 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000687 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000688 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000689 return -1;
690 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000691 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
692 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000693 if (channelPtr == NULL)
694 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000695 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000696 "StopRTPDump() failed to locate channel");
697 return -1;
698 }
699 return channelPtr->StopRTPDump(direction);
700}
701
702int VoERTP_RTCPImpl::RTPDumpIsActive(int channel, RTPDirections direction)
703{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000704 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000705 "RTPDumpIsActive(channel=%d, direction=%d)",
706 channel, direction);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000707 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000708 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000709 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000710 return -1;
711 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000712 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
713 voe::Channel* channelPtr = ch.channel();
niklase@google.com470e71d2011-07-07 08:21:25 +0000714 if (channelPtr == NULL)
715 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000716 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000717 "StopRTPDump() failed to locate channel");
718 return -1;
719 }
720 return channelPtr->RTPDumpIsActive(direction);
721}
722
roosa@google.com0870f022012-12-12 21:31:41 +0000723int 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())
728 {
729 _shared->SetLastError(VE_NOT_INITED, kTraceError);
730 return -1;
731 }
pbos@webrtc.org676ff1e2013-08-07 17:57:36 +0000732 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
733 voe::Channel* channelPtr = ch.channel();
roosa@google.com0870f022012-12-12 21:31:41 +0000734 if (channelPtr == NULL)
735 {
736 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
737 "GetLastRemoteTimeStamp() failed to locate channel");
738 return -1;
739 }
740 *timestamp = channelPtr->LastRemoteTimeStamp();
741 return 0;
742}
743
solenberg@webrtc.orgb1f50102014-03-24 10:38:25 +0000744int VoERTP_RTCPImpl::SetVideoEngineBWETarget(int channel,
745 ViENetwork* vie_network,
746 int video_channel) {
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);
750
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");
756 if (vie_network) {
757 vie_network->Release();
758 }
759 return -1;
760 }
761 channelPtr->SetVideoEngineBWETarget(vie_network, video_channel);
762 return 0;
763}
764
niklase@google.com470e71d2011-07-07 08:21:25 +0000765#endif // #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
766
767} // namespace webrtc