| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 state_ = MediaSourceInterface::kEnded; | 141 state_ = MediaSourceInterface::kEnded; |
| 142 if (observer_) | 142 if (observer_) |
| 143 observer_->OnChanged(); | 143 observer_->OnChanged(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 webrtc::MediaSourceInterface::SourceState MockAudioSource::state() const { | 146 webrtc::MediaSourceInterface::SourceState MockAudioSource::state() const { |
| 147 return state_; | 147 return state_; |
| 148 } | 148 } |
| 149 | 149 |
| 150 MockVideoSource::MockVideoSource() | 150 MockVideoSource::MockVideoSource() |
| 151 : observer_(NULL), | 151 : state_(MediaSourceInterface::kInitializing) { |
| 152 state_(MediaSourceInterface::kInitializing) { | |
| 153 } | 152 } |
| 154 | 153 |
| 155 MockVideoSource::~MockVideoSource() {} | 154 MockVideoSource::~MockVideoSource() {} |
| 156 | 155 |
| 157 cricket::VideoCapturer* MockVideoSource::GetVideoCapturer() { | 156 cricket::VideoCapturer* MockVideoSource::GetVideoCapturer() { |
| 158 NOTIMPLEMENTED(); | 157 NOTIMPLEMENTED(); |
| 159 return NULL; | 158 return NULL; |
| 160 } | 159 } |
| 161 | 160 |
| 162 void MockVideoSource::AddSink(cricket::VideoRenderer* output) { | 161 void MockVideoSource::AddSink(cricket::VideoRenderer* output) { |
| 163 NOTIMPLEMENTED(); | 162 NOTIMPLEMENTED(); |
| 164 } | 163 } |
| 165 | 164 |
| 166 void MockVideoSource::RemoveSink(cricket::VideoRenderer* output) { | 165 void MockVideoSource::RemoveSink(cricket::VideoRenderer* output) { |
| 167 NOTIMPLEMENTED(); | 166 NOTIMPLEMENTED(); |
| 168 } | 167 } |
| 169 | 168 |
| 170 void MockVideoSource::RegisterObserver(webrtc::ObserverInterface* observer) { | 169 void MockVideoSource::RegisterObserver(webrtc::ObserverInterface* observer) { |
| 171 observer_ = observer; | 170 observers_.push_back(observer); |
| 172 } | 171 } |
| 173 | 172 |
| 174 void MockVideoSource::UnregisterObserver(webrtc::ObserverInterface* observer) { | 173 void MockVideoSource::UnregisterObserver(webrtc::ObserverInterface* observer) { |
| 175 DCHECK(observer_ == observer); | 174 for (std::vector<ObserverInterface*>::iterator it = observers_.begin(); |
| 176 observer_ = NULL; | 175 it != observers_.end(); ++it) { |
| 176 if (*it == observer) { |
| 177 observers_.erase(it); |
| 178 break; |
| 179 } |
| 180 } |
| 181 } |
| 182 |
| 183 void MockVideoSource::FireOnChanged() { |
| 184 std::vector<ObserverInterface*> observers(observers_); |
| 185 for (std::vector<ObserverInterface*>::iterator it = observers.begin(); |
| 186 it != observers.end(); ++it) { |
| 187 (*it)->OnChanged(); |
| 188 } |
| 177 } | 189 } |
| 178 | 190 |
| 179 void MockVideoSource::SetLive() { | 191 void MockVideoSource::SetLive() { |
| 180 DCHECK_EQ(MediaSourceInterface::kInitializing, state_); | 192 DCHECK_EQ(MediaSourceInterface::kInitializing, state_); |
| 181 state_ = MediaSourceInterface::kLive; | 193 state_ = MediaSourceInterface::kLive; |
| 182 if (observer_) | 194 FireOnChanged(); |
| 183 observer_->OnChanged(); | |
| 184 } | 195 } |
| 185 | 196 |
| 186 void MockVideoSource::SetEnded() { | 197 void MockVideoSource::SetEnded() { |
| 187 DCHECK_NE(MediaSourceInterface::kEnded, state_); | 198 DCHECK_NE(MediaSourceInterface::kEnded, state_); |
| 188 state_ = MediaSourceInterface::kEnded; | 199 state_ = MediaSourceInterface::kEnded; |
| 189 if (observer_) | 200 FireOnChanged(); |
| 190 observer_->OnChanged(); | |
| 191 } | 201 } |
| 192 | 202 |
| 193 webrtc::MediaSourceInterface::SourceState MockVideoSource::state() const { | 203 webrtc::MediaSourceInterface::SourceState MockVideoSource::state() const { |
| 194 return state_; | 204 return state_; |
| 195 } | 205 } |
| 196 | 206 |
| 197 const cricket::VideoOptions* MockVideoSource::options() const { | 207 const cricket::VideoOptions* MockVideoSource::options() const { |
| 198 NOTIMPLEMENTED(); | 208 NOTIMPLEMENTED(); |
| 199 return NULL; | 209 return NULL; |
| 200 } | 210 } |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 | 487 |
| 478 webrtc::IceCandidateInterface* | 488 webrtc::IceCandidateInterface* |
| 479 MockMediaStreamDependencyFactory::CreateIceCandidate( | 489 MockMediaStreamDependencyFactory::CreateIceCandidate( |
| 480 const std::string& sdp_mid, | 490 const std::string& sdp_mid, |
| 481 int sdp_mline_index, | 491 int sdp_mline_index, |
| 482 const std::string& sdp) { | 492 const std::string& sdp) { |
| 483 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp); | 493 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp); |
| 484 } | 494 } |
| 485 | 495 |
| 486 } // namespace content | 496 } // namespace content |
| OLD | NEW |