Commit de10703e authored by tommi's avatar tommi Committed by Commit bot

Remove unused libpeerconnection code.

This removes boilerplate code that was used when we supported building libpeerconnection as a shared library.  We don't support that any longer, so it's safe to delete.

BUG=463660

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

Cr-Commit-Position: refs/heads/master@{#330783}
parent 87389cc0
......@@ -329,8 +329,6 @@
'defines': [ 'LIBPEERCONNECTION_LIB=1' ],
},
'sources': [
'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/audiotrackrenderer.cc',
......
// 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 "third_party/libjingle/overrides/allocator_shim/allocator_stub.h"
#if !defined(LIBPEERCONNECTION_IMPLEMENTATION) || defined(LIBPEERCONNECTION_LIB)
#error "Only compile the allocator proxy with the shared_library implementation"
#endif
#if defined(OS_MACOSX) || defined(OS_ANDROID)
#error "The allocator proxy isn't supported (or needed) on mac or android."
#endif
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 InitializeModule.
void* operator new(std::size_t n) throw() {
return g_alloc(n);
}
void operator delete(void* p) throw() {
g_dealloc(p);
}
// 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 "third_party/libjingle/overrides/allocator_shim/allocator_stub.h"
#if defined(OS_MACOSX) || defined(OS_ANDROID)
#error "The allocator stub isn't supported (or needed) on mac or android."
#endif
void* Allocate(std::size_t n) {
return operator new(n);
}
void Dellocate(void* p) {
return operator delete(p);
}
// 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) && !defined(OS_ANDROID)
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 && OS_ANDROID
#endif // THIRD_PARTY_LIBJINGLE_OVERRIDES_ALLOCATOR_SHIM_ALLOCATOR_STUB_H_
......@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/native_library.h"
......@@ -14,6 +15,7 @@
#include "base/trace_event/trace_event.h"
#include "third_party/webrtc/overrides/webrtc/base/basictypes.h"
#include "third_party/webrtc/overrides/webrtc/base/logging.h"
#include "third_party/webrtc/system_wrappers/interface/event_tracer.h"
const unsigned char* GetCategoryGroupEnabled(const char* category_group) {
return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group);
......@@ -44,6 +46,12 @@ std::string FindFullName(const std::string& trial_name) {
// Define webrtc::metrics functions to provide webrtc with implementations.
namespace metrics {
// This class doesn't actually exist, so don't go looking for it :)
// This type is just fwd declared here in order to use it as an opaque type
// between the Histogram functions in this file.
class Histogram;
Histogram* HistogramFactoryGetCounts(
const std::string& name, int min, int max, int bucket_count) {
return reinterpret_cast<Histogram*>(
......@@ -69,8 +77,6 @@ void HistogramAdd(
} // namespace metrics
} // namespace webrtc
#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
......@@ -79,115 +85,3 @@ bool InitializeWebRtcModule() {
webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent);
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() {
base::FilePath path;
CHECK(PathService::Get(base::DIR_MODULE, &path));
#if defined(OS_WIN)
path = path.Append(FILE_PATH_LITERAL("libpeerconnection.dll"));
#elif defined(OS_MACOSX)
// Simulate '@loader_path/Libraries'.
path = path.Append(FILE_PATH_LITERAL("Libraries"))
.Append(FILE_PATH_LITERAL("libpeerconnection.so"));
#elif defined(OS_ANDROID)
path = path.Append(FILE_PATH_LITERAL("libpeerconnection.so"));
#else
path = path.Append(FILE_PATH_LITERAL("lib"))
.Append(FILE_PATH_LITERAL("libpeerconnection.so"));
#endif
return path;
}
bool InitializeWebRtcModule() {
TRACE_EVENT0("webrtc", "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();
base::NativeLibraryLoadError error;
static base::NativeLibrary lib = base::LoadNativeLibrary(path, &error);
#if defined(OS_WIN)
// We've been seeing problems on Windows with loading the DLL and we're
// not sure exactly why. It could be that AV programs are quarantining the
// file or disallowing loading the DLL. To get a better picture of the errors
// we're checking these specific error codes.
if (error.code == ERROR_MOD_NOT_FOUND) {
// It's possible that we get this error due to failure to load other
// dependencies, so check first that libpeerconnection actually exists.
CHECK(base::PathExists(path)); // libpeerconnection itself is missing.
CHECK(lib); // If we hit this, a dependency is missing.
} else if (error.code == ERROR_ACCESS_DENIED) {
CHECK(lib); // AV blocking access?
}
#endif
// Catch-all error handler for all other sorts of errors.
CHECK(lib) << error.ToString();
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.
InitDiagnosticLoggingDelegateFunctionFunction init_diagnostic_logging = NULL;
bool init_ok = initialize_module(*base::CommandLine::ForCurrentProcess(),
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
&Allocate,
&Dellocate,
#endif
&webrtc::field_trial::FindFullName,
&webrtc::metrics::HistogramFactoryGetCounts,
&webrtc::metrics::HistogramFactoryGetEnumeration,
&webrtc::metrics::HistogramAdd,
logging::GetLogMessageHandler(),
&GetCategoryGroupEnabled,
&AddTraceEvent,
&g_create_webrtc_media_engine,
&g_destroy_webrtc_media_engine,
&init_diagnostic_logging);
if (init_ok)
rtc::SetExtraLoggingInit(init_diagnostic_logging);
return init_ok;
}
cricket::MediaEngineInterface* CreateWebRtcMediaEngine(
webrtc::AudioDeviceModule* adm,
webrtc::AudioDeviceModule* adm_sc,
cricket::WebRtcVideoEncoderFactory* encoder_factory,
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, encoder_factory,
decoder_factory);
}
void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) {
g_destroy_webrtc_media_engine(media_engine);
}
#endif // LIBPEERCONNECTION_LIB
......@@ -5,82 +5,9 @@
#ifndef THIRD_PARTY_LIBJINGLE_OVERRIDES_INIT_WEBRTC_H_
#define THIRD_PARTY_LIBJINGLE_OVERRIDES_INIT_WEBRTC_H_
#include <string>
#include "third_party/libjingle/overrides/allocator_shim/allocator_stub.h"
#include "base/logging.h"
#include "third_party/webrtc/system_wrappers/interface/event_tracer.h"
namespace base {
class CommandLine;
}
namespace cricket {
class MediaEngineInterface;
class WebRtcVideoDecoderFactory;
class WebRtcVideoEncoderFactory;
} // namespace cricket
namespace webrtc {
class AudioDeviceModule;
namespace metrics {
class Histogram;
} // namespace metrics
} // namespace webrtc
typedef std::string (*FieldTrialFindFullName)(const std::string& trial_name);
typedef webrtc::metrics::Histogram* (*RtcHistogramFactoryGetCounts)(
const std::string& name, int min, int max, int bucket_count);
typedef webrtc::metrics::Histogram* (*RtcHistogramFactoryGetEnumeration)(
const std::string& name, int boundary);
typedef void (*RtcHistogramAdd)(
webrtc::metrics::Histogram* histogram_pointer,
const std::string& name,
int sample);
typedef cricket::MediaEngineInterface* (*CreateWebRtcMediaEngineFunction)(
webrtc::AudioDeviceModule* adm,
webrtc::AudioDeviceModule* adm_sc,
cricket::WebRtcVideoEncoderFactory* encoder_factory,
cricket::WebRtcVideoDecoderFactory* decoder_factory);
typedef void (*DestroyWebRtcMediaEngineFunction)(
cricket::MediaEngineInterface* media_engine);
typedef void (*InitDiagnosticLoggingDelegateFunctionFunction)(
void (*DelegateFunction)(const std::string&));
// 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.
// TODO(tommi): The number of functions is growing. Use a struct.
typedef bool (*InitializeModuleFunction)(
const base::CommandLine& command_line,
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
AllocateFunction alloc,
DellocateFunction dealloc,
#endif
FieldTrialFindFullName field_trial_find,
RtcHistogramFactoryGetCounts factory_get_counts,
RtcHistogramFactoryGetEnumeration factory_get_enumeration,
RtcHistogramAdd histogram_add,
logging::LogMessageHandlerFunction log_handler,
webrtc::GetCategoryEnabledPtr trace_get_category_enabled,
webrtc::AddTraceEventPtr trace_add_trace_event,
CreateWebRtcMediaEngineFunction* create_media_engine,
DestroyWebRtcMediaEngineFunction* destroy_media_engine,
InitDiagnosticLoggingDelegateFunctionFunction* init_diagnostic_logging);
#if !defined(LIBPEERCONNECTION_IMPLEMENTATION)
// 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.
// Initialize WebRTC. Call this explicitly to initialize WebRTC module
// (before initializing the sandbox in Chrome) and hook up Chrome+WebRTC
// integration such as common logging and tracing.
bool InitializeWebRtcModule();
#endif
#endif // THIRD_PARTY_LIBJINGLE_OVERRIDES_INIT_WEBRTC_H_
// 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.
#if defined(OS_WIN) && defined(ARCH_CPU_X86_64)
#include <math.h> // needed for _set_FMA3_enable
#endif // WIN && ARCH_CPU_X86_64
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "third_party/libjingle/source/talk/media/webrtc/webrtcmediaengine.h"
#include "third_party/libjingle/allocator_shim/allocator_stub.h"
#include "third_party/libjingle/overrides/init_webrtc.h"
#include "third_party/webrtc/base/basictypes.h"
#include "third_party/webrtc/base/logging.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
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
// 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::WebRtcVideoEncoderFactory* encoder_factory,
cricket::WebRtcVideoDecoderFactory* decoder_factory);
void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine);
namespace {
// Provide webrtc with a field trial and metrics implementations.
// The implementations are provided by the loader via the InitializeModule.
// Defines webrtc::field_trial::FindFullName.
FieldTrialFindFullName g_field_trial_find_ = NULL;
// Defines webrtc::metrics::RtcFactoryGetCounts.
RtcHistogramFactoryGetCounts g_factory_get_counts = NULL;
// Defines webrtc::metrics::RtcFactoryGetEnumeration.
RtcHistogramFactoryGetEnumeration g_factory_get_enumeration = NULL;
// Defines webrtc::metrics::RtcAdd.
RtcHistogramAdd g_histogram_add = NULL;
}
namespace webrtc {
namespace field_trial {
std::string FindFullName(const std::string& trial_name) {
return g_field_trial_find_(trial_name);
}
} // namespace field_trial
namespace metrics {
Histogram* HistogramFactoryGetCounts(
const std::string& name, int min, int max, int bucket_count) {
return g_factory_get_counts(name, min, max, bucket_count);
}
Histogram* HistogramFactoryGetEnumeration(
const std::string& name, int boundary) {
return g_factory_get_enumeration(name, boundary);
}
void HistogramAdd(
Histogram* histogram_pointer, const std::string& name, int sample) {
g_histogram_add(histogram_pointer, name, sample);
}
} // namespace metrics
} // namespace webrtc
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 base::CommandLine& command_line,
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
AllocateFunction alloc,
DellocateFunction dealloc,
#endif
FieldTrialFindFullName field_trial_find,
RtcHistogramFactoryGetCounts factory_get_counts,
RtcHistogramFactoryGetEnumeration factory_get_enumeration,
RtcHistogramAdd histogram_add,
logging::LogMessageHandlerFunction log_handler,
webrtc::GetCategoryEnabledPtr trace_get_category_enabled,
webrtc::AddTraceEventPtr trace_add_trace_event,
CreateWebRtcMediaEngineFunction* create_media_engine,
DestroyWebRtcMediaEngineFunction* destroy_media_engine,
InitDiagnosticLoggingDelegateFunctionFunction*
init_diagnostic_logging) {
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
g_alloc = alloc;
g_dealloc = dealloc;
#endif
g_field_trial_find_ = field_trial_find;
g_factory_get_counts = factory_get_counts;
g_factory_get_enumeration = factory_get_enumeration;
g_histogram_add = histogram_add;
*create_media_engine = &CreateWebRtcMediaEngine;
*destroy_media_engine = &DestroyWebRtcMediaEngine;
*init_diagnostic_logging = &rtc::InitDiagnosticLoggingDelegateFunction;
#if defined(OS_WIN) && defined(ARCH_CPU_X86_64)
// VS2013 only checks the existence of FMA3 instructions, not the enabled-ness
// of them at the OS level (this is fixed in VS2015). We force off usage of
// FMA3 instructions in the CRT to avoid using that path and hitting illegal
// instructions when running on CPUs that support FMA3, but OSs that don't.
// See http://crbug.com/436603 and http://crbug.com/446983.
_set_FMA3_enable(0);
#endif // WIN && ARCH_CPU_X86_64
if (base::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.
base::CommandLine::ForCurrentProcess()->AppendArguments(command_line, true);
#endif
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
logging::InitLogging(settings);
// Override the log message handler to forward logs to chrome's handler.
logging::SetLogMessageHandler(log_handler);
webrtc::SetupEventTracer(trace_get_category_enabled,
trace_add_trace_event);
}
return true;
}
} // extern "C"
// 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_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment