andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 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 | 471ae72 | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 11 | #include "webrtc/voice_engine/voe_neteq_stats_impl.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 12 | |
pbos@webrtc.org | 471ae72 | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 13 | #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" |
| 14 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
| 15 | #include "webrtc/system_wrappers/interface/trace.h" |
| 16 | #include "webrtc/voice_engine/channel.h" |
| 17 | #include "webrtc/voice_engine/include/voe_errors.h" |
| 18 | #include "webrtc/voice_engine/voice_engine_impl.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 19 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 20 | namespace webrtc { |
| 21 | |
| 22 | VoENetEqStats* VoENetEqStats::GetInterface(VoiceEngine* voiceEngine) |
| 23 | { |
| 24 | #ifndef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API |
| 25 | return NULL; |
| 26 | #else |
| 27 | if (NULL == voiceEngine) |
| 28 | { |
| 29 | return NULL; |
| 30 | } |
tommi@webrtc.org | b9e5a3d | 2013-02-15 15:07:32 +0000 | [diff] [blame] | 31 | VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 32 | s->AddRef(); |
| 33 | return s; |
| 34 | #endif |
| 35 | } |
| 36 | |
| 37 | #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API |
| 38 | |
| 39 | VoENetEqStatsImpl::VoENetEqStatsImpl(voe::SharedData* shared) : _shared(shared) |
| 40 | { |
| 41 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 42 | "VoENetEqStatsImpl::VoENetEqStatsImpl() - ctor"); |
| 43 | } |
| 44 | |
| 45 | VoENetEqStatsImpl::~VoENetEqStatsImpl() |
| 46 | { |
| 47 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 48 | "VoENetEqStatsImpl::~VoENetEqStatsImpl() - dtor"); |
| 49 | } |
| 50 | |
| 51 | int VoENetEqStatsImpl::GetNetworkStatistics(int channel, |
| 52 | NetworkStatistics& stats) |
| 53 | { |
| 54 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 55 | "GetNetworkStatistics(channel=%d, stats=?)", channel); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 56 | |
| 57 | if (!_shared->statistics().Initialized()) |
| 58 | { |
| 59 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 60 | return -1; |
| 61 | } |
pbos@webrtc.org | b3ada15 | 2013-08-07 17:57:36 +0000 | [diff] [blame] | 62 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 63 | voe::Channel* channelPtr = ch.channel(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 64 | if (channelPtr == NULL) |
| 65 | { |
| 66 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 67 | "GetNetworkStatistics() failed to locate channel"); |
| 68 | return -1; |
| 69 | } |
| 70 | |
| 71 | return channelPtr->GetNetworkStatistics(stats); |
| 72 | } |
| 73 | |
wu@webrtc.org | 79d6daf | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 74 | int VoENetEqStatsImpl::GetDecodingCallStatistics( |
| 75 | int channel, AudioDecodingCallStats* stats) const { |
wu@webrtc.org | 79d6daf | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 76 | |
| 77 | if (!_shared->statistics().Initialized()) { |
| 78 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 79 | return -1; |
| 80 | } |
| 81 | voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 82 | voe::Channel* channelPtr = ch.channel(); |
| 83 | if (channelPtr == NULL) { |
| 84 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 85 | "GetDecodingCallStatistics() failed to locate " |
| 86 | "channel"); |
| 87 | return -1; |
| 88 | } |
| 89 | |
| 90 | channelPtr->GetDecodingCallStatistics(stats); |
| 91 | return 0; |
| 92 | } |
| 93 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 94 | #endif // #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API |
| 95 | |
pbos@webrtc.org | 3b89e10 | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 96 | } // namespace webrtc |