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