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