| 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/utf_string_conversions.h" | 8 #include "base/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/webrtc_audio_capturer.h" |
| 11 #include "content/renderer/media/webrtc_local_audio_track.h" |
| 10 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | 12 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
| 11 #include "third_party/libjingle/source/talk/base/scoped_ref_ptr.h" | 13 #include "third_party/libjingle/source/talk/base/scoped_ref_ptr.h" |
| 12 #include "third_party/libjingle/source/talk/media/base/videocapturer.h" | 14 #include "third_party/libjingle/source/talk/media/base/videocapturer.h" |
| 13 | 15 |
| 14 using webrtc::AudioSourceInterface; | 16 using webrtc::AudioSourceInterface; |
| 15 using webrtc::AudioTrackInterface; | 17 using webrtc::AudioTrackInterface; |
| 16 using webrtc::AudioTrackVector; | 18 using webrtc::AudioTrackVector; |
| 17 using webrtc::IceCandidateCollection; | 19 using webrtc::IceCandidateCollection; |
| 18 using webrtc::IceCandidateInterface; | 20 using webrtc::IceCandidateInterface; |
| 19 using webrtc::MediaStreamInterface; | 21 using webrtc::MediaStreamInterface; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 271 |
| 270 void MockLocalVideoTrack::UnregisterObserver(ObserverInterface* observer) { | 272 void MockLocalVideoTrack::UnregisterObserver(ObserverInterface* observer) { |
| 271 DCHECK(observer_ == observer); | 273 DCHECK(observer_ == observer); |
| 272 observer_ = NULL; | 274 observer_ = NULL; |
| 273 } | 275 } |
| 274 | 276 |
| 275 VideoSourceInterface* MockLocalVideoTrack::GetSource() const { | 277 VideoSourceInterface* MockLocalVideoTrack::GetSource() const { |
| 276 return source_.get(); | 278 return source_.get(); |
| 277 } | 279 } |
| 278 | 280 |
| 279 std::string MockLocalAudioTrack::kind() const { | |
| 280 NOTIMPLEMENTED(); | |
| 281 return std::string(); | |
| 282 } | |
| 283 | |
| 284 std::string MockLocalAudioTrack::id() const { return id_; } | |
| 285 | |
| 286 bool MockLocalAudioTrack::enabled() const { return enabled_; } | |
| 287 | |
| 288 MockLocalAudioTrack::TrackState MockLocalAudioTrack::state() const { | |
| 289 return state_; | |
| 290 } | |
| 291 | |
| 292 bool MockLocalAudioTrack::set_enabled(bool enable) { | |
| 293 enabled_ = enable; | |
| 294 return true; | |
| 295 } | |
| 296 | |
| 297 bool MockLocalAudioTrack::set_state(TrackState new_state) { | |
| 298 state_ = new_state; | |
| 299 if (observer_) | |
| 300 observer_->OnChanged(); | |
| 301 return true; | |
| 302 } | |
| 303 | |
| 304 void MockLocalAudioTrack::RegisterObserver(ObserverInterface* observer) { | |
| 305 observer_ = observer; | |
| 306 } | |
| 307 | |
| 308 void MockLocalAudioTrack::UnregisterObserver(ObserverInterface* observer) { | |
| 309 DCHECK(observer_ == observer); | |
| 310 observer_ = NULL; | |
| 311 } | |
| 312 | |
| 313 AudioSourceInterface* MockLocalAudioTrack::GetSource() const { | |
| 314 NOTIMPLEMENTED(); | |
| 315 return NULL; | |
| 316 } | |
| 317 | |
| 318 class MockSessionDescription : public SessionDescriptionInterface { | 281 class MockSessionDescription : public SessionDescriptionInterface { |
| 319 public: | 282 public: |
| 320 MockSessionDescription(const std::string& type, | 283 MockSessionDescription(const std::string& type, |
| 321 const std::string& sdp) | 284 const std::string& sdp) |
| 322 : type_(type), | 285 : type_(type), |
| 323 sdp_(sdp) { | 286 sdp_(sdp) { |
| 324 } | 287 } |
| 325 virtual ~MockSessionDescription() {} | 288 virtual ~MockSessionDescription() {} |
| 326 virtual cricket::SessionDescription* description() OVERRIDE { | 289 virtual cricket::SessionDescription* description() OVERRIDE { |
| 327 NOTIMPLEMENTED(); | 290 NOTIMPLEMENTED(); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 source->SetVideoCapturer(capturer); | 446 source->SetVideoCapturer(capturer); |
| 484 | 447 |
| 485 return new talk_base::RefCountedObject<MockLocalVideoTrack>(id, source); | 448 return new talk_base::RefCountedObject<MockLocalVideoTrack>(id, source); |
| 486 } | 449 } |
| 487 | 450 |
| 488 scoped_refptr<webrtc::AudioTrackInterface> | 451 scoped_refptr<webrtc::AudioTrackInterface> |
| 489 MockMediaStreamDependencyFactory::CreateLocalAudioTrack( | 452 MockMediaStreamDependencyFactory::CreateLocalAudioTrack( |
| 490 const std::string& id, | 453 const std::string& id, |
| 491 webrtc::AudioSourceInterface* source) { | 454 webrtc::AudioSourceInterface* source) { |
| 492 DCHECK(mock_pc_factory_created_); | 455 DCHECK(mock_pc_factory_created_); |
| 493 scoped_refptr<webrtc::AudioTrackInterface> track( | 456 scoped_refptr<WebRtcAudioCapturer> capturer( |
| 494 new talk_base::RefCountedObject<MockLocalAudioTrack>(id)); | 457 WebRtcAudioCapturer::CreateCapturer()); |
| 495 return track; | 458 return WebRtcLocalAudioTrack::Create(id, capturer, source); |
| 496 } | 459 } |
| 497 | 460 |
| 498 SessionDescriptionInterface* | 461 SessionDescriptionInterface* |
| 499 MockMediaStreamDependencyFactory::CreateSessionDescription( | 462 MockMediaStreamDependencyFactory::CreateSessionDescription( |
| 500 const std::string& type, | 463 const std::string& type, |
| 501 const std::string& sdp, | 464 const std::string& sdp, |
| 502 webrtc::SdpParseError* error) { | 465 webrtc::SdpParseError* error) { |
| 503 return new MockSessionDescription(type, sdp); | 466 return new MockSessionDescription(type, sdp); |
| 504 } | 467 } |
| 505 | 468 |
| 506 webrtc::IceCandidateInterface* | 469 webrtc::IceCandidateInterface* |
| 507 MockMediaStreamDependencyFactory::CreateIceCandidate( | 470 MockMediaStreamDependencyFactory::CreateIceCandidate( |
| 508 const std::string& sdp_mid, | 471 const std::string& sdp_mid, |
| 509 int sdp_mline_index, | 472 int sdp_mline_index, |
| 510 const std::string& sdp) { | 473 const std::string& sdp) { |
| 511 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp); | 474 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp); |
| 512 } | 475 } |
| 513 | 476 |
| 514 } // namespace content | 477 } // namespace content |
| OLD | NEW |