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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 private: | 36 private: |
37 std::vector<talk_base::scoped_refptr<MediaStreamInterface> > streams_; | 37 std::vector<talk_base::scoped_refptr<MediaStreamInterface> > streams_; |
38 }; | 38 }; |
39 | 39 |
40 const char MockPeerConnectionImpl::kDummyOffer[] = "dummy offer"; | 40 const char MockPeerConnectionImpl::kDummyOffer[] = "dummy offer"; |
41 | 41 |
42 MockPeerConnectionImpl::MockPeerConnectionImpl( | 42 MockPeerConnectionImpl::MockPeerConnectionImpl( |
43 MockMediaStreamDependencyFactory* factory) | 43 MockMediaStreamDependencyFactory* factory) |
44 : dependency_factory_(factory), | 44 : dependency_factory_(factory), |
45 stream_changes_committed_(false), | |
46 local_streams_(new talk_base::RefCountedObject<MockStreamCollection>), | 45 local_streams_(new talk_base::RefCountedObject<MockStreamCollection>), |
47 remote_streams_(new talk_base::RefCountedObject<MockStreamCollection>), | 46 remote_streams_(new talk_base::RefCountedObject<MockStreamCollection>), |
48 hint_audio_(false), | 47 hint_audio_(false), |
49 hint_video_(false), | 48 hint_video_(false), |
50 action_(kAnswer), | 49 action_(kAnswer), |
51 ice_options_(kOnlyRelay), | 50 ice_options_(kOnlyRelay), |
52 ready_state_(kNew) { | 51 ready_state_(kNew) { |
53 } | 52 } |
54 | 53 |
55 MockPeerConnectionImpl::~MockPeerConnectionImpl() {} | 54 MockPeerConnectionImpl::~MockPeerConnectionImpl() {} |
56 | 55 |
57 void MockPeerConnectionImpl::ProcessSignalingMessage(const std::string& msg) { | |
58 signaling_message_ = msg; | |
59 } | |
60 | |
61 bool MockPeerConnectionImpl::Send(const std::string& msg) { | |
62 NOTIMPLEMENTED(); | |
63 return false; | |
64 } | |
65 | |
66 talk_base::scoped_refptr<StreamCollectionInterface> | 56 talk_base::scoped_refptr<StreamCollectionInterface> |
67 MockPeerConnectionImpl::local_streams() { | 57 MockPeerConnectionImpl::local_streams() { |
68 return local_streams_; | 58 return local_streams_; |
69 } | 59 } |
70 | 60 |
71 talk_base::scoped_refptr<StreamCollectionInterface> | 61 talk_base::scoped_refptr<StreamCollectionInterface> |
72 MockPeerConnectionImpl::remote_streams() { | 62 MockPeerConnectionImpl::remote_streams() { |
73 return remote_streams_; | 63 return remote_streams_; |
74 } | 64 } |
75 | 65 |
76 void MockPeerConnectionImpl::AddStream(LocalMediaStreamInterface* stream) { | 66 void MockPeerConnectionImpl::AddStream(LocalMediaStreamInterface* stream) { |
77 DCHECK(stream_label_.empty()); | 67 DCHECK(stream_label_.empty()); |
78 stream_label_ = stream->label(); | 68 stream_label_ = stream->label(); |
79 local_streams_->AddStream(stream); | 69 local_streams_->AddStream(stream); |
80 } | 70 } |
81 | 71 |
82 bool MockPeerConnectionImpl::AddStream( | 72 bool MockPeerConnectionImpl::AddStream( |
83 MediaStreamInterface* local_stream, | 73 MediaStreamInterface* local_stream, |
84 const MediaConstraintsInterface* constraints) { | 74 const MediaConstraintsInterface* constraints) { |
85 DCHECK(stream_label_.empty()); | 75 DCHECK(stream_label_.empty()); |
86 stream_label_ = local_stream->label(); | 76 stream_label_ = local_stream->label(); |
87 local_streams_->AddStream(local_stream); | 77 local_streams_->AddStream(local_stream); |
88 return true; | 78 return true; |
89 } | 79 } |
90 | 80 |
91 void MockPeerConnectionImpl::RemoveStream(LocalMediaStreamInterface* stream) { | |
92 DCHECK_EQ(stream_label_, stream->label()); | |
93 stream_label_.clear(); | |
94 } | |
95 | |
96 void MockPeerConnectionImpl::RemoveStream( | 81 void MockPeerConnectionImpl::RemoveStream( |
97 MediaStreamInterface* local_stream) { | 82 MediaStreamInterface* local_stream) { |
98 DCHECK_EQ(stream_label_, local_stream->label()); | 83 DCHECK_EQ(stream_label_, local_stream->label()); |
99 stream_label_.clear(); | 84 stream_label_.clear(); |
100 } | 85 } |
101 | 86 |
102 bool MockPeerConnectionImpl::RemoveStream(const std::string& label) { | |
103 if (stream_label_ != label) | |
104 return false; | |
105 stream_label_.clear(); | |
106 return true; | |
107 } | |
108 | |
109 void MockPeerConnectionImpl::CommitStreamChanges() { | |
110 stream_changes_committed_ = true; | |
111 } | |
112 | |
113 void MockPeerConnectionImpl::Close() { | |
114 signaling_message_.clear(); | |
115 stream_label_.clear(); | |
116 stream_changes_committed_ = false; | |
117 } | |
118 | |
119 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::ready_state() { | 87 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::ready_state() { |
120 return ready_state_; | 88 return ready_state_; |
121 } | 89 } |
122 | 90 |
123 MockPeerConnectionImpl::SdpState MockPeerConnectionImpl::sdp_state() { | |
124 NOTIMPLEMENTED(); | |
125 return kSdpNew; | |
126 } | |
127 | |
128 bool MockPeerConnectionImpl::StartIce(IceOptions options) { | 91 bool MockPeerConnectionImpl::StartIce(IceOptions options) { |
129 ice_options_ = options; | 92 ice_options_ = options; |
130 return true; | 93 return true; |
131 } | 94 } |
132 | 95 |
133 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateOffer( | 96 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateOffer( |
134 const webrtc::MediaHints& hints) { | 97 const webrtc::MediaHints& hints) { |
135 hint_audio_ = hints.has_audio(); | 98 hint_audio_ = hints.has_audio(); |
136 hint_video_ = hints.has_video(); | 99 hint_video_ = hints.has_video(); |
137 return dependency_factory_->CreateSessionDescription(kDummyOffer); | 100 return dependency_factory_->CreateSessionDescription(kDummyOffer); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 NOTIMPLEMENTED(); | 182 NOTIMPLEMENTED(); |
220 return false; | 183 return false; |
221 } | 184 } |
222 | 185 |
223 PeerConnectionInterface::IceState MockPeerConnectionImpl::ice_state() { | 186 PeerConnectionInterface::IceState MockPeerConnectionImpl::ice_state() { |
224 NOTIMPLEMENTED(); | 187 NOTIMPLEMENTED(); |
225 return kIceNew; | 188 return kIceNew; |
226 } | 189 } |
227 | 190 |
228 } // namespace webrtc | 191 } // namespace webrtc |
OLD | NEW |