Line data Source code
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 :
11 : #include "webrtc/voice_engine/voe_neteq_stats_impl.h"
12 :
13 : #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
14 : #include "webrtc/system_wrappers/include/trace.h"
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"
18 :
19 : namespace webrtc {
20 :
21 0 : VoENetEqStats* VoENetEqStats::GetInterface(VoiceEngine* voiceEngine) {
22 0 : if (NULL == voiceEngine) {
23 0 : return NULL;
24 : }
25 0 : VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
26 0 : s->AddRef();
27 0 : return s;
28 : }
29 :
30 0 : VoENetEqStatsImpl::VoENetEqStatsImpl(voe::SharedData* shared)
31 0 : : _shared(shared) {
32 : WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
33 : "VoENetEqStatsImpl::VoENetEqStatsImpl() - ctor");
34 0 : }
35 :
36 0 : VoENetEqStatsImpl::~VoENetEqStatsImpl() {
37 : WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
38 : "VoENetEqStatsImpl::~VoENetEqStatsImpl() - dtor");
39 0 : }
40 :
41 0 : int VoENetEqStatsImpl::GetNetworkStatistics(int channel,
42 : NetworkStatistics& stats) {
43 0 : if (!_shared->statistics().Initialized()) {
44 0 : _shared->SetLastError(VE_NOT_INITED, kTraceError);
45 0 : return -1;
46 : }
47 0 : voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
48 0 : voe::Channel* channelPtr = ch.channel();
49 0 : if (channelPtr == NULL) {
50 0 : _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
51 0 : "GetNetworkStatistics() failed to locate channel");
52 0 : return -1;
53 : }
54 :
55 0 : return channelPtr->GetNetworkStatistics(stats);
56 : }
57 :
58 0 : int VoENetEqStatsImpl::GetDecodingCallStatistics(
59 : int channel, AudioDecodingCallStats* stats) const {
60 0 : if (!_shared->statistics().Initialized()) {
61 0 : _shared->SetLastError(VE_NOT_INITED, kTraceError);
62 0 : return -1;
63 : }
64 0 : voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
65 0 : voe::Channel* channelPtr = ch.channel();
66 0 : if (channelPtr == NULL) {
67 0 : _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
68 : "GetDecodingCallStatistics() failed to locate "
69 0 : "channel");
70 0 : return -1;
71 : }
72 :
73 0 : channelPtr->GetDecodingCallStatistics(stats);
74 0 : return 0;
75 : }
76 :
77 : } // namespace webrtc
|