| 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/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
| 12 #include "base/native_library.h" | 12 #include "base/native_library.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "third_party/webrtc/common.h" | |
| 15 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h
" | |
| 16 #include "webrtc/base/basictypes.h" | 14 #include "webrtc/base/basictypes.h" |
| 17 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
| 18 | 16 |
| 19 const unsigned char* GetCategoryGroupEnabled(const char* category_group) { | 17 const unsigned char* GetCategoryGroupEnabled(const char* category_group) { |
| 20 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); | 18 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); |
| 21 } | 19 } |
| 22 | 20 |
| 23 void AddTraceEvent(char phase, | 21 void AddTraceEvent(char phase, |
| 24 const unsigned char* category_group_enabled, | 22 const unsigned char* category_group_enabled, |
| 25 const char* name, | 23 const char* name, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 48 | 46 |
| 49 // libpeerconnection is being compiled as a static lib. In this case | 47 // libpeerconnection is being compiled as a static lib. In this case |
| 50 // 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 |
| 51 // provide an empty intialization routine so that this #ifdef doesn't | 49 // provide an empty intialization routine so that this #ifdef doesn't |
| 52 // have to be in other places. | 50 // have to be in other places. |
| 53 bool InitializeWebRtcModule() { | 51 bool InitializeWebRtcModule() { |
| 54 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent); | 52 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent); |
| 55 return true; | 53 return true; |
| 56 } | 54 } |
| 57 | 55 |
| 58 webrtc::AudioProcessing* CreateWebRtcAudioProcessing( | |
| 59 const webrtc::Config& config) { | |
| 60 // libpeerconnection is being compiled as a static lib, use | |
| 61 // webrtc::AudioProcessing directly. | |
| 62 return webrtc::AudioProcessing::Create(config); | |
| 63 } | |
| 64 | |
| 65 #else // !LIBPEERCONNECTION_LIB | 56 #else // !LIBPEERCONNECTION_LIB |
| 66 | 57 |
| 67 // 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 |
| 68 // 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 |
| 69 // more complicated. | 60 // more complicated. |
| 70 | 61 |
| 71 // Global function pointers to the factory functions in the shared library. | 62 // Global function pointers to the factory functions in the shared library. |
| 72 CreateWebRtcMediaEngineFunction g_create_webrtc_media_engine = NULL; | 63 CreateWebRtcMediaEngineFunction g_create_webrtc_media_engine = NULL; |
| 73 DestroyWebRtcMediaEngineFunction g_destroy_webrtc_media_engine = NULL; | 64 DestroyWebRtcMediaEngineFunction g_destroy_webrtc_media_engine = NULL; |
| 74 CreateWebRtcAudioProcessingFunction g_create_webrtc_audio_processing = NULL; | |
| 75 | 65 |
| 76 // Returns the full or relative path to the libpeerconnection module depending | 66 // Returns the full or relative path to the libpeerconnection module depending |
| 77 // on what platform we're on. | 67 // on what platform we're on. |
| 78 static base::FilePath GetLibPeerConnectionPath() { | 68 static base::FilePath GetLibPeerConnectionPath() { |
| 79 base::FilePath path; | 69 base::FilePath path; |
| 80 CHECK(PathService::Get(base::DIR_MODULE, &path)); | 70 CHECK(PathService::Get(base::DIR_MODULE, &path)); |
| 81 #if defined(OS_WIN) | 71 #if defined(OS_WIN) |
| 82 path = path.Append(FILE_PATH_LITERAL("libpeerconnection.dll")); | 72 path = path.Append(FILE_PATH_LITERAL("libpeerconnection.dll")); |
| 83 #elif defined(OS_MACOSX) | 73 #elif defined(OS_MACOSX) |
| 84 // Simulate '@loader_path/Libraries'. | 74 // Simulate '@loader_path/Libraries'. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 128 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 139 &Allocate, | 129 &Allocate, |
| 140 &Dellocate, | 130 &Dellocate, |
| 141 #endif | 131 #endif |
| 142 &webrtc::field_trial::FindFullName, | 132 &webrtc::field_trial::FindFullName, |
| 143 logging::GetLogMessageHandler(), | 133 logging::GetLogMessageHandler(), |
| 144 &GetCategoryGroupEnabled, | 134 &GetCategoryGroupEnabled, |
| 145 &AddTraceEvent, | 135 &AddTraceEvent, |
| 146 &g_create_webrtc_media_engine, | 136 &g_create_webrtc_media_engine, |
| 147 &g_destroy_webrtc_media_engine, | 137 &g_destroy_webrtc_media_engine, |
| 148 &init_diagnostic_logging, | 138 &init_diagnostic_logging); |
| 149 &g_create_webrtc_audio_processing); | |
| 150 | 139 |
| 151 if (init_ok) | 140 if (init_ok) |
| 152 rtc::SetExtraLoggingInit(init_diagnostic_logging); | 141 rtc::SetExtraLoggingInit(init_diagnostic_logging); |
| 153 return init_ok; | 142 return init_ok; |
| 154 } | 143 } |
| 155 | 144 |
| 156 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( | 145 cricket::MediaEngineInterface* CreateWebRtcMediaEngine( |
| 157 webrtc::AudioDeviceModule* adm, | 146 webrtc::AudioDeviceModule* adm, |
| 158 webrtc::AudioDeviceModule* adm_sc, | 147 webrtc::AudioDeviceModule* adm_sc, |
| 159 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 148 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 160 cricket::WebRtcVideoDecoderFactory* decoder_factory) { | 149 cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
| 161 // For convenience of tests etc, we call InitializeWebRtcModule here. | 150 // For convenience of tests etc, we call InitializeWebRtcModule here. |
| 162 // For Chrome however, InitializeWebRtcModule must be called | 151 // For Chrome however, InitializeWebRtcModule must be called |
| 163 // 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 |
| 164 // effectively a noop. | 153 // effectively a noop. |
| 165 InitializeWebRtcModule(); | 154 InitializeWebRtcModule(); |
| 166 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory, | 155 return g_create_webrtc_media_engine(adm, adm_sc, encoder_factory, |
| 167 decoder_factory); | 156 decoder_factory); |
| 168 } | 157 } |
| 169 | 158 |
| 170 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) { | 159 void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine) { |
| 171 g_destroy_webrtc_media_engine(media_engine); | 160 g_destroy_webrtc_media_engine(media_engine); |
| 172 } | 161 } |
| 173 | 162 |
| 174 webrtc::AudioProcessing* CreateWebRtcAudioProcessing( | |
| 175 const webrtc::Config& config) { | |
| 176 // The same as CreateWebRtcMediaEngine(), we call InitializeWebRtcModule here | |
| 177 // for convenience of tests. | |
| 178 InitializeWebRtcModule(); | |
| 179 return g_create_webrtc_audio_processing(config); | |
| 180 } | |
| 181 | |
| 182 #endif // LIBPEERCONNECTION_LIB | 163 #endif // LIBPEERCONNECTION_LIB |
| OLD | NEW |