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, |
(...skipping 11 matching lines...) Expand all Loading... |
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 | 28 // This file contains fake implementations, for use in unit tests, of the |
29 // following classes: | 29 // following classes: |
30 // | 30 // |
31 // webrtc::Call | 31 // webrtc::Call |
| 32 // webrtc::AudioState |
32 // webrtc::AudioSendStream | 33 // webrtc::AudioSendStream |
33 // webrtc::AudioReceiveStream | 34 // webrtc::AudioReceiveStream |
34 // webrtc::VideoSendStream | 35 // webrtc::VideoSendStream |
35 // webrtc::VideoReceiveStream | 36 // webrtc::VideoReceiveStream |
36 | 37 |
37 #ifndef TALK_MEDIA_WEBRTC_FAKEWEBRTCCALL_H_ | 38 #ifndef TALK_MEDIA_WEBRTC_FAKEWEBRTCCALL_H_ |
38 #define TALK_MEDIA_WEBRTC_FAKEWEBRTCCALL_H_ | 39 #define TALK_MEDIA_WEBRTC_FAKEWEBRTCCALL_H_ |
39 | 40 |
40 #include <vector> | 41 #include <vector> |
41 | 42 |
42 #include "webrtc/call.h" | 43 #include "webrtc/call.h" |
| 44 #include "webrtc/audio_state.h" |
43 #include "webrtc/audio_receive_stream.h" | 45 #include "webrtc/audio_receive_stream.h" |
44 #include "webrtc/audio_send_stream.h" | 46 #include "webrtc/audio_send_stream.h" |
45 #include "webrtc/video_frame.h" | 47 #include "webrtc/video_frame.h" |
46 #include "webrtc/video_receive_stream.h" | 48 #include "webrtc/video_receive_stream.h" |
47 #include "webrtc/video_send_stream.h" | 49 #include "webrtc/video_send_stream.h" |
48 | 50 |
49 namespace cricket { | 51 namespace cricket { |
50 | 52 |
51 class FakeAudioSendStream : public webrtc::AudioSendStream { | 53 class FakeAudioState final : public webrtc::AudioState { |
| 54 public: |
| 55 FakeAudioState() {} |
| 56 ~FakeAudioState() override {} |
| 57 }; |
| 58 |
| 59 class FakeAudioSendStream final : public webrtc::AudioSendStream { |
52 public: | 60 public: |
53 explicit FakeAudioSendStream( | 61 explicit FakeAudioSendStream( |
54 const webrtc::AudioSendStream::Config& config); | 62 const webrtc::AudioSendStream::Config& config); |
55 | 63 |
56 const webrtc::AudioSendStream::Config& GetConfig() const; | 64 const webrtc::AudioSendStream::Config& GetConfig() const; |
57 void SetStats(const webrtc::AudioSendStream::Stats& stats); | 65 void SetStats(const webrtc::AudioSendStream::Stats& stats); |
58 | 66 |
59 private: | 67 private: |
60 // webrtc::SendStream implementation. | 68 // webrtc::SendStream implementation. |
61 void Start() override {} | 69 void Start() override {} |
62 void Stop() override {} | 70 void Stop() override {} |
63 void SignalNetworkState(webrtc::NetworkState state) override {} | 71 void SignalNetworkState(webrtc::NetworkState state) override {} |
64 bool DeliverRtcp(const uint8_t* packet, size_t length) override { | 72 bool DeliverRtcp(const uint8_t* packet, size_t length) override { |
65 return true; | 73 return true; |
66 } | 74 } |
67 | 75 |
68 // webrtc::AudioSendStream implementation. | 76 // webrtc::AudioSendStream implementation. |
69 webrtc::AudioSendStream::Stats GetStats() const override; | 77 webrtc::AudioSendStream::Stats GetStats() const override; |
70 | 78 |
71 webrtc::AudioSendStream::Config config_; | 79 webrtc::AudioSendStream::Config config_; |
72 webrtc::AudioSendStream::Stats stats_; | 80 webrtc::AudioSendStream::Stats stats_; |
73 }; | 81 }; |
74 | 82 |
75 class FakeAudioReceiveStream : public webrtc::AudioReceiveStream { | 83 class FakeAudioReceiveStream final : public webrtc::AudioReceiveStream { |
76 public: | 84 public: |
77 explicit FakeAudioReceiveStream( | 85 explicit FakeAudioReceiveStream( |
78 const webrtc::AudioReceiveStream::Config& config); | 86 const webrtc::AudioReceiveStream::Config& config); |
79 | 87 |
80 const webrtc::AudioReceiveStream::Config& GetConfig() const; | 88 const webrtc::AudioReceiveStream::Config& GetConfig() const; |
81 void SetStats(const webrtc::AudioReceiveStream::Stats& stats); | 89 void SetStats(const webrtc::AudioReceiveStream::Stats& stats); |
82 int received_packets() const { return received_packets_; } | 90 int received_packets() const { return received_packets_; } |
83 void IncrementReceivedPackets(); | 91 void IncrementReceivedPackets(); |
84 | 92 |
85 private: | 93 private: |
(...skipping 11 matching lines...) Expand all Loading... |
97 } | 105 } |
98 | 106 |
99 // webrtc::AudioReceiveStream implementation. | 107 // webrtc::AudioReceiveStream implementation. |
100 webrtc::AudioReceiveStream::Stats GetStats() const override; | 108 webrtc::AudioReceiveStream::Stats GetStats() const override; |
101 | 109 |
102 webrtc::AudioReceiveStream::Config config_; | 110 webrtc::AudioReceiveStream::Config config_; |
103 webrtc::AudioReceiveStream::Stats stats_; | 111 webrtc::AudioReceiveStream::Stats stats_; |
104 int received_packets_; | 112 int received_packets_; |
105 }; | 113 }; |
106 | 114 |
107 class FakeVideoSendStream : public webrtc::VideoSendStream, | 115 class FakeVideoSendStream final : public webrtc::VideoSendStream, |
108 public webrtc::VideoCaptureInput { | 116 public webrtc::VideoCaptureInput { |
109 public: | 117 public: |
110 FakeVideoSendStream(const webrtc::VideoSendStream::Config& config, | 118 FakeVideoSendStream(const webrtc::VideoSendStream::Config& config, |
111 const webrtc::VideoEncoderConfig& encoder_config); | 119 const webrtc::VideoEncoderConfig& encoder_config); |
112 webrtc::VideoSendStream::Config GetConfig() const; | 120 webrtc::VideoSendStream::Config GetConfig() const; |
113 webrtc::VideoEncoderConfig GetEncoderConfig() const; | 121 webrtc::VideoEncoderConfig GetEncoderConfig() const; |
114 std::vector<webrtc::VideoStream> GetVideoStreams(); | 122 std::vector<webrtc::VideoStream> GetVideoStreams(); |
115 | 123 |
116 bool IsSending() const; | 124 bool IsSending() const; |
117 bool GetVp8Settings(webrtc::VideoCodecVP8* settings) const; | 125 bool GetVp8Settings(webrtc::VideoCodecVP8* settings) const; |
118 bool GetVp9Settings(webrtc::VideoCodecVP9* settings) const; | 126 bool GetVp9Settings(webrtc::VideoCodecVP9* settings) const; |
(...skipping 27 matching lines...) Expand all Loading... |
146 bool codec_settings_set_; | 154 bool codec_settings_set_; |
147 union VpxSettings { | 155 union VpxSettings { |
148 webrtc::VideoCodecVP8 vp8; | 156 webrtc::VideoCodecVP8 vp8; |
149 webrtc::VideoCodecVP9 vp9; | 157 webrtc::VideoCodecVP9 vp9; |
150 } vpx_settings_; | 158 } vpx_settings_; |
151 int num_swapped_frames_; | 159 int num_swapped_frames_; |
152 webrtc::VideoFrame last_frame_; | 160 webrtc::VideoFrame last_frame_; |
153 webrtc::VideoSendStream::Stats stats_; | 161 webrtc::VideoSendStream::Stats stats_; |
154 }; | 162 }; |
155 | 163 |
156 class FakeVideoReceiveStream : public webrtc::VideoReceiveStream { | 164 class FakeVideoReceiveStream final : public webrtc::VideoReceiveStream { |
157 public: | 165 public: |
158 explicit FakeVideoReceiveStream( | 166 explicit FakeVideoReceiveStream( |
159 const webrtc::VideoReceiveStream::Config& config); | 167 const webrtc::VideoReceiveStream::Config& config); |
160 | 168 |
161 webrtc::VideoReceiveStream::Config GetConfig(); | 169 webrtc::VideoReceiveStream::Config GetConfig(); |
162 | 170 |
163 bool IsReceiving() const; | 171 bool IsReceiving() const; |
164 | 172 |
165 void InjectFrame(const webrtc::VideoFrame& frame, int time_to_render_ms); | 173 void InjectFrame(const webrtc::VideoFrame& frame, int time_to_render_ms); |
166 | 174 |
(...skipping 14 matching lines...) Expand all Loading... |
181 } | 189 } |
182 | 190 |
183 // webrtc::VideoReceiveStream implementation. | 191 // webrtc::VideoReceiveStream implementation. |
184 webrtc::VideoReceiveStream::Stats GetStats() const override; | 192 webrtc::VideoReceiveStream::Stats GetStats() const override; |
185 | 193 |
186 webrtc::VideoReceiveStream::Config config_; | 194 webrtc::VideoReceiveStream::Config config_; |
187 bool receiving_; | 195 bool receiving_; |
188 webrtc::VideoReceiveStream::Stats stats_; | 196 webrtc::VideoReceiveStream::Stats stats_; |
189 }; | 197 }; |
190 | 198 |
191 class FakeCall : public webrtc::Call, public webrtc::PacketReceiver { | 199 class FakeCall final : public webrtc::Call, public webrtc::PacketReceiver { |
192 public: | 200 public: |
193 explicit FakeCall(const webrtc::Call::Config& config); | 201 explicit FakeCall(const webrtc::Call::Config& config); |
194 ~FakeCall() override; | 202 ~FakeCall() override; |
195 | 203 |
196 webrtc::Call::Config GetConfig() const; | 204 webrtc::Call::Config GetConfig() const; |
197 const std::vector<FakeVideoSendStream*>& GetVideoSendStreams(); | 205 const std::vector<FakeVideoSendStream*>& GetVideoSendStreams(); |
198 const std::vector<FakeVideoReceiveStream*>& GetVideoReceiveStreams(); | 206 const std::vector<FakeVideoReceiveStream*>& GetVideoReceiveStreams(); |
199 | 207 |
200 const std::vector<FakeAudioSendStream*>& GetAudioSendStreams(); | 208 const std::vector<FakeAudioSendStream*>& GetAudioSendStreams(); |
201 const FakeAudioSendStream* GetAudioSendStream(uint32_t ssrc); | 209 const FakeAudioSendStream* GetAudioSendStream(uint32_t ssrc); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 std::vector<FakeAudioSendStream*> audio_send_streams_; | 257 std::vector<FakeAudioSendStream*> audio_send_streams_; |
250 std::vector<FakeVideoReceiveStream*> video_receive_streams_; | 258 std::vector<FakeVideoReceiveStream*> video_receive_streams_; |
251 std::vector<FakeAudioReceiveStream*> audio_receive_streams_; | 259 std::vector<FakeAudioReceiveStream*> audio_receive_streams_; |
252 | 260 |
253 int num_created_send_streams_; | 261 int num_created_send_streams_; |
254 int num_created_receive_streams_; | 262 int num_created_receive_streams_; |
255 }; | 263 }; |
256 | 264 |
257 } // namespace cricket | 265 } // namespace cricket |
258 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_ | 266 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_ |
OLD | NEW |