| 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/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/native_library.h" | 10 #include "base/native_library.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "talk/base/basictypes.h" | 12 #include "talk/base/basictypes.h" |
| 13 #include "third_party/libjingle/overrides/talk/base/logging.h" |
| 13 | 14 |
| 14 const unsigned char* GetCategoryGroupEnabled(const char* category_group) { | 15 const unsigned char* GetCategoryGroupEnabled(const char* category_group) { |
| 15 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); | 16 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); |
| 16 } | 17 } |
| 17 | 18 |
| 18 void AddTraceEvent(char phase, | 19 void AddTraceEvent(char phase, |
| 19 const unsigned char* category_group_enabled, | 20 const unsigned char* category_group_enabled, |
| 20 const char* name, | 21 const char* name, |
| 21 unsigned long long id, | 22 unsigned long long id, |
| 22 int num_args, | 23 int num_args, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 reinterpret_cast<InitializeModuleFunction>( | 89 reinterpret_cast<InitializeModuleFunction>( |
| 89 base::GetFunctionPointerFromNativeLibrary( | 90 base::GetFunctionPointerFromNativeLibrary( |
| 90 lib, "InitializeModule")); | 91 lib, "InitializeModule")); |
| 91 | 92 |
| 92 // Initialize the proxy by supplying it with a pointer to our | 93 // Initialize the proxy by supplying it with a pointer to our |
| 93 // allocator/deallocator routines. | 94 // allocator/deallocator routines. |
| 94 // On mac we use malloc zones, which are global, so we provide NULLs for | 95 // On mac we use malloc zones, which are global, so we provide NULLs for |
| 95 // the alloc/dealloc functions. | 96 // the alloc/dealloc functions. |
| 96 // PS: This function is actually implemented in allocator_proxy.cc with the | 97 // PS: This function is actually implemented in allocator_proxy.cc with the |
| 97 // new/delete overrides. | 98 // new/delete overrides. |
| 98 return initialize_module(*CommandLine::ForCurrentProcess(), | 99 InitDiagnosticLoggingDelegateFunctionFunction init_diagnostic_logging = NULL; |
| 100 bool init_ok = initialize_module(*CommandLine::ForCurrentProcess(), |
| 99 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 101 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 100 &Allocate, &Dellocate, | 102 &Allocate, &Dellocate, |
| 101 #endif | 103 #endif |
| 102 logging::GetLogMessageHandler(), | 104 logging::GetLogMessageHandler(), |
| 103 &GetCategoryGroupEnabled, &AddTraceEvent, | 105 &GetCategoryGroupEnabled, &AddTraceEvent, |
| 104 &g_create_webrtc_media_engine, &g_destroy_webrtc_media_engine); | 106 &g_create_webrtc_media_engine, &g_destroy_webrtc_media_engine, |
| 107 &init_diagnostic_logging); |
| 108 |
| 109 if (init_ok) |
| 110 talk_base::SetExtraLoggingInit(init_diagnostic_logging); |
| 111 return init_ok; |
| 105 } | 112 } |
| 106 | 113 |
| 107 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( | 114 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( |
| 108 webrtc::AudioDeviceModule* adm, | 115 webrtc::AudioDeviceModule* adm, |
| 109 webrtc::AudioDeviceModule* adm_sc, | 116 webrtc::AudioDeviceModule* adm_sc, |
| 110 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 117 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 111 cricket::WebRtcVideoDecoderFactory* decoder_factory) { | 118 cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
| 112 // For convenience of tests etc, we call InitializeWebRtcModule here. | 119 // For convenience of tests etc, we call InitializeWebRtcModule here. |
| 113 // For Chrome however, InitializeWebRtcModule must be called | 120 // For Chrome however, InitializeWebRtcModule must be called |
| 114 // explicitly before the sandbox is initialized. In that case, this call is | 121 // explicitly before the sandbox is initialized. In that case, this call is |
| 115 // effectively a noop. | 122 // effectively a noop. |
| 116 InitializeWebRtcModule(); | 123 InitializeWebRtcModule(); |
| 117 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory, | 124 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory, |
| 118 decoder_factory); | 125 decoder_factory); |
| 119 } | 126 } |
| 120 | 127 |
| 121 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) { | 128 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) { |
| 122 g_destroy_webrtc_media_engine(media_engine); | 129 g_destroy_webrtc_media_engine(media_engine); |
| 123 } | 130 } |
| 124 | 131 |
| 125 #endif // LIBPEERCONNECTION_LIB | 132 #endif // LIBPEERCONNECTION_LIB |
| OLD | NEW |