LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/voice_engine - voice_engine_impl.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 0 43 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

          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             : #if defined(WEBRTC_ANDROID)
      12             : #include "webrtc/modules/audio_device/android/audio_device_template.h"
      13             : #include "webrtc/modules/audio_device/android/audio_record_jni.h"
      14             : #include "webrtc/modules/audio_device/android/audio_track_jni.h"
      15             : #include "webrtc/modules/utility/include/jvm_android.h"
      16             : #endif
      17             : 
      18             : #include "webrtc/base/checks.h"
      19             : #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
      20             : #include "webrtc/system_wrappers/include/trace.h"
      21             : #include "webrtc/voice_engine/channel_proxy.h"
      22             : #include "webrtc/voice_engine/voice_engine_impl.h"
      23             : 
      24             : namespace webrtc {
      25             : 
      26             : // Counter to be ensure that we can add a correct ID in all static trace
      27             : // methods. It is not the nicest solution, especially not since we already
      28             : // have a counter in VoEBaseImpl. In other words, there is room for
      29             : // improvement here.
      30             : static int32_t gVoiceEngineInstanceCounter = 0;
      31             : 
      32           0 : VoiceEngine* GetVoiceEngine() {
      33           0 :   VoiceEngineImpl* self = new VoiceEngineImpl();
      34           0 :   if (self != NULL) {
      35           0 :     self->AddRef();  // First reference.  Released in VoiceEngine::Delete.
      36           0 :     gVoiceEngineInstanceCounter++;
      37             :   }
      38           0 :   return self;
      39             : }
      40             : 
      41           0 : int VoiceEngineImpl::AddRef() {
      42           0 :   return ++_ref_count;
      43             : }
      44             : 
      45             : // This implements the Release() method for all the inherited interfaces.
      46           0 : int VoiceEngineImpl::Release() {
      47           0 :   int new_ref = --_ref_count;
      48           0 :   assert(new_ref >= 0);
      49           0 :   if (new_ref == 0) {
      50             :     WEBRTC_TRACE(kTraceApiCall, kTraceVoice, -1,
      51             :                  "VoiceEngineImpl self deleting (voiceEngine=0x%p)", this);
      52             : 
      53             :     // Clear any pointers before starting destruction. Otherwise worker-
      54             :     // threads will still have pointers to a partially destructed object.
      55             :     // Example: AudioDeviceBuffer::RequestPlayoutData() can access a
      56             :     // partially deconstructed |_ptrCbAudioTransport| during destruction
      57             :     // if we don't call Terminate here.
      58           0 :     Terminate();
      59           0 :     delete this;
      60             :   }
      61             : 
      62           0 :   return new_ref;
      63             : }
      64             : 
      65           0 : std::unique_ptr<voe::ChannelProxy> VoiceEngineImpl::GetChannelProxy(
      66             :     int channel_id) {
      67           0 :   RTC_DCHECK(channel_id >= 0);
      68           0 :   rtc::CritScope cs(crit_sec());
      69           0 :   RTC_DCHECK(statistics().Initialized());
      70             :   return std::unique_ptr<voe::ChannelProxy>(
      71           0 :       new voe::ChannelProxy(channel_manager().GetChannel(channel_id)));
      72             : }
      73             : 
      74           0 : VoiceEngine* VoiceEngine::Create() {
      75           0 :   return GetVoiceEngine();
      76             : }
      77             : 
      78           0 : int VoiceEngine::SetTraceFilter(unsigned int filter) {
      79             :   WEBRTC_TRACE(kTraceApiCall, kTraceVoice,
      80             :                VoEId(gVoiceEngineInstanceCounter, -1),
      81             :                "SetTraceFilter(filter=0x%x)", filter);
      82             : 
      83             :   // Remember old filter
      84           0 :   uint32_t oldFilter = Trace::level_filter();
      85           0 :   Trace::set_level_filter(filter);
      86             : 
      87             :   // If previous log was ignored, log again after changing filter
      88             :   if (kTraceNone == oldFilter) {
      89             :     WEBRTC_TRACE(kTraceApiCall, kTraceVoice, -1, "SetTraceFilter(filter=0x%x)",
      90             :                  filter);
      91             :   }
      92             : 
      93           0 :   return 0;
      94             : }
      95             : 
      96           0 : int VoiceEngine::SetTraceFile(const char* fileNameUTF8, bool addFileCounter) {
      97           0 :   int ret = Trace::SetTraceFile(fileNameUTF8, addFileCounter);
      98             :   WEBRTC_TRACE(kTraceApiCall, kTraceVoice,
      99             :                VoEId(gVoiceEngineInstanceCounter, -1),
     100             :                "SetTraceFile(fileNameUTF8=%s, addFileCounter=%d)", fileNameUTF8,
     101             :                addFileCounter);
     102           0 :   return (ret);
     103             : }
     104             : 
     105           0 : int VoiceEngine::SetTraceCallback(TraceCallback* callback) {
     106             :   WEBRTC_TRACE(kTraceApiCall, kTraceVoice,
     107             :                VoEId(gVoiceEngineInstanceCounter, -1),
     108             :                "SetTraceCallback(callback=0x%x)", callback);
     109           0 :   return (Trace::SetTraceCallback(callback));
     110             : }
     111             : 
     112           0 : bool VoiceEngine::Delete(VoiceEngine*& voiceEngine) {
     113           0 :   if (voiceEngine == NULL)
     114           0 :     return false;
     115             : 
     116           0 :   VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
     117             :   // Release the reference that was added in GetVoiceEngine.
     118           0 :   int ref = s->Release();
     119           0 :   voiceEngine = NULL;
     120             : 
     121             :   if (ref != 0) {
     122             :     WEBRTC_TRACE(
     123             :         kTraceWarning, kTraceVoice, -1,
     124             :         "VoiceEngine::Delete did not release the very last reference.  "
     125             :         "%d references remain.",
     126             :         ref);
     127             :   }
     128             : 
     129           0 :   return true;
     130             : }
     131             : 
     132             : #if !defined(WEBRTC_CHROMIUM_BUILD)
     133             : // TODO(henrika): change types to JavaVM* and jobject instead of void*.
     134           0 : int VoiceEngine::SetAndroidObjects(void* javaVM, void* context) {
     135             : #ifdef WEBRTC_ANDROID
     136             :   webrtc::JVM::Initialize(reinterpret_cast<JavaVM*>(javaVM),
     137             :                           reinterpret_cast<jobject>(context));
     138             :   return 0;
     139             : #else
     140           0 :   return -1;
     141             : #endif
     142             : }
     143             : #endif
     144             : 
     145           0 : std::string VoiceEngine::GetVersionString() {
     146           0 :   std::string version = "VoiceEngine 4.1.0";
     147             : #ifdef WEBRTC_EXTERNAL_TRANSPORT
     148             :   version += " (External transport build)";
     149             : #endif
     150           0 :   return version;
     151             : }
     152             : 
     153             : }  // namespace webrtc

Generated by: LCOV version 1.13