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

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

Issue 14200016: Added implementation of RemoteMediaStreams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 "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 21 matching lines...) Expand all
32 if ((*it)->id() == track_id) { 32 if ((*it)->id() == track_id) {
33 break; 33 break;
34 } 34 }
35 } 35 }
36 return it; 36 return it;
37 }; 37 };
38 38
39 class MockMediaStream : public webrtc::MediaStreamInterface { 39 class MockMediaStream : public webrtc::MediaStreamInterface {
40 public: 40 public:
41 explicit MockMediaStream(const std::string& label) 41 explicit MockMediaStream(const std::string& label)
42 : label_(label) { 42 : label_(label),
43 observer_(NULL) {
43 } 44 }
44 virtual bool AddTrack(AudioTrackInterface* track) OVERRIDE { 45 virtual bool AddTrack(AudioTrackInterface* track) OVERRIDE {
45 audio_track_vector_.push_back(track); 46 audio_track_vector_.push_back(track);
47 if (observer_)
48 observer_->OnChanged();
46 return true; 49 return true;
47 } 50 }
48 virtual bool AddTrack(VideoTrackInterface* track) OVERRIDE { 51 virtual bool AddTrack(VideoTrackInterface* track) OVERRIDE {
49 video_track_vector_.push_back(track); 52 video_track_vector_.push_back(track);
53 if (observer_)
54 observer_->OnChanged();
50 return true; 55 return true;
51 } 56 }
52 virtual bool RemoveTrack(AudioTrackInterface* track) OVERRIDE { 57 virtual bool RemoveTrack(AudioTrackInterface* track) OVERRIDE {
53 AudioTrackVector::iterator it = FindTrack(&audio_track_vector_, 58 AudioTrackVector::iterator it = FindTrack(&audio_track_vector_,
54 track->id()); 59 track->id());
55 if (it == audio_track_vector_.end()) 60 if (it == audio_track_vector_.end())
56 return false; 61 return false;
57 audio_track_vector_.erase(it); 62 audio_track_vector_.erase(it);
63 if (observer_)
64 observer_->OnChanged();
58 return true; 65 return true;
59 } 66 }
60 virtual bool RemoveTrack(VideoTrackInterface* track) OVERRIDE { 67 virtual bool RemoveTrack(VideoTrackInterface* track) OVERRIDE {
61 VideoTrackVector::iterator it = FindTrack(&video_track_vector_, 68 VideoTrackVector::iterator it = FindTrack(&video_track_vector_,
62 track->id()); 69 track->id());
63 if (it == video_track_vector_.end()) 70 if (it == video_track_vector_.end())
64 return false; 71 return false;
65 video_track_vector_.erase(it); 72 video_track_vector_.erase(it);
73 if (observer_)
74 observer_->OnChanged();
66 return true; 75 return true;
67 } 76 }
68 virtual std::string label() const OVERRIDE { return label_; } 77 virtual std::string label() const OVERRIDE { return label_; }
69 virtual AudioTrackVector GetAudioTracks() OVERRIDE { 78 virtual AudioTrackVector GetAudioTracks() OVERRIDE {
70 return audio_track_vector_; 79 return audio_track_vector_;
71 } 80 }
72 virtual VideoTrackVector GetVideoTracks() OVERRIDE { 81 virtual VideoTrackVector GetVideoTracks() OVERRIDE {
73 return video_track_vector_; 82 return video_track_vector_;
74 } 83 }
75 virtual talk_base::scoped_refptr<AudioTrackInterface> 84 virtual talk_base::scoped_refptr<AudioTrackInterface>
76 FindAudioTrack(const std::string& track_id) OVERRIDE { 85 FindAudioTrack(const std::string& track_id) OVERRIDE {
77 AudioTrackVector::iterator it = FindTrack(&audio_track_vector_, track_id); 86 AudioTrackVector::iterator it = FindTrack(&audio_track_vector_, track_id);
78 return it == audio_track_vector_.end() ? NULL : *it; 87 return it == audio_track_vector_.end() ? NULL : *it;
79 } 88 }
80 virtual talk_base::scoped_refptr<VideoTrackInterface> 89 virtual talk_base::scoped_refptr<VideoTrackInterface>
81 FindVideoTrack(const std::string& track_id) OVERRIDE { 90 FindVideoTrack(const std::string& track_id) OVERRIDE {
82 VideoTrackVector::iterator it = FindTrack(&video_track_vector_, track_id); 91 VideoTrackVector::iterator it = FindTrack(&video_track_vector_, track_id);
83 return it == video_track_vector_.end() ? NULL : *it; 92 return it == video_track_vector_.end() ? NULL : *it;
84 } 93 }
85 virtual void RegisterObserver(ObserverInterface* observer) OVERRIDE { 94 virtual void RegisterObserver(ObserverInterface* observer) OVERRIDE {
86 NOTIMPLEMENTED(); 95 observer_ = observer;
tommi (sloooow) - chröme 2013/04/16 15:59:59 first DCHECK(!observer_)?
perkj_chrome 2013/04/18 14:46:58 Done.
87 } 96 }
88 virtual void UnregisterObserver(ObserverInterface* observer) OVERRIDE { 97 virtual void UnregisterObserver(ObserverInterface* observer) OVERRIDE {
89 NOTIMPLEMENTED(); 98 DCHECK(observer_ == observer);
99 observer_ = NULL;
90 } 100 }
91 101
92 protected: 102 protected:
93 virtual ~MockMediaStream() {} 103 virtual ~MockMediaStream() {}
94 104
95 private: 105 private:
96 std::string label_; 106 std::string label_;
97 AudioTrackVector audio_track_vector_; 107 AudioTrackVector audio_track_vector_;
98 VideoTrackVector video_track_vector_; 108 VideoTrackVector video_track_vector_;
109 webrtc::ObserverInterface* observer_;
99 }; 110 };
100 111
101 MockAudioSource::MockAudioSource( 112 MockAudioSource::MockAudioSource(
102 const webrtc::MediaConstraintsInterface* constraints) 113 const webrtc::MediaConstraintsInterface* constraints)
103 : observer_(NULL), 114 : observer_(NULL),
104 state_(MediaSourceInterface::kInitializing), 115 state_(MediaSourceInterface::kInitializing),
105 optional_constraints_(constraints->GetOptional()), 116 optional_constraints_(constraints->GetOptional()),
106 mandatory_constraints_(constraints->GetMandatory()) { 117 mandatory_constraints_(constraints->GetMandatory()) {
107 } 118 }
108 119
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 195
185 const cricket::VideoOptions* MockVideoSource::options() const { 196 const cricket::VideoOptions* MockVideoSource::options() const {
186 NOTIMPLEMENTED(); 197 NOTIMPLEMENTED();
187 return NULL; 198 return NULL;
188 } 199 }
189 200
190 MockLocalVideoTrack::MockLocalVideoTrack(std::string id, 201 MockLocalVideoTrack::MockLocalVideoTrack(std::string id,
191 webrtc::VideoSourceInterface* source) 202 webrtc::VideoSourceInterface* source)
192 : enabled_(false), 203 : enabled_(false),
193 id_(id), 204 id_(id),
194 source_(source) { 205 state_(MediaStreamTrackInterface::kLive),
206 source_(source),
207 observer_(NULL) {
195 } 208 }
196 209
197 MockLocalVideoTrack::~MockLocalVideoTrack() {} 210 MockLocalVideoTrack::~MockLocalVideoTrack() {}
198 211
199 void MockLocalVideoTrack::AddRenderer(VideoRendererInterface* renderer) { 212 void MockLocalVideoTrack::AddRenderer(VideoRendererInterface* renderer) {
200 NOTIMPLEMENTED(); 213 NOTIMPLEMENTED();
201 } 214 }
202 215
203 void MockLocalVideoTrack::RemoveRenderer(VideoRendererInterface* renderer) { 216 void MockLocalVideoTrack::RemoveRenderer(VideoRendererInterface* renderer) {
204 NOTIMPLEMENTED(); 217 NOTIMPLEMENTED();
205 } 218 }
206 219
207 cricket::VideoRenderer* MockLocalVideoTrack::FrameInput() { 220 cricket::VideoRenderer* MockLocalVideoTrack::FrameInput() {
208 NOTIMPLEMENTED(); 221 NOTIMPLEMENTED();
209 return NULL; 222 return NULL;
210 } 223 }
211 224
212 std::string MockLocalVideoTrack::kind() const { 225 std::string MockLocalVideoTrack::kind() const {
213 NOTIMPLEMENTED(); 226 NOTIMPLEMENTED();
214 return std::string(); 227 return std::string();
215 } 228 }
216 229
217 std::string MockLocalVideoTrack::id() const { return id_; } 230 std::string MockLocalVideoTrack::id() const { return id_; }
218 231
219 bool MockLocalVideoTrack::enabled() const { return enabled_; } 232 bool MockLocalVideoTrack::enabled() const { return enabled_; }
220 233
221 MockLocalVideoTrack::TrackState MockLocalVideoTrack::state() const { 234 MockLocalVideoTrack::TrackState MockLocalVideoTrack::state() const {
222 NOTIMPLEMENTED(); 235 return state_;
223 return kInitializing;
224 } 236 }
225 237
226 bool MockLocalVideoTrack::set_enabled(bool enable) { 238 bool MockLocalVideoTrack::set_enabled(bool enable) {
227 enabled_ = enable; 239 enabled_ = enable;
228 return true; 240 return true;
229 } 241 }
230 242
231 bool MockLocalVideoTrack::set_state(TrackState new_state) { 243 bool MockLocalVideoTrack::set_state(TrackState new_state) {
232 NOTIMPLEMENTED(); 244 state_ = new_state;
233 return false; 245 if (observer_)
246 observer_->OnChanged();
247 return true;
234 } 248 }
235 249
236 void MockLocalVideoTrack::RegisterObserver(ObserverInterface* observer) { 250 void MockLocalVideoTrack::RegisterObserver(ObserverInterface* observer) {
237 NOTIMPLEMENTED(); 251 observer_ = observer;
238 } 252 }
239 253
240 void MockLocalVideoTrack::UnregisterObserver(ObserverInterface* observer) { 254 void MockLocalVideoTrack::UnregisterObserver(ObserverInterface* observer) {
241 NOTIMPLEMENTED(); 255 DCHECK(observer_ == observer);
256 observer_ = NULL;
242 } 257 }
243 258
244 VideoSourceInterface* MockLocalVideoTrack::GetSource() const { 259 VideoSourceInterface* MockLocalVideoTrack::GetSource() const {
245 return source_; 260 return source_;
246 } 261 }
247 262
248 std::string MockLocalAudioTrack::kind() const { 263 std::string MockLocalAudioTrack::kind() const {
249 NOTIMPLEMENTED(); 264 NOTIMPLEMENTED();
250 return std::string(); 265 return std::string();
251 } 266 }
252 267
253 std::string MockLocalAudioTrack::id() const { return id_; } 268 std::string MockLocalAudioTrack::id() const { return id_; }
254 269
255 bool MockLocalAudioTrack::enabled() const { return enabled_; } 270 bool MockLocalAudioTrack::enabled() const { return enabled_; }
256 271
257 MockLocalVideoTrack::TrackState MockLocalAudioTrack::state() const { 272 MockLocalAudioTrack::TrackState MockLocalAudioTrack::state() const {
258 NOTIMPLEMENTED(); 273 return state_;
259 return kInitializing;
260 } 274 }
261 275
262 bool MockLocalAudioTrack::set_enabled(bool enable) { 276 bool MockLocalAudioTrack::set_enabled(bool enable) {
263 enabled_ = enable; 277 enabled_ = enable;
264 return true; 278 return true;
265 } 279 }
266 280
267 bool MockLocalAudioTrack::set_state(TrackState new_state) { 281 bool MockLocalAudioTrack::set_state(TrackState new_state) {
268 NOTIMPLEMENTED(); 282 state_ = new_state;
269 return false; 283 if (observer_)
284 observer_->OnChanged();
285 return true;
270 } 286 }
271 287
272 void MockLocalAudioTrack::RegisterObserver(ObserverInterface* observer) { 288 void MockLocalAudioTrack::RegisterObserver(ObserverInterface* observer) {
273 NOTIMPLEMENTED(); 289 observer_ = observer;
274 } 290 }
275 291
276 void MockLocalAudioTrack::UnregisterObserver(ObserverInterface* observer) { 292 void MockLocalAudioTrack::UnregisterObserver(ObserverInterface* observer) {
277 NOTIMPLEMENTED(); 293 DCHECK(observer_ == observer);
294 observer_ = NULL;
278 } 295 }
279 296
280 AudioSourceInterface* MockLocalAudioTrack::GetSource() const { 297 AudioSourceInterface* MockLocalAudioTrack::GetSource() const {
281 NOTIMPLEMENTED(); 298 NOTIMPLEMENTED();
282 return NULL; 299 return NULL;
283 } 300 }
284 301
285 class MockSessionDescription : public SessionDescriptionInterface { 302 class MockSessionDescription : public SessionDescriptionInterface {
286 public: 303 public:
287 MockSessionDescription(const std::string& type, 304 MockSessionDescription(const std::string& type,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 475
459 webrtc::IceCandidateInterface* 476 webrtc::IceCandidateInterface*
460 MockMediaStreamDependencyFactory::CreateIceCandidate( 477 MockMediaStreamDependencyFactory::CreateIceCandidate(
461 const std::string& sdp_mid, 478 const std::string& sdp_mid,
462 int sdp_mline_index, 479 int sdp_mline_index,
463 const std::string& sdp) { 480 const std::string& sdp) {
464 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp); 481 return new MockIceCandidate(sdp_mid, sdp_mline_index, sdp);
465 } 482 }
466 483
467 } // namespace content 484 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698