Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: content/renderer/media/mock_media_stream_dependency_factory.cc

Issue 131763002: Adds MediaStreamSource, MediaStreamAudioSource and MediaStreamVideoCaptureDeviceSource (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 bool MockVideoRenderer::RenderFrame(const cricket::VideoFrame* frame) { 131 bool MockVideoRenderer::RenderFrame(const cricket::VideoFrame* frame) {
132 ++num_; 132 ++num_;
133 return true; 133 return true;
134 } 134 }
135 135
136 MockAudioSource::MockAudioSource( 136 MockAudioSource::MockAudioSource(
137 const webrtc::MediaConstraintsInterface* constraints) 137 const webrtc::MediaConstraintsInterface* constraints)
138 : observer_(NULL), 138 : observer_(NULL),
139 state_(MediaSourceInterface::kInitializing), 139 state_(MediaSourceInterface::kLive),
140 optional_constraints_(constraints->GetOptional()), 140 optional_constraints_(constraints->GetOptional()),
141 mandatory_constraints_(constraints->GetMandatory()) { 141 mandatory_constraints_(constraints->GetMandatory()) {
142 } 142 }
143 143
144 MockAudioSource::~MockAudioSource() {} 144 MockAudioSource::~MockAudioSource() {}
145 145
146 void MockAudioSource::RegisterObserver(webrtc::ObserverInterface* observer) { 146 void MockAudioSource::RegisterObserver(webrtc::ObserverInterface* observer) {
147 observer_ = observer; 147 observer_ = observer;
148 } 148 }
149 149
150 void MockAudioSource::UnregisterObserver(webrtc::ObserverInterface* observer) { 150 void MockAudioSource::UnregisterObserver(webrtc::ObserverInterface* observer) {
151 DCHECK(observer_ == observer); 151 DCHECK(observer_ == observer);
152 observer_ = NULL; 152 observer_ = NULL;
153 } 153 }
154 154
155 void MockAudioSource::SetLive() {
156 DCHECK(state_ == MediaSourceInterface::kInitializing ||
157 state_ == MediaSourceInterface::kLive);
158 state_ = MediaSourceInterface::kLive;
159 if (observer_)
160 observer_->OnChanged();
161 }
162
163 void MockAudioSource::SetEnded() {
164 DCHECK_NE(MediaSourceInterface::kEnded, state_);
165 state_ = MediaSourceInterface::kEnded;
166 if (observer_)
167 observer_->OnChanged();
168 }
169
170 webrtc::MediaSourceInterface::SourceState MockAudioSource::state() const { 155 webrtc::MediaSourceInterface::SourceState MockAudioSource::state() const {
171 return state_; 156 return state_;
172 } 157 }
173 158
174 MockVideoSource::MockVideoSource() 159 MockVideoSource::MockVideoSource()
175 : state_(MediaSourceInterface::kInitializing) { 160 : state_(MediaSourceInterface::kInitializing) {
176 } 161 }
177 162
178 MockVideoSource::~MockVideoSource() {} 163 MockVideoSource::~MockVideoSource() {}
179 164
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 return true; 362 return true;
378 } 363 }
379 364
380 private: 365 private:
381 std::string sdp_mid_; 366 std::string sdp_mid_;
382 int sdp_mline_index_; 367 int sdp_mline_index_;
383 std::string sdp_; 368 std::string sdp_;
384 }; 369 };
385 370
386 MockMediaStreamDependencyFactory::MockMediaStreamDependencyFactory() 371 MockMediaStreamDependencyFactory::MockMediaStreamDependencyFactory()
387 : MediaStreamDependencyFactory(NULL), 372 : MediaStreamDependencyFactory(NULL) {
388 mock_pc_factory_created_(false) {
389 } 373 }
390 374
391 MockMediaStreamDependencyFactory::~MockMediaStreamDependencyFactory() {} 375 MockMediaStreamDependencyFactory::~MockMediaStreamDependencyFactory() {}
392 376
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> 377 scoped_refptr<webrtc::PeerConnectionInterface>
403 MockMediaStreamDependencyFactory::CreatePeerConnection( 378 MockMediaStreamDependencyFactory::CreatePeerConnection(
404 const webrtc::PeerConnectionInterface::IceServers& ice_servers, 379 const webrtc::PeerConnectionInterface::IceServers& ice_servers,
405 const webrtc::MediaConstraintsInterface* constraints, 380 const webrtc::MediaConstraintsInterface* constraints,
406 blink::WebFrame* frame, 381 blink::WebFrame* frame,
407 webrtc::PeerConnectionObserver* observer) { 382 webrtc::PeerConnectionObserver* observer) {
408 DCHECK(mock_pc_factory_created_);
409 return new talk_base::RefCountedObject<MockPeerConnectionImpl>(this); 383 return new talk_base::RefCountedObject<MockPeerConnectionImpl>(this);
410 } 384 }
411 385
412 scoped_refptr<webrtc::AudioSourceInterface> 386 scoped_refptr<webrtc::AudioSourceInterface>
413 MockMediaStreamDependencyFactory::CreateLocalAudioSource( 387 MockMediaStreamDependencyFactory::CreateLocalAudioSource(
414 const webrtc::MediaConstraintsInterface* constraints) { 388 const webrtc::MediaConstraintsInterface* constraints) {
415 last_audio_source_ = 389 last_audio_source_ =
416 new talk_base::RefCountedObject<MockAudioSource>(constraints); 390 new talk_base::RefCountedObject<MockAudioSource>(constraints);
417 return last_audio_source_; 391 return last_audio_source_;
418 } 392 }
419 393
420 scoped_refptr<webrtc::VideoSourceInterface> 394 cricket::VideoCapturer* MockMediaStreamDependencyFactory::CreateVideoCapturer(
421 MockMediaStreamDependencyFactory::CreateLocalVideoSource( 395 const StreamDeviceInfo& info) {
422 int video_session_id, 396 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 } 397 }
428 398
429 scoped_refptr<webrtc::VideoSourceInterface> 399 scoped_refptr<webrtc::VideoSourceInterface>
430 MockMediaStreamDependencyFactory::CreateVideoSource( 400 MockMediaStreamDependencyFactory::CreateVideoSource(
431 cricket::VideoCapturer* capturer, 401 cricket::VideoCapturer* capturer,
432 const webrtc::MediaConstraintsInterface* constraints) { 402 const webrtc::MediaConstraintsInterface* constraints) {
433 last_video_source_ = new talk_base::RefCountedObject<MockVideoSource>(); 403 last_video_source_ = new talk_base::RefCountedObject<MockVideoSource>();
434 last_video_source_->SetVideoCapturer(capturer); 404 last_video_source_->SetVideoCapturer(capturer);
435 return last_video_source_; 405 return last_video_source_;
436 } 406 }
437 407
438 scoped_refptr<WebAudioCapturerSource> 408 scoped_refptr<WebAudioCapturerSource>
439 MockMediaStreamDependencyFactory::CreateWebAudioSource( 409 MockMediaStreamDependencyFactory::CreateWebAudioSource(
440 blink::WebMediaStreamSource* source, 410 blink::WebMediaStreamSource* source,
441 const RTCMediaConstraints& constraints) { 411 const RTCMediaConstraints& constraints) {
442 return NULL; 412 return NULL;
443 } 413 }
444 414
445 scoped_refptr<webrtc::MediaStreamInterface> 415 scoped_refptr<webrtc::MediaStreamInterface>
446 MockMediaStreamDependencyFactory::CreateLocalMediaStream( 416 MockMediaStreamDependencyFactory::CreateLocalMediaStream(
447 const std::string& label) { 417 const std::string& label) {
448 DCHECK(mock_pc_factory_created_);
449 return new talk_base::RefCountedObject<MockMediaStream>(label); 418 return new talk_base::RefCountedObject<MockMediaStream>(label);
450 } 419 }
451 420
452 scoped_refptr<webrtc::VideoTrackInterface> 421 scoped_refptr<webrtc::VideoTrackInterface>
453 MockMediaStreamDependencyFactory::CreateLocalVideoTrack( 422 MockMediaStreamDependencyFactory::CreateLocalVideoTrack(
454 const std::string& id, 423 const std::string& id,
455 webrtc::VideoSourceInterface* source) { 424 webrtc::VideoSourceInterface* source) {
456 DCHECK(mock_pc_factory_created_);
457 scoped_refptr<webrtc::VideoTrackInterface> track( 425 scoped_refptr<webrtc::VideoTrackInterface> track(
458 new talk_base::RefCountedObject<MockLocalVideoTrack>( 426 new talk_base::RefCountedObject<MockLocalVideoTrack>(
459 id, source)); 427 id, source));
460 return track; 428 return track;
461 } 429 }
462 430
463 scoped_refptr<webrtc::VideoTrackInterface> 431 scoped_refptr<webrtc::VideoTrackInterface>
464 MockMediaStreamDependencyFactory::CreateLocalVideoTrack( 432 MockMediaStreamDependencyFactory::CreateLocalVideoTrack(
465 const std::string& id, 433 const std::string& id,
466 cricket::VideoCapturer* capturer) { 434 cricket::VideoCapturer* capturer) {
467 DCHECK(mock_pc_factory_created_);
468
469 scoped_refptr<MockVideoSource> source = 435 scoped_refptr<MockVideoSource> source =
470 new talk_base::RefCountedObject<MockVideoSource>(); 436 new talk_base::RefCountedObject<MockVideoSource>();
471 source->SetVideoCapturer(capturer); 437 source->SetVideoCapturer(capturer);
472 438
473 return new talk_base::RefCountedObject<MockLocalVideoTrack>(id, source.get()); 439 return new talk_base::RefCountedObject<MockLocalVideoTrack>(id, source.get());
474 } 440 }
475 441
476 scoped_refptr<webrtc::AudioTrackInterface> 442 scoped_refptr<webrtc::AudioTrackInterface>
477 MockMediaStreamDependencyFactory::CreateLocalAudioTrack( 443 MockMediaStreamDependencyFactory::CreateLocalAudioTrack(
478 const std::string& id, 444 const std::string& id,
479 const scoped_refptr<WebRtcAudioCapturer>& capturer, 445 const scoped_refptr<WebRtcAudioCapturer>& capturer,
480 WebAudioCapturerSource* webaudio_source, 446 WebAudioCapturerSource* webaudio_source,
481 webrtc::AudioSourceInterface* source) { 447 webrtc::AudioSourceInterface* source) {
482 DCHECK(mock_pc_factory_created_);
483 blink::WebMediaConstraints constraints; 448 blink::WebMediaConstraints constraints;
484 scoped_refptr<WebRtcAudioCapturer> audio_capturer = capturer ? 449 scoped_refptr<WebRtcAudioCapturer> audio_capturer = capturer ?
485 capturer : WebRtcAudioCapturer::CreateCapturer(-1, StreamDeviceInfo(), 450 capturer : WebRtcAudioCapturer::CreateCapturer(-1, StreamDeviceInfo(),
486 constraints, NULL); 451 constraints, NULL);
487 return WebRtcLocalAudioTrack::Create( 452 return WebRtcLocalAudioTrack::Create(
488 id, audio_capturer, webaudio_source, source); 453 id, audio_capturer, webaudio_source, source);
489 } 454 }
490 455
491 SessionDescriptionInterface* 456 SessionDescriptionInterface*
492 MockMediaStreamDependencyFactory::CreateSessionDescription( 457 MockMediaStreamDependencyFactory::CreateSessionDescription(
(...skipping 13 matching lines...) Expand all
506 471
507 scoped_refptr<WebRtcAudioCapturer> 472 scoped_refptr<WebRtcAudioCapturer>
508 MockMediaStreamDependencyFactory::CreateAudioCapturer( 473 MockMediaStreamDependencyFactory::CreateAudioCapturer(
509 int render_view_id, const StreamDeviceInfo& device_info, 474 int render_view_id, const StreamDeviceInfo& device_info,
510 const blink::WebMediaConstraints& constraints) { 475 const blink::WebMediaConstraints& constraints) {
511 return WebRtcAudioCapturer::CreateCapturer(-1, device_info, 476 return WebRtcAudioCapturer::CreateCapturer(-1, device_info,
512 constraints, NULL); 477 constraints, NULL);
513 } 478 }
514 479
515 } // namespace content 480 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/mock_media_stream_dependency_factory.h ('k') | content/renderer/media/rtc_peer_connection_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698