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" |
| 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 17 | |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 18 | #include "webrtc/voice_engine/channel.h" |
| 19 | #include "webrtc/voice_engine/transmit_mixer.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | VoERTP_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.org | 0989fb7 | 2013-02-15 15:07:32 +0000 | [diff] [blame] | 32 | VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); |
tommi@webrtc.org | a990e12 | 2012-04-26 15:28:22 +0000 | [diff] [blame] | 33 | s->AddRef(); |
| 34 | return s; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | #endif |
| 36 | } |
| 37 | |
| 38 | #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API |
| 39 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 40 | VoERTP_RTCPImpl::VoERTP_RTCPImpl(voe::SharedData* shared) : _shared(shared) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 42 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | "VoERTP_RTCPImpl::VoERTP_RTCPImpl() - ctor"); |
| 44 | } |
| 45 | |
| 46 | VoERTP_RTCPImpl::~VoERTP_RTCPImpl() |
| 47 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 48 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 49 | "VoERTP_RTCPImpl::~VoERTP_RTCPImpl() - dtor"); |
| 50 | } |
| 51 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | int VoERTP_RTCPImpl::RegisterRTPObserver(int channel, VoERTPObserver& observer) |
| 53 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 54 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | "RegisterRTPObserver(channel=%d observer=0x%x)", |
| 56 | channel, &observer); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 57 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 59 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 60 | return -1; |
| 61 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 62 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 63 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 64 | if (channelPtr == NULL) |
| 65 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 66 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 67 | "RegisterRTPObserver() failed to locate channel"); |
| 68 | return -1; |
| 69 | } |
| 70 | return channelPtr->RegisterRTPObserver(observer); |
| 71 | } |
| 72 | |
| 73 | int VoERTP_RTCPImpl::DeRegisterRTPObserver(int channel) |
| 74 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 75 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 76 | "DeRegisterRTPObserver(channel=%d)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 77 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 78 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 79 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 80 | return -1; |
| 81 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 82 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 83 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 84 | if (channelPtr == NULL) |
| 85 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 86 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 87 | "DeRegisterRTPObserver() failed to locate channel"); |
| 88 | return -1; |
| 89 | } |
| 90 | return channelPtr->DeRegisterRTPObserver(); |
| 91 | } |
| 92 | |
| 93 | int VoERTP_RTCPImpl::RegisterRTCPObserver(int channel, VoERTCPObserver& observer) |
| 94 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 95 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 96 | "RegisterRTCPObserver(channel=%d observer=0x%x)", |
| 97 | channel, &observer); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 98 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 99 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 100 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | return -1; |
| 102 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 103 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 104 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 105 | if (channelPtr == NULL) |
| 106 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 107 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 108 | "RegisterRTPObserver() failed to locate channel"); |
| 109 | return -1; |
| 110 | } |
| 111 | return channelPtr->RegisterRTCPObserver(observer); |
| 112 | } |
| 113 | |
| 114 | int VoERTP_RTCPImpl::DeRegisterRTCPObserver(int channel) |
| 115 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 116 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 117 | "DeRegisterRTCPObserver(channel=%d)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 118 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 120 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 121 | return -1; |
| 122 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 123 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 124 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 125 | if (channelPtr == NULL) |
| 126 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 127 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 128 | "DeRegisterRTCPObserver() failed to locate channel"); |
| 129 | return -1; |
| 130 | } |
| 131 | return channelPtr->DeRegisterRTCPObserver(); |
| 132 | } |
| 133 | |
| 134 | int VoERTP_RTCPImpl::SetLocalSSRC(int channel, unsigned int ssrc) |
| 135 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 136 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 137 | "SetLocalSSRC(channel=%d, %lu)", channel, ssrc); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 138 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 139 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 140 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 141 | return -1; |
| 142 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 143 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 144 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 145 | if (channelPtr == NULL) |
| 146 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 147 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 148 | "SetLocalSSRC() failed to locate channel"); |
| 149 | return -1; |
| 150 | } |
| 151 | return channelPtr->SetLocalSSRC(ssrc); |
| 152 | } |
| 153 | |
| 154 | int VoERTP_RTCPImpl::GetLocalSSRC(int channel, unsigned int& ssrc) |
| 155 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 156 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 157 | "GetLocalSSRC(channel=%d, ssrc=?)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 158 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 159 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 160 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 161 | return -1; |
| 162 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 163 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 164 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 165 | if (channelPtr == NULL) |
| 166 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 167 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 168 | "GetLocalSSRC() failed to locate channel"); |
| 169 | return -1; |
| 170 | } |
| 171 | return channelPtr->GetLocalSSRC(ssrc); |
| 172 | } |
| 173 | |
| 174 | int VoERTP_RTCPImpl::GetRemoteSSRC(int channel, unsigned int& ssrc) |
| 175 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 176 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 177 | "GetRemoteSSRC(channel=%d, ssrc=?)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 178 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 179 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 180 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 181 | return -1; |
| 182 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 183 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 184 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 185 | if (channelPtr == NULL) |
| 186 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 187 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 188 | "GetRemoteSSRC() failed to locate channel"); |
| 189 | return -1; |
| 190 | } |
| 191 | return channelPtr->GetRemoteSSRC(ssrc); |
| 192 | } |
| 193 | |
| 194 | int VoERTP_RTCPImpl::GetRemoteCSRCs(int channel, unsigned int arrCSRC[15]) |
| 195 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 196 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 197 | "GetRemoteCSRCs(channel=%d, arrCSRC=?)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 198 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 199 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 200 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 201 | return -1; |
| 202 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 203 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 204 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 205 | if (channelPtr == NULL) |
| 206 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 207 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 208 | "GetRemoteCSRCs() failed to locate channel"); |
| 209 | return -1; |
| 210 | } |
| 211 | return channelPtr->GetRemoteCSRCs(arrCSRC); |
| 212 | } |
| 213 | |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame^] | 214 | int VoERTP_RTCPImpl::SetSendAudioLevelIndicationStatus(int channel, |
| 215 | bool enable, |
| 216 | unsigned char id) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 217 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 218 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame^] | 219 | "SetSendAudioLevelIndicationStatus(channel=%d, enable=%d," |
| 220 | " ID=%u)", channel, enable, id); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 221 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 222 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 223 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 224 | return -1; |
| 225 | } |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame^] | 226 | if (enable && (id < kVoiceEngineMinRtpExtensionId || |
| 227 | id > kVoiceEngineMaxRtpExtensionId)) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 228 | { |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame^] | 229 | // [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] | 230 | // the range 1-14 inclusive. |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 231 | _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame^] | 232 | "SetSendAudioLevelIndicationStatus() invalid ID parameter"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 233 | return -1; |
| 234 | } |
| 235 | |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame^] | 236 | // Set state and id for the specified channel. |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 237 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 238 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 239 | if (channelPtr == NULL) |
| 240 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 241 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame^] | 242 | "SetSendAudioLevelIndicationStatus() failed to locate channel"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 243 | return -1; |
| 244 | } |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame^] | 245 | return channelPtr->SetSendAudioLevelIndicationStatus(enable, id); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 246 | } |
| 247 | |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame^] | 248 | int VoERTP_RTCPImpl::SetSendAbsoluteSenderTimeStatus(int channel, |
| 249 | bool enable, |
| 250 | unsigned char id) { |
| 251 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 252 | "SetSendAbsoluteSenderTimeStatus(channel=%d, enable=%d, id=%u)", |
| 253 | channel, enable, id); |
| 254 | if (!_shared->statistics().Initialized()) { |
| 255 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 256 | return -1; |
| 257 | } |
| 258 | if (enable && (id < kVoiceEngineMinRtpExtensionId || |
| 259 | id > kVoiceEngineMaxRtpExtensionId)) { |
| 260 | // [RFC5285] The 4-bit id is the local identifier of this element in |
| 261 | // the range 1-14 inclusive. |
| 262 | _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
| 263 | "SetSendAbsoluteSenderTimeStatus() invalid id parameter"); |
| 264 | return -1; |
| 265 | } |
| 266 | // Set state and id for the specified channel. |
| 267 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 268 | voe::Channel* channelPtr = ch.channel(); |
| 269 | if (channelPtr == NULL) { |
| 270 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 271 | "SetSendAbsoluteSenderTimeStatus() failed to locate channel"); |
| 272 | return -1; |
| 273 | } |
| 274 | return channelPtr->SetSendAbsoluteSenderTimeStatus(enable, id); |
| 275 | } |
| 276 | |
| 277 | int VoERTP_RTCPImpl::SetReceiveAbsoluteSenderTimeStatus(int channel, |
| 278 | bool enable, |
| 279 | unsigned char id) { |
| 280 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 281 | "SetReceiveAbsoluteSenderTimeStatus(channel=%d, enable=%d, id=%u)", |
| 282 | channel, enable, id); |
| 283 | if (!_shared->statistics().Initialized()) { |
| 284 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 285 | return -1; |
| 286 | } |
| 287 | if (enable && (id < kVoiceEngineMinRtpExtensionId || |
| 288 | id > kVoiceEngineMaxRtpExtensionId)) { |
| 289 | // [RFC5285] The 4-bit id is the local identifier of this element in |
| 290 | // the range 1-14 inclusive. |
| 291 | _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
| 292 | "SetReceiveAbsoluteSenderTimeStatus() invalid id parameter"); |
| 293 | return -1; |
| 294 | } |
| 295 | // Set state and id for the specified channel. |
| 296 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 297 | voe::Channel* channelPtr = ch.channel(); |
| 298 | if (channelPtr == NULL) { |
| 299 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 300 | "SetReceiveAbsoluteSenderTimeStatus() failed to locate channel"); |
| 301 | return -1; |
| 302 | } |
| 303 | return channelPtr->SetReceiveAbsoluteSenderTimeStatus(enable, id); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | int VoERTP_RTCPImpl::SetRTCPStatus(int channel, bool enable) |
| 307 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 308 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 309 | "SetRTCPStatus(channel=%d, enable=%d)", channel, enable); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 310 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 311 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 312 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 313 | return -1; |
| 314 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 315 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 316 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 317 | if (channelPtr == NULL) |
| 318 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 319 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 320 | "SetRTCPStatus() failed to locate channel"); |
| 321 | return -1; |
| 322 | } |
| 323 | return channelPtr->SetRTCPStatus(enable); |
| 324 | } |
| 325 | |
| 326 | int VoERTP_RTCPImpl::GetRTCPStatus(int channel, bool& enabled) |
| 327 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 328 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 329 | "GetRTCPStatus(channel=%d)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 330 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 331 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 332 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 333 | return -1; |
| 334 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 335 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 336 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 337 | if (channelPtr == NULL) |
| 338 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 339 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 340 | "GetRTCPStatus() failed to locate channel"); |
| 341 | return -1; |
| 342 | } |
| 343 | return channelPtr->GetRTCPStatus(enabled); |
| 344 | } |
| 345 | |
| 346 | int VoERTP_RTCPImpl::SetRTCP_CNAME(int channel, const char cName[256]) |
| 347 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 348 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 349 | "SetRTCP_CNAME(channel=%d, cName=%s)", channel, cName); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 350 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 351 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 352 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 353 | return -1; |
| 354 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 355 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 356 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 357 | if (channelPtr == NULL) |
| 358 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 359 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 360 | "SetRTCP_CNAME() failed to locate channel"); |
| 361 | return -1; |
| 362 | } |
| 363 | return channelPtr->SetRTCP_CNAME(cName); |
| 364 | } |
| 365 | |
| 366 | int VoERTP_RTCPImpl::GetRTCP_CNAME(int channel, char cName[256]) |
| 367 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 368 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 369 | "GetRTCP_CNAME(channel=%d, cName=?)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 370 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 371 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 372 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 373 | return -1; |
| 374 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 375 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 376 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 377 | if (channelPtr == NULL) |
| 378 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 379 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 380 | "GetRTCP_CNAME() failed to locate channel"); |
| 381 | return -1; |
| 382 | } |
| 383 | return channelPtr->GetRTCP_CNAME(cName); |
| 384 | } |
| 385 | |
| 386 | int VoERTP_RTCPImpl::GetRemoteRTCP_CNAME(int channel, char cName[256]) |
| 387 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 388 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 389 | "GetRemoteRTCP_CNAME(channel=%d, cName=?)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 390 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 391 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 392 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 393 | return -1; |
| 394 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 395 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 396 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 397 | if (channelPtr == NULL) |
| 398 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 399 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 400 | "GetRemoteRTCP_CNAME() failed to locate channel"); |
| 401 | return -1; |
| 402 | } |
| 403 | return channelPtr->GetRemoteRTCP_CNAME(cName); |
| 404 | } |
| 405 | |
| 406 | int VoERTP_RTCPImpl::GetRemoteRTCPData( |
| 407 | int channel, |
| 408 | unsigned int& NTPHigh, // from sender info in SR |
| 409 | unsigned int& NTPLow, // from sender info in SR |
| 410 | unsigned int& timestamp, // from sender info in SR |
| 411 | unsigned int& playoutTimestamp, // derived locally |
| 412 | unsigned int* jitter, // from report block 1 in SR/RR |
| 413 | unsigned short* fractionLost) // from report block 1 in SR/RR |
| 414 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 415 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 416 | "GetRemoteRTCPData(channel=%d,...)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 417 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 418 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 419 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 420 | return -1; |
| 421 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 422 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 423 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 424 | if (channelPtr == NULL) |
| 425 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 426 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 427 | "GetRemoteRTCP_CNAME() failed to locate channel"); |
| 428 | return -1; |
| 429 | } |
| 430 | return channelPtr->GetRemoteRTCPData(NTPHigh, |
| 431 | NTPLow, |
| 432 | timestamp, |
| 433 | playoutTimestamp, |
| 434 | jitter, |
| 435 | fractionLost); |
| 436 | } |
| 437 | |
| 438 | int VoERTP_RTCPImpl::SendApplicationDefinedRTCPPacket( |
| 439 | int channel, |
pbos@webrtc.org | 9213521 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 440 | unsigned char subType, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 441 | unsigned int name, |
| 442 | const char* data, |
| 443 | unsigned short dataLengthInBytes) |
| 444 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 445 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 446 | "SendApplicationDefinedRTCPPacket(channel=%d, subType=%u," |
| 447 | "name=%u, data=?, dataLengthInBytes=%u)", |
| 448 | channel, subType, name, dataLengthInBytes); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 449 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 450 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 451 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 452 | return -1; |
| 453 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 454 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 455 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 456 | if (channelPtr == NULL) |
| 457 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 458 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 459 | "SendApplicationDefinedRTCPPacket() failed to locate channel"); |
| 460 | return -1; |
| 461 | } |
| 462 | return channelPtr->SendApplicationDefinedRTCPPacket(subType, |
| 463 | name, |
| 464 | data, |
| 465 | dataLengthInBytes); |
| 466 | } |
| 467 | |
| 468 | int VoERTP_RTCPImpl::GetRTPStatistics(int channel, |
| 469 | unsigned int& averageJitterMs, |
| 470 | unsigned int& maxJitterMs, |
| 471 | unsigned int& discardedPackets) |
| 472 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 473 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 474 | "GetRTPStatistics(channel=%d,....)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 475 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 476 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 477 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 478 | return -1; |
| 479 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 480 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 481 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 482 | if (channelPtr == NULL) |
| 483 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 484 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 485 | "GetRTPStatistics() failed to locate channel"); |
| 486 | return -1; |
| 487 | } |
| 488 | return channelPtr->GetRTPStatistics(averageJitterMs, |
| 489 | maxJitterMs, |
| 490 | discardedPackets); |
| 491 | } |
| 492 | |
| 493 | int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats) |
| 494 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 495 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 496 | "GetRTCPStatistics(channel=%d)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 497 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 498 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 499 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 500 | return -1; |
| 501 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 502 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 503 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 504 | if (channelPtr == NULL) |
| 505 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 506 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 507 | "GetRTPStatistics() failed to locate channel"); |
| 508 | return -1; |
| 509 | } |
| 510 | return channelPtr->GetRTPStatistics(stats); |
| 511 | } |
| 512 | |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 513 | int VoERTP_RTCPImpl::GetRemoteRTCPSenderInfo(int channel, |
| 514 | SenderInfo* sender_info) { |
| 515 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 516 | "GetRemoteRTCPSenderInfo(channel=%d)", channel); |
| 517 | if (!_shared->statistics().Initialized()) { |
| 518 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 519 | return -1; |
| 520 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 521 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 522 | voe::Channel* channel_ptr = ch.channel(); |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 523 | if (channel_ptr == NULL) { |
| 524 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 525 | "GetRemoteRTCPSenderInfo() failed to locate channel"); |
| 526 | return -1; |
| 527 | } |
| 528 | return channel_ptr->GetRemoteRTCPSenderInfo(sender_info); |
| 529 | } |
| 530 | |
| 531 | int VoERTP_RTCPImpl::GetRemoteRTCPReportBlocks( |
| 532 | int channel, std::vector<ReportBlock>* report_blocks) { |
| 533 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 534 | "GetRemoteRTCPReportBlocks(channel=%d)", channel); |
| 535 | if (!_shared->statistics().Initialized()) { |
| 536 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 537 | return -1; |
| 538 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 539 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 540 | voe::Channel* channel_ptr = ch.channel(); |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 541 | if (channel_ptr == NULL) { |
| 542 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 543 | "GetRemoteRTCPReportBlocks() failed to locate channel"); |
| 544 | return -1; |
| 545 | } |
| 546 | return channel_ptr->GetRemoteRTCPReportBlocks(report_blocks); |
| 547 | } |
| 548 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 549 | int VoERTP_RTCPImpl::SetFECStatus(int channel, bool enable, int redPayloadtype) |
| 550 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 551 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 552 | "SetFECStatus(channel=%d, enable=%d, redPayloadtype=%d)", |
| 553 | channel, enable, redPayloadtype); |
| 554 | #ifdef WEBRTC_CODEC_RED |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 555 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 556 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 557 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 558 | return -1; |
| 559 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 560 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 561 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 562 | if (channelPtr == NULL) |
| 563 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 564 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 565 | "SetFECStatus() failed to locate channel"); |
| 566 | return -1; |
| 567 | } |
| 568 | return channelPtr->SetFECStatus(enable, redPayloadtype); |
| 569 | #else |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 570 | _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, |
| 571 | "SetFECStatus() RED is not supported"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 572 | return -1; |
| 573 | #endif |
| 574 | } |
| 575 | |
| 576 | int VoERTP_RTCPImpl::GetFECStatus(int channel, |
| 577 | bool& enabled, |
| 578 | int& redPayloadtype) |
| 579 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 580 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 581 | "GetFECStatus(channel=%d, enabled=?, redPayloadtype=?)", |
| 582 | channel); |
| 583 | #ifdef WEBRTC_CODEC_RED |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 584 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 585 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 586 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 587 | return -1; |
| 588 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 589 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 590 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 591 | if (channelPtr == NULL) |
| 592 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 593 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 594 | "GetFECStatus() failed to locate channel"); |
| 595 | return -1; |
| 596 | } |
| 597 | return channelPtr->GetFECStatus(enabled, redPayloadtype); |
| 598 | #else |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 599 | _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, |
| 600 | "GetFECStatus() RED is not supported"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 601 | return -1; |
| 602 | #endif |
| 603 | } |
| 604 | |
niklas.enbom@webrtc.org | b35d2e3 | 2013-05-31 21:13:52 +0000 | [diff] [blame] | 605 | |
| 606 | int VoERTP_RTCPImpl::SetNACKStatus(int channel, |
| 607 | bool enable, |
| 608 | int maxNoPackets) |
| 609 | { |
| 610 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 611 | "SetNACKStatus(channel=%d, enable=%d, maxNoPackets=%d)", |
| 612 | channel, enable, maxNoPackets); |
pwestin@webrtc.org | db24995 | 2013-06-05 15:33:20 +0000 | [diff] [blame] | 613 | |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 614 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 615 | voe::Channel* channelPtr = ch.channel(); |
pwestin@webrtc.org | db24995 | 2013-06-05 15:33:20 +0000 | [diff] [blame] | 616 | if (channelPtr == NULL) |
| 617 | { |
| 618 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 619 | "SetNACKStatus() failed to locate channel"); |
| 620 | return -1; |
| 621 | } |
| 622 | channelPtr->SetNACKStatus(enable, maxNoPackets); |
niklas.enbom@webrtc.org | b35d2e3 | 2013-05-31 21:13:52 +0000 | [diff] [blame] | 623 | return 0; |
| 624 | } |
| 625 | |
| 626 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 627 | int VoERTP_RTCPImpl::StartRTPDump(int channel, |
| 628 | const char fileNameUTF8[1024], |
| 629 | RTPDirections direction) |
| 630 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 631 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 632 | "StartRTPDump(channel=%d, fileNameUTF8=%s, direction=%d)", |
| 633 | channel, fileNameUTF8, direction); |
| 634 | assert(1024 == FileWrapper::kMaxFileNameSize); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 635 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 636 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 637 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 638 | return -1; |
| 639 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 640 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 641 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 642 | if (channelPtr == NULL) |
| 643 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 644 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 645 | "StartRTPDump() failed to locate channel"); |
| 646 | return -1; |
| 647 | } |
| 648 | return channelPtr->StartRTPDump(fileNameUTF8, direction); |
| 649 | } |
| 650 | |
| 651 | int VoERTP_RTCPImpl::StopRTPDump(int channel, RTPDirections direction) |
| 652 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 653 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 654 | "StopRTPDump(channel=%d, direction=%d)", channel, direction); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 655 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 656 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 657 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 658 | return -1; |
| 659 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 660 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 661 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 662 | if (channelPtr == NULL) |
| 663 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 664 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 665 | "StopRTPDump() failed to locate channel"); |
| 666 | return -1; |
| 667 | } |
| 668 | return channelPtr->StopRTPDump(direction); |
| 669 | } |
| 670 | |
| 671 | int VoERTP_RTCPImpl::RTPDumpIsActive(int channel, RTPDirections direction) |
| 672 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 673 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 674 | "RTPDumpIsActive(channel=%d, direction=%d)", |
| 675 | channel, direction); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 676 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 677 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 678 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 679 | return -1; |
| 680 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 681 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 682 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 683 | if (channelPtr == NULL) |
| 684 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 685 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 686 | "StopRTPDump() failed to locate channel"); |
| 687 | return -1; |
| 688 | } |
| 689 | return channelPtr->RTPDumpIsActive(direction); |
| 690 | } |
| 691 | |
roosa@google.com | 0870f02 | 2012-12-12 21:31:41 +0000 | [diff] [blame] | 692 | int VoERTP_RTCPImpl::GetLastRemoteTimeStamp(int channel, |
| 693 | uint32_t* timestamp) { |
| 694 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 695 | "GetLastRemoteTimeStamp(channel=%d, timestamp=?)", channel); |
| 696 | if (!_shared->statistics().Initialized()) |
| 697 | { |
| 698 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 699 | return -1; |
| 700 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 701 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 702 | voe::Channel* channelPtr = ch.channel(); |
roosa@google.com | 0870f02 | 2012-12-12 21:31:41 +0000 | [diff] [blame] | 703 | if (channelPtr == NULL) |
| 704 | { |
| 705 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 706 | "GetLastRemoteTimeStamp() failed to locate channel"); |
| 707 | return -1; |
| 708 | } |
| 709 | *timestamp = channelPtr->LastRemoteTimeStamp(); |
| 710 | return 0; |
| 711 | } |
| 712 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 713 | #endif // #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API |
| 714 | |
| 715 | } // namespace webrtc |