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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 state_ = MediaSourceInterface::kEnded; | 129 state_ = MediaSourceInterface::kEnded; |
130 if (observer_) | 130 if (observer_) |
131 observer_->OnChanged(); | 131 observer_->OnChanged(); |
132 } | 132 } |
133 | 133 |
134 webrtc::MediaSourceInterface::SourceState MockAudioSource::state() const { | 134 webrtc::MediaSourceInterface::SourceState MockAudioSource::state() const { |
135 return state_; | 135 return state_; |
136 } | 136 } |
137 | 137 |
138 MockVideoSource::MockVideoSource() | 138 MockVideoSource::MockVideoSource() |
139 : observer_(NULL), | 139 : state_(MediaSourceInterface::kInitializing) { |
140 state_(MediaSourceInterface::kInitializing) { | |
141 } | 140 } |
142 | 141 |
143 MockVideoSource::~MockVideoSource() {} | 142 MockVideoSource::~MockVideoSource() {} |
144 | 143 |
145 cricket::VideoCapturer* MockVideoSource::GetVideoCapturer() { | 144 cricket::VideoCapturer* MockVideoSource::GetVideoCapturer() { |
146 NOTIMPLEMENTED(); | 145 NOTIMPLEMENTED(); |
147 return NULL; | 146 return NULL; |
148 } | 147 } |
149 | 148 |
150 void MockVideoSource::AddSink(cricket::VideoRenderer* output) { | 149 void MockVideoSource::AddSink(cricket::VideoRenderer* output) { |
151 NOTIMPLEMENTED(); | 150 NOTIMPLEMENTED(); |
152 } | 151 } |
153 | 152 |
154 void MockVideoSource::RemoveSink(cricket::VideoRenderer* output) { | 153 void MockVideoSource::RemoveSink(cricket::VideoRenderer* output) { |
155 NOTIMPLEMENTED(); | 154 NOTIMPLEMENTED(); |
156 } | 155 } |
157 | 156 |
158 void MockVideoSource::RegisterObserver(webrtc::ObserverInterface* observer) { | 157 void MockVideoSource::RegisterObserver(webrtc::ObserverInterface* observer) { |
159 observer_ = observer; | 158 observers_.push_back(observer); |
160 } | 159 } |
161 | 160 |
162 void MockVideoSource::UnregisterObserver(webrtc::ObserverInterface* observer) { | 161 void MockVideoSource::UnregisterObserver(webrtc::ObserverInterface* observer) { |
163 DCHECK(observer_ == observer); | 162 for (std::list<ObserverInterface*>::iterator it = observers_.begin(); |
164 observer_ = NULL; | 163 it != observers_.end(); it++) { |
| 164 if (*it == observer) { |
| 165 observers_.erase(it); |
| 166 break; |
| 167 } |
| 168 } |
| 169 } |
| 170 |
| 171 void MockVideoSource::FireOnChanged() { |
| 172 std::list<ObserverInterface*> observers = observers_; |
| 173 for (std::list<ObserverInterface*>::iterator it = observers.begin(); |
| 174 it != observers.end(); ++it) { |
| 175 (*it)->OnChanged(); |
| 176 } |
165 } | 177 } |
166 | 178 |
167 void MockVideoSource::SetLive() { | 179 void MockVideoSource::SetLive() { |
168 DCHECK_EQ(MediaSourceInterface::kInitializing, state_); | 180 DCHECK_EQ(MediaSourceInterface::kInitializing, state_); |
169 state_ = MediaSourceInterface::kLive; | 181 state_ = MediaSourceInterface::kLive; |
170 if (observer_) | 182 FireOnChanged(); |
171 observer_->OnChanged(); | |
172 } | 183 } |
173 | 184 |
174 void MockVideoSource::SetEnded() { | 185 void MockVideoSource::SetEnded() { |
175 DCHECK_NE(MediaSourceInterface::kEnded, state_); | 186 DCHECK_NE(MediaSourceInterface::kEnded, state_); |
176 state_ = MediaSourceInterface::kEnded; | 187 state_ = MediaSourceInterface::kEnded; |
177 if (observer_) | 188 FireOnChanged(); |
178 observer_->OnChanged(); | |
179 } | 189 } |
180 | 190 |
181 webrtc::MediaSourceInterface::SourceState MockVideoSource::state() const { | 191 webrtc::MediaSourceInterface::SourceState MockVideoSource::state() const { |
182 return state_; | 192 return state_; |
183 } | 193 } |
184 | 194 |
185 const cricket::VideoOptions* MockVideoSource::options() const { | 195 const cricket::VideoOptions* MockVideoSource::options() const { |
186 NOTIMPLEMENTED(); | 196 NOTIMPLEMENTED(); |
187 return NULL; | 197 return NULL; |
188 } | 198 } |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 | 468 |
459 webrtc::IceCandidateInterface* | 469 webrtc::IceCandidateInterface* |
460 MockMediaStreamDependencyFactory::CreateIceCandidate( | 470 MockMediaStreamDependencyFactory::CreateIceCandidate( |
461 const std::string& sdp_mid, | 471 const std::string& sdp_mid, |
462 int sdp_mline_index, | 472 int sdp_mline_index, |
463 const std::string& sdp) { | 473 const std::string& sdp) { |
464 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp); | 474 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp); |
465 } | 475 } |
466 | 476 |
467 } // namespace content | 477 } // namespace content |
OLD | NEW |