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 | |
| 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | VoENetEqStats* 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.org | b9e5a3d | 2013-02-15 15:07:32 +0000 | [diff] [blame] | 32 | VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 33 | s->AddRef(); |
| 34 | return s; |
| 35 | #endif |
| 36 | } |
| 37 | |
| 38 | #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API |
| 39 | |
| 40 | VoENetEqStatsImpl::VoENetEqStatsImpl(voe::SharedData* shared) : _shared(shared) |
| 41 | { |
| 42 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 43 | "VoENetEqStatsImpl::VoENetEqStatsImpl() - ctor"); |
| 44 | } |
| 45 | |
| 46 | VoENetEqStatsImpl::~VoENetEqStatsImpl() |
| 47 | { |
| 48 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 49 | "VoENetEqStatsImpl::~VoENetEqStatsImpl() - dtor"); |
| 50 | } |
| 51 | |
| 52 | int VoENetEqStatsImpl::GetNetworkStatistics(int channel, |
| 53 | NetworkStatistics& stats) |
| 54 | { |
| 55 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 56 | "GetNetworkStatistics(channel=%d, stats=?)", channel); |
| 57 | ANDROID_NOT_SUPPORTED(_shared->statistics()); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 58 | |
| 59 | if (!_shared->statistics().Initialized()) |
| 60 | { |
| 61 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 62 | return -1; |
| 63 | } |
| 64 | voe::ScopedChannel sc(_shared->channel_manager(), channel); |
| 65 | voe::Channel* channelPtr = sc.ChannelPtr(); |
| 66 | if (channelPtr == NULL) |
| 67 | { |
| 68 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 69 | "GetNetworkStatistics() failed to locate channel"); |
| 70 | return -1; |
| 71 | } |
| 72 | |
| 73 | return channelPtr->GetNetworkStatistics(stats); |
| 74 | } |
| 75 | |
| 76 | #endif // #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API |
| 77 | |
| 78 | } // namespace webrtc |