| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 5 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 141 } |
| 142 | 142 |
| 143 const scoped_refptr<webrtc::PeerConnectionFactoryInterface>& | 143 const scoped_refptr<webrtc::PeerConnectionFactoryInterface>& |
| 144 PeerConnectionDependencyFactory::GetPcFactory() { | 144 PeerConnectionDependencyFactory::GetPcFactory() { |
| 145 if (!pc_factory_.get()) | 145 if (!pc_factory_.get()) |
| 146 CreatePeerConnectionFactory(); | 146 CreatePeerConnectionFactory(); |
| 147 CHECK(pc_factory_.get()); | 147 CHECK(pc_factory_.get()); |
| 148 return pc_factory_; | 148 return pc_factory_; |
| 149 } | 149 } |
| 150 | 150 |
| 151 void PeerConnectionDependencyFactory::WillDestroyCurrentMessageLoop() { | |
| 152 CleanupPeerConnectionFactory(); | |
| 153 } | |
| 154 | |
| 155 void PeerConnectionDependencyFactory::CreatePeerConnectionFactory() { | 151 void PeerConnectionDependencyFactory::CreatePeerConnectionFactory() { |
| 156 DCHECK(!pc_factory_.get()); | 152 DCHECK(!pc_factory_.get()); |
| 157 DCHECK(!signaling_thread_); | 153 DCHECK(!signaling_thread_); |
| 158 DCHECK(!worker_thread_); | 154 DCHECK(!worker_thread_); |
| 159 DCHECK(!network_manager_); | 155 DCHECK(!network_manager_); |
| 160 DCHECK(!socket_factory_); | 156 DCHECK(!socket_factory_); |
| 161 DCHECK(!chrome_signaling_thread_.IsRunning()); | 157 DCHECK(!chrome_signaling_thread_.IsRunning()); |
| 162 DCHECK(!chrome_worker_thread_.IsRunning()); | 158 DCHECK(!chrome_worker_thread_.IsRunning()); |
| 163 | 159 |
| 164 DVLOG(1) << "PeerConnectionDependencyFactory::CreatePeerConnectionFactory()"; | 160 DVLOG(1) << "PeerConnectionDependencyFactory::CreatePeerConnectionFactory()"; |
| 165 | 161 |
| 166 #if BUILDFLAG(RTC_USE_H264) | 162 #if BUILDFLAG(RTC_USE_H264) |
| 167 // Building /w |rtc_use_h264|, is the corresponding run-time feature enabled? | 163 // Building /w |rtc_use_h264|, is the corresponding run-time feature enabled? |
| 168 if (base::FeatureList::IsEnabled(kWebRtcH264WithOpenH264FFmpeg)) { | 164 if (base::FeatureList::IsEnabled(kWebRtcH264WithOpenH264FFmpeg)) { |
| 169 // |H264DecoderImpl| may be used which depends on FFmpeg, therefore we need | 165 // |H264DecoderImpl| may be used which depends on FFmpeg, therefore we need |
| 170 // to initialize FFmpeg before going further. | 166 // to initialize FFmpeg before going further. |
| 171 media::FFmpegGlue::InitializeFFmpeg(); | 167 media::FFmpegGlue::InitializeFFmpeg(); |
| 172 } else { | 168 } else { |
| 173 // Feature is to be disabled, no need to make sure FFmpeg is initialized. | 169 // Feature is to be disabled, no need to make sure FFmpeg is initialized. |
| 174 webrtc::DisableRtcUseH264(); | 170 webrtc::DisableRtcUseH264(); |
| 175 } | 171 } |
| 176 #endif | 172 #endif |
| 177 | 173 |
| 178 base::MessageLoop::current()->AddDestructionObserver(this); | |
| 179 // To allow sending to the signaling/worker threads. | 174 // To allow sending to the signaling/worker threads. |
| 180 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 175 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
| 181 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); | 176 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); |
| 182 | 177 |
| 183 EnsureWebRtcAudioDeviceImpl(); | 178 EnsureWebRtcAudioDeviceImpl(); |
| 184 | 179 |
| 185 CHECK(chrome_signaling_thread_.Start()); | 180 CHECK(chrome_signaling_thread_.Start()); |
| 186 CHECK(chrome_worker_thread_.Start()); | 181 CHECK(chrome_worker_thread_.Start()); |
| 187 | 182 |
| 188 base::WaitableEvent start_worker_event( | 183 base::WaitableEvent start_worker_event( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 std::string group_name = | 269 std::string group_name = |
| 275 base::FieldTrialList::FindFullName("WebRTC-PeerConnectionDTLS1.2"); | 270 base::FieldTrialList::FindFullName("WebRTC-PeerConnectionDTLS1.2"); |
| 276 if (StartsWith(group_name, "Control", base::CompareCase::SENSITIVE)) | 271 if (StartsWith(group_name, "Control", base::CompareCase::SENSITIVE)) |
| 277 factory_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 272 factory_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
| 278 | 273 |
| 279 pc_factory_->SetOptions(factory_options); | 274 pc_factory_->SetOptions(factory_options); |
| 280 | 275 |
| 281 event->Signal(); | 276 event->Signal(); |
| 282 } | 277 } |
| 283 | 278 |
| 279 void PeerConnectionDependencyFactory::ShutDown() { |
| 280 CleanupPeerConnectionFactory(); |
| 281 } |
| 282 |
| 284 bool PeerConnectionDependencyFactory::PeerConnectionFactoryCreated() { | 283 bool PeerConnectionDependencyFactory::PeerConnectionFactoryCreated() { |
| 285 return pc_factory_.get() != NULL; | 284 return pc_factory_.get() != NULL; |
| 286 } | 285 } |
| 287 | 286 |
| 288 scoped_refptr<webrtc::PeerConnectionInterface> | 287 scoped_refptr<webrtc::PeerConnectionInterface> |
| 289 PeerConnectionDependencyFactory::CreatePeerConnection( | 288 PeerConnectionDependencyFactory::CreatePeerConnection( |
| 290 const webrtc::PeerConnectionInterface::RTCConfiguration& config, | 289 const webrtc::PeerConnectionInterface::RTCConfiguration& config, |
| 291 blink::WebFrame* web_frame, | 290 blink::WebFrame* web_frame, |
| 292 webrtc::PeerConnectionObserver* observer) { | 291 webrtc::PeerConnectionObserver* observer) { |
| 293 CHECK(web_frame); | 292 CHECK(web_frame); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 | 558 |
| 560 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { | 559 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { |
| 561 DCHECK(CalledOnValidThread()); | 560 DCHECK(CalledOnValidThread()); |
| 562 if (audio_device_.get()) | 561 if (audio_device_.get()) |
| 563 return; | 562 return; |
| 564 | 563 |
| 565 audio_device_ = new WebRtcAudioDeviceImpl(); | 564 audio_device_ = new WebRtcAudioDeviceImpl(); |
| 566 } | 565 } |
| 567 | 566 |
| 568 } // namespace content | 567 } // namespace content |
| OLD | NEW |