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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "content/renderer/media/mock_media_stream_dependency_factory.h" | 6 #include "content/renderer/media/mock_media_stream_dependency_factory.h" |
7 #include "content/renderer/media/mock_peer_connection_impl.h" | 7 #include "content/renderer/media/mock_peer_connection_impl.h" |
8 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | 8 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
9 #include "third_party/libjingle/source/talk/base/scoped_ref_ptr.h" | 9 #include "third_party/libjingle/source/talk/base/scoped_ref_ptr.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 return tracks_[index]; | 21 return tracks_[index]; |
22 } | 22 } |
23 void AddTrack(TrackType* track) { | 23 void AddTrack(TrackType* track) { |
24 tracks_.push_back(track); | 24 tracks_.push_back(track); |
25 } | 25 } |
26 | 26 |
27 protected: | 27 protected: |
28 virtual ~MockMediaStreamTrackList() {} | 28 virtual ~MockMediaStreamTrackList() {} |
29 | 29 |
30 private: | 30 private: |
31 std::vector<talk_base::scoped_refptr<TrackType> > tracks_; | 31 std::vector<scoped_refptr<TrackType> > tracks_; |
32 }; | 32 }; |
33 | 33 |
34 typedef MockMediaStreamTrackList<AudioTrackInterface> MockAudioTracks; | 34 typedef MockMediaStreamTrackList<AudioTrackInterface> MockAudioTracks; |
35 typedef MockMediaStreamTrackList<VideoTrackInterface> MockVideoTracks; | 35 typedef MockMediaStreamTrackList<VideoTrackInterface> MockVideoTracks; |
36 | 36 |
37 class MockLocalMediaStream : public LocalMediaStreamInterface { | 37 class MockLocalMediaStream : public LocalMediaStreamInterface { |
38 public: | 38 public: |
39 explicit MockLocalMediaStream(std::string label) | 39 explicit MockLocalMediaStream(std::string label) |
40 : label_(label), | 40 : label_(label), |
41 audio_tracks_(new talk_base::RefCountedObject<MockAudioTracks>), | 41 audio_tracks_(new talk_base::RefCountedObject<MockAudioTracks>), |
(...skipping 24 matching lines...) Expand all Loading... |
66 } | 66 } |
67 virtual void UnregisterObserver(ObserverInterface* observer) { | 67 virtual void UnregisterObserver(ObserverInterface* observer) { |
68 NOTIMPLEMENTED(); | 68 NOTIMPLEMENTED(); |
69 } | 69 } |
70 | 70 |
71 protected: | 71 protected: |
72 virtual ~MockLocalMediaStream() {} | 72 virtual ~MockLocalMediaStream() {} |
73 | 73 |
74 private: | 74 private: |
75 std::string label_; | 75 std::string label_; |
76 talk_base::scoped_refptr<MockAudioTracks> audio_tracks_; | 76 scoped_refptr<MockAudioTracks> audio_tracks_; |
77 talk_base::scoped_refptr<MockVideoTracks> video_tracks_; | 77 scoped_refptr<MockVideoTracks> video_tracks_; |
78 }; | 78 }; |
79 | 79 |
80 cricket::VideoCapturer* MockLocalVideoTrack::GetVideoCapture() { | 80 cricket::VideoCapturer* MockLocalVideoTrack::GetVideoCapture() { |
81 NOTIMPLEMENTED(); | 81 NOTIMPLEMENTED(); |
82 return NULL; | 82 return NULL; |
83 } | 83 } |
84 | 84 |
85 void MockLocalVideoTrack::AddRenderer(VideoRendererInterface* renderer) { | 85 void MockLocalVideoTrack::AddRenderer(VideoRendererInterface* renderer) { |
86 NOTIMPLEMENTED(); | 86 NOTIMPLEMENTED(); |
87 } | 87 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 void MockLocalAudioTrack::RegisterObserver(ObserverInterface* observer) { | 159 void MockLocalAudioTrack::RegisterObserver(ObserverInterface* observer) { |
160 NOTIMPLEMENTED(); | 160 NOTIMPLEMENTED(); |
161 } | 161 } |
162 | 162 |
163 void MockLocalAudioTrack::UnregisterObserver(ObserverInterface* observer) { | 163 void MockLocalAudioTrack::UnregisterObserver(ObserverInterface* observer) { |
164 NOTIMPLEMENTED(); | 164 NOTIMPLEMENTED(); |
165 } | 165 } |
166 | 166 |
167 class MockSessionDescription : public SessionDescriptionInterface { | 167 class MockSessionDescription : public SessionDescriptionInterface { |
168 public: | 168 public: |
169 MockSessionDescription(const std::string& sdp) | 169 MockSessionDescription(const std::string& type, |
170 : sdp_(sdp) { | 170 const std::string& sdp) |
| 171 : type_(type), |
| 172 sdp_(sdp) { |
171 } | 173 } |
172 virtual ~MockSessionDescription() {} | 174 virtual ~MockSessionDescription() {} |
173 virtual const cricket::SessionDescription* description() const OVERRIDE { | 175 virtual const cricket::SessionDescription* description() const OVERRIDE { |
174 NOTIMPLEMENTED(); | 176 NOTIMPLEMENTED(); |
175 return NULL; | 177 return NULL; |
176 } | 178 } |
177 virtual std::string session_id() const OVERRIDE { | 179 virtual std::string session_id() const OVERRIDE { |
178 NOTIMPLEMENTED(); | 180 NOTIMPLEMENTED(); |
179 return ""; | 181 return ""; |
180 } | 182 } |
181 virtual std::string session_version() const OVERRIDE { | 183 virtual std::string session_version() const OVERRIDE { |
182 NOTIMPLEMENTED(); | 184 NOTIMPLEMENTED(); |
183 return ""; | 185 return ""; |
184 } | 186 } |
185 virtual std::string type() const OVERRIDE { | 187 virtual std::string type() const OVERRIDE { |
186 NOTIMPLEMENTED(); | 188 return type_; |
187 return ""; | |
188 } | 189 } |
189 virtual bool AddCandidate(const IceCandidateInterface* candidate) OVERRIDE { | 190 virtual bool AddCandidate(const IceCandidateInterface* candidate) OVERRIDE { |
190 NOTIMPLEMENTED(); | 191 NOTIMPLEMENTED(); |
191 return false; | 192 return false; |
192 } | 193 } |
193 virtual size_t number_of_mediasections() const OVERRIDE { | 194 virtual size_t number_of_mediasections() const OVERRIDE { |
194 NOTIMPLEMENTED(); | 195 NOTIMPLEMENTED(); |
195 return 0; | 196 return 0; |
196 } | 197 } |
197 virtual const IceCandidateCollection* candidates( | 198 virtual const IceCandidateCollection* candidates( |
198 size_t mediasection_index) const OVERRIDE { | 199 size_t mediasection_index) const OVERRIDE { |
199 NOTIMPLEMENTED(); | 200 NOTIMPLEMENTED(); |
200 return NULL; | 201 return NULL; |
201 } | 202 } |
202 | 203 |
203 virtual bool ToString(std::string* out) const OVERRIDE { | 204 virtual bool ToString(std::string* out) const OVERRIDE { |
204 *out = sdp_; | 205 *out = sdp_; |
205 return true; | 206 return true; |
206 } | 207 } |
207 | 208 |
208 private: | 209 private: |
| 210 std::string type_; |
209 std::string sdp_; | 211 std::string sdp_; |
210 }; | 212 }; |
211 | 213 |
212 class MockIceCandidate : public IceCandidateInterface { | 214 class MockIceCandidate : public IceCandidateInterface { |
213 public: | 215 public: |
214 MockIceCandidate(const std::string& sdp_mid, | 216 MockIceCandidate(const std::string& sdp_mid, |
215 int sdp_mline_index, | 217 int sdp_mline_index, |
216 const std::string& sdp) | 218 const std::string& sdp) |
217 : sdp_mid_(sdp_mid), | 219 : sdp_mid_(sdp_mid), |
218 sdp_mline_index_(sdp_mline_index), | 220 sdp_mline_index_(sdp_mline_index), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 mock_pc_factory_created_(false) { | 252 mock_pc_factory_created_(false) { |
251 } | 253 } |
252 | 254 |
253 MockMediaStreamDependencyFactory::~MockMediaStreamDependencyFactory() {} | 255 MockMediaStreamDependencyFactory::~MockMediaStreamDependencyFactory() {} |
254 | 256 |
255 bool MockMediaStreamDependencyFactory::EnsurePeerConnectionFactory() { | 257 bool MockMediaStreamDependencyFactory::EnsurePeerConnectionFactory() { |
256 mock_pc_factory_created_ = true; | 258 mock_pc_factory_created_ = true; |
257 return true; | 259 return true; |
258 } | 260 } |
259 | 261 |
260 talk_base::scoped_refptr<webrtc::PeerConnectionInterface> | 262 scoped_refptr<webrtc::PeerConnectionInterface> |
261 MockMediaStreamDependencyFactory::CreatePeerConnection( | 263 MockMediaStreamDependencyFactory::CreatePeerConnection( |
262 const std::string& config, | 264 const std::string& config, |
263 webrtc::PeerConnectionObserver* observer) { | 265 webrtc::PeerConnectionObserver* observer) { |
264 DCHECK(mock_pc_factory_created_); | 266 DCHECK(mock_pc_factory_created_); |
265 return new talk_base::RefCountedObject<webrtc::MockPeerConnectionImpl>(this); | 267 return new talk_base::RefCountedObject<webrtc::MockPeerConnectionImpl>(this); |
266 } | 268 } |
267 | 269 |
268 talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> | 270 scoped_refptr<webrtc::PeerConnectionInterface> |
| 271 MockMediaStreamDependencyFactory::CreatePeerConnection( |
| 272 const webrtc::JsepInterface::IceServers& ice_servers, |
| 273 const webrtc::MediaConstraintsInterface* constraints, |
| 274 webrtc::PeerConnectionObserver* observer) { |
| 275 DCHECK(mock_pc_factory_created_); |
| 276 return new talk_base::RefCountedObject<webrtc::MockPeerConnectionImpl>(this); |
| 277 } |
| 278 |
| 279 scoped_refptr<webrtc::LocalMediaStreamInterface> |
269 MockMediaStreamDependencyFactory::CreateLocalMediaStream( | 280 MockMediaStreamDependencyFactory::CreateLocalMediaStream( |
270 const std::string& label) { | 281 const std::string& label) { |
271 DCHECK(mock_pc_factory_created_); | 282 DCHECK(mock_pc_factory_created_); |
272 talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> stream( | 283 return |
273 new talk_base::RefCountedObject<webrtc::MockLocalMediaStream>(label)); | 284 new talk_base::RefCountedObject<webrtc::MockLocalMediaStream>(label); |
274 return stream; | |
275 } | 285 } |
276 | 286 |
277 talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> | 287 scoped_refptr<webrtc::LocalVideoTrackInterface> |
278 MockMediaStreamDependencyFactory::CreateLocalVideoTrack( | 288 MockMediaStreamDependencyFactory::CreateLocalVideoTrack( |
279 const std::string& label, | 289 const std::string& label, |
280 int video_session_id) { | 290 int video_session_id) { |
281 DCHECK(mock_pc_factory_created_); | 291 DCHECK(mock_pc_factory_created_); |
282 talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> track( | 292 scoped_refptr<webrtc::LocalVideoTrackInterface> track( |
283 new talk_base::RefCountedObject<webrtc::MockLocalVideoTrack>(label)); | 293 new talk_base::RefCountedObject<webrtc::MockLocalVideoTrack>(label)); |
284 return track; | 294 return track; |
285 } | 295 } |
286 | 296 |
287 talk_base::scoped_refptr<webrtc::LocalAudioTrackInterface> | 297 scoped_refptr<webrtc::LocalAudioTrackInterface> |
288 MockMediaStreamDependencyFactory::CreateLocalAudioTrack( | 298 MockMediaStreamDependencyFactory::CreateLocalAudioTrack( |
289 const std::string& label, | 299 const std::string& label, |
290 webrtc::AudioDeviceModule* audio_device) { | 300 webrtc::AudioDeviceModule* audio_device) { |
291 DCHECK(mock_pc_factory_created_); | 301 DCHECK(mock_pc_factory_created_); |
292 talk_base::scoped_refptr<webrtc::LocalAudioTrackInterface> track( | 302 scoped_refptr<webrtc::LocalAudioTrackInterface> track( |
293 new talk_base::RefCountedObject<webrtc::MockLocalAudioTrack>(label)); | 303 new talk_base::RefCountedObject<webrtc::MockLocalAudioTrack>(label)); |
294 return track; | 304 return track; |
295 } | 305 } |
296 | 306 |
297 webrtc::SessionDescriptionInterface* | 307 webrtc::SessionDescriptionInterface* |
298 MockMediaStreamDependencyFactory::CreateSessionDescription( | 308 MockMediaStreamDependencyFactory::CreateSessionDescription( |
299 const std::string& sdp) { | 309 const std::string& sdp) { |
300 return new webrtc::MockSessionDescription(sdp); | 310 return CreateSessionDescription ("unknown", sdp); |
| 311 } |
| 312 |
| 313 webrtc::SessionDescriptionInterface* |
| 314 MockMediaStreamDependencyFactory::CreateSessionDescription( |
| 315 const std::string& type, |
| 316 const std::string& sdp) { |
| 317 return new webrtc::MockSessionDescription(type, sdp); |
301 } | 318 } |
302 | 319 |
303 webrtc::IceCandidateInterface* | 320 webrtc::IceCandidateInterface* |
304 MockMediaStreamDependencyFactory::CreateIceCandidate( | 321 MockMediaStreamDependencyFactory::CreateIceCandidate( |
305 const std::string& sdp_mid, | 322 const std::string& sdp_mid, |
306 int sdp_mline_index, | 323 int sdp_mline_index, |
307 const std::string& sdp) { | 324 const std::string& sdp) { |
308 return new webrtc::MockIceCandidate(sdp_mid, sdp_mline_index, sdp); | 325 return new webrtc::MockIceCandidate(sdp_mid, sdp_mline_index, sdp); |
309 } | 326 } |
310 | 327 |
311 void MockMediaStreamDependencyFactory::SetAudioDeviceSessionId(int session_id) { | 328 void MockMediaStreamDependencyFactory::SetAudioDeviceSessionId(int session_id) { |
312 } | 329 } |
OLD | NEW |