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 "init_webrtc.h" | 5 #include "init_webrtc.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 int num_args, | 25 int num_args, |
26 const char** arg_names, | 26 const char** arg_names, |
27 const unsigned char* arg_types, | 27 const unsigned char* arg_types, |
28 const unsigned long long* arg_values, | 28 const unsigned long long* arg_values, |
29 unsigned char flags) { | 29 unsigned char flags) { |
30 TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_group_enabled, name, id, | 30 TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_group_enabled, name, id, |
31 num_args, arg_names, arg_types, arg_values, | 31 num_args, arg_names, arg_types, arg_values, |
32 NULL, flags); | 32 NULL, flags); |
33 } | 33 } |
34 | 34 |
| 35 // Define webrtc:field_trial::FindFullName to provide webrtc with a field trial |
| 36 // implementation. |
| 37 namespace webrtc { |
| 38 namespace field_trial { |
| 39 std::string FindFullName(const std::string& trial_name) { |
| 40 return base::FieldTrialList::FindFullName(trial_name); |
| 41 } |
| 42 } // namespace field_trial |
| 43 } // namespace webrtc |
| 44 |
35 #if defined(LIBPEERCONNECTION_LIB) | 45 #if defined(LIBPEERCONNECTION_LIB) |
36 | 46 |
37 // libpeerconnection is being compiled as a static lib. In this case | 47 // libpeerconnection is being compiled as a static lib. In this case |
38 // we don't need to do any initializing but to keep things simple we | 48 // we don't need to do any initializing but to keep things simple we |
39 // provide an empty intialization routine so that this #ifdef doesn't | 49 // provide an empty intialization routine so that this #ifdef doesn't |
40 // have to be in other places. | 50 // have to be in other places. |
41 bool InitializeWebRtcModule() { | 51 bool InitializeWebRtcModule() { |
42 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent); | 52 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent); |
43 return true; | 53 return true; |
44 } | 54 } |
45 | 55 |
46 // Define webrtc:field_trial::FindFullName to provide webrtc with a field trial | |
47 // implementation. When compiled as a static library this can be done directly | |
48 // and without pointers to functions. | |
49 namespace webrtc { | |
50 namespace field_trial { | |
51 std::string FindFullName(const std::string& trial_name) { | |
52 return base::FieldTrialList::FindFullName(trial_name); | |
53 } | |
54 } // namespace field_trial | |
55 } // namespace webrtc | |
56 | |
57 #else // !LIBPEERCONNECTION_LIB | 56 #else // !LIBPEERCONNECTION_LIB |
58 | 57 |
59 // When being compiled as a shared library, we need to bridge the gap between | 58 // When being compiled as a shared library, we need to bridge the gap between |
60 // the current module and the libpeerconnection module, so things get a tad | 59 // the current module and the libpeerconnection module, so things get a tad |
61 // more complicated. | 60 // more complicated. |
62 | 61 |
63 // Global function pointers to the factory functions in the shared library. | 62 // Global function pointers to the factory functions in the shared library. |
64 CreateWebRtcMediaEngineFunction g_create_webrtc_media_engine = NULL; | 63 CreateWebRtcMediaEngineFunction g_create_webrtc_media_engine = NULL; |
65 DestroyWebRtcMediaEngineFunction g_destroy_webrtc_media_engine = NULL; | 64 DestroyWebRtcMediaEngineFunction g_destroy_webrtc_media_engine = NULL; |
66 | 65 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 119 |
121 // Initialize the proxy by supplying it with a pointer to our | 120 // Initialize the proxy by supplying it with a pointer to our |
122 // allocator/deallocator routines. | 121 // allocator/deallocator routines. |
123 // On mac we use malloc zones, which are global, so we provide NULLs for | 122 // On mac we use malloc zones, which are global, so we provide NULLs for |
124 // the alloc/dealloc functions. | 123 // the alloc/dealloc functions. |
125 // PS: This function is actually implemented in allocator_proxy.cc with the | 124 // PS: This function is actually implemented in allocator_proxy.cc with the |
126 // new/delete overrides. | 125 // new/delete overrides. |
127 InitDiagnosticLoggingDelegateFunctionFunction init_diagnostic_logging = NULL; | 126 InitDiagnosticLoggingDelegateFunctionFunction init_diagnostic_logging = NULL; |
128 bool init_ok = initialize_module(*CommandLine::ForCurrentProcess(), | 127 bool init_ok = initialize_module(*CommandLine::ForCurrentProcess(), |
129 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 128 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
130 &Allocate, &Dellocate, | 129 &Allocate, |
| 130 &Dellocate, |
131 #endif | 131 #endif |
132 &base::FieldTrialList::FindFullName, | 132 &webrtc::field_trial::FindFullName, |
133 logging::GetLogMessageHandler(), | 133 logging::GetLogMessageHandler(), |
134 &GetCategoryGroupEnabled, &AddTraceEvent, | 134 &GetCategoryGroupEnabled, |
135 &g_create_webrtc_media_engine, &g_destroy_webrtc_media_engine, | 135 &AddTraceEvent, |
136 &init_diagnostic_logging); | 136 &g_create_webrtc_media_engine, |
| 137 &g_destroy_webrtc_media_engine, |
| 138 &init_diagnostic_logging); |
137 | 139 |
138 if (init_ok) | 140 if (init_ok) |
139 rtc::SetExtraLoggingInit(init_diagnostic_logging); | 141 rtc::SetExtraLoggingInit(init_diagnostic_logging); |
140 return init_ok; | 142 return init_ok; |
141 } | 143 } |
142 | 144 |
143 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( | 145 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( |
144 webrtc::AudioDeviceModule* adm, | 146 webrtc::AudioDeviceModule* adm, |
145 webrtc::AudioDeviceModule* adm_sc, | 147 webrtc::AudioDeviceModule* adm_sc, |
146 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 148 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
147 cricket::WebRtcVideoDecoderFactory* decoder_factory) { | 149 cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
148 // For convenience of tests etc, we call InitializeWebRtcModule here. | 150 // For convenience of tests etc, we call InitializeWebRtcModule here. |
149 // For Chrome however, InitializeWebRtcModule must be called | 151 // For Chrome however, InitializeWebRtcModule must be called |
150 // explicitly before the sandbox is initialized. In that case, this call is | 152 // explicitly before the sandbox is initialized. In that case, this call is |
151 // effectively a noop. | 153 // effectively a noop. |
152 InitializeWebRtcModule(); | 154 InitializeWebRtcModule(); |
153 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory, | 155 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory, |
154 decoder_factory); | 156 decoder_factory); |
155 } | 157 } |
156 | 158 |
157 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) { | 159 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) { |
158 g_destroy_webrtc_media_engine(media_engine); | 160 g_destroy_webrtc_media_engine(media_engine); |
159 } | 161 } |
160 | 162 |
161 #endif // LIBPEERCONNECTION_LIB | 163 #endif // LIBPEERCONNECTION_LIB |
OLD | NEW |