| 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), | |
| 122 sdp_mline_index_(-1), | 120 sdp_mline_index_(-1), |
| 123 ready_state_(kNew), | 121 signaling_state_(kNew), |
| 124 ice_state_(kIceNew) { | 122 ice_state_(kIceNew) { |
| 125 } | 123 } |
| 126 | 124 |
| 127 MockPeerConnectionImpl::~MockPeerConnectionImpl() {} | 125 MockPeerConnectionImpl::~MockPeerConnectionImpl() {} |
| 128 | 126 |
| 129 talk_base::scoped_refptr<webrtc::StreamCollectionInterface> | 127 talk_base::scoped_refptr<webrtc::StreamCollectionInterface> |
| 130 MockPeerConnectionImpl::local_streams() { | 128 MockPeerConnectionImpl::local_streams() { |
| 131 return local_streams_; | 129 return local_streams_; |
| 132 } | 130 } |
| 133 | 131 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 report.local.values.push_back(value); | 195 report.local.values.push_back(value); |
| 198 reports.push_back(report); | 196 reports.push_back(report); |
| 199 } | 197 } |
| 200 // Note that the callback is synchronous, not asynchronous; it will | 198 // Note that the callback is synchronous, not asynchronous; it will |
| 201 // happen before the request call completes. | 199 // happen before the request call completes. |
| 202 observer->OnComplete(reports); | 200 observer->OnComplete(reports); |
| 203 return true; | 201 return true; |
| 204 } | 202 } |
| 205 | 203 |
| 206 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::ready_state() { | 204 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::ready_state() { |
| 207 return ready_state_; | 205 return signaling_state_; |
| 208 } | 206 } |
| 209 | 207 |
| 210 bool MockPeerConnectionImpl::StartIce(IceOptions options) { | 208 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::signaling_state() { |
| 211 ice_options_ = options; | 209 return signaling_state_; |
| 212 return true; | |
| 213 } | |
| 214 | |
| 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 } | 210 } |
| 251 | 211 |
| 252 const webrtc::SessionDescriptionInterface* | 212 const webrtc::SessionDescriptionInterface* |
| 253 MockPeerConnectionImpl::local_description() const { | 213 MockPeerConnectionImpl::local_description() const { |
| 254 return local_desc_.get(); | 214 return local_desc_.get(); |
| 255 } | 215 } |
| 256 | 216 |
| 257 const webrtc::SessionDescriptionInterface* | 217 const webrtc::SessionDescriptionInterface* |
| 258 MockPeerConnectionImpl::remote_description() const { | 218 MockPeerConnectionImpl::remote_description() const { |
| 259 return remote_desc_.get(); | 219 return remote_desc_.get(); |
| 260 } | 220 } |
| 261 | 221 |
| 262 void MockPeerConnectionImpl::AddRemoteStream(MediaStreamInterface* stream) { | 222 void MockPeerConnectionImpl::AddRemoteStream(MediaStreamInterface* stream) { |
| 263 remote_streams_->AddStream(stream); | 223 remote_streams_->AddStream(stream); |
| 264 } | 224 } |
| 265 | 225 |
| 266 void MockPeerConnectionImpl::CreateOffer( | 226 void MockPeerConnectionImpl::CreateOffer( |
| 267 CreateSessionDescriptionObserver* observer, | 227 CreateSessionDescriptionObserver* observer, |
| 268 const MediaConstraintsInterface* constraints) { | 228 const MediaConstraintsInterface* constraints) { |
| 269 DCHECK(observer); | 229 DCHECK(observer); |
| 270 created_sessiondescription_.reset( | 230 created_sessiondescription_.reset( |
| 271 dependency_factory_->CreateSessionDescription(kDummyOffer)); | 231 dependency_factory_->CreateSessionDescription("unknown", kDummyOffer)); |
| 272 } | 232 } |
| 273 | 233 |
| 274 void MockPeerConnectionImpl::CreateAnswer( | 234 void MockPeerConnectionImpl::CreateAnswer( |
| 275 CreateSessionDescriptionObserver* observer, | 235 CreateSessionDescriptionObserver* observer, |
| 276 const MediaConstraintsInterface* constraints) { | 236 const MediaConstraintsInterface* constraints) { |
| 277 DCHECK(observer); | 237 DCHECK(observer); |
| 278 created_sessiondescription_.reset( | 238 created_sessiondescription_.reset( |
| 279 dependency_factory_->CreateSessionDescription(kDummyAnswer)); | 239 dependency_factory_->CreateSessionDescription("unknown", kDummyAnswer)); |
| 280 } | 240 } |
| 281 | 241 |
| 282 void MockPeerConnectionImpl::SetLocalDescription( | 242 void MockPeerConnectionImpl::SetLocalDescription( |
| 283 SetSessionDescriptionObserver* observer, | 243 SetSessionDescriptionObserver* observer, |
| 284 SessionDescriptionInterface* desc) { | 244 SessionDescriptionInterface* desc) { |
| 285 desc->ToString(&description_sdp_); | 245 desc->ToString(&description_sdp_); |
| 286 local_desc_.reset(desc); | 246 local_desc_.reset(desc); |
| 287 } | 247 } |
| 288 | 248 |
| 289 void MockPeerConnectionImpl::SetRemoteDescription( | 249 void MockPeerConnectionImpl::SetRemoteDescription( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 304 sdp_mid_ = candidate->sdp_mid(); | 264 sdp_mid_ = candidate->sdp_mid(); |
| 305 sdp_mline_index_ = candidate->sdp_mline_index(); | 265 sdp_mline_index_ = candidate->sdp_mline_index(); |
| 306 return candidate->ToString(&ice_sdp_); | 266 return candidate->ToString(&ice_sdp_); |
| 307 } | 267 } |
| 308 | 268 |
| 309 PeerConnectionInterface::IceState MockPeerConnectionImpl::ice_state() { | 269 PeerConnectionInterface::IceState MockPeerConnectionImpl::ice_state() { |
| 310 return ice_state_; | 270 return ice_state_; |
| 311 } | 271 } |
| 312 | 272 |
| 313 } // namespace content | 273 } // namespace content |
| OLD | NEW |