Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: third_party/libjingle/overrides/init_webrtc.cc

Issue 663413002: Reland 597923002: Fix the way how we create webrtc::AudioProcessing in Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed two extra empty line caused by rebasing Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "
15 #include "webrtc/base/basictypes.h" 17 #include "webrtc/base/basictypes.h"
16 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
17 19
18 const unsigned char* GetCategoryGroupEnabled(const char* category_group) { 20 const unsigned char* GetCategoryGroupEnabled(const char* category_group) {
19 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); 21 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group);
20 } 22 }
21 23
22 void AddTraceEvent(char phase, 24 void AddTraceEvent(char phase,
23 const unsigned char* category_group_enabled, 25 const unsigned char* category_group_enabled,
24 const char* name, 26 const char* name,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 75
74 // libpeerconnection is being compiled as a static lib. In this case 76 // libpeerconnection is being compiled as a static lib. In this case
75 // we don't need to do any initializing but to keep things simple we 77 // we don't need to do any initializing but to keep things simple we
76 // provide an empty intialization routine so that this #ifdef doesn't 78 // provide an empty intialization routine so that this #ifdef doesn't
77 // have to be in other places. 79 // have to be in other places.
78 bool InitializeWebRtcModule() { 80 bool InitializeWebRtcModule() {
79 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent); 81 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent);
80 return true; 82 return true;
81 } 83 }
82 84
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
83 #else // !LIBPEERCONNECTION_LIB 92 #else // !LIBPEERCONNECTION_LIB
84 93
85 // When being compiled as a shared library, we need to bridge the gap between 94 // When being compiled as a shared library, we need to bridge the gap between
86 // the current module and the libpeerconnection module, so things get a tad 95 // the current module and the libpeerconnection module, so things get a tad
87 // more complicated. 96 // more complicated.
88 97
89 // Global function pointers to the factory functions in the shared library. 98 // Global function pointers to the factory functions in the shared library.
90 CreateWebRtcMediaEngineFunction g_create_webrtc_media_engine = NULL; 99 CreateWebRtcMediaEngineFunction g_create_webrtc_media_engine = NULL;
91 DestroyWebRtcMediaEngineFunction g_destroy_webrtc_media_engine = NULL; 100 DestroyWebRtcMediaEngineFunction g_destroy_webrtc_media_engine = NULL;
101 CreateWebRtcAudioProcessingFunction g_create_webrtc_audio_processing = NULL;
92 102
93 // Returns the full or relative path to the libpeerconnection module depending 103 // Returns the full or relative path to the libpeerconnection module depending
94 // on what platform we're on. 104 // on what platform we're on.
95 static base::FilePath GetLibPeerConnectionPath() { 105 static base::FilePath GetLibPeerConnectionPath() {
96 base::FilePath path; 106 base::FilePath path;
97 CHECK(PathService::Get(base::DIR_MODULE, &path)); 107 CHECK(PathService::Get(base::DIR_MODULE, &path));
98 #if defined(OS_WIN) 108 #if defined(OS_WIN)
99 path = path.Append(FILE_PATH_LITERAL("libpeerconnection.dll")); 109 path = path.Append(FILE_PATH_LITERAL("libpeerconnection.dll"));
100 #elif defined(OS_MACOSX) 110 #elif defined(OS_MACOSX)
101 // Simulate '@loader_path/Libraries'. 111 // Simulate '@loader_path/Libraries'.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 #endif 168 #endif
159 &webrtc::field_trial::FindFullName, 169 &webrtc::field_trial::FindFullName,
160 &webrtc::metrics::HistogramFactoryGetCounts, 170 &webrtc::metrics::HistogramFactoryGetCounts,
161 &webrtc::metrics::HistogramFactoryGetEnumeration, 171 &webrtc::metrics::HistogramFactoryGetEnumeration,
162 &webrtc::metrics::HistogramAdd, 172 &webrtc::metrics::HistogramAdd,
163 logging::GetLogMessageHandler(), 173 logging::GetLogMessageHandler(),
164 &GetCategoryGroupEnabled, 174 &GetCategoryGroupEnabled,
165 &AddTraceEvent, 175 &AddTraceEvent,
166 &g_create_webrtc_media_engine, 176 &g_create_webrtc_media_engine,
167 &g_destroy_webrtc_media_engine, 177 &g_destroy_webrtc_media_engine,
168 &init_diagnostic_logging); 178 &init_diagnostic_logging,
169 179 &g_create_webrtc_audio_processing);
170 if (init_ok) 180 if (init_ok)
171 rtc::SetExtraLoggingInit(init_diagnostic_logging); 181 rtc::SetExtraLoggingInit(init_diagnostic_logging);
172 return init_ok; 182 return init_ok;
173 } 183 }
174 184
175 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( 185 cricket::MediaEngineInterface* CreateWebRtcMediaEngine(
176 webrtc::AudioDeviceModule* adm, 186 webrtc::AudioDeviceModule* adm,
177 webrtc::AudioDeviceModule* adm_sc, 187 webrtc::AudioDeviceModule* adm_sc,
178 cricket::WebRtcVideoEncoderFactory* encoder_factory, 188 cricket::WebRtcVideoEncoderFactory* encoder_factory,
179 cricket::WebRtcVideoDecoderFactory* decoder_factory) { 189 cricket::WebRtcVideoDecoderFactory* decoder_factory) {
180 // For convenience of tests etc, we call InitializeWebRtcModule here. 190 // For convenience of tests etc, we call InitializeWebRtcModule here.
181 // For Chrome however, InitializeWebRtcModule must be called 191 // For Chrome however, InitializeWebRtcModule must be called
182 // explicitly before the sandbox is initialized. In that case, this call is 192 // explicitly before the sandbox is initialized. In that case, this call is
183 // effectively a noop. 193 // effectively a noop.
184 InitializeWebRtcModule(); 194 InitializeWebRtcModule();
185 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory, 195 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory,
186 decoder_factory); 196 decoder_factory);
187 } 197 }
188 198
189 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) { 199 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) {
190 g_destroy_webrtc_media_engine(media_engine); 200 g_destroy_webrtc_media_engine(media_engine);
191 } 201 }
192 202
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
193 #endif // LIBPEERCONNECTION_LIB 211 #endif // LIBPEERCONNECTION_LIB
OLDNEW
« no previous file with comments | « third_party/libjingle/overrides/init_webrtc.h ('k') | third_party/libjingle/overrides/initialize_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698