| 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/mock_media_stream_dependency_factory.h" | 5 #include "content/renderer/media/mock_media_stream_dependency_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/renderer/media/mock_peer_connection_impl.h" | 9 #include "content/renderer/media/mock_peer_connection_impl.h" |
| 10 #include "content/renderer/media/webaudio_capturer_source.h" | 10 #include "content/renderer/media/webaudio_capturer_source.h" |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 return true; | 377 return true; |
| 378 } | 378 } |
| 379 | 379 |
| 380 private: | 380 private: |
| 381 std::string sdp_mid_; | 381 std::string sdp_mid_; |
| 382 int sdp_mline_index_; | 382 int sdp_mline_index_; |
| 383 std::string sdp_; | 383 std::string sdp_; |
| 384 }; | 384 }; |
| 385 | 385 |
| 386 MockMediaStreamDependencyFactory::MockMediaStreamDependencyFactory() | 386 MockMediaStreamDependencyFactory::MockMediaStreamDependencyFactory() |
| 387 : MediaStreamDependencyFactory(NULL), | 387 : MediaStreamDependencyFactory(NULL) { |
| 388 mock_pc_factory_created_(false) { | |
| 389 } | 388 } |
| 390 | 389 |
| 391 MockMediaStreamDependencyFactory::~MockMediaStreamDependencyFactory() {} | 390 MockMediaStreamDependencyFactory::~MockMediaStreamDependencyFactory() {} |
| 392 | 391 |
| 393 bool MockMediaStreamDependencyFactory::EnsurePeerConnectionFactory() { | |
| 394 mock_pc_factory_created_ = true; | |
| 395 return true; | |
| 396 } | |
| 397 | |
| 398 bool MockMediaStreamDependencyFactory::PeerConnectionFactoryCreated() { | |
| 399 return mock_pc_factory_created_; | |
| 400 } | |
| 401 | |
| 402 scoped_refptr<webrtc::PeerConnectionInterface> | 392 scoped_refptr<webrtc::PeerConnectionInterface> |
| 403 MockMediaStreamDependencyFactory::CreatePeerConnection( | 393 MockMediaStreamDependencyFactory::CreatePeerConnection( |
| 404 const webrtc::PeerConnectionInterface::IceServers& ice_servers, | 394 const webrtc::PeerConnectionInterface::IceServers& ice_servers, |
| 405 const webrtc::MediaConstraintsInterface* constraints, | 395 const webrtc::MediaConstraintsInterface* constraints, |
| 406 blink::WebFrame* frame, | 396 blink::WebFrame* frame, |
| 407 webrtc::PeerConnectionObserver* observer) { | 397 webrtc::PeerConnectionObserver* observer) { |
| 408 DCHECK(mock_pc_factory_created_); | |
| 409 return new talk_base::RefCountedObject<MockPeerConnectionImpl>(this); | 398 return new talk_base::RefCountedObject<MockPeerConnectionImpl>(this); |
| 410 } | 399 } |
| 411 | 400 |
| 412 scoped_refptr<webrtc::AudioSourceInterface> | 401 scoped_refptr<webrtc::AudioSourceInterface> |
| 413 MockMediaStreamDependencyFactory::CreateLocalAudioSource( | 402 MockMediaStreamDependencyFactory::CreateLocalAudioSource( |
| 414 const webrtc::MediaConstraintsInterface* constraints) { | 403 const webrtc::MediaConstraintsInterface* constraints) { |
| 415 last_audio_source_ = | 404 last_audio_source_ = |
| 416 new talk_base::RefCountedObject<MockAudioSource>(constraints); | 405 new talk_base::RefCountedObject<MockAudioSource>(constraints); |
| 417 return last_audio_source_; | 406 return last_audio_source_; |
| 418 } | 407 } |
| 419 | 408 |
| 420 scoped_refptr<webrtc::VideoSourceInterface> | 409 cricket::VideoCapturer* MockMediaStreamDependencyFactory::CreateVideoCapturer( |
| 421 MockMediaStreamDependencyFactory::CreateLocalVideoSource( | 410 const StreamDeviceInfo& info) { |
| 422 int video_session_id, | 411 return NULL; |
| 423 bool is_screencast, | |
| 424 const webrtc::MediaConstraintsInterface* constraints) { | |
| 425 last_video_source_ = new talk_base::RefCountedObject<MockVideoSource>(); | |
| 426 return last_video_source_; | |
| 427 } | 412 } |
| 428 | 413 |
| 429 scoped_refptr<webrtc::VideoSourceInterface> | 414 scoped_refptr<webrtc::VideoSourceInterface> |
| 430 MockMediaStreamDependencyFactory::CreateVideoSource( | 415 MockMediaStreamDependencyFactory::CreateVideoSource( |
| 431 cricket::VideoCapturer* capturer, | 416 cricket::VideoCapturer* capturer, |
| 432 const webrtc::MediaConstraintsInterface* constraints) { | 417 const webrtc::MediaConstraintsInterface* constraints) { |
| 433 last_video_source_ = new talk_base::RefCountedObject<MockVideoSource>(); | 418 last_video_source_ = new talk_base::RefCountedObject<MockVideoSource>(); |
| 434 last_video_source_->SetVideoCapturer(capturer); | 419 last_video_source_->SetVideoCapturer(capturer); |
| 435 return last_video_source_; | 420 return last_video_source_; |
| 436 } | 421 } |
| 437 | 422 |
| 438 scoped_refptr<WebAudioCapturerSource> | 423 scoped_refptr<WebAudioCapturerSource> |
| 439 MockMediaStreamDependencyFactory::CreateWebAudioSource( | 424 MockMediaStreamDependencyFactory::CreateWebAudioSource( |
| 440 blink::WebMediaStreamSource* source, | 425 blink::WebMediaStreamSource* source, |
| 441 const RTCMediaConstraints& constraints) { | 426 const RTCMediaConstraints& constraints) { |
| 442 return NULL; | 427 return NULL; |
| 443 } | 428 } |
| 444 | 429 |
| 445 scoped_refptr<webrtc::MediaStreamInterface> | 430 scoped_refptr<webrtc::MediaStreamInterface> |
| 446 MockMediaStreamDependencyFactory::CreateLocalMediaStream( | 431 MockMediaStreamDependencyFactory::CreateLocalMediaStream( |
| 447 const std::string& label) { | 432 const std::string& label) { |
| 448 DCHECK(mock_pc_factory_created_); | |
| 449 return new talk_base::RefCountedObject<MockMediaStream>(label); | 433 return new talk_base::RefCountedObject<MockMediaStream>(label); |
| 450 } | 434 } |
| 451 | 435 |
| 452 scoped_refptr<webrtc::VideoTrackInterface> | 436 scoped_refptr<webrtc::VideoTrackInterface> |
| 453 MockMediaStreamDependencyFactory::CreateLocalVideoTrack( | 437 MockMediaStreamDependencyFactory::CreateLocalVideoTrack( |
| 454 const std::string& id, | 438 const std::string& id, |
| 455 webrtc::VideoSourceInterface* source) { | 439 webrtc::VideoSourceInterface* source) { |
| 456 DCHECK(mock_pc_factory_created_); | |
| 457 scoped_refptr<webrtc::VideoTrackInterface> track( | 440 scoped_refptr<webrtc::VideoTrackInterface> track( |
| 458 new talk_base::RefCountedObject<MockLocalVideoTrack>( | 441 new talk_base::RefCountedObject<MockLocalVideoTrack>( |
| 459 id, source)); | 442 id, source)); |
| 460 return track; | 443 return track; |
| 461 } | 444 } |
| 462 | 445 |
| 463 scoped_refptr<webrtc::VideoTrackInterface> | 446 scoped_refptr<webrtc::VideoTrackInterface> |
| 464 MockMediaStreamDependencyFactory::CreateLocalVideoTrack( | 447 MockMediaStreamDependencyFactory::CreateLocalVideoTrack( |
| 465 const std::string& id, | 448 const std::string& id, |
| 466 cricket::VideoCapturer* capturer) { | 449 cricket::VideoCapturer* capturer) { |
| 467 DCHECK(mock_pc_factory_created_); | |
| 468 | |
| 469 scoped_refptr<MockVideoSource> source = | 450 scoped_refptr<MockVideoSource> source = |
| 470 new talk_base::RefCountedObject<MockVideoSource>(); | 451 new talk_base::RefCountedObject<MockVideoSource>(); |
| 471 source->SetVideoCapturer(capturer); | 452 source->SetVideoCapturer(capturer); |
| 472 | 453 |
| 473 return new talk_base::RefCountedObject<MockLocalVideoTrack>(id, source.get()); | 454 return new talk_base::RefCountedObject<MockLocalVideoTrack>(id, source.get()); |
| 474 } | 455 } |
| 475 | 456 |
| 476 scoped_refptr<webrtc::AudioTrackInterface> | 457 scoped_refptr<webrtc::AudioTrackInterface> |
| 477 MockMediaStreamDependencyFactory::CreateLocalAudioTrack( | 458 MockMediaStreamDependencyFactory::CreateLocalAudioTrack( |
| 478 const std::string& id, | 459 const std::string& id, |
| 479 const scoped_refptr<WebRtcAudioCapturer>& capturer, | 460 const scoped_refptr<WebRtcAudioCapturer>& capturer, |
| 480 WebAudioCapturerSource* webaudio_source, | 461 WebAudioCapturerSource* webaudio_source, |
| 481 webrtc::AudioSourceInterface* source) { | 462 webrtc::AudioSourceInterface* source) { |
| 482 DCHECK(mock_pc_factory_created_); | |
| 483 blink::WebMediaConstraints constraints; | 463 blink::WebMediaConstraints constraints; |
| 484 scoped_refptr<WebRtcAudioCapturer> audio_capturer = capturer ? | 464 scoped_refptr<WebRtcAudioCapturer> audio_capturer = capturer ? |
| 485 capturer : WebRtcAudioCapturer::CreateCapturer(-1, StreamDeviceInfo(), | 465 capturer : WebRtcAudioCapturer::CreateCapturer(-1, StreamDeviceInfo(), |
| 486 constraints, NULL); | 466 constraints, NULL); |
| 487 return WebRtcLocalAudioTrack::Create( | 467 return WebRtcLocalAudioTrack::Create( |
| 488 id, audio_capturer, webaudio_source, source); | 468 id, audio_capturer, webaudio_source, source); |
| 489 } | 469 } |
| 490 | 470 |
| 491 SessionDescriptionInterface* | 471 SessionDescriptionInterface* |
| 492 MockMediaStreamDependencyFactory::CreateSessionDescription( | 472 MockMediaStreamDependencyFactory::CreateSessionDescription( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 506 | 486 |
| 507 scoped_refptr<WebRtcAudioCapturer> | 487 scoped_refptr<WebRtcAudioCapturer> |
| 508 MockMediaStreamDependencyFactory::CreateAudioCapturer( | 488 MockMediaStreamDependencyFactory::CreateAudioCapturer( |
| 509 int render_view_id, const StreamDeviceInfo& device_info, | 489 int render_view_id, const StreamDeviceInfo& device_info, |
| 510 const blink::WebMediaConstraints& constraints) { | 490 const blink::WebMediaConstraints& constraints) { |
| 511 return WebRtcAudioCapturer::CreateCapturer(-1, device_info, | 491 return WebRtcAudioCapturer::CreateCapturer(-1, device_info, |
| 512 constraints, NULL); | 492 constraints, NULL); |
| 513 } | 493 } |
| 514 | 494 |
| 515 } // namespace content | 495 } // namespace content |
| OLD | NEW |