| 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_peer_connection_impl.h" | 5 #include "content/renderer/media/mock_peer_connection_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory.
h" | 10 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory.
h" |
| 11 | 11 |
| 12 using testing::_; | 12 using testing::_; |
| 13 using webrtc::AudioTrackInterface; | 13 using webrtc::AudioTrackInterface; |
| 14 using webrtc::CreateSessionDescriptionObserver; | 14 using webrtc::CreateSessionDescriptionObserver; |
| 15 using webrtc::DtmfSenderInterface; | 15 using webrtc::DtmfSenderInterface; |
| 16 using webrtc::DtmfSenderObserverInterface; | 16 using webrtc::DtmfSenderObserverInterface; |
| 17 using webrtc::IceCandidateInterface; | 17 using webrtc::IceCandidateInterface; |
| 18 using webrtc::MediaConstraintsInterface; | 18 using webrtc::MediaConstraintsInterface; |
| 19 using webrtc::MediaStreamInterface; | 19 using webrtc::MediaStreamInterface; |
| 20 using webrtc::PeerConnectionInterface; | 20 using webrtc::PeerConnectionInterface; |
| 21 using webrtc::SessionDescriptionInterface; | 21 using webrtc::SessionDescriptionInterface; |
| 22 using webrtc::SetSessionDescriptionObserver; | 22 using webrtc::SetSessionDescriptionObserver; |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 class MockStreamCollection : public webrtc::StreamCollectionInterface { | 26 class MockStreamCollection : public webrtc::StreamCollectionInterface { |
| 27 public: | 27 public: |
| 28 virtual size_t count() OVERRIDE { | 28 virtual size_t count() override { |
| 29 return streams_.size(); | 29 return streams_.size(); |
| 30 } | 30 } |
| 31 virtual MediaStreamInterface* at(size_t index) OVERRIDE { | 31 virtual MediaStreamInterface* at(size_t index) override { |
| 32 return streams_[index]; | 32 return streams_[index]; |
| 33 } | 33 } |
| 34 virtual MediaStreamInterface* find(const std::string& label) OVERRIDE { | 34 virtual MediaStreamInterface* find(const std::string& label) override { |
| 35 for (size_t i = 0; i < streams_.size(); ++i) { | 35 for (size_t i = 0; i < streams_.size(); ++i) { |
| 36 if (streams_[i]->label() == label) | 36 if (streams_[i]->label() == label) |
| 37 return streams_[i]; | 37 return streams_[i]; |
| 38 } | 38 } |
| 39 return NULL; | 39 return NULL; |
| 40 } | 40 } |
| 41 virtual webrtc::MediaStreamTrackInterface* FindAudioTrack( | 41 virtual webrtc::MediaStreamTrackInterface* FindAudioTrack( |
| 42 const std::string& id) OVERRIDE { | 42 const std::string& id) override { |
| 43 for (size_t i = 0; i < streams_.size(); ++i) { | 43 for (size_t i = 0; i < streams_.size(); ++i) { |
| 44 webrtc::MediaStreamTrackInterface* track = | 44 webrtc::MediaStreamTrackInterface* track = |
| 45 streams_.at(i)->FindAudioTrack(id); | 45 streams_.at(i)->FindAudioTrack(id); |
| 46 if (track) | 46 if (track) |
| 47 return track; | 47 return track; |
| 48 } | 48 } |
| 49 return NULL; | 49 return NULL; |
| 50 } | 50 } |
| 51 virtual webrtc::MediaStreamTrackInterface* FindVideoTrack( | 51 virtual webrtc::MediaStreamTrackInterface* FindVideoTrack( |
| 52 const std::string& id) OVERRIDE { | 52 const std::string& id) override { |
| 53 for (size_t i = 0; i < streams_.size(); ++i) { | 53 for (size_t i = 0; i < streams_.size(); ++i) { |
| 54 webrtc::MediaStreamTrackInterface* track = | 54 webrtc::MediaStreamTrackInterface* track = |
| 55 streams_.at(i)->FindVideoTrack(id); | 55 streams_.at(i)->FindVideoTrack(id); |
| 56 if (track) | 56 if (track) |
| 57 return track; | 57 return track; |
| 58 } | 58 } |
| 59 return NULL; | 59 return NULL; |
| 60 } | 60 } |
| 61 void AddStream(MediaStreamInterface* stream) { | 61 void AddStream(MediaStreamInterface* stream) { |
| 62 streams_.push_back(stream); | 62 streams_.push_back(stream); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 84 public: | 84 public: |
| 85 MockDataChannel(const std::string& label, | 85 MockDataChannel(const std::string& label, |
| 86 const webrtc::DataChannelInit* config) | 86 const webrtc::DataChannelInit* config) |
| 87 : label_(label), | 87 : label_(label), |
| 88 reliable_(config->reliable), | 88 reliable_(config->reliable), |
| 89 state_(webrtc::DataChannelInterface::kConnecting), | 89 state_(webrtc::DataChannelInterface::kConnecting), |
| 90 config_(*config) { | 90 config_(*config) { |
| 91 } | 91 } |
| 92 | 92 |
| 93 virtual void RegisterObserver( | 93 virtual void RegisterObserver( |
| 94 webrtc::DataChannelObserver* observer) OVERRIDE { | 94 webrtc::DataChannelObserver* observer) override { |
| 95 } | 95 } |
| 96 | 96 |
| 97 virtual void UnregisterObserver() OVERRIDE { | 97 virtual void UnregisterObserver() override { |
| 98 } | 98 } |
| 99 | 99 |
| 100 virtual std::string label() const OVERRIDE { | 100 virtual std::string label() const override { |
| 101 return label_; | 101 return label_; |
| 102 } | 102 } |
| 103 | 103 |
| 104 virtual bool reliable() const OVERRIDE { | 104 virtual bool reliable() const override { |
| 105 return reliable_; | 105 return reliable_; |
| 106 } | 106 } |
| 107 | 107 |
| 108 virtual bool ordered() const OVERRIDE { | 108 virtual bool ordered() const override { |
| 109 return config_.ordered; | 109 return config_.ordered; |
| 110 } | 110 } |
| 111 | 111 |
| 112 virtual unsigned short maxRetransmitTime() const OVERRIDE { | 112 virtual unsigned short maxRetransmitTime() const override { |
| 113 return config_.maxRetransmitTime; | 113 return config_.maxRetransmitTime; |
| 114 } | 114 } |
| 115 | 115 |
| 116 virtual unsigned short maxRetransmits() const OVERRIDE { | 116 virtual unsigned short maxRetransmits() const override { |
| 117 return config_.maxRetransmits; | 117 return config_.maxRetransmits; |
| 118 } | 118 } |
| 119 | 119 |
| 120 virtual std::string protocol() const OVERRIDE { | 120 virtual std::string protocol() const override { |
| 121 return config_.protocol; | 121 return config_.protocol; |
| 122 } | 122 } |
| 123 | 123 |
| 124 virtual bool negotiated() const OVERRIDE { | 124 virtual bool negotiated() const override { |
| 125 return config_.negotiated; | 125 return config_.negotiated; |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual int id() const OVERRIDE { | 128 virtual int id() const override { |
| 129 NOTIMPLEMENTED(); | 129 NOTIMPLEMENTED(); |
| 130 return 0; | 130 return 0; |
| 131 } | 131 } |
| 132 | 132 |
| 133 virtual DataState state() const OVERRIDE { | 133 virtual DataState state() const override { |
| 134 return state_; | 134 return state_; |
| 135 } | 135 } |
| 136 | 136 |
| 137 virtual uint64 buffered_amount() const OVERRIDE { | 137 virtual uint64 buffered_amount() const override { |
| 138 NOTIMPLEMENTED(); | 138 NOTIMPLEMENTED(); |
| 139 return 0; | 139 return 0; |
| 140 } | 140 } |
| 141 | 141 |
| 142 virtual void Close() OVERRIDE { | 142 virtual void Close() override { |
| 143 state_ = webrtc::DataChannelInterface::kClosing; | 143 state_ = webrtc::DataChannelInterface::kClosing; |
| 144 } | 144 } |
| 145 | 145 |
| 146 virtual bool Send(const webrtc::DataBuffer& buffer) OVERRIDE { | 146 virtual bool Send(const webrtc::DataBuffer& buffer) override { |
| 147 return state_ == webrtc::DataChannelInterface::kOpen; | 147 return state_ == webrtc::DataChannelInterface::kOpen; |
| 148 } | 148 } |
| 149 | 149 |
| 150 protected: | 150 protected: |
| 151 virtual ~MockDataChannel() {} | 151 virtual ~MockDataChannel() {} |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 std::string label_; | 154 std::string label_; |
| 155 bool reliable_; | 155 bool reliable_; |
| 156 webrtc::DataChannelInterface::DataState state_; | 156 webrtc::DataChannelInterface::DataState state_; |
| 157 webrtc::DataChannelInit config_; | 157 webrtc::DataChannelInit config_; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 class MockDtmfSender : public DtmfSenderInterface { | 160 class MockDtmfSender : public DtmfSenderInterface { |
| 161 public: | 161 public: |
| 162 explicit MockDtmfSender(AudioTrackInterface* track) | 162 explicit MockDtmfSender(AudioTrackInterface* track) |
| 163 : track_(track), | 163 : track_(track), |
| 164 observer_(NULL), | 164 observer_(NULL), |
| 165 duration_(0), | 165 duration_(0), |
| 166 inter_tone_gap_(0) {} | 166 inter_tone_gap_(0) {} |
| 167 virtual void RegisterObserver( | 167 virtual void RegisterObserver( |
| 168 DtmfSenderObserverInterface* observer) OVERRIDE { | 168 DtmfSenderObserverInterface* observer) override { |
| 169 observer_ = observer; | 169 observer_ = observer; |
| 170 } | 170 } |
| 171 virtual void UnregisterObserver() OVERRIDE { | 171 virtual void UnregisterObserver() override { |
| 172 observer_ = NULL; | 172 observer_ = NULL; |
| 173 } | 173 } |
| 174 virtual bool CanInsertDtmf() OVERRIDE { | 174 virtual bool CanInsertDtmf() override { |
| 175 return true; | 175 return true; |
| 176 } | 176 } |
| 177 virtual bool InsertDtmf(const std::string& tones, int duration, | 177 virtual bool InsertDtmf(const std::string& tones, int duration, |
| 178 int inter_tone_gap) OVERRIDE { | 178 int inter_tone_gap) override { |
| 179 tones_ = tones; | 179 tones_ = tones; |
| 180 duration_ = duration; | 180 duration_ = duration; |
| 181 inter_tone_gap_ = inter_tone_gap; | 181 inter_tone_gap_ = inter_tone_gap; |
| 182 return true; | 182 return true; |
| 183 } | 183 } |
| 184 virtual const AudioTrackInterface* track() const OVERRIDE { | 184 virtual const AudioTrackInterface* track() const override { |
| 185 return track_.get(); | 185 return track_.get(); |
| 186 } | 186 } |
| 187 virtual std::string tones() const OVERRIDE { | 187 virtual std::string tones() const override { |
| 188 return tones_; | 188 return tones_; |
| 189 } | 189 } |
| 190 virtual int duration() const OVERRIDE { return duration_; } | 190 virtual int duration() const override { return duration_; } |
| 191 virtual int inter_tone_gap() const OVERRIDE { return inter_tone_gap_; } | 191 virtual int inter_tone_gap() const override { return inter_tone_gap_; } |
| 192 | 192 |
| 193 protected: | 193 protected: |
| 194 virtual ~MockDtmfSender() {} | 194 virtual ~MockDtmfSender() {} |
| 195 | 195 |
| 196 private: | 196 private: |
| 197 rtc::scoped_refptr<AudioTrackInterface> track_; | 197 rtc::scoped_refptr<AudioTrackInterface> track_; |
| 198 DtmfSenderObserverInterface* observer_; | 198 DtmfSenderObserverInterface* observer_; |
| 199 std::string tones_; | 199 std::string tones_; |
| 200 int duration_; | 200 int duration_; |
| 201 int inter_tone_gap_; | 201 int inter_tone_gap_; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 sdp_mline_index_ = candidate->sdp_mline_index(); | 359 sdp_mline_index_ = candidate->sdp_mline_index(); |
| 360 return candidate->ToString(&ice_sdp_); | 360 return candidate->ToString(&ice_sdp_); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void MockPeerConnectionImpl::RegisterUMAObserver( | 363 void MockPeerConnectionImpl::RegisterUMAObserver( |
| 364 webrtc::UMAObserver* observer) { | 364 webrtc::UMAObserver* observer) { |
| 365 NOTIMPLEMENTED(); | 365 NOTIMPLEMENTED(); |
| 366 } | 366 } |
| 367 | 367 |
| 368 } // namespace content | 368 } // namespace content |
| OLD | NEW |