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 "content/renderer/media/mock_peer_connection_impl.h" | 8 #include "content/renderer/media/mock_peer_connection_impl.h" |
9 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | 9 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
10 #include "third_party/libjingle/source/talk/base/scoped_ref_ptr.h" | 10 #include "third_party/libjingle/source/talk/base/scoped_ref_ptr.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 virtual ~MockLocalMediaStream() {} | 116 virtual ~MockLocalMediaStream() {} |
117 | 117 |
118 private: | 118 private: |
119 std::string label_; | 119 std::string label_; |
120 scoped_refptr<MockAudioTracks> audio_tracks_; | 120 scoped_refptr<MockAudioTracks> audio_tracks_; |
121 scoped_refptr<MockVideoTracks> video_tracks_; | 121 scoped_refptr<MockVideoTracks> video_tracks_; |
122 AudioTrackVector audio_track_vector_; | 122 AudioTrackVector audio_track_vector_; |
123 VideoTrackVector video_track_vector_; | 123 VideoTrackVector video_track_vector_; |
124 }; | 124 }; |
125 | 125 |
| 126 MockAudioSource::MockAudioSource( |
| 127 const webrtc::MediaConstraintsInterface* constraints) |
| 128 : observer_(NULL), |
| 129 state_(MediaSourceInterface::kInitializing), |
| 130 optional_constraints_(constraints->GetOptional()), |
| 131 mandatory_constraints_(constraints->GetMandatory()) { |
| 132 } |
| 133 |
| 134 MockAudioSource::~MockAudioSource() {} |
| 135 |
| 136 void MockAudioSource::RegisterObserver(webrtc::ObserverInterface* observer) { |
| 137 observer_ = observer; |
| 138 } |
| 139 |
| 140 void MockAudioSource::UnregisterObserver(webrtc::ObserverInterface* observer) { |
| 141 DCHECK(observer_ == observer); |
| 142 observer_ = NULL; |
| 143 } |
| 144 |
| 145 void MockAudioSource::SetLive() { |
| 146 DCHECK_EQ(MediaSourceInterface::kInitializing, state_); |
| 147 state_ = MediaSourceInterface::kLive; |
| 148 if (observer_) |
| 149 observer_->OnChanged(); |
| 150 } |
| 151 |
| 152 void MockAudioSource::SetEnded() { |
| 153 DCHECK_NE(MediaSourceInterface::kEnded, state_); |
| 154 state_ = MediaSourceInterface::kEnded; |
| 155 if (observer_) |
| 156 observer_->OnChanged(); |
| 157 } |
| 158 |
| 159 webrtc::MediaSourceInterface::SourceState MockAudioSource::state() const { |
| 160 return state_; |
| 161 } |
| 162 |
126 MockVideoSource::MockVideoSource() | 163 MockVideoSource::MockVideoSource() |
127 : observer_(NULL), | 164 : observer_(NULL), |
128 state_(MediaSourceInterface::kInitializing) { | 165 state_(MediaSourceInterface::kInitializing) { |
129 } | 166 } |
130 | 167 |
131 MockVideoSource::~MockVideoSource() {} | 168 MockVideoSource::~MockVideoSource() {} |
132 | 169 |
133 cricket::VideoCapturer* MockVideoSource::GetVideoCapturer() { | 170 cricket::VideoCapturer* MockVideoSource::GetVideoCapturer() { |
134 NOTIMPLEMENTED(); | 171 NOTIMPLEMENTED(); |
135 return NULL; | 172 return NULL; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 scoped_refptr<webrtc::PeerConnectionInterface> | 406 scoped_refptr<webrtc::PeerConnectionInterface> |
370 MockMediaStreamDependencyFactory::CreatePeerConnection( | 407 MockMediaStreamDependencyFactory::CreatePeerConnection( |
371 const webrtc::JsepInterface::IceServers& ice_servers, | 408 const webrtc::JsepInterface::IceServers& ice_servers, |
372 const webrtc::MediaConstraintsInterface* constraints, | 409 const webrtc::MediaConstraintsInterface* constraints, |
373 WebKit::WebFrame* frame, | 410 WebKit::WebFrame* frame, |
374 webrtc::PeerConnectionObserver* observer) { | 411 webrtc::PeerConnectionObserver* observer) { |
375 DCHECK(mock_pc_factory_created_); | 412 DCHECK(mock_pc_factory_created_); |
376 return new talk_base::RefCountedObject<MockPeerConnectionImpl>(this); | 413 return new talk_base::RefCountedObject<MockPeerConnectionImpl>(this); |
377 } | 414 } |
378 | 415 |
| 416 scoped_refptr<webrtc::AudioSourceInterface> |
| 417 MockMediaStreamDependencyFactory::CreateLocalAudioSource( |
| 418 const webrtc::MediaConstraintsInterface* constraints) { |
| 419 last_audio_source_ = |
| 420 new talk_base::RefCountedObject<MockAudioSource>(constraints); |
| 421 return last_audio_source_; |
| 422 } |
| 423 |
379 scoped_refptr<webrtc::VideoSourceInterface> | 424 scoped_refptr<webrtc::VideoSourceInterface> |
380 MockMediaStreamDependencyFactory::CreateVideoSource( | 425 MockMediaStreamDependencyFactory::CreateLocalVideoSource( |
381 int video_session_id, | 426 int video_session_id, |
382 bool is_screencast, | 427 bool is_screencast, |
383 const webrtc::MediaConstraintsInterface* constraints) { | 428 const webrtc::MediaConstraintsInterface* constraints) { |
384 last_video_source_ = new talk_base::RefCountedObject<MockVideoSource>(); | 429 last_video_source_ = new talk_base::RefCountedObject<MockVideoSource>(); |
385 return last_video_source_; | 430 return last_video_source_; |
386 } | 431 } |
387 | 432 |
388 bool MockMediaStreamDependencyFactory::InitializeAudioSource( | 433 bool MockMediaStreamDependencyFactory::InitializeAudioSource( |
389 const StreamDeviceInfo& device_info) { | 434 const StreamDeviceInfo& device_info) { |
390 return true; | 435 return true; |
(...skipping 18 matching lines...) Expand all Loading... |
409 DCHECK(mock_pc_factory_created_); | 454 DCHECK(mock_pc_factory_created_); |
410 scoped_refptr<webrtc::VideoTrackInterface> track( | 455 scoped_refptr<webrtc::VideoTrackInterface> track( |
411 new talk_base::RefCountedObject<MockLocalVideoTrack>( | 456 new talk_base::RefCountedObject<MockLocalVideoTrack>( |
412 id, source)); | 457 id, source)); |
413 return track; | 458 return track; |
414 } | 459 } |
415 | 460 |
416 scoped_refptr<webrtc::LocalAudioTrackInterface> | 461 scoped_refptr<webrtc::LocalAudioTrackInterface> |
417 MockMediaStreamDependencyFactory::CreateLocalAudioTrack( | 462 MockMediaStreamDependencyFactory::CreateLocalAudioTrack( |
418 const std::string& id, | 463 const std::string& id, |
419 webrtc::AudioDeviceModule* audio_device) { | 464 webrtc::AudioSourceInterface* source) { |
420 DCHECK(mock_pc_factory_created_); | 465 DCHECK(mock_pc_factory_created_); |
421 scoped_refptr<webrtc::LocalAudioTrackInterface> track( | 466 scoped_refptr<webrtc::LocalAudioTrackInterface> track( |
422 new talk_base::RefCountedObject<MockLocalAudioTrack>(id)); | 467 new talk_base::RefCountedObject<MockLocalAudioTrack>(id)); |
423 return track; | 468 return track; |
424 } | 469 } |
425 | 470 |
426 SessionDescriptionInterface* | 471 SessionDescriptionInterface* |
427 MockMediaStreamDependencyFactory::CreateSessionDescription( | 472 MockMediaStreamDependencyFactory::CreateSessionDescription( |
428 const std::string& type, | 473 const std::string& type, |
429 const std::string& sdp) { | 474 const std::string& sdp) { |
430 return new MockSessionDescription(type, sdp); | 475 return new MockSessionDescription(type, sdp); |
431 } | 476 } |
432 | 477 |
433 webrtc::IceCandidateInterface* | 478 webrtc::IceCandidateInterface* |
434 MockMediaStreamDependencyFactory::CreateIceCandidate( | 479 MockMediaStreamDependencyFactory::CreateIceCandidate( |
435 const std::string& sdp_mid, | 480 const std::string& sdp_mid, |
436 int sdp_mline_index, | 481 int sdp_mline_index, |
437 const std::string& sdp) { | 482 const std::string& sdp) { |
438 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp); | 483 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp); |
439 } | 484 } |
440 | 485 |
441 } // namespace content | 486 } // namespace content |
OLD | NEW |