blob: 102e09e3cb899af06585c34102cde608e68234b9 [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"
14#include "webrtc/voice_engine/include/voe_errors.h"
15#include "webrtc/voice_engine/voe_rtp_rtcp_impl.h"
16#include "webrtc/voice_engine/voice_engine_impl.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000017
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000018#include "webrtc/voice_engine/channel.h"
19#include "webrtc/voice_engine/transmit_mixer.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020
21namespace webrtc {
22
23VoERTP_RTCP* VoERTP_RTCP::GetInterface(VoiceEngine* voiceEngine)
24{
25#ifndef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
26 return NULL;
27#else
28 if (NULL == voiceEngine)
29 {
30 return NULL;
31 }
tommi@webrtc.org0989fb72013-02-15 15:07:32 +000032 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
tommi@webrtc.orga990e122012-04-26 15:28:22 +000033 s->AddRef();
34 return s;
niklase@google.com470e71d2011-07-07 08:21:25 +000035#endif
36}
37
38#ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
39
tommi@webrtc.org851becd2012-04-04 14:57:19 +000040VoERTP_RTCPImpl::VoERTP_RTCPImpl(voe::SharedData* shared) : _shared(shared)
niklase@google.com470e71d2011-07-07 08:21:25 +000041{
tommi@webrtc.org851becd2012-04-04 14:57:19 +000042 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +000043 "VoERTP_RTCPImpl::VoERTP_RTCPImpl() - ctor");
44}
45
46VoERTP_RTCPImpl::~VoERTP_RTCPImpl()
47{
tommi@webrtc.org851becd2012-04-04 14:57:19 +000048 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +000049 "VoERTP_RTCPImpl::~VoERTP_RTCPImpl() - dtor");
50}
51
niklase@google.com470e71d2011-07-07 08:21:25 +000052int VoERTP_RTCPImpl::RegisterRTPObserver(int channel, VoERTPObserver& observer)
53{
tommi@webrtc.org851becd2012-04-04 14:57:19 +000054 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +000055 "RegisterRTPObserver(channel=%d observer=0x%x)",
56 channel, &observer);
tommi@webrtc.org851becd2012-04-04 14:57:19 +000057 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +000058 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +000059 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +000060 return -1;
61 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +000062 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +000063 voe::Channel* channelPtr = sc.ChannelPtr();
64 if (channelPtr == NULL)
65 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +000066 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +000067 "RegisterRTPObserver() failed to locate channel");
68 return -1;
69 }
70 return channelPtr->RegisterRTPObserver(observer);
71}
72
73int VoERTP_RTCPImpl::DeRegisterRTPObserver(int channel)
74{
tommi@webrtc.org851becd2012-04-04 14:57:19 +000075 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +000076 "DeRegisterRTPObserver(channel=%d)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +000077 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +000078 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +000079 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +000080 return -1;
81 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +000082 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +000083 voe::Channel* channelPtr = sc.ChannelPtr();
84 if (channelPtr == NULL)
85 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +000086 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +000087 "DeRegisterRTPObserver() failed to locate channel");
88 return -1;
89 }
90 return channelPtr->DeRegisterRTPObserver();
91}
92
93int VoERTP_RTCPImpl::RegisterRTCPObserver(int channel, VoERTCPObserver& observer)
94{
tommi@webrtc.org851becd2012-04-04 14:57:19 +000095 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +000096 "RegisterRTCPObserver(channel=%d observer=0x%x)",
97 channel, &observer);
tommi@webrtc.org851becd2012-04-04 14:57:19 +000098 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +000099 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000100 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000101 return -1;
102 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000103 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000104 voe::Channel* channelPtr = sc.ChannelPtr();
105 if (channelPtr == NULL)
106 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000107 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000108 "RegisterRTPObserver() failed to locate channel");
109 return -1;
110 }
111 return channelPtr->RegisterRTCPObserver(observer);
112}
113
114int VoERTP_RTCPImpl::DeRegisterRTCPObserver(int channel)
115{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000116 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000117 "DeRegisterRTCPObserver(channel=%d)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000118 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000119 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000120 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000121 return -1;
122 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000123 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000124 voe::Channel* channelPtr = sc.ChannelPtr();
125 if (channelPtr == NULL)
126 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000127 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000128 "DeRegisterRTCPObserver() failed to locate channel");
129 return -1;
130 }
131 return channelPtr->DeRegisterRTCPObserver();
132}
133
134int VoERTP_RTCPImpl::SetLocalSSRC(int channel, unsigned int ssrc)
135{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000136 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000137 "SetLocalSSRC(channel=%d, %lu)", channel, ssrc);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000138 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000139 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000140 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000141 return -1;
142 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000143 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000144 voe::Channel* channelPtr = sc.ChannelPtr();
145 if (channelPtr == NULL)
146 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000147 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000148 "SetLocalSSRC() failed to locate channel");
149 return -1;
150 }
151 return channelPtr->SetLocalSSRC(ssrc);
152}
153
154int VoERTP_RTCPImpl::GetLocalSSRC(int channel, unsigned int& ssrc)
155{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000156 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000157 "GetLocalSSRC(channel=%d, ssrc=?)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000158 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000159 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000160 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000161 return -1;
162 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000163 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000164 voe::Channel* channelPtr = sc.ChannelPtr();
165 if (channelPtr == NULL)
166 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000167 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000168 "GetLocalSSRC() failed to locate channel");
169 return -1;
170 }
171 return channelPtr->GetLocalSSRC(ssrc);
172}
173
174int VoERTP_RTCPImpl::GetRemoteSSRC(int channel, unsigned int& ssrc)
175{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000176 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000177 "GetRemoteSSRC(channel=%d, ssrc=?)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000178 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000179 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000180 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000181 return -1;
182 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000183 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000184 voe::Channel* channelPtr = sc.ChannelPtr();
185 if (channelPtr == NULL)
186 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000187 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000188 "GetRemoteSSRC() failed to locate channel");
189 return -1;
190 }
191 return channelPtr->GetRemoteSSRC(ssrc);
192}
193
194int VoERTP_RTCPImpl::GetRemoteCSRCs(int channel, unsigned int arrCSRC[15])
195{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000196 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000197 "GetRemoteCSRCs(channel=%d, arrCSRC=?)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000198 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000199 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000200 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000201 return -1;
202 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000203 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000204 voe::Channel* channelPtr = sc.ChannelPtr();
205 if (channelPtr == NULL)
206 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000207 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000208 "GetRemoteCSRCs() failed to locate channel");
209 return -1;
210 }
211 return channelPtr->GetRemoteCSRCs(arrCSRC);
212}
213
214
215int VoERTP_RTCPImpl::SetRTPAudioLevelIndicationStatus(int channel,
216 bool enable,
217 unsigned char ID)
218{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000219 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000220 "SetRTPAudioLevelIndicationStatus(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 }
227 if (ID < kVoiceEngineMinRtpExtensionId ||
228 ID > kVoiceEngineMaxRtpExtensionId)
229 {
230 // [RFC5285] The 4-bit ID is the local identifier of this element in
231 // the range 1-14 inclusive.
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000232 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000233 "SetRTPAudioLevelIndicationStatus() invalid ID parameter");
234 return -1;
235 }
236
niklase@google.com470e71d2011-07-07 08:21:25 +0000237 // Set state and ID for the specified channel.
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000238 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000239 voe::Channel* channelPtr = sc.ChannelPtr();
240 if (channelPtr == NULL)
241 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000242 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000243 "SetRTPAudioLevelIndicationStatus() failed to locate channel");
244 return -1;
245 }
246 return channelPtr->SetRTPAudioLevelIndicationStatus(enable, ID);
247}
248
249int VoERTP_RTCPImpl::GetRTPAudioLevelIndicationStatus(int channel,
250 bool& enabled,
251 unsigned char& ID)
252{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000253 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000254 "GetRTPAudioLevelIndicationStatus(channel=%d, enable=?, ID=?)",
255 channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000256 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000257 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000258 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000259 return -1;
260 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000261 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000262 voe::Channel* channelPtr = sc.ChannelPtr();
263 if (channelPtr == NULL)
264 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000265 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000266 "GetRTPAudioLevelIndicationStatus() failed to locate channel");
267 return -1;
268 }
269 return channelPtr->GetRTPAudioLevelIndicationStatus(enabled, ID);
270}
271
272int VoERTP_RTCPImpl::SetRTCPStatus(int channel, bool enable)
273{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000274 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000275 "SetRTCPStatus(channel=%d, enable=%d)", channel, enable);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000276 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000277 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000278 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000279 return -1;
280 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000281 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000282 voe::Channel* channelPtr = sc.ChannelPtr();
283 if (channelPtr == NULL)
284 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000285 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000286 "SetRTCPStatus() failed to locate channel");
287 return -1;
288 }
289 return channelPtr->SetRTCPStatus(enable);
290}
291
292int VoERTP_RTCPImpl::GetRTCPStatus(int channel, bool& enabled)
293{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000294 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000295 "GetRTCPStatus(channel=%d)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000296 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000297 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000298 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000299 return -1;
300 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000301 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000302 voe::Channel* channelPtr = sc.ChannelPtr();
303 if (channelPtr == NULL)
304 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000305 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000306 "GetRTCPStatus() failed to locate channel");
307 return -1;
308 }
309 return channelPtr->GetRTCPStatus(enabled);
310}
311
312int VoERTP_RTCPImpl::SetRTCP_CNAME(int channel, const char cName[256])
313{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000314 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000315 "SetRTCP_CNAME(channel=%d, cName=%s)", channel, cName);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000316 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000317 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000318 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000319 return -1;
320 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000321 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000322 voe::Channel* channelPtr = sc.ChannelPtr();
323 if (channelPtr == NULL)
324 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000325 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000326 "SetRTCP_CNAME() failed to locate channel");
327 return -1;
328 }
329 return channelPtr->SetRTCP_CNAME(cName);
330}
331
332int VoERTP_RTCPImpl::GetRTCP_CNAME(int channel, char cName[256])
333{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000334 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000335 "GetRTCP_CNAME(channel=%d, cName=?)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000336 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000337 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000338 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000339 return -1;
340 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000341 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000342 voe::Channel* channelPtr = sc.ChannelPtr();
343 if (channelPtr == NULL)
344 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000345 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000346 "GetRTCP_CNAME() failed to locate channel");
347 return -1;
348 }
349 return channelPtr->GetRTCP_CNAME(cName);
350}
351
352int VoERTP_RTCPImpl::GetRemoteRTCP_CNAME(int channel, char cName[256])
353{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000354 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000355 "GetRemoteRTCP_CNAME(channel=%d, cName=?)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000356 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000357 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000358 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000359 return -1;
360 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000361 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000362 voe::Channel* channelPtr = sc.ChannelPtr();
363 if (channelPtr == NULL)
364 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000365 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000366 "GetRemoteRTCP_CNAME() failed to locate channel");
367 return -1;
368 }
369 return channelPtr->GetRemoteRTCP_CNAME(cName);
370}
371
372int VoERTP_RTCPImpl::GetRemoteRTCPData(
373 int channel,
374 unsigned int& NTPHigh, // from sender info in SR
375 unsigned int& NTPLow, // from sender info in SR
376 unsigned int& timestamp, // from sender info in SR
377 unsigned int& playoutTimestamp, // derived locally
378 unsigned int* jitter, // from report block 1 in SR/RR
379 unsigned short* fractionLost) // from report block 1 in SR/RR
380{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000381 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000382 "GetRemoteRTCPData(channel=%d,...)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000383 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000384 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000385 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000386 return -1;
387 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000388 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000389 voe::Channel* channelPtr = sc.ChannelPtr();
390 if (channelPtr == NULL)
391 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000392 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000393 "GetRemoteRTCP_CNAME() failed to locate channel");
394 return -1;
395 }
396 return channelPtr->GetRemoteRTCPData(NTPHigh,
397 NTPLow,
398 timestamp,
399 playoutTimestamp,
400 jitter,
401 fractionLost);
402}
403
404int VoERTP_RTCPImpl::SendApplicationDefinedRTCPPacket(
405 int channel,
pbos@webrtc.org92135212013-05-14 08:31:39 +0000406 unsigned char subType,
niklase@google.com470e71d2011-07-07 08:21:25 +0000407 unsigned int name,
408 const char* data,
409 unsigned short dataLengthInBytes)
410{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000411 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000412 "SendApplicationDefinedRTCPPacket(channel=%d, subType=%u,"
413 "name=%u, data=?, dataLengthInBytes=%u)",
414 channel, subType, name, dataLengthInBytes);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000415 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000416 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000417 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000418 return -1;
419 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000420 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000421 voe::Channel* channelPtr = sc.ChannelPtr();
422 if (channelPtr == NULL)
423 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000424 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000425 "SendApplicationDefinedRTCPPacket() failed to locate channel");
426 return -1;
427 }
428 return channelPtr->SendApplicationDefinedRTCPPacket(subType,
429 name,
430 data,
431 dataLengthInBytes);
432}
433
434int VoERTP_RTCPImpl::GetRTPStatistics(int channel,
435 unsigned int& averageJitterMs,
436 unsigned int& maxJitterMs,
437 unsigned int& discardedPackets)
438{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000439 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000440 "GetRTPStatistics(channel=%d,....)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000441 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000442 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000443 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000444 return -1;
445 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000446 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000447 voe::Channel* channelPtr = sc.ChannelPtr();
448 if (channelPtr == NULL)
449 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000450 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000451 "GetRTPStatistics() failed to locate channel");
452 return -1;
453 }
454 return channelPtr->GetRTPStatistics(averageJitterMs,
455 maxJitterMs,
456 discardedPackets);
457}
458
459int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats)
460{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000461 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000462 "GetRTCPStatistics(channel=%d)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000463 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000464 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000465 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000466 return -1;
467 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000468 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000469 voe::Channel* channelPtr = sc.ChannelPtr();
470 if (channelPtr == NULL)
471 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000472 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000473 "GetRTPStatistics() failed to locate channel");
474 return -1;
475 }
476 return channelPtr->GetRTPStatistics(stats);
477}
478
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +0000479int VoERTP_RTCPImpl::GetRemoteRTCPSenderInfo(int channel,
480 SenderInfo* sender_info) {
481 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
482 "GetRemoteRTCPSenderInfo(channel=%d)", channel);
483 if (!_shared->statistics().Initialized()) {
484 _shared->SetLastError(VE_NOT_INITED, kTraceError);
485 return -1;
486 }
487 voe::ScopedChannel sc(_shared->channel_manager(), channel);
488 voe::Channel* channel_ptr = sc.ChannelPtr();
489 if (channel_ptr == NULL) {
490 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
491 "GetRemoteRTCPSenderInfo() failed to locate channel");
492 return -1;
493 }
494 return channel_ptr->GetRemoteRTCPSenderInfo(sender_info);
495}
496
497int VoERTP_RTCPImpl::GetRemoteRTCPReportBlocks(
498 int channel, std::vector<ReportBlock>* report_blocks) {
499 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
500 "GetRemoteRTCPReportBlocks(channel=%d)", channel);
501 if (!_shared->statistics().Initialized()) {
502 _shared->SetLastError(VE_NOT_INITED, kTraceError);
503 return -1;
504 }
505 voe::ScopedChannel sc(_shared->channel_manager(), channel);
506 voe::Channel* channel_ptr = sc.ChannelPtr();
507 if (channel_ptr == NULL) {
508 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
509 "GetRemoteRTCPReportBlocks() failed to locate channel");
510 return -1;
511 }
512 return channel_ptr->GetRemoteRTCPReportBlocks(report_blocks);
513}
514
niklase@google.com470e71d2011-07-07 08:21:25 +0000515int VoERTP_RTCPImpl::SetFECStatus(int channel, bool enable, int redPayloadtype)
516{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000517 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000518 "SetFECStatus(channel=%d, enable=%d, redPayloadtype=%d)",
519 channel, enable, redPayloadtype);
520#ifdef WEBRTC_CODEC_RED
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000521 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000522 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000523 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000524 return -1;
525 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000526 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000527 voe::Channel* channelPtr = sc.ChannelPtr();
528 if (channelPtr == NULL)
529 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000530 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000531 "SetFECStatus() failed to locate channel");
532 return -1;
533 }
534 return channelPtr->SetFECStatus(enable, redPayloadtype);
535#else
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000536 _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
537 "SetFECStatus() RED is not supported");
niklase@google.com470e71d2011-07-07 08:21:25 +0000538 return -1;
539#endif
540}
541
542int VoERTP_RTCPImpl::GetFECStatus(int channel,
543 bool& enabled,
544 int& redPayloadtype)
545{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000546 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000547 "GetFECStatus(channel=%d, enabled=?, redPayloadtype=?)",
548 channel);
549#ifdef WEBRTC_CODEC_RED
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000550 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000551 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000552 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000553 return -1;
554 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000555 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000556 voe::Channel* channelPtr = sc.ChannelPtr();
557 if (channelPtr == NULL)
558 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000559 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000560 "GetFECStatus() failed to locate channel");
561 return -1;
562 }
563 return channelPtr->GetFECStatus(enabled, redPayloadtype);
564#else
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000565 _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
566 "GetFECStatus() RED is not supported");
niklase@google.com470e71d2011-07-07 08:21:25 +0000567 return -1;
568#endif
569}
570
niklas.enbom@webrtc.orgb35d2e32013-05-31 21:13:52 +0000571
572int VoERTP_RTCPImpl::SetNACKStatus(int channel,
573 bool enable,
574 int maxNoPackets)
575{
576 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
577 "SetNACKStatus(channel=%d, enable=%d, maxNoPackets=%d)",
578 channel, enable, maxNoPackets);
579 // Dummy for now
580 return 0;
581}
582
583
niklase@google.com470e71d2011-07-07 08:21:25 +0000584int VoERTP_RTCPImpl::StartRTPDump(int channel,
585 const char fileNameUTF8[1024],
586 RTPDirections direction)
587{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000588 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000589 "StartRTPDump(channel=%d, fileNameUTF8=%s, direction=%d)",
590 channel, fileNameUTF8, direction);
591 assert(1024 == FileWrapper::kMaxFileNameSize);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000592 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000593 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000594 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000595 return -1;
596 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000597 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000598 voe::Channel* channelPtr = sc.ChannelPtr();
599 if (channelPtr == NULL)
600 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000601 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000602 "StartRTPDump() failed to locate channel");
603 return -1;
604 }
605 return channelPtr->StartRTPDump(fileNameUTF8, direction);
606}
607
608int VoERTP_RTCPImpl::StopRTPDump(int channel, RTPDirections direction)
609{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000610 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000611 "StopRTPDump(channel=%d, direction=%d)", channel, direction);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000612 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000613 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000614 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000615 return -1;
616 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000617 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000618 voe::Channel* channelPtr = sc.ChannelPtr();
619 if (channelPtr == NULL)
620 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000621 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000622 "StopRTPDump() failed to locate channel");
623 return -1;
624 }
625 return channelPtr->StopRTPDump(direction);
626}
627
628int VoERTP_RTCPImpl::RTPDumpIsActive(int channel, RTPDirections direction)
629{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000630 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000631 "RTPDumpIsActive(channel=%d, direction=%d)",
632 channel, direction);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000633 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000634 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000635 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000636 return -1;
637 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000638 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000639 voe::Channel* channelPtr = sc.ChannelPtr();
640 if (channelPtr == NULL)
641 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000642 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000643 "StopRTPDump() failed to locate channel");
644 return -1;
645 }
646 return channelPtr->RTPDumpIsActive(direction);
647}
648
649int VoERTP_RTCPImpl::InsertExtraRTPPacket(int channel,
650 unsigned char payloadType,
651 bool markerBit,
652 const char* payloadData,
653 unsigned short payloadSize)
654{
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000655 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +0000656 "InsertExtraRTPPacket(channel=%d, payloadType=%u,"
657 " markerBit=%u, payloadSize=%u)",
658 channel, payloadType, markerBit, payloadSize);
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000659 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +0000660 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000661 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +0000662 return -1;
663 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000664 voe::ScopedChannel sc(_shared->channel_manager(), channel);
niklase@google.com470e71d2011-07-07 08:21:25 +0000665 voe::Channel* channelPtr = sc.ChannelPtr();
666 if (channelPtr == NULL)
667 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000668 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +0000669 "StopRTPDump() failed to locate channel");
670 return -1;
671 }
672 return channelPtr->InsertExtraRTPPacket(payloadType,
673 markerBit,
674 payloadData,
675 payloadSize);
676}
677
roosa@google.com0870f022012-12-12 21:31:41 +0000678int VoERTP_RTCPImpl::GetLastRemoteTimeStamp(int channel,
679 uint32_t* timestamp) {
680 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
681 "GetLastRemoteTimeStamp(channel=%d, timestamp=?)", channel);
682 if (!_shared->statistics().Initialized())
683 {
684 _shared->SetLastError(VE_NOT_INITED, kTraceError);
685 return -1;
686 }
687 voe::ScopedChannel sc(_shared->channel_manager(), channel);
688 voe::Channel* channelPtr = sc.ChannelPtr();
689 if (channelPtr == NULL)
690 {
691 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
692 "GetLastRemoteTimeStamp() failed to locate channel");
693 return -1;
694 }
695 *timestamp = channelPtr->LastRemoteTimeStamp();
696 return 0;
697}
698
niklase@google.com470e71d2011-07-07 08:21:25 +0000699#endif // #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
700
701} // namespace webrtc