niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +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/voice_engine/voe_neteq_stats_impl.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 13 | #include "webrtc/modules/audio_coding/include/audio_coding_module.h" |
Henrik Kjellander | 98f5351 | 2015-10-28 18:17:40 +0100 | [diff] [blame] | 14 | #include "webrtc/system_wrappers/include/trace.h" |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 15 | #include "webrtc/voice_engine/channel.h" |
| 16 | #include "webrtc/voice_engine/include/voe_errors.h" |
| 17 | #include "webrtc/voice_engine/voice_engine_impl.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 18 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | namespace webrtc { |
| 20 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 21 | VoENetEqStats* VoENetEqStats::GetInterface(VoiceEngine* voiceEngine) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | #ifndef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 23 | return NULL; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | #else |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 25 | if (NULL == voiceEngine) { |
| 26 | return NULL; |
| 27 | } |
| 28 | VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); |
| 29 | s->AddRef(); |
| 30 | return s; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | #endif |
| 32 | } |
| 33 | |
| 34 | #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API |
| 35 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 36 | VoENetEqStatsImpl::VoENetEqStatsImpl(voe::SharedData* shared) |
| 37 | : _shared(shared) { |
| 38 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 39 | "VoENetEqStatsImpl::VoENetEqStatsImpl() - ctor"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 40 | } |
| 41 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 42 | VoENetEqStatsImpl::~VoENetEqStatsImpl() { |
| 43 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 44 | "VoENetEqStatsImpl::~VoENetEqStatsImpl() - dtor"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | } |
| 46 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 47 | int VoENetEqStatsImpl::GetNetworkStatistics(int channel, |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 48 | NetworkStatistics& stats) { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 49 | if (!_shared->statistics().Initialized()) { |
| 50 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 51 | return -1; |
| 52 | } |
| 53 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 54 | voe::Channel* channelPtr = ch.channel(); |
| 55 | if (channelPtr == NULL) { |
| 56 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 57 | "GetNetworkStatistics() failed to locate channel"); |
| 58 | return -1; |
| 59 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 60 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 61 | return channelPtr->GetNetworkStatistics(stats); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | } |
| 63 | |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 64 | int VoENetEqStatsImpl::GetDecodingCallStatistics( |
| 65 | int channel, AudioDecodingCallStats* stats) const { |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 66 | if (!_shared->statistics().Initialized()) { |
| 67 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 68 | return -1; |
| 69 | } |
| 70 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 71 | voe::Channel* channelPtr = ch.channel(); |
| 72 | if (channelPtr == NULL) { |
| 73 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 74 | "GetDecodingCallStatistics() failed to locate " |
| 75 | "channel"); |
| 76 | return -1; |
| 77 | } |
| 78 | |
| 79 | channelPtr->GetDecodingCallStatistics(stats); |
| 80 | return 0; |
| 81 | } |
| 82 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 83 | #endif // #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API |
| 84 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 85 | } // namespace webrtc |