pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
| 3 | * Copyright 2014 Google Inc. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 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 |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 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 |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 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, |
| 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 |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #ifndef TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_ |
| 29 | #define TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_ |
| 30 | |
| 31 | #include <map> |
| 32 | #include <vector> |
| 33 | |
| 34 | #include "webrtc/call.h" |
| 35 | #include "webrtc/video_receive_stream.h" |
| 36 | #include "webrtc/video_send_stream.h" |
| 37 | |
| 38 | namespace cricket { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 39 | class FakeVideoSendStream : public webrtc::VideoSendStream, |
| 40 | public webrtc::VideoSendStreamInput { |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 41 | public: |
| 42 | FakeVideoSendStream(const webrtc::VideoSendStream::Config& config, |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 43 | const webrtc::VideoEncoderConfig& encoder_config); |
pbos@webrtc.org | efc82c2 | 2014-10-27 13:58:00 +0000 | [diff] [blame] | 44 | webrtc::VideoSendStream::Config GetConfig() const; |
| 45 | webrtc::VideoEncoderConfig GetEncoderConfig() const; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 46 | std::vector<webrtc::VideoStream> GetVideoStreams(); |
| 47 | |
pbos@webrtc.org | 85f4294 | 2014-07-22 09:14:58 +0000 | [diff] [blame] | 48 | bool IsSending() const; |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 49 | bool GetVp8Settings(webrtc::VideoCodecVP8* settings) const; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 50 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 51 | int GetNumberOfSwappedFrames() const; |
| 52 | int GetLastWidth() const; |
| 53 | int GetLastHeight() const; |
pbos@webrtc.org | 273a414 | 2014-12-01 15:23:21 +0000 | [diff] [blame] | 54 | void SetStats(const webrtc::VideoSendStream::Stats& stats); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 55 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 56 | private: |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame^] | 57 | void SwapFrame(webrtc::I420VideoFrame* frame) override; |
| 58 | webrtc::VideoSendStream::Stats GetStats() override; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 59 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame^] | 60 | bool ReconfigureVideoEncoder( |
| 61 | const webrtc::VideoEncoderConfig& config) override; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 62 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame^] | 63 | webrtc::VideoSendStreamInput* Input() override; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 64 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame^] | 65 | void Start() override; |
| 66 | void Stop() override; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 67 | |
| 68 | bool sending_; |
| 69 | webrtc::VideoSendStream::Config config_; |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 70 | webrtc::VideoEncoderConfig encoder_config_; |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 71 | bool codec_settings_set_; |
| 72 | webrtc::VideoCodecVP8 vp8_settings_; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 73 | int num_swapped_frames_; |
| 74 | webrtc::I420VideoFrame last_frame_; |
pbos@webrtc.org | 273a414 | 2014-12-01 15:23:21 +0000 | [diff] [blame] | 75 | webrtc::VideoSendStream::Stats stats_; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | class FakeVideoReceiveStream : public webrtc::VideoReceiveStream { |
| 79 | public: |
| 80 | explicit FakeVideoReceiveStream( |
| 81 | const webrtc::VideoReceiveStream::Config& config); |
| 82 | |
| 83 | webrtc::VideoReceiveStream::Config GetConfig(); |
| 84 | |
pbos@webrtc.org | 85f4294 | 2014-07-22 09:14:58 +0000 | [diff] [blame] | 85 | bool IsReceiving() const; |
| 86 | |
magjed@webrtc.org | fc5ad95 | 2015-01-27 09:57:01 +0000 | [diff] [blame] | 87 | void InjectFrame(const webrtc::I420VideoFrame& frame, int time_to_render_ms); |
| 88 | |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 89 | void SetStats(const webrtc::VideoReceiveStream::Stats& stats); |
| 90 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 91 | private: |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame^] | 92 | webrtc::VideoReceiveStream::Stats GetStats() const override; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 93 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame^] | 94 | void Start() override; |
| 95 | void Stop() override; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 96 | |
| 97 | webrtc::VideoReceiveStream::Config config_; |
| 98 | bool receiving_; |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 99 | webrtc::VideoReceiveStream::Stats stats_; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | class FakeCall : public webrtc::Call { |
| 103 | public: |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 104 | FakeCall(const webrtc::Call::Config& config); |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 105 | ~FakeCall(); |
| 106 | |
| 107 | void SetVideoCodecs(const std::vector<webrtc::VideoCodec> codecs); |
| 108 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 109 | webrtc::Call::Config GetConfig() const; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 110 | std::vector<FakeVideoSendStream*> GetVideoSendStreams(); |
| 111 | std::vector<FakeVideoReceiveStream*> GetVideoReceiveStreams(); |
| 112 | |
| 113 | webrtc::VideoCodec GetEmptyVideoCodec(); |
| 114 | |
| 115 | webrtc::VideoCodec GetVideoCodecVp8(); |
| 116 | webrtc::VideoCodec GetVideoCodecVp9(); |
| 117 | |
| 118 | std::vector<webrtc::VideoCodec> GetDefaultVideoCodecs(); |
| 119 | |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 120 | webrtc::Call::NetworkState GetNetworkState() const; |
pbos@webrtc.org | c37e72e | 2015-01-05 18:51:13 +0000 | [diff] [blame] | 121 | int GetNumCreatedSendStreams() const; |
| 122 | int GetNumCreatedReceiveStreams() const; |
pbos@webrtc.org | 2b19f06 | 2014-12-11 13:26:09 +0000 | [diff] [blame] | 123 | void SetStats(const webrtc::Call::Stats& stats); |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 124 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 125 | private: |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame^] | 126 | webrtc::VideoSendStream* CreateVideoSendStream( |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 127 | const webrtc::VideoSendStream::Config& config, |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame^] | 128 | const webrtc::VideoEncoderConfig& encoder_config) override; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 129 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame^] | 130 | void DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) override; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 131 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame^] | 132 | webrtc::VideoReceiveStream* CreateVideoReceiveStream( |
| 133 | const webrtc::VideoReceiveStream::Config& config) override; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 134 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame^] | 135 | void DestroyVideoReceiveStream( |
| 136 | webrtc::VideoReceiveStream* receive_stream) override; |
| 137 | webrtc::PacketReceiver* Receiver() override; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 138 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame^] | 139 | webrtc::Call::Stats GetStats() const override; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 140 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame^] | 141 | void SetBitrateConfig( |
| 142 | const webrtc::Call::Config::BitrateConfig& bitrate_config) override; |
| 143 | void SignalNetworkState(webrtc::Call::NetworkState state) override; |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 144 | |
pbos@webrtc.org | 0087318 | 2014-11-25 14:03:34 +0000 | [diff] [blame] | 145 | webrtc::Call::Config config_; |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 146 | webrtc::Call::NetworkState network_state_; |
pbos@webrtc.org | 2b19f06 | 2014-12-11 13:26:09 +0000 | [diff] [blame] | 147 | webrtc::Call::Stats stats_; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 148 | std::vector<webrtc::VideoCodec> codecs_; |
| 149 | std::vector<FakeVideoSendStream*> video_send_streams_; |
| 150 | std::vector<FakeVideoReceiveStream*> video_receive_streams_; |
pbos@webrtc.org | c37e72e | 2015-01-05 18:51:13 +0000 | [diff] [blame] | 151 | |
| 152 | int num_created_send_streams_; |
| 153 | int num_created_receive_streams_; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 154 | }; |
| 155 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 156 | } // namespace cricket |
| 157 | #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_ |