niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
leozwang@webrtc.org | 0975d21 | 2012-03-06 20:59:13 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 11 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
| 12 | #include "webrtc/system_wrappers/interface/file_wrapper.h" |
| 13 | #include "webrtc/system_wrappers/interface/trace.h" |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 +0000 | [diff] [blame] | 14 | #include "webrtc/video_engine/include/vie_network.h" |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 15 | #include "webrtc/voice_engine/include/voe_errors.h" |
| 16 | #include "webrtc/voice_engine/voe_rtp_rtcp_impl.h" |
| 17 | #include "webrtc/voice_engine/voice_engine_impl.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 18 | |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 19 | #include "webrtc/voice_engine/channel.h" |
| 20 | #include "webrtc/voice_engine/transmit_mixer.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | VoERTP_RTCP* VoERTP_RTCP::GetInterface(VoiceEngine* voiceEngine) |
| 25 | { |
| 26 | #ifndef WEBRTC_VOICE_ENGINE_RTP_RTCP_API |
| 27 | return NULL; |
| 28 | #else |
| 29 | if (NULL == voiceEngine) |
| 30 | { |
| 31 | return NULL; |
| 32 | } |
tommi@webrtc.org | 0989fb7 | 2013-02-15 15:07:32 +0000 | [diff] [blame] | 33 | VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); |
tommi@webrtc.org | a990e12 | 2012-04-26 15:28:22 +0000 | [diff] [blame] | 34 | s->AddRef(); |
| 35 | return s; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | #endif |
| 37 | } |
| 38 | |
| 39 | #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API |
| 40 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 41 | VoERTP_RTCPImpl::VoERTP_RTCPImpl(voe::SharedData* shared) : _shared(shared) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 43 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | "VoERTP_RTCPImpl::VoERTP_RTCPImpl() - ctor"); |
| 45 | } |
| 46 | |
| 47 | VoERTP_RTCPImpl::~VoERTP_RTCPImpl() |
| 48 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 49 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | "VoERTP_RTCPImpl::~VoERTP_RTCPImpl() - dtor"); |
| 51 | } |
| 52 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 53 | int VoERTP_RTCPImpl::RegisterRTPObserver(int channel, VoERTPObserver& observer) |
| 54 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 55 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | "RegisterRTPObserver(channel=%d observer=0x%x)", |
| 57 | channel, &observer); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 58 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 60 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | return -1; |
| 62 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 63 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 64 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 65 | if (channelPtr == NULL) |
| 66 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 67 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 68 | "RegisterRTPObserver() failed to locate channel"); |
| 69 | return -1; |
| 70 | } |
| 71 | return channelPtr->RegisterRTPObserver(observer); |
| 72 | } |
| 73 | |
| 74 | int VoERTP_RTCPImpl::DeRegisterRTPObserver(int channel) |
| 75 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 76 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 77 | "DeRegisterRTPObserver(channel=%d)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 78 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 79 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 80 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 81 | return -1; |
| 82 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 83 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 84 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 85 | if (channelPtr == NULL) |
| 86 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 87 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 88 | "DeRegisterRTPObserver() failed to locate channel"); |
| 89 | return -1; |
| 90 | } |
| 91 | return channelPtr->DeRegisterRTPObserver(); |
| 92 | } |
| 93 | |
| 94 | int VoERTP_RTCPImpl::RegisterRTCPObserver(int channel, VoERTCPObserver& observer) |
| 95 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 96 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | "RegisterRTCPObserver(channel=%d observer=0x%x)", |
| 98 | channel, &observer); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 99 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 100 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 101 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 102 | return -1; |
| 103 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 104 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 105 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 106 | if (channelPtr == NULL) |
| 107 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 108 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 109 | "RegisterRTPObserver() failed to locate channel"); |
| 110 | return -1; |
| 111 | } |
| 112 | return channelPtr->RegisterRTCPObserver(observer); |
| 113 | } |
| 114 | |
| 115 | int VoERTP_RTCPImpl::DeRegisterRTCPObserver(int channel) |
| 116 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 117 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 118 | "DeRegisterRTCPObserver(channel=%d)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 119 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 120 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 121 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 122 | return -1; |
| 123 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 124 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 125 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 126 | if (channelPtr == NULL) |
| 127 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 128 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 129 | "DeRegisterRTCPObserver() failed to locate channel"); |
| 130 | return -1; |
| 131 | } |
| 132 | return channelPtr->DeRegisterRTCPObserver(); |
| 133 | } |
| 134 | |
| 135 | int VoERTP_RTCPImpl::SetLocalSSRC(int channel, unsigned int ssrc) |
| 136 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 137 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 138 | "SetLocalSSRC(channel=%d, %lu)", channel, ssrc); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 139 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 140 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 141 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 142 | return -1; |
| 143 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 144 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 145 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 146 | if (channelPtr == NULL) |
| 147 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 148 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 149 | "SetLocalSSRC() failed to locate channel"); |
| 150 | return -1; |
| 151 | } |
| 152 | return channelPtr->SetLocalSSRC(ssrc); |
| 153 | } |
| 154 | |
| 155 | int VoERTP_RTCPImpl::GetLocalSSRC(int channel, unsigned int& ssrc) |
| 156 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 157 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 158 | "GetLocalSSRC(channel=%d, ssrc=?)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 159 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 160 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 161 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 162 | return -1; |
| 163 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 164 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 165 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 166 | if (channelPtr == NULL) |
| 167 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 168 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 169 | "GetLocalSSRC() failed to locate channel"); |
| 170 | return -1; |
| 171 | } |
| 172 | return channelPtr->GetLocalSSRC(ssrc); |
| 173 | } |
| 174 | |
| 175 | int VoERTP_RTCPImpl::GetRemoteSSRC(int channel, unsigned int& ssrc) |
| 176 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 177 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 178 | "GetRemoteSSRC(channel=%d, ssrc=?)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 179 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 180 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 181 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 182 | return -1; |
| 183 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 184 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 185 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 186 | if (channelPtr == NULL) |
| 187 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 188 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 189 | "GetRemoteSSRC() failed to locate channel"); |
| 190 | return -1; |
| 191 | } |
| 192 | return channelPtr->GetRemoteSSRC(ssrc); |
| 193 | } |
| 194 | |
| 195 | int VoERTP_RTCPImpl::GetRemoteCSRCs(int channel, unsigned int arrCSRC[15]) |
| 196 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 197 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 198 | "GetRemoteCSRCs(channel=%d, arrCSRC=?)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 199 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 200 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 201 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 202 | return -1; |
| 203 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 204 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 205 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 206 | if (channelPtr == NULL) |
| 207 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 208 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 209 | "GetRemoteCSRCs() failed to locate channel"); |
| 210 | return -1; |
| 211 | } |
| 212 | return channelPtr->GetRemoteCSRCs(arrCSRC); |
| 213 | } |
| 214 | |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 215 | int VoERTP_RTCPImpl::SetSendAudioLevelIndicationStatus(int channel, |
| 216 | bool enable, |
| 217 | unsigned char id) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 218 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 219 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 220 | "SetSendAudioLevelIndicationStatus(channel=%d, enable=%d," |
| 221 | " ID=%u)", channel, enable, id); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 222 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 223 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 224 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 225 | return -1; |
| 226 | } |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 227 | if (enable && (id < kVoiceEngineMinRtpExtensionId || |
| 228 | id > kVoiceEngineMaxRtpExtensionId)) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 229 | { |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 230 | // [RFC5285] The 4-bit id is the local identifier of this element in |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 231 | // the range 1-14 inclusive. |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 232 | _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 233 | "SetSendAudioLevelIndicationStatus() invalid ID parameter"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 234 | return -1; |
| 235 | } |
| 236 | |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 237 | // Set state and id for the specified channel. |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 238 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 239 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 240 | if (channelPtr == NULL) |
| 241 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 242 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 243 | "SetSendAudioLevelIndicationStatus() failed to locate channel"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 244 | return -1; |
| 245 | } |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 246 | return channelPtr->SetSendAudioLevelIndicationStatus(enable, id); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 247 | } |
| 248 | |
wu@webrtc.org | 93fd25c | 2014-04-24 20:33:08 +0000 | [diff] [blame^] | 249 | int 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.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 279 | int 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 | |
| 308 | int 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | int VoERTP_RTCPImpl::SetRTCPStatus(int channel, bool enable) |
| 338 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 339 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 340 | "SetRTCPStatus(channel=%d, enable=%d)", channel, enable); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 341 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 342 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 343 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 344 | return -1; |
| 345 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 346 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 347 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 348 | if (channelPtr == NULL) |
| 349 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 350 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 351 | "SetRTCPStatus() failed to locate channel"); |
| 352 | return -1; |
| 353 | } |
| 354 | return channelPtr->SetRTCPStatus(enable); |
| 355 | } |
| 356 | |
| 357 | int VoERTP_RTCPImpl::GetRTCPStatus(int channel, bool& enabled) |
| 358 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 359 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 360 | "GetRTCPStatus(channel=%d)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 361 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 362 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 363 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 364 | return -1; |
| 365 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 366 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 367 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 368 | if (channelPtr == NULL) |
| 369 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 370 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 371 | "GetRTCPStatus() failed to locate channel"); |
| 372 | return -1; |
| 373 | } |
| 374 | return channelPtr->GetRTCPStatus(enabled); |
| 375 | } |
| 376 | |
| 377 | int VoERTP_RTCPImpl::SetRTCP_CNAME(int channel, const char cName[256]) |
| 378 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 379 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 380 | "SetRTCP_CNAME(channel=%d, cName=%s)", channel, cName); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 381 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 382 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 383 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 384 | return -1; |
| 385 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 386 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 387 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 388 | if (channelPtr == NULL) |
| 389 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 390 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 391 | "SetRTCP_CNAME() failed to locate channel"); |
| 392 | return -1; |
| 393 | } |
| 394 | return channelPtr->SetRTCP_CNAME(cName); |
| 395 | } |
| 396 | |
| 397 | int VoERTP_RTCPImpl::GetRTCP_CNAME(int channel, char cName[256]) |
| 398 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 399 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 400 | "GetRTCP_CNAME(channel=%d, cName=?)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 401 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 402 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 403 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 404 | return -1; |
| 405 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 406 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 407 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 408 | if (channelPtr == NULL) |
| 409 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 410 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 411 | "GetRTCP_CNAME() failed to locate channel"); |
| 412 | return -1; |
| 413 | } |
| 414 | return channelPtr->GetRTCP_CNAME(cName); |
| 415 | } |
| 416 | |
| 417 | int VoERTP_RTCPImpl::GetRemoteRTCP_CNAME(int channel, char cName[256]) |
| 418 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 419 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 420 | "GetRemoteRTCP_CNAME(channel=%d, cName=?)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 421 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 422 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 423 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 424 | return -1; |
| 425 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 426 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 427 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 428 | if (channelPtr == NULL) |
| 429 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 430 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 431 | "GetRemoteRTCP_CNAME() failed to locate channel"); |
| 432 | return -1; |
| 433 | } |
| 434 | return channelPtr->GetRemoteRTCP_CNAME(cName); |
| 435 | } |
| 436 | |
| 437 | int 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.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 446 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 447 | "GetRemoteRTCPData(channel=%d,...)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 448 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 449 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 450 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 451 | return -1; |
| 452 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 453 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 454 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 455 | if (channelPtr == NULL) |
| 456 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 457 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 458 | "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 | |
| 469 | int VoERTP_RTCPImpl::SendApplicationDefinedRTCPPacket( |
| 470 | int channel, |
pbos@webrtc.org | 9213521 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 471 | unsigned char subType, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 472 | unsigned int name, |
| 473 | const char* data, |
| 474 | unsigned short dataLengthInBytes) |
| 475 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 476 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 477 | "SendApplicationDefinedRTCPPacket(channel=%d, subType=%u," |
| 478 | "name=%u, data=?, dataLengthInBytes=%u)", |
| 479 | channel, subType, name, dataLengthInBytes); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 480 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 481 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 482 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 483 | return -1; |
| 484 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 485 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 486 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 487 | if (channelPtr == NULL) |
| 488 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 489 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 490 | "SendApplicationDefinedRTCPPacket() failed to locate channel"); |
| 491 | return -1; |
| 492 | } |
| 493 | return channelPtr->SendApplicationDefinedRTCPPacket(subType, |
| 494 | name, |
| 495 | data, |
| 496 | dataLengthInBytes); |
| 497 | } |
| 498 | |
| 499 | int VoERTP_RTCPImpl::GetRTPStatistics(int channel, |
| 500 | unsigned int& averageJitterMs, |
| 501 | unsigned int& maxJitterMs, |
| 502 | unsigned int& discardedPackets) |
| 503 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 504 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 505 | "GetRTPStatistics(channel=%d,....)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 506 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 507 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 508 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 509 | return -1; |
| 510 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 511 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 512 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 513 | if (channelPtr == NULL) |
| 514 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 515 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 516 | "GetRTPStatistics() failed to locate channel"); |
| 517 | return -1; |
| 518 | } |
| 519 | return channelPtr->GetRTPStatistics(averageJitterMs, |
| 520 | maxJitterMs, |
| 521 | discardedPackets); |
| 522 | } |
| 523 | |
| 524 | int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats) |
| 525 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 526 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 527 | "GetRTCPStatistics(channel=%d)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 528 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 529 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 530 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 531 | return -1; |
| 532 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 533 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 534 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 535 | if (channelPtr == NULL) |
| 536 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 537 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 538 | "GetRTPStatistics() failed to locate channel"); |
| 539 | return -1; |
| 540 | } |
| 541 | return channelPtr->GetRTPStatistics(stats); |
| 542 | } |
| 543 | |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 544 | int VoERTP_RTCPImpl::GetRemoteRTCPSenderInfo(int channel, |
| 545 | SenderInfo* sender_info) { |
| 546 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 547 | "GetRemoteRTCPSenderInfo(channel=%d)", channel); |
| 548 | if (!_shared->statistics().Initialized()) { |
| 549 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 550 | return -1; |
| 551 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 552 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 553 | voe::Channel* channel_ptr = ch.channel(); |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 554 | 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 | |
| 562 | int VoERTP_RTCPImpl::GetRemoteRTCPReportBlocks( |
| 563 | int channel, std::vector<ReportBlock>* report_blocks) { |
| 564 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 565 | "GetRemoteRTCPReportBlocks(channel=%d)", channel); |
| 566 | if (!_shared->statistics().Initialized()) { |
| 567 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 568 | return -1; |
| 569 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 570 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 571 | voe::Channel* channel_ptr = ch.channel(); |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 572 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 580 | int VoERTP_RTCPImpl::SetFECStatus(int channel, bool enable, int redPayloadtype) |
| 581 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 582 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 583 | "SetFECStatus(channel=%d, enable=%d, redPayloadtype=%d)", |
| 584 | channel, enable, redPayloadtype); |
| 585 | #ifdef WEBRTC_CODEC_RED |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 586 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 587 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 588 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 589 | return -1; |
| 590 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 591 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 592 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 593 | if (channelPtr == NULL) |
| 594 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 595 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 596 | "SetFECStatus() failed to locate channel"); |
| 597 | return -1; |
| 598 | } |
| 599 | return channelPtr->SetFECStatus(enable, redPayloadtype); |
| 600 | #else |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 601 | _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, |
| 602 | "SetFECStatus() RED is not supported"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 603 | return -1; |
| 604 | #endif |
| 605 | } |
| 606 | |
| 607 | int VoERTP_RTCPImpl::GetFECStatus(int channel, |
| 608 | bool& enabled, |
| 609 | int& redPayloadtype) |
| 610 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 611 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 612 | "GetFECStatus(channel=%d, enabled=?, redPayloadtype=?)", |
| 613 | channel); |
| 614 | #ifdef WEBRTC_CODEC_RED |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 615 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 616 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 617 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 618 | return -1; |
| 619 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 620 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 621 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 622 | if (channelPtr == NULL) |
| 623 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 624 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 625 | "GetFECStatus() failed to locate channel"); |
| 626 | return -1; |
| 627 | } |
| 628 | return channelPtr->GetFECStatus(enabled, redPayloadtype); |
| 629 | #else |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 630 | _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, |
| 631 | "GetFECStatus() RED is not supported"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 632 | return -1; |
| 633 | #endif |
| 634 | } |
| 635 | |
niklas.enbom@webrtc.org | b35d2e3 | 2013-05-31 21:13:52 +0000 | [diff] [blame] | 636 | |
| 637 | int 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.org | db24995 | 2013-06-05 15:33:20 +0000 | [diff] [blame] | 644 | |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 645 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 646 | voe::Channel* channelPtr = ch.channel(); |
pwestin@webrtc.org | db24995 | 2013-06-05 15:33:20 +0000 | [diff] [blame] | 647 | 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.org | b35d2e3 | 2013-05-31 21:13:52 +0000 | [diff] [blame] | 654 | return 0; |
| 655 | } |
| 656 | |
| 657 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 658 | int VoERTP_RTCPImpl::StartRTPDump(int channel, |
| 659 | const char fileNameUTF8[1024], |
| 660 | RTPDirections direction) |
| 661 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 662 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 663 | "StartRTPDump(channel=%d, fileNameUTF8=%s, direction=%d)", |
| 664 | channel, fileNameUTF8, direction); |
| 665 | assert(1024 == FileWrapper::kMaxFileNameSize); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 666 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 667 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 668 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 669 | return -1; |
| 670 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 671 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 672 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 673 | if (channelPtr == NULL) |
| 674 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 675 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 676 | "StartRTPDump() failed to locate channel"); |
| 677 | return -1; |
| 678 | } |
| 679 | return channelPtr->StartRTPDump(fileNameUTF8, direction); |
| 680 | } |
| 681 | |
| 682 | int VoERTP_RTCPImpl::StopRTPDump(int channel, RTPDirections direction) |
| 683 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 684 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 685 | "StopRTPDump(channel=%d, direction=%d)", channel, direction); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 686 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 687 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 688 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 689 | return -1; |
| 690 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 691 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 692 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 693 | if (channelPtr == NULL) |
| 694 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 695 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 696 | "StopRTPDump() failed to locate channel"); |
| 697 | return -1; |
| 698 | } |
| 699 | return channelPtr->StopRTPDump(direction); |
| 700 | } |
| 701 | |
| 702 | int VoERTP_RTCPImpl::RTPDumpIsActive(int channel, RTPDirections direction) |
| 703 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 704 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 705 | "RTPDumpIsActive(channel=%d, direction=%d)", |
| 706 | channel, direction); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 707 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 708 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 709 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 710 | return -1; |
| 711 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 712 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 713 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 714 | if (channelPtr == NULL) |
| 715 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 716 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 717 | "StopRTPDump() failed to locate channel"); |
| 718 | return -1; |
| 719 | } |
| 720 | return channelPtr->RTPDumpIsActive(direction); |
| 721 | } |
| 722 | |
roosa@google.com | 0870f02 | 2012-12-12 21:31:41 +0000 | [diff] [blame] | 723 | int VoERTP_RTCPImpl::GetLastRemoteTimeStamp(int channel, |
| 724 | uint32_t* timestamp) { |
| 725 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 726 | "GetLastRemoteTimeStamp(channel=%d, timestamp=?)", channel); |
| 727 | if (!_shared->statistics().Initialized()) |
| 728 | { |
| 729 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 730 | return -1; |
| 731 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 732 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 733 | voe::Channel* channelPtr = ch.channel(); |
roosa@google.com | 0870f02 | 2012-12-12 21:31:41 +0000 | [diff] [blame] | 734 | 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.org | b1f5010 | 2014-03-24 10:38:25 +0000 | [diff] [blame] | 744 | int 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 765 | #endif // #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API |
| 766 | |
| 767 | } // namespace webrtc |