Skip to content

Commit 255ee24

Browse files
author
xians
committed
Merge 663413002 to M39:
Reland 597923002: Fix the way how we create webrtc::AudioProcessing in Chrome. The original review thread is in https://codereview.chromium.org/588523002/ Fix the way how we create webrtc::AudioProcessing in Chrome. [email protected],[email protected] BUG=415935 TEST=all webrtc tests in all bots + manual test to verify the agc loggings exist. Review URL: https://codereview.chromium.org/681123003 Cr-Commit-Position: refs/branch-heads/2171@{crosswalk-project#274} Cr-Branched-From: 267aeeb-refs/heads/master@{#297060}
1 parent 5154d5b commit 255ee24

File tree

10 files changed

+74
-13
lines changed

10 files changed

+74
-13
lines changed

build/android/pylib/gtest/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def _GenerateDepsDirUsingIsolate(suite_name, isolate_file_path=None):
118118
'--config-variable', 'component', 'static_library',
119119
'--config-variable', 'fastbuild', '0',
120120
'--config-variable', 'icu_use_data_file_flag', '1',
121+
'--config-variable', 'libpeer_target_type', 'static_library',
121122
# TODO(maruel): This may not be always true.
122123
'--config-variable', 'target_arch', 'arm',
123124
'--config-variable', 'use_openssl', '0',

