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

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

Issue 588523002: Fix the way how we create webrtc::AudioProcessing in Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased and another try 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/native_library.h" 12 #include "base/native_library.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "third_party/webrtc/common.h"
15 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h "
14 #include "webrtc/base/basictypes.h" 16 #include "webrtc/base/basictypes.h"
15 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
16 18
17 const unsigned char* GetCategoryGroupEnabled(const char* category_group) { 19 const unsigned char* GetCategoryGroupEnabled(const char* category_group) {
18 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); 20 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group);
19 } 21 }
20 22
21 void AddTraceEvent(char phase, 23 void AddTraceEvent(char phase,
22 const unsigned char* category_group_enabled, 24 const unsigned char* category_group_enabled,
23 const char* name, 25 const char* name,
(...skipping 22 matching lines...) Expand all
46 48
47 // libpeerconnection is being compiled as a static lib. In this case 49 // libpeerconnection is being compiled as a static lib. In this case
48 // we don't need to do any initializing but to keep things simple we 50 // we don't need to do any initializing but to keep things simple we
49 // provide an empty intialization routine so that this #ifdef doesn't 51 // provide an empty intialization routine so that this #ifdef doesn't
50 // have to be in other places. 52 // have to be in other places.
51 bool InitializeWebRtcModule() { 53 bool InitializeWebRtcModule() {
52 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent); 54 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent);
53 return true; 55 return true;
54 } 56 }
55 57
58 webrtc::AudioProcessing* CreateWebRtcAudioProcessing(
59 const webrtc::Config& config) {
60 // libpeerconnection is being compiled as a static lib, use
61 // webrtc::AudioProcessing directly.
62 return webrtc::AudioProcessing::Create(config);
63 }
64
56 #else // !LIBPEERCONNECTION_LIB 65 #else // !LIBPEERCONNECTION_LIB
57 66
58 // When being compiled as a shared library, we need to bridge the gap between 67 // When being compiled as a shared library, we need to bridge the gap between
59 // the current module and the libpeerconnection module, so things get a tad 68 // the current module and the libpeerconnection module, so things get a tad
60 // more complicated. 69 // more complicated.
61 70
62 // Global function pointers to the factory functions in the shared library. 71 // Global function pointers to the factory functions in the shared library.
63 CreateWebRtcMediaEngineFunction g_create_webrtc_media_engine = NULL; 72 CreateWebRtcMediaEngineFunction g_create_webrtc_media_engine = NULL;
64 DestroyWebRtcMediaEngineFunction g_destroy_webrtc_media_engine = NULL; 73 DestroyWebRtcMediaEngineFunction g_destroy_webrtc_media_engine = NULL;
74 CreateWebRtcAudioProcessingFunction g_create_webrtc_audio_processing = NULL;
65 75
66 // Returns the full or relative path to the libpeerconnection module depending 76 // Returns the full or relative path to the libpeerconnection module depending
67 // on what platform we're on. 77 // on what platform we're on.
68 static base::FilePath GetLibPeerConnectionPath() { 78 static base::FilePath GetLibPeerConnectionPath() {
69 base::FilePath path; 79 base::FilePath path;
70 CHECK(PathService::Get(base::DIR_MODULE, &path)); 80 CHECK(PathService::Get(base::DIR_MODULE, &path));
71 #if defined(OS_WIN) 81 #if defined(OS_WIN)
72 path = path.Append(FILE_PATH_LITERAL("libpeerconnection.dll")); 82 path = path.Append(FILE_PATH_LITERAL("libpeerconnection.dll"));
73 #elif defined(OS_MACOSX) 83 #elif defined(OS_MACOSX)
74 // Simulate '@loader_path/Libraries'. 84 // Simulate '@loader_path/Libraries'.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 138 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
129 &Allocate, 139 &Allocate,
130 &Dellocate, 140 &Dellocate,
131 #endif 141 #endif
132 &webrtc::field_trial::FindFullName, 142 &webrtc::field_trial::FindFullName,
133 logging::GetLogMessageHandler(), 143 logging::GetLogMessageHandler(),
134 &GetCategoryGroupEnabled, 144 &GetCategoryGroupEnabled,
135 &AddTraceEvent, 145 &AddTraceEvent,
136 &g_create_webrtc_media_engine, 146 &g_create_webrtc_media_engine,
137 &g_destroy_webrtc_media_engine, 147 &g_destroy_webrtc_media_engine,
138 &init_diagnostic_logging); 148 &init_diagnostic_logging,
149 &g_create_webrtc_audio_processing);
139 150
140 if (init_ok) 151 if (init_ok)
141 rtc::SetExtraLoggingInit(init_diagnostic_logging); 152 rtc::SetExtraLoggingInit(init_diagnostic_logging);
142 return init_ok; 153 return init_ok;
143 } 154 }
144 155
145 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( 156 cricket::MediaEngineInterface* CreateWebRtcMediaEngine(
146 webrtc::AudioDeviceModule* adm, 157 webrtc::AudioDeviceModule* adm,
147 webrtc::AudioDeviceModule* adm_sc, 158 webrtc::AudioDeviceModule* adm_sc,
148 cricket::WebRtcVideoEncoderFactory* encoder_factory, 159 cricket::WebRtcVideoEncoderFactory* encoder_factory,
149 cricket::WebRtcVideoDecoderFactory* decoder_factory) { 160 cricket::WebRtcVideoDecoderFactory* decoder_factory) {
150 // For convenience of tests etc, we call InitializeWebRtcModule here. 161 // For convenience of tests etc, we call InitializeWebRtcModule here.
151 // For Chrome however, InitializeWebRtcModule must be called 162 // For Chrome however, InitializeWebRtcModule must be called
152 // explicitly before the sandbox is initialized. In that case, this call is 163 // explicitly before the sandbox is initialized. In that case, this call is
153 // effectively a noop. 164 // effectively a noop.
154 InitializeWebRtcModule(); 165 InitializeWebRtcModule();
155 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory, 166 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory,
156 decoder_factory); 167 decoder_factory);
157 } 168 }
158 169
159 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) { 170 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) {
160 g_destroy_webrtc_media_engine(media_engine); 171 g_destroy_webrtc_media_engine(media_engine);
161 } 172 }
162 173
174 webrtc::AudioProcessing* CreateWebRtcAudioProcessing(
175 const webrtc::Config& config) {
176 // The same as CreateWebRtcMediaEngine(), we call InitializeWebRtcModule here
177 // for convenience of tests.
178 InitializeWebRtcModule();
179 return g_create_webrtc_audio_processing(config);
180 }
181
163 #endif // LIBPEERCONNECTION_LIB 182 #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