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" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 33 | #include "talk/media/webrtc/webrtcvideochannelfactory.h" |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 34 | #include "talk/media/webrtc/webrtcvideoengine2.h" |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 35 | #include "talk/media/webrtc/webrtcvideoengine2_unittest.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 36 | #include "webrtc/base/gunit.h" |
| 37 | #include "webrtc/base/stringutils.h" |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 38 | #include "webrtc/video_encoder.h" |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 39 | |
| 40 | namespace { |
| 41 | static const cricket::VideoCodec kVp8Codec720p(100, "VP8", 1280, 720, 30, 0); |
| 42 | static const cricket::VideoCodec kVp8Codec360p(100, "VP8", 640, 360, 30, 0); |
| 43 | static const cricket::VideoCodec kVp8Codec270p(100, "VP8", 480, 270, 30, 0); |
| 44 | static const cricket::VideoCodec kVp8Codec180p(100, "VP8", 320, 180, 30, 0); |
| 45 | |
| 46 | static const cricket::VideoCodec kVp8Codec(100, "VP8", 640, 400, 30, 0); |
| 47 | static const cricket::VideoCodec kVp9Codec(101, "VP9", 640, 400, 30, 0); |
| 48 | static const cricket::VideoCodec kRedCodec(116, "red", 0, 0, 0, 0); |
| 49 | static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec", 0, 0, 0, 0); |
| 50 | |
| 51 | static const uint32 kSsrcs1[] = {1}; |
| 52 | static const uint32 kRtxSsrcs1[] = {4}; |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 53 | static const char kUnsupportedExtensionName[] = |
| 54 | "urn:ietf:params:rtp-hdrext:unsupported"; |
pbos@webrtc.org | f99c2f2 | 2014-06-13 12:27:38 +0000 | [diff] [blame] | 55 | |
| 56 | void VerifyCodecHasDefaultFeedbackParams(const cricket::VideoCodec& codec) { |
| 57 | EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( |
| 58 | cricket::kRtcpFbParamNack, cricket::kParamValueEmpty))); |
| 59 | EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( |
| 60 | cricket::kRtcpFbParamNack, cricket::kRtcpFbNackParamPli))); |
| 61 | EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( |
| 62 | cricket::kRtcpFbParamRemb, cricket::kParamValueEmpty))); |
| 63 | EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( |
| 64 | cricket::kRtcpFbParamCcm, cricket::kRtcpFbCcmParamFir))); |
| 65 | } |
| 66 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 67 | } // namespace |
| 68 | |
| 69 | namespace cricket { |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 70 | FakeVideoSendStream::FakeVideoSendStream( |
| 71 | const webrtc::VideoSendStream::Config& config, |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 72 | const webrtc::VideoEncoderConfig& encoder_config) |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 73 | : sending_(false), |
| 74 | config_(config), |
| 75 | codec_settings_set_(false), |
| 76 | num_swapped_frames_(0) { |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 77 | assert(config.encoder_settings.encoder != NULL); |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 78 | ReconfigureVideoEncoder(encoder_config); |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 79 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 80 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 81 | webrtc::VideoSendStream::Config FakeVideoSendStream::GetConfig() { |
| 82 | return config_; |
| 83 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 84 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 85 | std::vector<webrtc::VideoStream> FakeVideoSendStream::GetVideoStreams() { |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 86 | return encoder_config_.streams; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 87 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 88 | |
pbos@webrtc.org | 85f4294 | 2014-07-22 09:14:58 +0000 | [diff] [blame] | 89 | bool FakeVideoSendStream::IsSending() const { |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 90 | return sending_; |
| 91 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 92 | |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 93 | bool FakeVideoSendStream::GetVp8Settings( |
| 94 | webrtc::VideoCodecVP8* settings) const { |
| 95 | if (!codec_settings_set_) { |
| 96 | return false; |
| 97 | } |
| 98 | |
| 99 | *settings = vp8_settings_; |
| 100 | return true; |
| 101 | } |
| 102 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 103 | int FakeVideoSendStream::GetNumberOfSwappedFrames() const { |
| 104 | return num_swapped_frames_; |
| 105 | } |
| 106 | |
| 107 | int FakeVideoSendStream::GetLastWidth() const { |
| 108 | return last_frame_.width(); |
| 109 | } |
| 110 | |
| 111 | int FakeVideoSendStream::GetLastHeight() const { |
| 112 | return last_frame_.height(); |
| 113 | } |
| 114 | |
| 115 | void FakeVideoSendStream::SwapFrame(webrtc::I420VideoFrame* frame) { |
| 116 | ++num_swapped_frames_; |
| 117 | last_frame_.SwapFrame(frame); |
| 118 | } |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 119 | webrtc::VideoSendStream::Stats FakeVideoSendStream::GetStats() const { |
| 120 | return webrtc::VideoSendStream::Stats(); |
| 121 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 122 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 123 | bool FakeVideoSendStream::ReconfigureVideoEncoder( |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 124 | const webrtc::VideoEncoderConfig& config) { |
| 125 | encoder_config_ = config; |
| 126 | if (config.encoder_specific_settings != NULL) { |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 127 | assert(config_.encoder_settings.payload_name == "VP8"); |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 128 | vp8_settings_ = *reinterpret_cast<const webrtc::VideoCodecVP8*>( |
| 129 | config.encoder_specific_settings); |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 130 | } |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 131 | codec_settings_set_ = config.encoder_specific_settings != NULL; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 132 | return true; |
| 133 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 134 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 135 | webrtc::VideoSendStreamInput* FakeVideoSendStream::Input() { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 136 | return this; |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 137 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 138 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 139 | void FakeVideoSendStream::Start() { |
| 140 | sending_ = true; |
| 141 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 142 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 143 | void FakeVideoSendStream::Stop() { |
| 144 | sending_ = false; |
| 145 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 146 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 147 | FakeVideoReceiveStream::FakeVideoReceiveStream( |
| 148 | const webrtc::VideoReceiveStream::Config& config) |
| 149 | : config_(config), receiving_(false) { |
| 150 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 151 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 152 | webrtc::VideoReceiveStream::Config FakeVideoReceiveStream::GetConfig() { |
| 153 | return config_; |
| 154 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 155 | |
pbos@webrtc.org | 85f4294 | 2014-07-22 09:14:58 +0000 | [diff] [blame] | 156 | bool FakeVideoReceiveStream::IsReceiving() const { |
| 157 | return receiving_; |
| 158 | } |
| 159 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 160 | webrtc::VideoReceiveStream::Stats FakeVideoReceiveStream::GetStats() const { |
| 161 | return webrtc::VideoReceiveStream::Stats(); |
| 162 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 163 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 164 | void FakeVideoReceiveStream::Start() { |
| 165 | receiving_ = true; |
| 166 | } |
pbos@webrtc.org | 85f4294 | 2014-07-22 09:14:58 +0000 | [diff] [blame] | 167 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 168 | void FakeVideoReceiveStream::Stop() { |
| 169 | receiving_ = false; |
| 170 | } |
pbos@webrtc.org | 85f4294 | 2014-07-22 09:14:58 +0000 | [diff] [blame] | 171 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 172 | void FakeVideoReceiveStream::GetCurrentReceiveCodec(webrtc::VideoCodec* codec) { |
| 173 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 174 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 175 | FakeCall::FakeCall(const webrtc::Call::Config& config) |
| 176 | : config_(config), network_state_(kNetworkUp) { |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 177 | SetVideoCodecs(GetDefaultVideoCodecs()); |
| 178 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 179 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 180 | FakeCall::~FakeCall() { |
| 181 | EXPECT_EQ(0u, video_send_streams_.size()); |
| 182 | EXPECT_EQ(0u, video_receive_streams_.size()); |
| 183 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 184 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 185 | void FakeCall::SetVideoCodecs(const std::vector<webrtc::VideoCodec> codecs) { |
| 186 | codecs_ = codecs; |
| 187 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 188 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 189 | webrtc::Call::Config FakeCall::GetConfig() const { |
| 190 | return config_; |
| 191 | } |
| 192 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 193 | std::vector<FakeVideoSendStream*> FakeCall::GetVideoSendStreams() { |
| 194 | return video_send_streams_; |
| 195 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 196 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 197 | std::vector<FakeVideoReceiveStream*> FakeCall::GetVideoReceiveStreams() { |
| 198 | return video_receive_streams_; |
| 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 | webrtc::VideoCodec FakeCall::GetEmptyVideoCodec() { |
| 202 | webrtc::VideoCodec codec; |
| 203 | codec.minBitrate = 300; |
| 204 | codec.startBitrate = 800; |
| 205 | codec.maxBitrate = 1500; |
| 206 | codec.maxFramerate = 10; |
| 207 | codec.width = 640; |
| 208 | codec.height = 480; |
| 209 | codec.qpMax = 56; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 210 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 211 | return codec; |
| 212 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 213 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 214 | webrtc::VideoCodec FakeCall::GetVideoCodecVp8() { |
| 215 | webrtc::VideoCodec vp8_codec = GetEmptyVideoCodec(); |
| 216 | vp8_codec.codecType = webrtc::kVideoCodecVP8; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 217 | rtc::strcpyn( |
| 218 | 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] | 219 | vp8_codec.plType = kVp8Codec.id; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 220 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 221 | return vp8_codec; |
| 222 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 223 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 224 | webrtc::VideoCodec FakeCall::GetVideoCodecVp9() { |
| 225 | webrtc::VideoCodec vp9_codec = GetEmptyVideoCodec(); |
| 226 | // TODO(pbos): Add a correct codecType when webrtc has one. |
| 227 | vp9_codec.codecType = webrtc::kVideoCodecVP8; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 228 | rtc::strcpyn( |
| 229 | 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] | 230 | vp9_codec.plType = kVp9Codec.id; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 231 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 232 | return vp9_codec; |
| 233 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 234 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 235 | std::vector<webrtc::VideoCodec> FakeCall::GetDefaultVideoCodecs() { |
| 236 | std::vector<webrtc::VideoCodec> codecs; |
| 237 | codecs.push_back(GetVideoCodecVp8()); |
| 238 | // codecs.push_back(GetVideoCodecVp9()); |
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 | return codecs; |
| 241 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 242 | |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 243 | webrtc::Call::NetworkState FakeCall::GetNetworkState() const { |
| 244 | return network_state_; |
| 245 | } |
| 246 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 247 | webrtc::VideoSendStream* FakeCall::CreateVideoSendStream( |
| 248 | const webrtc::VideoSendStream::Config& config, |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 249 | const webrtc::VideoEncoderConfig& encoder_config) { |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 250 | FakeVideoSendStream* fake_stream = |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 251 | new FakeVideoSendStream(config, encoder_config); |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 252 | video_send_streams_.push_back(fake_stream); |
| 253 | return fake_stream; |
| 254 | } |
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 | void FakeCall::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { |
| 257 | FakeVideoSendStream* fake_stream = |
| 258 | static_cast<FakeVideoSendStream*>(send_stream); |
| 259 | for (size_t i = 0; i < video_send_streams_.size(); ++i) { |
| 260 | if (video_send_streams_[i] == fake_stream) { |
| 261 | delete video_send_streams_[i]; |
| 262 | video_send_streams_.erase(video_send_streams_.begin() + i); |
| 263 | return; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 264 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 265 | } |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 266 | ADD_FAILURE() << "DestroyVideoSendStream called with unknown paramter."; |
| 267 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 268 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 269 | webrtc::VideoReceiveStream* FakeCall::CreateVideoReceiveStream( |
| 270 | const webrtc::VideoReceiveStream::Config& config) { |
| 271 | video_receive_streams_.push_back(new FakeVideoReceiveStream(config)); |
| 272 | return video_receive_streams_[video_receive_streams_.size() - 1]; |
| 273 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 274 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 275 | void FakeCall::DestroyVideoReceiveStream( |
| 276 | webrtc::VideoReceiveStream* receive_stream) { |
| 277 | FakeVideoReceiveStream* fake_stream = |
| 278 | static_cast<FakeVideoReceiveStream*>(receive_stream); |
| 279 | for (size_t i = 0; i < video_receive_streams_.size(); ++i) { |
| 280 | if (video_receive_streams_[i] == fake_stream) { |
| 281 | delete video_receive_streams_[i]; |
| 282 | video_receive_streams_.erase(video_receive_streams_.begin() + i); |
| 283 | return; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 284 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 285 | } |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 286 | ADD_FAILURE() << "DestroyVideoReceiveStream called with unknown paramter."; |
| 287 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 288 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 289 | webrtc::PacketReceiver* FakeCall::Receiver() { |
| 290 | // TODO(pbos): Fix this. |
| 291 | return NULL; |
| 292 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 293 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 294 | uint32_t FakeCall::SendBitrateEstimate() { |
| 295 | return 0; |
| 296 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 297 | |
pbos@webrtc.org | 86f613d | 2014-06-10 08:53:05 +0000 | [diff] [blame] | 298 | uint32_t FakeCall::ReceiveBitrateEstimate() { |
| 299 | return 0; |
| 300 | } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 301 | |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 302 | void FakeCall::SignalNetworkState(webrtc::Call::NetworkState state) { |
| 303 | network_state_ = state; |
| 304 | } |
| 305 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 306 | class WebRtcVideoEngine2Test : public testing::Test { |
| 307 | public: |
pbos@webrtc.org | b648b9d | 2014-08-26 11:08:06 +0000 | [diff] [blame] | 308 | WebRtcVideoEngine2Test() { |
pbos@webrtc.org | 9fbb717 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 309 | std::vector<VideoCodec> engine_codecs = engine_.codecs(); |
| 310 | assert(!engine_codecs.empty()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 311 | bool codec_set = false; |
pbos@webrtc.org | 9fbb717 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 312 | for (size_t i = 0; i < engine_codecs.size(); ++i) { |
| 313 | if (engine_codecs[i].name == "red") { |
| 314 | default_red_codec_ = engine_codecs[i]; |
| 315 | } else if (engine_codecs[i].name == "ulpfec") { |
| 316 | default_ulpfec_codec_ = engine_codecs[i]; |
| 317 | } else if (engine_codecs[i].name == "rtx") { |
| 318 | default_rtx_codec_ = engine_codecs[i]; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 319 | } else if (!codec_set) { |
pbos@webrtc.org | 9fbb717 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 320 | default_codec_ = engine_codecs[i]; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 321 | codec_set = true; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | assert(codec_set); |
| 326 | } |
| 327 | |
| 328 | protected: |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 329 | WebRtcVideoEngine2 engine_; |
| 330 | VideoCodec default_codec_; |
| 331 | VideoCodec default_red_codec_; |
| 332 | VideoCodec default_ulpfec_codec_; |
| 333 | VideoCodec default_rtx_codec_; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 334 | }; |
| 335 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 336 | // TODO(pbos): Add test that verifies that sync is configured properly. |
| 337 | TEST_F(WebRtcVideoEngine2Test, DISABLED_CreateChannelWithVoiceEngine) { |
| 338 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 339 | } |
| 340 | |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 341 | TEST_F(WebRtcVideoEngine2Test, FindCodec) { |
| 342 | const std::vector<cricket::VideoCodec>& c = engine_.codecs(); |
| 343 | EXPECT_EQ(4U, c.size()); |
| 344 | |
| 345 | cricket::VideoCodec vp8(104, "VP8", 320, 200, 30, 0); |
| 346 | EXPECT_TRUE(engine_.FindCodec(vp8)); |
| 347 | |
| 348 | cricket::VideoCodec vp8_ci(104, "vp8", 320, 200, 30, 0); |
| 349 | EXPECT_TRUE(engine_.FindCodec(vp8)); |
| 350 | |
| 351 | cricket::VideoCodec vp8_diff_fr_diff_pref(104, "VP8", 320, 200, 50, 50); |
| 352 | EXPECT_TRUE(engine_.FindCodec(vp8_diff_fr_diff_pref)); |
| 353 | |
| 354 | cricket::VideoCodec vp8_diff_id(95, "VP8", 320, 200, 30, 0); |
| 355 | EXPECT_FALSE(engine_.FindCodec(vp8_diff_id)); |
| 356 | vp8_diff_id.id = 97; |
| 357 | EXPECT_TRUE(engine_.FindCodec(vp8_diff_id)); |
| 358 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 359 | // FindCodec ignores the codec size. |
| 360 | // Test that FindCodec can accept uncommon codec size. |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 361 | cricket::VideoCodec vp8_diff_res(104, "VP8", 320, 111, 30, 0); |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 362 | EXPECT_TRUE(engine_.FindCodec(vp8_diff_res)); |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 363 | |
| 364 | // PeerConnection doesn't negotiate the resolution at this point. |
| 365 | // Test that FindCodec can handle the case when width/height is 0. |
| 366 | cricket::VideoCodec vp8_zero_res(104, "VP8", 0, 0, 30, 0); |
| 367 | EXPECT_TRUE(engine_.FindCodec(vp8_zero_res)); |
| 368 | |
| 369 | cricket::VideoCodec red(101, "RED", 0, 0, 30, 0); |
| 370 | EXPECT_TRUE(engine_.FindCodec(red)); |
| 371 | |
| 372 | cricket::VideoCodec red_ci(101, "red", 0, 0, 30, 0); |
| 373 | EXPECT_TRUE(engine_.FindCodec(red)); |
| 374 | |
| 375 | cricket::VideoCodec fec(102, "ULPFEC", 0, 0, 30, 0); |
| 376 | EXPECT_TRUE(engine_.FindCodec(fec)); |
| 377 | |
| 378 | cricket::VideoCodec fec_ci(102, "ulpfec", 0, 0, 30, 0); |
| 379 | EXPECT_TRUE(engine_.FindCodec(fec)); |
| 380 | |
| 381 | cricket::VideoCodec rtx(96, "rtx", 0, 0, 30, 0); |
| 382 | EXPECT_TRUE(engine_.FindCodec(rtx)); |
| 383 | } |
| 384 | |
| 385 | TEST_F(WebRtcVideoEngine2Test, DefaultRtxCodecHasAssociatedPayloadTypeSet) { |
| 386 | std::vector<VideoCodec> engine_codecs = engine_.codecs(); |
| 387 | for (size_t i = 0; i < engine_codecs.size(); ++i) { |
| 388 | if (engine_codecs[i].name != kRtxCodecName) |
| 389 | continue; |
| 390 | int associated_payload_type; |
| 391 | EXPECT_TRUE(engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType, |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 392 | &associated_payload_type)); |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 393 | EXPECT_EQ(default_codec_.id, associated_payload_type); |
| 394 | return; |
| 395 | } |
| 396 | FAIL() << "No RTX codec found among default codecs."; |
| 397 | } |
| 398 | |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 399 | TEST_F(WebRtcVideoEngine2Test, SupportsTimestampOffsetHeaderExtension) { |
| 400 | std::vector<RtpHeaderExtension> extensions = engine_.rtp_header_extensions(); |
| 401 | ASSERT_FALSE(extensions.empty()); |
| 402 | for (size_t i = 0; i < extensions.size(); ++i) { |
| 403 | if (extensions[i].uri == kRtpTimestampOffsetHeaderExtension) { |
| 404 | EXPECT_EQ(kRtpTimestampOffsetHeaderExtensionDefaultId, extensions[i].id); |
| 405 | return; |
| 406 | } |
| 407 | } |
| 408 | FAIL() << "Timestamp offset extension not in header-extension list."; |
| 409 | } |
| 410 | |
| 411 | TEST_F(WebRtcVideoEngine2Test, SupportsAbsoluteSenderTimeHeaderExtension) { |
| 412 | std::vector<RtpHeaderExtension> extensions = engine_.rtp_header_extensions(); |
| 413 | ASSERT_FALSE(extensions.empty()); |
| 414 | for (size_t i = 0; i < extensions.size(); ++i) { |
| 415 | if (extensions[i].uri == kRtpAbsoluteSenderTimeHeaderExtension) { |
| 416 | EXPECT_EQ(kRtpAbsoluteSenderTimeHeaderExtensionDefaultId, |
| 417 | extensions[i].id); |
| 418 | return; |
| 419 | } |
| 420 | } |
| 421 | FAIL() << "Absolute Sender Time extension not in header-extension list."; |
| 422 | } |
| 423 | |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 424 | TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 425 | rtc::scoped_ptr<VideoMediaChannel> channel(engine_.CreateChannel(NULL)); |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 426 | |
| 427 | EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); |
| 428 | |
| 429 | EXPECT_FALSE(channel->SetSend(true)) |
| 430 | << "Channel should not start without codecs."; |
| 431 | EXPECT_TRUE(channel->SetSend(false)) |
| 432 | << "Channel should be stoppable even without set codecs."; |
| 433 | } |
| 434 | |
pbos@webrtc.org | c3d2bd2 | 2014-08-12 20:55:10 +0000 | [diff] [blame] | 435 | TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) { |
| 436 | rtc::scoped_ptr<VideoMediaChannel> channel(engine_.CreateChannel(NULL)); |
| 437 | EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); |
| 438 | VideoMediaInfo info; |
| 439 | channel->GetStats(&info); |
| 440 | } |
| 441 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 442 | class WebRtcVideoEngine2BaseTest |
| 443 | : public VideoEngineTest<cricket::WebRtcVideoEngine2> { |
| 444 | protected: |
| 445 | typedef VideoEngineTest<cricket::WebRtcVideoEngine2> Base; |
| 446 | }; |
| 447 | |
| 448 | #define WEBRTC_ENGINE_BASE_TEST(test) \ |
| 449 | TEST_F(WebRtcVideoEngine2BaseTest, test) { Base::test##Body(); } |
| 450 | |
| 451 | WEBRTC_ENGINE_BASE_TEST(ConstrainNewCodec2); |
| 452 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 453 | class WebRtcVideoChannel2BaseTest |
| 454 | : public VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> { |
| 455 | protected: |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 456 | typedef VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> Base; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 457 | |
| 458 | virtual cricket::VideoCodec DefaultCodec() OVERRIDE { return kVp8Codec; } |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 459 | }; |
| 460 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 461 | #define WEBRTC_BASE_TEST(test) \ |
| 462 | TEST_F(WebRtcVideoChannel2BaseTest, test) { Base::test(); } |
| 463 | |
| 464 | #define WEBRTC_DISABLED_BASE_TEST(test) \ |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 465 | TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_##test) { Base::test(); } |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 466 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 467 | // TODO(pbos): Fix WebRtcVideoEngine2BaseTest, where we want CheckCoInitialize. |
| 468 | #if 0 |
| 469 | // TODO(juberti): Figure out why ViE is munging the COM refcount. |
| 470 | #ifdef WIN32 |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 471 | WEBRTC_DISABLED_BASE_TEST(CheckCoInitialize) { |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 472 | Base::CheckCoInitialize(); |
| 473 | } |
| 474 | #endif |
| 475 | #endif |
| 476 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 477 | WEBRTC_BASE_TEST(SetSend); |
| 478 | WEBRTC_BASE_TEST(SetSendWithoutCodecs); |
| 479 | WEBRTC_BASE_TEST(SetSendSetsTransportBufferSizes); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 480 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 481 | WEBRTC_BASE_TEST(GetStats); |
| 482 | WEBRTC_BASE_TEST(GetStatsMultipleRecvStreams); |
| 483 | WEBRTC_BASE_TEST(GetStatsMultipleSendStreams); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 484 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 485 | WEBRTC_BASE_TEST(SetSendBandwidth); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 486 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 487 | WEBRTC_BASE_TEST(SetSendSsrc); |
| 488 | WEBRTC_BASE_TEST(SetSendSsrcAfterSetCodecs); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 489 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 490 | WEBRTC_BASE_TEST(SetRenderer); |
| 491 | WEBRTC_BASE_TEST(AddRemoveRecvStreams); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 492 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 493 | WEBRTC_DISABLED_BASE_TEST(AddRemoveRecvStreamAndRender); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 494 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 495 | WEBRTC_BASE_TEST(AddRemoveRecvStreamsNoConference); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 496 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 497 | WEBRTC_BASE_TEST(AddRemoveSendStreams); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 498 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 499 | WEBRTC_BASE_TEST(SimulateConference); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 500 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 501 | WEBRTC_BASE_TEST(AddRemoveCapturer); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 502 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 503 | WEBRTC_BASE_TEST(RemoveCapturerWithoutAdd); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 504 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 505 | WEBRTC_BASE_TEST(AddRemoveCapturerMultipleSources); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 506 | |
| 507 | // TODO(pbos): Figure out why this fails so often. |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 508 | WEBRTC_DISABLED_BASE_TEST(HighAspectHighHeightCapturer); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 509 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 510 | WEBRTC_BASE_TEST(RejectEmptyStreamParams); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 511 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 512 | WEBRTC_BASE_TEST(AdaptResolution16x10); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 513 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 514 | WEBRTC_BASE_TEST(AdaptResolution4x3); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 515 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 516 | // TODO(juberti): Restore this test once we support sending 0 fps. |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 517 | WEBRTC_DISABLED_BASE_TEST(AdaptDropAllFrames); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 518 | // TODO(juberti): Understand why we get decode errors on this test. |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 519 | WEBRTC_DISABLED_BASE_TEST(AdaptFramerate); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 520 | |
pbos@webrtc.org | c4175b9 | 2014-09-03 15:25:49 +0000 | [diff] [blame] | 521 | WEBRTC_BASE_TEST(SendsLowerResolutionOnSmallerFrames); |
| 522 | |
| 523 | WEBRTC_BASE_TEST(MuteStream); |
| 524 | |
| 525 | WEBRTC_BASE_TEST(MultipleSendStreams); |
| 526 | |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 527 | WEBRTC_BASE_TEST(SetSendStreamFormat0x0); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 528 | |
| 529 | // TODO(zhurunz): Fix the flakey test. |
pbos@webrtc.org | 8fdeee6 | 2014-07-20 14:40:23 +0000 | [diff] [blame] | 530 | WEBRTC_DISABLED_BASE_TEST(SetSendStreamFormat); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 531 | |
pbos@webrtc.org | 9359cb3 | 2014-07-23 15:44:48 +0000 | [diff] [blame] | 532 | TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Vga) { |
| 533 | SendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30, 0)); |
| 534 | } |
| 535 | |
| 536 | TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Qvga) { |
| 537 | SendAndReceive(cricket::VideoCodec(100, "VP8", 320, 200, 30, 0)); |
| 538 | } |
| 539 | |
| 540 | TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8SvcQqvga) { |
| 541 | SendAndReceive(cricket::VideoCodec(100, "VP8", 160, 100, 30, 0)); |
| 542 | } |
| 543 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 544 | TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsSendAndReceive) { |
| 545 | Base::TwoStreamsSendAndReceive(kVp8Codec); |
| 546 | } |
| 547 | |
| 548 | TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsReUseFirstStream) { |
| 549 | Base::TwoStreamsReUseFirstStream(kVp8Codec); |
| 550 | } |
| 551 | |
pbos@webrtc.org | 9359cb3 | 2014-07-23 15:44:48 +0000 | [diff] [blame] | 552 | WEBRTC_BASE_TEST(SendManyResizeOnce); |
| 553 | |
| 554 | // TODO(pbos): Enable and figure out why this fails (or should work). |
| 555 | TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_SendVp8HdAndReceiveAdaptedVp8Vga) { |
| 556 | EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL)); |
| 557 | EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); |
| 558 | channel_->UpdateAspectRatio(1280, 720); |
| 559 | video_capturer_.reset(new cricket::FakeVideoCapturer); |
| 560 | const std::vector<cricket::VideoFormat>* formats = |
| 561 | video_capturer_->GetSupportedFormats(); |
| 562 | cricket::VideoFormat capture_format_hd = (*formats)[0]; |
| 563 | EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(capture_format_hd)); |
| 564 | EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get())); |
| 565 | |
| 566 | // Capture format HD -> adapt (OnOutputFormatRequest VGA) -> VGA. |
| 567 | cricket::VideoCodec codec(100, "VP8", 1280, 720, 30, 0); |
| 568 | EXPECT_TRUE(SetOneCodec(codec)); |
| 569 | codec.width /= 2; |
| 570 | codec.height /= 2; |
| 571 | EXPECT_TRUE(SetSend(true)); |
| 572 | EXPECT_TRUE(channel_->SetRender(true)); |
| 573 | EXPECT_EQ(0, renderer_.num_rendered_frames()); |
| 574 | EXPECT_TRUE(SendFrame()); |
| 575 | EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); |
| 576 | } |
| 577 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 578 | class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test, |
| 579 | public WebRtcCallFactory { |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 580 | public: |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 581 | WebRtcVideoChannel2Test() : fake_call_(NULL) {} |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 582 | virtual void SetUp() OVERRIDE { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 583 | engine_.SetCallFactory(this); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 584 | channel_.reset(engine_.CreateChannel(NULL)); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 585 | ASSERT_TRUE(fake_call_ != NULL) << "Call not created through factory."; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 586 | last_ssrc_ = 123; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 587 | ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | protected: |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 591 | virtual webrtc::Call* CreateCall( |
| 592 | const webrtc::Call::Config& config) OVERRIDE { |
| 593 | assert(fake_call_ == NULL); |
| 594 | fake_call_ = new FakeCall(config); |
| 595 | return fake_call_; |
| 596 | } |
| 597 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 598 | FakeVideoSendStream* AddSendStream() { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 599 | return AddSendStream(StreamParams::CreateLegacy(++last_ssrc_)); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 600 | } |
| 601 | |
| 602 | FakeVideoSendStream* AddSendStream(const StreamParams& sp) { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 603 | size_t num_streams = fake_call_->GetVideoSendStreams().size(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 604 | EXPECT_TRUE(channel_->AddSendStream(sp)); |
| 605 | std::vector<FakeVideoSendStream*> streams = |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 606 | fake_call_->GetVideoSendStreams(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 607 | EXPECT_EQ(num_streams + 1, streams.size()); |
| 608 | return streams[streams.size() - 1]; |
| 609 | } |
| 610 | |
| 611 | std::vector<FakeVideoSendStream*> GetFakeSendStreams() { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 612 | return fake_call_->GetVideoSendStreams(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | FakeVideoReceiveStream* AddRecvStream() { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 616 | return AddRecvStream(StreamParams::CreateLegacy(++last_ssrc_)); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 620 | size_t num_streams = fake_call_->GetVideoReceiveStreams().size(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 621 | EXPECT_TRUE(channel_->AddRecvStream(sp)); |
| 622 | std::vector<FakeVideoReceiveStream*> streams = |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 623 | fake_call_->GetVideoReceiveStreams(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 624 | EXPECT_EQ(num_streams + 1, streams.size()); |
| 625 | return streams[streams.size() - 1]; |
| 626 | } |
| 627 | |
| 628 | void SetSendCodecsShouldWorkForBitrates(const char* min_bitrate, |
| 629 | const char* max_bitrate) { |
| 630 | std::vector<VideoCodec> codecs; |
| 631 | codecs.push_back(kVp8Codec); |
| 632 | codecs[0].params[kCodecParamMinBitrate] = min_bitrate; |
| 633 | codecs[0].params[kCodecParamMaxBitrate] = max_bitrate; |
| 634 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 635 | |
| 636 | FakeVideoSendStream* stream = AddSendStream(); |
| 637 | |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 638 | std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); |
| 639 | ASSERT_EQ(1u, video_streams.size()); |
| 640 | EXPECT_EQ(atoi(min_bitrate), video_streams.back().min_bitrate_bps / 1000); |
| 641 | EXPECT_EQ(atoi(max_bitrate), video_streams.back().max_bitrate_bps / 1000); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 642 | |
| 643 | VideoCodec codec; |
| 644 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
| 645 | EXPECT_EQ(min_bitrate, codec.params[kCodecParamMinBitrate]); |
| 646 | EXPECT_EQ(max_bitrate, codec.params[kCodecParamMaxBitrate]); |
| 647 | } |
| 648 | |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 649 | void TestSetSendRtpHeaderExtensions(const std::string& cricket_ext, |
| 650 | const std::string& webrtc_ext) { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 651 | FakeCall* call = fake_call_; |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 652 | // Enable extension. |
| 653 | const int id = 1; |
| 654 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 655 | extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id)); |
| 656 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 657 | |
| 658 | FakeVideoSendStream* send_stream = |
| 659 | AddSendStream(cricket::StreamParams::CreateLegacy(123)); |
| 660 | |
| 661 | // Verify the send extension id. |
| 662 | ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); |
| 663 | EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); |
| 664 | EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name); |
| 665 | // Verify call with same set of extensions returns true. |
| 666 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 667 | // Verify that SetSendRtpHeaderExtensions doesn't implicitly add them for |
| 668 | // receivers. |
| 669 | EXPECT_TRUE(AddRecvStream(cricket::StreamParams::CreateLegacy(123)) |
| 670 | ->GetConfig() |
| 671 | .rtp.extensions.empty()); |
| 672 | |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 673 | // Verify that existing RTP header extensions can be removed. |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 674 | std::vector<cricket::RtpHeaderExtension> empty_extensions; |
| 675 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions)); |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 676 | ASSERT_EQ(1u, call->GetVideoSendStreams().size()); |
| 677 | send_stream = call->GetVideoSendStreams()[0]; |
| 678 | EXPECT_TRUE(send_stream->GetConfig().rtp.extensions.empty()); |
| 679 | |
| 680 | // Verify that adding receive RTP header extensions adds them for existing |
| 681 | // streams. |
| 682 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 683 | send_stream = call->GetVideoSendStreams()[0]; |
| 684 | ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); |
| 685 | EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); |
| 686 | EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name); |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 687 | } |
| 688 | |
| 689 | void TestSetRecvRtpHeaderExtensions(const std::string& cricket_ext, |
| 690 | const std::string& webrtc_ext) { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 691 | FakeCall* call = fake_call_; |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 692 | // Enable extension. |
| 693 | const int id = 1; |
| 694 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 695 | extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id)); |
| 696 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 697 | |
| 698 | FakeVideoReceiveStream* recv_stream = |
| 699 | AddRecvStream(cricket::StreamParams::CreateLegacy(123)); |
| 700 | |
| 701 | // Verify the recv extension id. |
| 702 | ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); |
| 703 | EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); |
| 704 | EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); |
| 705 | // Verify call with same set of extensions returns true. |
| 706 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 707 | |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 708 | // Verify that SetRecvRtpHeaderExtensions doesn't implicitly add them for |
| 709 | // senders. |
| 710 | EXPECT_TRUE(AddSendStream(cricket::StreamParams::CreateLegacy(123)) |
| 711 | ->GetConfig() |
| 712 | .rtp.extensions.empty()); |
| 713 | |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 714 | // Verify that existing RTP header extensions can be removed. |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 715 | std::vector<cricket::RtpHeaderExtension> empty_extensions; |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 716 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(empty_extensions)); |
| 717 | ASSERT_EQ(1u, call->GetVideoReceiveStreams().size()); |
| 718 | recv_stream = call->GetVideoReceiveStreams()[0]; |
| 719 | EXPECT_TRUE(recv_stream->GetConfig().rtp.extensions.empty()); |
| 720 | |
| 721 | // Verify that adding receive RTP header extensions adds them for existing |
| 722 | // streams. |
| 723 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 724 | recv_stream = call->GetVideoReceiveStreams()[0]; |
| 725 | ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); |
| 726 | EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); |
| 727 | EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 728 | } |
| 729 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 730 | void TestCpuAdaptation(bool enable_overuse); |
| 731 | |
| 732 | FakeCall* fake_call_; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 733 | rtc::scoped_ptr<VideoMediaChannel> channel_; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 734 | uint32 last_ssrc_; |
| 735 | }; |
| 736 | |
| 737 | TEST_F(WebRtcVideoChannel2Test, DISABLED_MaxBitrateResetsWithConferenceMode) { |
| 738 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 739 | } |
| 740 | |
| 741 | TEST_F(WebRtcVideoChannel2Test, DISABLED_StartSendBitrate) { |
| 742 | // TODO(pbos): Is this test testing vie_ ? this is confusing. No API to set |
| 743 | // start send bitrate from outside? Add defaults here that should be kept? |
| 744 | std::vector<cricket::VideoCodec> codec_list; |
| 745 | codec_list.push_back(kVp8Codec); |
| 746 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 747 | const unsigned int kVideoMinSendBitrateKbps = 50; |
| 748 | const unsigned int kVideoTargetSendBitrateKbps = 300; |
| 749 | const unsigned int kVideoMaxSendBitrateKbps = 2000; |
| 750 | FakeVideoSendStream* stream = AddSendStream(); |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 751 | std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); |
| 752 | ASSERT_EQ(1u, video_streams.size()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 753 | EXPECT_EQ(kVideoMinSendBitrateKbps, |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 754 | video_streams.back().min_bitrate_bps / 1000); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 755 | EXPECT_EQ(kVideoTargetSendBitrateKbps, |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 756 | video_streams.back().target_bitrate_bps / 1000); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 757 | EXPECT_EQ(kVideoMaxSendBitrateKbps, |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 758 | video_streams.back().max_bitrate_bps / 1000); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 759 | #if 0 |
| 760 | // TODO(pbos): un-#if |
| 761 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 762 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 763 | kVideoDefaultStartSendBitrateKbps); |
| 764 | EXPECT_EQ(0, vie_.StartSend(send_channel)); |
| 765 | |
| 766 | // Increase the send bitrate and verify it is used as start bitrate. |
| 767 | const unsigned int kVideoSendBitrateBps = 768000; |
| 768 | vie_.SetSendBitrates(send_channel, kVideoSendBitrateBps, 0, 0); |
| 769 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 770 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 771 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 772 | kVideoSendBitrateBps / 1000); |
| 773 | |
| 774 | // Never set a start bitrate higher than the max bitrate. |
| 775 | vie_.SetSendBitrates(send_channel, kVideoMaxSendBitrateKbps + 500, 0, 0); |
| 776 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 777 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 778 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 779 | kVideoDefaultStartSendBitrateKbps); |
| 780 | |
| 781 | // Use the default start bitrate if the send bitrate is lower. |
| 782 | vie_.SetSendBitrates(send_channel, kVideoDefaultStartSendBitrateKbps - 50, 0, |
| 783 | 0); |
| 784 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 785 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 786 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 787 | kVideoDefaultStartSendBitrateKbps); |
| 788 | #endif |
| 789 | } |
| 790 | |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 791 | TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) { |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 792 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 793 | EXPECT_TRUE(channel_->SetSend(true)); |
| 794 | cricket::VideoOptions options; |
| 795 | options.conference_mode.Set(true); |
| 796 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 797 | |
| 798 | // Send side. |
| 799 | const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
| 800 | const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
| 801 | FakeVideoSendStream* send_stream = AddSendStream( |
| 802 | cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| 803 | |
| 804 | ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size()); |
| 805 | for (size_t i = 0; i < rtx_ssrcs.size(); ++i) |
| 806 | EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]); |
| 807 | |
| 808 | // Receiver side. |
| 809 | FakeVideoReceiveStream* recv_stream = AddRecvStream( |
| 810 | cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| 811 | ASSERT_GT(recv_stream->GetConfig().rtp.rtx.size(), 0u) |
| 812 | << "No SSRCs for RTX configured by AddRecvStream."; |
| 813 | ASSERT_EQ(1u, recv_stream->GetConfig().rtp.rtx.size()) |
| 814 | << "This test only works with one receive codec. Please update the test."; |
| 815 | EXPECT_EQ(rtx_ssrcs[0], |
| 816 | recv_stream->GetConfig().rtp.rtx.begin()->second.ssrc); |
| 817 | // TODO(pbos): Make sure we set the RTX for correct payloads etc. |
| 818 | } |
| 819 | |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 820 | TEST_F(WebRtcVideoChannel2Test, RecvStreamWithRtx) { |
| 821 | // Setup one channel with an associated RTX stream. |
| 822 | cricket::StreamParams params = |
| 823 | cricket::StreamParams::CreateLegacy(kSsrcs1[0]); |
| 824 | params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]); |
| 825 | FakeVideoReceiveStream* recv_stream = AddRecvStream(params); |
| 826 | ASSERT_EQ(1u, recv_stream->GetConfig().rtp.rtx.size()); |
| 827 | EXPECT_EQ(kRtxSsrcs1[0], |
| 828 | recv_stream->GetConfig().rtp.rtx.begin()->second.ssrc); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 829 | } |
| 830 | |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 831 | TEST_F(WebRtcVideoChannel2Test, RecvStreamNoRtx) { |
| 832 | // Setup one channel without an associated RTX stream. |
| 833 | cricket::StreamParams params = |
| 834 | cricket::StreamParams::CreateLegacy(kSsrcs1[0]); |
| 835 | FakeVideoReceiveStream* recv_stream = AddRecvStream(params); |
| 836 | ASSERT_TRUE(recv_stream->GetConfig().rtp.rtx.empty()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 837 | } |
| 838 | |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 839 | TEST_F(WebRtcVideoChannel2Test, NoHeaderExtesionsByDefault) { |
| 840 | FakeVideoSendStream* send_stream = |
| 841 | AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0])); |
| 842 | ASSERT_TRUE(send_stream->GetConfig().rtp.extensions.empty()); |
| 843 | |
| 844 | FakeVideoReceiveStream* recv_stream = |
| 845 | AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0])); |
| 846 | ASSERT_TRUE(recv_stream->GetConfig().rtp.extensions.empty()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 847 | } |
| 848 | |
pbos@webrtc.org | 587ef60 | 2014-06-16 17:32:02 +0000 | [diff] [blame] | 849 | // Test support for RTP timestamp offset header extension. |
| 850 | TEST_F(WebRtcVideoChannel2Test, SendRtpTimestampOffsetHeaderExtensions) { |
| 851 | TestSetSendRtpHeaderExtensions(kRtpTimestampOffsetHeaderExtension, |
| 852 | webrtc::RtpExtension::kTOffset); |
| 853 | } |
| 854 | TEST_F(WebRtcVideoChannel2Test, RecvRtpTimestampOffsetHeaderExtensions) { |
| 855 | TestSetRecvRtpHeaderExtensions(kRtpTimestampOffsetHeaderExtension, |
| 856 | webrtc::RtpExtension::kTOffset); |
| 857 | } |
| 858 | |
| 859 | // Test support for absolute send time header extension. |
| 860 | TEST_F(WebRtcVideoChannel2Test, SendAbsoluteSendTimeHeaderExtensions) { |
| 861 | TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension, |
| 862 | webrtc::RtpExtension::kAbsSendTime); |
| 863 | } |
| 864 | TEST_F(WebRtcVideoChannel2Test, RecvAbsoluteSendTimeHeaderExtensions) { |
| 865 | TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension, |
| 866 | webrtc::RtpExtension::kAbsSendTime); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 867 | } |
| 868 | |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 869 | TEST_F(WebRtcVideoChannel2Test, |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 870 | SetSendRtpHeaderExtensionsExcludeUnsupportedExtensions) { |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 871 | const int kUnsupportedId = 1; |
| 872 | const int kTOffsetId = 2; |
| 873 | |
| 874 | std::vector<cricket::RtpHeaderExtension> extensions; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 875 | extensions.push_back( |
| 876 | cricket::RtpHeaderExtension(kUnsupportedExtensionName, kUnsupportedId)); |
| 877 | extensions.push_back( |
| 878 | cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, kTOffsetId)); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 879 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 880 | FakeVideoSendStream* send_stream = |
| 881 | AddSendStream(cricket::StreamParams::CreateLegacy(123)); |
| 882 | |
| 883 | // Only timestamp offset extension is set to send stream, |
| 884 | // unsupported rtp extension is ignored. |
| 885 | ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); |
| 886 | EXPECT_STREQ(webrtc::RtpExtension::kTOffset, |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 887 | send_stream->GetConfig().rtp.extensions[0].name.c_str()); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 888 | } |
| 889 | |
| 890 | TEST_F(WebRtcVideoChannel2Test, |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 891 | SetRecvRtpHeaderExtensionsExcludeUnsupportedExtensions) { |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 892 | const int kUnsupportedId = 1; |
| 893 | const int kTOffsetId = 2; |
| 894 | |
| 895 | std::vector<cricket::RtpHeaderExtension> extensions; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 896 | extensions.push_back( |
| 897 | cricket::RtpHeaderExtension(kUnsupportedExtensionName, kUnsupportedId)); |
| 898 | extensions.push_back( |
| 899 | cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, kTOffsetId)); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 900 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 901 | FakeVideoReceiveStream* recv_stream = |
| 902 | AddRecvStream(cricket::StreamParams::CreateLegacy(123)); |
| 903 | |
| 904 | // Only timestamp offset extension is set to receive stream, |
| 905 | // unsupported rtp extension is ignored. |
| 906 | ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); |
| 907 | EXPECT_STREQ(webrtc::RtpExtension::kTOffset, |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 908 | recv_stream->GetConfig().rtp.extensions[0].name.c_str()); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 909 | } |
| 910 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 911 | TEST_F(WebRtcVideoChannel2Test, SetSendRtpHeaderExtensionsRejectsIncorrectIds) { |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 912 | const size_t kNumIncorrectIds = 4; |
| 913 | const int kIncorrectIds[kNumIncorrectIds] = {-2, -1, 15, 16}; |
| 914 | for (size_t i = 0; i < kNumIncorrectIds; ++i) { |
| 915 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 916 | extensions.push_back(cricket::RtpHeaderExtension( |
| 917 | webrtc::RtpExtension::kTOffset, kIncorrectIds[i])); |
| 918 | EXPECT_FALSE(channel_->SetSendRtpHeaderExtensions(extensions)) |
| 919 | << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; |
| 920 | } |
| 921 | } |
| 922 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 923 | TEST_F(WebRtcVideoChannel2Test, SetRecvRtpHeaderExtensionsRejectsIncorrectIds) { |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 924 | const size_t kNumIncorrectIds = 4; |
| 925 | const int kIncorrectIds[kNumIncorrectIds] = {-2, -1, 15, 16}; |
| 926 | for (size_t i = 0; i < kNumIncorrectIds; ++i) { |
| 927 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 928 | extensions.push_back(cricket::RtpHeaderExtension( |
| 929 | webrtc::RtpExtension::kTOffset, kIncorrectIds[i])); |
| 930 | EXPECT_FALSE(channel_->SetRecvRtpHeaderExtensions(extensions)) |
| 931 | << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; |
| 932 | } |
| 933 | } |
| 934 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 935 | TEST_F(WebRtcVideoChannel2Test, SetSendRtpHeaderExtensionsRejectsDuplicateIds) { |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 936 | const int id = 1; |
| 937 | std::vector<cricket::RtpHeaderExtension> extensions; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 938 | extensions.push_back( |
| 939 | cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); |
| 940 | extensions.push_back( |
| 941 | cricket::RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension, id)); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 942 | EXPECT_FALSE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 943 | |
| 944 | // Duplicate entries are also not supported. |
| 945 | extensions.clear(); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 946 | extensions.push_back( |
| 947 | cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 948 | extensions.push_back(extensions.back()); |
| 949 | EXPECT_FALSE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 950 | } |
| 951 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 952 | TEST_F(WebRtcVideoChannel2Test, SetRecvRtpHeaderExtensionsRejectsDuplicateIds) { |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 953 | const int id = 1; |
| 954 | std::vector<cricket::RtpHeaderExtension> extensions; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 955 | extensions.push_back( |
| 956 | cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); |
| 957 | extensions.push_back( |
| 958 | cricket::RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension, id)); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 959 | EXPECT_FALSE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 960 | |
| 961 | // Duplicate entries are also not supported. |
| 962 | extensions.clear(); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 963 | extensions.push_back( |
| 964 | cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); |
pbos@webrtc.org | 3c10758 | 2014-07-20 15:27:35 +0000 | [diff] [blame] | 965 | extensions.push_back(extensions.back()); |
| 966 | EXPECT_FALSE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 967 | } |
| 968 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 969 | TEST_F(WebRtcVideoChannel2Test, DISABLED_LeakyBucketTest) { |
| 970 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 971 | } |
| 972 | |
| 973 | TEST_F(WebRtcVideoChannel2Test, DISABLED_BufferedModeLatency) { |
| 974 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 975 | } |
| 976 | |
| 977 | TEST_F(WebRtcVideoChannel2Test, DISABLED_AdditiveVideoOptions) { |
| 978 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 979 | } |
| 980 | |
| 981 | TEST_F(WebRtcVideoChannel2Test, AddRecvStreamOnlyUsesOneReceiveStream) { |
| 982 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 983 | EXPECT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 984 | } |
| 985 | |
pbos@webrtc.org | 257e130 | 2014-07-25 19:01:32 +0000 | [diff] [blame] | 986 | TEST_F(WebRtcVideoChannel2Test, RembIsEnabledByDefault) { |
| 987 | FakeVideoReceiveStream* stream = AddRecvStream(); |
| 988 | EXPECT_TRUE(stream->GetConfig().rtp.remb); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 989 | } |
| 990 | |
pbos@webrtc.org | 257e130 | 2014-07-25 19:01:32 +0000 | [diff] [blame] | 991 | TEST_F(WebRtcVideoChannel2Test, RembCanBeEnabledAndDisabled) { |
| 992 | FakeVideoReceiveStream* stream = AddRecvStream(); |
| 993 | EXPECT_TRUE(stream->GetConfig().rtp.remb); |
| 994 | |
| 995 | // Verify that REMB is turned off when codecs without REMB are set. |
| 996 | std::vector<VideoCodec> codecs; |
| 997 | codecs.push_back(kVp8Codec); |
| 998 | EXPECT_TRUE(codecs[0].feedback_params.params().empty()); |
| 999 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1000 | stream = fake_call_->GetVideoReceiveStreams()[0]; |
pbos@webrtc.org | 257e130 | 2014-07-25 19:01:32 +0000 | [diff] [blame] | 1001 | EXPECT_FALSE(stream->GetConfig().rtp.remb); |
| 1002 | |
| 1003 | // Verify that REMB is turned on when setting default codecs since the |
| 1004 | // default codecs have REMB enabled. |
| 1005 | EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1006 | stream = fake_call_->GetVideoReceiveStreams()[0]; |
pbos@webrtc.org | 257e130 | 2014-07-25 19:01:32 +0000 | [diff] [blame] | 1007 | EXPECT_TRUE(stream->GetConfig().rtp.remb); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1008 | } |
| 1009 | |
pbos@webrtc.org | f99c2f2 | 2014-06-13 12:27:38 +0000 | [diff] [blame] | 1010 | TEST_F(WebRtcVideoChannel2Test, NackIsEnabledByDefault) { |
| 1011 | VerifyCodecHasDefaultFeedbackParams(default_codec_); |
| 1012 | |
pbos@webrtc.org | 1986474 | 2014-05-30 07:35:47 +0000 | [diff] [blame] | 1013 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1014 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1015 | |
| 1016 | // Send side. |
| 1017 | FakeVideoSendStream* send_stream = |
| 1018 | AddSendStream(cricket::StreamParams::CreateLegacy(1)); |
| 1019 | EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
| 1020 | |
| 1021 | // Receiver side. |
| 1022 | FakeVideoReceiveStream* recv_stream = |
| 1023 | AddRecvStream(cricket::StreamParams::CreateLegacy(1)); |
| 1024 | EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
| 1025 | |
| 1026 | // Nack history size should match between sender and receiver. |
| 1027 | EXPECT_EQ(send_stream->GetConfig().rtp.nack.rtp_history_ms, |
| 1028 | recv_stream->GetConfig().rtp.nack.rtp_history_ms); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1029 | } |
| 1030 | |
pbos@webrtc.org | f99c2f2 | 2014-06-13 12:27:38 +0000 | [diff] [blame] | 1031 | TEST_F(WebRtcVideoChannel2Test, NackCanBeDisabled) { |
| 1032 | std::vector<VideoCodec> codecs; |
| 1033 | codecs.push_back(kVp8Codec); |
| 1034 | |
| 1035 | // Send side. |
| 1036 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1037 | FakeVideoSendStream* send_stream = |
| 1038 | AddSendStream(cricket::StreamParams::CreateLegacy(1)); |
| 1039 | EXPECT_EQ(0, send_stream->GetConfig().rtp.nack.rtp_history_ms); |
| 1040 | |
| 1041 | // Receiver side. |
| 1042 | ASSERT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1043 | FakeVideoReceiveStream* recv_stream = |
| 1044 | AddRecvStream(cricket::StreamParams::CreateLegacy(1)); |
| 1045 | EXPECT_EQ(0, recv_stream->GetConfig().rtp.nack.rtp_history_ms); |
| 1046 | } |
| 1047 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1048 | TEST_F(WebRtcVideoChannel2Test, DISABLED_VideoProtectionInterop) { |
| 1049 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1050 | } |
| 1051 | |
| 1052 | TEST_F(WebRtcVideoChannel2Test, DISABLED_VideoProtectionInteropReversed) { |
| 1053 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1054 | } |
| 1055 | |
| 1056 | TEST_F(WebRtcVideoChannel2Test, DISABLED_HybridNackFecConference) { |
| 1057 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1058 | } |
| 1059 | |
| 1060 | TEST_F(WebRtcVideoChannel2Test, DISABLED_AddRemoveRecvStreamConference) { |
| 1061 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1062 | } |
| 1063 | |
| 1064 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetRender) { |
| 1065 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1066 | } |
| 1067 | |
| 1068 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthAuto) { |
| 1069 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1070 | } |
| 1071 | |
| 1072 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthAutoCapped) { |
| 1073 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1074 | } |
| 1075 | |
| 1076 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthFixed) { |
| 1077 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1078 | } |
| 1079 | |
| 1080 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthInConference) { |
| 1081 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1082 | } |
| 1083 | |
| 1084 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthScreencast) { |
| 1085 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1086 | } |
| 1087 | |
| 1088 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetSendSsrcAndCname) { |
| 1089 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1090 | } |
| 1091 | |
| 1092 | TEST_F(WebRtcVideoChannel2Test, |
| 1093 | DISABLED_SetSendSsrcAfterCreatingReceiveChannel) { |
| 1094 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1095 | } |
| 1096 | |
pbos@webrtc.org | 5ff71ab | 2014-07-23 07:28:56 +0000 | [diff] [blame] | 1097 | TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { |
| 1098 | FakeVideoSendStream* stream = AddSendStream(); |
| 1099 | EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); |
| 1100 | } |
| 1101 | |
| 1102 | TEST_F(WebRtcVideoChannel2Test, SetOptionsWithSuspendBelowMinBitrate) { |
| 1103 | VideoOptions options; |
| 1104 | options.suspend_below_min_bitrate.Set(true); |
| 1105 | channel_->SetOptions(options); |
| 1106 | |
| 1107 | FakeVideoSendStream* stream = AddSendStream(); |
| 1108 | EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate); |
| 1109 | |
| 1110 | options.suspend_below_min_bitrate.Set(false); |
| 1111 | channel_->SetOptions(options); |
| 1112 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1113 | stream = fake_call_->GetVideoSendStreams()[0]; |
pbos@webrtc.org | 5ff71ab | 2014-07-23 07:28:56 +0000 | [diff] [blame] | 1114 | EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); |
| 1115 | } |
| 1116 | |
pbos@webrtc.org | 543e589 | 2014-07-23 07:01:31 +0000 | [diff] [blame] | 1117 | TEST_F(WebRtcVideoChannel2Test, RedundantPayloadsDisabledByDefault) { |
| 1118 | const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
| 1119 | const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
| 1120 | FakeVideoSendStream* stream = AddSendStream( |
| 1121 | cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| 1122 | EXPECT_FALSE(stream->GetConfig().rtp.rtx.pad_with_redundant_payloads); |
| 1123 | } |
| 1124 | |
| 1125 | TEST_F(WebRtcVideoChannel2Test, SetOptionsWithPayloadPadding) { |
| 1126 | VideoOptions options; |
| 1127 | options.use_payload_padding.Set(true); |
| 1128 | channel_->SetOptions(options); |
| 1129 | |
| 1130 | const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
| 1131 | const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
| 1132 | FakeVideoSendStream* stream = AddSendStream( |
| 1133 | cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| 1134 | EXPECT_TRUE(stream->GetConfig().rtp.rtx.pad_with_redundant_payloads); |
| 1135 | |
| 1136 | options.use_payload_padding.Set(false); |
| 1137 | channel_->SetOptions(options); |
| 1138 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1139 | stream = fake_call_->GetVideoSendStreams()[0]; |
pbos@webrtc.org | 543e589 | 2014-07-23 07:01:31 +0000 | [diff] [blame] | 1140 | EXPECT_FALSE(stream->GetConfig().rtp.rtx.pad_with_redundant_payloads); |
| 1141 | } |
| 1142 | |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 1143 | TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) { |
| 1144 | FakeVideoSendStream* stream = AddSendStream(); |
| 1145 | webrtc::VideoCodecVP8 vp8_settings; |
| 1146 | ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
| 1147 | EXPECT_TRUE(vp8_settings.denoisingOn); |
| 1148 | } |
| 1149 | |
| 1150 | TEST_F(WebRtcVideoChannel2Test, SetOptionsWithDenoising) { |
| 1151 | VideoOptions options; |
| 1152 | options.video_noise_reduction.Set(false); |
| 1153 | channel_->SetOptions(options); |
| 1154 | |
| 1155 | FakeVideoSendStream* stream = AddSendStream(); |
| 1156 | webrtc::VideoCodecVP8 vp8_settings; |
| 1157 | ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
| 1158 | EXPECT_FALSE(vp8_settings.denoisingOn); |
| 1159 | |
| 1160 | options.video_noise_reduction.Set(true); |
| 1161 | channel_->SetOptions(options); |
| 1162 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1163 | stream = fake_call_->GetVideoSendStreams()[0]; |
pbos@webrtc.org | 6f48f1b | 2014-07-22 16:29:54 +0000 | [diff] [blame] | 1164 | ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
| 1165 | EXPECT_TRUE(vp8_settings.denoisingOn); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1166 | } |
| 1167 | |
| 1168 | TEST_F(WebRtcVideoChannel2Test, DISABLED_MultipleSendStreamsWithOneCapturer) { |
| 1169 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1170 | } |
| 1171 | |
pbos@webrtc.org | 8aed945 | 2014-07-26 10:16:49 +0000 | [diff] [blame] | 1172 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SendReceiveBitratesStats) { |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1173 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1174 | } |
| 1175 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1176 | TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruse) { |
| 1177 | TestCpuAdaptation(true); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1178 | } |
| 1179 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1180 | TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenDisabled) { |
| 1181 | TestCpuAdaptation(false); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1182 | } |
| 1183 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1184 | void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse) { |
| 1185 | cricket::VideoCodec codec(100, "VP8", 1280, 720, 30, 0); |
| 1186 | std::vector<cricket::VideoCodec> codecs; |
| 1187 | codecs.push_back(codec); |
| 1188 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1189 | |
| 1190 | if (enable_overuse) { |
| 1191 | VideoOptions options; |
| 1192 | options.cpu_overuse_detection.Set(true); |
| 1193 | channel_->SetOptions(options); |
| 1194 | } |
| 1195 | |
| 1196 | AddSendStream(); |
| 1197 | |
| 1198 | cricket::FakeVideoCapturer capturer; |
| 1199 | EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
| 1200 | EXPECT_EQ(cricket::CS_RUNNING, |
| 1201 | capturer.Start(capturer.GetSupportedFormats()->front())); |
| 1202 | |
| 1203 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1204 | |
| 1205 | // Trigger overuse. |
| 1206 | webrtc::LoadObserver* overuse_callback = |
| 1207 | fake_call_->GetConfig().overuse_callback; |
| 1208 | ASSERT_TRUE(overuse_callback != NULL); |
| 1209 | overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); |
| 1210 | |
| 1211 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 1212 | ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); |
| 1213 | FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); |
| 1214 | |
| 1215 | EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); |
| 1216 | |
| 1217 | if (enable_overuse) { |
| 1218 | EXPECT_LT(send_stream->GetLastWidth(), codec.width); |
| 1219 | EXPECT_LT(send_stream->GetLastHeight(), codec.height); |
| 1220 | } else { |
| 1221 | EXPECT_EQ(codec.width, send_stream->GetLastWidth()); |
| 1222 | EXPECT_EQ(codec.height, send_stream->GetLastHeight()); |
| 1223 | } |
| 1224 | |
| 1225 | // Trigger underuse which should go back to normal resolution. |
| 1226 | overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); |
| 1227 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 1228 | |
| 1229 | EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); |
| 1230 | |
| 1231 | EXPECT_EQ(codec.width, send_stream->GetLastWidth()); |
| 1232 | EXPECT_EQ(codec.height, send_stream->GetLastHeight()); |
| 1233 | |
| 1234 | EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1235 | } |
| 1236 | |
| 1237 | TEST_F(WebRtcVideoChannel2Test, DISABLED_WebRtcShouldLog) { |
| 1238 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1239 | } |
| 1240 | |
| 1241 | TEST_F(WebRtcVideoChannel2Test, DISABLED_WebRtcShouldNotLog) { |
| 1242 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1243 | } |
| 1244 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1245 | TEST_F(WebRtcVideoChannel2Test, SetDefaultSendCodecs) { |
pbos@webrtc.org | 9fbb717 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 1246 | ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1247 | |
| 1248 | VideoCodec codec; |
| 1249 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
pbos@webrtc.org | 9fbb717 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 1250 | EXPECT_TRUE(codec.Matches(engine_.codecs()[0])); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1251 | |
| 1252 | // Using a RTX setup to verify that the default RTX payload type is good. |
| 1253 | const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
| 1254 | const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
| 1255 | FakeVideoSendStream* stream = AddSendStream( |
| 1256 | cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| 1257 | webrtc::VideoSendStream::Config config = stream->GetConfig(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1258 | |
| 1259 | // Make sure NACK and FEC are enabled on the correct payload types. |
| 1260 | EXPECT_EQ(1000, config.rtp.nack.rtp_history_ms); |
| 1261 | EXPECT_EQ(default_ulpfec_codec_.id, config.rtp.fec.ulpfec_payload_type); |
| 1262 | 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] | 1263 | |
| 1264 | EXPECT_EQ(1u, config.rtp.rtx.ssrcs.size()); |
| 1265 | EXPECT_EQ(kRtxSsrcs1[0], config.rtp.rtx.ssrcs[0]); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1266 | EXPECT_EQ(static_cast<int>(default_rtx_codec_.id), |
| 1267 | config.rtp.rtx.payload_type); |
| 1268 | // TODO(juberti): Check RTCP, PLI, TMMBR. |
| 1269 | } |
| 1270 | |
| 1271 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) { |
| 1272 | std::vector<VideoCodec> codecs; |
| 1273 | codecs.push_back(kVp8Codec); |
| 1274 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1275 | |
| 1276 | FakeVideoSendStream* stream = AddSendStream(); |
| 1277 | webrtc::VideoSendStream::Config config = stream->GetConfig(); |
| 1278 | |
| 1279 | EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type); |
| 1280 | EXPECT_EQ(-1, config.rtp.fec.red_payload_type); |
| 1281 | } |
| 1282 | |
| 1283 | TEST_F(WebRtcVideoChannel2Test, |
pbos@webrtc.org | 269605c | 2014-06-26 08:49:03 +0000 | [diff] [blame] | 1284 | SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { |
| 1285 | std::vector<VideoCodec> codecs; |
| 1286 | cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); |
| 1287 | codecs.push_back(rtx_codec); |
| 1288 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)) |
| 1289 | << "RTX codec without associated payload type should be rejected."; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1290 | } |
| 1291 | |
| 1292 | TEST_F(WebRtcVideoChannel2Test, |
pbos@webrtc.org | 269605c | 2014-06-26 08:49:03 +0000 | [diff] [blame] | 1293 | SetSendCodecRejectsRtxWithoutMatchingVideoCodec) { |
| 1294 | std::vector<VideoCodec> codecs; |
| 1295 | cricket::VideoCodec rtx_codec = |
| 1296 | cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id); |
| 1297 | codecs.push_back(kVp8Codec); |
| 1298 | codecs.push_back(rtx_codec); |
| 1299 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1300 | |
| 1301 | cricket::VideoCodec rtx_codec2 = |
| 1302 | cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id + 1); |
| 1303 | codecs.pop_back(); |
| 1304 | codecs.push_back(rtx_codec2); |
| 1305 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)) |
| 1306 | << "RTX without matching video codec should be rejected."; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1307 | } |
| 1308 | |
pbos@webrtc.org | 269605c | 2014-06-26 08:49:03 +0000 | [diff] [blame] | 1309 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) { |
| 1310 | std::vector<VideoCodec> codecs; |
| 1311 | codecs.push_back(kVp8Codec); |
| 1312 | codecs.push_back(kUlpfecCodec); |
| 1313 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1314 | |
| 1315 | FakeVideoSendStream* stream = AddSendStream(); |
| 1316 | webrtc::VideoSendStream::Config config = stream->GetConfig(); |
| 1317 | |
| 1318 | EXPECT_EQ(kUlpfecCodec.id, config.rtp.fec.ulpfec_payload_type); |
| 1319 | |
| 1320 | codecs.pop_back(); |
| 1321 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1322 | stream = fake_call_->GetVideoSendStreams()[0]; |
pbos@webrtc.org | 269605c | 2014-06-26 08:49:03 +0000 | [diff] [blame] | 1323 | ASSERT_TRUE(stream != NULL); |
| 1324 | config = stream->GetConfig(); |
| 1325 | EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type) |
| 1326 | << "SetSendCodec without FEC should disable current FEC."; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1327 | } |
| 1328 | |
pbos@webrtc.org | 38ce7d0 | 2014-07-16 08:01:38 +0000 | [diff] [blame] | 1329 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { |
| 1330 | std::vector<VideoCodec> codecs; |
| 1331 | codecs.push_back(kVp8Codec720p); |
| 1332 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1333 | |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1334 | std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams(); |
pbos@webrtc.org | 38ce7d0 | 2014-07-16 08:01:38 +0000 | [diff] [blame] | 1335 | EXPECT_EQ(kVp8Codec720p.width, streams[0].width); |
| 1336 | EXPECT_EQ(kVp8Codec720p.height, streams[0].height); |
| 1337 | |
| 1338 | codecs.clear(); |
| 1339 | codecs.push_back(kVp8Codec360p); |
| 1340 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1341 | streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); |
pbos@webrtc.org | 38ce7d0 | 2014-07-16 08:01:38 +0000 | [diff] [blame] | 1342 | EXPECT_EQ(kVp8Codec360p.width, streams[0].width); |
| 1343 | EXPECT_EQ(kVp8Codec360p.height, streams[0].height); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1344 | } |
| 1345 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1346 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMinMaxBitrate) { |
| 1347 | SetSendCodecsShouldWorkForBitrates("10", "20"); |
| 1348 | } |
| 1349 | |
| 1350 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) { |
pbos@webrtc.org | 9fbb717 | 2014-06-13 09:34:13 +0000 | [diff] [blame] | 1351 | std::vector<VideoCodec> video_codecs = engine_.codecs(); |
| 1352 | video_codecs[0].params[kCodecParamMinBitrate] = "30"; |
| 1353 | video_codecs[0].params[kCodecParamMaxBitrate] = "20"; |
| 1354 | EXPECT_FALSE(channel_->SetSendCodecs(video_codecs)); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1355 | } |
| 1356 | |
| 1357 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsAcceptLargeMinMaxBitrate) { |
| 1358 | SetSendCodecsShouldWorkForBitrates("1000", "2000"); |
| 1359 | } |
| 1360 | |
| 1361 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) { |
| 1362 | static const char* kMaxQuantization = "21"; |
| 1363 | std::vector<VideoCodec> codecs; |
| 1364 | codecs.push_back(kVp8Codec); |
| 1365 | codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization; |
| 1366 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 1367 | EXPECT_EQ(static_cast<unsigned int>(atoi(kMaxQuantization)), |
| 1368 | AddSendStream()->GetVideoStreams().back().max_qp); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1369 | |
| 1370 | VideoCodec codec; |
| 1371 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
| 1372 | EXPECT_EQ(kMaxQuantization, codec.params[kCodecParamMaxQuantization]); |
| 1373 | } |
| 1374 | |
| 1375 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadDimensions) { |
| 1376 | std::vector<cricket::VideoCodec> codecs; |
| 1377 | codecs.push_back(kVp8Codec); |
| 1378 | |
| 1379 | codecs[0].width = 0; |
| 1380 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)) |
| 1381 | << "Codec set though codec width is zero."; |
| 1382 | |
| 1383 | codecs[0].width = kVp8Codec.width; |
| 1384 | codecs[0].height = 0; |
| 1385 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)) |
| 1386 | << "Codec set though codec height is zero."; |
| 1387 | } |
| 1388 | |
| 1389 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadPayloadTypes) { |
| 1390 | // TODO(pbos): Should we only allow the dynamic range? |
| 1391 | static const size_t kNumIncorrectPayloads = 4; |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1392 | static const int kIncorrectPayloads[kNumIncorrectPayloads] = { |
| 1393 | -2, -1, 128, 129}; |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1394 | std::vector<cricket::VideoCodec> codecs; |
| 1395 | codecs.push_back(kVp8Codec); |
| 1396 | for (size_t i = 0; i < kNumIncorrectPayloads; ++i) { |
| 1397 | int payload_type = kIncorrectPayloads[i]; |
| 1398 | codecs[0].id = payload_type; |
| 1399 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)) |
| 1400 | << "Bad payload type '" << payload_type << "' accepted."; |
| 1401 | } |
| 1402 | } |
| 1403 | |
| 1404 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsAcceptAllValidPayloadTypes) { |
| 1405 | std::vector<cricket::VideoCodec> codecs; |
| 1406 | codecs.push_back(kVp8Codec); |
| 1407 | for (int payload_type = 0; payload_type <= 127; ++payload_type) { |
| 1408 | codecs[0].id = payload_type; |
| 1409 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)) |
| 1410 | << "Payload type '" << payload_type << "' rejected."; |
| 1411 | } |
| 1412 | } |
| 1413 | |
| 1414 | TEST_F(WebRtcVideoChannel2Test, DISABLED_ResetVieSendCodecOnNewFrameSize) { |
| 1415 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1416 | } |
| 1417 | |
| 1418 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) { |
| 1419 | std::vector<cricket::VideoCodec> codecs; |
| 1420 | codecs.push_back(kVp8Codec); |
| 1421 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1422 | } |
| 1423 | |
pbos@webrtc.org | e322a17 | 2014-06-13 11:47:28 +0000 | [diff] [blame] | 1424 | // Test that we set our inbound RTX codecs properly. |
| 1425 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) { |
| 1426 | std::vector<cricket::VideoCodec> codecs; |
| 1427 | codecs.push_back(kVp8Codec); |
| 1428 | cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); |
| 1429 | codecs.push_back(rtx_codec); |
| 1430 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) |
| 1431 | << "RTX codec without associated payload should be rejected."; |
| 1432 | |
| 1433 | codecs[1].SetParam("apt", kVp8Codec.id + 1); |
| 1434 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) |
| 1435 | << "RTX codec with invalid associated payload type should be rejected."; |
| 1436 | |
| 1437 | codecs[1].SetParam("apt", kVp8Codec.id); |
| 1438 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1439 | |
| 1440 | cricket::VideoCodec rtx_codec2(97, "rtx", 0, 0, 0, 0); |
| 1441 | rtx_codec2.SetParam("apt", rtx_codec.id); |
| 1442 | codecs.push_back(rtx_codec2); |
| 1443 | |
| 1444 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) << "RTX codec with another RTX " |
| 1445 | "as associated payload type " |
| 1446 | "should be rejected."; |
| 1447 | } |
| 1448 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1449 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentPayloadType) { |
| 1450 | std::vector<cricket::VideoCodec> codecs; |
| 1451 | codecs.push_back(kVp8Codec); |
| 1452 | codecs[0].id = 99; |
| 1453 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1454 | } |
| 1455 | |
pbos@webrtc.org | ccbed3b | 2014-07-11 13:02:54 +0000 | [diff] [blame] | 1456 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) { |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1457 | EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); |
pbos@webrtc.org | ccbed3b | 2014-07-11 13:02:54 +0000 | [diff] [blame] | 1458 | |
| 1459 | FakeVideoReceiveStream* stream = AddRecvStream(); |
| 1460 | webrtc::VideoReceiveStream::Config config = stream->GetConfig(); |
| 1461 | EXPECT_STREQ(engine_.codecs()[0].name.c_str(), config.codecs[0].plName); |
| 1462 | EXPECT_EQ(engine_.codecs()[0].id, config.codecs[0].plType); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1463 | } |
| 1464 | |
| 1465 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) { |
| 1466 | std::vector<VideoCodec> codecs; |
| 1467 | codecs.push_back(kVp8Codec); |
| 1468 | codecs.push_back(VideoCodec(101, "WTF3", 640, 400, 30, 0)); |
| 1469 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 1470 | } |
| 1471 | |
| 1472 | // TODO(pbos): Enable VP9 through external codec support |
| 1473 | TEST_F(WebRtcVideoChannel2Test, |
| 1474 | DISABLED_SetRecvCodecsAcceptsMultipleVideoCodecs) { |
| 1475 | std::vector<VideoCodec> codecs; |
| 1476 | codecs.push_back(kVp8Codec); |
| 1477 | codecs.push_back(kVp9Codec); |
| 1478 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1479 | } |
| 1480 | |
| 1481 | TEST_F(WebRtcVideoChannel2Test, |
| 1482 | DISABLED_SetRecvCodecsSetsFecForAllVideoCodecs) { |
| 1483 | std::vector<VideoCodec> codecs; |
| 1484 | codecs.push_back(kVp8Codec); |
| 1485 | codecs.push_back(kVp9Codec); |
| 1486 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1487 | FAIL(); // TODO(pbos): Verify that the FEC parameters are set for all codecs. |
| 1488 | } |
| 1489 | |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 1490 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithoutFecDisablesFec) { |
| 1491 | std::vector<VideoCodec> codecs; |
| 1492 | codecs.push_back(kVp8Codec); |
| 1493 | codecs.push_back(kUlpfecCodec); |
| 1494 | ASSERT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1495 | |
| 1496 | FakeVideoReceiveStream* stream = AddRecvStream(); |
| 1497 | webrtc::VideoReceiveStream::Config config = stream->GetConfig(); |
| 1498 | |
| 1499 | EXPECT_EQ(kUlpfecCodec.id, config.rtp.fec.ulpfec_payload_type); |
| 1500 | |
| 1501 | codecs.pop_back(); |
| 1502 | ASSERT_TRUE(channel_->SetRecvCodecs(codecs)); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1503 | stream = fake_call_->GetVideoReceiveStreams()[0]; |
pbos@webrtc.org | d1ea06b | 2014-07-18 09:35:58 +0000 | [diff] [blame] | 1504 | ASSERT_TRUE(stream != NULL); |
| 1505 | config = stream->GetConfig(); |
| 1506 | EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type) |
| 1507 | << "SetSendCodec without FEC should disable current FEC."; |
pbos@webrtc.org | 269605c | 2014-06-26 08:49:03 +0000 | [diff] [blame] | 1508 | } |
| 1509 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1510 | TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectDuplicateFecPayloads) { |
| 1511 | std::vector<VideoCodec> codecs; |
| 1512 | codecs.push_back(kVp8Codec); |
| 1513 | codecs.push_back(kRedCodec); |
| 1514 | codecs[1].id = codecs[0].id; |
| 1515 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 1516 | } |
| 1517 | |
| 1518 | TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectDuplicateCodecPayloads) { |
| 1519 | std::vector<VideoCodec> codecs; |
| 1520 | codecs.push_back(kVp8Codec); |
| 1521 | codecs.push_back(kVp9Codec); |
| 1522 | codecs[1].id = codecs[0].id; |
| 1523 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 1524 | } |
| 1525 | |
| 1526 | TEST_F(WebRtcVideoChannel2Test, |
| 1527 | SetRecvCodecsAcceptSameCodecOnMultiplePayloadTypes) { |
| 1528 | std::vector<VideoCodec> codecs; |
| 1529 | codecs.push_back(kVp8Codec); |
| 1530 | codecs.push_back(kVp8Codec); |
| 1531 | codecs[1].id += 1; |
| 1532 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1533 | } |
| 1534 | |
| 1535 | TEST_F(WebRtcVideoChannel2Test, SendStreamNotSendingByDefault) { |
| 1536 | EXPECT_FALSE(AddSendStream()->IsSending()); |
| 1537 | } |
| 1538 | |
pbos@webrtc.org | 85f4294 | 2014-07-22 09:14:58 +0000 | [diff] [blame] | 1539 | TEST_F(WebRtcVideoChannel2Test, ReceiveStreamReceivingByDefault) { |
| 1540 | EXPECT_TRUE(AddRecvStream()->IsReceiving()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1541 | } |
| 1542 | |
| 1543 | TEST_F(WebRtcVideoChannel2Test, SetSend) { |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 1544 | FakeVideoSendStream* stream = AddSendStream(); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1545 | EXPECT_FALSE(stream->IsSending()); |
| 1546 | |
| 1547 | // false->true |
| 1548 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1549 | EXPECT_TRUE(stream->IsSending()); |
| 1550 | // true->true |
| 1551 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1552 | EXPECT_TRUE(stream->IsSending()); |
| 1553 | // true->false |
| 1554 | EXPECT_TRUE(channel_->SetSend(false)); |
| 1555 | EXPECT_FALSE(stream->IsSending()); |
| 1556 | // false->false |
| 1557 | EXPECT_TRUE(channel_->SetSend(false)); |
| 1558 | EXPECT_FALSE(stream->IsSending()); |
| 1559 | |
| 1560 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1561 | FakeVideoSendStream* new_stream = AddSendStream(); |
| 1562 | EXPECT_TRUE(new_stream->IsSending()) |
| 1563 | << "Send stream created after SetSend(true) not sending initially."; |
| 1564 | } |
| 1565 | |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1566 | TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetDscpOptions) { |
| 1567 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1568 | } |
| 1569 | |
| 1570 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsWithMaxBitrate) { |
| 1571 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1572 | } |
| 1573 | |
| 1574 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsWithLoweredBitrate) { |
| 1575 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1576 | } |
| 1577 | |
| 1578 | TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsSucceedsWhenSending) { |
| 1579 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1580 | } |
| 1581 | |
| 1582 | TEST_F(WebRtcVideoChannel2Test, DISABLED_ResetCodecOnScreencast) { |
| 1583 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1584 | } |
| 1585 | |
| 1586 | TEST_F(WebRtcVideoChannel2Test, DISABLED_DontResetCodecOnSendFrame) { |
| 1587 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1588 | } |
| 1589 | |
| 1590 | TEST_F(WebRtcVideoChannel2Test, |
| 1591 | DISABLED_DontRegisterDecoderIfFactoryIsNotGiven) { |
| 1592 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1593 | } |
| 1594 | |
| 1595 | TEST_F(WebRtcVideoChannel2Test, DISABLED_RegisterDecoderIfFactoryIsGiven) { |
| 1596 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1597 | } |
| 1598 | |
| 1599 | TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterDecoderMultipleTimes) { |
| 1600 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1601 | } |
| 1602 | |
| 1603 | TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterDecoderForNonVP8) { |
| 1604 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1605 | } |
| 1606 | |
| 1607 | TEST_F(WebRtcVideoChannel2Test, |
| 1608 | DISABLED_DontRegisterEncoderIfFactoryIsNotGiven) { |
| 1609 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1610 | } |
| 1611 | |
| 1612 | TEST_F(WebRtcVideoChannel2Test, DISABLED_RegisterEncoderIfFactoryIsGiven) { |
| 1613 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1614 | } |
| 1615 | |
| 1616 | TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterEncoderMultipleTimes) { |
| 1617 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1618 | } |
| 1619 | |
| 1620 | TEST_F(WebRtcVideoChannel2Test, |
| 1621 | DISABLED_RegisterEncoderWithMultipleSendStreams) { |
| 1622 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1623 | } |
| 1624 | |
| 1625 | TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterEncoderForNonVP8) { |
| 1626 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1627 | } |
| 1628 | |
| 1629 | TEST_F(WebRtcVideoChannel2Test, DISABLED_FeedbackParamsForNonVP8) { |
| 1630 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1631 | } |
| 1632 | |
| 1633 | TEST_F(WebRtcVideoChannel2Test, DISABLED_ExternalCodecAddedToTheEnd) { |
| 1634 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1635 | } |
| 1636 | |
| 1637 | TEST_F(WebRtcVideoChannel2Test, DISABLED_ExternalCodecIgnored) { |
| 1638 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1639 | } |
| 1640 | |
| 1641 | TEST_F(WebRtcVideoChannel2Test, DISABLED_UpdateEncoderCodecsAfterSetFactory) { |
| 1642 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1643 | } |
| 1644 | |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 1645 | TEST_F(WebRtcVideoChannel2Test, OnReadyToSendSignalsNetworkState) { |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1646 | EXPECT_EQ(webrtc::Call::kNetworkUp, fake_call_->GetNetworkState()); |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 1647 | |
| 1648 | channel_->OnReadyToSend(false); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1649 | EXPECT_EQ(webrtc::Call::kNetworkDown, fake_call_->GetNetworkState()); |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 1650 | |
| 1651 | channel_->OnReadyToSend(true); |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame^] | 1652 | EXPECT_EQ(webrtc::Call::kNetworkUp, fake_call_->GetNetworkState()); |
pbos@webrtc.org | b5a22b1 | 2014-05-13 11:07:01 +0000 | [diff] [blame] | 1653 | } |
| 1654 | |
| 1655 | TEST_F(WebRtcVideoChannel2Test, DISABLED_CaptureFrameTimestampToNtpTimestamp) { |
| 1656 | FAIL() << "Not implemented."; // TODO(pbos): Implement. |
| 1657 | } |
| 1658 | } // namespace cricket |