| 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_peer_connection_impl.h" | 6 #include "content/renderer/media/mock_peer_connection_impl.h" |
| 6 | 7 |
| 7 #include <vector> | 8 #include <vector> |
| 8 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 | 11 |
| 11 namespace webrtc { | 12 namespace webrtc { |
| 12 | 13 |
| 13 class MockStreamCollection : public StreamCollectionInterface { | 14 class MockStreamCollection : public StreamCollectionInterface { |
| 14 public: | 15 public: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 29 streams_.push_back(stream); | 30 streams_.push_back(stream); |
| 30 } | 31 } |
| 31 | 32 |
| 32 protected: | 33 protected: |
| 33 virtual ~MockStreamCollection() {} | 34 virtual ~MockStreamCollection() {} |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 std::vector<talk_base::scoped_refptr<MediaStreamInterface> > streams_; | 37 std::vector<talk_base::scoped_refptr<MediaStreamInterface> > streams_; |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 MockPeerConnectionImpl::MockPeerConnectionImpl() | 40 const char MockPeerConnectionImpl::kDummyOffer[] = "dummy offer"; |
| 40 : stream_changes_committed_(false), | 41 |
| 42 MockPeerConnectionImpl::MockPeerConnectionImpl( |
| 43 MockMediaStreamDependencyFactory* factory) |
| 44 : dependency_factory_(factory), |
| 45 stream_changes_committed_(false), |
| 41 local_streams_(new talk_base::RefCountedObject<MockStreamCollection>), | 46 local_streams_(new talk_base::RefCountedObject<MockStreamCollection>), |
| 42 remote_streams_(new talk_base::RefCountedObject<MockStreamCollection>) { | 47 remote_streams_(new talk_base::RefCountedObject<MockStreamCollection>), |
| 48 hint_audio_(false), |
| 49 hint_video_(false), |
| 50 action_(kAnswer), |
| 51 ice_options_(kOnlyRelay), |
| 52 ready_state_(kNew) { |
| 43 } | 53 } |
| 44 | 54 |
| 45 MockPeerConnectionImpl::~MockPeerConnectionImpl() {} | 55 MockPeerConnectionImpl::~MockPeerConnectionImpl() {} |
| 46 | 56 |
| 47 void MockPeerConnectionImpl::ProcessSignalingMessage(const std::string& msg) { | 57 void MockPeerConnectionImpl::ProcessSignalingMessage(const std::string& msg) { |
| 48 signaling_message_ = msg; | 58 signaling_message_ = msg; |
| 49 } | 59 } |
| 50 | 60 |
| 51 bool MockPeerConnectionImpl::Send(const std::string& msg) { | 61 bool MockPeerConnectionImpl::Send(const std::string& msg) { |
| 52 NOTIMPLEMENTED(); | 62 NOTIMPLEMENTED(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 78 stream_changes_committed_ = true; | 88 stream_changes_committed_ = true; |
| 79 } | 89 } |
| 80 | 90 |
| 81 void MockPeerConnectionImpl::Close() { | 91 void MockPeerConnectionImpl::Close() { |
| 82 signaling_message_.clear(); | 92 signaling_message_.clear(); |
| 83 stream_label_.clear(); | 93 stream_label_.clear(); |
| 84 stream_changes_committed_ = false; | 94 stream_changes_committed_ = false; |
| 85 } | 95 } |
| 86 | 96 |
| 87 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::ready_state() { | 97 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::ready_state() { |
| 88 NOTIMPLEMENTED(); | 98 return ready_state_; |
| 89 return kNew; | |
| 90 } | 99 } |
| 91 | 100 |
| 92 MockPeerConnectionImpl::SdpState MockPeerConnectionImpl::sdp_state() { | 101 MockPeerConnectionImpl::SdpState MockPeerConnectionImpl::sdp_state() { |
| 93 NOTIMPLEMENTED(); | 102 NOTIMPLEMENTED(); |
| 94 return kSdpNew; | 103 return kSdpNew; |
| 95 } | 104 } |
| 96 | 105 |
| 97 bool MockPeerConnectionImpl::StartIce(IceOptions options) { | 106 bool MockPeerConnectionImpl::StartIce(IceOptions options) { |
| 98 NOTIMPLEMENTED(); | 107 ice_options_ = options; |
| 99 return false; | 108 return true; |
| 100 } | 109 } |
| 101 | 110 |
| 102 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateOffer( | 111 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateOffer( |
| 103 const webrtc::MediaHints& hints) { | 112 const webrtc::MediaHints& hints) { |
| 104 NOTIMPLEMENTED(); | 113 hint_audio_ = hints.has_audio(); |
| 105 return NULL; | 114 hint_video_ = hints.has_video(); |
| 115 return dependency_factory_->CreateSessionDescription(kDummyOffer); |
| 106 } | 116 } |
| 107 | 117 |
| 108 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateAnswer( | 118 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateAnswer( |
| 109 const webrtc::MediaHints& hints, | 119 const webrtc::MediaHints& hints, |
| 110 const webrtc::SessionDescriptionInterface* offer) { | 120 const webrtc::SessionDescriptionInterface* offer) { |
| 111 NOTIMPLEMENTED(); | 121 hint_audio_ = hints.has_audio(); |
| 112 return NULL; | 122 hint_video_ = hints.has_video(); |
| 123 offer->ToString(&description_sdp_); |
| 124 return dependency_factory_->CreateSessionDescription(description_sdp_); |
| 113 } | 125 } |
| 114 | 126 |
| 115 bool MockPeerConnectionImpl::SetLocalDescription( | 127 bool MockPeerConnectionImpl::SetLocalDescription( |
| 116 Action action, | 128 Action action, |
| 117 webrtc::SessionDescriptionInterface* desc) { | 129 webrtc::SessionDescriptionInterface* desc) { |
| 118 NOTIMPLEMENTED(); | 130 action_ = action; |
| 119 return false; | 131 return desc->ToString(&description_sdp_); |
| 120 } | 132 } |
| 121 | 133 |
| 122 bool MockPeerConnectionImpl::SetRemoteDescription( | 134 bool MockPeerConnectionImpl::SetRemoteDescription( |
| 123 Action action, | 135 Action action, |
| 124 webrtc::SessionDescriptionInterface* desc) { | 136 webrtc::SessionDescriptionInterface* desc) { |
| 125 NOTIMPLEMENTED(); | 137 action_ = action; |
| 126 return false; | 138 return desc->ToString(&description_sdp_); |
| 127 } | 139 } |
| 128 | 140 |
| 129 bool MockPeerConnectionImpl::ProcessIceMessage( | 141 bool MockPeerConnectionImpl::ProcessIceMessage( |
| 130 const webrtc::IceCandidateInterface* ice_candidate) { | 142 const webrtc::IceCandidateInterface* ice_candidate) { |
| 131 NOTIMPLEMENTED(); | 143 ice_label_ = ice_candidate->label(); |
| 132 return false; | 144 return ice_candidate->ToString(&ice_sdp_); |
| 133 } | 145 } |
| 134 | 146 |
| 135 const webrtc::SessionDescriptionInterface* | 147 const webrtc::SessionDescriptionInterface* |
| 136 MockPeerConnectionImpl::local_description() const { | 148 MockPeerConnectionImpl::local_description() const { |
| 137 NOTIMPLEMENTED(); | 149 return dependency_factory_->CreateSessionDescription(description_sdp_); |
| 138 return NULL; | |
| 139 } | 150 } |
| 140 | 151 |
| 141 const webrtc::SessionDescriptionInterface* | 152 const webrtc::SessionDescriptionInterface* |
| 142 MockPeerConnectionImpl::remote_description() const { | 153 MockPeerConnectionImpl::remote_description() const { |
| 143 NOTIMPLEMENTED(); | 154 return dependency_factory_->CreateSessionDescription(description_sdp_); |
| 144 return NULL; | |
| 145 } | 155 } |
| 146 | 156 |
| 147 void MockPeerConnectionImpl::AddRemoteStream(MediaStreamInterface* stream) { | 157 void MockPeerConnectionImpl::AddRemoteStream(MediaStreamInterface* stream) { |
| 148 remote_streams_->AddStream(stream); | 158 remote_streams_->AddStream(stream); |
| 149 } | 159 } |
| 150 | 160 |
| 151 } // namespace webrtc | 161 } // namespace webrtc |
| OLD | NEW |