OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
11 * this list of conditions and the following disclaimer in the documentation | 11 * this list of conditions and the following disclaimer in the documentation |
12 * and/or other materials provided with the distribution. | 12 * and/or other materials provided with the distribution. |
13 * 3. The name of the author may not be used to endorse or promote products | 13 * 3. The name of the author may not be used to endorse or promote products |
14 * derived from this software without specific prior written permission. | 14 * derived from this software without specific prior written permission. |
15 * | 15 * |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
| 28 // This file contains fake implementations, for use in unit tests, of the |
| 29 // following classes: |
| 30 // |
| 31 // webrtc::Call |
| 32 // webrtc::AudioSendStream |
| 33 // webrtc::AudioReceiveStream |
| 34 // webrtc::VideoSendStream |
| 35 // webrtc::VideoReceiveStream |
| 36 |
28 #ifndef TALK_MEDIA_WEBRTC_FAKEWEBRTCCALL_H_ | 37 #ifndef TALK_MEDIA_WEBRTC_FAKEWEBRTCCALL_H_ |
29 #define TALK_MEDIA_WEBRTC_FAKEWEBRTCCALL_H_ | 38 #define TALK_MEDIA_WEBRTC_FAKEWEBRTCCALL_H_ |
30 | 39 |
31 #include <vector> | 40 #include <vector> |
32 | 41 |
33 #include "webrtc/call.h" | 42 #include "webrtc/call.h" |
34 #include "webrtc/audio_receive_stream.h" | 43 #include "webrtc/audio_receive_stream.h" |
| 44 #include "webrtc/audio_send_stream.h" |
35 #include "webrtc/video_frame.h" | 45 #include "webrtc/video_frame.h" |
36 #include "webrtc/video_receive_stream.h" | 46 #include "webrtc/video_receive_stream.h" |
37 #include "webrtc/video_send_stream.h" | 47 #include "webrtc/video_send_stream.h" |
38 | 48 |
39 namespace cricket { | 49 namespace cricket { |
| 50 |
| 51 class FakeAudioSendStream : public webrtc::AudioSendStream { |
| 52 public: |
| 53 explicit FakeAudioSendStream( |
| 54 const webrtc::AudioSendStream::Config& config); |
| 55 |
| 56 // webrtc::AudioSendStream implementation. |
| 57 webrtc::AudioSendStream::Stats GetStats() const override; |
| 58 |
| 59 const webrtc::AudioSendStream::Config& GetConfig() const; |
| 60 |
| 61 private: |
| 62 // webrtc::SendStream implementation. |
| 63 void Start() override {} |
| 64 void Stop() override {} |
| 65 void SignalNetworkState(webrtc::NetworkState state) override {} |
| 66 bool DeliverRtcp(const uint8_t* packet, size_t length) override { |
| 67 return true; |
| 68 } |
| 69 |
| 70 webrtc::AudioSendStream::Config config_; |
| 71 }; |
| 72 |
40 class FakeAudioReceiveStream : public webrtc::AudioReceiveStream { | 73 class FakeAudioReceiveStream : public webrtc::AudioReceiveStream { |
41 public: | 74 public: |
42 explicit FakeAudioReceiveStream( | 75 explicit FakeAudioReceiveStream( |
43 const webrtc::AudioReceiveStream::Config& config); | 76 const webrtc::AudioReceiveStream::Config& config); |
44 | 77 |
45 // webrtc::AudioReceiveStream implementation. | 78 // webrtc::AudioReceiveStream implementation. |
46 webrtc::AudioReceiveStream::Stats GetStats() const override; | 79 webrtc::AudioReceiveStream::Stats GetStats() const override; |
47 | 80 |
48 const webrtc::AudioReceiveStream::Config& GetConfig() const; | 81 const webrtc::AudioReceiveStream::Config& GetConfig() const; |
49 | 82 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 187 |
155 class FakeCall : public webrtc::Call, public webrtc::PacketReceiver { | 188 class FakeCall : public webrtc::Call, public webrtc::PacketReceiver { |
156 public: | 189 public: |
157 explicit FakeCall(const webrtc::Call::Config& config); | 190 explicit FakeCall(const webrtc::Call::Config& config); |
158 ~FakeCall() override; | 191 ~FakeCall() override; |
159 | 192 |
160 webrtc::Call::Config GetConfig() const; | 193 webrtc::Call::Config GetConfig() const; |
161 const std::vector<FakeVideoSendStream*>& GetVideoSendStreams(); | 194 const std::vector<FakeVideoSendStream*>& GetVideoSendStreams(); |
162 const std::vector<FakeVideoReceiveStream*>& GetVideoReceiveStreams(); | 195 const std::vector<FakeVideoReceiveStream*>& GetVideoReceiveStreams(); |
163 | 196 |
| 197 const std::vector<FakeAudioSendStream*>& GetAudioSendStreams(); |
| 198 const FakeAudioSendStream* GetAudioSendStream(uint32_t ssrc); |
164 const std::vector<FakeAudioReceiveStream*>& GetAudioReceiveStreams(); | 199 const std::vector<FakeAudioReceiveStream*>& GetAudioReceiveStreams(); |
165 const FakeAudioReceiveStream* GetAudioReceiveStream(uint32_t ssrc); | 200 const FakeAudioReceiveStream* GetAudioReceiveStream(uint32_t ssrc); |
166 | 201 |
167 rtc::SentPacket last_sent_packet() const { return last_sent_packet_; } | 202 rtc::SentPacket last_sent_packet() const { return last_sent_packet_; } |
168 webrtc::NetworkState GetNetworkState() const; | 203 webrtc::NetworkState GetNetworkState() const; |
169 int GetNumCreatedSendStreams() const; | 204 int GetNumCreatedSendStreams() const; |
170 int GetNumCreatedReceiveStreams() const; | 205 int GetNumCreatedReceiveStreams() const; |
171 void SetStats(const webrtc::Call::Stats& stats); | 206 void SetStats(const webrtc::Call::Stats& stats); |
172 | 207 |
173 private: | 208 private: |
(...skipping 27 matching lines...) Expand all Loading... |
201 void SetBitrateConfig( | 236 void SetBitrateConfig( |
202 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; | 237 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; |
203 void SignalNetworkState(webrtc::NetworkState state) override; | 238 void SignalNetworkState(webrtc::NetworkState state) override; |
204 void OnSentPacket(const rtc::SentPacket& sent_packet) override; | 239 void OnSentPacket(const rtc::SentPacket& sent_packet) override; |
205 | 240 |
206 webrtc::Call::Config config_; | 241 webrtc::Call::Config config_; |
207 webrtc::NetworkState network_state_; | 242 webrtc::NetworkState network_state_; |
208 rtc::SentPacket last_sent_packet_; | 243 rtc::SentPacket last_sent_packet_; |
209 webrtc::Call::Stats stats_; | 244 webrtc::Call::Stats stats_; |
210 std::vector<FakeVideoSendStream*> video_send_streams_; | 245 std::vector<FakeVideoSendStream*> video_send_streams_; |
| 246 std::vector<FakeAudioSendStream*> audio_send_streams_; |
211 std::vector<FakeVideoReceiveStream*> video_receive_streams_; | 247 std::vector<FakeVideoReceiveStream*> video_receive_streams_; |
212 std::vector<FakeAudioReceiveStream*> audio_receive_streams_; | 248 std::vector<FakeAudioReceiveStream*> audio_receive_streams_; |
213 | 249 |
214 int num_created_send_streams_; | 250 int num_created_send_streams_; |
215 int num_created_receive_streams_; | 251 int num_created_receive_streams_; |
216 }; | 252 }; |
217 | 253 |
218 } // namespace cricket | 254 } // namespace cricket |
219 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_ | 255 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_ |
OLD | NEW |