blob: 6b2b37c57ceb64f382dd9adf81b0efaf855fb491 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
tommi@webrtc.org851becd2012-04-04 14:57:19 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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.org956aa7e2013-05-21 13:52:32 +000011#include "webrtc/voice_engine/voe_neteq_stats_impl.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000012
kjellander3e6db232015-11-26 04:44:54 -080013#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
Henrik Kjellander98f53512015-10-28 18:17:40 +010014#include "webrtc/system_wrappers/include/trace.h"
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000015#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.com470e71d2011-07-07 08:21:25 +000018
niklase@google.com470e71d2011-07-07 08:21:25 +000019namespace webrtc {
20
Jelena Marusic0d266052015-05-04 14:15:32 +020021VoENetEqStats* VoENetEqStats::GetInterface(VoiceEngine* voiceEngine) {
niklase@google.com470e71d2011-07-07 08:21:25 +000022#ifndef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
Jelena Marusic0d266052015-05-04 14:15:32 +020023 return NULL;
niklase@google.com470e71d2011-07-07 08:21:25 +000024#else
Jelena Marusic0d266052015-05-04 14:15:32 +020025 if (NULL == voiceEngine) {
26 return NULL;
27 }
28 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
29 s->AddRef();
30 return s;
niklase@google.com470e71d2011-07-07 08:21:25 +000031#endif
32}
33
34#ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
35
Jelena Marusic0d266052015-05-04 14:15:32 +020036VoENetEqStatsImpl::VoENetEqStatsImpl(voe::SharedData* shared)
37 : _shared(shared) {
38 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
39 "VoENetEqStatsImpl::VoENetEqStatsImpl() - ctor");
niklase@google.com470e71d2011-07-07 08:21:25 +000040}
41
Jelena Marusic0d266052015-05-04 14:15:32 +020042VoENetEqStatsImpl::~VoENetEqStatsImpl() {
43 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
44 "VoENetEqStatsImpl::~VoENetEqStatsImpl() - dtor");
niklase@google.com470e71d2011-07-07 08:21:25 +000045}
46
niklase@google.com470e71d2011-07-07 08:21:25 +000047int VoENetEqStatsImpl::GetNetworkStatistics(int channel,
Jelena Marusic0d266052015-05-04 14:15:32 +020048 NetworkStatistics& stats) {
Jelena Marusic0d266052015-05-04 14:15:32 +020049 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.com470e71d2011-07-07 08:21:25 +000060
Jelena Marusic0d266052015-05-04 14:15:32 +020061 return channelPtr->GetNetworkStatistics(stats);
niklase@google.com470e71d2011-07-07 08:21:25 +000062}
63
wu@webrtc.org24301a62013-12-13 19:17:43 +000064int VoENetEqStatsImpl::GetDecodingCallStatistics(
65 int channel, AudioDecodingCallStats* stats) const {
wu@webrtc.org24301a62013-12-13 19:17:43 +000066 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.com470e71d2011-07-07 08:21:25 +000083#endif // #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
84
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000085} // namespace webrtc