OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/media_stream_dependency_factory.h" | 5 #include "content/renderer/media/media_stream_dependency_factory.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 type == WebKit::WebMediaStreamSource::TypeVideo); | 413 type == WebKit::WebMediaStreamSource::TypeVideo); |
414 | 414 |
415 std::string track_id = UTF16ToUTF8(track.id()); | 415 std::string track_id = UTF16ToUTF8(track.id()); |
416 return type == WebKit::WebMediaStreamSource::TypeAudio ? | 416 return type == WebKit::WebMediaStreamSource::TypeAudio ? |
417 native_stream->RemoveTrack(native_stream->FindAudioTrack(track_id)) : | 417 native_stream->RemoveTrack(native_stream->FindAudioTrack(track_id)) : |
418 native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id)); | 418 native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id)); |
419 } | 419 } |
420 | 420 |
421 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { | 421 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { |
422 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; | 422 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; |
423 if (!pc_factory_.get()) { | 423 if (!pc_factory_) { |
424 DCHECK(!audio_device_); | 424 DCHECK(!audio_device_); |
425 audio_device_ = new WebRtcAudioDeviceImpl(); | 425 audio_device_ = new WebRtcAudioDeviceImpl(); |
426 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( | 426 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( |
427 webrtc::CreatePeerConnectionFactory(worker_thread_, | 427 webrtc::CreatePeerConnectionFactory(worker_thread_, |
428 signaling_thread_, | 428 signaling_thread_, |
429 audio_device_)); | 429 audio_device_)); |
430 if (factory.get()) | 430 if (factory) |
431 pc_factory_ = factory; | 431 pc_factory_ = factory; |
432 else | 432 else |
433 audio_device_ = NULL; | 433 audio_device_ = NULL; |
434 } | 434 } |
435 return pc_factory_.get() != NULL; | 435 return pc_factory_.get() != NULL; |
436 } | 436 } |
437 | 437 |
438 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { | 438 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { |
439 return pc_factory_.get() != NULL; | 439 return pc_factory_.get() != NULL; |
440 } | 440 } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 646 |
647 if (!network_manager_) { | 647 if (!network_manager_) { |
648 base::WaitableEvent event(true, false); | 648 base::WaitableEvent event(true, false); |
649 chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( | 649 chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
650 &MediaStreamDependencyFactory::CreateIpcNetworkManagerOnWorkerThread, | 650 &MediaStreamDependencyFactory::CreateIpcNetworkManagerOnWorkerThread, |
651 base::Unretained(this), | 651 base::Unretained(this), |
652 &event)); | 652 &event)); |
653 event.Wait(); | 653 event.Wait(); |
654 } | 654 } |
655 | 655 |
656 if (!socket_factory_.get()) { | 656 if (!socket_factory_) { |
657 socket_factory_.reset( | 657 socket_factory_.reset( |
658 new IpcPacketSocketFactory(p2p_socket_dispatcher_)); | 658 new IpcPacketSocketFactory(p2p_socket_dispatcher_)); |
659 } | 659 } |
660 | 660 |
661 // Init SSL, which will be needed by PeerConnection. | 661 // Init SSL, which will be needed by PeerConnection. |
662 #if defined(USE_OPENSSL) | 662 #if defined(USE_OPENSSL) |
663 if (!talk_base::InitializeSSL()) { | 663 if (!talk_base::InitializeSSL()) { |
664 LOG(ERROR) << "Failed on InitializeSSL."; | 664 LOG(ERROR) << "Failed on InitializeSSL."; |
665 return false; | 665 return false; |
666 } | 666 } |
(...skipping 22 matching lines...) Expand all Loading... |
689 // processed before returning. We wait for the above task to finish before | 689 // processed before returning. We wait for the above task to finish before |
690 // letting the the function continue to avoid any potential race issues. | 690 // letting the the function continue to avoid any potential race issues. |
691 chrome_worker_thread_.Stop(); | 691 chrome_worker_thread_.Stop(); |
692 } else { | 692 } else { |
693 NOTREACHED() << "Worker thread not running."; | 693 NOTREACHED() << "Worker thread not running."; |
694 } | 694 } |
695 } | 695 } |
696 } | 696 } |
697 | 697 |
698 } // namespace content | 698 } // namespace content |
OLD | NEW |