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/base/basictypes.h" | 10 #include "talk/base/basictypes.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 { |
| 45 FieldTrialFindFullName g_field_trial_find_ = NULL; |
| 46 } |
| 47 |
| 48 namespace webrtc { |
| 49 namespace field_trial { |
| 50 std::string FindFullName(const std::string& trial_name) { |
| 51 return g_field_trial_find_(trial_name); |
| 52 } |
| 53 } // namespace field_trial |
| 54 } // namespace webrtc |
| 55 |
41 extern "C" { | 56 extern "C" { |
42 | 57 |
43 // Initialize logging, set the forward allocator functions (not on mac), and | 58 // Initialize logging, set the forward allocator functions (not on mac), and |
44 // return pointers to libjingle's WebRTC factory methods. | 59 // return pointers to libjingle's WebRTC factory methods. |
45 // Called from init_webrtc.cc. | 60 // Called from init_webrtc.cc. |
46 ALLOC_EXPORT | 61 ALLOC_EXPORT |
47 bool InitializeModule(const CommandLine& command_line, | 62 bool InitializeModule(const CommandLine& command_line, |
48 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 63 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
49 AllocateFunction alloc, | 64 AllocateFunction alloc, |
50 DellocateFunction dealloc, | 65 DellocateFunction dealloc, |
51 #endif | 66 #endif |
| 67 FieldTrialFindFullName field_trial_find, |
52 logging::LogMessageHandlerFunction log_handler, | 68 logging::LogMessageHandlerFunction log_handler, |
53 webrtc::GetCategoryEnabledPtr trace_get_category_enabled, | 69 webrtc::GetCategoryEnabledPtr trace_get_category_enabled, |
54 webrtc::AddTraceEventPtr trace_add_trace_event, | 70 webrtc::AddTraceEventPtr trace_add_trace_event, |
55 CreateWebRtcMediaEngineFunction* create_media_engine, | 71 CreateWebRtcMediaEngineFunction* create_media_engine, |
56 DestroyWebRtcMediaEngineFunction* destroy_media_engine, | 72 DestroyWebRtcMediaEngineFunction* destroy_media_engine, |
57 InitDiagnosticLoggingDelegateFunctionFunction* | 73 InitDiagnosticLoggingDelegateFunctionFunction* |
58 init_diagnostic_logging) { | 74 init_diagnostic_logging) { |
59 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 75 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
60 g_alloc = alloc; | 76 g_alloc = alloc; |
61 g_dealloc = dealloc; | 77 g_dealloc = dealloc; |
62 #endif | 78 #endif |
63 | 79 |
| 80 g_field_trial_find_ = field_trial_find; |
| 81 |
64 *create_media_engine = &CreateWebRtcMediaEngine; | 82 *create_media_engine = &CreateWebRtcMediaEngine; |
65 *destroy_media_engine = &DestroyWebRtcMediaEngine; | 83 *destroy_media_engine = &DestroyWebRtcMediaEngine; |
66 *init_diagnostic_logging = &talk_base::InitDiagnosticLoggingDelegateFunction; | 84 *init_diagnostic_logging = &talk_base::InitDiagnosticLoggingDelegateFunction; |
67 | 85 |
68 if (CommandLine::Init(0, NULL)) { | 86 if (CommandLine::Init(0, NULL)) { |
69 #if !defined(OS_WIN) | 87 #if !defined(OS_WIN) |
70 // This is not needed on Windows since CommandLine::Init has already | 88 // This is not needed on Windows since CommandLine::Init has already |
71 // done the equivalent thing via the GetCommandLine() API. | 89 // done the equivalent thing via the GetCommandLine() API. |
72 CommandLine::ForCurrentProcess()->AppendArguments(command_line, true); | 90 CommandLine::ForCurrentProcess()->AppendArguments(command_line, true); |
73 #endif | 91 #endif |
74 logging::LoggingSettings settings; | 92 logging::LoggingSettings settings; |
75 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 93 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
76 logging::InitLogging(settings); | 94 logging::InitLogging(settings); |
77 | 95 |
78 // Override the log message handler to forward logs to chrome's handler. | 96 // Override the log message handler to forward logs to chrome's handler. |
79 logging::SetLogMessageHandler(log_handler); | 97 logging::SetLogMessageHandler(log_handler); |
80 webrtc::SetupEventTracer(trace_get_category_enabled, | 98 webrtc::SetupEventTracer(trace_get_category_enabled, |
81 trace_add_trace_event); | 99 trace_add_trace_event); |
82 } | 100 } |
83 | 101 |
84 return true; | 102 return true; |
85 } | 103 } |
86 } // extern "C" | 104 } // extern "C" |
OLD | NEW |