[c8bea5]: media / webrtc / trunk / webrtc / voice_engine / voice_engine_impl.cc  Maximize  Restore  History

Download this file

156 lines (129 with data), 4.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#if defined(ANDROID) && !defined(MOZ_WIDGET_GONK)
#include "modules/audio_device/android/audio_device_jni_android.h"
#endif
#include "voice_engine_impl.h"
#include "trace.h"
namespace webrtc
{
// Counter to be ensure that we can add a correct ID in all static trace
// methods. It is not the nicest solution, especially not since we already
// have a counter in VoEBaseImpl. In other words, there is room for
// improvement here.
static WebRtc_Word32 gVoiceEngineInstanceCounter = 0;
extern "C"
{
WEBRTC_DLLEXPORT VoiceEngine* GetVoiceEngine();
VoiceEngine* GetVoiceEngine()
{
VoiceEngineImpl* self = new VoiceEngineImpl();
VoiceEngine* ve = reinterpret_cast<VoiceEngine*>(self);
if (ve != NULL)
{
self->AddRef(); // First reference. Released in VoiceEngine::Delete.
gVoiceEngineInstanceCounter++;
}
return ve;
}
} // extern "C"
int VoiceEngineImpl::AddRef() {
return ++_ref_count;
}
// This implements the Release() method for all the inherited interfaces.
int VoiceEngineImpl::Release() {
int new_ref = --_ref_count;
assert(new_ref >= 0);
if (new_ref == 0) {
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, -1,
"VoiceEngineImpl self deleting (voiceEngine=0x%p)",
this);
delete this;
}
return new_ref;
}
VoiceEngine* VoiceEngine::Create()
{
#if (defined _WIN32)
HMODULE hmod_ = LoadLibrary(TEXT("VoiceEngineTestingDynamic.dll"));
if (hmod_)
{
typedef VoiceEngine* (*PfnGetVoiceEngine)(void);
PfnGetVoiceEngine pfn = (PfnGetVoiceEngine)GetProcAddress(
hmod_,"GetVoiceEngine");
if (pfn)
{
VoiceEngine* self = pfn();
return (self);
}
}
#endif
return GetVoiceEngine();
}
int VoiceEngine::SetTraceFilter(const unsigned int filter)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice,
VoEId(gVoiceEngineInstanceCounter, -1),
"SetTraceFilter(filter=0x%x)", filter);
// Remember old filter
WebRtc_UWord32 oldFilter = 0;
Trace::LevelFilter(oldFilter);
// Set new filter
WebRtc_Word32 ret = Trace::SetLevelFilter(filter);
// If previous log was ignored, log again after changing filter
if (kTraceNone == oldFilter)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, -1,
"SetTraceFilter(filter=0x%x)", filter);
}
return (ret);
}
int VoiceEngine::SetTraceFile(const char* fileNameUTF8,
const bool addFileCounter)
{
int ret = Trace::SetTraceFile(fileNameUTF8, addFileCounter);
WEBRTC_TRACE(kTraceApiCall, kTraceVoice,
VoEId(gVoiceEngineInstanceCounter, -1),
"SetTraceFile(fileNameUTF8=%s, addFileCounter=%d)",
fileNameUTF8, addFileCounter);
return (ret);
}
int VoiceEngine::SetTraceCallback(TraceCallback* callback)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice,
VoEId(gVoiceEngineInstanceCounter, -1),
"SetTraceCallback(callback=0x%x)", callback);
return (Trace::SetTraceCallback(callback));
}
bool VoiceEngine::Delete(VoiceEngine*& voiceEngine)
{
if (voiceEngine == NULL)
return false;
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine);
// Release the reference that was added in GetVoiceEngine.
int ref = s->Release();
voiceEngine = NULL;
if (ref != 0) {
WEBRTC_TRACE(kTraceWarning, kTraceVoice, -1,
"VoiceEngine::Delete did not release the very last reference. "
"%d references remain.", ref);
}
return true;
}
int VoiceEngine::SetAndroidObjects(void* javaVM, void* context)
{
#if defined(ANDROID) && !defined(MOZ_WIDGET_GONK)
return AudioDeviceAndroidJni::SetAndroidAudioDeviceObjects(
javaVM, context);
#else
return -1;
#endif
}
} //namespace webrtc

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks