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 | |
Henrik Kjellander | 98f5351 | 2015-10-28 18:17:40 +0100 | [diff] [blame] | 11 | #include "webrtc/system_wrappers/include/file_wrapper.h" |
| 12 | #include "webrtc/system_wrappers/include/trace.h" |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 13 | #include "webrtc/voice_engine/include/voe_errors.h" |
| 14 | #include "webrtc/voice_engine/voe_rtp_rtcp_impl.h" |
| 15 | #include "webrtc/voice_engine/voice_engine_impl.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 16 | |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 17 | #include "webrtc/voice_engine/channel.h" |
| 18 | #include "webrtc/voice_engine/transmit_mixer.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 22 | VoERTP_RTCP* VoERTP_RTCP::GetInterface(VoiceEngine* voiceEngine) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | #ifndef WEBRTC_VOICE_ENGINE_RTP_RTCP_API |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 24 | return NULL; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | #else |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 26 | if (NULL == voiceEngine) { |
| 27 | return NULL; |
| 28 | } |
| 29 | VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); |
| 30 | s->AddRef(); |
| 31 | return s; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | #endif |
| 33 | } |
| 34 | |
| 35 | #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API |
| 36 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 37 | VoERTP_RTCPImpl::VoERTP_RTCPImpl(voe::SharedData* shared) : _shared(shared) { |
| 38 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 39 | "VoERTP_RTCPImpl::VoERTP_RTCPImpl() - ctor"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 40 | } |
| 41 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 42 | VoERTP_RTCPImpl::~VoERTP_RTCPImpl() { |
| 43 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 44 | "VoERTP_RTCPImpl::~VoERTP_RTCPImpl() - dtor"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 47 | int VoERTP_RTCPImpl::SetLocalSSRC(int channel, unsigned int ssrc) { |
| 48 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 49 | "SetLocalSSRC(channel=%d, %lu)", channel, ssrc); |
| 50 | if (!_shared->statistics().Initialized()) { |
| 51 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 52 | return -1; |
| 53 | } |
| 54 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 55 | voe::Channel* channelPtr = ch.channel(); |
| 56 | if (channelPtr == NULL) { |
| 57 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 58 | "SetLocalSSRC() failed to locate channel"); |
| 59 | return -1; |
| 60 | } |
| 61 | return channelPtr->SetLocalSSRC(ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | } |
| 63 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 64 | int VoERTP_RTCPImpl::GetLocalSSRC(int channel, unsigned int& ssrc) { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 65 | if (!_shared->statistics().Initialized()) { |
| 66 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 67 | return -1; |
| 68 | } |
| 69 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 70 | voe::Channel* channelPtr = ch.channel(); |
| 71 | if (channelPtr == NULL) { |
| 72 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 73 | "GetLocalSSRC() failed to locate channel"); |
| 74 | return -1; |
| 75 | } |
| 76 | return channelPtr->GetLocalSSRC(ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 77 | } |
| 78 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 79 | int VoERTP_RTCPImpl::GetRemoteSSRC(int channel, unsigned int& ssrc) { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 80 | if (!_shared->statistics().Initialized()) { |
| 81 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 82 | return -1; |
| 83 | } |
| 84 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 85 | voe::Channel* channelPtr = ch.channel(); |
| 86 | if (channelPtr == NULL) { |
| 87 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 88 | "GetRemoteSSRC() failed to locate channel"); |
| 89 | return -1; |
| 90 | } |
| 91 | return channelPtr->GetRemoteSSRC(ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 92 | } |
| 93 | |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 94 | int VoERTP_RTCPImpl::SetSendAudioLevelIndicationStatus(int channel, |
| 95 | bool enable, |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 96 | unsigned char id) { |
| 97 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 98 | "SetSendAudioLevelIndicationStatus(channel=%d, enable=%d," |
| 99 | " ID=%u)", |
| 100 | channel, enable, id); |
| 101 | if (!_shared->statistics().Initialized()) { |
| 102 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 103 | return -1; |
| 104 | } |
| 105 | if (enable && (id < kVoiceEngineMinRtpExtensionId || |
| 106 | id > kVoiceEngineMaxRtpExtensionId)) { |
| 107 | // [RFC5285] The 4-bit id is the local identifier of this element in |
| 108 | // the range 1-14 inclusive. |
| 109 | _shared->SetLastError( |
| 110 | VE_INVALID_ARGUMENT, kTraceError, |
| 111 | "SetSendAudioLevelIndicationStatus() invalid ID parameter"); |
| 112 | return -1; |
| 113 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 114 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 115 | // Set state and id for the specified channel. |
| 116 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 117 | voe::Channel* channelPtr = ch.channel(); |
| 118 | if (channelPtr == NULL) { |
| 119 | _shared->SetLastError( |
| 120 | VE_CHANNEL_NOT_VALID, kTraceError, |
| 121 | "SetSendAudioLevelIndicationStatus() failed to locate channel"); |
| 122 | return -1; |
| 123 | } |
| 124 | return channelPtr->SetSendAudioLevelIndicationStatus(enable, id); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 125 | } |
| 126 | |
wu@webrtc.org | 93fd25c | 2014-04-24 20:33:08 +0000 | [diff] [blame] | 127 | int VoERTP_RTCPImpl::SetReceiveAudioLevelIndicationStatus(int channel, |
| 128 | bool enable, |
| 129 | unsigned char id) { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 130 | WEBRTC_TRACE( |
| 131 | kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
wu@webrtc.org | 93fd25c | 2014-04-24 20:33:08 +0000 | [diff] [blame] | 132 | "SetReceiveAudioLevelIndicationStatus(channel=%d, enable=%d, id=%u)", |
| 133 | channel, enable, id); |
| 134 | if (!_shared->statistics().Initialized()) { |
| 135 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 136 | return -1; |
| 137 | } |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 138 | if (enable && (id < kVoiceEngineMinRtpExtensionId || |
| 139 | id > kVoiceEngineMaxRtpExtensionId)) { |
wu@webrtc.org | 93fd25c | 2014-04-24 20:33:08 +0000 | [diff] [blame] | 140 | // [RFC5285] The 4-bit id is the local identifier of this element in |
| 141 | // the range 1-14 inclusive. |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 142 | _shared->SetLastError( |
| 143 | VE_INVALID_ARGUMENT, kTraceError, |
wu@webrtc.org | 93fd25c | 2014-04-24 20:33:08 +0000 | [diff] [blame] | 144 | "SetReceiveAbsoluteSenderTimeStatus() invalid id parameter"); |
| 145 | return -1; |
| 146 | } |
| 147 | // Set state and id for the specified channel. |
| 148 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 149 | voe::Channel* channel_ptr = ch.channel(); |
| 150 | if (channel_ptr == NULL) { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 151 | _shared->SetLastError( |
| 152 | VE_CHANNEL_NOT_VALID, kTraceError, |
wu@webrtc.org | 93fd25c | 2014-04-24 20:33:08 +0000 | [diff] [blame] | 153 | "SetReceiveAudioLevelIndicationStatus() failed to locate channel"); |
| 154 | return -1; |
| 155 | } |
| 156 | return channel_ptr->SetReceiveAudioLevelIndicationStatus(enable, id); |
| 157 | } |
| 158 | |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 159 | int VoERTP_RTCPImpl::SetSendAbsoluteSenderTimeStatus(int channel, |
| 160 | bool enable, |
| 161 | unsigned char id) { |
| 162 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 163 | "SetSendAbsoluteSenderTimeStatus(channel=%d, enable=%d, id=%u)", |
| 164 | channel, enable, id); |
| 165 | if (!_shared->statistics().Initialized()) { |
| 166 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 167 | return -1; |
| 168 | } |
| 169 | if (enable && (id < kVoiceEngineMinRtpExtensionId || |
| 170 | id > kVoiceEngineMaxRtpExtensionId)) { |
| 171 | // [RFC5285] The 4-bit id is the local identifier of this element in |
| 172 | // the range 1-14 inclusive. |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 173 | _shared->SetLastError( |
| 174 | VE_INVALID_ARGUMENT, kTraceError, |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 175 | "SetSendAbsoluteSenderTimeStatus() invalid id parameter"); |
| 176 | return -1; |
| 177 | } |
| 178 | // Set state and id for the specified channel. |
| 179 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 180 | voe::Channel* channelPtr = ch.channel(); |
| 181 | if (channelPtr == NULL) { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 182 | _shared->SetLastError( |
| 183 | VE_CHANNEL_NOT_VALID, kTraceError, |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 184 | "SetSendAbsoluteSenderTimeStatus() failed to locate channel"); |
| 185 | return -1; |
| 186 | } |
| 187 | return channelPtr->SetSendAbsoluteSenderTimeStatus(enable, id); |
| 188 | } |
| 189 | |
| 190 | int VoERTP_RTCPImpl::SetReceiveAbsoluteSenderTimeStatus(int channel, |
| 191 | bool enable, |
| 192 | unsigned char id) { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 193 | WEBRTC_TRACE( |
| 194 | kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 195 | "SetReceiveAbsoluteSenderTimeStatus(channel=%d, enable=%d, id=%u)", |
| 196 | channel, enable, id); |
| 197 | if (!_shared->statistics().Initialized()) { |
| 198 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 199 | return -1; |
| 200 | } |
| 201 | if (enable && (id < kVoiceEngineMinRtpExtensionId || |
| 202 | id > kVoiceEngineMaxRtpExtensionId)) { |
| 203 | // [RFC5285] The 4-bit id is the local identifier of this element in |
| 204 | // the range 1-14 inclusive. |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 205 | _shared->SetLastError( |
| 206 | VE_INVALID_ARGUMENT, kTraceError, |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 207 | "SetReceiveAbsoluteSenderTimeStatus() invalid id parameter"); |
| 208 | return -1; |
| 209 | } |
| 210 | // Set state and id for the specified channel. |
| 211 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 212 | voe::Channel* channelPtr = ch.channel(); |
| 213 | if (channelPtr == NULL) { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 214 | _shared->SetLastError( |
| 215 | VE_CHANNEL_NOT_VALID, kTraceError, |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 216 | "SetReceiveAbsoluteSenderTimeStatus() failed to locate channel"); |
| 217 | return -1; |
| 218 | } |
| 219 | return channelPtr->SetReceiveAbsoluteSenderTimeStatus(enable, id); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 220 | } |
| 221 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 222 | int VoERTP_RTCPImpl::SetRTCPStatus(int channel, bool enable) { |
| 223 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 224 | "SetRTCPStatus(channel=%d, enable=%d)", channel, enable); |
| 225 | if (!_shared->statistics().Initialized()) { |
| 226 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 227 | return -1; |
| 228 | } |
| 229 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 230 | voe::Channel* channelPtr = ch.channel(); |
| 231 | if (channelPtr == NULL) { |
| 232 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 233 | "SetRTCPStatus() failed to locate channel"); |
| 234 | return -1; |
| 235 | } |
| 236 | channelPtr->SetRTCPStatus(enable); |
| 237 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 238 | } |
| 239 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 240 | int VoERTP_RTCPImpl::GetRTCPStatus(int channel, bool& enabled) { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 241 | if (!_shared->statistics().Initialized()) { |
| 242 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 243 | return -1; |
| 244 | } |
| 245 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 246 | voe::Channel* channelPtr = ch.channel(); |
| 247 | if (channelPtr == NULL) { |
| 248 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 249 | "GetRTCPStatus() failed to locate channel"); |
| 250 | return -1; |
| 251 | } |
| 252 | return channelPtr->GetRTCPStatus(enabled); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 253 | } |
| 254 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 255 | int VoERTP_RTCPImpl::SetRTCP_CNAME(int channel, const char cName[256]) { |
| 256 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 257 | "SetRTCP_CNAME(channel=%d, cName=%s)", channel, cName); |
| 258 | if (!_shared->statistics().Initialized()) { |
| 259 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 260 | return -1; |
| 261 | } |
| 262 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 263 | voe::Channel* channelPtr = ch.channel(); |
| 264 | if (channelPtr == NULL) { |
| 265 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 266 | "SetRTCP_CNAME() failed to locate channel"); |
| 267 | return -1; |
| 268 | } |
| 269 | return channelPtr->SetRTCP_CNAME(cName); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 270 | } |
| 271 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 272 | int VoERTP_RTCPImpl::GetRemoteRTCP_CNAME(int channel, char cName[256]) { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 273 | if (!_shared->statistics().Initialized()) { |
| 274 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 275 | return -1; |
| 276 | } |
| 277 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 278 | voe::Channel* channelPtr = ch.channel(); |
| 279 | if (channelPtr == NULL) { |
| 280 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 281 | "GetRemoteRTCP_CNAME() failed to locate channel"); |
| 282 | return -1; |
| 283 | } |
| 284 | return channelPtr->GetRemoteRTCP_CNAME(cName); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | int VoERTP_RTCPImpl::GetRemoteRTCPData( |
| 288 | int channel, |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 289 | unsigned int& NTPHigh, // from sender info in SR |
| 290 | unsigned int& NTPLow, // from sender info in SR |
| 291 | unsigned int& timestamp, // from sender info in SR |
| 292 | unsigned int& playoutTimestamp, // derived locally |
| 293 | unsigned int* jitter, // from report block 1 in SR/RR |
| 294 | unsigned short* fractionLost) // from report block 1 in SR/RR |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 295 | { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 296 | if (!_shared->statistics().Initialized()) { |
| 297 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 298 | return -1; |
| 299 | } |
| 300 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 301 | voe::Channel* channelPtr = ch.channel(); |
| 302 | if (channelPtr == NULL) { |
| 303 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 304 | "GetRemoteRTCP_CNAME() failed to locate channel"); |
| 305 | return -1; |
| 306 | } |
| 307 | return channelPtr->GetRemoteRTCPData(NTPHigh, NTPLow, timestamp, |
| 308 | playoutTimestamp, jitter, fractionLost); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 309 | } |
| 310 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 311 | int VoERTP_RTCPImpl::GetRTPStatistics(int channel, |
| 312 | unsigned int& averageJitterMs, |
| 313 | unsigned int& maxJitterMs, |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 314 | unsigned int& discardedPackets) { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 315 | if (!_shared->statistics().Initialized()) { |
| 316 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 317 | return -1; |
| 318 | } |
| 319 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 320 | voe::Channel* channelPtr = ch.channel(); |
| 321 | if (channelPtr == NULL) { |
| 322 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 323 | "GetRTPStatistics() failed to locate channel"); |
| 324 | return -1; |
| 325 | } |
| 326 | return channelPtr->GetRTPStatistics(averageJitterMs, maxJitterMs, |
| 327 | discardedPackets); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 328 | } |
| 329 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 330 | int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats) { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 331 | if (!_shared->statistics().Initialized()) { |
| 332 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 333 | return -1; |
| 334 | } |
| 335 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 336 | voe::Channel* channelPtr = ch.channel(); |
| 337 | if (channelPtr == NULL) { |
| 338 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 339 | "GetRTPStatistics() failed to locate channel"); |
| 340 | return -1; |
| 341 | } |
| 342 | return channelPtr->GetRTPStatistics(stats); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 343 | } |
| 344 | |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 345 | int VoERTP_RTCPImpl::GetRemoteRTCPReportBlocks( |
| 346 | int channel, std::vector<ReportBlock>* report_blocks) { |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 347 | if (!_shared->statistics().Initialized()) { |
| 348 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 349 | return -1; |
| 350 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 351 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 352 | voe::Channel* channel_ptr = ch.channel(); |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 353 | if (channel_ptr == NULL) { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 354 | _shared->SetLastError( |
| 355 | VE_CHANNEL_NOT_VALID, kTraceError, |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 356 | "GetRemoteRTCPReportBlocks() failed to locate channel"); |
| 357 | return -1; |
| 358 | } |
| 359 | return channel_ptr->GetRemoteRTCPReportBlocks(report_blocks); |
| 360 | } |
| 361 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 362 | int VoERTP_RTCPImpl::SetREDStatus(int channel, |
| 363 | bool enable, |
| 364 | int redPayloadtype) { |
| 365 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 366 | "SetREDStatus(channel=%d, enable=%d, redPayloadtype=%d)", |
| 367 | channel, enable, redPayloadtype); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 368 | #ifdef WEBRTC_CODEC_RED |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 369 | if (!_shared->statistics().Initialized()) { |
| 370 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 371 | return -1; |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 372 | } |
| 373 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 374 | voe::Channel* channelPtr = ch.channel(); |
| 375 | if (channelPtr == NULL) { |
| 376 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 377 | "SetREDStatus() failed to locate channel"); |
| 378 | return -1; |
| 379 | } |
| 380 | return channelPtr->SetREDStatus(enable, redPayloadtype); |
| 381 | #else |
| 382 | _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, |
| 383 | "SetREDStatus() RED is not supported"); |
| 384 | return -1; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 385 | #endif |
| 386 | } |
| 387 | |
minyue@webrtc.org | c1a40a7 | 2014-05-28 09:52:06 +0000 | [diff] [blame] | 388 | int VoERTP_RTCPImpl::GetREDStatus(int channel, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 389 | bool& enabled, |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 390 | int& redPayloadtype) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 391 | #ifdef WEBRTC_CODEC_RED |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 392 | if (!_shared->statistics().Initialized()) { |
| 393 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 394 | return -1; |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 395 | } |
| 396 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 397 | voe::Channel* channelPtr = ch.channel(); |
| 398 | if (channelPtr == NULL) { |
| 399 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 400 | "GetREDStatus() failed to locate channel"); |
| 401 | return -1; |
| 402 | } |
| 403 | return channelPtr->GetREDStatus(enabled, redPayloadtype); |
| 404 | #else |
| 405 | _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, |
| 406 | "GetREDStatus() RED is not supported"); |
| 407 | return -1; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 408 | #endif |
| 409 | } |
| 410 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 411 | int VoERTP_RTCPImpl::SetNACKStatus(int channel, bool enable, int maxNoPackets) { |
| 412 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 413 | "SetNACKStatus(channel=%d, enable=%d, maxNoPackets=%d)", channel, |
| 414 | enable, maxNoPackets); |
pwestin@webrtc.org | db24995 | 2013-06-05 15:33:20 +0000 | [diff] [blame] | 415 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 416 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 417 | voe::Channel* channelPtr = ch.channel(); |
| 418 | if (channelPtr == NULL) { |
| 419 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 420 | "SetNACKStatus() failed to locate channel"); |
| 421 | return -1; |
| 422 | } |
| 423 | channelPtr->SetNACKStatus(enable, maxNoPackets); |
| 424 | return 0; |
niklas.enbom@webrtc.org | b35d2e3 | 2013-05-31 21:13:52 +0000 | [diff] [blame] | 425 | } |
| 426 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 427 | #endif // #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API |
| 428 | |
| 429 | } // namespace webrtc |