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 | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 249 | int VoERTP_RTCPImpl::SetSendAbsoluteSenderTimeStatus(int channel, |
| 250 | bool enable, |
| 251 | unsigned char id) { |
| 252 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 253 | "SetSendAbsoluteSenderTimeStatus(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 && (id < kVoiceEngineMinRtpExtensionId || |
| 260 | id > kVoiceEngineMaxRtpExtensionId)) { |
| 261 | // [RFC5285] The 4-bit id is the local identifier of this element in |
| 262 | // the range 1-14 inclusive. |
| 263 | _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
| 264 | "SetSendAbsoluteSenderTimeStatus() invalid id parameter"); |
| 265 | return -1; |
| 266 | } |
| 267 | // Set state and id for the specified channel. |
| 268 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 269 | voe::Channel* channelPtr = ch.channel(); |
| 270 | if (channelPtr == NULL) { |
| 271 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 272 | "SetSendAbsoluteSenderTimeStatus() failed to locate channel"); |
| 273 | return -1; |
| 274 | } |
| 275 | return channelPtr->SetSendAbsoluteSenderTimeStatus(enable, id); |
| 276 | } |
| 277 | |
| 278 | int VoERTP_RTCPImpl::SetReceiveAbsoluteSenderTimeStatus(int channel, |
| 279 | bool enable, |
| 280 | unsigned char id) { |
| 281 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 282 | "SetReceiveAbsoluteSenderTimeStatus(channel=%d, enable=%d, id=%u)", |
| 283 | channel, enable, id); |
| 284 | if (!_shared->statistics().Initialized()) { |
| 285 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 286 | return -1; |
| 287 | } |
| 288 | if (enable && (id < kVoiceEngineMinRtpExtensionId || |
| 289 | id > kVoiceEngineMaxRtpExtensionId)) { |
| 290 | // [RFC5285] The 4-bit id is the local identifier of this element in |
| 291 | // the range 1-14 inclusive. |
| 292 | _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
| 293 | "SetReceiveAbsoluteSenderTimeStatus() invalid id parameter"); |
| 294 | return -1; |
| 295 | } |
| 296 | // Set state and id for the specified channel. |
| 297 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 298 | voe::Channel* channelPtr = ch.channel(); |
| 299 | if (channelPtr == NULL) { |
| 300 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 301 | "SetReceiveAbsoluteSenderTimeStatus() failed to locate channel"); |
| 302 | return -1; |
| 303 | } |
| 304 | return channelPtr->SetReceiveAbsoluteSenderTimeStatus(enable, id); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | int VoERTP_RTCPImpl::SetRTCPStatus(int channel, bool enable) |
| 308 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 309 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 310 | "SetRTCPStatus(channel=%d, enable=%d)", channel, enable); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 311 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 312 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 313 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 314 | return -1; |
| 315 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 316 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 317 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 318 | if (channelPtr == NULL) |
| 319 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 320 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 321 | "SetRTCPStatus() failed to locate channel"); |
| 322 | return -1; |
| 323 | } |
| 324 | return channelPtr->SetRTCPStatus(enable); |
| 325 | } |
| 326 | |
| 327 | int VoERTP_RTCPImpl::GetRTCPStatus(int channel, bool& enabled) |
| 328 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 329 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 330 | "GetRTCPStatus(channel=%d)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 331 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 332 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 333 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 334 | return -1; |
| 335 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 336 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 337 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 338 | if (channelPtr == NULL) |
| 339 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 340 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 341 | "GetRTCPStatus() failed to locate channel"); |
| 342 | return -1; |
| 343 | } |
| 344 | return channelPtr->GetRTCPStatus(enabled); |
| 345 | } |
| 346 | |
| 347 | int VoERTP_RTCPImpl::SetRTCP_CNAME(int channel, const char cName[256]) |
| 348 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 349 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 350 | "SetRTCP_CNAME(channel=%d, cName=%s)", channel, cName); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 351 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 352 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 353 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 354 | return -1; |
| 355 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 356 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 357 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 358 | if (channelPtr == NULL) |
| 359 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 360 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 361 | "SetRTCP_CNAME() failed to locate channel"); |
| 362 | return -1; |
| 363 | } |
| 364 | return channelPtr->SetRTCP_CNAME(cName); |
| 365 | } |
| 366 | |
| 367 | int VoERTP_RTCPImpl::GetRTCP_CNAME(int channel, char cName[256]) |
| 368 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 369 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 370 | "GetRTCP_CNAME(channel=%d, cName=?)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 371 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 372 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 373 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 374 | return -1; |
| 375 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 376 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 377 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 378 | if (channelPtr == NULL) |
| 379 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 380 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 381 | "GetRTCP_CNAME() failed to locate channel"); |
| 382 | return -1; |
| 383 | } |
| 384 | return channelPtr->GetRTCP_CNAME(cName); |
| 385 | } |
| 386 | |
| 387 | int VoERTP_RTCPImpl::GetRemoteRTCP_CNAME(int channel, char cName[256]) |
| 388 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 389 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 390 | "GetRemoteRTCP_CNAME(channel=%d, cName=?)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 391 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 392 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 393 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 394 | return -1; |
| 395 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 396 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 397 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 398 | if (channelPtr == NULL) |
| 399 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 400 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 401 | "GetRemoteRTCP_CNAME() failed to locate channel"); |
| 402 | return -1; |
| 403 | } |
| 404 | return channelPtr->GetRemoteRTCP_CNAME(cName); |
| 405 | } |
| 406 | |
| 407 | int VoERTP_RTCPImpl::GetRemoteRTCPData( |
| 408 | int channel, |
| 409 | unsigned int& NTPHigh, // from sender info in SR |
| 410 | unsigned int& NTPLow, // from sender info in SR |
| 411 | unsigned int& timestamp, // from sender info in SR |
| 412 | unsigned int& playoutTimestamp, // derived locally |
| 413 | unsigned int* jitter, // from report block 1 in SR/RR |
| 414 | unsigned short* fractionLost) // from report block 1 in SR/RR |
| 415 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 416 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 417 | "GetRemoteRTCPData(channel=%d,...)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 418 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 419 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 420 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 421 | return -1; |
| 422 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 423 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 424 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 425 | if (channelPtr == NULL) |
| 426 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 427 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 428 | "GetRemoteRTCP_CNAME() failed to locate channel"); |
| 429 | return -1; |
| 430 | } |
| 431 | return channelPtr->GetRemoteRTCPData(NTPHigh, |
| 432 | NTPLow, |
| 433 | timestamp, |
| 434 | playoutTimestamp, |
| 435 | jitter, |
| 436 | fractionLost); |
| 437 | } |
| 438 | |
| 439 | int VoERTP_RTCPImpl::SendApplicationDefinedRTCPPacket( |
| 440 | int channel, |
pbos@webrtc.org | 9213521 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 441 | unsigned char subType, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 442 | unsigned int name, |
| 443 | const char* data, |
| 444 | unsigned short dataLengthInBytes) |
| 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 | "SendApplicationDefinedRTCPPacket(channel=%d, subType=%u," |
| 448 | "name=%u, data=?, dataLengthInBytes=%u)", |
| 449 | channel, subType, name, dataLengthInBytes); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 450 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 451 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 452 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 453 | return -1; |
| 454 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 455 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 456 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 457 | if (channelPtr == NULL) |
| 458 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 459 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 460 | "SendApplicationDefinedRTCPPacket() failed to locate channel"); |
| 461 | return -1; |
| 462 | } |
| 463 | return channelPtr->SendApplicationDefinedRTCPPacket(subType, |
| 464 | name, |
| 465 | data, |
| 466 | dataLengthInBytes); |
| 467 | } |
| 468 | |
| 469 | int VoERTP_RTCPImpl::GetRTPStatistics(int channel, |
| 470 | unsigned int& averageJitterMs, |
| 471 | unsigned int& maxJitterMs, |
| 472 | unsigned int& discardedPackets) |
| 473 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 474 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 475 | "GetRTPStatistics(channel=%d,....)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 476 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 477 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 478 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 479 | return -1; |
| 480 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 481 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 482 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 483 | if (channelPtr == NULL) |
| 484 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 485 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 486 | "GetRTPStatistics() failed to locate channel"); |
| 487 | return -1; |
| 488 | } |
| 489 | return channelPtr->GetRTPStatistics(averageJitterMs, |
| 490 | maxJitterMs, |
| 491 | discardedPackets); |
| 492 | } |
| 493 | |
| 494 | int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats) |
| 495 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 496 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 497 | "GetRTCPStatistics(channel=%d)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 498 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 499 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 500 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 501 | return -1; |
| 502 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 503 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 504 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 505 | if (channelPtr == NULL) |
| 506 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 507 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 508 | "GetRTPStatistics() failed to locate channel"); |
| 509 | return -1; |
| 510 | } |
| 511 | return channelPtr->GetRTPStatistics(stats); |
| 512 | } |
| 513 | |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 514 | int VoERTP_RTCPImpl::GetRemoteRTCPSenderInfo(int channel, |
| 515 | SenderInfo* sender_info) { |
| 516 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 517 | "GetRemoteRTCPSenderInfo(channel=%d)", channel); |
| 518 | if (!_shared->statistics().Initialized()) { |
| 519 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 520 | return -1; |
| 521 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 522 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 523 | voe::Channel* channel_ptr = ch.channel(); |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 524 | if (channel_ptr == NULL) { |
| 525 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 526 | "GetRemoteRTCPSenderInfo() failed to locate channel"); |
| 527 | return -1; |
| 528 | } |
| 529 | return channel_ptr->GetRemoteRTCPSenderInfo(sender_info); |
| 530 | } |
| 531 | |
| 532 | int VoERTP_RTCPImpl::GetRemoteRTCPReportBlocks( |
| 533 | int channel, std::vector<ReportBlock>* report_blocks) { |
| 534 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 535 | "GetRemoteRTCPReportBlocks(channel=%d)", channel); |
| 536 | if (!_shared->statistics().Initialized()) { |
| 537 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 538 | return -1; |
| 539 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 540 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 541 | voe::Channel* channel_ptr = ch.channel(); |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 542 | if (channel_ptr == NULL) { |
| 543 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 544 | "GetRemoteRTCPReportBlocks() failed to locate channel"); |
| 545 | return -1; |
| 546 | } |
| 547 | return channel_ptr->GetRemoteRTCPReportBlocks(report_blocks); |
| 548 | } |
| 549 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 550 | int VoERTP_RTCPImpl::SetFECStatus(int channel, bool enable, int redPayloadtype) |
| 551 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 552 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 553 | "SetFECStatus(channel=%d, enable=%d, redPayloadtype=%d)", |
| 554 | channel, enable, redPayloadtype); |
| 555 | #ifdef WEBRTC_CODEC_RED |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 556 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 557 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 558 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 559 | return -1; |
| 560 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 561 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 562 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 563 | if (channelPtr == NULL) |
| 564 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 565 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 566 | "SetFECStatus() failed to locate channel"); |
| 567 | return -1; |
| 568 | } |
| 569 | return channelPtr->SetFECStatus(enable, redPayloadtype); |
| 570 | #else |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 571 | _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, |
| 572 | "SetFECStatus() RED is not supported"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 573 | return -1; |
| 574 | #endif |
| 575 | } |
| 576 | |
| 577 | int VoERTP_RTCPImpl::GetFECStatus(int channel, |
| 578 | bool& enabled, |
| 579 | int& redPayloadtype) |
| 580 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 581 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 582 | "GetFECStatus(channel=%d, enabled=?, redPayloadtype=?)", |
| 583 | channel); |
| 584 | #ifdef WEBRTC_CODEC_RED |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 585 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 586 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 587 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 588 | return -1; |
| 589 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 590 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 591 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 592 | if (channelPtr == NULL) |
| 593 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 594 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 595 | "GetFECStatus() failed to locate channel"); |
| 596 | return -1; |
| 597 | } |
| 598 | return channelPtr->GetFECStatus(enabled, redPayloadtype); |
| 599 | #else |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 600 | _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, |
| 601 | "GetFECStatus() RED is not supported"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 602 | return -1; |
| 603 | #endif |
| 604 | } |
| 605 | |
niklas.enbom@webrtc.org | b35d2e3 | 2013-05-31 21:13:52 +0000 | [diff] [blame] | 606 | |
| 607 | int VoERTP_RTCPImpl::SetNACKStatus(int channel, |
| 608 | bool enable, |
| 609 | int maxNoPackets) |
| 610 | { |
| 611 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 612 | "SetNACKStatus(channel=%d, enable=%d, maxNoPackets=%d)", |
| 613 | channel, enable, maxNoPackets); |
pwestin@webrtc.org | db24995 | 2013-06-05 15:33:20 +0000 | [diff] [blame] | 614 | |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 615 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 616 | voe::Channel* channelPtr = ch.channel(); |
pwestin@webrtc.org | db24995 | 2013-06-05 15:33:20 +0000 | [diff] [blame] | 617 | if (channelPtr == NULL) |
| 618 | { |
| 619 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 620 | "SetNACKStatus() failed to locate channel"); |
| 621 | return -1; |
| 622 | } |
| 623 | channelPtr->SetNACKStatus(enable, maxNoPackets); |
niklas.enbom@webrtc.org | b35d2e3 | 2013-05-31 21:13:52 +0000 | [diff] [blame] | 624 | return 0; |
| 625 | } |
| 626 | |
| 627 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 628 | int VoERTP_RTCPImpl::StartRTPDump(int channel, |
| 629 | const char fileNameUTF8[1024], |
| 630 | RTPDirections direction) |
| 631 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 632 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 633 | "StartRTPDump(channel=%d, fileNameUTF8=%s, direction=%d)", |
| 634 | channel, fileNameUTF8, direction); |
| 635 | assert(1024 == FileWrapper::kMaxFileNameSize); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 636 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 637 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 638 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 639 | return -1; |
| 640 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 641 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 642 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 643 | if (channelPtr == NULL) |
| 644 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 645 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 646 | "StartRTPDump() failed to locate channel"); |
| 647 | return -1; |
| 648 | } |
| 649 | return channelPtr->StartRTPDump(fileNameUTF8, direction); |
| 650 | } |
| 651 | |
| 652 | int VoERTP_RTCPImpl::StopRTPDump(int channel, RTPDirections direction) |
| 653 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 654 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 655 | "StopRTPDump(channel=%d, direction=%d)", channel, direction); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 656 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 657 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 658 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 659 | return -1; |
| 660 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 661 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 662 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 663 | if (channelPtr == NULL) |
| 664 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 665 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 666 | "StopRTPDump() failed to locate channel"); |
| 667 | return -1; |
| 668 | } |
| 669 | return channelPtr->StopRTPDump(direction); |
| 670 | } |
| 671 | |
| 672 | int VoERTP_RTCPImpl::RTPDumpIsActive(int channel, RTPDirections direction) |
| 673 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 674 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 675 | "RTPDumpIsActive(channel=%d, direction=%d)", |
| 676 | channel, direction); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 677 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 678 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 679 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 680 | return -1; |
| 681 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 682 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 683 | voe::Channel* channelPtr = ch.channel(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 684 | if (channelPtr == NULL) |
| 685 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 686 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 687 | "StopRTPDump() failed to locate channel"); |
| 688 | return -1; |
| 689 | } |
| 690 | return channelPtr->RTPDumpIsActive(direction); |
| 691 | } |
| 692 | |
roosa@google.com | 0870f02 | 2012-12-12 21:31:41 +0000 | [diff] [blame] | 693 | int VoERTP_RTCPImpl::GetLastRemoteTimeStamp(int channel, |
| 694 | uint32_t* timestamp) { |
| 695 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 696 | "GetLastRemoteTimeStamp(channel=%d, timestamp=?)", channel); |
| 697 | if (!_shared->statistics().Initialized()) |
| 698 | { |
| 699 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 700 | return -1; |
| 701 | } |
pbos@webrtc.org | 676ff1e | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 702 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 703 | voe::Channel* channelPtr = ch.channel(); |
roosa@google.com | 0870f02 | 2012-12-12 21:31:41 +0000 | [diff] [blame] | 704 | if (channelPtr == NULL) |
| 705 | { |
| 706 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 707 | "GetLastRemoteTimeStamp() failed to locate channel"); |
| 708 | return -1; |
| 709 | } |
| 710 | *timestamp = channelPtr->LastRemoteTimeStamp(); |
| 711 | return 0; |
| 712 | } |
| 713 | |
solenberg@webrtc.org | b1f5010 | 2014-03-24 10:38:25 +0000 | [diff] [blame] | 714 | int VoERTP_RTCPImpl::SetVideoEngineBWETarget(int channel, |
| 715 | ViENetwork* vie_network, |
| 716 | int video_channel) { |
| 717 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 718 | "SetVideoEngineBWETarget(channel=%d, vie_network=?, video_channel=%d)", |
| 719 | channel, vie_network, video_channel); |
| 720 | |
| 721 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 722 | voe::Channel* channelPtr = ch.channel(); |
| 723 | if (channelPtr == NULL) { |
| 724 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 725 | "SetVideoEngineBWETarget() failed to locate channel"); |
| 726 | if (vie_network) { |
| 727 | vie_network->Release(); |
| 728 | } |
| 729 | return -1; |
| 730 | } |
| 731 | channelPtr->SetVideoEngineBWETarget(vie_network, video_channel); |
| 732 | return 0; |
| 733 | } |
| 734 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 735 | #endif // #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API |
| 736 | |
| 737 | } // namespace webrtc |