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