Skip to content

Commit

Permalink
The original review thread is in https://codereview.chromium.org/5885…
Browse files Browse the repository at this point in the history
…23002/

Fix the way how we create webrtc::AudioProcessing in Chrome.

TBR=tommi@chromium.org

BUG=415935
TEST=all webrtc tests in all bots + manual test to verify the agc loggings exist.

Review URL: https://codereview.chromium.org/597923002

Cr-Commit-Position: refs/heads/master@{#296709}
  • Loading branch information
xians authored and Commit bot committed Sep 25, 2014
1 parent fe3e9c0 commit 6299e2d
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 4 deletions.
1 change: 1 addition & 0 deletions build/android/pylib/gtest/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def _GenerateDepsDirUsingIsolate(suite_name, isolate_file_path=None):
'--config-variable', 'component', 'static_library',
'--config-variable', 'fastbuild', '0',
'--config-variable', 'icu_use_data_file_flag', '1',
'--config-variable', 'libpeer_target_type', 'static_library',
# TODO(maruel): This may not be always true.
'--config-variable', 'target_arch', 'arm',
'--config-variable', 'use_openssl', '0',
Expand Down
15 changes: 15 additions & 0 deletions content/content_tests.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,21 @@
'../third_party/webrtc/modules/modules.gyp:desktop_capture',
],
}],
['enable_webrtc==1 and OS=="mac"', {
'variables': {
'libpeer_target_type%': 'static_library',
},
'conditions': [
['libpeer_target_type!="static_library"', {
'copies': [{
'destination': '<(PRODUCT_DIR)/Libraries',
'files': [
'<(PRODUCT_DIR)/libpeerconnection.so',
],
}],
}],
],
}],
['enable_webrtc==1 and chromeos==1', {
'sources': [
'browser/media/capture/desktop_capture_device_aura_unittest.cc',
Expand Down
14 changes: 14 additions & 0 deletions content/content_unittests.isolate
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
],
},
}],
['OS=="linux" and libpeer_target_type=="loadable_module"', {
'variables': {
'isolate_dependency_tracked': [
'<(PRODUCT_DIR)/lib/libpeerconnection.so',
],
},
}],
['OS=="mac"', {
'variables': {
'command': [
Expand Down Expand Up @@ -91,6 +98,13 @@
],
},
}],
['OS=="win" and libpeer_target_type=="loadable_module"', {
'variables': {
'isolate_dependency_tracked': [
'<(PRODUCT_DIR)/libpeerconnection.dll',
],
},
}],
],
'includes': [
'../third_party/icu/icu.isolate',
Expand Down
3 changes: 2 additions & 1 deletion content/renderer/media/media_stream_audio_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "media/base/audio_fifo.h"
#include "media/base/channel_layout.h"
#include "third_party/WebKit/public/platform/WebMediaConstraints.h"
#include "third_party/libjingle/overrides/init_webrtc.h"
#include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface.h"
#include "third_party/webrtc/modules/audio_processing/typing_detection.h"

Expand Down Expand Up @@ -423,7 +424,7 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule(
#endif

// Create and configure the webrtc::AudioProcessing.
audio_processing_.reset(webrtc::AudioProcessing::Create(config));
audio_processing_.reset(CreateWebRtcAudioProcessing(config));

// Enable the audio processing components.
if (echo_cancellation) {
Expand Down
1 change: 1 addition & 0 deletions third_party/libjingle/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ if (enable_webrtc) {
deps = [
":libjingle_webrtc_common",
"//third_party/webrtc",
"//third_party/webrtc/modules/audio_processing",
"//third_party/webrtc/system_wrappers",
"//third_party/webrtc/voice_engine",
]
Expand Down
1 change: 1 addition & 0 deletions third_party/libjingle/libjingle.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@
'<(libjingle_source)/talk/media/webrtc/webrtcvoiceengine.h',
],
'dependencies': [
'<(DEPTH)/third_party/webrtc/modules/modules.gyp:audio_processing',
'<(DEPTH)/third_party/webrtc/system_wrappers/source/system_wrappers.gyp:system_wrappers',
'<(DEPTH)/third_party/webrtc/voice_engine/voice_engine.gyp:voice_engine',
'<(DEPTH)/third_party/webrtc/webrtc.gyp:webrtc',
Expand Down
21 changes: 20 additions & 1 deletion third_party/libjingle/overrides/init_webrtc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "base/metrics/field_trial.h"
#include "base/native_library.h"
#include "base/path_service.h"
#include "third_party/webrtc/common.h"
#include "third_party/webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/base/basictypes.h"
#include "webrtc/base/logging.h"

Expand Down Expand Up @@ -53,6 +55,13 @@ bool InitializeWebRtcModule() {
return true;
}

webrtc::AudioProcessing* CreateWebRtcAudioProcessing(
const webrtc::Config& config) {
// libpeerconnection is being compiled as a static lib, use
// webrtc::AudioProcessing directly.
return webrtc::AudioProcessing::Create(config);
}

#else // !LIBPEERCONNECTION_LIB

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

// Returns the full or relative path to the libpeerconnection module depending
// on what platform we're on.
Expand Down Expand Up @@ -135,7 +145,8 @@ bool InitializeWebRtcModule() {
&AddTraceEvent,
&g_create_webrtc_media_engine,
&g_destroy_webrtc_media_engine,
&init_diagnostic_logging);
&init_diagnostic_logging,
&g_create_webrtc_audio_processing);

if (init_ok)
rtc::SetExtraLoggingInit(init_diagnostic_logging);
Expand All @@ -160,4 +171,12 @@ void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) {
g_destroy_webrtc_media_engine(media_engine);
}

webrtc::AudioProcessing* CreateWebRtcAudioProcessing(
const webrtc::Config& config) {
// The same as CreateWebRtcMediaEngine(), we call InitializeWebRtcModule here
// for convenience of tests.
InitializeWebRtcModule();
return g_create_webrtc_audio_processing(config);
}

#endif // LIBPEERCONNECTION_LIB
13 changes: 12 additions & 1 deletion third_party/libjingle/overrides/init_webrtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class WebRtcVideoEncoderFactory;

namespace webrtc {
class AudioDeviceModule;
class AudioProcessing;
class Config;
} // namespace webrtc

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

typedef webrtc::AudioProcessing* (*CreateWebRtcAudioProcessingFunction)(
const webrtc::Config& config);

// A typedef for the main initialize function in libpeerconnection.
// This will initialize logging in the module with the proper arguments
// as well as provide pointers back to a couple webrtc factory functions.
Expand All @@ -56,7 +61,8 @@ typedef bool (*InitializeModuleFunction)(
webrtc::AddTraceEventPtr trace_add_trace_event,
CreateWebRtcMediaEngineFunction* create_media_engine,
DestroyWebRtcMediaEngineFunction* destroy_media_engine,
InitDiagnosticLoggingDelegateFunctionFunction* init_diagnostic_logging);
InitDiagnosticLoggingDelegateFunctionFunction* init_diagnostic_logging,
CreateWebRtcAudioProcessingFunction* create_audio_processing);

#if !defined(LIBPEERCONNECTION_IMPLEMENTATION)
// Load and initialize the shared WebRTC module (libpeerconnection).
Expand All @@ -65,6 +71,11 @@ typedef bool (*InitializeModuleFunction)(
// If not called explicitly, this function will still be called from the main
// CreateWebRtcMediaEngine factory function the first time it is called.
bool InitializeWebRtcModule();

// Return a webrtc::AudioProcessing object.
webrtc::AudioProcessing* CreateWebRtcAudioProcessing(
const webrtc::Config& config);

#endif

#endif // THIRD_PARTY_LIBJINGLE_OVERRIDES_INIT_WEBRTC_H_
6 changes: 5 additions & 1 deletion third_party/libjingle/overrides/initialize_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "base/logging.h"
#include "init_webrtc.h"
#include "talk/media/webrtc/webrtcmediaengine.h"
#include "third_party/webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/base/basictypes.h"
#include "webrtc/base/logging.h"

Expand Down Expand Up @@ -71,7 +72,9 @@ bool InitializeModule(const CommandLine& command_line,
CreateWebRtcMediaEngineFunction* create_media_engine,
DestroyWebRtcMediaEngineFunction* destroy_media_engine,
InitDiagnosticLoggingDelegateFunctionFunction*
init_diagnostic_logging) {
init_diagnostic_logging,
CreateWebRtcAudioProcessingFunction*
create_audio_processing) {
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
g_alloc = alloc;
g_dealloc = dealloc;
Expand All @@ -82,6 +85,7 @@ bool InitializeModule(const CommandLine& command_line,
*create_media_engine = &CreateWebRtcMediaEngine;
*destroy_media_engine = &DestroyWebRtcMediaEngine;
*init_diagnostic_logging = &rtc::InitDiagnosticLoggingDelegateFunction;
*create_audio_processing = &webrtc::AudioProcessing::Create;

if (CommandLine::Init(0, NULL)) {
#if !defined(OS_WIN)
Expand Down

0 comments on commit 6299e2d

Please sign in to comment.