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/mock_peer_connection_dependency_factory.
h" | 5 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory.
h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "content/renderer/media/mock_peer_connection_impl.h" | 11 #include "content/renderer/media/mock_peer_connection_impl.h" |
12 #include "content/renderer/media/webaudio_capturer_source.h" | |
13 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" | |
14 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" | 12 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" |
15 #include "content/renderer/media/webrtc_audio_capturer.h" | |
16 #include "content/renderer/media/webrtc_local_audio_track.h" | |
17 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 13 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
18 #include "third_party/webrtc/api/mediastreaminterface.h" | 14 #include "third_party/webrtc/api/mediastreaminterface.h" |
19 #include "third_party/webrtc/base/scoped_ref_ptr.h" | 15 #include "third_party/webrtc/base/scoped_ref_ptr.h" |
20 #include "third_party/webrtc/media/base/videocapturer.h" | 16 #include "third_party/webrtc/media/base/videocapturer.h" |
21 | 17 |
22 using webrtc::AudioSourceInterface; | 18 using webrtc::AudioSourceInterface; |
23 using webrtc::AudioTrackInterface; | 19 using webrtc::AudioTrackInterface; |
24 using webrtc::AudioTrackVector; | 20 using webrtc::AudioTrackVector; |
25 using webrtc::IceCandidateCollection; | 21 using webrtc::IceCandidateCollection; |
26 using webrtc::IceCandidateInterface; | 22 using webrtc::IceCandidateInterface; |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 369 |
374 private: | 370 private: |
375 std::string sdp_mid_; | 371 std::string sdp_mid_; |
376 int sdp_mline_index_; | 372 int sdp_mline_index_; |
377 std::string sdp_; | 373 std::string sdp_; |
378 cricket::Candidate candidate_; | 374 cricket::Candidate candidate_; |
379 }; | 375 }; |
380 | 376 |
381 MockPeerConnectionDependencyFactory::MockPeerConnectionDependencyFactory() | 377 MockPeerConnectionDependencyFactory::MockPeerConnectionDependencyFactory() |
382 : PeerConnectionDependencyFactory(NULL), | 378 : PeerConnectionDependencyFactory(NULL), |
383 fail_to_create_next_audio_capturer_(false) { | 379 signaling_thread_("MockPCFactory WebRtc Signaling Thread") { |
| 380 EnsureWebRtcAudioDeviceImpl(); |
| 381 CHECK(signaling_thread_.Start()); |
384 } | 382 } |
385 | 383 |
386 MockPeerConnectionDependencyFactory::~MockPeerConnectionDependencyFactory() {} | 384 MockPeerConnectionDependencyFactory::~MockPeerConnectionDependencyFactory() {} |
387 | 385 |
388 scoped_refptr<webrtc::PeerConnectionInterface> | 386 scoped_refptr<webrtc::PeerConnectionInterface> |
389 MockPeerConnectionDependencyFactory::CreatePeerConnection( | 387 MockPeerConnectionDependencyFactory::CreatePeerConnection( |
390 const webrtc::PeerConnectionInterface::RTCConfiguration& config, | 388 const webrtc::PeerConnectionInterface::RTCConfiguration& config, |
391 blink::WebFrame* frame, | 389 blink::WebFrame* frame, |
392 webrtc::PeerConnectionObserver* observer) { | 390 webrtc::PeerConnectionObserver* observer) { |
393 return new rtc::RefCountedObject<MockPeerConnectionImpl>(this, observer); | 391 return new rtc::RefCountedObject<MockPeerConnectionImpl>(this, observer); |
(...skipping 15 matching lines...) Expand all Loading... |
409 | 407 |
410 scoped_refptr<webrtc::VideoTrackSourceInterface> | 408 scoped_refptr<webrtc::VideoTrackSourceInterface> |
411 MockPeerConnectionDependencyFactory::CreateVideoSource( | 409 MockPeerConnectionDependencyFactory::CreateVideoSource( |
412 cricket::VideoCapturer* capturer) { | 410 cricket::VideoCapturer* capturer) { |
413 // Video source normally take ownership of |capturer|. | 411 // Video source normally take ownership of |capturer|. |
414 delete capturer; | 412 delete capturer; |
415 NOTIMPLEMENTED(); | 413 NOTIMPLEMENTED(); |
416 return nullptr; | 414 return nullptr; |
417 } | 415 } |
418 | 416 |
419 void MockPeerConnectionDependencyFactory::CreateWebAudioSource( | |
420 blink::WebMediaStreamSource* source) {} | |
421 | |
422 scoped_refptr<webrtc::MediaStreamInterface> | 417 scoped_refptr<webrtc::MediaStreamInterface> |
423 MockPeerConnectionDependencyFactory::CreateLocalMediaStream( | 418 MockPeerConnectionDependencyFactory::CreateLocalMediaStream( |
424 const std::string& label) { | 419 const std::string& label) { |
425 return new rtc::RefCountedObject<MockMediaStream>(label); | 420 return new rtc::RefCountedObject<MockMediaStream>(label); |
426 } | 421 } |
427 | 422 |
428 scoped_refptr<webrtc::VideoTrackInterface> | 423 scoped_refptr<webrtc::VideoTrackInterface> |
429 MockPeerConnectionDependencyFactory::CreateLocalVideoTrack( | 424 MockPeerConnectionDependencyFactory::CreateLocalVideoTrack( |
430 const std::string& id, | 425 const std::string& id, |
431 webrtc::VideoTrackSourceInterface* source) { | 426 webrtc::VideoTrackSourceInterface* source) { |
(...skipping 19 matching lines...) Expand all Loading... |
451 } | 446 } |
452 | 447 |
453 webrtc::IceCandidateInterface* | 448 webrtc::IceCandidateInterface* |
454 MockPeerConnectionDependencyFactory::CreateIceCandidate( | 449 MockPeerConnectionDependencyFactory::CreateIceCandidate( |
455 const std::string& sdp_mid, | 450 const std::string& sdp_mid, |
456 int sdp_mline_index, | 451 int sdp_mline_index, |
457 const std::string& sdp) { | 452 const std::string& sdp) { |
458 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp); | 453 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp); |
459 } | 454 } |
460 | 455 |
461 std::unique_ptr<WebRtcAudioCapturer> | 456 scoped_refptr<base::SingleThreadTaskRunner> |
462 MockPeerConnectionDependencyFactory::CreateAudioCapturer( | 457 MockPeerConnectionDependencyFactory::GetWebRtcSignalingThread() const { |
463 int render_frame_id, | 458 return signaling_thread_.task_runner(); |
464 const StreamDeviceInfo& device_info, | |
465 const blink::WebMediaConstraints& constraints, | |
466 MediaStreamAudioSource* audio_source) { | |
467 if (fail_to_create_next_audio_capturer_) { | |
468 fail_to_create_next_audio_capturer_ = false; | |
469 return NULL; | |
470 } | |
471 DCHECK(audio_source); | |
472 return WebRtcAudioCapturer::CreateCapturer(-1, device_info, constraints, NULL, | |
473 audio_source); | |
474 } | 459 } |
475 | 460 |
476 } // namespace content | 461 } // namespace content |
OLD | NEW |