| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 protected: | 108 protected: |
| 109 virtual ~MockMediaStream() {} | 109 virtual ~MockMediaStream() {} |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 std::string label_; | 112 std::string label_; |
| 113 AudioTrackVector audio_track_vector_; | 113 AudioTrackVector audio_track_vector_; |
| 114 VideoTrackVector video_track_vector_; | 114 VideoTrackVector video_track_vector_; |
| 115 webrtc::ObserverInterface* observer_; | 115 webrtc::ObserverInterface* observer_; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 MockVideoRenderer::MockVideoRenderer() |
| 119 : width_(0), |
| 120 height_(0), |
| 121 num_(0) {} |
| 122 |
| 123 MockVideoRenderer::~MockVideoRenderer() {} |
| 124 |
| 125 bool MockVideoRenderer::SetSize(int width, int height, int reserved) { |
| 126 width_ = width; |
| 127 height_ = height; |
| 128 return true; |
| 129 } |
| 130 |
| 131 bool MockVideoRenderer::RenderFrame(const cricket::VideoFrame* frame) { |
| 132 ++num_; |
| 133 return true; |
| 134 } |
| 135 |
| 118 MockAudioSource::MockAudioSource( | 136 MockAudioSource::MockAudioSource( |
| 119 const webrtc::MediaConstraintsInterface* constraints) | 137 const webrtc::MediaConstraintsInterface* constraints) |
| 120 : observer_(NULL), | 138 : observer_(NULL), |
| 121 state_(MediaSourceInterface::kInitializing), | 139 state_(MediaSourceInterface::kInitializing), |
| 122 optional_constraints_(constraints->GetOptional()), | 140 optional_constraints_(constraints->GetOptional()), |
| 123 mandatory_constraints_(constraints->GetMandatory()) { | 141 mandatory_constraints_(constraints->GetMandatory()) { |
| 124 } | 142 } |
| 125 | 143 |
| 126 MockAudioSource::~MockAudioSource() {} | 144 MockAudioSource::~MockAudioSource() {} |
| 127 | 145 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 187 |
| 170 void MockVideoSource::AddSink(cricket::VideoRenderer* output) { | 188 void MockVideoSource::AddSink(cricket::VideoRenderer* output) { |
| 171 NOTIMPLEMENTED(); | 189 NOTIMPLEMENTED(); |
| 172 } | 190 } |
| 173 | 191 |
| 174 void MockVideoSource::RemoveSink(cricket::VideoRenderer* output) { | 192 void MockVideoSource::RemoveSink(cricket::VideoRenderer* output) { |
| 175 NOTIMPLEMENTED(); | 193 NOTIMPLEMENTED(); |
| 176 } | 194 } |
| 177 | 195 |
| 178 cricket::VideoRenderer* MockVideoSource::FrameInput() { | 196 cricket::VideoRenderer* MockVideoSource::FrameInput() { |
| 179 NOTIMPLEMENTED(); | 197 return &renderer_; |
| 180 return NULL; | |
| 181 } | 198 } |
| 182 | 199 |
| 183 void MockVideoSource::RegisterObserver(webrtc::ObserverInterface* observer) { | 200 void MockVideoSource::RegisterObserver(webrtc::ObserverInterface* observer) { |
| 184 observers_.push_back(observer); | 201 observers_.push_back(observer); |
| 185 } | 202 } |
| 186 | 203 |
| 187 void MockVideoSource::UnregisterObserver(webrtc::ObserverInterface* observer) { | 204 void MockVideoSource::UnregisterObserver(webrtc::ObserverInterface* observer) { |
| 188 for (std::vector<ObserverInterface*>::iterator it = observers_.begin(); | 205 for (std::vector<ObserverInterface*>::iterator it = observers_.begin(); |
| 189 it != observers_.end(); ++it) { | 206 it != observers_.end(); ++it) { |
| 190 if (*it == observer) { | 207 if (*it == observer) { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 419 |
| 403 scoped_refptr<webrtc::VideoSourceInterface> | 420 scoped_refptr<webrtc::VideoSourceInterface> |
| 404 MockMediaStreamDependencyFactory::CreateLocalVideoSource( | 421 MockMediaStreamDependencyFactory::CreateLocalVideoSource( |
| 405 int video_session_id, | 422 int video_session_id, |
| 406 bool is_screencast, | 423 bool is_screencast, |
| 407 const webrtc::MediaConstraintsInterface* constraints) { | 424 const webrtc::MediaConstraintsInterface* constraints) { |
| 408 last_video_source_ = new talk_base::RefCountedObject<MockVideoSource>(); | 425 last_video_source_ = new talk_base::RefCountedObject<MockVideoSource>(); |
| 409 return last_video_source_; | 426 return last_video_source_; |
| 410 } | 427 } |
| 411 | 428 |
| 429 scoped_refptr<webrtc::VideoSourceInterface> |
| 430 MockMediaStreamDependencyFactory::CreateVideoSource( |
| 431 cricket::VideoCapturer* capturer, |
| 432 const webrtc::MediaConstraintsInterface* constraints) { |
| 433 last_video_source_ = new talk_base::RefCountedObject<MockVideoSource>(); |
| 434 return last_video_source_; |
| 435 } |
| 436 |
| 412 scoped_refptr<WebAudioCapturerSource> | 437 scoped_refptr<WebAudioCapturerSource> |
| 413 MockMediaStreamDependencyFactory::CreateWebAudioSource( | 438 MockMediaStreamDependencyFactory::CreateWebAudioSource( |
| 414 blink::WebMediaStreamSource* source, | 439 blink::WebMediaStreamSource* source, |
| 415 const RTCMediaConstraints& constraints) { | 440 const RTCMediaConstraints& constraints) { |
| 416 return NULL; | 441 return NULL; |
| 417 } | 442 } |
| 418 | 443 |
| 419 scoped_refptr<webrtc::MediaStreamInterface> | 444 scoped_refptr<webrtc::MediaStreamInterface> |
| 420 MockMediaStreamDependencyFactory::CreateLocalMediaStream( | 445 MockMediaStreamDependencyFactory::CreateLocalMediaStream( |
| 421 const std::string& label) { | 446 const std::string& label) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 } | 501 } |
| 477 | 502 |
| 478 scoped_refptr<WebRtcAudioCapturer> | 503 scoped_refptr<WebRtcAudioCapturer> |
| 479 MockMediaStreamDependencyFactory::MaybeCreateAudioCapturer( | 504 MockMediaStreamDependencyFactory::MaybeCreateAudioCapturer( |
| 480 int render_view_id, const StreamDeviceInfo& device_info, | 505 int render_view_id, const StreamDeviceInfo& device_info, |
| 481 const blink::WebMediaConstraints& constraints) { | 506 const blink::WebMediaConstraints& constraints) { |
| 482 return WebRtcAudioCapturer::CreateCapturer(); | 507 return WebRtcAudioCapturer::CreateCapturer(); |
| 483 } | 508 } |
| 484 | 509 |
| 485 } // namespace content | 510 } // namespace content |
| OLD | NEW |