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 #include "content/renderer/media/mock_peer_connection_impl.h" | 6 #include "content/renderer/media/mock_peer_connection_impl.h" |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 const char MockPeerConnectionImpl::kDummyOffer[] = "dummy offer"; | 110 const char MockPeerConnectionImpl::kDummyOffer[] = "dummy offer"; |
111 const char MockPeerConnectionImpl::kDummyAnswer[] = "dummy answer"; | 111 const char MockPeerConnectionImpl::kDummyAnswer[] = "dummy answer"; |
112 | 112 |
113 MockPeerConnectionImpl::MockPeerConnectionImpl( | 113 MockPeerConnectionImpl::MockPeerConnectionImpl( |
114 MockMediaStreamDependencyFactory* factory) | 114 MockMediaStreamDependencyFactory* factory) |
115 : dependency_factory_(factory), | 115 : dependency_factory_(factory), |
116 local_streams_(new talk_base::RefCountedObject<MockStreamCollection>), | 116 local_streams_(new talk_base::RefCountedObject<MockStreamCollection>), |
117 remote_streams_(new talk_base::RefCountedObject<MockStreamCollection>), | 117 remote_streams_(new talk_base::RefCountedObject<MockStreamCollection>), |
118 hint_audio_(false), | 118 hint_audio_(false), |
119 hint_video_(false), | 119 hint_video_(false), |
120 action_(kAnswer), | |
121 ice_options_(kOnlyRelay), | 120 ice_options_(kOnlyRelay), |
122 sdp_mline_index_(-1), | 121 sdp_mline_index_(-1), |
123 ready_state_(kNew), | 122 signaling_state_(kNew), |
124 ice_state_(kIceNew) { | 123 ice_state_(kIceNew) { |
125 } | 124 } |
126 | 125 |
127 MockPeerConnectionImpl::~MockPeerConnectionImpl() {} | 126 MockPeerConnectionImpl::~MockPeerConnectionImpl() {} |
128 | 127 |
129 talk_base::scoped_refptr<webrtc::StreamCollectionInterface> | 128 talk_base::scoped_refptr<webrtc::StreamCollectionInterface> |
130 MockPeerConnectionImpl::local_streams() { | 129 MockPeerConnectionImpl::local_streams() { |
131 return local_streams_; | 130 return local_streams_; |
132 } | 131 } |
133 | 132 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 report.local.values.push_back(value); | 196 report.local.values.push_back(value); |
198 reports.push_back(report); | 197 reports.push_back(report); |
199 } | 198 } |
200 // Note that the callback is synchronous, not asynchronous; it will | 199 // Note that the callback is synchronous, not asynchronous; it will |
201 // happen before the request call completes. | 200 // happen before the request call completes. |
202 observer->OnComplete(reports); | 201 observer->OnComplete(reports); |
203 return true; | 202 return true; |
204 } | 203 } |
205 | 204 |
206 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::ready_state() { | 205 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::ready_state() { |
207 return ready_state_; | 206 return signaling_state_; |
| 207 } |
| 208 |
| 209 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::signaling_state() { |
| 210 return signaling_state_; |
208 } | 211 } |
209 | 212 |
210 bool MockPeerConnectionImpl::StartIce(IceOptions options) { | 213 bool MockPeerConnectionImpl::StartIce(IceOptions options) { |
211 ice_options_ = options; | 214 ice_options_ = options; |
212 return true; | 215 return true; |
213 } | 216 } |
214 | 217 |
215 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateOffer( | |
216 const webrtc::MediaHints& hints) { | |
217 hint_audio_ = hints.has_audio(); | |
218 hint_video_ = hints.has_video(); | |
219 return dependency_factory_->CreateSessionDescription(kDummyOffer); | |
220 } | |
221 | |
222 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateAnswer( | |
223 const webrtc::MediaHints& hints, | |
224 const webrtc::SessionDescriptionInterface* offer) { | |
225 hint_audio_ = hints.has_audio(); | |
226 hint_video_ = hints.has_video(); | |
227 offer->ToString(&description_sdp_); | |
228 return dependency_factory_->CreateSessionDescription(description_sdp_); | |
229 } | |
230 | |
231 bool MockPeerConnectionImpl::SetLocalDescription( | |
232 Action action, | |
233 webrtc::SessionDescriptionInterface* desc) { | |
234 action_ = action; | |
235 local_desc_.reset(desc); | |
236 return desc->ToString(&description_sdp_); | |
237 } | |
238 | |
239 bool MockPeerConnectionImpl::SetRemoteDescription( | |
240 Action action, | |
241 webrtc::SessionDescriptionInterface* desc) { | |
242 action_ = action; | |
243 remote_desc_.reset(desc); | |
244 return desc->ToString(&description_sdp_); | |
245 } | |
246 | |
247 bool MockPeerConnectionImpl::ProcessIceMessage( | |
248 const webrtc::IceCandidateInterface* ice_candidate) { | |
249 return AddIceCandidate(ice_candidate); | |
250 } | |
251 | |
252 const webrtc::SessionDescriptionInterface* | 218 const webrtc::SessionDescriptionInterface* |
253 MockPeerConnectionImpl::local_description() const { | 219 MockPeerConnectionImpl::local_description() const { |
254 return local_desc_.get(); | 220 return local_desc_.get(); |
255 } | 221 } |
256 | 222 |
257 const webrtc::SessionDescriptionInterface* | 223 const webrtc::SessionDescriptionInterface* |
258 MockPeerConnectionImpl::remote_description() const { | 224 MockPeerConnectionImpl::remote_description() const { |
259 return remote_desc_.get(); | 225 return remote_desc_.get(); |
260 } | 226 } |
261 | 227 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 sdp_mid_ = candidate->sdp_mid(); | 270 sdp_mid_ = candidate->sdp_mid(); |
305 sdp_mline_index_ = candidate->sdp_mline_index(); | 271 sdp_mline_index_ = candidate->sdp_mline_index(); |
306 return candidate->ToString(&ice_sdp_); | 272 return candidate->ToString(&ice_sdp_); |
307 } | 273 } |
308 | 274 |
309 PeerConnectionInterface::IceState MockPeerConnectionImpl::ice_state() { | 275 PeerConnectionInterface::IceState MockPeerConnectionImpl::ice_state() { |
310 return ice_state_; | 276 return ice_state_; |
311 } | 277 } |
312 | 278 |
313 } // namespace content | 279 } // namespace content |
OLD | NEW |