blob: ef4984668f85b3443fe30c61af61aeb18d1c7db7 [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
11#include "voe_neteq_stats_impl.h"
12
13#include "audio_coding_module.h"
14#include "channel.h"
15#include "critical_section_wrapper.h"
16#include "trace.h"
17#include "voe_errors.h"
18#include "voice_engine_impl.h"
19
20
21namespace webrtc {
22
23VoENetEqStats* VoENetEqStats::GetInterface(VoiceEngine* voiceEngine)
24{
25#ifndef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
26 return NULL;
27#else
28 if (NULL == voiceEngine)
29 {
30 return NULL;
31 }
tommi@webrtc.org0989fb72013-02-15 15:07:32 +000032 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
tommi@webrtc.orga990e122012-04-26 15:28:22 +000033 s->AddRef();
34 return s;
niklase@google.com470e71d2011-07-07 08:21:25 +000035#endif
36}
37
38#ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
39
tommi@webrtc.org851becd2012-04-04 14:57:19 +000040VoENetEqStatsImpl::VoENetEqStatsImpl(voe::SharedData* shared) : _shared(shared)
niklase@google.com470e71d2011-07-07 08:21:25 +000041{
tommi@webrtc.org851becd2012-04-04 14:57:19 +000042 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +000043 "VoENetEqStatsImpl::VoENetEqStatsImpl() - ctor");
44}
45
46VoENetEqStatsImpl::~VoENetEqStatsImpl()
47{
tommi@webrtc.org851becd2012-04-04 14:57:19 +000048 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +000049 "VoENetEqStatsImpl::~VoENetEqStatsImpl() - dtor");
50}
51
niklase@google.com470e71d2011-07-07 08:21:25 +000052int VoENetEqStatsImpl::GetNetworkStatistics(int channel,
53 NetworkStatistics& stats)
54{
tommi@webrtc.org851becd2012-04-04 14:57:19 +000055 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
niklase@google.com470e71d2011-07-07 08:21:25 +000056 "GetNetworkStatistics(channel=%d, stats=?)", channel);
tommi@webrtc.org851becd2012-04-04 14:57:19 +000057 ANDROID_NOT_SUPPORTED(_shared->statistics());
leozwang@webrtc.org26385772012-01-20 18:45:45 +000058
tommi@webrtc.org851becd2012-04-04 14:57:19 +000059 if (!_shared->statistics().Initialized())
niklase@google.com470e71d2011-07-07 08:21:25 +000060 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +000061 _shared->SetLastError(VE_NOT_INITED, kTraceError);
niklase@google.com470e71d2011-07-07 08:21:25 +000062 return -1;
63 }
tommi@webrtc.org851becd2012-04-04 14:57:19 +000064 voe::ScopedChannel sc(_shared->channel_manager(), channel);
65 voe::Channel* channelPtr = sc.ChannelPtr();
niklase@google.com470e71d2011-07-07 08:21:25 +000066 if (channelPtr == NULL)
67 {
tommi@webrtc.org851becd2012-04-04 14:57:19 +000068 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
niklase@google.com470e71d2011-07-07 08:21:25 +000069 "GetNetworkStatistics() failed to locate channel");
70 return -1;
71 }
72
73 return channelPtr->GetNetworkStatistics(stats);
74}
75
niklase@google.com470e71d2011-07-07 08:21:25 +000076#endif // #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
77
78} // namespace webrtc