| OLD | NEW |
| 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 "allocator_shim/allocator_stub.h" | 5 #include "allocator_shim/allocator_stub.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "init_webrtc.h" | 9 #include "init_webrtc.h" |
| 10 #include "talk/media/webrtc/webrtcmediaengine.h" | 10 #include "talk/media/webrtc/webrtcmediaengine.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // Forward declare of the libjingle internal factory and destroy methods for the | 31 // Forward declare of the libjingle internal factory and destroy methods for the |
| 32 // WebRTC media engine. | 32 // WebRTC media engine. |
| 33 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( | 33 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( |
| 34 webrtc::AudioDeviceModule* adm, | 34 webrtc::AudioDeviceModule* adm, |
| 35 webrtc::AudioDeviceModule* adm_sc, | 35 webrtc::AudioDeviceModule* adm_sc, |
| 36 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 36 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 37 cricket::WebRtcVideoDecoderFactory* decoder_factory); | 37 cricket::WebRtcVideoDecoderFactory* decoder_factory); |
| 38 | 38 |
| 39 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine); | 39 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine); |
| 40 | 40 |
| 41 // Define webrtc:field_trial::FindFullName to provide webrtc with a field trial | |
| 42 // implementation. The implementation is provided by the loader via the | |
| 43 // InitializeModule. | |
| 44 namespace { | 41 namespace { |
| 42 // Provide webrtc with a field trial and metrics implementations. |
| 43 // The implementations are provided by the loader via the InitializeModule. |
| 44 |
| 45 // Defines webrtc::field_trial::FindFullName. |
| 45 FieldTrialFindFullName g_field_trial_find_ = NULL; | 46 FieldTrialFindFullName g_field_trial_find_ = NULL; |
| 47 // Defines webrtc::metrics::RtcFactoryGetCounts. |
| 48 RtcHistogramFactoryGetCounts g_factory_get_counts = NULL; |
| 49 // Defines webrtc::metrics::RtcFactoryGetEnumeration. |
| 50 RtcHistogramFactoryGetEnumeration g_factory_get_enumeration = NULL; |
| 51 // Defines webrtc::metrics::RtcAdd. |
| 52 RtcHistogramAdd g_histogram_add = NULL; |
| 46 } | 53 } |
| 47 | 54 |
| 48 namespace webrtc { | 55 namespace webrtc { |
| 49 namespace field_trial { | 56 namespace field_trial { |
| 50 std::string FindFullName(const std::string& trial_name) { | 57 std::string FindFullName(const std::string& trial_name) { |
| 51 return g_field_trial_find_(trial_name); | 58 return g_field_trial_find_(trial_name); |
| 52 } | 59 } |
| 53 } // namespace field_trial | 60 } // namespace field_trial |
| 61 |
| 62 namespace metrics { |
| 63 Histogram* HistogramFactoryGetCounts( |
| 64 const std::string& name, int min, int max, int bucket_count) { |
| 65 return g_factory_get_counts(name, min, max, bucket_count); |
| 66 } |
| 67 |
| 68 Histogram* HistogramFactoryGetEnumeration( |
| 69 const std::string& name, int boundary) { |
| 70 return g_factory_get_enumeration(name, boundary); |
| 71 } |
| 72 |
| 73 void HistogramAdd( |
| 74 Histogram* histogram_pointer, const std::string& name, int sample) { |
| 75 g_histogram_add(histogram_pointer, name, sample); |
| 76 } |
| 77 } // namespace metrics |
| 54 } // namespace webrtc | 78 } // namespace webrtc |
| 55 | 79 |
| 56 extern "C" { | 80 extern "C" { |
| 57 | 81 |
| 58 // Initialize logging, set the forward allocator functions (not on mac), and | 82 // Initialize logging, set the forward allocator functions (not on mac), and |
| 59 // return pointers to libjingle's WebRTC factory methods. | 83 // return pointers to libjingle's WebRTC factory methods. |
| 60 // Called from init_webrtc.cc. | 84 // Called from init_webrtc.cc. |
| 61 ALLOC_EXPORT | 85 ALLOC_EXPORT |
| 62 bool InitializeModule(const CommandLine& command_line, | 86 bool InitializeModule(const CommandLine& command_line, |
| 63 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 87 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 64 AllocateFunction alloc, | 88 AllocateFunction alloc, |
| 65 DellocateFunction dealloc, | 89 DellocateFunction dealloc, |
| 66 #endif | 90 #endif |
| 67 FieldTrialFindFullName field_trial_find, | 91 FieldTrialFindFullName field_trial_find, |
| 92 RtcHistogramFactoryGetCounts factory_get_counts, |
| 93 RtcHistogramFactoryGetEnumeration factory_get_enumeration, |
| 94 RtcHistogramAdd histogram_add, |
| 68 logging::LogMessageHandlerFunction log_handler, | 95 logging::LogMessageHandlerFunction log_handler, |
| 69 webrtc::GetCategoryEnabledPtr trace_get_category_enabled, | 96 webrtc::GetCategoryEnabledPtr trace_get_category_enabled, |
| 70 webrtc::AddTraceEventPtr trace_add_trace_event, | 97 webrtc::AddTraceEventPtr trace_add_trace_event, |
| 71 CreateWebRtcMediaEngineFunction* create_media_engine, | 98 CreateWebRtcMediaEngineFunction* create_media_engine, |
| 72 DestroyWebRtcMediaEngineFunction* destroy_media_engine, | 99 DestroyWebRtcMediaEngineFunction* destroy_media_engine, |
| 73 InitDiagnosticLoggingDelegateFunctionFunction* | 100 InitDiagnosticLoggingDelegateFunctionFunction* |
| 74 init_diagnostic_logging) { | 101 init_diagnostic_logging) { |
| 75 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 102 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 76 g_alloc = alloc; | 103 g_alloc = alloc; |
| 77 g_dealloc = dealloc; | 104 g_dealloc = dealloc; |
| 78 #endif | 105 #endif |
| 79 | 106 |
| 80 g_field_trial_find_ = field_trial_find; | 107 g_field_trial_find_ = field_trial_find; |
| 108 g_factory_get_counts = factory_get_counts; |
| 109 g_factory_get_enumeration = factory_get_enumeration; |
| 110 g_histogram_add = histogram_add; |
| 81 | 111 |
| 82 *create_media_engine = &CreateWebRtcMediaEngine; | 112 *create_media_engine = &CreateWebRtcMediaEngine; |
| 83 *destroy_media_engine = &DestroyWebRtcMediaEngine; | 113 *destroy_media_engine = &DestroyWebRtcMediaEngine; |
| 84 *init_diagnostic_logging = &rtc::InitDiagnosticLoggingDelegateFunction; | 114 *init_diagnostic_logging = &rtc::InitDiagnosticLoggingDelegateFunction; |
| 85 | 115 |
| 86 if (CommandLine::Init(0, NULL)) { | 116 if (CommandLine::Init(0, NULL)) { |
| 87 #if !defined(OS_WIN) | 117 #if !defined(OS_WIN) |
| 88 // This is not needed on Windows since CommandLine::Init has already | 118 // This is not needed on Windows since CommandLine::Init has already |
| 89 // done the equivalent thing via the GetCommandLine() API. | 119 // done the equivalent thing via the GetCommandLine() API. |
| 90 CommandLine::ForCurrentProcess()->AppendArguments(command_line, true); | 120 CommandLine::ForCurrentProcess()->AppendArguments(command_line, true); |
| 91 #endif | 121 #endif |
| 92 logging::LoggingSettings settings; | 122 logging::LoggingSettings settings; |
| 93 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 123 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 94 logging::InitLogging(settings); | 124 logging::InitLogging(settings); |
| 95 | 125 |
| 96 // Override the log message handler to forward logs to chrome's handler. | 126 // Override the log message handler to forward logs to chrome's handler. |
| 97 logging::SetLogMessageHandler(log_handler); | 127 logging::SetLogMessageHandler(log_handler); |
| 98 webrtc::SetupEventTracer(trace_get_category_enabled, | 128 webrtc::SetupEventTracer(trace_get_category_enabled, |
| 99 trace_add_trace_event); | 129 trace_add_trace_event); |
| 100 } | 130 } |
| 101 | 131 |
| 102 return true; | 132 return true; |
| 103 } | 133 } |
| 104 } // extern "C" | 134 } // extern "C" |
| OLD | NEW |