summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 18:54:19 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 18:54:19 +0000
commite4aa290bc7113c8ed53edc94837ba59df1cce800 (patch)
tree14d8b1ec925eaa14d0a37fb020af6bd6941f4c64
parent0e5a13aa0e667d34f893cb04d7c07db2153a733a (diff)
downloadchromium_src-e4aa290bc7113c8ed53edc94837ba59df1cce800.zip
chromium_src-e4aa290bc7113c8ed53edc94837ba59df1cce800.tar.gz
chromium_src-e4aa290bc7113c8ed53edc94837ba59df1cce800.tar.bz2
Support for loading libpeerconnection dynamically instead of statically.
This means that instead of using shared_library as the target type for libpeerconnection, we'll support loadable_module. This fixes issues with test binaries that would otherwise unnecessarily depend on libpeerconnection in shared builds. The renderer now loads and initializes the module just before initializing the sandbox. I'm also enabling logging in the module since we can now do that after the process CommandLine instance has been initialized. The output directory on linux is now always the lib/ subfolder of the build directory. This is so that FILES.cfg and installer scripts will find it reliably. Make builds would previuosly put it in lib.target/ whereas ninja already used lib/. (lib/ is also the folder the installer will use) BUG=232402,233173,235379,235380 R=jam@chromium.org, jln@chromium.org, mark@chromium.org, ronghuawu@chromium.org Review URL: https://codereview.chromium.org/14021012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197679 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/chrome_dll_bundle.gypi4
-rw-r--r--chrome/chrome_installer.gypi4
-rw-r--r--content/DEPS1
-rw-r--r--content/content_shell.gypi4
-rw-r--r--content/renderer/renderer_main.cc8
-rw-r--r--content/zygote/zygote_main_linux.cc4
-rw-r--r--third_party/libjingle/libjingle.gyp64
-rw-r--r--third_party/libjingle/overrides/allocator_shim/allocator_proxy.cc30
-rw-r--r--third_party/libjingle/overrides/allocator_shim/allocator_stub.cc53
-rw-r--r--third_party/libjingle/overrides/allocator_shim/allocator_stub.h24
-rw-r--r--third_party/libjingle/overrides/init_webrtc.cc100
-rw-r--r--third_party/libjingle/overrides/init_webrtc.h50
-rw-r--r--third_party/libjingle/overrides/initialize_module.cc81
-rw-r--r--third_party/libjingle/overrides/talk/media/webrtc/webrtcexport.h21
14 files changed, 345 insertions, 103 deletions
diff --git a/chrome/chrome_dll_bundle.gypi b/chrome/chrome_dll_bundle.gypi
index 1fc8a77..5b8dec2 100644
--- a/chrome/chrome_dll_bundle.gypi
+++ b/chrome/chrome_dll_bundle.gypi
@@ -289,11 +289,11 @@
'<(SHARED_INTERMEDIATE_DIR)/repack/chrome_200_percent.pak',
],
}],
- ['enable_webrtc==1 and libpeer_target_type=="shared_library"', {
+ ['enable_webrtc==1 and libpeer_target_type!="static_library"', {
'copies': [{
'destination': '<(PRODUCT_DIR)/$(CONTENTS_FOLDER_PATH)/Libraries',
'files': [
- '<(PRODUCT_DIR)/Libraries/libpeerconnection.dylib',
+ '<(PRODUCT_DIR)/Libraries/libpeerconnection.so',
],
}],
}],
diff --git a/chrome/chrome_installer.gypi b/chrome/chrome_installer.gypi
index e8d5679..55dd4c8 100644
--- a/chrome/chrome_installer.gypi
+++ b/chrome/chrome_installer.gypi
@@ -588,9 +588,9 @@
'<(PRODUCT_DIR)/libpdf.so',
],
}],
- ['libpeer_target_type=="shared_library"', {
+ ['libpeer_target_type!="static_library"', {
'packaging_files_binaries': [
- '<(SHARED_LIB_DIR)/libpeerconnection.so',
+ '<(PRODUCT_DIR)/lib/libpeerconnection.so',
],
}],
],
diff --git a/content/DEPS b/content/DEPS
index 71d3a15..fae46cf 100644
--- a/content/DEPS
+++ b/content/DEPS
@@ -54,6 +54,7 @@ include_rules = [
"+third_party/angle",
"+third_party/flac",
"+third_party/gpsd",
+ "+third_party/libjingle",
"+third_party/mozilla",
"+third_party/npapi/bindings",
"+third_party/skia",
diff --git a/content/content_shell.gypi b/content/content_shell.gypi
index b245dd3..7381c94 100644
--- a/content/content_shell.gypi
+++ b/content/content_shell.gypi
@@ -498,11 +498,11 @@
'libpeer_target_type%': 'static_library',
},
'conditions': [
- ['libpeer_target_type=="shared_library"', {
+ ['libpeer_target_type!="static_library"', {
'copies': [{
'destination': '<(PRODUCT_DIR)/$(CONTENTS_FOLDER_PATH)/Libraries',
'files': [
- '<(PRODUCT_DIR)/Libraries/libpeerconnection.dylib',
+ '<(PRODUCT_DIR)/Libraries/libpeerconnection.so',
],
}],
}],
diff --git a/content/renderer/renderer_main.cc b/content/renderer/renderer_main.cc
index c154e69c..b69c0df 100644
--- a/content/renderer/renderer_main.cc
+++ b/content/renderer/renderer_main.cc
@@ -30,6 +30,7 @@
#include "content/renderer/render_process_impl.h"
#include "content/renderer/render_thread_impl.h"
#include "content/renderer/renderer_main_platform_delegate.h"
+#include "third_party/libjingle/overrides/init_webrtc.h"
#include "ui/base/ui_base_switches.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/plugins/ppapi/ppapi_interface_factory.h"
@@ -188,6 +189,13 @@ int RendererMain(const MainFunctionParams& parameters) {
// Load pepper plugins before engaging the sandbox.
PepperPluginRegistry::GetInstance();
#endif
+#if defined(ENABLE_WEBRTC)
+ // Initialize WebRTC before engaging the sandbox.
+ // NOTE: On linux, this call could already have been made from
+ // zygote_main_linux.cc. However, calling multiple times from the same thread
+ // is OK.
+ InitializeWebRtcModule();
+#endif
{
#if defined(OS_WIN) || defined(OS_MACOSX)
diff --git a/content/zygote/zygote_main_linux.cc b/content/zygote/zygote_main_linux.cc
index 9c909ab..ca75518 100644
--- a/content/zygote/zygote_main_linux.cc
+++ b/content/zygote/zygote_main_linux.cc
@@ -40,6 +40,7 @@
#include "sandbox/linux/services/libc_urandom_override.h"
#include "sandbox/linux/suid/client/setuid_sandbox_client.h"
#include "third_party/icu/public/i18n/unicode/timezone.h"
+#include "third_party/libjingle/overrides/init_webrtc.h"
#include "third_party/skia/include/ports/SkFontConfigInterface.h"
#if defined(OS_LINUX)
@@ -281,6 +282,9 @@ static void PreSandboxInit() {
// Ensure access to the Pepper plugins before the sandbox is turned on.
PepperPluginRegistry::PreloadModules();
#endif
+#if defined(ENABLE_WEBRTC)
+ InitializeWebRtcModule();
+#endif
}
#if !defined(CHROMIUM_SELINUX)
diff --git a/third_party/libjingle/libjingle.gyp b/third_party/libjingle/libjingle.gyp
index 1051fb1..fc2ee9e 100644
--- a/third_party/libjingle/libjingle.gyp
+++ b/third_party/libjingle/libjingle.gyp
@@ -627,6 +627,10 @@
],
},
'sources': [
+ 'overrides/init_webrtc.cc',
+ 'overrides/init_webrtc.h',
+ 'overrides/talk/media/webrtc/webrtcexport.h',
+
'<(libjingle_source)/talk/app/webrtc/audiotrack.cc',
'<(libjingle_source)/talk/app/webrtc/audiotrack.h',
'<(libjingle_source)/talk/app/webrtc/datachannel.cc',
@@ -642,12 +646,12 @@
'<(libjingle_source)/talk/app/webrtc/localaudiosource.h',
'<(libjingle_source)/talk/app/webrtc/localvideosource.cc',
'<(libjingle_source)/talk/app/webrtc/localvideosource.h',
+ '<(libjingle_source)/talk/app/webrtc/mediaconstraintsinterface.cc',
+ '<(libjingle_source)/talk/app/webrtc/mediaconstraintsinterface.h',
'<(libjingle_source)/talk/app/webrtc/mediastream.cc',
'<(libjingle_source)/talk/app/webrtc/mediastream.h',
'<(libjingle_source)/talk/app/webrtc/mediastreamhandler.cc',
'<(libjingle_source)/talk/app/webrtc/mediastreamhandler.h',
- '<(libjingle_source)/talk/app/webrtc/mediaconstraintsinterface.cc',
- '<(libjingle_source)/talk/app/webrtc/mediaconstraintsinterface.h',
'<(libjingle_source)/talk/app/webrtc/mediastreaminterface.h',
'<(libjingle_source)/talk/app/webrtc/mediastreamprovider.h',
'<(libjingle_source)/talk/app/webrtc/mediastreamproxy.h',
@@ -757,18 +761,10 @@
],
'conditions': [
['libpeer_allocator_shim==1 and '
- 'libpeer_target_type=="shared_library" and '
- 'component!="shared_library"', {
+ 'libpeer_target_type!="static_library" and OS!="mac"', {
'sources': [
'overrides/allocator_shim/allocator_stub.cc',
- ],
- 'sources/': [
- # |allocator_stub.cc| will include this file directly to ensure
- # that the stub code gets included with whatever depends on
- # peerconnectionfactory, also includes the stub code. If we
- # don't do that, the linker is free to discard the stub code
- # since it by itself does not have any dependencies.
- ['exclude', '<(libjingle_source)/talk/app/webrtc/peerconnectionfactory.cc'],
+ 'overrides/allocator_shim/allocator_stub.h',
],
}],
['enabled_libjingle_device_manager==1', {
@@ -852,7 +848,7 @@
'<(DEPTH)/third_party/webrtc/modules/modules.gyp:video_render_module',
'libjingle',
],
- }, # target libpeerconnection
+ }, # target libjingle_webrtc
{
'target_name': 'libpeerconnection',
'type': '<(libpeer_target_type)',
@@ -869,22 +865,25 @@
'<@(libjingle_peerconnection_additional_deps)',
'libjingle_webrtc',
],
- 'export_dependent_settings': [
- '<(DEPTH)/third_party/libjingle/libjingle.gyp:libjingle_webrtc',
- ],
'conditions': [
['libpeer_allocator_shim==1 and '
- 'libpeer_target_type=="shared_library" and '
- 'component!="shared_library"', {
+ 'libpeer_target_type!="static_library"', {
'sources': [
- 'overrides/allocator_shim/allocator_proxy.cc',
+ 'overrides/initialize_module.cc',
+ ],
+ 'conditions': [
+ ['OS!="mac"', {
+ 'sources': [
+ 'overrides/allocator_shim/allocator_proxy.cc',
+ ],
+ }],
],
}],
- ['"<(libpeer_target_type)"=="shared_library"', {
+ ['"<(libpeer_target_type)"!="static_library"', {
# Used to control symbol export/import.
'defines': [ 'LIBPEERCONNECTION_IMPLEMENTATION=1' ],
}],
- ['OS=="win" and "<(libpeer_target_type)"=="shared_library"', {
+ ['OS=="win" and "<(libpeer_target_type)"!="static_library"', {
'link_settings': {
'libraries': [
'-lsecur32.lib',
@@ -893,17 +892,30 @@
],
},
}],
- ['OS=="mac" and libpeer_target_type=="shared_library"', {
- 'xcode_settings': {
- 'DYLIB_INSTALL_NAME_BASE': '@loader_path/Libraries',
- },
+ ['OS!="win" and "<(libpeer_target_type)"!="static_library"', {
+ 'cflags': [
+ # For compatibility with how we export symbols from this
+ # target on Windows. This also prevents the linker from
+ # picking up symbols from this target that should be linked
+ # in from other libjingle libs.
+ '-fvisibility=hidden',
+ ],
+ }],
+ ['OS=="mac" and libpeer_target_type!="static_library"', {
'product_dir': '<(PRODUCT_DIR)/Libraries',
+ 'product_name': 'libpeerconnection',
}],
['OS=="android"', {
'standalone_static_library': 1,
}],
+ ['OS=="linux" and libpeer_target_type!="static_library"', {
+ # The installer and various tools depend on finding the .so
+ # in this directory and not lib.target as will otherwise be
+ # the case with make builds.
+ 'product_dir': '<(PRODUCT_DIR)/lib',
+ }],
],
- }, # target peerconnection
+ }, # target libpeerconnection
],
}],
],
diff --git a/third_party/libjingle/overrides/allocator_shim/allocator_proxy.cc b/third_party/libjingle/overrides/allocator_shim/allocator_proxy.cc
index 70215e9..d3f24e0 100644
--- a/third_party/libjingle/overrides/allocator_shim/allocator_proxy.cc
+++ b/third_party/libjingle/overrides/allocator_shim/allocator_proxy.cc
@@ -2,37 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <new>
+#include "allocator_shim/allocator_stub.h"
-#include "talk/base/basictypes.h"
-
-typedef void* (*AllocateFunction)(std::size_t);
-typedef void (*DellocateFunction)(void*);
-
-#ifndef LIBPEERCONNECTION_IMPLEMENTATION
+#if !defined(LIBPEERCONNECTION_IMPLEMENTATION) || defined(LIBPEERCONNECTION_LIB)
#error "Only compile the allocator proxy with the shared_library implementation"
#endif
-#ifdef WIN32
-#define ALLOC_EXPORT __declspec(dllexport)
-#else
-#define ALLOC_EXPORT __attribute__((visibility("default")))
+#if defined(OS_MACOSX)
+#error "The allocator proxy isn't supported (or needed) on mac."
#endif
-static AllocateFunction g_alloc = NULL;
-static DellocateFunction g_dealloc = NULL;
-
-// This function will be called by the client code to initialize the allocator
-// routines (see allocator_stub.cc).
-ALLOC_EXPORT
-bool SetProxyAllocator(AllocateFunction alloc, DellocateFunction dealloc) {
- g_alloc = alloc;
- g_dealloc = dealloc;
- return true;
-}
+extern AllocateFunction g_alloc;
+extern DellocateFunction g_dealloc;
// Override the global new/delete routines and proxy them over to the allocator
-// routines handed to us via SetProxyAllocator.
+// routines handed to us via InitializeModule.
void* operator new(std::size_t n) throw() {
return g_alloc(n);
diff --git a/third_party/libjingle/overrides/allocator_shim/allocator_stub.cc b/third_party/libjingle/overrides/allocator_shim/allocator_stub.cc
index 1e23d82..28ea658 100644
--- a/third_party/libjingle/overrides/allocator_shim/allocator_stub.cc
+++ b/third_party/libjingle/overrides/allocator_shim/allocator_stub.cc
@@ -2,59 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <new>
+#include "allocator_shim/allocator_stub.h"
-#include "talk/base/basictypes.h"
-
-
-typedef void* (*AllocateFunction)(std::size_t);
-typedef void (*DellocateFunction)(void*);
-
-#ifdef LIBPEERCONNECTION_IMPLEMENTATION
-#error "Only compile the allocator stub with the client implementation"
-#endif
-
-#ifdef WIN32
-#define ALLOC_IMPORT __declspec(dllimport)
-#else
-#define ALLOC_IMPORT
+#if defined(OS_MACOSX)
+#error "The allocator stub isn't supported (or needed) on mac."
#endif
-// The stub implementations that forward new / delete calls to the allocator
-// in the current binary (usually tcmalloc).
-
-static void* Allocate(std::size_t n) {
+void* Allocate(std::size_t n) {
return operator new(n);
}
-static void Dellocate(void* p) {
+void Dellocate(void* p) {
return operator delete(p);
}
-
-ALLOC_IMPORT
-bool SetProxyAllocator(AllocateFunction a, DellocateFunction d);
-
-// Initialize the proxy by supplying it with a pointer to our
-// allocator/deallocator routines.
-// This unfortunately costs a single static initializer. The alternatives
-// are:
-// * A circular reference from libjingle back to chrome (or any other binary)
-// * Reworking libjingle interfaces to not use stl types in classinterfaces.
-// This is currently not feasible.
-// * Hack internal peerconnectionfactory implementation details such as
-// PeerConnectionFactory::Initialize to initialize the proxy. While possible,
-// this would be very prone to regressions due to any changes in the libjingle
-// library.
-// * Make modifications to libjingle to support initializing the proxy when
-// needed. I'm (tommi) currently working on this.
-static const bool proxy_allocator_initialized =
- SetProxyAllocator(&Allocate, &Dellocate);
-
-// Include the implementation of peerconnectionfactory.cc here.
-// This is done to ensure that the stub initialization code and
-// peerconnectionfactory belong to the same object file. That way the
-// linker cannot discard the necessary stub initialization code that goes with
-// the factory, even though there aren't any explicit dependencies.
-// See libjingle.gyp for how we exclude peerconnectionfactory.cc from the
-// target in this case.
-#include "talk/app/webrtc/peerconnectionfactory.cc"
diff --git a/third_party/libjingle/overrides/allocator_shim/allocator_stub.h b/third_party/libjingle/overrides/allocator_shim/allocator_stub.h
new file mode 100644
index 0000000..9e0fc2f
--- /dev/null
+++ b/third_party/libjingle/overrides/allocator_shim/allocator_stub.h
@@ -0,0 +1,24 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_LIBJINGLE_OVERRIDES_ALLOCATOR_SHIM_ALLOCATOR_STUB_H_
+#define THIRD_PARTY_LIBJINGLE_OVERRIDES_ALLOCATOR_SHIM_ALLOCATOR_STUB_H_
+
+#include <new>
+
+#include "base/basictypes.h"
+
+#if !defined(OS_MACOSX)
+
+typedef void* (*AllocateFunction)(std::size_t);
+typedef void (*DellocateFunction)(void*);
+
+// The stub implementations that forward new / delete calls to the allocator
+// in the current binary (i.e. tcmalloc).
+void* Allocate(std::size_t n);
+void Dellocate(void* p);
+
+#endif // OS_MACOSX
+
+#endif // THIRD_PARTY_LIBJINGLE_OVERRIDES_ALLOCATOR_SHIM_ALLOCATOR_STUB_H_
diff --git a/third_party/libjingle/overrides/init_webrtc.cc b/third_party/libjingle/overrides/init_webrtc.cc
new file mode 100644
index 0000000..c73b270
--- /dev/null
+++ b/third_party/libjingle/overrides/init_webrtc.cc
@@ -0,0 +1,100 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "init_webrtc.h"
+
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "base/native_library.h"
+#include "base/path_service.h"
+#include "talk/base/basictypes.h"
+
+#if defined(LIBPEERCONNECTION_LIB)
+
+// libpeerconnection is being compiled as a static lib. In this case
+// we don't need to do any initializing but to keep things simple we
+// provide an empty intialization routine so that this #ifdef doesn't
+// have to be in other places.
+bool InitializeWebRtcModule() {
+ return true;
+}
+
+#else // !LIBPEERCONNECTION_LIB
+
+// When being compiled as a shared library, we need to bridge the gap between
+// the current module and the libpeerconnection module, so things get a tad
+// more complicated.
+
+// 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;
+
+// Returns the full or relative path to the libpeerconnection module depending
+// on what platform we're on.
+static base::FilePath GetLibPeerConnectionPath() {
+#if defined(OS_WIN)
+ base::FilePath path(FILE_PATH_LITERAL("libpeerconnection.dll"));
+#elif defined(OS_MACOSX)
+ // Simulate '@loader_path/Libraries'.
+ base::FilePath path;
+ CHECK(PathService::Get(base::DIR_MODULE, &path));
+ path = path.Append(FILE_PATH_LITERAL("Libraries"))
+ .Append(FILE_PATH_LITERAL("libpeerconnection.so"));
+#else
+ base::FilePath path;
+ CHECK(PathService::Get(base::DIR_MODULE, &path));
+ path = path.Append(FILE_PATH_LITERAL("lib"))
+ .Append(FILE_PATH_LITERAL("libpeerconnection.so"));
+#endif
+ return path;
+}
+
+bool InitializeWebRtcModule() {
+ if (g_create_webrtc_media_engine)
+ return true; // InitializeWebRtcModule has already been called.
+
+ base::FilePath path(GetLibPeerConnectionPath());
+ DVLOG(1) << "Loading WebRTC module: " << path.value();
+
+ std::string error;
+ static base::NativeLibrary lib =
+ base::LoadNativeLibrary(path, &error);
+ CHECK(lib);
+
+ InitializeModuleFunction initialize_module =
+ reinterpret_cast<InitializeModuleFunction>(
+ base::GetFunctionPointerFromNativeLibrary(
+ lib, "InitializeModule"));
+
+ // Initialize the proxy by supplying it with a pointer to our
+ // allocator/deallocator routines.
+ // On mac we use malloc zones, which are global, so we provide NULLs for
+ // the alloc/dealloc functions.
+ // PS: This function is actually implemented in allocator_proxy.cc with the
+ // new/delete overrides.
+ return initialize_module(*CommandLine::ForCurrentProcess(),
+#if !defined(OS_MACOSX)
+ &Allocate, &Dellocate,
+#endif
+ &g_create_webrtc_media_engine, &g_destroy_webrtc_media_engine);
+}
+
+cricket::MediaEngineInterface* CreateWebRtcMediaEngine(
+ webrtc::AudioDeviceModule* adm,
+ webrtc::AudioDeviceModule* adm_sc,
+ cricket::WebRtcVideoDecoderFactory* decoder_factory) {
+ // For convenience of tests etc, we call InitializeWebRtcModule here.
+ // For Chrome however, InitializeWebRtcModule must be called
+ // explicitly before the sandbox is initialized. In that case, this call is
+ // effectively a noop.
+ InitializeWebRtcModule();
+ return g_create_webrtc_media_engine(adm, adm_sc, decoder_factory);
+}
+
+void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) {
+ g_destroy_webrtc_media_engine(media_engine);
+}
+
+#endif // LIBPEERCONNECTION_LIB
diff --git a/third_party/libjingle/overrides/init_webrtc.h b/third_party/libjingle/overrides/init_webrtc.h
new file mode 100644
index 0000000..bcf3268
--- /dev/null
+++ b/third_party/libjingle/overrides/init_webrtc.h
@@ -0,0 +1,50 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_LIBJINGLE_OVERRIDES_INIT_WEBRTC_H_
+#define THIRD_PARTY_LIBJINGLE_OVERRIDES_INIT_WEBRTC_H_
+
+#include "allocator_shim/allocator_stub.h"
+
+class CommandLine;
+
+namespace cricket {
+class MediaEngineInterface;
+class WebRtcVideoDecoderFactory;
+} // namespace cricket
+
+namespace webrtc {
+class AudioDeviceModule;
+} // namespace webrtc
+
+typedef cricket::MediaEngineInterface* (*CreateWebRtcMediaEngineFunction)(
+ webrtc::AudioDeviceModule* adm,
+ webrtc::AudioDeviceModule* adm_sc,
+ cricket::WebRtcVideoDecoderFactory* decoder_factory);
+
+typedef void (*DestroyWebRtcMediaEngineFunction)(
+ cricket::MediaEngineInterface* media_engine);
+
+// 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.
+// The reason we get pointers to these functions this way is to avoid having
+// to go through GetProcAddress et al and rely on specific name mangling.
+typedef bool (*InitializeModuleFunction)(
+ const CommandLine& command_line,
+#if !defined(OS_MACOSX)
+ AllocateFunction alloc,
+ DellocateFunction dealloc,
+#endif
+ CreateWebRtcMediaEngineFunction* create_media_engine,
+ DestroyWebRtcMediaEngineFunction* destroy_media_engine);
+
+// Load and initialize the shared WebRTC module (libpeerconnection).
+// Call this explicitly to load and initialize the WebRTC module (e.g. before
+// initializing the sandbox in Chrome).
+// If not called explicitly, this function will still be called from the main
+// CreateWebRtcMediaEngine factory function the first time it is called.
+bool InitializeWebRtcModule();
+
+#endif // THIRD_PARTY_LIBJINGLE_OVERRIDES_INIT_WEBRTC_H_
diff --git a/third_party/libjingle/overrides/initialize_module.cc b/third_party/libjingle/overrides/initialize_module.cc
new file mode 100644
index 0000000..8c70f4f
--- /dev/null
+++ b/third_party/libjingle/overrides/initialize_module.cc
@@ -0,0 +1,81 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "allocator_shim/allocator_stub.h"
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "talk/base/basictypes.h"
+#include "talk/media/webrtc/webrtcmediaengine.h"
+
+#if !defined(LIBPEERCONNECTION_IMPLEMENTATION) || defined(LIBPEERCONNECTION_LIB)
+#error "Only compile the allocator proxy with the shared_library implementation"
+#endif
+
+#if defined(OS_WIN)
+#define ALLOC_EXPORT __declspec(dllexport)
+#else
+#define ALLOC_EXPORT __attribute__((visibility("default")))
+#endif
+
+typedef cricket::MediaEngineInterface* (*CreateWebRtcMediaEngineFunction)(
+ webrtc::AudioDeviceModule* adm,
+ webrtc::AudioDeviceModule* adm_sc,
+ cricket::WebRtcVideoDecoderFactory* decoder_factory);
+typedef void (*DestroyWebRtcMediaEngineFunction)(
+ cricket::MediaEngineInterface* media_engine);
+
+#if !defined(OS_MACOSX)
+// These are used by our new/delete overrides in
+// allocator_shim/allocator_proxy.cc
+AllocateFunction g_alloc = NULL;
+DellocateFunction g_dealloc = NULL;
+#endif
+
+// Forward declare of the libjingle internal factory and destroy methods for the
+// WebRTC media engine.
+cricket::MediaEngineInterface* CreateWebRtcMediaEngine(
+ webrtc::AudioDeviceModule* adm, webrtc::AudioDeviceModule* adm_sc,
+ cricket::WebRtcVideoDecoderFactory* decoder_factory);
+
+void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine);
+
+extern "C" {
+
+// Initialize logging, set the forward allocator functions (not on mac), and
+// return pointers to libjingle's WebRTC factory methods.
+// Called from init_webrtc.cc.
+ALLOC_EXPORT
+bool InitializeModule(const CommandLine& command_line,
+#if !defined(OS_MACOSX)
+ AllocateFunction alloc,
+ DellocateFunction dealloc,
+#endif
+ CreateWebRtcMediaEngineFunction* create_media_engine,
+ DestroyWebRtcMediaEngineFunction* destroy_media_engine) {
+#if !defined(OS_MACOSX)
+ g_alloc = alloc;
+ g_dealloc = dealloc;
+#endif
+
+ *create_media_engine = &CreateWebRtcMediaEngine;
+ *destroy_media_engine = &DestroyWebRtcMediaEngine;
+
+ if (CommandLine::Init(0, NULL)) {
+#if !defined(OS_WIN)
+ // This is not needed on Windows since CommandLine::Init has already
+ // done the equivalent thing via the GetCommandLine() API.
+ CommandLine::ForCurrentProcess()->AppendArguments(command_line, true);
+#endif
+ logging::InitLogging(
+ FILE_PATH_LITERAL("libpeerconnection.log"),
+ logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG,
+ logging::LOCK_LOG_FILE,
+ logging::APPEND_TO_OLD_LOG_FILE,
+ logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
+ }
+
+ return true;
+}
+} // extern "C"
diff --git a/third_party/libjingle/overrides/talk/media/webrtc/webrtcexport.h b/third_party/libjingle/overrides/talk/media/webrtc/webrtcexport.h
new file mode 100644
index 0000000..ffa60bb
--- /dev/null
+++ b/third_party/libjingle/overrides/talk/media/webrtc/webrtcexport.h
@@ -0,0 +1,21 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is overridden to disable exports and imports in libjingle
+// between the libpeerconnection and libjingle_webrtc targets.
+// TODO(tommi): Remove when a version of libjingle has been rolled in that
+// either removes this header file or offers an easy way to turn this off.
+
+#ifndef TALK_MEDIA_WEBRTC_WEBRTCEXPORT_H_
+#define TALK_MEDIA_WEBRTC_WEBRTCEXPORT_H_
+
+#ifndef NON_EXPORTED_BASE
+#define NON_EXPORTED_BASE(code) code
+#endif // NON_EXPORTED_BASE
+
+#ifndef WRME_EXPORT
+#define WRME_EXPORT
+#endif
+
+#endif // TALK_MEDIA_WEBRTC_WEBRTCEXPORT_H_