OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "init_webrtc.h" | 5 #include "init_webrtc.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/native_library.h" | 13 #include "base/native_library.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "third_party/webrtc/common.h" | |
16 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h
" | |
17 #include "webrtc/base/basictypes.h" | 15 #include "webrtc/base/basictypes.h" |
18 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
19 | 17 |
20 const unsigned char* GetCategoryGroupEnabled(const char* category_group) { | 18 const unsigned char* GetCategoryGroupEnabled(const char* category_group) { |
21 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); | 19 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); |
22 } | 20 } |
23 | 21 |
24 void AddTraceEvent(char phase, | 22 void AddTraceEvent(char phase, |
25 const unsigned char* category_group_enabled, | 23 const unsigned char* category_group_enabled, |
26 const char* name, | 24 const char* name, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 73 |
76 // libpeerconnection is being compiled as a static lib. In this case | 74 // libpeerconnection is being compiled as a static lib. In this case |
77 // we don't need to do any initializing but to keep things simple we | 75 // we don't need to do any initializing but to keep things simple we |
78 // provide an empty intialization routine so that this #ifdef doesn't | 76 // provide an empty intialization routine so that this #ifdef doesn't |
79 // have to be in other places. | 77 // have to be in other places. |
80 bool InitializeWebRtcModule() { | 78 bool InitializeWebRtcModule() { |
81 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent); | 79 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent); |
82 return true; | 80 return true; |
83 } | 81 } |
84 | 82 |
85 webrtc::AudioProcessing* CreateWebRtcAudioProcessing( | |
86 const webrtc::Config& config) { | |
87 // libpeerconnection is being compiled as a static lib, use | |
88 // webrtc::AudioProcessing directly. | |
89 return webrtc::AudioProcessing::Create(config); | |
90 } | |
91 | |
92 #else // !LIBPEERCONNECTION_LIB | 83 #else // !LIBPEERCONNECTION_LIB |
93 | 84 |
94 // When being compiled as a shared library, we need to bridge the gap between | 85 // When being compiled as a shared library, we need to bridge the gap between |
95 // the current module and the libpeerconnection module, so things get a tad | 86 // the current module and the libpeerconnection module, so things get a tad |
96 // more complicated. | 87 // more complicated. |
97 | 88 |
98 // Global function pointers to the factory functions in the shared library. | 89 // Global function pointers to the factory functions in the shared library. |
99 CreateWebRtcMediaEngineFunction g_create_webrtc_media_engine = NULL; | 90 CreateWebRtcMediaEngineFunction g_create_webrtc_media_engine = NULL; |
100 DestroyWebRtcMediaEngineFunction g_destroy_webrtc_media_engine = NULL; | 91 DestroyWebRtcMediaEngineFunction g_destroy_webrtc_media_engine = NULL; |
101 CreateWebRtcAudioProcessingFunction g_create_webrtc_audio_processing = NULL; | |
102 | 92 |
103 // Returns the full or relative path to the libpeerconnection module depending | 93 // Returns the full or relative path to the libpeerconnection module depending |
104 // on what platform we're on. | 94 // on what platform we're on. |
105 static base::FilePath GetLibPeerConnectionPath() { | 95 static base::FilePath GetLibPeerConnectionPath() { |
106 base::FilePath path; | 96 base::FilePath path; |
107 CHECK(PathService::Get(base::DIR_MODULE, &path)); | 97 CHECK(PathService::Get(base::DIR_MODULE, &path)); |
108 #if defined(OS_WIN) | 98 #if defined(OS_WIN) |
109 path = path.Append(FILE_PATH_LITERAL("libpeerconnection.dll")); | 99 path = path.Append(FILE_PATH_LITERAL("libpeerconnection.dll")); |
110 #elif defined(OS_MACOSX) | 100 #elif defined(OS_MACOSX) |
111 // Simulate '@loader_path/Libraries'. | 101 // Simulate '@loader_path/Libraries'. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 #endif | 158 #endif |
169 &webrtc::field_trial::FindFullName, | 159 &webrtc::field_trial::FindFullName, |
170 &webrtc::metrics::HistogramFactoryGetCounts, | 160 &webrtc::metrics::HistogramFactoryGetCounts, |
171 &webrtc::metrics::HistogramFactoryGetEnumeration, | 161 &webrtc::metrics::HistogramFactoryGetEnumeration, |
172 &webrtc::metrics::HistogramAdd, | 162 &webrtc::metrics::HistogramAdd, |
173 logging::GetLogMessageHandler(), | 163 logging::GetLogMessageHandler(), |
174 &GetCategoryGroupEnabled, | 164 &GetCategoryGroupEnabled, |
175 &AddTraceEvent, | 165 &AddTraceEvent, |
176 &g_create_webrtc_media_engine, | 166 &g_create_webrtc_media_engine, |
177 &g_destroy_webrtc_media_engine, | 167 &g_destroy_webrtc_media_engine, |
178 &init_diagnostic_logging, | 168 &init_diagnostic_logging); |
179 &g_create_webrtc_audio_processing); | 169 |
180 if (init_ok) | 170 if (init_ok) |
181 rtc::SetExtraLoggingInit(init_diagnostic_logging); | 171 rtc::SetExtraLoggingInit(init_diagnostic_logging); |
182 return init_ok; | 172 return init_ok; |
183 } | 173 } |
184 | 174 |
185 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( | 175 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( |
186 webrtc::AudioDeviceModule* adm, | 176 webrtc::AudioDeviceModule* adm, |
187 webrtc::AudioDeviceModule* adm_sc, | 177 webrtc::AudioDeviceModule* adm_sc, |
188 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 178 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
189 cricket::WebRtcVideoDecoderFactory* decoder_factory) { | 179 cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
190 // For convenience of tests etc, we call InitializeWebRtcModule here. | 180 // For convenience of tests etc, we call InitializeWebRtcModule here. |
191 // For Chrome however, InitializeWebRtcModule must be called | 181 // For Chrome however, InitializeWebRtcModule must be called |
192 // explicitly before the sandbox is initialized. In that case, this call is | 182 // explicitly before the sandbox is initialized. In that case, this call is |
193 // effectively a noop. | 183 // effectively a noop. |
194 InitializeWebRtcModule(); | 184 InitializeWebRtcModule(); |
195 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory, | 185 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory, |
196 decoder_factory); | 186 decoder_factory); |
197 } | 187 } |
198 | 188 |
199 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) { | 189 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) { |
200 g_destroy_webrtc_media_engine(media_engine); | 190 g_destroy_webrtc_media_engine(media_engine); |
201 } | 191 } |
202 | 192 |
203 webrtc::AudioProcessing* CreateWebRtcAudioProcessing( | |
204 const webrtc::Config& config) { | |
205 // The same as CreateWebRtcMediaEngine(), we call InitializeWebRtcModule here | |
206 // for convenience of tests. | |
207 InitializeWebRtcModule(); | |
208 return g_create_webrtc_audio_processing(config); | |
209 } | |
210 | |
211 #endif // LIBPEERCONNECTION_LIB | 193 #endif // LIBPEERCONNECTION_LIB |
OLD | NEW |