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" |
| 11 #include "base/metrics/field_trial.h" |
11 #include "base/native_library.h" | 12 #include "base/native_library.h" |
12 #include "base/path_service.h" | 13 #include "base/path_service.h" |
13 #include "talk/base/basictypes.h" | 14 #include "talk/base/basictypes.h" |
14 #include "third_party/libjingle/overrides/talk/base/logging.h" | 15 #include "third_party/libjingle/overrides/talk/base/logging.h" |
15 | 16 |
16 const unsigned char* GetCategoryGroupEnabled(const char* category_group) { | 17 const unsigned char* GetCategoryGroupEnabled(const char* category_group) { |
17 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); | 18 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); |
18 } | 19 } |
19 | 20 |
20 void AddTraceEvent(char phase, | 21 void AddTraceEvent(char phase, |
(...skipping 14 matching lines...) Expand all Loading... |
35 | 36 |
36 // libpeerconnection is being compiled as a static lib. In this case | 37 // libpeerconnection is being compiled as a static lib. In this case |
37 // we don't need to do any initializing but to keep things simple we | 38 // we don't need to do any initializing but to keep things simple we |
38 // provide an empty intialization routine so that this #ifdef doesn't | 39 // provide an empty intialization routine so that this #ifdef doesn't |
39 // have to be in other places. | 40 // have to be in other places. |
40 bool InitializeWebRtcModule() { | 41 bool InitializeWebRtcModule() { |
41 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent); | 42 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent); |
42 return true; | 43 return true; |
43 } | 44 } |
44 | 45 |
| 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 |
45 #else // !LIBPEERCONNECTION_LIB | 57 #else // !LIBPEERCONNECTION_LIB |
46 | 58 |
47 // When being compiled as a shared library, we need to bridge the gap between | 59 // When being compiled as a shared library, we need to bridge the gap between |
48 // the current module and the libpeerconnection module, so things get a tad | 60 // the current module and the libpeerconnection module, so things get a tad |
49 // more complicated. | 61 // more complicated. |
50 | 62 |
51 // Global function pointers to the factory functions in the shared library. | 63 // Global function pointers to the factory functions in the shared library. |
52 CreateWebRtcMediaEngineFunction g_create_webrtc_media_engine = NULL; | 64 CreateWebRtcMediaEngineFunction g_create_webrtc_media_engine = NULL; |
53 DestroyWebRtcMediaEngineFunction g_destroy_webrtc_media_engine = NULL; | 65 DestroyWebRtcMediaEngineFunction g_destroy_webrtc_media_engine = NULL; |
54 | 66 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // allocator/deallocator routines. | 122 // allocator/deallocator routines. |
111 // On mac we use malloc zones, which are global, so we provide NULLs for | 123 // On mac we use malloc zones, which are global, so we provide NULLs for |
112 // the alloc/dealloc functions. | 124 // the alloc/dealloc functions. |
113 // PS: This function is actually implemented in allocator_proxy.cc with the | 125 // PS: This function is actually implemented in allocator_proxy.cc with the |
114 // new/delete overrides. | 126 // new/delete overrides. |
115 InitDiagnosticLoggingDelegateFunctionFunction init_diagnostic_logging = NULL; | 127 InitDiagnosticLoggingDelegateFunctionFunction init_diagnostic_logging = NULL; |
116 bool init_ok = initialize_module(*CommandLine::ForCurrentProcess(), | 128 bool init_ok = initialize_module(*CommandLine::ForCurrentProcess(), |
117 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 129 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
118 &Allocate, &Dellocate, | 130 &Allocate, &Dellocate, |
119 #endif | 131 #endif |
| 132 &base::FieldTrialList::FindFullName, |
120 logging::GetLogMessageHandler(), | 133 logging::GetLogMessageHandler(), |
121 &GetCategoryGroupEnabled, &AddTraceEvent, | 134 &GetCategoryGroupEnabled, &AddTraceEvent, |
122 &g_create_webrtc_media_engine, &g_destroy_webrtc_media_engine, | 135 &g_create_webrtc_media_engine, &g_destroy_webrtc_media_engine, |
123 &init_diagnostic_logging); | 136 &init_diagnostic_logging); |
124 | 137 |
125 if (init_ok) | 138 if (init_ok) |
126 talk_base::SetExtraLoggingInit(init_diagnostic_logging); | 139 talk_base::SetExtraLoggingInit(init_diagnostic_logging); |
127 return init_ok; | 140 return init_ok; |
128 } | 141 } |
129 | 142 |
130 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( | 143 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( |
131 webrtc::AudioDeviceModule* adm, | 144 webrtc::AudioDeviceModule* adm, |
132 webrtc::AudioDeviceModule* adm_sc, | 145 webrtc::AudioDeviceModule* adm_sc, |
133 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 146 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
134 cricket::WebRtcVideoDecoderFactory* decoder_factory) { | 147 cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
135 // For convenience of tests etc, we call InitializeWebRtcModule here. | 148 // For convenience of tests etc, we call InitializeWebRtcModule here. |
136 // For Chrome however, InitializeWebRtcModule must be called | 149 // For Chrome however, InitializeWebRtcModule must be called |
137 // explicitly before the sandbox is initialized. In that case, this call is | 150 // explicitly before the sandbox is initialized. In that case, this call is |
138 // effectively a noop. | 151 // effectively a noop. |
139 InitializeWebRtcModule(); | 152 InitializeWebRtcModule(); |
140 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory, | 153 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory, |
141 decoder_factory); | 154 decoder_factory); |
142 } | 155 } |
143 | 156 |
144 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) { | 157 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) { |
145 g_destroy_webrtc_media_engine(media_engine); | 158 g_destroy_webrtc_media_engine(media_engine); |
146 } | 159 } |
147 | 160 |
148 #endif // LIBPEERCONNECTION_LIB | 161 #endif // LIBPEERCONNECTION_LIB |
OLD | NEW |