| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 void MockLocalVideoTrack::RegisterObserver(ObserverInterface* observer) { | 118 void MockLocalVideoTrack::RegisterObserver(ObserverInterface* observer) { |
| 119 NOTIMPLEMENTED(); | 119 NOTIMPLEMENTED(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void MockLocalVideoTrack::UnregisterObserver(ObserverInterface* observer) { | 122 void MockLocalVideoTrack::UnregisterObserver(ObserverInterface* observer) { |
| 123 NOTIMPLEMENTED(); | 123 NOTIMPLEMENTED(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 class MockSessionDescription : public SessionDescriptionInterface { |
| 127 public: |
| 128 MockSessionDescription(const std::string& sdp) |
| 129 : sdp_(sdp) { |
| 130 } |
| 131 virtual ~MockSessionDescription() {} |
| 132 virtual const cricket::SessionDescription* description() const OVERRIDE { |
| 133 NOTIMPLEMENTED(); |
| 134 return NULL; |
| 135 } |
| 136 virtual bool AddCandidate(const IceCandidateInterface* candidate) OVERRIDE { |
| 137 NOTIMPLEMENTED(); |
| 138 return false; |
| 139 } |
| 140 virtual size_t number_of_mediasections() const OVERRIDE { |
| 141 NOTIMPLEMENTED(); |
| 142 return 0; |
| 143 } |
| 144 virtual const IceCandidateColletion* candidates( |
| 145 size_t mediasection_index) const OVERRIDE { |
| 146 NOTIMPLEMENTED(); |
| 147 return NULL; |
| 148 } |
| 149 virtual bool ToString(std::string* out) const OVERRIDE { |
| 150 *out = sdp_; |
| 151 return true; |
| 152 } |
| 153 |
| 154 private: |
| 155 std::string sdp_; |
| 156 }; |
| 157 |
| 158 class MockIceCandidate : public IceCandidateInterface { |
| 159 public: |
| 160 MockIceCandidate(const std::string& label, const std::string& sdp) |
| 161 : label_(label), |
| 162 sdp_(sdp) { |
| 163 } |
| 164 virtual ~MockIceCandidate() {} |
| 165 virtual std::string label() const OVERRIDE { |
| 166 return label_; |
| 167 } |
| 168 virtual const cricket::Candidate& candidate() const OVERRIDE { |
| 169 // This function should never be called. It will intentionally crash. The |
| 170 // base class forces us to return a reference. |
| 171 NOTREACHED(); |
| 172 cricket::Candidate* candidate = NULL; |
| 173 return *candidate; |
| 174 } |
| 175 virtual bool ToString(std::string* out) const OVERRIDE { |
| 176 *out = sdp_; |
| 177 return true; |
| 178 } |
| 179 |
| 180 private: |
| 181 std::string label_; |
| 182 std::string sdp_; |
| 183 }; |
| 184 |
| 126 } // namespace webrtc | 185 } // namespace webrtc |
| 127 | 186 |
| 128 MockMediaStreamDependencyFactory::MockMediaStreamDependencyFactory() | 187 MockMediaStreamDependencyFactory::MockMediaStreamDependencyFactory() |
| 129 : mock_pc_factory_created_(false) { | 188 : mock_pc_factory_created_(false) { |
| 130 } | 189 } |
| 131 | 190 |
| 132 MockMediaStreamDependencyFactory::~MockMediaStreamDependencyFactory() {} | 191 MockMediaStreamDependencyFactory::~MockMediaStreamDependencyFactory() {} |
| 133 | 192 |
| 134 bool MockMediaStreamDependencyFactory::CreatePeerConnectionFactory( | 193 bool MockMediaStreamDependencyFactory::CreatePeerConnectionFactory( |
| 135 talk_base::Thread* worker_thread, | 194 talk_base::Thread* worker_thread, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 147 | 206 |
| 148 bool MockMediaStreamDependencyFactory::PeerConnectionFactoryCreated() { | 207 bool MockMediaStreamDependencyFactory::PeerConnectionFactoryCreated() { |
| 149 return mock_pc_factory_created_; | 208 return mock_pc_factory_created_; |
| 150 } | 209 } |
| 151 | 210 |
| 152 talk_base::scoped_refptr<webrtc::PeerConnectionInterface> | 211 talk_base::scoped_refptr<webrtc::PeerConnectionInterface> |
| 153 MockMediaStreamDependencyFactory::CreatePeerConnection( | 212 MockMediaStreamDependencyFactory::CreatePeerConnection( |
| 154 const std::string& config, | 213 const std::string& config, |
| 155 webrtc::PeerConnectionObserver* observer) { | 214 webrtc::PeerConnectionObserver* observer) { |
| 156 DCHECK(mock_pc_factory_created_); | 215 DCHECK(mock_pc_factory_created_); |
| 157 return new talk_base::RefCountedObject<webrtc::MockPeerConnectionImpl>(); | 216 return new talk_base::RefCountedObject<webrtc::MockPeerConnectionImpl>(this); |
| 158 } | 217 } |
| 159 | 218 |
| 160 talk_base::scoped_refptr<webrtc::PeerConnectionInterface> | 219 talk_base::scoped_refptr<webrtc::PeerConnectionInterface> |
| 161 MockMediaStreamDependencyFactory::CreateRoapPeerConnection( | 220 MockMediaStreamDependencyFactory::CreateRoapPeerConnection( |
| 162 const std::string& config, | 221 const std::string& config, |
| 163 webrtc::PeerConnectionObserver* observer) { | 222 webrtc::PeerConnectionObserver* observer) { |
| 164 DCHECK(mock_pc_factory_created_); | 223 DCHECK(mock_pc_factory_created_); |
| 165 return new talk_base::RefCountedObject<webrtc::MockPeerConnectionImpl>(); | 224 return new talk_base::RefCountedObject<webrtc::MockPeerConnectionImpl>(this); |
| 166 } | 225 } |
| 167 | 226 |
| 168 talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> | 227 talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> |
| 169 MockMediaStreamDependencyFactory::CreateLocalMediaStream( | 228 MockMediaStreamDependencyFactory::CreateLocalMediaStream( |
| 170 const std::string& label) { | 229 const std::string& label) { |
| 171 talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> stream( | 230 talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> stream( |
| 172 new talk_base::RefCountedObject<webrtc::MockLocalMediaStream>(label)); | 231 new talk_base::RefCountedObject<webrtc::MockLocalMediaStream>(label)); |
| 173 return stream; | 232 return stream; |
| 174 } | 233 } |
| 175 | 234 |
| 176 talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> | 235 talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> |
| 177 MockMediaStreamDependencyFactory::CreateLocalVideoTrack( | 236 MockMediaStreamDependencyFactory::CreateLocalVideoTrack( |
| 178 const std::string& label, | 237 const std::string& label, |
| 179 cricket::VideoCapturer* video_device) { | 238 cricket::VideoCapturer* video_device) { |
| 180 talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> stream( | 239 talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> stream( |
| 181 new talk_base::RefCountedObject<webrtc::MockLocalVideoTrack>(label)); | 240 new talk_base::RefCountedObject<webrtc::MockLocalVideoTrack>(label)); |
| 182 return stream; | 241 return stream; |
| 183 } | 242 } |
| 184 | 243 |
| 185 talk_base::scoped_refptr<webrtc::LocalAudioTrackInterface> | 244 talk_base::scoped_refptr<webrtc::LocalAudioTrackInterface> |
| 186 MockMediaStreamDependencyFactory::CreateLocalAudioTrack( | 245 MockMediaStreamDependencyFactory::CreateLocalAudioTrack( |
| 187 const std::string& label, | 246 const std::string& label, |
| 188 webrtc::AudioDeviceModule* audio_device) { | 247 webrtc::AudioDeviceModule* audio_device) { |
| 189 NOTIMPLEMENTED(); | 248 NOTIMPLEMENTED(); |
| 190 return NULL; | 249 return NULL; |
| 191 } | 250 } |
| 251 |
| 252 webrtc::SessionDescriptionInterface* |
| 253 MockMediaStreamDependencyFactory::CreateSessionDescription( |
| 254 const std::string& sdp) { |
| 255 return new webrtc::MockSessionDescription(sdp); |
| 256 } |
| 257 |
| 258 webrtc::IceCandidateInterface* |
| 259 MockMediaStreamDependencyFactory::CreateIceCandidate( |
| 260 const std::string& label, |
| 261 const std::string& sdp) { |
| 262 return new webrtc::MockIceCandidate(label, sdp); |
| 263 } |
| OLD | NEW |