pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
| 3 | * Copyright 2004 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 | #include <map> |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 29 | #include <vector> |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 30 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 31 | #include "talk/media/base/testutils.h" |
| 32 | #include "talk/media/base/videoengine_unittest.h" |
pbos@webrtc.org | 7fe1e03 | 2014-10-14 04:25:33 +0000 | [diff] [blame] | 33 | #include "talk/media/webrtc/fakewebrtcvideoengine.h" |
buildbot@webrtc.org | a853077 | 2014-12-10 09:01:18 +0000 | [diff] [blame] | 34 | #include "talk/media/webrtc/simulcast.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 35 | #include "talk/media/webrtc/webrtcvideochannelfactory.h" |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 36 | #include "talk/media/webrtc/webrtcvideoengine2.h" |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 37 | #include "talk/media/webrtc/webrtcvideoengine2_unittest.h" |
pbos@webrtc.org | 3bf3d23 | 2014-10-31 12:59:34 +0000 | [diff] [blame] | 38 | #include "talk/media/webrtc/webrtcvoiceengine.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 39 | #include "webrtc/base/gunit.h" |
| 40 | #include "webrtc/base/stringutils.h" |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 41 | #include "webrtc/video_encoder.h" |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 42 | |
| 43 | namespace { |
buildbot@webrtc.org | a853077 | 2014-12-10 09:01:18 +0000 | [diff] [blame] | 44 | static const int kDefaultQpMax = 56; |
| 45 | static const int kDefaultFramerate = 30; |
| 46 | static const int kMinBitrateBps = 30000; |
| 47 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 48 | static const cricket::VideoCodec kVp8Codec720p(100, "VP8", 1280, 720, 30, 0); |
| 49 | static const cricket::VideoCodec kVp8Codec360p(100, "VP8", 640, 360, 30, 0); |
buildbot@webrtc.org | a853077 | 2014-12-10 09:01:18 +0000 | [diff] [blame] | 50 | static const cricket::VideoCodec kVp8Codec270p(100, "VP8", 480, 270, 30, 0); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 51 | |
| 52 | static const cricket::VideoCodec kVp8Codec(100, "VP8", 640, 400, 30, 0); |
| 53 | static const cricket::VideoCodec kVp9Codec(101, "VP9", 640, 400, 30, 0); |
pbos@webrtc.org | 7fe1e03 | 2014-10-14 04:25:33 +0000 | [diff] [blame] | 54 | static const cricket::VideoCodec kH264Codec(102, "H264", 640, 400, 30, 0); |
| 55 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 56 | static const cricket::VideoCodec kRedCodec(116, "red", 0, 0, 0, 0); |
| 57 | static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec", 0, 0, 0, 0); |
| 58 | |
| 59 | static const uint32 kSsrcs1[] = {1}; |
buildbot@webrtc.org | a853077 | 2014-12-10 09:01:18 +0000 | [diff] [blame] | 60 | static const uint32 kSsrcs3[] = {1, 2, 3}; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 61 | static const uint32 kRtxSsrcs1[] = {4}; |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 62 | static const char kUnsupportedExtensionName[] = |
| 63 | "urn:ietf:params:rtp-hdrext:unsupported"; |
pbos@webrtc.org | f99c2f2 | 2014-06-13 12:27:38 +0000 | [diff] [blame] | 64 | |
| 65 | void VerifyCodecHasDefaultFeedbackParams(const cricket::VideoCodec& codec) { |
| 66 | EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( |
| 67 | cricket::kRtcpFbParamNack, cricket::kParamValueEmpty))); |
| 68 | EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( |
| 69 | cricket::kRtcpFbParamNack, cricket::kRtcpFbNackParamPli))); |
| 70 | EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( |
| 71 | cricket::kRtcpFbParamRemb, cricket::kParamValueEmpty))); |
| 72 | EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( |
| 73 | cricket::kRtcpFbParamCcm, cricket::kRtcpFbCcmParamFir))); |
| 74 | } |
| 75 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 76 | } // namespace |
| 77 | |
| 78 | namespace cricket { |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 79 | FakeVideoSendStream::FakeVideoSendStream( |
| 80 | const webrtc::VideoSendStream::Config& config, |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 81 | const webrtc::VideoEncoderConfig& encoder_config) |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 82 | : sending_(false), |
| 83 | config_(config), |
| 84 | codec_settings_set_(false), |
| 85 | num_swapped_frames_(0) { |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 86 | assert(config.encoder_settings.encoder != NULL); |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 87 | ReconfigureVideoEncoder(encoder_config); |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 88 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 89 | |
pbos@webrtc.org | efc82c2 | 2014-10-27 13:58:00 +0000 | [diff] [blame] | 90 | webrtc::VideoSendStream::Config FakeVideoSendStream::GetConfig() const { |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 91 | return config_; |
| 92 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 93 | |
pbos@webrtc.org | efc82c2 | 2014-10-27 13:58:00 +0000 | [diff] [blame] | 94 | webrtc::VideoEncoderConfig FakeVideoSendStream::GetEncoderConfig() const { |
| 95 | return encoder_config_; |
| 96 | } |
| 97 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 98 | std::vector<webrtc::VideoStream> FakeVideoSendStream::GetVideoStreams() { |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 99 | return encoder_config_.streams; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 100 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 101 | |
pbos@webrtc.org | 85f4294 | 2014-07-22 09:14:58 +0000 | [diff] [blame] | 102 | bool FakeVideoSendStream::IsSending() const { |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 103 | return sending_; |
| 104 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 105 | |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 106 | bool FakeVideoSendStream::GetVp8Settings( |
| 107 | webrtc::VideoCodecVP8* settings) const { |
| 108 | if (!codec_settings_set_) { |
| 109 | return false; |
| 110 | } |
| 111 | |
| 112 | *settings = vp8_settings_; |
| 113 | return true; |
| 114 | } |
| 115 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 116 | int FakeVideoSendStream::GetNumberOfSwappedFrames() const { |
| 117 | return num_swapped_frames_; |
| 118 | } |
| 119 | |
| 120 | int FakeVideoSendStream::GetLastWidth() const { |
| 121 | return last_frame_.width(); |
| 122 | } |
| 123 | |
| 124 | int FakeVideoSendStream::GetLastHeight() const { |
| 125 | return last_frame_.height(); |
| 126 | } |
| 127 | |
| 128 | void FakeVideoSendStream::SwapFrame(webrtc::I420VideoFrame* frame) { |
| 129 | ++num_swapped_frames_; |
| 130 | last_frame_.SwapFrame(frame); |
| 131 | } |
pbos@webrtc.org | 273a414 | 2014-12-01 15:23:21 +0000 | [diff] [blame] | 132 | |
| 133 | void FakeVideoSendStream::SetStats( |
| 134 | const webrtc::VideoSendStream::Stats& stats) { |
| 135 | stats_ = stats; |
| 136 | } |
| 137 | |
| 138 | webrtc::VideoSendStream::Stats FakeVideoSendStream::GetStats() { |
| 139 | return stats_; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 140 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 141 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 142 | bool FakeVideoSendStream::ReconfigureVideoEncoder( |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 143 | const webrtc::VideoEncoderConfig& config) { |
| 144 | encoder_config_ = config; |
| 145 | if (config.encoder_specific_settings != NULL) { |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 146 | assert(config_.encoder_settings.payload_name == "VP8"); |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 147 | vp8_settings_ = *reinterpret_cast<const webrtc::VideoCodecVP8*>( |
| 148 | config.encoder_specific_settings); |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 149 | } |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 150 | codec_settings_set_ = config.encoder_specific_settings != NULL; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 151 | return true; |
| 152 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 153 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 154 | webrtc::VideoSendStreamInput* FakeVideoSendStream::Input() { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 155 | return this; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 156 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 157 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 158 | void FakeVideoSendStream::Start() { |
| 159 | sending_ = true; |
| 160 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 161 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 162 | void FakeVideoSendStream::Stop() { |
| 163 | sending_ = false; |
| 164 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 165 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 166 | FakeVideoReceiveStream::FakeVideoReceiveStream( |
| 167 | const webrtc::VideoReceiveStream::Config& config) |
| 168 | : config_(config), receiving_(false) { |
| 169 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 170 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 171 | webrtc::VideoReceiveStream::Config FakeVideoReceiveStream::GetConfig() { |
| 172 | return config_; |
| 173 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 174 | |
pbos@webrtc.org | 85f4294 | 2014-07-22 09:14:58 +0000 | [diff] [blame] | 175 | bool FakeVideoReceiveStream::IsReceiving() const { |
| 176 | return receiving_; |
| 177 | } |
| 178 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 179 | webrtc::VideoReceiveStream::Stats FakeVideoReceiveStream::GetStats() const { |
| 180 | return webrtc::VideoReceiveStream::Stats(); |
| 181 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 182 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 183 | void FakeVideoReceiveStream::Start() { |
| 184 | receiving_ = true; |
| 185 | } |
pbos@webrtc.org | 85f4294 | 2014-07-22 09:14:58 +0000 | [diff] [blame] | 186 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 187 | void FakeVideoReceiveStream::Stop() { |
| 188 | receiving_ = false; |
| 189 | } |
pbos@webrtc.org | 85f4294 | 2014-07-22 09:14:58 +0000 | [diff] [blame] | 190 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 191 | FakeCall::FakeCall(const webrtc::Call::Config& config) |
| 192 | : config_(config), network_state_(kNetworkUp) { |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 193 | SetVideoCodecs(GetDefaultVideoCodecs()); |
| 194 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 195 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 196 | FakeCall::~FakeCall() { |
| 197 | EXPECT_EQ(0u, video_send_streams_.size()); |
| 198 | EXPECT_EQ(0u, video_receive_streams_.size()); |
| 199 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 200 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 201 | void FakeCall::SetVideoCodecs(const std::vector<webrtc::VideoCodec> codecs) { |
| 202 | codecs_ = codecs; |
| 203 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 204 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 205 | webrtc::Call::Config FakeCall::GetConfig() const { |
| 206 | return config_; |
| 207 | } |
| 208 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 209 | std::vector<FakeVideoSendStream*> FakeCall::GetVideoSendStreams() { |
| 210 | return video_send_streams_; |
| 211 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 212 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 213 | std::vector<FakeVideoReceiveStream*> FakeCall::GetVideoReceiveStreams() { |
| 214 | return video_receive_streams_; |
| 215 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 216 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 217 | webrtc::VideoCodec FakeCall::GetEmptyVideoCodec() { |
| 218 | webrtc::VideoCodec codec; |
| 219 | codec.minBitrate = 300; |
| 220 | codec.startBitrate = 800; |
| 221 | codec.maxBitrate = 1500; |
| 222 | codec.maxFramerate = 10; |
| 223 | codec.width = 640; |
| 224 | codec.height = 480; |
| 225 | codec.qpMax = 56; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 226 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 227 | return codec; |
| 228 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 229 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 230 | webrtc::VideoCodec FakeCall::GetVideoCodecVp8() { |
| 231 | webrtc::VideoCodec vp8_codec = GetEmptyVideoCodec(); |
| 232 | vp8_codec.codecType = webrtc::kVideoCodecVP8; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 233 | rtc::strcpyn( |
| 234 | vp8_codec.plName, ARRAY_SIZE(vp8_codec.plName), kVp8Codec.name.c_str()); |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 235 | vp8_codec.plType = kVp8Codec.id; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 236 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 237 | return vp8_codec; |
| 238 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 239 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 240 | webrtc::VideoCodec FakeCall::GetVideoCodecVp9() { |
| 241 | webrtc::VideoCodec vp9_codec = GetEmptyVideoCodec(); |
| 242 | // TODO(pbos): Add a correct codecType when webrtc has one. |
| 243 | vp9_codec.codecType = webrtc::kVideoCodecVP8; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 244 | rtc::strcpyn( |
| 245 | vp9_codec.plName, ARRAY_SIZE(vp9_codec.plName), kVp9Codec.name.c_str()); |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 246 | vp9_codec.plType = kVp9Codec.id; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 247 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 248 | return vp9_codec; |
| 249 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 250 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 251 | std::vector<webrtc::VideoCodec> FakeCall::GetDefaultVideoCodecs() { |
| 252 | std::vector<webrtc::VideoCodec> codecs; |
| 253 | codecs.push_back(GetVideoCodecVp8()); |
| 254 | // codecs.push_back(GetVideoCodecVp9()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 255 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 256 | return codecs; |
| 257 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 258 | |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 259 | webrtc::Call::NetworkState FakeCall::GetNetworkState() const { |
| 260 | return network_state_; |
| 261 | } |
| 262 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 263 | webrtc::VideoSendStream* FakeCall::CreateVideoSendStream( |
| 264 | const webrtc::VideoSendStream::Config& config, |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 265 | const webrtc::VideoEncoderConfig& encoder_config) { |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 266 | FakeVideoSendStream* fake_stream = |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 267 | new FakeVideoSendStream(config, encoder_config); |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 268 | video_send_streams_.push_back(fake_stream); |
| 269 | return fake_stream; |
| 270 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 271 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 272 | void FakeCall::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { |
| 273 | FakeVideoSendStream* fake_stream = |
| 274 | static_cast<FakeVideoSendStream*>(send_stream); |
| 275 | for (size_t i = 0; i < video_send_streams_.size(); ++i) { |
| 276 | if (video_send_streams_[i] == fake_stream) { |
| 277 | delete video_send_streams_[i]; |
| 278 | video_send_streams_.erase(video_send_streams_.begin() + i); |
| 279 | return; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 280 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 281 | } |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 282 | ADD_FAILURE() << "DestroyVideoSendStream called with unknown paramter."; |
| 283 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 284 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 285 | webrtc::VideoReceiveStream* FakeCall::CreateVideoReceiveStream( |
| 286 | const webrtc::VideoReceiveStream::Config& config) { |
| 287 | video_receive_streams_.push_back(new FakeVideoReceiveStream(config)); |
| 288 | return video_receive_streams_[video_receive_streams_.size() - 1]; |
| 289 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 290 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 291 | void FakeCall::DestroyVideoReceiveStream( |
| 292 | webrtc::VideoReceiveStream* receive_stream) { |
| 293 | FakeVideoReceiveStream* fake_stream = |
| 294 | static_cast<FakeVideoReceiveStream*>(receive_stream); |
| 295 | for (size_t i = 0; i < video_receive_streams_.size(); ++i) { |
| 296 | if (video_receive_streams_[i] == fake_stream) { |
| 297 | delete video_receive_streams_[i]; |
| 298 | video_receive_streams_.erase(video_receive_streams_.begin() + i); |
| 299 | return; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 300 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 301 | } |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 302 | ADD_FAILURE() << "DestroyVideoReceiveStream called with unknown paramter."; |
| 303 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 304 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 305 | webrtc::PacketReceiver* FakeCall::Receiver() { |
| 306 | // TODO(pbos): Fix this. |
| 307 | return NULL; |
| 308 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 309 | |
pbos@webrtc.org | 2b19f06 | 2014-12-11 13:26:09 +0000 | [diff] [blame^] | 310 | void FakeCall::SetStats(const webrtc::Call::Stats& stats) { |
| 311 | stats_ = stats; |
| 312 | } |
| 313 | |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame] | 314 | webrtc::Call::Stats FakeCall::GetStats() const { |
pbos@webrtc.org | 2b19f06 | 2014-12-11 13:26:09 +0000 | [diff] [blame^] | 315 | return stats_; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 316 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 317 | |
pbos@webrtc.org | 0087318 | 2014-11-25 14:03:34 +0000 | [diff] [blame] | 318 | void FakeCall::SetBitrateConfig( |
| 319 | const webrtc::Call::Config::BitrateConfig& bitrate_config) { |
| 320 | config_.stream_bitrates = bitrate_config; |
| 321 | } |
| 322 | |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 323 | void FakeCall::SignalNetworkState(webrtc::Call::NetworkState state) { |
| 324 | network_state_ = state; |
| 325 | } |
| 326 | |
pbos@webrtc.org | 7fe1e03 | 2014-10-14 04:25:33 +0000 | [diff] [blame] | 327 | class WebRtcVideoEngine2Test : public ::testing::Test { |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 328 | public: |
pbos@webrtc.org | b648b9d | 2014-08-26 11:08:06 +0000 | [diff] [blame] | 329 | WebRtcVideoEngine2Test() { |
pbos@webrtc.org | 9fbb717 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 330 | std::vector<VideoCodec> engine_codecs = engine_.codecs(); |
| 331 | assert(!engine_codecs.empty()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 332 | bool codec_set = false; |
pbos@webrtc.org | 9fbb717 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 333 | for (size_t i = 0; i < engine_codecs.size(); ++i) { |
| 334 | if (engine_codecs[i].name == "red") { |
| 335 | default_red_codec_ = engine_codecs[i]; |
| 336 | } else if (engine_codecs[i].name == "ulpfec") { |
| 337 | default_ulpfec_codec_ = engine_codecs[i]; |
| 338 | } else if (engine_codecs[i].name == "rtx") { |
| 339 | default_rtx_codec_ = engine_codecs[i]; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 340 | } else if (!codec_set) { |
pbos@webrtc.org | 9fbb717 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 341 | default_codec_ = engine_codecs[i]; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 342 | codec_set = true; |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | assert(codec_set); |
| 347 | } |
| 348 | |
| 349 | protected: |
pbos@webrtc.org | 3bf3d23 | 2014-10-31 12:59:34 +0000 | [diff] [blame] | 350 | class FakeCallFactory : public WebRtcCallFactory { |
| 351 | public: |
| 352 | FakeCallFactory() : fake_call_(NULL) {} |
| 353 | FakeCall* GetCall() { return fake_call_; } |
| 354 | |
| 355 | private: |
| 356 | virtual webrtc::Call* CreateCall( |
| 357 | const webrtc::Call::Config& config) OVERRIDE { |
| 358 | assert(fake_call_ == NULL); |
| 359 | fake_call_ = new FakeCall(config); |
| 360 | return fake_call_; |
| 361 | } |
| 362 | |
| 363 | FakeCall* fake_call_; |
| 364 | }; |
| 365 | |
pbos@webrtc.org | 7fe1e03 | 2014-10-14 04:25:33 +0000 | [diff] [blame] | 366 | VideoMediaChannel* SetUpForExternalEncoderFactory( |
| 367 | cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 368 | const std::vector<VideoCodec>& codecs); |
pbos@webrtc.org | fa553ef | 2014-10-20 11:07:07 +0000 | [diff] [blame] | 369 | |
pbos@webrtc.org | 96a9325 | 2014-11-03 14:46:44 +0000 | [diff] [blame] | 370 | VideoMediaChannel* SetUpForExternalDecoderFactory( |
| 371 | cricket::WebRtcVideoDecoderFactory* decoder_factory, |
| 372 | const std::vector<VideoCodec>& codecs); |
| 373 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 374 | WebRtcVideoEngine2 engine_; |
| 375 | VideoCodec default_codec_; |
| 376 | VideoCodec default_red_codec_; |
| 377 | VideoCodec default_ulpfec_codec_; |
| 378 | VideoCodec default_rtx_codec_; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 379 | }; |
| 380 | |
pbos@webrtc.org | 3bf3d23 | 2014-10-31 12:59:34 +0000 | [diff] [blame] | 381 | TEST_F(WebRtcVideoEngine2Test, ConfiguresAvSyncForFirstReceiveChannel) { |
| 382 | FakeCallFactory call_factory; |
| 383 | engine_.SetCallFactory(&call_factory); |
| 384 | |
| 385 | WebRtcVoiceEngine voice_engine; |
| 386 | engine_.SetVoiceEngine(&voice_engine); |
| 387 | voice_engine.Init(rtc::Thread::Current()); |
| 388 | engine_.Init(rtc::Thread::Current()); |
| 389 | |
| 390 | rtc::scoped_ptr<VoiceMediaChannel> voice_channel( |
| 391 | voice_engine.CreateChannel()); |
| 392 | ASSERT_TRUE(voice_channel.get() != NULL); |
| 393 | WebRtcVoiceMediaChannel* webrtc_voice_channel = |
| 394 | static_cast<WebRtcVoiceMediaChannel*>(voice_channel.get()); |
| 395 | ASSERT_NE(webrtc_voice_channel->voe_channel(), -1); |
| 396 | rtc::scoped_ptr<VideoMediaChannel> channel( |
| 397 | engine_.CreateChannel(cricket::VideoOptions(), voice_channel.get())); |
| 398 | |
| 399 | FakeCall* fake_call = call_factory.GetCall(); |
| 400 | ASSERT_TRUE(fake_call != NULL); |
| 401 | |
| 402 | webrtc::Call::Config call_config = fake_call->GetConfig(); |
| 403 | |
| 404 | ASSERT_TRUE(voice_engine.voe()->engine() != NULL); |
| 405 | ASSERT_EQ(voice_engine.voe()->engine(), call_config.voice_engine); |
| 406 | |
| 407 | EXPECT_TRUE(channel->AddRecvStream(StreamParams::CreateLegacy(kSsrc))); |
| 408 | EXPECT_TRUE(channel->AddRecvStream(StreamParams::CreateLegacy(kSsrc + 1))); |
| 409 | std::vector<FakeVideoReceiveStream*> receive_streams = |
| 410 | fake_call->GetVideoReceiveStreams(); |
| 411 | |
| 412 | ASSERT_EQ(2u, receive_streams.size()); |
| 413 | EXPECT_EQ(webrtc_voice_channel->voe_channel(), |
| 414 | receive_streams[0]->GetConfig().audio_channel_id); |
| 415 | EXPECT_EQ(-1, receive_streams[1]->GetConfig().audio_channel_id) |
| 416 | << "AV sync should only be set up for the first receive channel."; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 417 | } |
| 418 | |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 419 | TEST_F(WebRtcVideoEngine2Test, FindCodec) { |
| 420 | const std::vector<cricket::VideoCodec>& c = engine_.codecs(); |
| 421 | EXPECT_EQ(4U, c.size()); |
| 422 | |
| 423 | cricket::VideoCodec vp8(104, "VP8", 320, 200, 30, 0); |
| 424 | EXPECT_TRUE(engine_.FindCodec(vp8)); |
| 425 | |
| 426 | cricket::VideoCodec vp8_ci(104, "vp8", 320, 200, 30, 0); |
| 427 | EXPECT_TRUE(engine_.FindCodec(vp8)); |
| 428 | |
| 429 | cricket::VideoCodec vp8_diff_fr_diff_pref(104, "VP8", 320, 200, 50, 50); |
| 430 | EXPECT_TRUE(engine_.FindCodec(vp8_diff_fr_diff_pref)); |
| 431 | |
| 432 | cricket::VideoCodec vp8_diff_id(95, "VP8", 320, 200, 30, 0); |
| 433 | EXPECT_FALSE(engine_.FindCodec(vp8_diff_id)); |
| 434 | vp8_diff_id.id = 97; |
| 435 | EXPECT_TRUE(engine_.FindCodec(vp8_diff_id)); |
| 436 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 437 | // FindCodec ignores the codec size. |
| 438 | // Test that FindCodec can accept uncommon codec size. |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 439 | cricket::VideoCodec vp8_diff_res(104, "VP8", 320, 111, 30, 0); |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 440 | EXPECT_TRUE(engine_.FindCodec(vp8_diff_res)); |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 441 | |
| 442 | // PeerConnection doesn't negotiate the resolution at this point. |
| 443 | // Test that FindCodec can handle the case when width/height is 0. |
| 444 | cricket::VideoCodec vp8_zero_res(104, "VP8", 0, 0, 30, 0); |
| 445 | EXPECT_TRUE(engine_.FindCodec(vp8_zero_res)); |
| 446 | |
| 447 | cricket::VideoCodec red(101, "RED", 0, 0, 30, 0); |
| 448 | EXPECT_TRUE(engine_.FindCodec(red)); |
| 449 | |
| 450 | cricket::VideoCodec red_ci(101, "red", 0, 0, 30, 0); |
| 451 | EXPECT_TRUE(engine_.FindCodec(red)); |
| 452 | |
| 453 | cricket::VideoCodec fec(102, "ULPFEC", 0, 0, 30, 0); |
| 454 | EXPECT_TRUE(engine_.FindCodec(fec)); |
| 455 | |
| 456 | cricket::VideoCodec fec_ci(102, "ulpfec", 0, 0, 30, 0); |
| 457 | EXPECT_TRUE(engine_.FindCodec(fec)); |
| 458 | |
| 459 | cricket::VideoCodec rtx(96, "rtx", 0, 0, 30, 0); |
| 460 | EXPECT_TRUE(engine_.FindCodec(rtx)); |
| 461 | } |
| 462 | |
| 463 | TEST_F(WebRtcVideoEngine2Test, DefaultRtxCodecHasAssociatedPayloadTypeSet) { |
| 464 | std::vector<VideoCodec> engine_codecs = engine_.codecs(); |
| 465 | for (size_t i = 0; i < engine_codecs.size(); ++i) { |
| 466 | if (engine_codecs[i].name != kRtxCodecName) |
| 467 | continue; |
| 468 | int associated_payload_type; |
| 469 | EXPECT_TRUE(engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType, |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 470 | &associated_payload_type)); |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 471 | EXPECT_EQ(default_codec_.id, associated_payload_type); |
| 472 | return; |
| 473 | } |
| 474 | FAIL() << "No RTX codec found among default codecs."; |
| 475 | } |
| 476 | |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 477 | TEST_F(WebRtcVideoEngine2Test, SupportsTimestampOffsetHeaderExtension) { |
| 478 | std::vector<RtpHeaderExtension> extensions = engine_.rtp_header_extensions(); |
| 479 | ASSERT_FALSE(extensions.empty()); |
| 480 | for (size_t i = 0; i < extensions.size(); ++i) { |
| 481 | if (extensions[i].uri == kRtpTimestampOffsetHeaderExtension) { |
| 482 | EXPECT_EQ(kRtpTimestampOffsetHeaderExtensionDefaultId, extensions[i].id); |
| 483 | return; |
| 484 | } |
| 485 | } |
| 486 | FAIL() << "Timestamp offset extension not in header-extension list."; |
| 487 | } |
| 488 | |
| 489 | TEST_F(WebRtcVideoEngine2Test, SupportsAbsoluteSenderTimeHeaderExtension) { |
| 490 | std::vector<RtpHeaderExtension> extensions = engine_.rtp_header_extensions(); |
| 491 | ASSERT_FALSE(extensions.empty()); |
| 492 | for (size_t i = 0; i < extensions.size(); ++i) { |
| 493 | if (extensions[i].uri == kRtpAbsoluteSenderTimeHeaderExtension) { |
| 494 | EXPECT_EQ(kRtpAbsoluteSenderTimeHeaderExtensionDefaultId, |
| 495 | extensions[i].id); |
| 496 | return; |
| 497 | } |
| 498 | } |
| 499 | FAIL() << "Absolute Sender Time extension not in header-extension list."; |
| 500 | } |
| 501 | |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 502 | TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) { |
pbos@webrtc.org | 7fe1e03 | 2014-10-14 04:25:33 +0000 | [diff] [blame] | 503 | engine_.Init(rtc::Thread::Current()); |
buildbot@webrtc.org | 1ecbe45 | 2014-10-14 20:29:28 +0000 | [diff] [blame] | 504 | rtc::scoped_ptr<VideoMediaChannel> channel( |
| 505 | engine_.CreateChannel(cricket::VideoOptions(), NULL)); |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 506 | |
| 507 | EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); |
| 508 | |
| 509 | EXPECT_FALSE(channel->SetSend(true)) |
| 510 | << "Channel should not start without codecs."; |
| 511 | EXPECT_TRUE(channel->SetSend(false)) |
| 512 | << "Channel should be stoppable even without set codecs."; |
| 513 | } |
| 514 | |
pbos@webrtc.org | c3d2bd2 | 2014-08-12 20:55:10 +0000 | [diff] [blame] | 515 | TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) { |
pbos@webrtc.org | 7fe1e03 | 2014-10-14 04:25:33 +0000 | [diff] [blame] | 516 | engine_.Init(rtc::Thread::Current()); |
buildbot@webrtc.org | 1ecbe45 | 2014-10-14 20:29:28 +0000 | [diff] [blame] | 517 | rtc::scoped_ptr<VideoMediaChannel> channel( |
| 518 | engine_.CreateChannel(cricket::VideoOptions(), NULL)); |
pbos@webrtc.org | c3d2bd2 | 2014-08-12 20:55:10 +0000 | [diff] [blame] | 519 | EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); |
| 520 | VideoMediaInfo info; |
| 521 | channel->GetStats(&info); |
| 522 | } |
| 523 | |
pbos@webrtc.org | 7fe1e03 | 2014-10-14 04:25:33 +0000 | [diff] [blame] | 524 | TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) { |
| 525 | cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
| 526 | encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
| 527 | std::vector<cricket::VideoCodec> codecs; |
| 528 | codecs.push_back(kVp8Codec); |
| 529 | |
| 530 | rtc::scoped_ptr<VideoMediaChannel> channel( |
| 531 | SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
| 532 | |
| 533 | EXPECT_TRUE( |
| 534 | channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
| 535 | ASSERT_EQ(1u, encoder_factory.encoders().size()); |
| 536 | EXPECT_TRUE(channel->SetSend(true)); |
| 537 | |
| 538 | cricket::FakeVideoCapturer capturer; |
| 539 | EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); |
| 540 | EXPECT_EQ(cricket::CS_RUNNING, |
| 541 | capturer.Start(capturer.GetSupportedFormats()->front())); |
| 542 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 543 | |
| 544 | EXPECT_TRUE_WAIT(encoder_factory.encoders()[0]->GetNumEncodedFrames() > 0, |
| 545 | kTimeout); |
| 546 | |
| 547 | // Setting codecs of the same type should not reallocate the encoder. |
| 548 | EXPECT_TRUE(channel->SetSendCodecs(codecs)); |
| 549 | EXPECT_EQ(1, encoder_factory.GetNumCreatedEncoders()); |
| 550 | |
| 551 | // Remove stream previously added to free the external encoder instance. |
| 552 | EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); |
| 553 | EXPECT_EQ(0u, encoder_factory.encoders().size()); |
| 554 | } |
| 555 | |
| 556 | VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( |
| 557 | cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 558 | const std::vector<VideoCodec>& codecs) { |
| 559 | engine_.SetExternalEncoderFactory(encoder_factory); |
| 560 | engine_.Init(rtc::Thread::Current()); |
| 561 | |
buildbot@webrtc.org | 1ecbe45 | 2014-10-14 20:29:28 +0000 | [diff] [blame] | 562 | VideoMediaChannel* channel = |
| 563 | engine_.CreateChannel(cricket::VideoOptions(), NULL); |
pbos@webrtc.org | 7fe1e03 | 2014-10-14 04:25:33 +0000 | [diff] [blame] | 564 | EXPECT_TRUE(channel->SetSendCodecs(codecs)); |
| 565 | |
| 566 | return channel; |
| 567 | } |
| 568 | |
pbos@webrtc.org | 96a9325 | 2014-11-03 14:46:44 +0000 | [diff] [blame] | 569 | VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalDecoderFactory( |
| 570 | cricket::WebRtcVideoDecoderFactory* decoder_factory, |
| 571 | const std::vector<VideoCodec>& codecs) { |
| 572 | engine_.SetExternalDecoderFactory(decoder_factory); |
| 573 | engine_.Init(rtc::Thread::Current()); |
| 574 | |
| 575 | VideoMediaChannel* channel = |
| 576 | engine_.CreateChannel(cricket::VideoOptions(), NULL); |
| 577 | EXPECT_TRUE(channel->SetRecvCodecs(codecs)); |
| 578 | |
| 579 | return channel; |
| 580 | } |
| 581 | |
pbos@webrtc.org | 7fe1e03 | 2014-10-14 04:25:33 +0000 | [diff] [blame] | 582 | TEST_F(WebRtcVideoEngine2Test, ChannelWithExternalH264CanChangeToInternalVp8) { |
| 583 | cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
| 584 | encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); |
| 585 | std::vector<cricket::VideoCodec> codecs; |
| 586 | codecs.push_back(kH264Codec); |
| 587 | |
| 588 | rtc::scoped_ptr<VideoMediaChannel> channel( |
| 589 | SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
| 590 | |
| 591 | EXPECT_TRUE( |
| 592 | channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
| 593 | ASSERT_EQ(1u, encoder_factory.encoders().size()); |
| 594 | |
| 595 | codecs.clear(); |
| 596 | codecs.push_back(kVp8Codec); |
| 597 | EXPECT_TRUE(channel->SetSendCodecs(codecs)); |
| 598 | |
| 599 | ASSERT_EQ(0u, encoder_factory.encoders().size()); |
| 600 | } |
| 601 | |
| 602 | TEST_F(WebRtcVideoEngine2Test, |
| 603 | DontUseExternalEncoderFactoryForUnsupportedCodecs) { |
| 604 | cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
| 605 | encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); |
| 606 | std::vector<cricket::VideoCodec> codecs; |
| 607 | codecs.push_back(kVp8Codec); |
| 608 | |
| 609 | rtc::scoped_ptr<VideoMediaChannel> channel( |
| 610 | SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
| 611 | |
| 612 | EXPECT_TRUE( |
| 613 | channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
| 614 | ASSERT_EQ(0u, encoder_factory.encoders().size()); |
| 615 | } |
| 616 | |
| 617 | // Test external codec with be added to the end of the supported codec list. |
| 618 | TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecs) { |
| 619 | cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
| 620 | encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); |
| 621 | engine_.SetExternalEncoderFactory(&encoder_factory); |
| 622 | |
| 623 | engine_.Init(rtc::Thread::Current()); |
| 624 | |
| 625 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 626 | ASSERT_GE(codecs.size(), 2u); |
| 627 | cricket::VideoCodec internal_codec = codecs.front(); |
| 628 | cricket::VideoCodec external_codec = codecs.back(); |
| 629 | |
| 630 | // The external codec will appear at last. |
| 631 | EXPECT_EQ("VP8", internal_codec.name); |
| 632 | EXPECT_EQ("H264", external_codec.name); |
| 633 | } |
| 634 | |
pbos@webrtc.org | 96a9325 | 2014-11-03 14:46:44 +0000 | [diff] [blame] | 635 | TEST_F(WebRtcVideoEngine2Test, RegisterExternalDecodersIfSupported) { |
| 636 | cricket::FakeWebRtcVideoDecoderFactory decoder_factory; |
| 637 | decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); |
| 638 | std::vector<cricket::VideoCodec> codecs; |
| 639 | codecs.push_back(kVp8Codec); |
| 640 | |
| 641 | rtc::scoped_ptr<VideoMediaChannel> channel( |
| 642 | SetUpForExternalDecoderFactory(&decoder_factory, codecs)); |
| 643 | |
| 644 | EXPECT_TRUE( |
| 645 | channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
| 646 | ASSERT_EQ(1u, decoder_factory.decoders().size()); |
| 647 | |
| 648 | // Setting codecs of the same type should not reallocate the decoder. |
| 649 | EXPECT_TRUE(channel->SetRecvCodecs(codecs)); |
| 650 | EXPECT_EQ(1, decoder_factory.GetNumCreatedDecoders()); |
| 651 | |
| 652 | // Remove stream previously added to free the external decoder instance. |
| 653 | EXPECT_TRUE(channel->RemoveRecvStream(kSsrc)); |
| 654 | EXPECT_EQ(0u, decoder_factory.decoders().size()); |
| 655 | } |
| 656 | |
| 657 | // Verifies that we can set up decoders that are not internally supported. |
| 658 | TEST_F(WebRtcVideoEngine2Test, RegisterExternalH264DecoderIfSupported) { |
| 659 | // TODO(pbos): Do not assume that encoder/decoder support is symmetric. We |
| 660 | // can't even query the WebRtcVideoDecoderFactory for supported codecs. |
| 661 | // For now we add a FakeWebRtcVideoEncoderFactory to add H264 to supported |
| 662 | // codecs. |
| 663 | cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
| 664 | encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); |
| 665 | engine_.SetExternalEncoderFactory(&encoder_factory); |
| 666 | cricket::FakeWebRtcVideoDecoderFactory decoder_factory; |
| 667 | decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264); |
| 668 | std::vector<cricket::VideoCodec> codecs; |
| 669 | codecs.push_back(kH264Codec); |
| 670 | |
| 671 | rtc::scoped_ptr<VideoMediaChannel> channel( |
| 672 | SetUpForExternalDecoderFactory(&decoder_factory, codecs)); |
| 673 | |
| 674 | EXPECT_TRUE( |
| 675 | channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
| 676 | ASSERT_EQ(1u, decoder_factory.decoders().size()); |
| 677 | } |
| 678 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 679 | class WebRtcVideoEngine2BaseTest |
| 680 | : public VideoEngineTest<cricket::WebRtcVideoEngine2> { |
| 681 | protected: |
| 682 | typedef VideoEngineTest<cricket::WebRtcVideoEngine2> Base; |
| 683 | }; |
| 684 | |
| 685 | #define WEBRTC_ENGINE_BASE_TEST(test) \ |
| 686 | TEST_F(WebRtcVideoEngine2BaseTest, test) { Base::test##Body(); } |
| 687 | |
| 688 | WEBRTC_ENGINE_BASE_TEST(ConstrainNewCodec2); |
| 689 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 690 | class WebRtcVideoChannel2BaseTest |
| 691 | : public VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> { |
| 692 | protected: |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 693 | typedef VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> Base; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 694 | |
| 695 | virtual cricket::VideoCodec DefaultCodec() OVERRIDE { return kVp8Codec; } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 696 | }; |
| 697 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 698 | #define WEBRTC_BASE_TEST(test) \ |
| 699 | TEST_F(WebRtcVideoChannel2BaseTest, test) { Base::test(); } |
| 700 | |
| 701 | #define WEBRTC_DISABLED_BASE_TEST(test) \ |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 702 | TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_##test) { Base::test(); } |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 703 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 704 | // TODO(pbos): Fix WebRtcVideoEngine2BaseTest, where we want CheckCoInitialize. |
| 705 | #if 0 |
| 706 | // TODO(juberti): Figure out why ViE is munging the COM refcount. |
| 707 | #ifdef WIN32 |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 708 | WEBRTC_DISABLED_BASE_TEST(CheckCoInitialize) { |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 709 | Base::CheckCoInitialize(); |
| 710 | } |
| 711 | #endif |
| 712 | #endif |
| 713 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 714 | WEBRTC_BASE_TEST(SetSend); |
| 715 | WEBRTC_BASE_TEST(SetSendWithoutCodecs); |
| 716 | WEBRTC_BASE_TEST(SetSendSetsTransportBufferSizes); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 717 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 718 | WEBRTC_BASE_TEST(GetStats); |
| 719 | WEBRTC_BASE_TEST(GetStatsMultipleRecvStreams); |
| 720 | WEBRTC_BASE_TEST(GetStatsMultipleSendStreams); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 721 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 722 | WEBRTC_BASE_TEST(SetSendBandwidth); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 723 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 724 | WEBRTC_BASE_TEST(SetSendSsrc); |
| 725 | WEBRTC_BASE_TEST(SetSendSsrcAfterSetCodecs); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 726 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 727 | WEBRTC_BASE_TEST(SetRenderer); |
| 728 | WEBRTC_BASE_TEST(AddRemoveRecvStreams); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 729 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 730 | WEBRTC_DISABLED_BASE_TEST(AddRemoveRecvStreamAndRender); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 731 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 732 | WEBRTC_BASE_TEST(AddRemoveRecvStreamsNoConference); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 733 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 734 | WEBRTC_BASE_TEST(AddRemoveSendStreams); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 735 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 736 | WEBRTC_BASE_TEST(SimulateConference); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 737 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 738 | WEBRTC_BASE_TEST(AddRemoveCapturer); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 739 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 740 | WEBRTC_BASE_TEST(RemoveCapturerWithoutAdd); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 741 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 742 | WEBRTC_BASE_TEST(AddRemoveCapturerMultipleSources); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 743 | |
| 744 | // TODO(pbos): Figure out why this fails so often. |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 745 | WEBRTC_DISABLED_BASE_TEST(HighAspectHighHeightCapturer); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 746 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 747 | WEBRTC_BASE_TEST(RejectEmptyStreamParams); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 748 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 749 | WEBRTC_BASE_TEST(AdaptResolution16x10); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 750 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 751 | WEBRTC_BASE_TEST(AdaptResolution4x3); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 752 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 753 | // TODO(juberti): Restore this test once we support sending 0 fps. |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 754 | WEBRTC_DISABLED_BASE_TEST(AdaptDropAllFrames); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 755 | // TODO(juberti): Understand why we get decode errors on this test. |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 756 | WEBRTC_DISABLED_BASE_TEST(AdaptFramerate); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 757 | |
pbos@webrtc.org | c4175b9 | 2014-09-03 15:25:49 +0000 | [diff] [blame] | 758 | WEBRTC_BASE_TEST(SendsLowerResolutionOnSmallerFrames); |
| 759 | |
| 760 | WEBRTC_BASE_TEST(MuteStream); |
| 761 | |
| 762 | WEBRTC_BASE_TEST(MultipleSendStreams); |
| 763 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 764 | WEBRTC_BASE_TEST(SetSendStreamFormat0x0); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 765 | |
| 766 | // TODO(zhurunz): Fix the flakey test. |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 767 | WEBRTC_DISABLED_BASE_TEST(SetSendStreamFormat); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 768 | |
pbos@webrtc.org | 9359cb3 | 2014-07-23 15:44:48 +0000 | [diff] [blame] | 769 | TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Vga) { |
| 770 | SendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30, 0)); |
| 771 | } |
| 772 | |
| 773 | TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Qvga) { |
| 774 | SendAndReceive(cricket::VideoCodec(100, "VP8", 320, 200, 30, 0)); |
| 775 | } |
| 776 | |
| 777 | TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8SvcQqvga) { |
| 778 | SendAndReceive(cricket::VideoCodec(100, "VP8", 160, 100, 30, 0)); |
| 779 | } |
| 780 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 781 | TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsSendAndReceive) { |
| 782 | Base::TwoStreamsSendAndReceive(kVp8Codec); |
| 783 | } |
| 784 | |
| 785 | TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsReUseFirstStream) { |
| 786 | Base::TwoStreamsReUseFirstStream(kVp8Codec); |
| 787 | } |
| 788 | |
pbos@webrtc.org | 9359cb3 | 2014-07-23 15:44:48 +0000 | [diff] [blame] | 789 | WEBRTC_BASE_TEST(SendManyResizeOnce); |
| 790 | |
| 791 | // TODO(pbos): Enable and figure out why this fails (or should work). |
| 792 | TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_SendVp8HdAndReceiveAdaptedVp8Vga) { |
| 793 | EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL)); |
| 794 | EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); |
| 795 | channel_->UpdateAspectRatio(1280, 720); |
| 796 | video_capturer_.reset(new cricket::FakeVideoCapturer); |
| 797 | const std::vector<cricket::VideoFormat>* formats = |
| 798 | video_capturer_->GetSupportedFormats(); |
| 799 | cricket::VideoFormat capture_format_hd = (*formats)[0]; |
| 800 | EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(capture_format_hd)); |
| 801 | EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get())); |
| 802 | |
| 803 | // Capture format HD -> adapt (OnOutputFormatRequest VGA) -> VGA. |
pbos@webrtc.org | efc82c2 | 2014-10-27 13:58:00 +0000 | [diff] [blame] | 804 | cricket::VideoCodec codec = kVp8Codec720p; |
pbos@webrtc.org | 9359cb3 | 2014-07-23 15:44:48 +0000 | [diff] [blame] | 805 | EXPECT_TRUE(SetOneCodec(codec)); |
| 806 | codec.width /= 2; |
| 807 | codec.height /= 2; |
| 808 | EXPECT_TRUE(SetSend(true)); |
| 809 | EXPECT_TRUE(channel_->SetRender(true)); |
| 810 | EXPECT_EQ(0, renderer_.num_rendered_frames()); |
| 811 | EXPECT_TRUE(SendFrame()); |
| 812 | EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); |
| 813 | } |
| 814 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 815 | class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test, |
| 816 | public WebRtcCallFactory { |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 817 | public: |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 818 | WebRtcVideoChannel2Test() : fake_call_(NULL) {} |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 819 | virtual void SetUp() OVERRIDE { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 820 | engine_.SetCallFactory(this); |
pbos@webrtc.org | 7fe1e03 | 2014-10-14 04:25:33 +0000 | [diff] [blame] | 821 | engine_.Init(rtc::Thread::Current()); |
buildbot@webrtc.org | 1ecbe45 | 2014-10-14 20:29:28 +0000 | [diff] [blame] | 822 | channel_.reset(engine_.CreateChannel(cricket::VideoOptions(), NULL)); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 823 | ASSERT_TRUE(fake_call_ != NULL) << "Call not created through factory."; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 824 | last_ssrc_ = 123; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 825 | ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 826 | } |
| 827 | |
| 828 | protected: |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 829 | virtual webrtc::Call* CreateCall( |
| 830 | const webrtc::Call::Config& config) OVERRIDE { |
| 831 | assert(fake_call_ == NULL); |
| 832 | fake_call_ = new FakeCall(config); |
| 833 | return fake_call_; |
| 834 | } |
| 835 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 836 | FakeVideoSendStream* AddSendStream() { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 837 | return AddSendStream(StreamParams::CreateLegacy(++last_ssrc_)); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 838 | } |
| 839 | |
| 840 | FakeVideoSendStream* AddSendStream(const StreamParams& sp) { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 841 | size_t num_streams = fake_call_->GetVideoSendStreams().size(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 842 | EXPECT_TRUE(channel_->AddSendStream(sp)); |
| 843 | std::vector<FakeVideoSendStream*> streams = |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 844 | fake_call_->GetVideoSendStreams(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 845 | EXPECT_EQ(num_streams + 1, streams.size()); |
| 846 | return streams[streams.size() - 1]; |
| 847 | } |
| 848 | |
| 849 | std::vector<FakeVideoSendStream*> GetFakeSendStreams() { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 850 | return fake_call_->GetVideoSendStreams(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 851 | } |
| 852 | |
| 853 | FakeVideoReceiveStream* AddRecvStream() { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 854 | return AddRecvStream(StreamParams::CreateLegacy(++last_ssrc_)); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 855 | } |
| 856 | |
| 857 | FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 858 | size_t num_streams = fake_call_->GetVideoReceiveStreams().size(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 859 | EXPECT_TRUE(channel_->AddRecvStream(sp)); |
| 860 | std::vector<FakeVideoReceiveStream*> streams = |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 861 | fake_call_->GetVideoReceiveStreams(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 862 | EXPECT_EQ(num_streams + 1, streams.size()); |
| 863 | return streams[streams.size() - 1]; |
| 864 | } |
| 865 | |
pbos@webrtc.org | 0087318 | 2014-11-25 14:03:34 +0000 | [diff] [blame] | 866 | void SetSendCodecsShouldWorkForBitrates(const char* min_bitrate_kbps, |
| 867 | int expected_min_bitrate_bps, |
| 868 | const char* start_bitrate_kbps, |
| 869 | int expected_start_bitrate_bps, |
| 870 | const char* max_bitrate_kbps, |
| 871 | int expected_max_bitrate_bps) { |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 872 | std::vector<VideoCodec> codecs; |
| 873 | codecs.push_back(kVp8Codec); |
pbos@webrtc.org | 0087318 | 2014-11-25 14:03:34 +0000 | [diff] [blame] | 874 | codecs[0].params[kCodecParamMinBitrate] = min_bitrate_kbps; |
| 875 | codecs[0].params[kCodecParamStartBitrate] = start_bitrate_kbps; |
| 876 | codecs[0].params[kCodecParamMaxBitrate] = max_bitrate_kbps; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 877 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 878 | |
pbos@webrtc.org | 0087318 | 2014-11-25 14:03:34 +0000 | [diff] [blame] | 879 | EXPECT_EQ(expected_min_bitrate_bps, |
| 880 | fake_call_->GetConfig().stream_bitrates.min_bitrate_bps); |
| 881 | EXPECT_EQ(expected_start_bitrate_bps, |
| 882 | fake_call_->GetConfig().stream_bitrates.start_bitrate_bps); |
| 883 | EXPECT_EQ(expected_max_bitrate_bps, |
| 884 | fake_call_->GetConfig().stream_bitrates.max_bitrate_bps); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 885 | } |
| 886 | |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 887 | void TestSetSendRtpHeaderExtensions(const std::string& cricket_ext, |
| 888 | const std::string& webrtc_ext) { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 889 | FakeCall* call = fake_call_; |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 890 | // Enable extension. |
| 891 | const int id = 1; |
| 892 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 893 | extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id)); |
| 894 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 895 | |
| 896 | FakeVideoSendStream* send_stream = |
| 897 | AddSendStream(cricket::StreamParams::CreateLegacy(123)); |
| 898 | |
| 899 | // Verify the send extension id. |
| 900 | ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); |
| 901 | EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); |
| 902 | EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name); |
| 903 | // Verify call with same set of extensions returns true. |
| 904 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 905 | // Verify that SetSendRtpHeaderExtensions doesn't implicitly add them for |
| 906 | // receivers. |
| 907 | EXPECT_TRUE(AddRecvStream(cricket::StreamParams::CreateLegacy(123)) |
| 908 | ->GetConfig() |
| 909 | .rtp.extensions.empty()); |
| 910 | |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 911 | // Verify that existing RTP header extensions can be removed. |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 912 | std::vector<cricket::RtpHeaderExtension> empty_extensions; |
| 913 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions)); |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 914 | ASSERT_EQ(1u, call->GetVideoSendStreams().size()); |
| 915 | send_stream = call->GetVideoSendStreams()[0]; |
| 916 | EXPECT_TRUE(send_stream->GetConfig().rtp.extensions.empty()); |
| 917 | |
| 918 | // Verify that adding receive RTP header extensions adds them for existing |
| 919 | // streams. |
| 920 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 921 | send_stream = call->GetVideoSendStreams()[0]; |
| 922 | ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); |
| 923 | EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); |
| 924 | EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name); |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 925 | } |
| 926 | |
| 927 | void TestSetRecvRtpHeaderExtensions(const std::string& cricket_ext, |
| 928 | const std::string& webrtc_ext) { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 929 | FakeCall* call = fake_call_; |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 930 | // Enable extension. |
| 931 | const int id = 1; |
| 932 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 933 | extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id)); |
| 934 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 935 | |
| 936 | FakeVideoReceiveStream* recv_stream = |
| 937 | AddRecvStream(cricket::StreamParams::CreateLegacy(123)); |
| 938 | |
| 939 | // Verify the recv extension id. |
| 940 | ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); |
| 941 | EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); |
| 942 | EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); |
| 943 | // Verify call with same set of extensions returns true. |
| 944 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 945 | |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 946 | // Verify that SetRecvRtpHeaderExtensions doesn't implicitly add them for |
| 947 | // senders. |
| 948 | EXPECT_TRUE(AddSendStream(cricket::StreamParams::CreateLegacy(123)) |
| 949 | ->GetConfig() |
| 950 | .rtp.extensions.empty()); |
| 951 | |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 952 | // Verify that existing RTP header extensions can be removed. |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 953 | std::vector<cricket::RtpHeaderExtension> empty_extensions; |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 954 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(empty_extensions)); |
| 955 | ASSERT_EQ(1u, call->GetVideoReceiveStreams().size()); |
| 956 | recv_stream = call->GetVideoReceiveStreams()[0]; |
| 957 | EXPECT_TRUE(recv_stream->GetConfig().rtp.extensions.empty()); |
| 958 | |
| 959 | // Verify that adding receive RTP header extensions adds them for existing |
| 960 | // streams. |
| 961 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 962 | recv_stream = call->GetVideoReceiveStreams()[0]; |
| 963 | ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); |
| 964 | EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); |
| 965 | EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 966 | } |
| 967 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 968 | void TestCpuAdaptation(bool enable_overuse); |
| 969 | |
| 970 | FakeCall* fake_call_; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 971 | rtc::scoped_ptr<VideoMediaChannel> channel_; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 972 | uint32 last_ssrc_; |
| 973 | }; |
| 974 | |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 975 | TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) { |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 976 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 977 | EXPECT_TRUE(channel_->SetSend(true)); |
| 978 | cricket::VideoOptions options; |
| 979 | options.conference_mode.Set(true); |
| 980 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 981 | |
| 982 | // Send side. |
| 983 | const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
| 984 | const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
| 985 | FakeVideoSendStream* send_stream = AddSendStream( |
| 986 | cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| 987 | |
| 988 | ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size()); |
| 989 | for (size_t i = 0; i < rtx_ssrcs.size(); ++i) |
| 990 | EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]); |
| 991 | |
| 992 | // Receiver side. |
| 993 | FakeVideoReceiveStream* recv_stream = AddRecvStream( |
| 994 | cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| 995 | ASSERT_GT(recv_stream->GetConfig().rtp.rtx.size(), 0u) |
| 996 | << "No SSRCs for RTX configured by AddRecvStream."; |
| 997 | ASSERT_EQ(1u, recv_stream->GetConfig().rtp.rtx.size()) |
| 998 | << "This test only works with one receive codec. Please update the test."; |
| 999 | EXPECT_EQ(rtx_ssrcs[0], |
| 1000 | recv_stream->GetConfig().rtp.rtx.begin()->second.ssrc); |
| 1001 | // TODO(pbos): Make sure we set the RTX for correct payloads etc. |
| 1002 | } |
| 1003 | |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 1004 | TEST_F(WebRtcVideoChannel2Test, RecvStreamWithRtx) { |
| 1005 | // Setup one channel with an associated RTX stream. |
| 1006 | cricket::StreamParams params = |
| 1007 | cricket::StreamParams::CreateLegacy(kSsrcs1[0]); |
| 1008 | params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]); |
| 1009 | FakeVideoReceiveStream* recv_stream = AddRecvStream(params); |
| 1010 | ASSERT_EQ(1u, recv_stream->GetConfig().rtp.rtx.size()); |
| 1011 | EXPECT_EQ(kRtxSsrcs1[0], |
| 1012 | recv_stream->GetConfig().rtp.rtx.begin()->second.ssrc); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1013 | } |
| 1014 | |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 1015 | TEST_F(WebRtcVideoChannel2Test, RecvStreamNoRtx) { |
| 1016 | // Setup one channel without an associated RTX stream. |
| 1017 | cricket::StreamParams params = |
| 1018 | cricket::StreamParams::CreateLegacy(kSsrcs1[0]); |
| 1019 | FakeVideoReceiveStream* recv_stream = AddRecvStream(params); |
| 1020 | ASSERT_TRUE(recv_stream->GetConfig().rtp.rtx.empty()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1021 | } |
| 1022 | |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 1023 | TEST_F(WebRtcVideoChannel2Test, NoHeaderExtesionsByDefault) { |
| 1024 | FakeVideoSendStream* send_stream = |
| 1025 | AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0])); |
| 1026 | ASSERT_TRUE(send_stream->GetConfig().rtp.extensions.empty()); |
| 1027 | |
| 1028 | FakeVideoReceiveStream* recv_stream = |
| 1029 | AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0])); |
| 1030 | ASSERT_TRUE(recv_stream->GetConfig().rtp.extensions.empty()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1031 | } |
| 1032 | |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 1033 | // Test support for RTP timestamp offset header extension. |
| 1034 | TEST_F(WebRtcVideoChannel2Test, SendRtpTimestampOffsetHeaderExtensions) { |
| 1035 | TestSetSendRtpHeaderExtensions(kRtpTimestampOffsetHeaderExtension, |
| 1036 | webrtc::RtpExtension::kTOffset); |
| 1037 | } |
| 1038 | TEST_F(WebRtcVideoChannel2Test, RecvRtpTimestampOffsetHeaderExtensions) { |
| 1039 | TestSetRecvRtpHeaderExtensions(kRtpTimestampOffsetHeaderExtension, |
| 1040 | webrtc::RtpExtension::kTOffset); |
| 1041 | } |
| 1042 | |
| 1043 | // Test support for absolute send time header extension. |
| 1044 | TEST_F(WebRtcVideoChannel2Test, SendAbsoluteSendTimeHeaderExtensions) { |
| 1045 | TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension, |
| 1046 | webrtc::RtpExtension::kAbsSendTime); |
| 1047 | } |
| 1048 | TEST_F(WebRtcVideoChannel2Test, RecvAbsoluteSendTimeHeaderExtensions) { |
| 1049 | TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension, |
| 1050 | webrtc::RtpExtension::kAbsSendTime); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1051 | } |
| 1052 | |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1053 | TEST_F(WebRtcVideoChannel2Test, |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1054 | SetSendRtpHeaderExtensionsExcludeUnsupportedExtensions) { |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1055 | const int kUnsupportedId = 1; |
| 1056 | const int kTOffsetId = 2; |
| 1057 | |
| 1058 | std::vector<cricket::RtpHeaderExtension> extensions; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1059 | extensions.push_back( |
| 1060 | cricket::RtpHeaderExtension(kUnsupportedExtensionName, kUnsupportedId)); |
| 1061 | extensions.push_back( |
| 1062 | cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, kTOffsetId)); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1063 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 1064 | FakeVideoSendStream* send_stream = |
| 1065 | AddSendStream(cricket::StreamParams::CreateLegacy(123)); |
| 1066 | |
| 1067 | // Only timestamp offset extension is set to send stream, |
| 1068 | // unsupported rtp extension is ignored. |
| 1069 | ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); |
| 1070 | EXPECT_STREQ(webrtc::RtpExtension::kTOffset, |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1071 | send_stream->GetConfig().rtp.extensions[0].name.c_str()); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1072 | } |
| 1073 | |
| 1074 | TEST_F(WebRtcVideoChannel2Test, |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1075 | SetRecvRtpHeaderExtensionsExcludeUnsupportedExtensions) { |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1076 | const int kUnsupportedId = 1; |
| 1077 | const int kTOffsetId = 2; |
| 1078 | |
| 1079 | std::vector<cricket::RtpHeaderExtension> extensions; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1080 | extensions.push_back( |
| 1081 | cricket::RtpHeaderExtension(kUnsupportedExtensionName, kUnsupportedId)); |
| 1082 | extensions.push_back( |
| 1083 | cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, kTOffsetId)); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1084 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 1085 | FakeVideoReceiveStream* recv_stream = |
| 1086 | AddRecvStream(cricket::StreamParams::CreateLegacy(123)); |
| 1087 | |
| 1088 | // Only timestamp offset extension is set to receive stream, |
| 1089 | // unsupported rtp extension is ignored. |
| 1090 | ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); |
| 1091 | EXPECT_STREQ(webrtc::RtpExtension::kTOffset, |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1092 | recv_stream->GetConfig().rtp.extensions[0].name.c_str()); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1093 | } |
| 1094 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1095 | TEST_F(WebRtcVideoChannel2Test, SetSendRtpHeaderExtensionsRejectsIncorrectIds) { |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1096 | const size_t kNumIncorrectIds = 4; |
| 1097 | const int kIncorrectIds[kNumIncorrectIds] = {-2, -1, 15, 16}; |
| 1098 | for (size_t i = 0; i < kNumIncorrectIds; ++i) { |
| 1099 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 1100 | extensions.push_back(cricket::RtpHeaderExtension( |
| 1101 | webrtc::RtpExtension::kTOffset, kIncorrectIds[i])); |
| 1102 | EXPECT_FALSE(channel_->SetSendRtpHeaderExtensions(extensions)) |
| 1103 | << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; |
| 1104 | } |
| 1105 | } |
| 1106 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1107 | TEST_F(WebRtcVideoChannel2Test, SetRecvRtpHeaderExtensionsRejectsIncorrectIds) { |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1108 | const size_t kNumIncorrectIds = 4; |
| 1109 | const int kIncorrectIds[kNumIncorrectIds] = {-2, -1, 15, 16}; |
| 1110 | for (size_t i = 0; i < kNumIncorrectIds; ++i) { |
| 1111 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 1112 | extensions.push_back(cricket::RtpHeaderExtension( |
| 1113 | webrtc::RtpExtension::kTOffset, kIncorrectIds[i])); |
| 1114 | EXPECT_FALSE(channel_->SetRecvRtpHeaderExtensions(extensions)) |
| 1115 | << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; |
| 1116 | } |
| 1117 | } |
| 1118 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1119 | TEST_F(WebRtcVideoChannel2Test, SetSendRtpHeaderExtensionsRejectsDuplicateIds) { |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1120 | const int id = 1; |
| 1121 | std::vector<cricket::RtpHeaderExtension> extensions; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1122 | extensions.push_back( |
| 1123 | cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); |
| 1124 | extensions.push_back( |
| 1125 | cricket::RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension, id)); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1126 | EXPECT_FALSE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 1127 | |
| 1128 | // Duplicate entries are also not supported. |
| 1129 | extensions.clear(); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1130 | extensions.push_back( |
| 1131 | cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1132 | extensions.push_back(extensions.back()); |
| 1133 | EXPECT_FALSE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 1134 | } |
| 1135 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1136 | TEST_F(WebRtcVideoChannel2Test, SetRecvRtpHeaderExtensionsRejectsDuplicateIds) { |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1137 | const int id = 1; |
| 1138 | std::vector<cricket::RtpHeaderExtension> extensions; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1139 | extensions.push_back( |
| 1140 | cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); |
| 1141 | extensions.push_back( |
| 1142 | cricket::RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension, id)); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1143 | EXPECT_FALSE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 1144 | |
| 1145 | // Duplicate entries are also not supported. |
| 1146 | extensions.clear(); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1147 | extensions.push_back( |
| 1148 | cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 1149 | extensions.push_back(extensions.back()); |
| 1150 | EXPECT_FALSE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 1151 | } |
| 1152 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1153 | TEST_F(WebRtcVideoChannel2Test, DISABLED_LeakyBucketTest) { |
| 1154 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1155 | } |
| 1156 | |
| 1157 | TEST_F(WebRtcVideoChannel2Test, DISABLED_BufferedModeLatency) { |
| 1158 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1159 | } |
| 1160 | |
| 1161 | TEST_F(WebRtcVideoChannel2Test, DISABLED_AdditiveVideoOptions) { |
| 1162 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1163 | } |
| 1164 | |
| 1165 | TEST_F(WebRtcVideoChannel2Test, AddRecvStreamOnlyUsesOneReceiveStream) { |
| 1166 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1167 | EXPECT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1168 | } |
| 1169 | |
pbos@webrtc.org | 257e130 | 2014-07-25 19:01:32 +0000 | [diff] [blame] | 1170 | TEST_F(WebRtcVideoChannel2Test, RembIsEnabledByDefault) { |
| 1171 | FakeVideoReceiveStream* stream = AddRecvStream(); |
| 1172 | EXPECT_TRUE(stream->GetConfig().rtp.remb); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1173 | } |
| 1174 | |
pbos@webrtc.org | 257e130 | 2014-07-25 19:01:32 +0000 | [diff] [blame] | 1175 | TEST_F(WebRtcVideoChannel2Test, RembCanBeEnabledAndDisabled) { |
| 1176 | FakeVideoReceiveStream* stream = AddRecvStream(); |
| 1177 | EXPECT_TRUE(stream->GetConfig().rtp.remb); |
| 1178 | |
| 1179 | // Verify that REMB is turned off when codecs without REMB are set. |
| 1180 | std::vector<VideoCodec> codecs; |
| 1181 | codecs.push_back(kVp8Codec); |
| 1182 | EXPECT_TRUE(codecs[0].feedback_params.params().empty()); |
| 1183 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1184 | stream = fake_call_->GetVideoReceiveStreams()[0]; |
pbos@webrtc.org | 257e130 | 2014-07-25 19:01:32 +0000 | [diff] [blame] | 1185 | EXPECT_FALSE(stream->GetConfig().rtp.remb); |
| 1186 | |
| 1187 | // Verify that REMB is turned on when setting default codecs since the |
| 1188 | // default codecs have REMB enabled. |
| 1189 | EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1190 | stream = fake_call_->GetVideoReceiveStreams()[0]; |
pbos@webrtc.org | 257e130 | 2014-07-25 19:01:32 +0000 | [diff] [blame] | 1191 | EXPECT_TRUE(stream->GetConfig().rtp.remb); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1192 | } |
| 1193 | |
pbos@webrtc.org | f99c2f2 | 2014-06-13 12:27:38 +0000 | [diff] [blame] | 1194 | TEST_F(WebRtcVideoChannel2Test, NackIsEnabledByDefault) { |
| 1195 | VerifyCodecHasDefaultFeedbackParams(default_codec_); |
| 1196 | |
pbos@webrtc.org | 1986474 | 2014-05-30 07:35:47 +0000 | [diff] [blame] | 1197 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1198 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1199 | |
| 1200 | // Send side. |
| 1201 | FakeVideoSendStream* send_stream = |
| 1202 | AddSendStream(cricket::StreamParams::CreateLegacy(1)); |
| 1203 | EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
| 1204 | |
| 1205 | // Receiver side. |
| 1206 | FakeVideoReceiveStream* recv_stream = |
| 1207 | AddRecvStream(cricket::StreamParams::CreateLegacy(1)); |
| 1208 | EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
| 1209 | |
| 1210 | // Nack history size should match between sender and receiver. |
| 1211 | EXPECT_EQ(send_stream->GetConfig().rtp.nack.rtp_history_ms, |
| 1212 | recv_stream->GetConfig().rtp.nack.rtp_history_ms); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1213 | } |
| 1214 | |
pbos@webrtc.org | f99c2f2 | 2014-06-13 12:27:38 +0000 | [diff] [blame] | 1215 | TEST_F(WebRtcVideoChannel2Test, NackCanBeDisabled) { |
| 1216 | std::vector<VideoCodec> codecs; |
| 1217 | codecs.push_back(kVp8Codec); |
| 1218 | |
| 1219 | // Send side. |
| 1220 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1221 | FakeVideoSendStream* send_stream = |
| 1222 | AddSendStream(cricket::StreamParams::CreateLegacy(1)); |
| 1223 | EXPECT_EQ(0, send_stream->GetConfig().rtp.nack.rtp_history_ms); |
| 1224 | |
| 1225 | // Receiver side. |
| 1226 | ASSERT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1227 | FakeVideoReceiveStream* recv_stream = |
| 1228 | AddRecvStream(cricket::StreamParams::CreateLegacy(1)); |
| 1229 | EXPECT_EQ(0, recv_stream->GetConfig().rtp.nack.rtp_history_ms); |
| 1230 | } |
| 1231 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1232 | TEST_F(WebRtcVideoChannel2Test, DISABLED_VideoProtectionInterop) { |
| 1233 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1234 | } |
| 1235 | |
| 1236 | TEST_F(WebRtcVideoChannel2Test, DISABLED_VideoProtectionInteropReversed) { |
| 1237 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1238 | } |
| 1239 | |
| 1240 | TEST_F(WebRtcVideoChannel2Test, DISABLED_HybridNackFecConference) { |
| 1241 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1242 | } |
| 1243 | |
| 1244 | TEST_F(WebRtcVideoChannel2Test, DISABLED_AddRemoveRecvStreamConference) { |
| 1245 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1246 | } |
| 1247 | |
| 1248 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetRender) { |
| 1249 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1250 | } |
| 1251 | |
| 1252 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthAuto) { |
| 1253 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1254 | } |
| 1255 | |
| 1256 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthAutoCapped) { |
| 1257 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1258 | } |
| 1259 | |
| 1260 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthFixed) { |
| 1261 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1262 | } |
| 1263 | |
| 1264 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthInConference) { |
| 1265 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1266 | } |
| 1267 | |
pbos@webrtc.org | efc82c2 | 2014-10-27 13:58:00 +0000 | [diff] [blame] | 1268 | TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { |
| 1269 | static const int kScreenshareMinBitrateKbps = 800; |
| 1270 | cricket::VideoCodec codec = kVp8Codec360p; |
| 1271 | std::vector<cricket::VideoCodec> codecs; |
| 1272 | codecs.push_back(codec); |
| 1273 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1274 | VideoOptions options; |
| 1275 | options.screencast_min_bitrate.Set(kScreenshareMinBitrateKbps); |
| 1276 | channel_->SetOptions(options); |
| 1277 | |
| 1278 | AddSendStream(); |
| 1279 | |
| 1280 | cricket::FakeVideoCapturer capturer; |
| 1281 | capturer.SetScreencast(false); |
| 1282 | EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
| 1283 | cricket::VideoFormat capture_format_hd = |
| 1284 | capturer.GetSupportedFormats()->front(); |
| 1285 | EXPECT_EQ(1280, capture_format_hd.width); |
| 1286 | EXPECT_EQ(720, capture_format_hd.height); |
| 1287 | EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); |
| 1288 | |
| 1289 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1290 | |
| 1291 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 1292 | ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); |
| 1293 | FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); |
| 1294 | |
| 1295 | EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); |
| 1296 | |
| 1297 | // Verify non-screencast settings. |
| 1298 | webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig(); |
| 1299 | EXPECT_EQ(webrtc::VideoEncoderConfig::kRealtimeVideo, |
| 1300 | encoder_config.content_type); |
| 1301 | EXPECT_EQ(codec.width, encoder_config.streams.front().width); |
| 1302 | EXPECT_EQ(codec.height, encoder_config.streams.front().height); |
| 1303 | EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps) |
| 1304 | << "Non-screenshare shouldn't use min-transmit bitrate."; |
| 1305 | |
| 1306 | capturer.SetScreencast(true); |
| 1307 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 1308 | |
| 1309 | EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); |
| 1310 | |
| 1311 | // Verify screencast settings. |
| 1312 | encoder_config = send_stream->GetEncoderConfig(); |
| 1313 | EXPECT_EQ(webrtc::VideoEncoderConfig::kScreenshare, |
| 1314 | encoder_config.content_type); |
| 1315 | EXPECT_EQ(kScreenshareMinBitrateKbps * 1000, |
| 1316 | encoder_config.min_transmit_bitrate_bps); |
| 1317 | |
| 1318 | EXPECT_EQ(capture_format_hd.width, encoder_config.streams.front().width); |
| 1319 | EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height); |
pbos@webrtc.org | b7ed779 | 2014-10-31 13:08:10 +0000 | [diff] [blame] | 1320 | EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty()); |
| 1321 | |
| 1322 | EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
| 1323 | } |
| 1324 | |
| 1325 | TEST_F(WebRtcVideoChannel2Test, |
| 1326 | ConferenceModeScreencastConfiguresTemporalLayer) { |
| 1327 | static const int kConferenceScreencastTemporalBitrateBps = 100000; |
| 1328 | VideoOptions options; |
| 1329 | options.conference_mode.Set(true); |
| 1330 | channel_->SetOptions(options); |
| 1331 | |
| 1332 | AddSendStream(); |
| 1333 | |
| 1334 | cricket::FakeVideoCapturer capturer; |
| 1335 | capturer.SetScreencast(true); |
| 1336 | EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
| 1337 | cricket::VideoFormat capture_format_hd = |
| 1338 | capturer.GetSupportedFormats()->front(); |
| 1339 | EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); |
| 1340 | |
| 1341 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1342 | |
| 1343 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 1344 | ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); |
| 1345 | FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); |
| 1346 | |
| 1347 | webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig(); |
| 1348 | |
| 1349 | // Verify screencast settings. |
| 1350 | encoder_config = send_stream->GetEncoderConfig(); |
| 1351 | EXPECT_EQ(webrtc::VideoEncoderConfig::kScreenshare, |
| 1352 | encoder_config.content_type); |
| 1353 | ASSERT_EQ(1u, encoder_config.streams.size()); |
| 1354 | ASSERT_EQ(1u, encoder_config.streams[0].temporal_layer_thresholds_bps.size()); |
| 1355 | EXPECT_EQ(kConferenceScreencastTemporalBitrateBps, |
| 1356 | encoder_config.streams[0].temporal_layer_thresholds_bps[0]); |
pbos@webrtc.org | efc82c2 | 2014-10-27 13:58:00 +0000 | [diff] [blame] | 1357 | |
| 1358 | EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1359 | } |
| 1360 | |
| 1361 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetSendSsrcAndCname) { |
| 1362 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1363 | } |
| 1364 | |
| 1365 | TEST_F(WebRtcVideoChannel2Test, |
| 1366 | DISABLED_SetSendSsrcAfterCreatingReceiveChannel) { |
| 1367 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1368 | } |
| 1369 | |
pbos@webrtc.org | 5ff71ab | 2014-07-23 07:28:56 +0000 | [diff] [blame] | 1370 | TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { |
| 1371 | FakeVideoSendStream* stream = AddSendStream(); |
| 1372 | EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); |
| 1373 | } |
| 1374 | |
| 1375 | TEST_F(WebRtcVideoChannel2Test, SetOptionsWithSuspendBelowMinBitrate) { |
| 1376 | VideoOptions options; |
| 1377 | options.suspend_below_min_bitrate.Set(true); |
| 1378 | channel_->SetOptions(options); |
| 1379 | |
| 1380 | FakeVideoSendStream* stream = AddSendStream(); |
| 1381 | EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate); |
| 1382 | |
| 1383 | options.suspend_below_min_bitrate.Set(false); |
| 1384 | channel_->SetOptions(options); |
| 1385 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1386 | stream = fake_call_->GetVideoSendStreams()[0]; |
pbos@webrtc.org | 5ff71ab | 2014-07-23 07:28:56 +0000 | [diff] [blame] | 1387 | EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); |
| 1388 | } |
| 1389 | |
pbos@webrtc.org | 543e589 | 2014-07-23 07:01:31 +0000 | [diff] [blame] | 1390 | TEST_F(WebRtcVideoChannel2Test, RedundantPayloadsDisabledByDefault) { |
| 1391 | const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
| 1392 | const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
| 1393 | FakeVideoSendStream* stream = AddSendStream( |
| 1394 | cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| 1395 | EXPECT_FALSE(stream->GetConfig().rtp.rtx.pad_with_redundant_payloads); |
| 1396 | } |
| 1397 | |
| 1398 | TEST_F(WebRtcVideoChannel2Test, SetOptionsWithPayloadPadding) { |
| 1399 | VideoOptions options; |
| 1400 | options.use_payload_padding.Set(true); |
| 1401 | channel_->SetOptions(options); |
| 1402 | |
| 1403 | const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
| 1404 | const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
| 1405 | FakeVideoSendStream* stream = AddSendStream( |
| 1406 | cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| 1407 | EXPECT_TRUE(stream->GetConfig().rtp.rtx.pad_with_redundant_payloads); |
| 1408 | |
| 1409 | options.use_payload_padding.Set(false); |
| 1410 | channel_->SetOptions(options); |
| 1411 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1412 | stream = fake_call_->GetVideoSendStreams()[0]; |
pbos@webrtc.org | 543e589 | 2014-07-23 07:01:31 +0000 | [diff] [blame] | 1413 | EXPECT_FALSE(stream->GetConfig().rtp.rtx.pad_with_redundant_payloads); |
| 1414 | } |
| 1415 | |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 1416 | TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) { |
| 1417 | FakeVideoSendStream* stream = AddSendStream(); |
| 1418 | webrtc::VideoCodecVP8 vp8_settings; |
| 1419 | ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
| 1420 | EXPECT_TRUE(vp8_settings.denoisingOn); |
| 1421 | } |
| 1422 | |
| 1423 | TEST_F(WebRtcVideoChannel2Test, SetOptionsWithDenoising) { |
| 1424 | VideoOptions options; |
| 1425 | options.video_noise_reduction.Set(false); |
| 1426 | channel_->SetOptions(options); |
| 1427 | |
| 1428 | FakeVideoSendStream* stream = AddSendStream(); |
| 1429 | webrtc::VideoCodecVP8 vp8_settings; |
| 1430 | ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
| 1431 | EXPECT_FALSE(vp8_settings.denoisingOn); |
| 1432 | |
| 1433 | options.video_noise_reduction.Set(true); |
| 1434 | channel_->SetOptions(options); |
| 1435 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1436 | stream = fake_call_->GetVideoSendStreams()[0]; |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 1437 | ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
| 1438 | EXPECT_TRUE(vp8_settings.denoisingOn); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1439 | } |
| 1440 | |
| 1441 | TEST_F(WebRtcVideoChannel2Test, DISABLED_MultipleSendStreamsWithOneCapturer) { |
| 1442 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1443 | } |
| 1444 | |
pbos@webrtc.org | 8aed945 | 2014-07-26 10:16:49 +0000 | [diff] [blame] | 1445 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SendReceiveBitratesStats) { |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1446 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1447 | } |
| 1448 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1449 | TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruse) { |
| 1450 | TestCpuAdaptation(true); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1451 | } |
| 1452 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1453 | TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenDisabled) { |
| 1454 | TestCpuAdaptation(false); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1455 | } |
| 1456 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1457 | void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse) { |
pbos@webrtc.org | efc82c2 | 2014-10-27 13:58:00 +0000 | [diff] [blame] | 1458 | cricket::VideoCodec codec = kVp8Codec720p; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1459 | std::vector<cricket::VideoCodec> codecs; |
| 1460 | codecs.push_back(codec); |
| 1461 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1462 | |
| 1463 | if (enable_overuse) { |
| 1464 | VideoOptions options; |
| 1465 | options.cpu_overuse_detection.Set(true); |
| 1466 | channel_->SetOptions(options); |
| 1467 | } |
| 1468 | |
| 1469 | AddSendStream(); |
| 1470 | |
| 1471 | cricket::FakeVideoCapturer capturer; |
| 1472 | EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
| 1473 | EXPECT_EQ(cricket::CS_RUNNING, |
| 1474 | capturer.Start(capturer.GetSupportedFormats()->front())); |
| 1475 | |
| 1476 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1477 | |
| 1478 | // Trigger overuse. |
| 1479 | webrtc::LoadObserver* overuse_callback = |
| 1480 | fake_call_->GetConfig().overuse_callback; |
| 1481 | ASSERT_TRUE(overuse_callback != NULL); |
| 1482 | overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); |
| 1483 | |
| 1484 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 1485 | ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); |
| 1486 | FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); |
| 1487 | |
| 1488 | EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); |
| 1489 | |
| 1490 | if (enable_overuse) { |
| 1491 | EXPECT_LT(send_stream->GetLastWidth(), codec.width); |
| 1492 | EXPECT_LT(send_stream->GetLastHeight(), codec.height); |
| 1493 | } else { |
| 1494 | EXPECT_EQ(codec.width, send_stream->GetLastWidth()); |
| 1495 | EXPECT_EQ(codec.height, send_stream->GetLastHeight()); |
| 1496 | } |
| 1497 | |
| 1498 | // Trigger underuse which should go back to normal resolution. |
| 1499 | overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); |
| 1500 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 1501 | |
| 1502 | EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); |
| 1503 | |
| 1504 | EXPECT_EQ(codec.width, send_stream->GetLastWidth()); |
| 1505 | EXPECT_EQ(codec.height, send_stream->GetLastHeight()); |
| 1506 | |
| 1507 | EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1508 | } |
| 1509 | |
| 1510 | TEST_F(WebRtcVideoChannel2Test, DISABLED_WebRtcShouldLog) { |
| 1511 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1512 | } |
| 1513 | |
| 1514 | TEST_F(WebRtcVideoChannel2Test, DISABLED_WebRtcShouldNotLog) { |
| 1515 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1516 | } |
| 1517 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1518 | TEST_F(WebRtcVideoChannel2Test, SetDefaultSendCodecs) { |
pbos@webrtc.org | 9fbb717 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 1519 | ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1520 | |
| 1521 | VideoCodec codec; |
| 1522 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
pbos@webrtc.org | 9fbb717 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 1523 | EXPECT_TRUE(codec.Matches(engine_.codecs()[0])); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1524 | |
| 1525 | // Using a RTX setup to verify that the default RTX payload type is good. |
| 1526 | const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
| 1527 | const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
| 1528 | FakeVideoSendStream* stream = AddSendStream( |
| 1529 | cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| 1530 | webrtc::VideoSendStream::Config config = stream->GetConfig(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1531 | |
| 1532 | // Make sure NACK and FEC are enabled on the correct payload types. |
| 1533 | EXPECT_EQ(1000, config.rtp.nack.rtp_history_ms); |
| 1534 | EXPECT_EQ(default_ulpfec_codec_.id, config.rtp.fec.ulpfec_payload_type); |
| 1535 | EXPECT_EQ(default_red_codec_.id, config.rtp.fec.red_payload_type); |
pbos@webrtc.org | 269605c | 2014-06-26 08:49:03 +0000 | [diff] [blame] | 1536 | |
| 1537 | EXPECT_EQ(1u, config.rtp.rtx.ssrcs.size()); |
| 1538 | EXPECT_EQ(kRtxSsrcs1[0], config.rtp.rtx.ssrcs[0]); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1539 | EXPECT_EQ(static_cast<int>(default_rtx_codec_.id), |
| 1540 | config.rtp.rtx.payload_type); |
| 1541 | // TODO(juberti): Check RTCP, PLI, TMMBR. |
| 1542 | } |
| 1543 | |
| 1544 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) { |
| 1545 | std::vector<VideoCodec> codecs; |
| 1546 | codecs.push_back(kVp8Codec); |
| 1547 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1548 | |
| 1549 | FakeVideoSendStream* stream = AddSendStream(); |
| 1550 | webrtc::VideoSendStream::Config config = stream->GetConfig(); |
| 1551 | |
| 1552 | EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type); |
| 1553 | EXPECT_EQ(-1, config.rtp.fec.red_payload_type); |
| 1554 | } |
| 1555 | |
| 1556 | TEST_F(WebRtcVideoChannel2Test, |
pbos@webrtc.org | 269605c | 2014-06-26 08:49:03 +0000 | [diff] [blame] | 1557 | SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { |
| 1558 | std::vector<VideoCodec> codecs; |
| 1559 | cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); |
| 1560 | codecs.push_back(rtx_codec); |
| 1561 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)) |
| 1562 | << "RTX codec without associated payload type should be rejected."; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1563 | } |
| 1564 | |
| 1565 | TEST_F(WebRtcVideoChannel2Test, |
pbos@webrtc.org | 269605c | 2014-06-26 08:49:03 +0000 | [diff] [blame] | 1566 | SetSendCodecRejectsRtxWithoutMatchingVideoCodec) { |
| 1567 | std::vector<VideoCodec> codecs; |
| 1568 | cricket::VideoCodec rtx_codec = |
| 1569 | cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id); |
| 1570 | codecs.push_back(kVp8Codec); |
| 1571 | codecs.push_back(rtx_codec); |
| 1572 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1573 | |
| 1574 | cricket::VideoCodec rtx_codec2 = |
| 1575 | cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id + 1); |
| 1576 | codecs.pop_back(); |
| 1577 | codecs.push_back(rtx_codec2); |
| 1578 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)) |
| 1579 | << "RTX without matching video codec should be rejected."; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1580 | } |
| 1581 | |
pbos@webrtc.org | 269605c | 2014-06-26 08:49:03 +0000 | [diff] [blame] | 1582 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) { |
| 1583 | std::vector<VideoCodec> codecs; |
| 1584 | codecs.push_back(kVp8Codec); |
| 1585 | codecs.push_back(kUlpfecCodec); |
| 1586 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1587 | |
| 1588 | FakeVideoSendStream* stream = AddSendStream(); |
| 1589 | webrtc::VideoSendStream::Config config = stream->GetConfig(); |
| 1590 | |
| 1591 | EXPECT_EQ(kUlpfecCodec.id, config.rtp.fec.ulpfec_payload_type); |
| 1592 | |
| 1593 | codecs.pop_back(); |
| 1594 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1595 | stream = fake_call_->GetVideoSendStreams()[0]; |
pbos@webrtc.org | 269605c | 2014-06-26 08:49:03 +0000 | [diff] [blame] | 1596 | ASSERT_TRUE(stream != NULL); |
| 1597 | config = stream->GetConfig(); |
| 1598 | EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type) |
| 1599 | << "SetSendCodec without FEC should disable current FEC."; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1600 | } |
| 1601 | |
pbos@webrtc.org | 38ce7d0 | 2014-07-16 08:01:38 +0000 | [diff] [blame] | 1602 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { |
| 1603 | std::vector<VideoCodec> codecs; |
| 1604 | codecs.push_back(kVp8Codec720p); |
| 1605 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1606 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1607 | std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams(); |
pbos@webrtc.org | 38ce7d0 | 2014-07-16 08:01:38 +0000 | [diff] [blame] | 1608 | EXPECT_EQ(kVp8Codec720p.width, streams[0].width); |
| 1609 | EXPECT_EQ(kVp8Codec720p.height, streams[0].height); |
| 1610 | |
| 1611 | codecs.clear(); |
| 1612 | codecs.push_back(kVp8Codec360p); |
| 1613 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1614 | streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); |
pbos@webrtc.org | 38ce7d0 | 2014-07-16 08:01:38 +0000 | [diff] [blame] | 1615 | EXPECT_EQ(kVp8Codec360p.width, streams[0].width); |
| 1616 | EXPECT_EQ(kVp8Codec360p.height, streams[0].height); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1617 | } |
| 1618 | |
pbos@webrtc.org | 0087318 | 2014-11-25 14:03:34 +0000 | [diff] [blame] | 1619 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { |
| 1620 | SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", |
| 1621 | 200000); |
| 1622 | } |
| 1623 | |
| 1624 | TEST_F(WebRtcVideoChannel2Test, |
| 1625 | SetSendCodecsWithoutBitratesUsesCorrectDefaults) { |
| 1626 | SetSendCodecsShouldWorkForBitrates( |
| 1627 | "", 0, "", -1, "", -1); |
| 1628 | } |
| 1629 | |
| 1630 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsCapsMinAndStartBitrate) { |
| 1631 | SetSendCodecsShouldWorkForBitrates("-1", 0, "-100", -1, "", -1); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1632 | } |
| 1633 | |
| 1634 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) { |
pbos@webrtc.org | 9fbb717 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 1635 | std::vector<VideoCodec> video_codecs = engine_.codecs(); |
pbos@webrtc.org | 88ef632 | 2014-11-04 15:29:29 +0000 | [diff] [blame] | 1636 | video_codecs[0].params[kCodecParamMinBitrate] = "300"; |
| 1637 | video_codecs[0].params[kCodecParamMaxBitrate] = "200"; |
pbos@webrtc.org | 9fbb717 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 1638 | EXPECT_FALSE(channel_->SetSendCodecs(video_codecs)); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1639 | } |
| 1640 | |
pbos@webrtc.org | 0087318 | 2014-11-25 14:03:34 +0000 | [diff] [blame] | 1641 | TEST_F(WebRtcVideoChannel2Test, |
| 1642 | SetMaxSendBandwidthShouldPreserveOtherBitrates) { |
| 1643 | SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", |
| 1644 | 200000); |
| 1645 | channel_->SetMaxSendBandwidth(300000); |
| 1646 | EXPECT_EQ(100000, fake_call_->GetConfig().stream_bitrates.min_bitrate_bps) |
| 1647 | << "Setting max bitrate should keep previous min bitrate."; |
| 1648 | EXPECT_EQ(-1, fake_call_->GetConfig().stream_bitrates.start_bitrate_bps) |
| 1649 | << "Setting max bitrate should not reset start bitrate."; |
| 1650 | EXPECT_EQ(300000, fake_call_->GetConfig().stream_bitrates.max_bitrate_bps); |
| 1651 | } |
| 1652 | |
| 1653 | TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthShouldBeRemovable) { |
| 1654 | channel_->SetMaxSendBandwidth(300000); |
| 1655 | EXPECT_EQ(300000, fake_call_->GetConfig().stream_bitrates.max_bitrate_bps); |
| 1656 | // <= 0 means disable (infinite) max bitrate. |
| 1657 | channel_->SetMaxSendBandwidth(0); |
| 1658 | EXPECT_EQ(-1, fake_call_->GetConfig().stream_bitrates.max_bitrate_bps) |
| 1659 | << "Setting zero max bitrate did not reset start bitrate."; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1660 | } |
| 1661 | |
| 1662 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) { |
| 1663 | static const char* kMaxQuantization = "21"; |
| 1664 | std::vector<VideoCodec> codecs; |
| 1665 | codecs.push_back(kVp8Codec); |
| 1666 | codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization; |
| 1667 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 1668 | EXPECT_EQ(static_cast<unsigned int>(atoi(kMaxQuantization)), |
| 1669 | AddSendStream()->GetVideoStreams().back().max_qp); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1670 | |
| 1671 | VideoCodec codec; |
| 1672 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
| 1673 | EXPECT_EQ(kMaxQuantization, codec.params[kCodecParamMaxQuantization]); |
| 1674 | } |
| 1675 | |
| 1676 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadDimensions) { |
| 1677 | std::vector<cricket::VideoCodec> codecs; |
| 1678 | codecs.push_back(kVp8Codec); |
| 1679 | |
| 1680 | codecs[0].width = 0; |
| 1681 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)) |
| 1682 | << "Codec set though codec width is zero."; |
| 1683 | |
| 1684 | codecs[0].width = kVp8Codec.width; |
| 1685 | codecs[0].height = 0; |
| 1686 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)) |
| 1687 | << "Codec set though codec height is zero."; |
| 1688 | } |
| 1689 | |
| 1690 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadPayloadTypes) { |
| 1691 | // TODO(pbos): Should we only allow the dynamic range? |
| 1692 | static const size_t kNumIncorrectPayloads = 4; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1693 | static const int kIncorrectPayloads[kNumIncorrectPayloads] = { |
| 1694 | -2, -1, 128, 129}; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1695 | std::vector<cricket::VideoCodec> codecs; |
| 1696 | codecs.push_back(kVp8Codec); |
| 1697 | for (size_t i = 0; i < kNumIncorrectPayloads; ++i) { |
| 1698 | int payload_type = kIncorrectPayloads[i]; |
| 1699 | codecs[0].id = payload_type; |
| 1700 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)) |
| 1701 | << "Bad payload type '" << payload_type << "' accepted."; |
| 1702 | } |
| 1703 | } |
| 1704 | |
| 1705 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsAcceptAllValidPayloadTypes) { |
| 1706 | std::vector<cricket::VideoCodec> codecs; |
| 1707 | codecs.push_back(kVp8Codec); |
| 1708 | for (int payload_type = 0; payload_type <= 127; ++payload_type) { |
| 1709 | codecs[0].id = payload_type; |
| 1710 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)) |
| 1711 | << "Payload type '" << payload_type << "' rejected."; |
| 1712 | } |
| 1713 | } |
| 1714 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1715 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) { |
| 1716 | std::vector<cricket::VideoCodec> codecs; |
| 1717 | codecs.push_back(kVp8Codec); |
| 1718 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1719 | } |
| 1720 | |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 1721 | // Test that we set our inbound RTX codecs properly. |
| 1722 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) { |
| 1723 | std::vector<cricket::VideoCodec> codecs; |
| 1724 | codecs.push_back(kVp8Codec); |
| 1725 | cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); |
| 1726 | codecs.push_back(rtx_codec); |
| 1727 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) |
| 1728 | << "RTX codec without associated payload should be rejected."; |
| 1729 | |
| 1730 | codecs[1].SetParam("apt", kVp8Codec.id + 1); |
| 1731 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) |
| 1732 | << "RTX codec with invalid associated payload type should be rejected."; |
| 1733 | |
| 1734 | codecs[1].SetParam("apt", kVp8Codec.id); |
| 1735 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1736 | |
| 1737 | cricket::VideoCodec rtx_codec2(97, "rtx", 0, 0, 0, 0); |
| 1738 | rtx_codec2.SetParam("apt", rtx_codec.id); |
| 1739 | codecs.push_back(rtx_codec2); |
| 1740 | |
| 1741 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) << "RTX codec with another RTX " |
| 1742 | "as associated payload type " |
| 1743 | "should be rejected."; |
| 1744 | } |
| 1745 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1746 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentPayloadType) { |
| 1747 | std::vector<cricket::VideoCodec> codecs; |
| 1748 | codecs.push_back(kVp8Codec); |
| 1749 | codecs[0].id = 99; |
| 1750 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1751 | } |
| 1752 | |
pbos@webrtc.org | ccbed3b | 2014-07-11 13:02:54 +0000 | [diff] [blame] | 1753 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) { |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1754 | EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); |
pbos@webrtc.org | ccbed3b | 2014-07-11 13:02:54 +0000 | [diff] [blame] | 1755 | |
| 1756 | FakeVideoReceiveStream* stream = AddRecvStream(); |
| 1757 | webrtc::VideoReceiveStream::Config config = stream->GetConfig(); |
pbos@webrtc.org | 776e6f2 | 2014-10-29 15:28:39 +0000 | [diff] [blame] | 1758 | EXPECT_EQ(engine_.codecs()[0].name, config.decoders[0].payload_name); |
| 1759 | EXPECT_EQ(engine_.codecs()[0].id, config.decoders[0].payload_type); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1760 | } |
| 1761 | |
| 1762 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) { |
| 1763 | std::vector<VideoCodec> codecs; |
| 1764 | codecs.push_back(kVp8Codec); |
| 1765 | codecs.push_back(VideoCodec(101, "WTF3", 640, 400, 30, 0)); |
| 1766 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 1767 | } |
| 1768 | |
| 1769 | // TODO(pbos): Enable VP9 through external codec support |
| 1770 | TEST_F(WebRtcVideoChannel2Test, |
| 1771 | DISABLED_SetRecvCodecsAcceptsMultipleVideoCodecs) { |
| 1772 | std::vector<VideoCodec> codecs; |
| 1773 | codecs.push_back(kVp8Codec); |
| 1774 | codecs.push_back(kVp9Codec); |
| 1775 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1776 | } |
| 1777 | |
| 1778 | TEST_F(WebRtcVideoChannel2Test, |
| 1779 | DISABLED_SetRecvCodecsSetsFecForAllVideoCodecs) { |
| 1780 | std::vector<VideoCodec> codecs; |
| 1781 | codecs.push_back(kVp8Codec); |
| 1782 | codecs.push_back(kVp9Codec); |
| 1783 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1784 | FAIL(); // TODO(pbos): Verify that the FEC parameters are set for all codecs. |
| 1785 | } |
| 1786 | |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 1787 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithoutFecDisablesFec) { |
| 1788 | std::vector<VideoCodec> codecs; |
| 1789 | codecs.push_back(kVp8Codec); |
| 1790 | codecs.push_back(kUlpfecCodec); |
| 1791 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1792 | |
| 1793 | FakeVideoReceiveStream* stream = AddRecvStream(); |
| 1794 | webrtc::VideoReceiveStream::Config config = stream->GetConfig(); |
| 1795 | |
| 1796 | EXPECT_EQ(kUlpfecCodec.id, config.rtp.fec.ulpfec_payload_type); |
| 1797 | |
| 1798 | codecs.pop_back(); |
| 1799 | ASSERT_TRUE(channel_->SetRecvCodecs(codecs)); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1800 | stream = fake_call_->GetVideoReceiveStreams()[0]; |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 1801 | ASSERT_TRUE(stream != NULL); |
| 1802 | config = stream->GetConfig(); |
| 1803 | EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type) |
| 1804 | << "SetSendCodec without FEC should disable current FEC."; |
pbos@webrtc.org | 269605c | 2014-06-26 08:49:03 +0000 | [diff] [blame] | 1805 | } |
| 1806 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1807 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectDuplicateFecPayloads) { |
| 1808 | std::vector<VideoCodec> codecs; |
| 1809 | codecs.push_back(kVp8Codec); |
| 1810 | codecs.push_back(kRedCodec); |
| 1811 | codecs[1].id = codecs[0].id; |
| 1812 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 1813 | } |
| 1814 | |
| 1815 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectDuplicateCodecPayloads) { |
| 1816 | std::vector<VideoCodec> codecs; |
| 1817 | codecs.push_back(kVp8Codec); |
| 1818 | codecs.push_back(kVp9Codec); |
| 1819 | codecs[1].id = codecs[0].id; |
| 1820 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 1821 | } |
| 1822 | |
| 1823 | TEST_F(WebRtcVideoChannel2Test, |
| 1824 | SetRecvCodecsAcceptSameCodecOnMultiplePayloadTypes) { |
| 1825 | std::vector<VideoCodec> codecs; |
| 1826 | codecs.push_back(kVp8Codec); |
| 1827 | codecs.push_back(kVp8Codec); |
| 1828 | codecs[1].id += 1; |
| 1829 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1830 | } |
| 1831 | |
| 1832 | TEST_F(WebRtcVideoChannel2Test, SendStreamNotSendingByDefault) { |
| 1833 | EXPECT_FALSE(AddSendStream()->IsSending()); |
| 1834 | } |
| 1835 | |
pbos@webrtc.org | 85f4294 | 2014-07-22 09:14:58 +0000 | [diff] [blame] | 1836 | TEST_F(WebRtcVideoChannel2Test, ReceiveStreamReceivingByDefault) { |
| 1837 | EXPECT_TRUE(AddRecvStream()->IsReceiving()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1838 | } |
| 1839 | |
| 1840 | TEST_F(WebRtcVideoChannel2Test, SetSend) { |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 1841 | FakeVideoSendStream* stream = AddSendStream(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1842 | EXPECT_FALSE(stream->IsSending()); |
| 1843 | |
| 1844 | // false->true |
| 1845 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1846 | EXPECT_TRUE(stream->IsSending()); |
| 1847 | // true->true |
| 1848 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1849 | EXPECT_TRUE(stream->IsSending()); |
| 1850 | // true->false |
| 1851 | EXPECT_TRUE(channel_->SetSend(false)); |
| 1852 | EXPECT_FALSE(stream->IsSending()); |
| 1853 | // false->false |
| 1854 | EXPECT_TRUE(channel_->SetSend(false)); |
| 1855 | EXPECT_FALSE(stream->IsSending()); |
| 1856 | |
| 1857 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1858 | FakeVideoSendStream* new_stream = AddSendStream(); |
| 1859 | EXPECT_TRUE(new_stream->IsSending()) |
| 1860 | << "Send stream created after SetSend(true) not sending initially."; |
| 1861 | } |
| 1862 | |
pbos@webrtc.org | d819803 | 2014-11-10 14:41:43 +0000 | [diff] [blame] | 1863 | // This test verifies DSCP settings are properly applied on video media channel. |
| 1864 | TEST_F(WebRtcVideoChannel2Test, TestSetDscpOptions) { |
| 1865 | rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface( |
| 1866 | new cricket::FakeNetworkInterface); |
| 1867 | channel_->SetInterface(network_interface.get()); |
| 1868 | cricket::VideoOptions options; |
| 1869 | options.dscp.Set(true); |
| 1870 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1871 | EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); |
| 1872 | // Verify previous value is not modified if dscp option is not set. |
| 1873 | cricket::VideoOptions options1; |
| 1874 | EXPECT_TRUE(channel_->SetOptions(options1)); |
| 1875 | EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); |
| 1876 | options.dscp.Set(false); |
| 1877 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1878 | EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); |
| 1879 | channel_->SetInterface(NULL); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1880 | } |
| 1881 | |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 1882 | TEST_F(WebRtcVideoChannel2Test, OnReadyToSendSignalsNetworkState) { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1883 | EXPECT_EQ(webrtc::Call::kNetworkUp, fake_call_->GetNetworkState()); |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 1884 | |
| 1885 | channel_->OnReadyToSend(false); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1886 | EXPECT_EQ(webrtc::Call::kNetworkDown, fake_call_->GetNetworkState()); |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 1887 | |
| 1888 | channel_->OnReadyToSend(true); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 1889 | EXPECT_EQ(webrtc::Call::kNetworkUp, fake_call_->GetNetworkState()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1890 | } |
| 1891 | |
pbos@webrtc.org | 273a414 | 2014-12-01 15:23:21 +0000 | [diff] [blame] | 1892 | TEST_F(WebRtcVideoChannel2Test, GetStatsReportsUpperResolution) { |
| 1893 | FakeVideoSendStream* stream = AddSendStream(); |
| 1894 | webrtc::VideoSendStream::Stats stats; |
| 1895 | stats.substreams[17].sent_width = 123; |
| 1896 | stats.substreams[17].sent_height = 40; |
| 1897 | stats.substreams[42].sent_width = 80; |
| 1898 | stats.substreams[42].sent_height = 31; |
| 1899 | stats.substreams[11].sent_width = 20; |
| 1900 | stats.substreams[11].sent_height = 90; |
| 1901 | stream->SetStats(stats); |
| 1902 | |
| 1903 | cricket::VideoMediaInfo info; |
| 1904 | ASSERT_TRUE(channel_->GetStats(cricket::StatsOptions(), &info)); |
| 1905 | ASSERT_EQ(1u, info.senders.size()); |
| 1906 | EXPECT_EQ(123, info.senders[0].send_frame_width); |
| 1907 | EXPECT_EQ(90, info.senders[0].send_frame_height); |
| 1908 | } |
| 1909 | |
pbos@webrtc.org | 2b19f06 | 2014-12-11 13:26:09 +0000 | [diff] [blame^] | 1910 | TEST_F(WebRtcVideoChannel2Test, TranslatesCallStatsCorrectly) { |
| 1911 | AddSendStream(); |
| 1912 | AddSendStream(); |
| 1913 | webrtc::Call::Stats stats; |
| 1914 | stats.rtt_ms = 123; |
| 1915 | fake_call_->SetStats(stats); |
| 1916 | |
| 1917 | cricket::VideoMediaInfo info; |
| 1918 | ASSERT_TRUE(channel_->GetStats(cricket::StatsOptions(), &info)); |
| 1919 | ASSERT_EQ(2u, info.senders.size()); |
| 1920 | EXPECT_EQ(stats.rtt_ms, info.senders[0].rtt_ms); |
| 1921 | EXPECT_EQ(stats.rtt_ms, info.senders[1].rtt_ms); |
| 1922 | } |
| 1923 | |
buildbot@webrtc.org | a853077 | 2014-12-10 09:01:18 +0000 | [diff] [blame] | 1924 | class WebRtcVideoEngine2SimulcastTest : public testing::Test { |
| 1925 | public: |
| 1926 | WebRtcVideoEngine2SimulcastTest() |
| 1927 | : engine_codecs_(engine_.codecs()) { |
| 1928 | assert(!engine_codecs_.empty()); |
| 1929 | |
| 1930 | bool codec_set = false; |
| 1931 | for (size_t i = 0; i < engine_codecs_.size(); ++i) { |
| 1932 | if (engine_codecs_[i].name == "red") { |
| 1933 | default_red_codec_ = engine_codecs_[i]; |
| 1934 | } else if (engine_codecs_[i].name == "ulpfec") { |
| 1935 | default_ulpfec_codec_ = engine_codecs_[i]; |
| 1936 | } else if (engine_codecs_[i].name == "rtx") { |
| 1937 | default_rtx_codec_ = engine_codecs_[i]; |
| 1938 | } else if (!codec_set) { |
| 1939 | default_codec_ = engine_codecs_[i]; |
| 1940 | codec_set = true; |
| 1941 | } |
| 1942 | } |
| 1943 | |
| 1944 | assert(codec_set); |
| 1945 | } |
| 1946 | |
| 1947 | protected: |
| 1948 | WebRtcVideoEngine2 engine_; |
| 1949 | VideoCodec default_codec_; |
| 1950 | VideoCodec default_red_codec_; |
| 1951 | VideoCodec default_ulpfec_codec_; |
| 1952 | VideoCodec default_rtx_codec_; |
| 1953 | // TODO(pbos): Remove engine_codecs_ unless used a lot. |
| 1954 | std::vector<VideoCodec> engine_codecs_; |
| 1955 | }; |
| 1956 | |
| 1957 | class WebRtcVideoChannel2SimulcastTest : public WebRtcVideoEngine2SimulcastTest, |
| 1958 | public WebRtcCallFactory { |
| 1959 | public: |
| 1960 | WebRtcVideoChannel2SimulcastTest() : fake_call_(NULL) {} |
| 1961 | |
| 1962 | virtual void SetUp() OVERRIDE { |
| 1963 | engine_.SetCallFactory(this); |
| 1964 | engine_.Init(rtc::Thread::Current()); |
| 1965 | channel_.reset(engine_.CreateChannel(VideoOptions(), NULL)); |
| 1966 | ASSERT_TRUE(fake_call_ != NULL) << "Call not created through factory."; |
| 1967 | last_ssrc_ = 123; |
| 1968 | } |
| 1969 | |
| 1970 | protected: |
| 1971 | virtual webrtc::Call* CreateCall( |
| 1972 | const webrtc::Call::Config& config) OVERRIDE { |
| 1973 | assert(fake_call_ == NULL); |
| 1974 | fake_call_ = new FakeCall(config); |
| 1975 | return fake_call_; |
| 1976 | } |
| 1977 | |
| 1978 | void VerifySimulcastSettings(const VideoCodec& codec, |
| 1979 | VideoOptions::HighestBitrate bitrate_mode, |
| 1980 | size_t num_configured_streams, |
| 1981 | size_t expected_num_streams, |
| 1982 | SimulcastBitrateMode simulcast_bitrate_mode) { |
| 1983 | cricket::VideoOptions options; |
| 1984 | options.video_highest_bitrate.Set(bitrate_mode); |
| 1985 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1986 | |
| 1987 | std::vector<VideoCodec> codecs; |
| 1988 | codecs.push_back(codec); |
| 1989 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1990 | |
| 1991 | std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs3); |
| 1992 | assert(num_configured_streams <= ssrcs.size()); |
| 1993 | ssrcs.resize(num_configured_streams); |
| 1994 | |
| 1995 | FakeVideoSendStream* stream = |
| 1996 | AddSendStream(CreateSimStreamParams("cname", ssrcs)); |
| 1997 | |
| 1998 | std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); |
| 1999 | ASSERT_EQ(expected_num_streams, video_streams.size()); |
| 2000 | |
| 2001 | std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig( |
| 2002 | num_configured_streams, |
| 2003 | simulcast_bitrate_mode, |
| 2004 | codec.width, |
| 2005 | codec.height, |
| 2006 | kMinBitrateBps, |
| 2007 | 0, |
| 2008 | kDefaultQpMax, |
| 2009 | codec.framerate != 0 ? codec.framerate : kDefaultFramerate); |
| 2010 | |
| 2011 | ASSERT_EQ(expected_streams.size(), video_streams.size()); |
| 2012 | |
| 2013 | size_t num_streams = video_streams.size(); |
| 2014 | for (size_t i = 0; i < num_streams; ++i) { |
| 2015 | EXPECT_EQ(expected_streams[i].width, video_streams[i].width); |
| 2016 | EXPECT_EQ(expected_streams[i].height, video_streams[i].height); |
| 2017 | |
| 2018 | EXPECT_GT(video_streams[i].max_framerate, 0); |
| 2019 | EXPECT_EQ(expected_streams[i].max_framerate, |
| 2020 | video_streams[i].max_framerate); |
| 2021 | |
| 2022 | EXPECT_GT(video_streams[i].min_bitrate_bps, 0); |
| 2023 | EXPECT_EQ(expected_streams[i].min_bitrate_bps, |
| 2024 | video_streams[i].min_bitrate_bps); |
| 2025 | |
| 2026 | EXPECT_GT(video_streams[i].target_bitrate_bps, 0); |
| 2027 | EXPECT_EQ(expected_streams[i].target_bitrate_bps, |
| 2028 | video_streams[i].target_bitrate_bps); |
| 2029 | |
| 2030 | EXPECT_GT(video_streams[i].max_bitrate_bps, 0); |
| 2031 | EXPECT_EQ(expected_streams[i].max_bitrate_bps, |
| 2032 | video_streams[i].max_bitrate_bps); |
| 2033 | |
| 2034 | EXPECT_GT(video_streams[i].max_qp, 0); |
| 2035 | EXPECT_EQ(expected_streams[i].max_qp, video_streams[i].max_qp); |
| 2036 | |
| 2037 | EXPECT_FALSE(expected_streams[i].temporal_layer_thresholds_bps.empty()); |
| 2038 | EXPECT_EQ(expected_streams[i].temporal_layer_thresholds_bps, |
| 2039 | video_streams[i].temporal_layer_thresholds_bps); |
| 2040 | } |
| 2041 | |
| 2042 | EXPECT_EQ(kMinBitrateBps, video_streams[0].min_bitrate_bps); |
| 2043 | } |
| 2044 | |
| 2045 | FakeVideoSendStream* AddSendStream() { |
| 2046 | return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++)); |
| 2047 | } |
| 2048 | |
| 2049 | FakeVideoSendStream* AddSendStream(const StreamParams& sp) { |
| 2050 | size_t num_streams = |
| 2051 | fake_call_->GetVideoSendStreams().size(); |
| 2052 | EXPECT_TRUE(channel_->AddSendStream(sp)); |
| 2053 | std::vector<FakeVideoSendStream*> streams = |
| 2054 | fake_call_->GetVideoSendStreams(); |
| 2055 | EXPECT_EQ(num_streams + 1, streams.size()); |
| 2056 | return streams[streams.size() - 1]; |
| 2057 | } |
| 2058 | |
| 2059 | std::vector<FakeVideoSendStream*> GetFakeSendStreams() { |
| 2060 | return fake_call_->GetVideoSendStreams(); |
| 2061 | } |
| 2062 | |
| 2063 | FakeVideoReceiveStream* AddRecvStream() { |
| 2064 | return AddRecvStream(StreamParams::CreateLegacy(last_ssrc_++)); |
| 2065 | } |
| 2066 | |
| 2067 | FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) { |
| 2068 | size_t num_streams = |
| 2069 | fake_call_->GetVideoReceiveStreams().size(); |
| 2070 | EXPECT_TRUE(channel_->AddRecvStream(sp)); |
| 2071 | std::vector<FakeVideoReceiveStream*> streams = |
| 2072 | fake_call_->GetVideoReceiveStreams(); |
| 2073 | EXPECT_EQ(num_streams + 1, streams.size()); |
| 2074 | return streams[streams.size() - 1]; |
| 2075 | } |
| 2076 | |
| 2077 | FakeCall* fake_call_; |
| 2078 | rtc::scoped_ptr<VideoMediaChannel> channel_; |
| 2079 | uint32 last_ssrc_; |
| 2080 | }; |
| 2081 | |
| 2082 | TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { |
| 2083 | VerifySimulcastSettings(kVp8Codec, VideoOptions::NORMAL, 2, 2, SBM_NORMAL); |
| 2084 | } |
| 2085 | |
| 2086 | TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { |
| 2087 | VerifySimulcastSettings( |
| 2088 | kVp8Codec720p, VideoOptions::NORMAL, 3, 3, SBM_NORMAL); |
| 2089 | } |
| 2090 | |
| 2091 | TEST_F(WebRtcVideoChannel2SimulcastTest, |
| 2092 | SetSendCodecsWith2SimulcastStreamsHighBitrateMode) { |
| 2093 | VerifySimulcastSettings(kVp8Codec, VideoOptions::HIGH, 2, 2, SBM_HIGH); |
| 2094 | } |
| 2095 | |
| 2096 | TEST_F(WebRtcVideoChannel2SimulcastTest, |
| 2097 | SetSendCodecsWith3SimulcastStreamsHighBitrateMode) { |
| 2098 | VerifySimulcastSettings(kVp8Codec720p, VideoOptions::HIGH, 3, 3, SBM_HIGH); |
| 2099 | } |
| 2100 | |
| 2101 | TEST_F(WebRtcVideoChannel2SimulcastTest, |
| 2102 | SetSendCodecsWith2SimulcastStreamsVeryHighBitrateMode) { |
| 2103 | VerifySimulcastSettings( |
| 2104 | kVp8Codec, VideoOptions::VERY_HIGH, 2, 2, SBM_VERY_HIGH); |
| 2105 | } |
| 2106 | |
| 2107 | TEST_F(WebRtcVideoChannel2SimulcastTest, |
| 2108 | SetSendCodecsWith3SimulcastStreamsVeryHighBitrateMode) { |
| 2109 | VerifySimulcastSettings( |
| 2110 | kVp8Codec720p, VideoOptions::VERY_HIGH, 3, 3, SBM_VERY_HIGH); |
| 2111 | } |
| 2112 | |
| 2113 | // Test that we normalize send codec format size in simulcast. |
| 2114 | TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
| 2115 | cricket::VideoCodec codec(kVp8Codec270p); |
| 2116 | codec.width += 1; |
| 2117 | codec.height += 1; |
| 2118 | VerifySimulcastSettings(codec, VideoOptions::NORMAL, 2, 2, SBM_NORMAL); |
| 2119 | } |
| 2120 | |
| 2121 | // Test that if we add a stream with RTX SSRC's, SSRC's get set correctly. |
| 2122 | TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestStreamWithRtx) { |
| 2123 | // TODO(pbos): Implement. |
| 2124 | FAIL() << "Not implemented."; |
| 2125 | } |
| 2126 | |
| 2127 | // Test that if we get too few ssrcs are given in AddSendStream(), |
| 2128 | // only supported sub-streams will be added. |
| 2129 | TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TooFewSimulcastSsrcs) { |
| 2130 | // TODO(pbos): Implement. |
| 2131 | FAIL() << "Not implemented."; |
| 2132 | } |
| 2133 | |
| 2134 | // Test that even more than enough ssrcs are given in AddSendStream(), |
| 2135 | // only supported sub-streams will be added. |
| 2136 | TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_MoreThanEnoughSimulcastSscrs) { |
| 2137 | // TODO(pbos): Implement. |
| 2138 | FAIL() << "Not implemented."; |
| 2139 | } |
| 2140 | |
| 2141 | // Test that SetSendStreamFormat works well with simulcast. |
| 2142 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2143 | DISABLED_SetSendStreamFormatWithSimulcast) { |
| 2144 | // TODO(pbos): Implement. |
| 2145 | FAIL() << "Not implemented."; |
| 2146 | } |
| 2147 | |
| 2148 | // Test that simulcast send codec is reset on new video frame size. |
| 2149 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2150 | DISABLED_ResetSimulcastSendCodecOnNewFrameSize) { |
| 2151 | // TODO(pbos): Implement. |
| 2152 | FAIL() << "Not implemented."; |
| 2153 | } |
| 2154 | |
| 2155 | // Test that simulcast send codec is reset on new portait mode video frame. |
| 2156 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2157 | DISABLED_ResetSimulcastSendCodecOnNewPortaitFrame) { |
| 2158 | // TODO(pbos): Implement. |
| 2159 | FAIL() << "Not implemented."; |
| 2160 | } |
| 2161 | |
| 2162 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2163 | DISABLED_SetBandwidthInConferenceWithSimulcast) { |
| 2164 | // TODO(pbos): Implement. |
| 2165 | FAIL() << "Not implemented."; |
| 2166 | } |
| 2167 | |
| 2168 | // Test that sending screencast frames in conference mode changes |
| 2169 | // bitrate. |
| 2170 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2171 | DISABLED_SetBandwidthScreencastInConference) { |
| 2172 | // TODO(pbos): Implement. |
| 2173 | FAIL() << "Not implemented."; |
| 2174 | } |
| 2175 | |
| 2176 | // Test AddSendStream with simulcast rejects bad StreamParams. |
| 2177 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2178 | DISABLED_AddSendStreamWithBadStreamParams) { |
| 2179 | // TODO(pbos): Implement. |
| 2180 | FAIL() << "Not implemented."; |
| 2181 | } |
| 2182 | |
| 2183 | // Test AddSendStream with simulcast sets ssrc and cname correctly. |
| 2184 | TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_AddSendStreamWithSimulcast) { |
| 2185 | // TODO(pbos): Implement. |
| 2186 | FAIL() << "Not implemented."; |
| 2187 | } |
| 2188 | |
| 2189 | // Test RemoveSendStream with simulcast. |
| 2190 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2191 | DISABLED_RemoveSendStreamWithSimulcast) { |
| 2192 | // TODO(pbos): Implement. |
| 2193 | FAIL() << "Not implemented."; |
| 2194 | } |
| 2195 | |
| 2196 | // Test AddSendStream after send codec has already been set will reset |
| 2197 | // send codec with simulcast settings. |
| 2198 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2199 | DISABLED_AddSimulcastStreamAfterSetSendCodec) { |
| 2200 | // TODO(pbos): Implement. |
| 2201 | FAIL() << "Not implemented."; |
| 2202 | } |
| 2203 | |
| 2204 | TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_GetStatsWithMultipleSsrcs) { |
| 2205 | // TODO(pbos): Implement. |
| 2206 | FAIL() << "Not implemented."; |
| 2207 | } |
| 2208 | |
| 2209 | // Test receiving channel(s) local ssrc is set to the same as the first |
| 2210 | // simulcast sending ssrc. |
| 2211 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2212 | DISABLED_AddSimulcastStreamAfterCreatingRecvChannels) { |
| 2213 | // TODO(pbos): Implement. |
| 2214 | FAIL() << "Not implemented."; |
| 2215 | } |
| 2216 | |
| 2217 | // Test 1:1 call never turn on simulcast. |
| 2218 | TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_NoSimulcastWith1on1) { |
| 2219 | // TODO(pbos): Implement. |
| 2220 | FAIL() << "Not implemented."; |
| 2221 | } |
| 2222 | |
| 2223 | // Test SetOptions with OPT_CONFERENCE flag. |
| 2224 | TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_SetOptionsWithConferenceMode) { |
| 2225 | // TODO(pbos): Implement. |
| 2226 | FAIL() << "Not implemented."; |
| 2227 | } |
| 2228 | |
| 2229 | // Test that two different streams can have different formats. |
| 2230 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2231 | DISABLED_MultipleSendStreamsDifferentFormats) { |
| 2232 | // TODO(pbos): Implement. |
| 2233 | FAIL() << "Not implemented."; |
| 2234 | } |
| 2235 | |
| 2236 | TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestAdaptToOutputFormat) { |
| 2237 | // TODO(pbos): Implement. |
| 2238 | FAIL() << "Not implemented."; |
| 2239 | } |
| 2240 | |
| 2241 | TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestAdaptToCpuLoad) { |
| 2242 | // TODO(pbos): Implement. |
| 2243 | FAIL() << "Not implemented."; |
| 2244 | } |
| 2245 | |
| 2246 | TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestAdaptToCpuLoadDisabled) { |
| 2247 | // TODO(pbos): Implement. |
| 2248 | FAIL() << "Not implemented."; |
| 2249 | } |
| 2250 | |
| 2251 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2252 | DISABLED_TestAdaptWithCpuOveruseObserver) { |
| 2253 | // TODO(pbos): Implement. |
| 2254 | FAIL() << "Not implemented."; |
| 2255 | } |
| 2256 | |
| 2257 | // Test that codec is not reset for every frame sent in non-conference and |
| 2258 | // non-screencast mode. |
| 2259 | TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_DontResetCodecOnSendFrame) { |
| 2260 | // TODO(pbos): Implement. |
| 2261 | FAIL() << "Not implemented."; |
| 2262 | } |
| 2263 | |
| 2264 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2265 | DISABLED_UseSimulcastAdapterOnVp8OnlyFactory) { |
| 2266 | // TODO(pbos): Implement. |
| 2267 | FAIL() << "Not implemented."; |
| 2268 | } |
| 2269 | |
| 2270 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2271 | DISABLED_DontUseSimulcastAdapterOnNoneVp8Factory) { |
| 2272 | // TODO(pbos): Implement. |
| 2273 | FAIL() << "Not implemented."; |
| 2274 | } |
| 2275 | |
| 2276 | TEST_F(WebRtcVideoEngine2SimulcastTest, |
| 2277 | DISABLED_DontUseSimulcastAdapterOnMultipleCodecsFactory) { |
| 2278 | // TODO(pbos): Implement. |
| 2279 | FAIL() << "Not implemented."; |
| 2280 | } |
| 2281 | |
| 2282 | TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_1280x800) { |
| 2283 | // TODO(pbos): Implement. |
| 2284 | FAIL() << "Not implemented."; |
| 2285 | } |
| 2286 | |
| 2287 | TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_1280x720) { |
| 2288 | // TODO(pbos): Implement. |
| 2289 | FAIL() << "Not implemented."; |
| 2290 | } |
| 2291 | |
| 2292 | TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_960x540) { |
| 2293 | // TODO(pbos): Implement. |
| 2294 | FAIL() << "Not implemented."; |
| 2295 | } |
| 2296 | |
| 2297 | TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_960x600) { |
| 2298 | // TODO(pbos): Implement. |
| 2299 | FAIL() << "Not implemented."; |
| 2300 | } |
| 2301 | |
| 2302 | TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_640x400) { |
| 2303 | // TODO(pbos): Implement. |
| 2304 | FAIL() << "Not implemented."; |
| 2305 | } |
| 2306 | |
| 2307 | TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_640x360) { |
| 2308 | // TODO(pbos): Implement. |
| 2309 | FAIL() << "Not implemented."; |
| 2310 | } |
| 2311 | |
| 2312 | TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_480x300) { |
| 2313 | // TODO(pbos): Implement. |
| 2314 | FAIL() << "Not implemented."; |
| 2315 | } |
| 2316 | |
| 2317 | TEST_F(WebRtcVideoChannel2SimulcastTest, |
| 2318 | DISABLED_DISABLED_SimulcastSend_480x270) { |
| 2319 | // TODO(pbos): Implement. |
| 2320 | FAIL() << "Not implemented."; |
| 2321 | } |
| 2322 | |
| 2323 | TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_320x200) { |
| 2324 | // TODO(pbos): Implement. |
| 2325 | FAIL() << "Not implemented."; |
| 2326 | } |
| 2327 | |
| 2328 | TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_320x180) { |
| 2329 | // TODO(pbos): Implement. |
| 2330 | FAIL() << "Not implemented."; |
| 2331 | } |
| 2332 | |
| 2333 | // Test reset send codec with simulcast. |
| 2334 | // Disabled per b/6773425 |
| 2335 | TEST_F(WebRtcVideoChannel2SimulcastTest, |
| 2336 | DISABLED_DISABLED_SimulcastResetSendCodec) { |
| 2337 | // TODO(pbos): Implement. |
| 2338 | FAIL() << "Not implemented."; |
| 2339 | } |
| 2340 | |
| 2341 | // Test simulcast streams are decodeable with expected sizes. |
| 2342 | TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastStreams) { |
| 2343 | // TODO(pbos): Implement. |
| 2344 | FAIL() << "Not implemented."; |
| 2345 | } |
| 2346 | |
| 2347 | // Simulcast and resolution resizing should be turned off when screencasting |
| 2348 | // but not otherwise. |
| 2349 | TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_ScreencastRendering) { |
| 2350 | // TODO(pbos): Implement. |
| 2351 | FAIL() << "Not implemented."; |
| 2352 | } |
| 2353 | |
| 2354 | // Ensures that the correct settings are applied to the codec when single |
| 2355 | // temporal layer screencasting is enabled, and that the correct simulcast |
| 2356 | // settings are reapplied when disabling screencasting. |
| 2357 | TEST_F(WebRtcVideoChannel2SimulcastTest, |
| 2358 | DISABLED_OneTemporalLayerScreencastSettings) { |
| 2359 | // TODO(pbos): Implement. |
| 2360 | FAIL() << "Not implemented."; |
| 2361 | } |
| 2362 | |
| 2363 | // Ensures that the correct settings are applied to the codec when two temporal |
| 2364 | // layer screencasting is enabled, and that the correct simulcast settings are |
| 2365 | // reapplied when disabling screencasting. |
| 2366 | TEST_F(WebRtcVideoChannel2SimulcastTest, |
| 2367 | DISABLED_TwoTemporalLayerScreencastSettings) { |
| 2368 | // TODO(pbos): Implement. |
| 2369 | FAIL() << "Not implemented."; |
| 2370 | } |
pbos@webrtc.org | 2b19f06 | 2014-12-11 13:26:09 +0000 | [diff] [blame^] | 2371 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 2372 | } // namespace cricket |