| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/webrtc/mock_peer_connection_dependency_factory.
h" | 5 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory.
h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 int GetFrameNum() const { | 145 int GetFrameNum() const { |
| 146 return number_of_capturered_frames_; | 146 return number_of_capturered_frames_; |
| 147 } | 147 } |
| 148 | 148 |
| 149 private: | 149 private: |
| 150 int number_of_capturered_frames_; | 150 int number_of_capturered_frames_; |
| 151 int width_; | 151 int width_; |
| 152 int height_; | 152 int height_; |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 MockAudioSource::MockAudioSource(const cricket::AudioOptions& options, | |
| 156 bool remote) | |
| 157 : remote_(remote), state_(MediaSourceInterface::kLive) {} | |
| 158 | |
| 159 MockAudioSource::~MockAudioSource() {} | |
| 160 | |
| 161 void MockAudioSource::RegisterObserver(webrtc::ObserverInterface* observer) { | |
| 162 DCHECK(observers_.find(observer) == observers_.end()); | |
| 163 observers_.insert(observer); | |
| 164 } | |
| 165 | |
| 166 void MockAudioSource::UnregisterObserver(webrtc::ObserverInterface* observer) { | |
| 167 DCHECK(observers_.find(observer) != observers_.end()); | |
| 168 observers_.erase(observer); | |
| 169 } | |
| 170 | |
| 171 webrtc::MediaSourceInterface::SourceState MockAudioSource::state() const { | |
| 172 return state_; | |
| 173 } | |
| 174 | |
| 175 bool MockAudioSource::remote() const { | |
| 176 return remote_; | |
| 177 } | |
| 178 | |
| 179 scoped_refptr<MockWebRtcAudioTrack> MockWebRtcAudioTrack::Create( | 155 scoped_refptr<MockWebRtcAudioTrack> MockWebRtcAudioTrack::Create( |
| 180 const std::string& id) { | 156 const std::string& id) { |
| 181 return new rtc::RefCountedObject<MockWebRtcAudioTrack>(id); | 157 return new rtc::RefCountedObject<MockWebRtcAudioTrack>(id); |
| 182 } | 158 } |
| 183 | 159 |
| 184 MockWebRtcAudioTrack::MockWebRtcAudioTrack(const std::string& id) | 160 MockWebRtcAudioTrack::MockWebRtcAudioTrack(const std::string& id) |
| 185 : id_(id), | 161 : id_(id), |
| 186 enabled_(true), | 162 enabled_(true), |
| 187 state_(webrtc::MediaStreamTrackInterface::kLive) {} | 163 state_(webrtc::MediaStreamTrackInterface::kLive) {} |
| 188 | 164 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 MockPeerConnectionDependencyFactory::~MockPeerConnectionDependencyFactory() {} | 360 MockPeerConnectionDependencyFactory::~MockPeerConnectionDependencyFactory() {} |
| 385 | 361 |
| 386 scoped_refptr<webrtc::PeerConnectionInterface> | 362 scoped_refptr<webrtc::PeerConnectionInterface> |
| 387 MockPeerConnectionDependencyFactory::CreatePeerConnection( | 363 MockPeerConnectionDependencyFactory::CreatePeerConnection( |
| 388 const webrtc::PeerConnectionInterface::RTCConfiguration& config, | 364 const webrtc::PeerConnectionInterface::RTCConfiguration& config, |
| 389 blink::WebFrame* frame, | 365 blink::WebFrame* frame, |
| 390 webrtc::PeerConnectionObserver* observer) { | 366 webrtc::PeerConnectionObserver* observer) { |
| 391 return new rtc::RefCountedObject<MockPeerConnectionImpl>(this, observer); | 367 return new rtc::RefCountedObject<MockPeerConnectionImpl>(this, observer); |
| 392 } | 368 } |
| 393 | 369 |
| 394 scoped_refptr<webrtc::AudioSourceInterface> | |
| 395 MockPeerConnectionDependencyFactory::CreateLocalAudioSource( | |
| 396 const cricket::AudioOptions& options) { | |
| 397 last_audio_source_ = | |
| 398 new rtc::RefCountedObject<MockAudioSource>(options, false); | |
| 399 return last_audio_source_; | |
| 400 } | |
| 401 | |
| 402 WebRtcVideoCapturerAdapter* | 370 WebRtcVideoCapturerAdapter* |
| 403 MockPeerConnectionDependencyFactory::CreateVideoCapturer( | 371 MockPeerConnectionDependencyFactory::CreateVideoCapturer( |
| 404 bool is_screen_capture) { | 372 bool is_screen_capture) { |
| 405 return new MockRtcVideoCapturer(is_screen_capture); | 373 return new MockRtcVideoCapturer(is_screen_capture); |
| 406 } | 374 } |
| 407 | 375 |
| 408 scoped_refptr<webrtc::VideoTrackSourceInterface> | 376 scoped_refptr<webrtc::VideoTrackSourceInterface> |
| 409 MockPeerConnectionDependencyFactory::CreateVideoSource( | 377 MockPeerConnectionDependencyFactory::CreateVideoSource( |
| 410 cricket::VideoCapturer* capturer) { | 378 cricket::VideoCapturer* capturer) { |
| 411 // Video source normally take ownership of |capturer|. | 379 // Video source normally take ownership of |capturer|. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 const std::string& sdp) { | 420 const std::string& sdp) { |
| 453 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp); | 421 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp); |
| 454 } | 422 } |
| 455 | 423 |
| 456 scoped_refptr<base::SingleThreadTaskRunner> | 424 scoped_refptr<base::SingleThreadTaskRunner> |
| 457 MockPeerConnectionDependencyFactory::GetWebRtcSignalingThread() const { | 425 MockPeerConnectionDependencyFactory::GetWebRtcSignalingThread() const { |
| 458 return signaling_thread_.task_runner(); | 426 return signaling_thread_.task_runner(); |
| 459 } | 427 } |
| 460 | 428 |
| 461 } // namespace content | 429 } // namespace content |
| OLD | NEW |