content/content_tests.gypi

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,21 @@
838838
'../third_party/webrtc/modules/modules.gyp:desktop_capture',
839839
],
840840
}],
841+
['enable_webrtc==1 and OS=="mac"', {
842+
'variables': {
843+
'libpeer_target_type%': 'static_library',
844+
},
845+
'conditions': [
846+
['libpeer_target_type!="static_library"', {
847+
'copies': [{
848+
'destination': '<(PRODUCT_DIR)/Libraries',
849+
'files': [
850+
'<(PRODUCT_DIR)/libpeerconnection.so',
851+
],
852+
}],
853+
}],
854+
],
855+
}],
841856
['enable_webrtc==1 and chromeos==1', {
842857
'sources': [
843858
'browser/media/capture/desktop_capture_device_aura_unittest.cc',

content/content_unittests.isolate

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@
5656
],
5757
},
5858
}],
59+
['OS=="linux" and libpeer_target_type=="loadable_module"', {
60+
'variables': {
61+
'isolate_dependency_tracked': [
62+
'<(PRODUCT_DIR)/lib/libpeerconnection.so',
63+
],
64+
},
65+
}],
5966
['OS=="mac"', {
6067
'variables': {
6168
'command': [
@@ -91,6 +98,13 @@
9198
],
9299
},
93100
}],
101+
['OS=="win" and libpeer_target_type=="loadable_module"', {
102+
'variables': {
103+
'isolate_dependency_tracked': [
104+
'<(PRODUCT_DIR)/libpeerconnection.dll',
105+
],
106+
},
107+
}],
94108
],
95109
'includes': [
96110
'../base/base.isolate',

content/renderer/media/media_stream_audio_processor.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "media/base/audio_fifo.h"
2020
#include "media/base/channel_layout.h"
2121
#include "third_party/WebKit/public/platform/WebMediaConstraints.h"
22+
#include "third_party/libjingle/overrides/init_webrtc.h"
2223
#include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface.h"
2324
#include "third_party/webrtc/modules/audio_processing/typing_detection.h"
2425

@@ -423,7 +424,7 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule(
423424
#endif
424425

425426
// Create and configure the webrtc::AudioProcessing.
426-
audio_processing_.reset(webrtc::AudioProcessing::Create(config));
427+
audio_processing_.reset(CreateWebRtcAudioProcessing(config));
427428

428429
// Enable the audio processing components.
429430
if (echo_cancellation) {

content/renderer/media/media_stream_audio_processor_options.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,10 @@ void EnableTypingDetection(AudioProcessing* audio_processing,
251251
void StartEchoCancellationDump(AudioProcessing* audio_processing,
252252
base::File aec_dump_file) {
253253
DCHECK(aec_dump_file.IsValid());
254-
255-
FILE* stream = base::FileToFILE(aec_dump_file.Pass(), "w");
256-
if (!stream) {
257-
LOG(ERROR) << "Failed to open AEC dump file";
258-
return;
259-
}
260-
261-
if (audio_processing->StartDebugRecording(stream))
254+
if (audio_processing->StartDebugRecordingForPlatformFile(
255+
aec_dump_file.TakePlatformFile())) {
262256
DLOG(ERROR) << "Fail to start AEC debug recording";
257+
}
263258
}
264259

265260
void StopEchoCancellationDump(AudioProcessing* audio_processing) {

third_party/libjingle/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ if (enable_webrtc) {
548548
deps = [
549549
":libjingle_webrtc_common",
550550
"//third_party/webrtc",
551+
"//third_party/webrtc/modules/audio_processing",
551552
"//third_party/webrtc/system_wrappers",
552553
"//third_party/webrtc/voice_engine",
553554
]

third_party/libjingle/libjingle.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@
589589
'<(libjingle_source)/talk/media/webrtc/webrtcvoiceengine.h',
590590
],
591591
'dependencies': [
592+
'<(DEPTH)/third_party/webrtc/modules/modules.gyp:audio_processing',
592593
'<(DEPTH)/third_party/webrtc/system_wrappers/source/system_wrappers.gyp:system_wrappers',
593594
'<(DEPTH)/third_party/webrtc/voice_engine/voice_engine.gyp:voice_engine',
594595
'<(DEPTH)/third_party/webrtc/webrtc.gyp:webrtc',

third_party/libjingle/overrides/init_webrtc.cc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "base/metrics/field_trial.h"
1212
#include "base/native_library.h"
1313
#include "base/path_service.h"
14+
#include "third_party/webrtc/common.h"
15+
#include "third_party/webrtc/modules/audio_processing/include/audio_processing.h"
1416
#include "webrtc/base/basictypes.h"
1517
#include "webrtc/base/logging.h"
1618

@@ -53,6 +55,13 @@ bool InitializeWebRtcModule() {
5355
return true;
5456
}
5557

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+
5665
#else // !LIBPEERCONNECTION_LIB
5766

5867
// When being compiled as a shared library, we need to bridge the gap between
@@ -62,6 +71,7 @@ bool InitializeWebRtcModule() {
6271
// Global function pointers to the factory functions in the shared library.
6372
CreateWebRtcMediaEngineFunction g_create_webrtc_media_engine = NULL;
6473
DestroyWebRtcMediaEngineFunction g_destroy_webrtc_media_engine = NULL;
74+
CreateWebRtcAudioProcessingFunction g_create_webrtc_audio_processing = NULL;
6575

6676
// Returns the full or relative path to the libpeerconnection module depending
6777
// on what platform we're on.
@@ -135,8 +145,8 @@ bool InitializeWebRtcModule() {
135145
&AddTraceEvent,
136146
&g_create_webrtc_media_engine,
137147
&g_destroy_webrtc_media_engine,
138-
&init_diagnostic_logging);
139-
148+
&init_diagnostic_logging,
149+
&g_create_webrtc_audio_processing);
140150
if (init_ok)
141151
rtc::SetExtraLoggingInit(init_diagnostic_logging);
142152
return init_ok;
@@ -160,4 +170,12 @@ void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) {
160170
g_destroy_webrtc_media_engine(media_engine);
161171
}
162172

173+
webrtc::AudioProcessing* CreateWebRtcAudioProcessing(
174+
const webrtc::Config& config) {
175+
// The same as CreateWebRtcMediaEngine(), we call InitializeWebRtcModule here
176+
// for convenience of tests.
177+
InitializeWebRtcModule();
178+
return g_create_webrtc_audio_processing(config);
179+
}
180+
163181
#endif // LIBPEERCONNECTION_LIB

third_party/libjingle/overrides/init_webrtc.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class WebRtcVideoEncoderFactory;
2323

2424
namespace webrtc {
2525
class AudioDeviceModule;
26+
class AudioProcessing;
27+
class Config;
2628
} // namespace webrtc
2729

2830
typedef std::string (*FieldTrialFindFullName)(const std::string& trial_name);
@@ -39,6 +41,9 @@ typedef void (*DestroyWebRtcMediaEngineFunction)(
3941
typedef void (*InitDiagnosticLoggingDelegateFunctionFunction)(
4042
void (*DelegateFunction)(const std::string&));
4143

44+
typedef webrtc::AudioProcessing* (*CreateWebRtcAudioProcessingFunction)(
45+
const webrtc::Config& config);
46+
4247
// A typedef for the main initialize function in libpeerconnection.
4348
// This will initialize logging in the module with the proper arguments
4449
// as well as provide pointers back to a couple webrtc factory functions.
@@ -56,7 +61,8 @@ typedef bool (*InitializeModuleFunction)(
5661
webrtc::AddTraceEventPtr trace_add_trace_event,
5762
CreateWebRtcMediaEngineFunction* create_media_engine,
5863
DestroyWebRtcMediaEngineFunction* destroy_media_engine,
59-
InitDiagnosticLoggingDelegateFunctionFunction* init_diagnostic_logging);
64+
InitDiagnosticLoggingDelegateFunctionFunction* init_diagnostic_logging,
65+
CreateWebRtcAudioProcessingFunction* create_audio_processing);
6066

6167
#if !defined(LIBPEERCONNECTION_IMPLEMENTATION)
6268
// Load and initialize the shared WebRTC module (libpeerconnection).
@@ -65,6 +71,11 @@ typedef bool (*InitializeModuleFunction)(
6571
// If not called explicitly, this function will still be called from the main
6672
// CreateWebRtcMediaEngine factory function the first time it is called.
6773
bool InitializeWebRtcModule();
74+
75+
// Return a webrtc::AudioProcessing object.
76+
webrtc::AudioProcessing* CreateWebRtcAudioProcessing(
77+
const webrtc::Config& config);
78+
6879
#endif
6980

7081
#endif // THIRD_PARTY_LIBJINGLE_OVERRIDES_INIT_WEBRTC_H_

third_party/libjingle/overrides/initialize_module.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "base/logging.h"
99
#include "init_webrtc.h"
1010
#include "talk/media/webrtc/webrtcmediaengine.h"
11+
#include "third_party/webrtc/modules/audio_processing/include/audio_processing.h"
1112
#include "webrtc/base/basictypes.h"
1213
#include "webrtc/base/logging.h"
1314

@@ -71,7 +72,9 @@ bool InitializeModule(const CommandLine& command_line,
7172
CreateWebRtcMediaEngineFunction* create_media_engine,
7273
DestroyWebRtcMediaEngineFunction* destroy_media_engine,
7374
InitDiagnosticLoggingDelegateFunctionFunction*
74-
init_diagnostic_logging) {
75+
init_diagnostic_logging,
76+
CreateWebRtcAudioProcessingFunction*
77+
create_audio_processing) {
7578
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
7679
g_alloc = alloc;
7780
g_dealloc = dealloc;
@@ -82,6 +85,7 @@ bool InitializeModule(const CommandLine& command_line,
8285
*create_media_engine = &CreateWebRtcMediaEngine;
8386
*destroy_media_engine = &DestroyWebRtcMediaEngine;
8487
*init_diagnostic_logging = &rtc::InitDiagnosticLoggingDelegateFunction;
88+
*create_audio_processing = &webrtc::AudioProcessing::Create;
8589

8690
if (CommandLine::Init(0, NULL)) {
8791
#if !defined(OS_WIN)

0 commit comments

Comments
 (0)