henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +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 "talk/base/fakecpumonitor.h" |
| 29 | #include "talk/base/gunit.h" |
| 30 | #include "talk/base/logging.h" |
| 31 | #include "talk/base/scoped_ptr.h" |
| 32 | #include "talk/base/stream.h" |
| 33 | #include "talk/media/base/constants.h" |
| 34 | #include "talk/media/base/fakemediaprocessor.h" |
| 35 | #include "talk/media/base/fakenetworkinterface.h" |
| 36 | #include "talk/media/base/fakevideorenderer.h" |
| 37 | #include "talk/media/base/mediachannel.h" |
| 38 | #include "talk/media/base/testutils.h" |
mallinath@webrtc.org | 67ee6b9 | 2014-02-03 16:57:16 +0000 | [diff] [blame] | 39 | #include "talk/media/base/videoadapter.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 40 | #include "talk/media/base/videoengine_unittest.h" |
| 41 | #include "talk/media/webrtc/fakewebrtcvideocapturemodule.h" |
| 42 | #include "talk/media/webrtc/fakewebrtcvideoengine.h" |
| 43 | #include "talk/media/webrtc/fakewebrtcvoiceengine.h" |
| 44 | #include "talk/media/webrtc/webrtcvideocapturer.h" |
| 45 | #include "talk/media/webrtc/webrtcvideoengine.h" |
| 46 | #include "talk/media/webrtc/webrtcvideoframe.h" |
| 47 | #include "talk/media/webrtc/webrtcvoiceengine.h" |
| 48 | #include "talk/session/media/mediasession.h" |
| 49 | #include "webrtc/system_wrappers/interface/trace.h" |
| 50 | |
| 51 | // Tests for the WebRtcVideoEngine/VideoChannel code. |
| 52 | |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame^] | 53 | using cricket::kRtpTimestampOffsetHeaderExtension; |
| 54 | using cricket::kRtpAbsoluteSenderTimeHeaderExtension; |
| 55 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 56 | static const cricket::VideoCodec kVP8Codec720p(100, "VP8", 1280, 720, 30, 0); |
| 57 | static const cricket::VideoCodec kVP8Codec360p(100, "VP8", 640, 360, 30, 0); |
| 58 | static const cricket::VideoCodec kVP8Codec270p(100, "VP8", 480, 270, 30, 0); |
| 59 | static const cricket::VideoCodec kVP8Codec180p(100, "VP8", 320, 180, 30, 0); |
| 60 | |
| 61 | static const cricket::VideoCodec kVP8Codec(100, "VP8", 640, 400, 30, 0); |
| 62 | static const cricket::VideoCodec kRedCodec(101, "red", 0, 0, 0, 0); |
| 63 | static const cricket::VideoCodec kUlpFecCodec(102, "ulpfec", 0, 0, 0, 0); |
| 64 | static const cricket::VideoCodec* const kVideoCodecs[] = { |
| 65 | &kVP8Codec, |
| 66 | &kRedCodec, |
| 67 | &kUlpFecCodec |
| 68 | }; |
| 69 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 70 | static const unsigned int kStartBandwidthKbps = 300; |
wu@webrtc.org | 1e6cb2c | 2014-03-24 17:01:50 +0000 | [diff] [blame] | 71 | static const unsigned int kMinBandwidthKbps = 50; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 72 | static const unsigned int kMaxBandwidthKbps = 2000; |
| 73 | |
| 74 | static const unsigned int kNumberOfTemporalLayers = 1; |
| 75 | |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 76 | static const uint32 kSsrcs1[] = {1}; |
| 77 | static const uint32 kSsrcs2[] = {1, 2}; |
| 78 | static const uint32 kSsrcs3[] = {1, 2, 3}; |
| 79 | static const uint32 kRtxSsrc1[] = {4}; |
| 80 | static const uint32 kRtxSsrcs3[] = {4, 5, 6}; |
| 81 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 82 | |
| 83 | class FakeViEWrapper : public cricket::ViEWrapper { |
| 84 | public: |
| 85 | explicit FakeViEWrapper(cricket::FakeWebRtcVideoEngine* engine) |
| 86 | : cricket::ViEWrapper(engine, // base |
| 87 | engine, // codec |
| 88 | engine, // capture |
| 89 | engine, // network |
| 90 | engine, // render |
| 91 | engine, // rtp |
| 92 | engine, // image |
| 93 | engine) { // external decoder |
| 94 | } |
| 95 | }; |
| 96 | |
| 97 | // Test fixture to test WebRtcVideoEngine with a fake webrtc::VideoEngine. |
| 98 | // Useful for testing failure paths. |
wu@webrtc.org | cadf904 | 2013-08-30 21:24:16 +0000 | [diff] [blame] | 99 | class WebRtcVideoEngineTestFake : public testing::Test, |
wu@webrtc.org | d64719d | 2013-08-01 00:00:07 +0000 | [diff] [blame] | 100 | public sigslot::has_slots<> { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 101 | public: |
| 102 | WebRtcVideoEngineTestFake() |
| 103 | : vie_(kVideoCodecs, ARRAY_SIZE(kVideoCodecs)), |
| 104 | cpu_monitor_(new talk_base::FakeCpuMonitor( |
| 105 | talk_base::Thread::Current())), |
| 106 | engine_(NULL, // cricket::WebRtcVoiceEngine |
| 107 | new FakeViEWrapper(&vie_), cpu_monitor_), |
| 108 | channel_(NULL), |
wu@webrtc.org | d64719d | 2013-08-01 00:00:07 +0000 | [diff] [blame] | 109 | voice_channel_(NULL), |
| 110 | last_error_(cricket::VideoMediaChannel::ERROR_NONE) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 111 | } |
| 112 | bool SetupEngine() { |
| 113 | bool result = engine_.Init(talk_base::Thread::Current()); |
| 114 | if (result) { |
| 115 | channel_ = engine_.CreateChannel(voice_channel_); |
wu@webrtc.org | d64719d | 2013-08-01 00:00:07 +0000 | [diff] [blame] | 116 | channel_->SignalMediaError.connect(this, |
| 117 | &WebRtcVideoEngineTestFake::OnMediaError); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 118 | result = (channel_ != NULL); |
| 119 | } |
| 120 | return result; |
| 121 | } |
wu@webrtc.org | d64719d | 2013-08-01 00:00:07 +0000 | [diff] [blame] | 122 | void OnMediaError(uint32 ssrc, cricket::VideoMediaChannel::Error error) { |
| 123 | last_error_ = error; |
| 124 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 125 | bool SendI420Frame(int width, int height) { |
| 126 | if (NULL == channel_) { |
| 127 | return false; |
| 128 | } |
| 129 | cricket::WebRtcVideoFrame frame; |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 130 | if (!frame.InitToBlack(width, height, 1, 1, 0, 0)) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 131 | return false; |
| 132 | } |
| 133 | cricket::FakeVideoCapturer capturer; |
wu@webrtc.org | f7d501d | 2014-03-27 23:48:25 +0000 | [diff] [blame] | 134 | channel_->SendFrame(&capturer, &frame); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 135 | return true; |
| 136 | } |
| 137 | bool SendI420ScreencastFrame(int width, int height) { |
| 138 | return SendI420ScreencastFrameWithTimestamp(width, height, 0); |
| 139 | } |
| 140 | bool SendI420ScreencastFrameWithTimestamp( |
| 141 | int width, int height, int64 timestamp) { |
| 142 | if (NULL == channel_) { |
| 143 | return false; |
| 144 | } |
| 145 | cricket::WebRtcVideoFrame frame; |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 146 | if (!frame.InitToBlack(width, height, 1, 1, 0, 0)) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 147 | return false; |
| 148 | } |
| 149 | cricket::FakeVideoCapturer capturer; |
| 150 | capturer.SetScreencast(true); |
wu@webrtc.org | f7d501d | 2014-03-27 23:48:25 +0000 | [diff] [blame] | 151 | channel_->SendFrame(&capturer, &frame); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 152 | return true; |
| 153 | } |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame^] | 154 | void TestSetSendRtpHeaderExtensions(const std::string& ext) { |
| 155 | EXPECT_TRUE(SetupEngine()); |
| 156 | int channel_num = vie_.GetLastChannel(); |
| 157 | |
| 158 | // Verify extensions are off by default. |
| 159 | EXPECT_EQ(-1, vie_.GetSendRtpExtensionId(channel_num, ext)); |
| 160 | |
| 161 | // Enable extension. |
| 162 | const int id = 1; |
| 163 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 164 | extensions.push_back(cricket::RtpHeaderExtension(ext, id)); |
| 165 | |
| 166 | // Verify the send extension id. |
| 167 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 168 | EXPECT_EQ(id, vie_.GetSendRtpExtensionId(channel_num, ext)); |
| 169 | // Verify call with same set of extensions returns true. |
| 170 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 171 | EXPECT_EQ(id, vie_.GetSendRtpExtensionId(channel_num, ext)); |
| 172 | |
| 173 | // Add a new send stream and verify the extension is set. |
| 174 | // The first send stream to occupy the default channel. |
| 175 | EXPECT_TRUE( |
| 176 | channel_->AddSendStream(cricket::StreamParams::CreateLegacy(123))); |
| 177 | EXPECT_TRUE( |
| 178 | channel_->AddSendStream(cricket::StreamParams::CreateLegacy(234))); |
| 179 | int new_send_channel_num = vie_.GetLastChannel(); |
| 180 | EXPECT_NE(channel_num, new_send_channel_num); |
| 181 | EXPECT_EQ(id, vie_.GetSendRtpExtensionId(new_send_channel_num, ext)); |
| 182 | |
| 183 | // Remove the extension id. |
| 184 | std::vector<cricket::RtpHeaderExtension> empty_extensions; |
| 185 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions)); |
| 186 | EXPECT_EQ(-1, vie_.GetSendRtpExtensionId(channel_num, ext)); |
| 187 | EXPECT_EQ(-1, vie_.GetSendRtpExtensionId(new_send_channel_num, ext)); |
| 188 | } |
| 189 | void TestSetRecvRtpHeaderExtensions(const std::string& ext) { |
| 190 | EXPECT_TRUE(SetupEngine()); |
| 191 | int channel_num = vie_.GetLastChannel(); |
| 192 | |
| 193 | // Verify extensions are off by default. |
| 194 | EXPECT_EQ(-1, vie_.GetReceiveRtpExtensionId(channel_num, ext)); |
| 195 | |
| 196 | // Enable extension. |
| 197 | const int id = 2; |
| 198 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 199 | extensions.push_back(cricket::RtpHeaderExtension(ext, id)); |
| 200 | |
| 201 | // Verify receive extension id. |
| 202 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 203 | EXPECT_EQ(id, vie_.GetReceiveRtpExtensionId(channel_num, ext)); |
| 204 | // Verify call with same set of extensions returns true. |
| 205 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 206 | EXPECT_EQ(id, vie_.GetReceiveRtpExtensionId(channel_num, ext)); |
| 207 | |
| 208 | // Add a new receive stream and verify the extension is set. |
| 209 | // The first send stream to occupy the default channel. |
| 210 | EXPECT_TRUE( |
| 211 | channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(345))); |
| 212 | EXPECT_TRUE( |
| 213 | channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(456))); |
| 214 | int new_recv_channel_num = vie_.GetLastChannel(); |
| 215 | EXPECT_NE(channel_num, new_recv_channel_num); |
| 216 | EXPECT_EQ(id, vie_.GetReceiveRtpExtensionId(new_recv_channel_num, ext)); |
| 217 | |
| 218 | // Remove the extension id. |
| 219 | std::vector<cricket::RtpHeaderExtension> empty_extensions; |
| 220 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(empty_extensions)); |
| 221 | EXPECT_EQ(-1, vie_.GetReceiveRtpExtensionId(channel_num, ext)); |
| 222 | EXPECT_EQ(-1, vie_.GetReceiveRtpExtensionId(new_recv_channel_num, ext)); |
| 223 | } |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 224 | void VerifyCodecFeedbackParams(const cricket::VideoCodec& codec) { |
| 225 | EXPECT_TRUE(codec.HasFeedbackParam( |
| 226 | cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
| 227 | cricket::kParamValueEmpty))); |
| 228 | EXPECT_TRUE(codec.HasFeedbackParam( |
| 229 | cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
| 230 | cricket::kRtcpFbNackParamPli))); |
| 231 | EXPECT_TRUE(codec.HasFeedbackParam( |
| 232 | cricket::FeedbackParam(cricket::kRtcpFbParamRemb, |
| 233 | cricket::kParamValueEmpty))); |
| 234 | EXPECT_TRUE(codec.HasFeedbackParam( |
| 235 | cricket::FeedbackParam(cricket::kRtcpFbParamCcm, |
| 236 | cricket::kRtcpFbCcmParamFir))); |
| 237 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 238 | void VerifyVP8SendCodec(int channel_num, |
| 239 | unsigned int width, |
| 240 | unsigned int height, |
| 241 | unsigned int layers = 0, |
| 242 | unsigned int max_bitrate = kMaxBandwidthKbps, |
| 243 | unsigned int min_bitrate = kMinBandwidthKbps, |
| 244 | unsigned int start_bitrate = kStartBandwidthKbps, |
| 245 | unsigned int fps = 30, |
| 246 | unsigned int max_quantization = 0 |
| 247 | ) { |
| 248 | webrtc::VideoCodec gcodec; |
| 249 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec)); |
| 250 | |
| 251 | // Video codec properties. |
| 252 | EXPECT_EQ(webrtc::kVideoCodecVP8, gcodec.codecType); |
| 253 | EXPECT_STREQ("VP8", gcodec.plName); |
| 254 | EXPECT_EQ(100, gcodec.plType); |
| 255 | EXPECT_EQ(width, gcodec.width); |
| 256 | EXPECT_EQ(height, gcodec.height); |
| 257 | EXPECT_EQ(talk_base::_min(start_bitrate, max_bitrate), gcodec.startBitrate); |
| 258 | EXPECT_EQ(max_bitrate, gcodec.maxBitrate); |
| 259 | EXPECT_EQ(min_bitrate, gcodec.minBitrate); |
| 260 | EXPECT_EQ(fps, gcodec.maxFramerate); |
| 261 | // VP8 specific. |
| 262 | EXPECT_FALSE(gcodec.codecSpecific.VP8.pictureLossIndicationOn); |
| 263 | EXPECT_FALSE(gcodec.codecSpecific.VP8.feedbackModeOn); |
| 264 | EXPECT_EQ(webrtc::kComplexityNormal, gcodec.codecSpecific.VP8.complexity); |
| 265 | EXPECT_EQ(webrtc::kResilienceOff, gcodec.codecSpecific.VP8.resilience); |
| 266 | EXPECT_EQ(max_quantization, gcodec.qpMax); |
| 267 | } |
| 268 | virtual void TearDown() { |
| 269 | delete channel_; |
| 270 | engine_.Terminate(); |
| 271 | } |
| 272 | |
| 273 | protected: |
| 274 | cricket::FakeWebRtcVideoEngine vie_; |
| 275 | cricket::FakeWebRtcVideoDecoderFactory decoder_factory_; |
| 276 | cricket::FakeWebRtcVideoEncoderFactory encoder_factory_; |
| 277 | talk_base::FakeCpuMonitor* cpu_monitor_; |
| 278 | cricket::WebRtcVideoEngine engine_; |
| 279 | cricket::WebRtcVideoMediaChannel* channel_; |
| 280 | cricket::WebRtcVoiceMediaChannel* voice_channel_; |
wu@webrtc.org | d64719d | 2013-08-01 00:00:07 +0000 | [diff] [blame] | 281 | cricket::VideoMediaChannel::Error last_error_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 282 | }; |
| 283 | |
| 284 | // Test fixtures to test WebRtcVideoEngine with a real webrtc::VideoEngine. |
| 285 | class WebRtcVideoEngineTest |
| 286 | : public VideoEngineTest<cricket::WebRtcVideoEngine> { |
| 287 | protected: |
| 288 | typedef VideoEngineTest<cricket::WebRtcVideoEngine> Base; |
| 289 | }; |
| 290 | class WebRtcVideoMediaChannelTest |
| 291 | : public VideoMediaChannelTest< |
| 292 | cricket::WebRtcVideoEngine, cricket::WebRtcVideoMediaChannel> { |
| 293 | protected: |
| 294 | typedef VideoMediaChannelTest<cricket::WebRtcVideoEngine, |
| 295 | cricket::WebRtcVideoMediaChannel> Base; |
| 296 | virtual cricket::VideoCodec DefaultCodec() { return kVP8Codec; } |
| 297 | virtual void SetUp() { |
| 298 | Base::SetUp(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 299 | } |
| 300 | virtual void TearDown() { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 301 | Base::TearDown(); |
| 302 | } |
| 303 | }; |
| 304 | |
| 305 | ///////////////////////// |
| 306 | // Tests with fake ViE // |
| 307 | ///////////////////////// |
| 308 | |
| 309 | // Tests that our stub library "works". |
| 310 | TEST_F(WebRtcVideoEngineTestFake, StartupShutdown) { |
| 311 | EXPECT_FALSE(vie_.IsInited()); |
| 312 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 313 | EXPECT_TRUE(vie_.IsInited()); |
| 314 | engine_.Terminate(); |
| 315 | } |
| 316 | |
| 317 | // Tests that webrtc logs are logged when they should be. |
| 318 | TEST_F(WebRtcVideoEngineTest, WebRtcShouldLog) { |
| 319 | const char webrtc_log[] = "WebRtcVideoEngineTest.WebRtcShouldLog"; |
| 320 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 321 | engine_.SetLogging(talk_base::LS_INFO, ""); |
| 322 | std::string str; |
| 323 | talk_base::StringStream stream(str); |
| 324 | talk_base::LogMessage::AddLogToStream(&stream, talk_base::LS_INFO); |
| 325 | EXPECT_EQ(talk_base::LS_INFO, talk_base::LogMessage::GetLogToStream(&stream)); |
| 326 | webrtc::Trace::Add(webrtc::kTraceStateInfo, webrtc::kTraceUndefined, 0, |
| 327 | webrtc_log); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 328 | talk_base::Thread::Current()->ProcessMessages(100); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 329 | talk_base::LogMessage::RemoveLogToStream(&stream); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 330 | // Access |str| after LogMessage is done with it to avoid data racing. |
| 331 | EXPECT_NE(std::string::npos, str.find(webrtc_log)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | // Tests that webrtc logs are not logged when they should't be. |
| 335 | TEST_F(WebRtcVideoEngineTest, WebRtcShouldNotLog) { |
| 336 | const char webrtc_log[] = "WebRtcVideoEngineTest.WebRtcShouldNotLog"; |
| 337 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 338 | // WebRTC should never be logged lower than LS_INFO. |
| 339 | engine_.SetLogging(talk_base::LS_WARNING, ""); |
| 340 | std::string str; |
| 341 | talk_base::StringStream stream(str); |
| 342 | // Make sure that WebRTC is not logged, even at lowest severity |
| 343 | talk_base::LogMessage::AddLogToStream(&stream, talk_base::LS_SENSITIVE); |
| 344 | EXPECT_EQ(talk_base::LS_SENSITIVE, |
| 345 | talk_base::LogMessage::GetLogToStream(&stream)); |
| 346 | webrtc::Trace::Add(webrtc::kTraceStateInfo, webrtc::kTraceUndefined, 0, |
| 347 | webrtc_log); |
| 348 | talk_base::Thread::Current()->ProcessMessages(10); |
| 349 | EXPECT_EQ(std::string::npos, str.find(webrtc_log)); |
| 350 | talk_base::LogMessage::RemoveLogToStream(&stream); |
| 351 | } |
| 352 | |
| 353 | // Tests that we can create and destroy a channel. |
| 354 | TEST_F(WebRtcVideoEngineTestFake, CreateChannel) { |
| 355 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 356 | channel_ = engine_.CreateChannel(voice_channel_); |
| 357 | EXPECT_TRUE(channel_ != NULL); |
| 358 | EXPECT_EQ(1, engine_.GetNumOfChannels()); |
| 359 | delete channel_; |
| 360 | channel_ = NULL; |
| 361 | EXPECT_EQ(0, engine_.GetNumOfChannels()); |
| 362 | } |
| 363 | |
| 364 | // Tests that we properly handle failures in CreateChannel. |
| 365 | TEST_F(WebRtcVideoEngineTestFake, CreateChannelFail) { |
| 366 | vie_.set_fail_create_channel(true); |
| 367 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 368 | channel_ = engine_.CreateChannel(voice_channel_); |
| 369 | EXPECT_TRUE(channel_ == NULL); |
| 370 | } |
| 371 | |
| 372 | // Tests that we properly handle failures in AllocateExternalCaptureDevice. |
| 373 | TEST_F(WebRtcVideoEngineTestFake, AllocateExternalCaptureDeviceFail) { |
| 374 | vie_.set_fail_alloc_capturer(true); |
| 375 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 376 | channel_ = engine_.CreateChannel(voice_channel_); |
| 377 | EXPECT_TRUE(channel_ == NULL); |
| 378 | } |
| 379 | |
| 380 | // Test that we apply our default codecs properly. |
| 381 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecs) { |
| 382 | EXPECT_TRUE(SetupEngine()); |
| 383 | int channel_num = vie_.GetLastChannel(); |
| 384 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 385 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 386 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height); |
| 387 | EXPECT_TRUE(vie_.GetHybridNackFecStatus(channel_num)); |
| 388 | EXPECT_FALSE(vie_.GetNackStatus(channel_num)); |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 389 | EXPECT_EQ(1, vie_.GetNumSetSendCodecs()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 390 | // TODO(juberti): Check RTCP, PLI, TMMBR. |
| 391 | } |
| 392 | |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 393 | // Test that ViE Channel doesn't call SetSendCodec again if same codec is tried |
| 394 | // to apply. |
| 395 | TEST_F(WebRtcVideoEngineTestFake, DontResetSetSendCodec) { |
| 396 | EXPECT_TRUE(SetupEngine()); |
| 397 | int channel_num = vie_.GetLastChannel(); |
| 398 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 399 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 400 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height); |
| 401 | EXPECT_TRUE(vie_.GetHybridNackFecStatus(channel_num)); |
| 402 | EXPECT_FALSE(vie_.GetNackStatus(channel_num)); |
| 403 | EXPECT_EQ(1, vie_.GetNumSetSendCodecs()); |
| 404 | // Try setting same code again. |
| 405 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 406 | // Since it's exact same codec which is already set, media channel shouldn't |
| 407 | // send the codec to ViE. |
| 408 | EXPECT_EQ(1, vie_.GetNumSetSendCodecs()); |
| 409 | } |
| 410 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 411 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithMinMaxBitrate) { |
| 412 | EXPECT_TRUE(SetupEngine()); |
| 413 | int channel_num = vie_.GetLastChannel(); |
| 414 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 415 | codecs[0].params[cricket::kCodecParamMinBitrate] = "10"; |
| 416 | codecs[0].params[cricket::kCodecParamMaxBitrate] = "20"; |
| 417 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 418 | |
| 419 | VerifyVP8SendCodec( |
| 420 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20); |
| 421 | |
| 422 | cricket::VideoCodec codec; |
| 423 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
| 424 | EXPECT_EQ("10", codec.params[cricket::kCodecParamMinBitrate]); |
| 425 | EXPECT_EQ("20", codec.params[cricket::kCodecParamMaxBitrate]); |
| 426 | } |
| 427 | |
| 428 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithMinMaxBitrateInvalid) { |
| 429 | EXPECT_TRUE(SetupEngine()); |
| 430 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 431 | codecs[0].params[cricket::kCodecParamMinBitrate] = "30"; |
| 432 | codecs[0].params[cricket::kCodecParamMaxBitrate] = "20"; |
| 433 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)); |
| 434 | } |
| 435 | |
| 436 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithLargeMinMaxBitrate) { |
| 437 | EXPECT_TRUE(SetupEngine()); |
| 438 | int channel_num = vie_.GetLastChannel(); |
| 439 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 440 | codecs[0].params[cricket::kCodecParamMinBitrate] = "1000"; |
| 441 | codecs[0].params[cricket::kCodecParamMaxBitrate] = "2000"; |
| 442 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 443 | |
| 444 | VerifyVP8SendCodec( |
| 445 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 2000, 1000, |
| 446 | 1000); |
| 447 | } |
| 448 | |
| 449 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithMaxQuantization) { |
| 450 | EXPECT_TRUE(SetupEngine()); |
| 451 | int channel_num = vie_.GetLastChannel(); |
| 452 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 453 | codecs[0].params[cricket::kCodecParamMaxQuantization] = "21"; |
| 454 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 455 | |
| 456 | VerifyVP8SendCodec( |
| 457 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 2000, 50, 300, |
| 458 | 30, 21); |
| 459 | |
| 460 | cricket::VideoCodec codec; |
| 461 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
| 462 | EXPECT_EQ("21", codec.params[cricket::kCodecParamMaxQuantization]); |
| 463 | } |
| 464 | |
| 465 | TEST_F(WebRtcVideoEngineTestFake, SetOptionsWithMaxBitrate) { |
| 466 | EXPECT_TRUE(SetupEngine()); |
| 467 | int channel_num = vie_.GetLastChannel(); |
| 468 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 469 | codecs[0].params[cricket::kCodecParamMinBitrate] = "10"; |
| 470 | codecs[0].params[cricket::kCodecParamMaxBitrate] = "20"; |
| 471 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 472 | |
| 473 | VerifyVP8SendCodec( |
| 474 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20); |
| 475 | |
| 476 | // Verify that max bitrate doesn't change after SetOptions(). |
| 477 | cricket::VideoOptions options; |
| 478 | options.video_noise_reduction.Set(true); |
| 479 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 480 | VerifyVP8SendCodec( |
| 481 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20); |
| 482 | |
| 483 | options.video_noise_reduction.Set(false); |
| 484 | options.conference_mode.Set(false); |
| 485 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 486 | VerifyVP8SendCodec( |
| 487 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20); |
| 488 | } |
| 489 | |
wu@webrtc.org | cecfd18 | 2013-10-30 05:18:12 +0000 | [diff] [blame] | 490 | TEST_F(WebRtcVideoEngineTestFake, SetOptionsWithLoweredBitrate) { |
| 491 | EXPECT_TRUE(SetupEngine()); |
| 492 | int channel_num = vie_.GetLastChannel(); |
| 493 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 494 | codecs[0].params[cricket::kCodecParamMinBitrate] = "50"; |
| 495 | codecs[0].params[cricket::kCodecParamMaxBitrate] = "100"; |
| 496 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 497 | |
| 498 | VerifyVP8SendCodec( |
| 499 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 100, 50, 100); |
| 500 | |
| 501 | // Verify that min bitrate changes after SetOptions(). |
| 502 | cricket::VideoOptions options; |
| 503 | options.lower_min_bitrate.Set(true); |
| 504 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 505 | VerifyVP8SendCodec( |
| 506 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 100, 30, 100); |
| 507 | } |
| 508 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 509 | TEST_F(WebRtcVideoEngineTestFake, MaxBitrateResetWithConferenceMode) { |
| 510 | EXPECT_TRUE(SetupEngine()); |
| 511 | int channel_num = vie_.GetLastChannel(); |
| 512 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 513 | codecs[0].params[cricket::kCodecParamMinBitrate] = "10"; |
| 514 | codecs[0].params[cricket::kCodecParamMaxBitrate] = "20"; |
| 515 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 516 | |
| 517 | VerifyVP8SendCodec( |
| 518 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20); |
| 519 | |
| 520 | cricket::VideoOptions options; |
| 521 | options.conference_mode.Set(true); |
| 522 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 523 | options.conference_mode.Set(false); |
| 524 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 525 | VerifyVP8SendCodec( |
| 526 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
| 527 | kMaxBandwidthKbps, 10, 20); |
| 528 | } |
| 529 | |
| 530 | // Verify the current send bitrate is used as start bitrate when reconfiguring |
| 531 | // the send codec. |
| 532 | TEST_F(WebRtcVideoEngineTestFake, StartSendBitrate) { |
| 533 | EXPECT_TRUE(SetupEngine()); |
| 534 | EXPECT_TRUE(channel_->AddSendStream( |
| 535 | cricket::StreamParams::CreateLegacy(1))); |
| 536 | int send_channel = vie_.GetLastChannel(); |
| 537 | cricket::VideoCodec codec(kVP8Codec); |
| 538 | std::vector<cricket::VideoCodec> codec_list; |
| 539 | codec_list.push_back(codec); |
| 540 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 541 | const unsigned int kVideoMaxSendBitrateKbps = 2000; |
| 542 | const unsigned int kVideoMinSendBitrateKbps = 50; |
| 543 | const unsigned int kVideoDefaultStartSendBitrateKbps = 300; |
| 544 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 545 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 546 | kVideoDefaultStartSendBitrateKbps); |
| 547 | EXPECT_EQ(0, vie_.StartSend(send_channel)); |
| 548 | |
| 549 | // Increase the send bitrate and verify it is used as start bitrate. |
| 550 | const unsigned int kVideoSendBitrateBps = 768000; |
| 551 | vie_.SetSendBitrates(send_channel, kVideoSendBitrateBps, 0, 0); |
| 552 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 553 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 554 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 555 | kVideoSendBitrateBps / 1000); |
| 556 | |
| 557 | // Never set a start bitrate higher than the max bitrate. |
| 558 | vie_.SetSendBitrates(send_channel, kVideoMaxSendBitrateKbps + 500, 0, 0); |
| 559 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 560 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 561 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 562 | kVideoDefaultStartSendBitrateKbps); |
| 563 | |
| 564 | // Use the default start bitrate if the send bitrate is lower. |
| 565 | vie_.SetSendBitrates(send_channel, kVideoDefaultStartSendBitrateKbps - 50, 0, |
| 566 | 0); |
| 567 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 568 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 569 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 570 | kVideoDefaultStartSendBitrateKbps); |
| 571 | } |
| 572 | |
| 573 | |
| 574 | // Test that we constrain send codecs properly. |
| 575 | TEST_F(WebRtcVideoEngineTestFake, ConstrainSendCodecs) { |
| 576 | EXPECT_TRUE(SetupEngine()); |
| 577 | int channel_num = vie_.GetLastChannel(); |
| 578 | |
| 579 | // Set max settings of 640x400x30. |
| 580 | EXPECT_TRUE(engine_.SetDefaultEncoderConfig( |
| 581 | cricket::VideoEncoderConfig(kVP8Codec))); |
| 582 | |
| 583 | // Send codec format bigger than max setting. |
| 584 | cricket::VideoCodec codec(kVP8Codec); |
| 585 | codec.width = 1280; |
| 586 | codec.height = 800; |
| 587 | codec.framerate = 60; |
| 588 | std::vector<cricket::VideoCodec> codec_list; |
| 589 | codec_list.push_back(codec); |
| 590 | |
| 591 | // Set send codec and verify codec has been constrained. |
| 592 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 593 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height); |
| 594 | } |
| 595 | |
| 596 | // Test that SetSendCodecs rejects bad format. |
| 597 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsRejectBadFormat) { |
| 598 | EXPECT_TRUE(SetupEngine()); |
| 599 | int channel_num = vie_.GetLastChannel(); |
| 600 | |
| 601 | // Set w = 0. |
| 602 | cricket::VideoCodec codec(kVP8Codec); |
| 603 | codec.width = 0; |
| 604 | std::vector<cricket::VideoCodec> codec_list; |
| 605 | codec_list.push_back(codec); |
| 606 | |
| 607 | // Verify SetSendCodecs failed and send codec is not changed on engine. |
| 608 | EXPECT_FALSE(channel_->SetSendCodecs(codec_list)); |
| 609 | webrtc::VideoCodec gcodec; |
| 610 | // Set plType to something other than the value to test against ensuring |
| 611 | // that failure will happen if it is not changed. |
| 612 | gcodec.plType = 1; |
| 613 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec)); |
| 614 | EXPECT_EQ(0, gcodec.plType); |
| 615 | |
| 616 | // Set h = 0. |
| 617 | codec_list[0].width = 640; |
| 618 | codec_list[0].height = 0; |
| 619 | |
| 620 | // Verify SetSendCodecs failed and send codec is not changed on engine. |
| 621 | EXPECT_FALSE(channel_->SetSendCodecs(codec_list)); |
| 622 | // Set plType to something other than the value to test against ensuring |
| 623 | // that failure will happen if it is not changed. |
| 624 | gcodec.plType = 1; |
| 625 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec)); |
| 626 | EXPECT_EQ(0, gcodec.plType); |
| 627 | } |
| 628 | |
| 629 | // Test that SetSendCodecs rejects bad codec. |
| 630 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsRejectBadCodec) { |
| 631 | EXPECT_TRUE(SetupEngine()); |
| 632 | int channel_num = vie_.GetLastChannel(); |
| 633 | |
| 634 | // Set bad codec name. |
| 635 | cricket::VideoCodec codec(kVP8Codec); |
| 636 | codec.name = "bad"; |
| 637 | std::vector<cricket::VideoCodec> codec_list; |
| 638 | codec_list.push_back(codec); |
| 639 | |
| 640 | // Verify SetSendCodecs failed and send codec is not changed on engine. |
| 641 | EXPECT_FALSE(channel_->SetSendCodecs(codec_list)); |
| 642 | webrtc::VideoCodec gcodec; |
| 643 | // Set plType to something other than the value to test against ensuring |
| 644 | // that failure will happen if it is not changed. |
| 645 | gcodec.plType = 1; |
| 646 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec)); |
| 647 | EXPECT_EQ(0, gcodec.plType); |
| 648 | } |
| 649 | |
| 650 | // Test that vie send codec is reset on new video frame size. |
| 651 | TEST_F(WebRtcVideoEngineTestFake, ResetVieSendCodecOnNewFrameSize) { |
| 652 | EXPECT_TRUE(SetupEngine()); |
| 653 | int channel_num = vie_.GetLastChannel(); |
| 654 | |
| 655 | // Set send codec. |
| 656 | std::vector<cricket::VideoCodec> codec_list; |
| 657 | codec_list.push_back(kVP8Codec); |
| 658 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 659 | EXPECT_TRUE(channel_->AddSendStream( |
| 660 | cricket::StreamParams::CreateLegacy(123))); |
| 661 | EXPECT_TRUE(channel_->SetSend(true)); |
| 662 | |
| 663 | // Capture a smaller frame and verify vie send codec has been reset to |
| 664 | // the new size. |
| 665 | SendI420Frame(kVP8Codec.width / 2, kVP8Codec.height / 2); |
| 666 | VerifyVP8SendCodec(channel_num, kVP8Codec.width / 2, kVP8Codec.height / 2); |
| 667 | |
| 668 | // Capture a frame bigger than send_codec_ and verify vie send codec has been |
| 669 | // reset (and clipped) to send_codec_. |
| 670 | SendI420Frame(kVP8Codec.width * 2, kVP8Codec.height * 2); |
| 671 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height); |
| 672 | } |
| 673 | |
| 674 | // Test that we set our inbound codecs properly. |
| 675 | TEST_F(WebRtcVideoEngineTestFake, SetRecvCodecs) { |
| 676 | EXPECT_TRUE(SetupEngine()); |
| 677 | int channel_num = vie_.GetLastChannel(); |
| 678 | |
| 679 | std::vector<cricket::VideoCodec> codecs; |
| 680 | codecs.push_back(kVP8Codec); |
| 681 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 682 | |
| 683 | webrtc::VideoCodec wcodec; |
| 684 | EXPECT_TRUE(engine_.ConvertFromCricketVideoCodec(kVP8Codec, &wcodec)); |
| 685 | EXPECT_TRUE(vie_.ReceiveCodecRegistered(channel_num, wcodec)); |
| 686 | } |
| 687 | |
| 688 | // Test that channel connects and disconnects external capturer correctly. |
| 689 | TEST_F(WebRtcVideoEngineTestFake, HasExternalCapturer) { |
| 690 | EXPECT_TRUE(SetupEngine()); |
| 691 | int channel_num = vie_.GetLastChannel(); |
| 692 | |
| 693 | EXPECT_EQ(1, vie_.GetNumCapturers()); |
| 694 | int capture_id = vie_.GetCaptureId(channel_num); |
| 695 | EXPECT_EQ(channel_num, vie_.GetCaptureChannelId(capture_id)); |
| 696 | |
| 697 | // Delete the channel should disconnect the capturer. |
| 698 | delete channel_; |
| 699 | channel_ = NULL; |
| 700 | EXPECT_EQ(0, vie_.GetNumCapturers()); |
| 701 | } |
| 702 | |
| 703 | // Test that channel adds and removes renderer correctly. |
| 704 | TEST_F(WebRtcVideoEngineTestFake, HasRenderer) { |
| 705 | EXPECT_TRUE(SetupEngine()); |
| 706 | int channel_num = vie_.GetLastChannel(); |
| 707 | |
| 708 | EXPECT_TRUE(vie_.GetHasRenderer(channel_num)); |
| 709 | EXPECT_FALSE(vie_.GetRenderStarted(channel_num)); |
| 710 | } |
| 711 | |
| 712 | // Test that rtcp is enabled on the channel. |
| 713 | TEST_F(WebRtcVideoEngineTestFake, RtcpEnabled) { |
| 714 | EXPECT_TRUE(SetupEngine()); |
| 715 | int channel_num = vie_.GetLastChannel(); |
| 716 | EXPECT_EQ(webrtc::kRtcpCompound_RFC4585, vie_.GetRtcpStatus(channel_num)); |
| 717 | } |
| 718 | |
| 719 | // Test that key frame request method is set on the channel. |
| 720 | TEST_F(WebRtcVideoEngineTestFake, KeyFrameRequestEnabled) { |
| 721 | EXPECT_TRUE(SetupEngine()); |
| 722 | int channel_num = vie_.GetLastChannel(); |
| 723 | EXPECT_EQ(webrtc::kViEKeyFrameRequestPliRtcp, |
| 724 | vie_.GetKeyFrameRequestMethod(channel_num)); |
| 725 | } |
| 726 | |
| 727 | // Test that remb receive and send is enabled for the default channel in a 1:1 |
| 728 | // call. |
| 729 | TEST_F(WebRtcVideoEngineTestFake, RembEnabled) { |
| 730 | EXPECT_TRUE(SetupEngine()); |
| 731 | int channel_num = vie_.GetLastChannel(); |
| 732 | EXPECT_TRUE(channel_->AddSendStream( |
| 733 | cricket::StreamParams::CreateLegacy(1))); |
| 734 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 735 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num)); |
| 736 | EXPECT_TRUE(channel_->SetSend(true)); |
| 737 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num)); |
| 738 | EXPECT_TRUE(vie_.GetRembStatusContribute(channel_num)); |
| 739 | } |
| 740 | |
| 741 | // When in conference mode, test that remb is enabled on a receive channel but |
| 742 | // not for the default channel and that it uses the default channel for sending |
| 743 | // remb packets. |
| 744 | TEST_F(WebRtcVideoEngineTestFake, RembEnabledOnReceiveChannels) { |
| 745 | EXPECT_TRUE(SetupEngine()); |
| 746 | int default_channel = vie_.GetLastChannel(); |
| 747 | cricket::VideoOptions options; |
| 748 | options.conference_mode.Set(true); |
| 749 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 750 | EXPECT_TRUE(channel_->AddSendStream( |
| 751 | cricket::StreamParams::CreateLegacy(1))); |
| 752 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 753 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(default_channel)); |
| 754 | EXPECT_TRUE(vie_.GetRembStatusContribute(default_channel)); |
| 755 | EXPECT_TRUE(channel_->SetSend(true)); |
| 756 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 757 | int new_channel_num = vie_.GetLastChannel(); |
| 758 | EXPECT_NE(default_channel, new_channel_num); |
| 759 | |
| 760 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(default_channel)); |
| 761 | EXPECT_TRUE(vie_.GetRembStatusContribute(default_channel)); |
| 762 | EXPECT_FALSE(vie_.GetRembStatusBwPartition(new_channel_num)); |
| 763 | EXPECT_TRUE(vie_.GetRembStatusContribute(new_channel_num)); |
| 764 | } |
| 765 | |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 766 | TEST_F(WebRtcVideoEngineTestFake, RecvStreamWithRtx) { |
| 767 | EXPECT_TRUE(SetupEngine()); |
| 768 | int default_channel = vie_.GetLastChannel(); |
| 769 | cricket::VideoOptions options; |
| 770 | options.conference_mode.Set(true); |
| 771 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 772 | EXPECT_TRUE(channel_->AddSendStream( |
| 773 | cricket::CreateSimWithRtxStreamParams("cname", |
| 774 | MAKE_VECTOR(kSsrcs3), |
| 775 | MAKE_VECTOR(kRtxSsrcs3)))); |
| 776 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 777 | EXPECT_TRUE(channel_->SetSend(true)); |
| 778 | EXPECT_TRUE(channel_->AddRecvStream( |
| 779 | cricket::CreateSimWithRtxStreamParams("cname", |
| 780 | MAKE_VECTOR(kSsrcs1), |
| 781 | MAKE_VECTOR(kRtxSsrc1)))); |
| 782 | int new_channel_num = vie_.GetLastChannel(); |
| 783 | EXPECT_NE(default_channel, new_channel_num); |
| 784 | EXPECT_EQ(4, vie_.GetRemoteRtxSsrc(new_channel_num)); |
| 785 | } |
| 786 | |
| 787 | TEST_F(WebRtcVideoEngineTestFake, RecvStreamNoRtx) { |
| 788 | EXPECT_TRUE(SetupEngine()); |
| 789 | int default_channel = vie_.GetLastChannel(); |
| 790 | cricket::VideoOptions options; |
| 791 | options.conference_mode.Set(true); |
| 792 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 793 | EXPECT_TRUE(channel_->AddSendStream( |
| 794 | cricket::CreateSimWithRtxStreamParams("cname", |
| 795 | MAKE_VECTOR(kSsrcs3), |
| 796 | MAKE_VECTOR(kRtxSsrcs3)))); |
| 797 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 798 | EXPECT_TRUE(channel_->SetSend(true)); |
| 799 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 800 | int new_channel_num = vie_.GetLastChannel(); |
| 801 | EXPECT_NE(default_channel, new_channel_num); |
| 802 | EXPECT_EQ(-1, vie_.GetRemoteRtxSsrc(new_channel_num)); |
| 803 | } |
| 804 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 805 | // Test support for RTP timestamp offset header extension. |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame^] | 806 | TEST_F(WebRtcVideoEngineTestFake, SendRtpTimestampOffsetHeaderExtensions) { |
| 807 | TestSetSendRtpHeaderExtensions(kRtpTimestampOffsetHeaderExtension); |
| 808 | } |
| 809 | TEST_F(WebRtcVideoEngineTestFake, RecvRtpTimestampOffsetHeaderExtensions) { |
| 810 | TestSetRecvRtpHeaderExtensions(kRtpTimestampOffsetHeaderExtension); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 811 | } |
| 812 | |
| 813 | // Test support for absolute send time header extension. |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame^] | 814 | TEST_F(WebRtcVideoEngineTestFake, SendAbsoluteSendTimeHeaderExtensions) { |
| 815 | TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); |
| 816 | } |
| 817 | TEST_F(WebRtcVideoEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) { |
| 818 | TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | TEST_F(WebRtcVideoEngineTestFake, LeakyBucketTest) { |
| 822 | EXPECT_TRUE(SetupEngine()); |
| 823 | |
| 824 | // Verify this is off by default. |
| 825 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 826 | int first_send_channel = vie_.GetLastChannel(); |
| 827 | EXPECT_FALSE(vie_.GetTransmissionSmoothingStatus(first_send_channel)); |
| 828 | |
| 829 | // Enable the experiment and verify. |
| 830 | cricket::VideoOptions options; |
| 831 | options.conference_mode.Set(true); |
| 832 | options.video_leaky_bucket.Set(true); |
| 833 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 834 | EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(first_send_channel)); |
| 835 | |
| 836 | // Add a receive channel and verify leaky bucket isn't enabled. |
| 837 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 838 | int recv_channel_num = vie_.GetLastChannel(); |
| 839 | EXPECT_NE(first_send_channel, recv_channel_num); |
| 840 | EXPECT_FALSE(vie_.GetTransmissionSmoothingStatus(recv_channel_num)); |
| 841 | |
| 842 | // Add a new send stream and verify leaky bucket is enabled from start. |
| 843 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3))); |
| 844 | int second_send_channel = vie_.GetLastChannel(); |
| 845 | EXPECT_NE(first_send_channel, second_send_channel); |
| 846 | EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(second_send_channel)); |
| 847 | } |
| 848 | |
henrike@webrtc.org | 6e3dbc2 | 2014-03-25 17:09:47 +0000 | [diff] [blame] | 849 | // Verify that SuspendBelowMinBitrate is enabled if it is set in the options. |
| 850 | TEST_F(WebRtcVideoEngineTestFake, SuspendBelowMinBitrateTest) { |
| 851 | EXPECT_TRUE(SetupEngine()); |
| 852 | |
| 853 | // Verify this is off by default. |
| 854 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 855 | int first_send_channel = vie_.GetLastChannel(); |
| 856 | EXPECT_FALSE(vie_.GetSuspendBelowMinBitrateStatus(first_send_channel)); |
| 857 | |
| 858 | // Enable the experiment and verify. |
| 859 | cricket::VideoOptions options; |
| 860 | options.suspend_below_min_bitrate.Set(true); |
| 861 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 862 | EXPECT_TRUE(vie_.GetSuspendBelowMinBitrateStatus(first_send_channel)); |
| 863 | |
| 864 | // Add a new send stream and verify suspend_below_min_bitrate is enabled. |
| 865 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); |
| 866 | int second_send_channel = vie_.GetLastChannel(); |
| 867 | EXPECT_NE(first_send_channel, second_send_channel); |
| 868 | EXPECT_TRUE(vie_.GetSuspendBelowMinBitrateStatus(second_send_channel)); |
| 869 | } |
| 870 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 871 | TEST_F(WebRtcVideoEngineTestFake, BufferedModeLatency) { |
| 872 | EXPECT_TRUE(SetupEngine()); |
| 873 | |
| 874 | // Verify this is off by default. |
| 875 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 876 | int first_send_channel = vie_.GetLastChannel(); |
| 877 | EXPECT_EQ(0, vie_.GetSenderTargetDelay(first_send_channel)); |
| 878 | EXPECT_EQ(0, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 879 | |
| 880 | // Enable the experiment and verify. The default channel will have both |
| 881 | // sender and receiver buffered mode enabled. |
| 882 | cricket::VideoOptions options; |
| 883 | options.conference_mode.Set(true); |
| 884 | options.buffered_mode_latency.Set(100); |
| 885 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 886 | EXPECT_EQ(100, vie_.GetSenderTargetDelay(first_send_channel)); |
| 887 | EXPECT_EQ(100, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 888 | |
| 889 | // Add a receive channel and verify sender buffered mode isn't enabled. |
| 890 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 891 | int recv_channel_num = vie_.GetLastChannel(); |
| 892 | EXPECT_NE(first_send_channel, recv_channel_num); |
| 893 | EXPECT_EQ(0, vie_.GetSenderTargetDelay(recv_channel_num)); |
| 894 | EXPECT_EQ(100, vie_.GetReceiverTargetDelay(recv_channel_num)); |
| 895 | |
| 896 | // Add a new send stream and verify sender buffered mode is enabled. |
| 897 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3))); |
| 898 | int second_send_channel = vie_.GetLastChannel(); |
| 899 | EXPECT_NE(first_send_channel, second_send_channel); |
| 900 | EXPECT_EQ(100, vie_.GetSenderTargetDelay(second_send_channel)); |
| 901 | EXPECT_EQ(0, vie_.GetReceiverTargetDelay(second_send_channel)); |
| 902 | |
| 903 | // Disable sender buffered mode and verify. |
| 904 | options.buffered_mode_latency.Set(cricket::kBufferedModeDisabled); |
| 905 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 906 | EXPECT_EQ(0, vie_.GetSenderTargetDelay(first_send_channel)); |
| 907 | EXPECT_EQ(0, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 908 | EXPECT_EQ(0, vie_.GetSenderTargetDelay(second_send_channel)); |
| 909 | EXPECT_EQ(0, vie_.GetReceiverTargetDelay(second_send_channel)); |
| 910 | EXPECT_EQ(0, vie_.GetSenderTargetDelay(recv_channel_num)); |
| 911 | EXPECT_EQ(0, vie_.GetReceiverTargetDelay(recv_channel_num)); |
| 912 | } |
| 913 | |
| 914 | TEST_F(WebRtcVideoEngineTestFake, AdditiveVideoOptions) { |
| 915 | EXPECT_TRUE(SetupEngine()); |
| 916 | |
| 917 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 918 | int first_send_channel = vie_.GetLastChannel(); |
| 919 | EXPECT_EQ(0, vie_.GetSenderTargetDelay(first_send_channel)); |
| 920 | EXPECT_EQ(0, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 921 | |
| 922 | cricket::VideoOptions options1; |
| 923 | options1.buffered_mode_latency.Set(100); |
| 924 | EXPECT_TRUE(channel_->SetOptions(options1)); |
| 925 | EXPECT_EQ(100, vie_.GetSenderTargetDelay(first_send_channel)); |
| 926 | EXPECT_EQ(100, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 927 | EXPECT_FALSE(vie_.GetTransmissionSmoothingStatus(first_send_channel)); |
| 928 | |
| 929 | cricket::VideoOptions options2; |
| 930 | options2.video_leaky_bucket.Set(true); |
| 931 | EXPECT_TRUE(channel_->SetOptions(options2)); |
| 932 | EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(first_send_channel)); |
| 933 | // The buffered_mode_latency still takes effect. |
| 934 | EXPECT_EQ(100, vie_.GetSenderTargetDelay(first_send_channel)); |
| 935 | EXPECT_EQ(100, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 936 | |
| 937 | options1.buffered_mode_latency.Set(50); |
| 938 | EXPECT_TRUE(channel_->SetOptions(options1)); |
| 939 | EXPECT_EQ(50, vie_.GetSenderTargetDelay(first_send_channel)); |
| 940 | EXPECT_EQ(50, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 941 | // The video_leaky_bucket still takes effect. |
| 942 | EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(first_send_channel)); |
| 943 | } |
| 944 | |
henrike@webrtc.org | b0ecc1c | 2014-03-26 22:44:28 +0000 | [diff] [blame] | 945 | TEST_F(WebRtcVideoEngineTestFake, SetCpuOveruseOptionsWithCaptureJitterMethod) { |
| 946 | EXPECT_TRUE(SetupEngine()); |
| 947 | |
| 948 | // Verify this is off by default. |
| 949 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 950 | int first_send_channel = vie_.GetLastChannel(); |
| 951 | webrtc::CpuOveruseOptions cpu_option = |
| 952 | vie_.GetCpuOveruseOptions(first_send_channel); |
| 953 | EXPECT_EQ(0, cpu_option.low_capture_jitter_threshold_ms); |
| 954 | EXPECT_EQ(0, cpu_option.high_capture_jitter_threshold_ms); |
| 955 | EXPECT_FALSE(cpu_option.enable_capture_jitter_method); |
| 956 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 957 | |
| 958 | // Set low and high threshold and verify that cpu options are set. |
| 959 | cricket::VideoOptions options; |
| 960 | options.conference_mode.Set(true); |
| 961 | options.cpu_underuse_threshold.Set(10); |
| 962 | options.cpu_overuse_threshold.Set(20); |
| 963 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 964 | cpu_option = vie_.GetCpuOveruseOptions(first_send_channel); |
| 965 | EXPECT_EQ(10, cpu_option.low_capture_jitter_threshold_ms); |
| 966 | EXPECT_EQ(20, cpu_option.high_capture_jitter_threshold_ms); |
| 967 | EXPECT_TRUE(cpu_option.enable_capture_jitter_method); |
| 968 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 969 | |
| 970 | // Add a receive channel and verify that cpu options are not set. |
| 971 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 972 | int recv_channel_num = vie_.GetLastChannel(); |
| 973 | EXPECT_NE(first_send_channel, recv_channel_num); |
| 974 | cpu_option = vie_.GetCpuOveruseOptions(recv_channel_num); |
| 975 | EXPECT_EQ(0, cpu_option.low_capture_jitter_threshold_ms); |
| 976 | EXPECT_EQ(0, cpu_option.high_capture_jitter_threshold_ms); |
| 977 | EXPECT_FALSE(cpu_option.enable_capture_jitter_method); |
| 978 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 979 | |
| 980 | // Add a new send stream and verify that cpu options are set from start. |
| 981 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3))); |
| 982 | int second_send_channel = vie_.GetLastChannel(); |
| 983 | EXPECT_NE(first_send_channel, second_send_channel); |
| 984 | cpu_option = vie_.GetCpuOveruseOptions(second_send_channel); |
| 985 | EXPECT_EQ(10, cpu_option.low_capture_jitter_threshold_ms); |
| 986 | EXPECT_EQ(20, cpu_option.high_capture_jitter_threshold_ms); |
| 987 | EXPECT_TRUE(cpu_option.enable_capture_jitter_method); |
| 988 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 989 | } |
| 990 | |
| 991 | TEST_F(WebRtcVideoEngineTestFake, SetInvalidCpuOveruseThresholds) { |
| 992 | EXPECT_TRUE(SetupEngine()); |
| 993 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 994 | int channel_num = vie_.GetLastChannel(); |
| 995 | |
| 996 | // Only low threshold set. Verify that cpu options are not set. |
| 997 | cricket::VideoOptions options; |
| 998 | options.conference_mode.Set(true); |
| 999 | options.cpu_underuse_threshold.Set(10); |
| 1000 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1001 | webrtc::CpuOveruseOptions cpu_option = vie_.GetCpuOveruseOptions(channel_num); |
| 1002 | EXPECT_EQ(0, cpu_option.low_capture_jitter_threshold_ms); |
| 1003 | EXPECT_EQ(0, cpu_option.high_capture_jitter_threshold_ms); |
| 1004 | EXPECT_FALSE(cpu_option.enable_capture_jitter_method); |
| 1005 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 1006 | |
| 1007 | // Set high threshold to a negative value. Verify that options are not set. |
| 1008 | options.cpu_overuse_threshold.Set(-1); |
| 1009 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1010 | cpu_option = vie_.GetCpuOveruseOptions(channel_num); |
| 1011 | EXPECT_EQ(0, cpu_option.low_capture_jitter_threshold_ms); |
| 1012 | EXPECT_EQ(0, cpu_option.high_capture_jitter_threshold_ms); |
| 1013 | EXPECT_FALSE(cpu_option.enable_capture_jitter_method); |
| 1014 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 1015 | |
| 1016 | // Low and high threshold valid. Verify that cpu options are set. |
| 1017 | options.cpu_overuse_threshold.Set(20); |
| 1018 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1019 | cpu_option = vie_.GetCpuOveruseOptions(channel_num); |
| 1020 | EXPECT_EQ(10, cpu_option.low_capture_jitter_threshold_ms); |
| 1021 | EXPECT_EQ(20, cpu_option.high_capture_jitter_threshold_ms); |
| 1022 | EXPECT_TRUE(cpu_option.enable_capture_jitter_method); |
| 1023 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 1024 | } |
| 1025 | |
| 1026 | TEST_F(WebRtcVideoEngineTestFake, SetCpuOveruseOptionsWithEncodeUsageMethod) { |
| 1027 | EXPECT_TRUE(SetupEngine()); |
| 1028 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 1029 | int first_send_channel = vie_.GetLastChannel(); |
| 1030 | |
| 1031 | // Set low and high threshold and enable encode usage method. |
| 1032 | // Verify that cpu options are set. |
| 1033 | cricket::VideoOptions options; |
| 1034 | options.conference_mode.Set(true); |
| 1035 | options.cpu_underuse_threshold.Set(10); |
| 1036 | options.cpu_overuse_threshold.Set(20); |
| 1037 | options.cpu_overuse_encode_usage.Set(true); |
| 1038 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1039 | webrtc::CpuOveruseOptions cpu_option = |
| 1040 | vie_.GetCpuOveruseOptions(first_send_channel); |
| 1041 | EXPECT_EQ(10, cpu_option.low_encode_usage_threshold_percent); |
| 1042 | EXPECT_EQ(20, cpu_option.high_encode_usage_threshold_percent); |
| 1043 | EXPECT_FALSE(cpu_option.enable_capture_jitter_method); |
| 1044 | EXPECT_TRUE(cpu_option.enable_encode_usage_method); |
| 1045 | |
| 1046 | // Add a new send stream and verify that cpu options are set from start. |
| 1047 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3))); |
| 1048 | int second_send_channel = vie_.GetLastChannel(); |
| 1049 | EXPECT_NE(first_send_channel, second_send_channel); |
| 1050 | cpu_option = vie_.GetCpuOveruseOptions(second_send_channel); |
| 1051 | EXPECT_EQ(10, cpu_option.low_encode_usage_threshold_percent); |
| 1052 | EXPECT_EQ(20, cpu_option.high_encode_usage_threshold_percent); |
| 1053 | EXPECT_FALSE(cpu_option.enable_capture_jitter_method); |
| 1054 | EXPECT_TRUE(cpu_option.enable_encode_usage_method); |
| 1055 | } |
henrike@webrtc.org | b0ecc1c | 2014-03-26 22:44:28 +0000 | [diff] [blame] | 1056 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1057 | // Test that AddRecvStream doesn't create new channel for 1:1 call. |
| 1058 | TEST_F(WebRtcVideoEngineTestFake, AddRecvStream1On1) { |
| 1059 | EXPECT_TRUE(SetupEngine()); |
| 1060 | int channel_num = vie_.GetLastChannel(); |
| 1061 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 1062 | EXPECT_EQ(channel_num, vie_.GetLastChannel()); |
| 1063 | } |
| 1064 | |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1065 | // Test that NACK, PLI and REMB are enabled for internal codec. |
| 1066 | TEST_F(WebRtcVideoEngineTestFake, InternalCodecFeedbackParams) { |
| 1067 | EXPECT_TRUE(SetupEngine()); |
| 1068 | |
| 1069 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 1070 | // Vp8 will appear at the beginning. |
| 1071 | size_t pos = 0; |
| 1072 | EXPECT_EQ("VP8", codecs[pos].name); |
| 1073 | VerifyCodecFeedbackParams(codecs[pos]); |
| 1074 | } |
| 1075 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1076 | // Test that AddRecvStream doesn't change remb for 1:1 call. |
| 1077 | TEST_F(WebRtcVideoEngineTestFake, NoRembChangeAfterAddRecvStream) { |
| 1078 | EXPECT_TRUE(SetupEngine()); |
| 1079 | int channel_num = vie_.GetLastChannel(); |
| 1080 | EXPECT_TRUE(channel_->AddSendStream( |
| 1081 | cricket::StreamParams::CreateLegacy(1))); |
| 1082 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1083 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num)); |
| 1084 | EXPECT_TRUE(vie_.GetRembStatusContribute(channel_num)); |
| 1085 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1086 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 1087 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num)); |
| 1088 | EXPECT_TRUE(vie_.GetRembStatusContribute(channel_num)); |
| 1089 | } |
| 1090 | |
| 1091 | // Verify default REMB setting and that it can be turned on and off. |
| 1092 | TEST_F(WebRtcVideoEngineTestFake, RembOnOff) { |
| 1093 | EXPECT_TRUE(SetupEngine()); |
| 1094 | int channel_num = vie_.GetLastChannel(); |
| 1095 | // Verify REMB sending is always off by default. |
| 1096 | EXPECT_FALSE(vie_.GetRembStatusBwPartition(channel_num)); |
| 1097 | |
| 1098 | // Verify that REMB is turned on when setting default codecs since the |
| 1099 | // default codecs have REMB enabled. |
| 1100 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1101 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num)); |
| 1102 | |
| 1103 | // Verify that REMB is turned off when codecs without REMB are set. |
| 1104 | std::vector<cricket::VideoCodec> codecs = engine_.codecs(); |
| 1105 | // Clearing the codecs' FeedbackParams and setting send codecs should disable |
| 1106 | // REMB. |
| 1107 | for (std::vector<cricket::VideoCodec>::iterator iter = codecs.begin(); |
| 1108 | iter != codecs.end(); ++iter) { |
| 1109 | // Intersecting with empty will clear the FeedbackParams. |
| 1110 | cricket::FeedbackParams empty_params; |
| 1111 | iter->feedback_params.Intersect(empty_params); |
| 1112 | EXPECT_TRUE(iter->feedback_params.params().empty()); |
| 1113 | } |
| 1114 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1115 | EXPECT_FALSE(vie_.GetRembStatusBwPartition(channel_num)); |
| 1116 | } |
| 1117 | |
| 1118 | // Test that nack is enabled on the channel if we don't offer red/fec. |
| 1119 | TEST_F(WebRtcVideoEngineTestFake, NackEnabled) { |
| 1120 | EXPECT_TRUE(SetupEngine()); |
| 1121 | int channel_num = vie_.GetLastChannel(); |
| 1122 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 1123 | codecs.resize(1); // toss out red and ulpfec |
| 1124 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1125 | EXPECT_TRUE(vie_.GetNackStatus(channel_num)); |
| 1126 | } |
| 1127 | |
| 1128 | // Test that we enable hybrid NACK FEC mode. |
| 1129 | TEST_F(WebRtcVideoEngineTestFake, HybridNackFec) { |
| 1130 | EXPECT_TRUE(SetupEngine()); |
| 1131 | int channel_num = vie_.GetLastChannel(); |
| 1132 | EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); |
| 1133 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1134 | EXPECT_TRUE(vie_.GetHybridNackFecStatus(channel_num)); |
| 1135 | EXPECT_FALSE(vie_.GetNackStatus(channel_num)); |
| 1136 | } |
| 1137 | |
| 1138 | // Test that we enable hybrid NACK FEC mode when calling SetSendCodecs and |
| 1139 | // SetReceiveCodecs in reversed order. |
| 1140 | TEST_F(WebRtcVideoEngineTestFake, HybridNackFecReversedOrder) { |
| 1141 | EXPECT_TRUE(SetupEngine()); |
| 1142 | int channel_num = vie_.GetLastChannel(); |
| 1143 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1144 | EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); |
| 1145 | EXPECT_TRUE(vie_.GetHybridNackFecStatus(channel_num)); |
| 1146 | EXPECT_FALSE(vie_.GetNackStatus(channel_num)); |
| 1147 | } |
| 1148 | |
| 1149 | // Test NACK vs Hybrid NACK/FEC interop call setup, i.e. only use NACK even if |
| 1150 | // red/fec is offered as receive codec. |
| 1151 | TEST_F(WebRtcVideoEngineTestFake, VideoProtectionInterop) { |
| 1152 | EXPECT_TRUE(SetupEngine()); |
| 1153 | int channel_num = vie_.GetLastChannel(); |
| 1154 | std::vector<cricket::VideoCodec> recv_codecs(engine_.codecs()); |
| 1155 | std::vector<cricket::VideoCodec> send_codecs(engine_.codecs()); |
| 1156 | // Only add VP8 as send codec. |
| 1157 | send_codecs.resize(1); |
| 1158 | EXPECT_TRUE(channel_->SetRecvCodecs(recv_codecs)); |
| 1159 | EXPECT_TRUE(channel_->SetSendCodecs(send_codecs)); |
| 1160 | EXPECT_FALSE(vie_.GetHybridNackFecStatus(channel_num)); |
| 1161 | EXPECT_TRUE(vie_.GetNackStatus(channel_num)); |
| 1162 | } |
| 1163 | |
| 1164 | // Test NACK vs Hybrid NACK/FEC interop call setup, i.e. only use NACK even if |
| 1165 | // red/fec is offered as receive codec. Call order reversed compared to |
| 1166 | // VideoProtectionInterop. |
| 1167 | TEST_F(WebRtcVideoEngineTestFake, VideoProtectionInteropReversed) { |
| 1168 | EXPECT_TRUE(SetupEngine()); |
| 1169 | int channel_num = vie_.GetLastChannel(); |
| 1170 | std::vector<cricket::VideoCodec> recv_codecs(engine_.codecs()); |
| 1171 | std::vector<cricket::VideoCodec> send_codecs(engine_.codecs()); |
| 1172 | // Only add VP8 as send codec. |
| 1173 | send_codecs.resize(1); |
| 1174 | EXPECT_TRUE(channel_->SetSendCodecs(send_codecs)); |
| 1175 | EXPECT_TRUE(channel_->SetRecvCodecs(recv_codecs)); |
| 1176 | EXPECT_FALSE(vie_.GetHybridNackFecStatus(channel_num)); |
| 1177 | EXPECT_TRUE(vie_.GetNackStatus(channel_num)); |
| 1178 | } |
| 1179 | |
| 1180 | // Test that NACK, not hybrid mode, is enabled in conference mode. |
| 1181 | TEST_F(WebRtcVideoEngineTestFake, HybridNackFecConference) { |
| 1182 | EXPECT_TRUE(SetupEngine()); |
| 1183 | // Setup the send channel. |
| 1184 | int send_channel_num = vie_.GetLastChannel(); |
| 1185 | cricket::VideoOptions options; |
| 1186 | options.conference_mode.Set(true); |
| 1187 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1188 | EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); |
| 1189 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1190 | EXPECT_FALSE(vie_.GetHybridNackFecStatus(send_channel_num)); |
| 1191 | EXPECT_TRUE(vie_.GetNackStatus(send_channel_num)); |
| 1192 | // Add a receive stream. |
| 1193 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 1194 | int receive_channel_num = vie_.GetLastChannel(); |
| 1195 | EXPECT_FALSE(vie_.GetHybridNackFecStatus(receive_channel_num)); |
| 1196 | EXPECT_TRUE(vie_.GetNackStatus(receive_channel_num)); |
| 1197 | } |
| 1198 | |
| 1199 | // Test that when AddRecvStream in conference mode, a new channel is created |
| 1200 | // for receiving. And the new channel's "original channel" is the send channel. |
| 1201 | TEST_F(WebRtcVideoEngineTestFake, AddRemoveRecvStreamConference) { |
| 1202 | EXPECT_TRUE(SetupEngine()); |
| 1203 | // Setup the send channel. |
| 1204 | int send_channel_num = vie_.GetLastChannel(); |
| 1205 | cricket::VideoOptions options; |
| 1206 | options.conference_mode.Set(true); |
| 1207 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1208 | // Add a receive stream. |
| 1209 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 1210 | int receive_channel_num = vie_.GetLastChannel(); |
| 1211 | EXPECT_EQ(send_channel_num, vie_.GetOriginalChannelId(receive_channel_num)); |
| 1212 | EXPECT_TRUE(channel_->RemoveRecvStream(1)); |
| 1213 | EXPECT_FALSE(vie_.IsChannel(receive_channel_num)); |
| 1214 | } |
| 1215 | |
henrike@webrtc.org | 6e3dbc2 | 2014-03-25 17:09:47 +0000 | [diff] [blame] | 1216 | // Test that adding/removing stream with 0 ssrc should fail (and not crash). |
| 1217 | // For crbug/351699 and 350988. |
| 1218 | TEST_F(WebRtcVideoEngineTestFake, AddRemoveRecvStreamWith0Ssrc) { |
| 1219 | EXPECT_TRUE(SetupEngine()); |
| 1220 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 1221 | EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(0))); |
| 1222 | EXPECT_FALSE(channel_->RemoveRecvStream(0)); |
| 1223 | EXPECT_TRUE(channel_->RemoveRecvStream(1)); |
| 1224 | } |
| 1225 | |
| 1226 | TEST_F(WebRtcVideoEngineTestFake, AddRemoveSendStreamWith0Ssrc) { |
| 1227 | EXPECT_TRUE(SetupEngine()); |
| 1228 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 1229 | EXPECT_FALSE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(0))); |
| 1230 | EXPECT_FALSE(channel_->RemoveSendStream(0)); |
| 1231 | EXPECT_TRUE(channel_->RemoveSendStream(1)); |
| 1232 | } |
| 1233 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1234 | // Test that we can create a channel and start/stop rendering out on it. |
| 1235 | TEST_F(WebRtcVideoEngineTestFake, SetRender) { |
| 1236 | EXPECT_TRUE(SetupEngine()); |
| 1237 | int channel_num = vie_.GetLastChannel(); |
| 1238 | |
| 1239 | // Verify we can start/stop/start/stop rendering. |
| 1240 | EXPECT_TRUE(channel_->SetRender(true)); |
| 1241 | EXPECT_TRUE(vie_.GetRenderStarted(channel_num)); |
| 1242 | EXPECT_TRUE(channel_->SetRender(false)); |
| 1243 | EXPECT_FALSE(vie_.GetRenderStarted(channel_num)); |
| 1244 | EXPECT_TRUE(channel_->SetRender(true)); |
| 1245 | EXPECT_TRUE(vie_.GetRenderStarted(channel_num)); |
| 1246 | EXPECT_TRUE(channel_->SetRender(false)); |
| 1247 | EXPECT_FALSE(vie_.GetRenderStarted(channel_num)); |
| 1248 | } |
| 1249 | |
| 1250 | // Test that we can create a channel and start/stop sending out on it. |
| 1251 | TEST_F(WebRtcVideoEngineTestFake, SetSend) { |
| 1252 | EXPECT_TRUE(SetupEngine()); |
| 1253 | int channel_num = vie_.GetLastChannel(); |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1254 | // Verify receiving is also started. |
| 1255 | EXPECT_TRUE(vie_.GetReceive(channel_num)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1256 | |
| 1257 | // Set send codecs on the channel. |
| 1258 | std::vector<cricket::VideoCodec> codecs; |
| 1259 | codecs.push_back(kVP8Codec); |
| 1260 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1261 | EXPECT_TRUE(channel_->AddSendStream( |
| 1262 | cricket::StreamParams::CreateLegacy(123))); |
| 1263 | |
| 1264 | // Verify we can start/stop/start/stop sending. |
| 1265 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1266 | EXPECT_TRUE(vie_.GetSend(channel_num)); |
| 1267 | EXPECT_TRUE(channel_->SetSend(false)); |
| 1268 | EXPECT_FALSE(vie_.GetSend(channel_num)); |
| 1269 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1270 | EXPECT_TRUE(vie_.GetSend(channel_num)); |
| 1271 | EXPECT_TRUE(channel_->SetSend(false)); |
| 1272 | EXPECT_FALSE(vie_.GetSend(channel_num)); |
| 1273 | } |
| 1274 | |
| 1275 | // Test that we set bandwidth properly when using full auto bandwidth mode. |
| 1276 | TEST_F(WebRtcVideoEngineTestFake, SetBandwidthAuto) { |
| 1277 | EXPECT_TRUE(SetupEngine()); |
| 1278 | int channel_num = vie_.GetLastChannel(); |
| 1279 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1280 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(cricket::kAutoBandwidth)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1281 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height); |
| 1282 | } |
| 1283 | |
| 1284 | // Test that we set bandwidth properly when using auto with upper bound. |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1285 | TEST_F(WebRtcVideoEngineTestFake, SetBandwidthCapped) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1286 | EXPECT_TRUE(SetupEngine()); |
| 1287 | int channel_num = vie_.GetLastChannel(); |
| 1288 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1289 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(768000)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1290 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, 768U); |
| 1291 | } |
| 1292 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1293 | // Test that we reduce the start bandwidth when the requested max is less than |
| 1294 | // the default start bandwidth. |
| 1295 | TEST_F(WebRtcVideoEngineTestFake, SetMaxBandwidthBelowDefaultStart) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1296 | EXPECT_TRUE(SetupEngine()); |
| 1297 | int channel_num = vie_.GetLastChannel(); |
| 1298 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1299 | int max_bandwidth_kbps = (kMinBandwidthKbps + kStartBandwidthKbps) / 2; |
| 1300 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(max_bandwidth_kbps * 1000)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1301 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1302 | max_bandwidth_kbps, kMinBandwidthKbps, max_bandwidth_kbps); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1303 | } |
| 1304 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1305 | // Test that we reduce the min bandwidth when the requested max is less than |
| 1306 | // the min bandwidth. |
| 1307 | TEST_F(WebRtcVideoEngineTestFake, SetMaxBandwidthBelowMin) { |
| 1308 | EXPECT_TRUE(SetupEngine()); |
| 1309 | int channel_num = vie_.GetLastChannel(); |
| 1310 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1311 | int max_bandwidth_kbps = kMinBandwidthKbps / 2; |
| 1312 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(max_bandwidth_kbps * 1000)); |
| 1313 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
| 1314 | max_bandwidth_kbps, max_bandwidth_kbps, max_bandwidth_kbps); |
| 1315 | } |
| 1316 | |
| 1317 | // Test that the start bandwidth can be controlled separately from the max |
| 1318 | // bandwidth. |
| 1319 | TEST_F(WebRtcVideoEngineTestFake, SetStartBandwidth) { |
| 1320 | EXPECT_TRUE(SetupEngine()); |
| 1321 | int channel_num = vie_.GetLastChannel(); |
| 1322 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1323 | int start_bandwidth_kbps = kStartBandwidthKbps + 1; |
| 1324 | EXPECT_TRUE(channel_->SetStartSendBandwidth(start_bandwidth_kbps * 1000)); |
| 1325 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
| 1326 | kMaxBandwidthKbps, kMinBandwidthKbps, start_bandwidth_kbps); |
| 1327 | |
| 1328 | // Check that SetMaxSendBandwidth doesn't overwrite the start bandwidth. |
| 1329 | int max_bandwidth_kbps = kMaxBandwidthKbps + 1; |
| 1330 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(max_bandwidth_kbps * 1000)); |
| 1331 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
| 1332 | max_bandwidth_kbps, kMinBandwidthKbps, start_bandwidth_kbps); |
| 1333 | } |
| 1334 | |
wu@webrtc.org | 1e6cb2c | 2014-03-24 17:01:50 +0000 | [diff] [blame] | 1335 | // Test that the start bandwidth can be controlled by experiment. |
| 1336 | TEST_F(WebRtcVideoEngineTestFake, SetStartBandwidthOption) { |
| 1337 | EXPECT_TRUE(SetupEngine()); |
| 1338 | int channel_num = vie_.GetLastChannel(); |
| 1339 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1340 | int start_bandwidth_kbps = kStartBandwidthKbps; |
| 1341 | EXPECT_TRUE(channel_->SetStartSendBandwidth(start_bandwidth_kbps * 1000)); |
| 1342 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
| 1343 | kMaxBandwidthKbps, kMinBandwidthKbps, start_bandwidth_kbps); |
| 1344 | |
| 1345 | // Set the start bitrate option. |
| 1346 | start_bandwidth_kbps = 1000; |
| 1347 | cricket::VideoOptions options; |
| 1348 | options.video_start_bitrate.Set( |
| 1349 | start_bandwidth_kbps); |
| 1350 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1351 | |
| 1352 | // Check that start bitrate has changed to the new value. |
| 1353 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
| 1354 | kMaxBandwidthKbps, kMinBandwidthKbps, start_bandwidth_kbps); |
| 1355 | } |
| 1356 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1357 | // Test that SetMaxSendBandwidth is ignored in conference mode. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1358 | TEST_F(WebRtcVideoEngineTestFake, SetBandwidthInConference) { |
| 1359 | EXPECT_TRUE(SetupEngine()); |
| 1360 | int channel_num = vie_.GetLastChannel(); |
| 1361 | cricket::VideoOptions options; |
| 1362 | options.conference_mode.Set(true); |
| 1363 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1364 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1365 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height); |
| 1366 | |
| 1367 | // Set send bandwidth. |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1368 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(768000)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1369 | |
| 1370 | // Verify bitrate not changed. |
| 1371 | webrtc::VideoCodec gcodec; |
| 1372 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec)); |
| 1373 | EXPECT_EQ(kMinBandwidthKbps, gcodec.minBitrate); |
| 1374 | EXPECT_EQ(kStartBandwidthKbps, gcodec.startBitrate); |
| 1375 | EXPECT_EQ(kMaxBandwidthKbps, gcodec.maxBitrate); |
| 1376 | EXPECT_NE(768U, gcodec.minBitrate); |
| 1377 | EXPECT_NE(768U, gcodec.startBitrate); |
| 1378 | EXPECT_NE(768U, gcodec.maxBitrate); |
| 1379 | } |
| 1380 | |
| 1381 | // Test that sending screencast frames doesn't change bitrate. |
| 1382 | TEST_F(WebRtcVideoEngineTestFake, SetBandwidthScreencast) { |
| 1383 | EXPECT_TRUE(SetupEngine()); |
| 1384 | int channel_num = vie_.GetLastChannel(); |
| 1385 | |
| 1386 | // Set send codec. |
| 1387 | cricket::VideoCodec codec(kVP8Codec); |
| 1388 | std::vector<cricket::VideoCodec> codec_list; |
| 1389 | codec_list.push_back(codec); |
| 1390 | EXPECT_TRUE(channel_->AddSendStream( |
| 1391 | cricket::StreamParams::CreateLegacy(123))); |
| 1392 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1393 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(111000)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1394 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1395 | |
| 1396 | SendI420ScreencastFrame(kVP8Codec.width, kVP8Codec.height); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1397 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, 111); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1398 | } |
| 1399 | |
| 1400 | |
| 1401 | // Test SetSendSsrc. |
| 1402 | TEST_F(WebRtcVideoEngineTestFake, SetSendSsrcAndCname) { |
| 1403 | EXPECT_TRUE(SetupEngine()); |
| 1404 | int channel_num = vie_.GetLastChannel(); |
| 1405 | |
| 1406 | cricket::StreamParams stream; |
| 1407 | stream.ssrcs.push_back(1234); |
| 1408 | stream.cname = "cname"; |
| 1409 | channel_->AddSendStream(stream); |
| 1410 | |
| 1411 | unsigned int ssrc = 0; |
| 1412 | EXPECT_EQ(0, vie_.GetLocalSSRC(channel_num, ssrc)); |
| 1413 | EXPECT_EQ(1234U, ssrc); |
| 1414 | EXPECT_EQ(1, vie_.GetNumSsrcs(channel_num)); |
| 1415 | |
| 1416 | char rtcp_cname[256]; |
| 1417 | EXPECT_EQ(0, vie_.GetRTCPCName(channel_num, rtcp_cname)); |
| 1418 | EXPECT_STREQ("cname", rtcp_cname); |
| 1419 | } |
| 1420 | |
| 1421 | |
| 1422 | // Test that the local SSRC is the same on sending and receiving channels if the |
| 1423 | // receive channel is created before the send channel. |
| 1424 | TEST_F(WebRtcVideoEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) { |
| 1425 | EXPECT_TRUE(SetupEngine()); |
| 1426 | |
| 1427 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 1428 | int receive_channel_num = vie_.GetLastChannel(); |
| 1429 | cricket::StreamParams stream = cricket::StreamParams::CreateLegacy(1234); |
| 1430 | EXPECT_TRUE(channel_->AddSendStream(stream)); |
| 1431 | int send_channel_num = vie_.GetLastChannel(); |
| 1432 | unsigned int ssrc = 0; |
| 1433 | EXPECT_EQ(0, vie_.GetLocalSSRC(send_channel_num, ssrc)); |
| 1434 | EXPECT_EQ(1234U, ssrc); |
| 1435 | EXPECT_EQ(1, vie_.GetNumSsrcs(send_channel_num)); |
| 1436 | ssrc = 0; |
| 1437 | EXPECT_EQ(0, vie_.GetLocalSSRC(receive_channel_num, ssrc)); |
| 1438 | EXPECT_EQ(1234U, ssrc); |
| 1439 | EXPECT_EQ(1, vie_.GetNumSsrcs(receive_channel_num)); |
| 1440 | } |
| 1441 | |
| 1442 | |
| 1443 | // Test SetOptions with denoising flag. |
| 1444 | TEST_F(WebRtcVideoEngineTestFake, SetOptionsWithDenoising) { |
| 1445 | EXPECT_TRUE(SetupEngine()); |
| 1446 | EXPECT_EQ(1, vie_.GetNumCapturers()); |
| 1447 | int channel_num = vie_.GetLastChannel(); |
| 1448 | int capture_id = vie_.GetCaptureId(channel_num); |
| 1449 | // Set send codecs on the channel. |
| 1450 | std::vector<cricket::VideoCodec> codecs; |
| 1451 | codecs.push_back(kVP8Codec); |
| 1452 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1453 | |
| 1454 | // Set options with OPT_VIDEO_NOISE_REDUCTION flag. |
| 1455 | cricket::VideoOptions options; |
| 1456 | options.video_noise_reduction.Set(true); |
| 1457 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1458 | |
| 1459 | // Verify capture has denoising turned on. |
| 1460 | webrtc::VideoCodec send_codec; |
| 1461 | memset(&send_codec, 0, sizeof(send_codec)); // avoid uninitialized warning |
| 1462 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, send_codec)); |
| 1463 | EXPECT_TRUE(send_codec.codecSpecific.VP8.denoisingOn); |
| 1464 | EXPECT_FALSE(vie_.GetCaptureDenoising(capture_id)); |
| 1465 | |
| 1466 | // Set options back to zero. |
| 1467 | options.video_noise_reduction.Set(false); |
| 1468 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1469 | |
| 1470 | // Verify capture has denoising turned off. |
| 1471 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, send_codec)); |
| 1472 | EXPECT_FALSE(send_codec.codecSpecific.VP8.denoisingOn); |
| 1473 | EXPECT_FALSE(vie_.GetCaptureDenoising(capture_id)); |
| 1474 | } |
| 1475 | |
wu@webrtc.org | a8910d2 | 2014-01-23 22:12:45 +0000 | [diff] [blame] | 1476 | TEST_F(WebRtcVideoEngineTestFake, MultipleSendStreamsWithOneCapturer) { |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 1477 | EXPECT_TRUE(SetupEngine()); |
| 1478 | |
| 1479 | // Start the capturer |
| 1480 | cricket::FakeVideoCapturer capturer; |
| 1481 | cricket::VideoFormat capture_format_vga = cricket::VideoFormat(640, 480, |
| 1482 | cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420); |
| 1483 | EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_vga)); |
| 1484 | |
| 1485 | // Add send streams and connect the capturer |
| 1486 | for (unsigned int i = 0; i < sizeof(kSsrcs2)/sizeof(kSsrcs2[0]); ++i) { |
| 1487 | EXPECT_TRUE(channel_->AddSendStream( |
| 1488 | cricket::StreamParams::CreateLegacy(kSsrcs2[i]))); |
| 1489 | // Register the capturer to the ssrc. |
| 1490 | EXPECT_TRUE(channel_->SetCapturer(kSsrcs2[i], &capturer)); |
| 1491 | } |
| 1492 | |
| 1493 | const int channel0 = vie_.GetChannelFromLocalSsrc(kSsrcs2[0]); |
| 1494 | ASSERT_NE(-1, channel0); |
| 1495 | const int channel1 = vie_.GetChannelFromLocalSsrc(kSsrcs2[1]); |
| 1496 | ASSERT_NE(-1, channel1); |
| 1497 | ASSERT_NE(channel0, channel1); |
| 1498 | |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1499 | // Both channels should have started receiving after created. |
| 1500 | EXPECT_TRUE(vie_.GetReceive(channel0)); |
| 1501 | EXPECT_TRUE(vie_.GetReceive(channel1)); |
| 1502 | |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 1503 | // Set send codec. |
| 1504 | std::vector<cricket::VideoCodec> codecs; |
| 1505 | cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0); |
| 1506 | codecs.push_back(send_codec); |
| 1507 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1508 | |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1509 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1510 | EXPECT_TRUE(vie_.GetSend(channel0)); |
| 1511 | EXPECT_TRUE(vie_.GetSend(channel1)); |
| 1512 | |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 1513 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 1514 | EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel0)); |
| 1515 | EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel1)); |
| 1516 | |
| 1517 | EXPECT_TRUE(channel_->RemoveSendStream(kSsrcs2[0])); |
| 1518 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 1519 | // channel0 is the default channel, so it won't be deleted. |
| 1520 | // But it should be disconnected from the capturer. |
| 1521 | EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel0)); |
| 1522 | EXPECT_EQ(2, vie_.GetIncomingFrameNum(channel1)); |
| 1523 | |
| 1524 | EXPECT_TRUE(channel_->RemoveSendStream(kSsrcs2[1])); |
| 1525 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 1526 | EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel0)); |
| 1527 | // channel1 has already been deleted. |
| 1528 | EXPECT_EQ(-1, vie_.GetIncomingFrameNum(channel1)); |
| 1529 | } |
| 1530 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1531 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 1532 | // Disabled since its flaky: b/11288120 |
| 1533 | TEST_F(WebRtcVideoEngineTestFake, DISABLED_SendReceiveBitratesStats) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1534 | EXPECT_TRUE(SetupEngine()); |
| 1535 | cricket::VideoOptions options; |
| 1536 | options.conference_mode.Set(true); |
| 1537 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1538 | EXPECT_TRUE(channel_->AddSendStream( |
| 1539 | cricket::StreamParams::CreateLegacy(1))); |
| 1540 | int send_channel = vie_.GetLastChannel(); |
| 1541 | cricket::VideoCodec codec(kVP8Codec720p); |
| 1542 | std::vector<cricket::VideoCodec> codec_list; |
| 1543 | codec_list.push_back(codec); |
| 1544 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 1545 | |
| 1546 | EXPECT_TRUE(channel_->AddRecvStream( |
| 1547 | cricket::StreamParams::CreateLegacy(2))); |
| 1548 | int first_receive_channel = vie_.GetLastChannel(); |
| 1549 | EXPECT_NE(send_channel, first_receive_channel); |
| 1550 | EXPECT_TRUE(channel_->AddRecvStream( |
| 1551 | cricket::StreamParams::CreateLegacy(3))); |
| 1552 | int second_receive_channel = vie_.GetLastChannel(); |
| 1553 | EXPECT_NE(first_receive_channel, second_receive_channel); |
| 1554 | |
| 1555 | cricket::VideoMediaInfo info; |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1556 | EXPECT_TRUE(channel_->GetStats(cricket::StatsOptions(), &info)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1557 | ASSERT_EQ(1U, info.bw_estimations.size()); |
| 1558 | ASSERT_EQ(0, info.bw_estimations[0].actual_enc_bitrate); |
| 1559 | ASSERT_EQ(0, info.bw_estimations[0].transmit_bitrate); |
| 1560 | ASSERT_EQ(0, info.bw_estimations[0].retransmit_bitrate); |
| 1561 | ASSERT_EQ(0, info.bw_estimations[0].available_send_bandwidth); |
| 1562 | ASSERT_EQ(0, info.bw_estimations[0].available_recv_bandwidth); |
| 1563 | ASSERT_EQ(0, info.bw_estimations[0].target_enc_bitrate); |
| 1564 | |
| 1565 | // Start sending and receiving on one of the channels and verify bitrates. |
| 1566 | EXPECT_EQ(0, vie_.StartSend(send_channel)); |
| 1567 | int send_video_bitrate = 800; |
| 1568 | int send_fec_bitrate = 100; |
| 1569 | int send_nack_bitrate = 20; |
| 1570 | int send_total_bitrate = send_video_bitrate + send_fec_bitrate + |
| 1571 | send_nack_bitrate; |
| 1572 | int send_bandwidth = 950; |
| 1573 | vie_.SetSendBitrates(send_channel, send_video_bitrate, send_fec_bitrate, |
| 1574 | send_nack_bitrate); |
| 1575 | vie_.SetSendBandwidthEstimate(send_channel, send_bandwidth); |
| 1576 | |
| 1577 | EXPECT_EQ(0, vie_.StartReceive(first_receive_channel)); |
| 1578 | int first_channel_receive_bandwidth = 600; |
| 1579 | vie_.SetReceiveBandwidthEstimate(first_receive_channel, |
| 1580 | first_channel_receive_bandwidth); |
| 1581 | |
| 1582 | info.Clear(); |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1583 | EXPECT_TRUE(channel_->GetStats(cricket::StatsOptions(), &info)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1584 | ASSERT_EQ(1U, info.bw_estimations.size()); |
| 1585 | ASSERT_EQ(send_video_bitrate, info.bw_estimations[0].actual_enc_bitrate); |
| 1586 | ASSERT_EQ(send_total_bitrate, info.bw_estimations[0].transmit_bitrate); |
| 1587 | ASSERT_EQ(send_nack_bitrate, info.bw_estimations[0].retransmit_bitrate); |
| 1588 | ASSERT_EQ(send_bandwidth, info.bw_estimations[0].available_send_bandwidth); |
| 1589 | ASSERT_EQ(first_channel_receive_bandwidth, |
| 1590 | info.bw_estimations[0].available_recv_bandwidth); |
| 1591 | ASSERT_EQ(send_video_bitrate, info.bw_estimations[0].target_enc_bitrate); |
| 1592 | |
| 1593 | // Start receiving on the second channel and verify received rate. |
| 1594 | EXPECT_EQ(0, vie_.StartReceive(second_receive_channel)); |
| 1595 | int second_channel_receive_bandwidth = 100; |
| 1596 | vie_.SetReceiveBandwidthEstimate(second_receive_channel, |
| 1597 | second_channel_receive_bandwidth); |
| 1598 | |
| 1599 | info.Clear(); |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1600 | EXPECT_TRUE(channel_->GetStats(cricket::StatsOptions(), &info)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1601 | ASSERT_EQ(1U, info.bw_estimations.size()); |
| 1602 | ASSERT_EQ(send_video_bitrate, info.bw_estimations[0].actual_enc_bitrate); |
| 1603 | ASSERT_EQ(send_total_bitrate, info.bw_estimations[0].transmit_bitrate); |
| 1604 | ASSERT_EQ(send_nack_bitrate, info.bw_estimations[0].retransmit_bitrate); |
| 1605 | ASSERT_EQ(send_bandwidth, info.bw_estimations[0].available_send_bandwidth); |
| 1606 | ASSERT_EQ(first_channel_receive_bandwidth + second_channel_receive_bandwidth, |
| 1607 | info.bw_estimations[0].available_recv_bandwidth); |
| 1608 | ASSERT_EQ(send_video_bitrate, info.bw_estimations[0].target_enc_bitrate); |
| 1609 | } |
| 1610 | |
| 1611 | TEST_F(WebRtcVideoEngineTestFake, TestSetAdaptInputToCpuUsage) { |
| 1612 | EXPECT_TRUE(SetupEngine()); |
| 1613 | cricket::VideoOptions options_in, options_out; |
| 1614 | bool cpu_adapt = false; |
| 1615 | channel_->SetOptions(options_in); |
| 1616 | EXPECT_TRUE(channel_->GetOptions(&options_out)); |
| 1617 | EXPECT_FALSE(options_out.adapt_input_to_cpu_usage.Get(&cpu_adapt)); |
| 1618 | // Set adapt input CPU usage option. |
| 1619 | options_in.adapt_input_to_cpu_usage.Set(true); |
| 1620 | EXPECT_TRUE(channel_->SetOptions(options_in)); |
| 1621 | EXPECT_TRUE(channel_->GetOptions(&options_out)); |
| 1622 | EXPECT_TRUE(options_out.adapt_input_to_cpu_usage.Get(&cpu_adapt)); |
| 1623 | EXPECT_TRUE(cpu_adapt); |
| 1624 | } |
| 1625 | |
| 1626 | TEST_F(WebRtcVideoEngineTestFake, TestSetCpuThreshold) { |
| 1627 | EXPECT_TRUE(SetupEngine()); |
| 1628 | float low, high; |
| 1629 | cricket::VideoOptions options_in, options_out; |
| 1630 | // Verify that initial values are set. |
| 1631 | EXPECT_TRUE(channel_->GetOptions(&options_out)); |
| 1632 | EXPECT_TRUE(options_out.system_low_adaptation_threshhold.Get(&low)); |
| 1633 | EXPECT_EQ(low, 0.65f); |
| 1634 | EXPECT_TRUE(options_out.system_high_adaptation_threshhold.Get(&high)); |
| 1635 | EXPECT_EQ(high, 0.85f); |
| 1636 | // Set new CPU threshold values. |
| 1637 | options_in.system_low_adaptation_threshhold.Set(0.45f); |
| 1638 | options_in.system_high_adaptation_threshhold.Set(0.95f); |
| 1639 | EXPECT_TRUE(channel_->SetOptions(options_in)); |
| 1640 | EXPECT_TRUE(channel_->GetOptions(&options_out)); |
| 1641 | EXPECT_TRUE(options_out.system_low_adaptation_threshhold.Get(&low)); |
| 1642 | EXPECT_EQ(low, 0.45f); |
| 1643 | EXPECT_TRUE(options_out.system_high_adaptation_threshhold.Get(&high)); |
| 1644 | EXPECT_EQ(high, 0.95f); |
| 1645 | } |
| 1646 | |
| 1647 | TEST_F(WebRtcVideoEngineTestFake, TestSetInvalidCpuThreshold) { |
| 1648 | EXPECT_TRUE(SetupEngine()); |
| 1649 | float low, high; |
| 1650 | cricket::VideoOptions options_in, options_out; |
| 1651 | // Valid range is [0, 1]. |
| 1652 | options_in.system_low_adaptation_threshhold.Set(-1.5f); |
| 1653 | options_in.system_high_adaptation_threshhold.Set(1.5f); |
| 1654 | EXPECT_TRUE(channel_->SetOptions(options_in)); |
| 1655 | EXPECT_TRUE(channel_->GetOptions(&options_out)); |
| 1656 | EXPECT_TRUE(options_out.system_low_adaptation_threshhold.Get(&low)); |
| 1657 | EXPECT_EQ(low, 0.0f); |
| 1658 | EXPECT_TRUE(options_out.system_high_adaptation_threshhold.Get(&high)); |
| 1659 | EXPECT_EQ(high, 1.0f); |
| 1660 | } |
| 1661 | |
| 1662 | |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1663 | TEST_F(WebRtcVideoEngineTestFake, ResetCodecOnScreencast) { |
| 1664 | EXPECT_TRUE(SetupEngine()); |
| 1665 | cricket::VideoOptions options; |
| 1666 | options.video_noise_reduction.Set(true); |
| 1667 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1668 | |
| 1669 | // Set send codec. |
| 1670 | cricket::VideoCodec codec(kVP8Codec); |
| 1671 | std::vector<cricket::VideoCodec> codec_list; |
| 1672 | codec_list.push_back(codec); |
| 1673 | EXPECT_TRUE(channel_->AddSendStream( |
| 1674 | cricket::StreamParams::CreateLegacy(123))); |
| 1675 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 1676 | EXPECT_TRUE(channel_->SetSend(true)); |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 1677 | EXPECT_EQ(1, vie_.GetNumSetSendCodecs()); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1678 | |
| 1679 | webrtc::VideoCodec gcodec; |
| 1680 | memset(&gcodec, 0, sizeof(gcodec)); |
| 1681 | int channel_num = vie_.GetLastChannel(); |
| 1682 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec)); |
| 1683 | EXPECT_TRUE(gcodec.codecSpecific.VP8.denoisingOn); |
| 1684 | |
| 1685 | // Send a screencast frame with the same size. |
| 1686 | // Verify that denoising is turned off. |
| 1687 | SendI420ScreencastFrame(kVP8Codec.width, kVP8Codec.height); |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 1688 | EXPECT_EQ(2, vie_.GetNumSetSendCodecs()); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1689 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec)); |
| 1690 | EXPECT_FALSE(gcodec.codecSpecific.VP8.denoisingOn); |
| 1691 | } |
| 1692 | |
| 1693 | |
| 1694 | TEST_F(WebRtcVideoEngineTestFake, DontRegisterDecoderIfFactoryIsNotGiven) { |
| 1695 | engine_.SetExternalDecoderFactory(NULL); |
| 1696 | EXPECT_TRUE(SetupEngine()); |
| 1697 | int channel_num = vie_.GetLastChannel(); |
| 1698 | |
| 1699 | std::vector<cricket::VideoCodec> codecs; |
| 1700 | codecs.push_back(kVP8Codec); |
| 1701 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1702 | |
| 1703 | EXPECT_EQ(0, vie_.GetNumExternalDecoderRegistered(channel_num)); |
| 1704 | } |
| 1705 | |
| 1706 | TEST_F(WebRtcVideoEngineTestFake, RegisterDecoderIfFactoryIsGiven) { |
| 1707 | decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); |
| 1708 | engine_.SetExternalDecoderFactory(&decoder_factory_); |
| 1709 | EXPECT_TRUE(SetupEngine()); |
| 1710 | int channel_num = vie_.GetLastChannel(); |
| 1711 | |
| 1712 | std::vector<cricket::VideoCodec> codecs; |
| 1713 | codecs.push_back(kVP8Codec); |
| 1714 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1715 | |
| 1716 | EXPECT_TRUE(vie_.ExternalDecoderRegistered(channel_num, 100)); |
| 1717 | EXPECT_EQ(1, vie_.GetNumExternalDecoderRegistered(channel_num)); |
| 1718 | } |
| 1719 | |
| 1720 | TEST_F(WebRtcVideoEngineTestFake, DontRegisterDecoderMultipleTimes) { |
| 1721 | decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); |
| 1722 | engine_.SetExternalDecoderFactory(&decoder_factory_); |
| 1723 | EXPECT_TRUE(SetupEngine()); |
| 1724 | int channel_num = vie_.GetLastChannel(); |
| 1725 | |
| 1726 | std::vector<cricket::VideoCodec> codecs; |
| 1727 | codecs.push_back(kVP8Codec); |
| 1728 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1729 | |
| 1730 | EXPECT_TRUE(vie_.ExternalDecoderRegistered(channel_num, 100)); |
| 1731 | EXPECT_EQ(1, vie_.GetNumExternalDecoderRegistered(channel_num)); |
| 1732 | EXPECT_EQ(1, decoder_factory_.GetNumCreatedDecoders()); |
| 1733 | |
| 1734 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1735 | EXPECT_EQ(1, vie_.GetNumExternalDecoderRegistered(channel_num)); |
| 1736 | EXPECT_EQ(1, decoder_factory_.GetNumCreatedDecoders()); |
| 1737 | } |
| 1738 | |
| 1739 | TEST_F(WebRtcVideoEngineTestFake, DontRegisterDecoderForNonVP8) { |
| 1740 | decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); |
| 1741 | engine_.SetExternalDecoderFactory(&decoder_factory_); |
| 1742 | EXPECT_TRUE(SetupEngine()); |
| 1743 | int channel_num = vie_.GetLastChannel(); |
| 1744 | |
| 1745 | std::vector<cricket::VideoCodec> codecs; |
| 1746 | codecs.push_back(kRedCodec); |
| 1747 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1748 | |
| 1749 | EXPECT_EQ(0, vie_.GetNumExternalDecoderRegistered(channel_num)); |
| 1750 | } |
| 1751 | |
| 1752 | TEST_F(WebRtcVideoEngineTestFake, DontRegisterEncoderIfFactoryIsNotGiven) { |
| 1753 | engine_.SetExternalEncoderFactory(NULL); |
| 1754 | EXPECT_TRUE(SetupEngine()); |
| 1755 | int channel_num = vie_.GetLastChannel(); |
| 1756 | |
| 1757 | std::vector<cricket::VideoCodec> codecs; |
| 1758 | codecs.push_back(kVP8Codec); |
| 1759 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1760 | |
| 1761 | EXPECT_EQ(0, vie_.GetNumExternalEncoderRegistered(channel_num)); |
| 1762 | } |
| 1763 | |
| 1764 | TEST_F(WebRtcVideoEngineTestFake, RegisterEncoderIfFactoryIsGiven) { |
| 1765 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
| 1766 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1767 | EXPECT_TRUE(SetupEngine()); |
| 1768 | int channel_num = vie_.GetLastChannel(); |
| 1769 | |
| 1770 | std::vector<cricket::VideoCodec> codecs; |
| 1771 | codecs.push_back(kVP8Codec); |
| 1772 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1773 | |
| 1774 | EXPECT_TRUE(channel_->AddSendStream( |
| 1775 | cricket::StreamParams::CreateLegacy(kSsrc))); |
| 1776 | |
| 1777 | EXPECT_TRUE(vie_.ExternalEncoderRegistered(channel_num, 100)); |
| 1778 | EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num)); |
| 1779 | |
| 1780 | // Remove stream previously added to free the external encoder instance. |
| 1781 | EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); |
| 1782 | } |
| 1783 | |
| 1784 | TEST_F(WebRtcVideoEngineTestFake, DontRegisterEncoderMultipleTimes) { |
| 1785 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
| 1786 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1787 | EXPECT_TRUE(SetupEngine()); |
| 1788 | int channel_num = vie_.GetLastChannel(); |
| 1789 | |
| 1790 | std::vector<cricket::VideoCodec> codecs; |
| 1791 | codecs.push_back(kVP8Codec); |
| 1792 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1793 | |
| 1794 | EXPECT_TRUE(channel_->AddSendStream( |
| 1795 | cricket::StreamParams::CreateLegacy(kSsrc))); |
| 1796 | |
| 1797 | EXPECT_TRUE(vie_.ExternalEncoderRegistered(channel_num, 100)); |
| 1798 | EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num)); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1799 | |
| 1800 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1801 | EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num)); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1802 | |
| 1803 | // Remove stream previously added to free the external encoder instance. |
| 1804 | EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); |
| 1805 | } |
| 1806 | |
| 1807 | TEST_F(WebRtcVideoEngineTestFake, RegisterEncoderWithMultipleSendStreams) { |
| 1808 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
| 1809 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1810 | EXPECT_TRUE(SetupEngine()); |
| 1811 | |
| 1812 | std::vector<cricket::VideoCodec> codecs; |
| 1813 | codecs.push_back(kVP8Codec); |
| 1814 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1815 | EXPECT_EQ(1, vie_.GetTotalNumExternalEncoderRegistered()); |
| 1816 | |
| 1817 | // When we add the first stream (1234), it reuses the default send channel, |
| 1818 | // so it doesn't increase the registration count of external encoders. |
| 1819 | EXPECT_TRUE(channel_->AddSendStream( |
| 1820 | cricket::StreamParams::CreateLegacy(1234))); |
| 1821 | EXPECT_EQ(1, vie_.GetTotalNumExternalEncoderRegistered()); |
| 1822 | |
| 1823 | // When we add the second stream (2345), it creates a new channel and |
| 1824 | // increments the registration count. |
| 1825 | EXPECT_TRUE(channel_->AddSendStream( |
| 1826 | cricket::StreamParams::CreateLegacy(2345))); |
| 1827 | EXPECT_EQ(2, vie_.GetTotalNumExternalEncoderRegistered()); |
| 1828 | |
| 1829 | // At this moment the total registration count is two, but only one encoder |
| 1830 | // is registered per channel. |
| 1831 | int channel_num = vie_.GetLastChannel(); |
| 1832 | EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num)); |
| 1833 | |
| 1834 | // Removing send streams decrements the registration count. |
| 1835 | EXPECT_TRUE(channel_->RemoveSendStream(1234)); |
| 1836 | EXPECT_EQ(1, vie_.GetTotalNumExternalEncoderRegistered()); |
| 1837 | |
| 1838 | // When we remove the last send stream, it also destroys the last send |
| 1839 | // channel and causes the registration count to drop to zero. It is a little |
| 1840 | // weird, but not a bug. |
| 1841 | EXPECT_TRUE(channel_->RemoveSendStream(2345)); |
| 1842 | EXPECT_EQ(0, vie_.GetTotalNumExternalEncoderRegistered()); |
| 1843 | } |
| 1844 | |
| 1845 | TEST_F(WebRtcVideoEngineTestFake, DontRegisterEncoderForNonVP8) { |
| 1846 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecGeneric, |
| 1847 | "GENERIC"); |
| 1848 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1849 | EXPECT_TRUE(SetupEngine()); |
| 1850 | int channel_num = vie_.GetLastChannel(); |
| 1851 | |
| 1852 | // Note: unlike the SetRecvCodecs, we must set a valid video codec for |
| 1853 | // channel_->SetSendCodecs() to succeed. |
| 1854 | std::vector<cricket::VideoCodec> codecs; |
| 1855 | codecs.push_back(kVP8Codec); |
| 1856 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1857 | |
| 1858 | EXPECT_EQ(0, vie_.GetNumExternalEncoderRegistered(channel_num)); |
| 1859 | } |
| 1860 | |
| 1861 | // Test that NACK, PLI and REMB are enabled for external codec. |
| 1862 | TEST_F(WebRtcVideoEngineTestFake, ExternalCodecFeedbackParams) { |
| 1863 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecGeneric, |
| 1864 | "GENERIC"); |
| 1865 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1866 | encoder_factory_.NotifyCodecsAvailable(); |
| 1867 | EXPECT_TRUE(SetupEngine()); |
| 1868 | |
| 1869 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 1870 | // The external codec will appear at last. |
| 1871 | size_t pos = codecs.size() - 1; |
| 1872 | EXPECT_EQ("GENERIC", codecs[pos].name); |
| 1873 | VerifyCodecFeedbackParams(codecs[pos]); |
| 1874 | } |
| 1875 | |
| 1876 | // Test external codec with be added to the end of the supported codec list. |
| 1877 | TEST_F(WebRtcVideoEngineTestFake, ExternalCodecAddedToTheEnd) { |
| 1878 | EXPECT_TRUE(SetupEngine()); |
| 1879 | |
| 1880 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 1881 | EXPECT_EQ("VP8", codecs[0].name); |
| 1882 | |
| 1883 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecGeneric, |
| 1884 | "GENERIC"); |
| 1885 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1886 | encoder_factory_.NotifyCodecsAvailable(); |
| 1887 | |
| 1888 | codecs = engine_.codecs(); |
| 1889 | cricket::VideoCodec internal_codec = codecs[0]; |
| 1890 | cricket::VideoCodec external_codec = codecs[codecs.size() - 1]; |
| 1891 | // The external codec will appear at last. |
| 1892 | EXPECT_EQ("GENERIC", external_codec.name); |
| 1893 | // The internal codec is preferred. |
| 1894 | EXPECT_GE(internal_codec.preference, external_codec.preference); |
| 1895 | } |
| 1896 | |
| 1897 | // Test that external codec with be ignored if it has the same name as one of |
| 1898 | // the internal codecs. |
| 1899 | TEST_F(WebRtcVideoEngineTestFake, ExternalCodecIgnored) { |
| 1900 | EXPECT_TRUE(SetupEngine()); |
| 1901 | |
| 1902 | std::vector<cricket::VideoCodec> internal_codecs(engine_.codecs()); |
| 1903 | EXPECT_EQ("VP8", internal_codecs[0].name); |
| 1904 | |
| 1905 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
| 1906 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1907 | encoder_factory_.NotifyCodecsAvailable(); |
| 1908 | |
| 1909 | std::vector<cricket::VideoCodec> codecs = engine_.codecs(); |
| 1910 | EXPECT_EQ("VP8", codecs[0].name); |
| 1911 | EXPECT_EQ(internal_codecs[0].height, codecs[0].height); |
| 1912 | EXPECT_EQ(internal_codecs[0].width, codecs[0].width); |
| 1913 | // Verify the last codec is not the external codec. |
| 1914 | EXPECT_NE("VP8", codecs[codecs.size() - 1].name); |
| 1915 | } |
| 1916 | |
| 1917 | TEST_F(WebRtcVideoEngineTestFake, UpdateEncoderCodecsAfterSetFactory) { |
| 1918 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1919 | EXPECT_TRUE(SetupEngine()); |
| 1920 | int channel_num = vie_.GetLastChannel(); |
| 1921 | |
| 1922 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
| 1923 | encoder_factory_.NotifyCodecsAvailable(); |
| 1924 | std::vector<cricket::VideoCodec> codecs; |
| 1925 | codecs.push_back(kVP8Codec); |
| 1926 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1927 | |
| 1928 | EXPECT_TRUE(channel_->AddSendStream( |
| 1929 | cricket::StreamParams::CreateLegacy(kSsrc))); |
| 1930 | |
| 1931 | EXPECT_TRUE(vie_.ExternalEncoderRegistered(channel_num, 100)); |
| 1932 | EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num)); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1933 | |
| 1934 | // Remove stream previously added to free the external encoder instance. |
| 1935 | EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); |
| 1936 | } |
| 1937 | |
| 1938 | // Tests that OnReadyToSend will be propagated into ViE. |
| 1939 | TEST_F(WebRtcVideoEngineTestFake, OnReadyToSend) { |
| 1940 | EXPECT_TRUE(SetupEngine()); |
| 1941 | int channel_num = vie_.GetLastChannel(); |
| 1942 | EXPECT_TRUE(vie_.GetIsTransmitting(channel_num)); |
| 1943 | |
| 1944 | channel_->OnReadyToSend(false); |
| 1945 | EXPECT_FALSE(vie_.GetIsTransmitting(channel_num)); |
| 1946 | |
| 1947 | channel_->OnReadyToSend(true); |
| 1948 | EXPECT_TRUE(vie_.GetIsTransmitting(channel_num)); |
| 1949 | } |
| 1950 | |
| 1951 | #if 0 |
| 1952 | TEST_F(WebRtcVideoEngineTestFake, CaptureFrameTimestampToNtpTimestamp) { |
| 1953 | EXPECT_TRUE(SetupEngine()); |
| 1954 | int capture_id = vie_.GetCaptureId(vie_.GetLastChannel()); |
| 1955 | |
| 1956 | // Set send codec. |
| 1957 | cricket::VideoCodec codec(kVP8Codec); |
| 1958 | std::vector<cricket::VideoCodec> codec_list; |
| 1959 | codec_list.push_back(codec); |
| 1960 | EXPECT_TRUE(channel_->AddSendStream( |
| 1961 | cricket::StreamParams::CreateLegacy(123))); |
| 1962 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 1963 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1964 | |
| 1965 | int64 timestamp = time(NULL) * talk_base::kNumNanosecsPerSec; |
| 1966 | SendI420ScreencastFrameWithTimestamp( |
| 1967 | kVP8Codec.width, kVP8Codec.height, timestamp); |
| 1968 | EXPECT_EQ(talk_base::UnixTimestampNanosecsToNtpMillisecs(timestamp), |
| 1969 | vie_.GetCaptureLastTimestamp(capture_id)); |
| 1970 | |
| 1971 | SendI420ScreencastFrameWithTimestamp(kVP8Codec.width, kVP8Codec.height, 0); |
| 1972 | EXPECT_EQ(0, vie_.GetCaptureLastTimestamp(capture_id)); |
| 1973 | } |
| 1974 | #endif |
| 1975 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1976 | ///////////////////////// |
| 1977 | // Tests with real ViE // |
| 1978 | ///////////////////////// |
| 1979 | |
| 1980 | // Tests that we can find codecs by name or id. |
| 1981 | TEST_F(WebRtcVideoEngineTest, FindCodec) { |
| 1982 | // We should not need to init engine in order to get codecs. |
| 1983 | const std::vector<cricket::VideoCodec>& c = engine_.codecs(); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 1984 | EXPECT_EQ(4U, c.size()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1985 | |
| 1986 | cricket::VideoCodec vp8(104, "VP8", 320, 200, 30, 0); |
| 1987 | EXPECT_TRUE(engine_.FindCodec(vp8)); |
| 1988 | |
| 1989 | cricket::VideoCodec vp8_ci(104, "vp8", 320, 200, 30, 0); |
| 1990 | EXPECT_TRUE(engine_.FindCodec(vp8)); |
| 1991 | |
| 1992 | cricket::VideoCodec vp8_diff_fr_diff_pref(104, "VP8", 320, 200, 50, 50); |
| 1993 | EXPECT_TRUE(engine_.FindCodec(vp8_diff_fr_diff_pref)); |
| 1994 | |
| 1995 | cricket::VideoCodec vp8_diff_id(95, "VP8", 320, 200, 30, 0); |
| 1996 | EXPECT_FALSE(engine_.FindCodec(vp8_diff_id)); |
| 1997 | vp8_diff_id.id = 97; |
| 1998 | EXPECT_TRUE(engine_.FindCodec(vp8_diff_id)); |
| 1999 | |
| 2000 | cricket::VideoCodec vp8_diff_res(104, "VP8", 320, 111, 30, 0); |
| 2001 | EXPECT_FALSE(engine_.FindCodec(vp8_diff_res)); |
| 2002 | |
| 2003 | // PeerConnection doesn't negotiate the resolution at this point. |
| 2004 | // Test that FindCodec can handle the case when width/height is 0. |
| 2005 | cricket::VideoCodec vp8_zero_res(104, "VP8", 0, 0, 30, 0); |
| 2006 | EXPECT_TRUE(engine_.FindCodec(vp8_zero_res)); |
| 2007 | |
| 2008 | cricket::VideoCodec red(101, "RED", 0, 0, 30, 0); |
| 2009 | EXPECT_TRUE(engine_.FindCodec(red)); |
| 2010 | |
| 2011 | cricket::VideoCodec red_ci(101, "red", 0, 0, 30, 0); |
| 2012 | EXPECT_TRUE(engine_.FindCodec(red)); |
| 2013 | |
| 2014 | cricket::VideoCodec fec(102, "ULPFEC", 0, 0, 30, 0); |
| 2015 | EXPECT_TRUE(engine_.FindCodec(fec)); |
| 2016 | |
| 2017 | cricket::VideoCodec fec_ci(102, "ulpfec", 0, 0, 30, 0); |
| 2018 | EXPECT_TRUE(engine_.FindCodec(fec)); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 2019 | |
| 2020 | cricket::VideoCodec rtx(96, "rtx", 0, 0, 30, 0); |
| 2021 | EXPECT_TRUE(engine_.FindCodec(rtx)); |
| 2022 | } |
| 2023 | |
| 2024 | TEST_F(WebRtcVideoEngineTest, RtxCodecHasAptSet) { |
| 2025 | std::vector<cricket::VideoCodec>::const_iterator it; |
| 2026 | bool apt_checked = false; |
| 2027 | for (it = engine_.codecs().begin(); it != engine_.codecs().end(); ++it) { |
| 2028 | if (_stricmp(cricket::kRtxCodecName, it->name.c_str()) && it->id != 96) { |
| 2029 | continue; |
| 2030 | } |
| 2031 | int apt; |
| 2032 | EXPECT_TRUE(it->GetParam("apt", &apt)); |
| 2033 | EXPECT_EQ(100, apt); |
| 2034 | apt_checked = true; |
| 2035 | } |
| 2036 | EXPECT_TRUE(apt_checked); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2037 | } |
| 2038 | |
| 2039 | TEST_F(WebRtcVideoEngineTest, StartupShutdown) { |
| 2040 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 2041 | engine_.Terminate(); |
| 2042 | } |
| 2043 | |
| 2044 | TEST_PRE_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainNewCodec) |
| 2045 | TEST_POST_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainNewCodec) |
| 2046 | |
| 2047 | TEST_PRE_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainRunningCodec) |
| 2048 | TEST_POST_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainRunningCodec) |
| 2049 | |
| 2050 | // TODO(juberti): Figure out why ViE is munging the COM refcount. |
| 2051 | #ifdef WIN32 |
| 2052 | TEST_F(WebRtcVideoEngineTest, DISABLED_CheckCoInitialize) { |
| 2053 | Base::CheckCoInitialize(); |
| 2054 | } |
| 2055 | #endif |
| 2056 | |
| 2057 | TEST_F(WebRtcVideoEngineTest, CreateChannel) { |
| 2058 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 2059 | cricket::VideoMediaChannel* channel = engine_.CreateChannel(NULL); |
| 2060 | EXPECT_TRUE(channel != NULL); |
| 2061 | delete channel; |
| 2062 | } |
| 2063 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2064 | TEST_F(WebRtcVideoMediaChannelTest, SetRecvCodecs) { |
| 2065 | std::vector<cricket::VideoCodec> codecs; |
| 2066 | codecs.push_back(kVP8Codec); |
| 2067 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 2068 | } |
| 2069 | TEST_F(WebRtcVideoMediaChannelTest, SetRecvCodecsWrongPayloadType) { |
| 2070 | std::vector<cricket::VideoCodec> codecs; |
| 2071 | codecs.push_back(kVP8Codec); |
| 2072 | codecs[0].id = 99; |
| 2073 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 2074 | } |
| 2075 | TEST_F(WebRtcVideoMediaChannelTest, SetRecvCodecsUnsupportedCodec) { |
| 2076 | std::vector<cricket::VideoCodec> codecs; |
| 2077 | codecs.push_back(kVP8Codec); |
| 2078 | codecs.push_back(cricket::VideoCodec(101, "VP1", 640, 400, 30, 0)); |
| 2079 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 2080 | } |
| 2081 | |
mallinath@webrtc.org | 92fdfeb | 2014-02-17 18:49:41 +0000 | [diff] [blame] | 2082 | TEST_F(WebRtcVideoMediaChannelTest, GetRtpSendTimeExtension) { |
| 2083 | // Enable RTP timestamp extension. |
| 2084 | const int id = 12; |
| 2085 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 2086 | extensions.push_back(cricket::RtpHeaderExtension( |
| 2087 | "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", id)); |
| 2088 | |
| 2089 | // Verify the send extension id. |
| 2090 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 2091 | EXPECT_EQ(id, channel_->GetRtpSendTimeExtnId()); |
| 2092 | } |
| 2093 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2094 | TEST_F(WebRtcVideoMediaChannelTest, SetSend) { |
| 2095 | Base::SetSend(); |
| 2096 | } |
| 2097 | TEST_F(WebRtcVideoMediaChannelTest, SetSendWithoutCodecs) { |
| 2098 | Base::SetSendWithoutCodecs(); |
| 2099 | } |
| 2100 | TEST_F(WebRtcVideoMediaChannelTest, SetSendSetsTransportBufferSizes) { |
| 2101 | Base::SetSendSetsTransportBufferSizes(); |
| 2102 | } |
| 2103 | |
| 2104 | TEST_F(WebRtcVideoMediaChannelTest, SendAndReceiveVp8Vga) { |
| 2105 | SendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30, 0)); |
| 2106 | } |
| 2107 | TEST_F(WebRtcVideoMediaChannelTest, SendAndReceiveVp8Qvga) { |
| 2108 | SendAndReceive(cricket::VideoCodec(100, "VP8", 320, 200, 30, 0)); |
| 2109 | } |
| 2110 | TEST_F(WebRtcVideoMediaChannelTest, SendAndReceiveH264SvcQqvga) { |
| 2111 | SendAndReceive(cricket::VideoCodec(100, "VP8", 160, 100, 30, 0)); |
| 2112 | } |
| 2113 | TEST_F(WebRtcVideoMediaChannelTest, SendManyResizeOnce) { |
| 2114 | SendManyResizeOnce(); |
| 2115 | } |
| 2116 | |
| 2117 | TEST_F(WebRtcVideoMediaChannelTest, SendVp8HdAndReceiveAdaptedVp8Vga) { |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 2118 | EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2119 | channel_->UpdateAspectRatio(1280, 720); |
| 2120 | video_capturer_.reset(new cricket::FakeVideoCapturer); |
| 2121 | const std::vector<cricket::VideoFormat>* formats = |
| 2122 | video_capturer_->GetSupportedFormats(); |
| 2123 | cricket::VideoFormat capture_format_hd = (*formats)[0]; |
| 2124 | EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(capture_format_hd)); |
| 2125 | EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get())); |
| 2126 | |
| 2127 | // Capture format HD -> adapt (OnOutputFormatRequest VGA) -> VGA. |
| 2128 | cricket::VideoCodec codec(100, "VP8", 1280, 720, 30, 0); |
| 2129 | EXPECT_TRUE(SetOneCodec(codec)); |
| 2130 | codec.width /= 2; |
| 2131 | codec.height /= 2; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2132 | EXPECT_TRUE(SetSend(true)); |
| 2133 | EXPECT_TRUE(channel_->SetRender(true)); |
| 2134 | EXPECT_EQ(0, renderer_.num_rendered_frames()); |
| 2135 | EXPECT_TRUE(SendFrame()); |
| 2136 | EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); |
| 2137 | } |
| 2138 | |
| 2139 | // TODO(juberti): Fix this test to tolerate missing stats. |
| 2140 | TEST_F(WebRtcVideoMediaChannelTest, DISABLED_GetStats) { |
| 2141 | Base::GetStats(); |
| 2142 | } |
| 2143 | |
| 2144 | // TODO(juberti): Fix this test to tolerate missing stats. |
| 2145 | TEST_F(WebRtcVideoMediaChannelTest, DISABLED_GetStatsMultipleRecvStreams) { |
| 2146 | Base::GetStatsMultipleRecvStreams(); |
| 2147 | } |
| 2148 | |
| 2149 | TEST_F(WebRtcVideoMediaChannelTest, GetStatsMultipleSendStreams) { |
| 2150 | Base::GetStatsMultipleSendStreams(); |
| 2151 | } |
| 2152 | |
| 2153 | TEST_F(WebRtcVideoMediaChannelTest, SetSendBandwidth) { |
| 2154 | Base::SetSendBandwidth(); |
| 2155 | } |
| 2156 | TEST_F(WebRtcVideoMediaChannelTest, SetSendSsrc) { |
| 2157 | Base::SetSendSsrc(); |
| 2158 | } |
| 2159 | TEST_F(WebRtcVideoMediaChannelTest, SetSendSsrcAfterSetCodecs) { |
| 2160 | Base::SetSendSsrcAfterSetCodecs(); |
| 2161 | } |
| 2162 | |
| 2163 | TEST_F(WebRtcVideoMediaChannelTest, SetRenderer) { |
| 2164 | Base::SetRenderer(); |
| 2165 | } |
| 2166 | |
| 2167 | TEST_F(WebRtcVideoMediaChannelTest, AddRemoveRecvStreams) { |
| 2168 | Base::AddRemoveRecvStreams(); |
| 2169 | } |
| 2170 | |
| 2171 | TEST_F(WebRtcVideoMediaChannelTest, AddRemoveRecvStreamAndRender) { |
| 2172 | Base::AddRemoveRecvStreamAndRender(); |
| 2173 | } |
| 2174 | |
| 2175 | TEST_F(WebRtcVideoMediaChannelTest, AddRemoveRecvStreamsNoConference) { |
| 2176 | Base::AddRemoveRecvStreamsNoConference(); |
| 2177 | } |
| 2178 | |
| 2179 | TEST_F(WebRtcVideoMediaChannelTest, AddRemoveSendStreams) { |
| 2180 | Base::AddRemoveSendStreams(); |
| 2181 | } |
| 2182 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2183 | TEST_F(WebRtcVideoMediaChannelTest, SimulateConference) { |
| 2184 | Base::SimulateConference(); |
| 2185 | } |
| 2186 | |
| 2187 | TEST_F(WebRtcVideoMediaChannelTest, AddRemoveCapturer) { |
| 2188 | Base::AddRemoveCapturer(); |
| 2189 | } |
| 2190 | |
| 2191 | TEST_F(WebRtcVideoMediaChannelTest, RemoveCapturerWithoutAdd) { |
| 2192 | Base::RemoveCapturerWithoutAdd(); |
| 2193 | } |
| 2194 | |
| 2195 | TEST_F(WebRtcVideoMediaChannelTest, AddRemoveCapturerMultipleSources) { |
| 2196 | Base::AddRemoveCapturerMultipleSources(); |
| 2197 | } |
| 2198 | |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 2199 | // This test verifies DSCP settings are properly applied on video media channel. |
| 2200 | TEST_F(WebRtcVideoMediaChannelTest, TestSetDscpOptions) { |
| 2201 | talk_base::scoped_ptr<cricket::FakeNetworkInterface> network_interface( |
| 2202 | new cricket::FakeNetworkInterface); |
| 2203 | channel_->SetInterface(network_interface.get()); |
| 2204 | cricket::VideoOptions options; |
| 2205 | options.dscp.Set(true); |
| 2206 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 2207 | EXPECT_EQ(talk_base::DSCP_AF41, network_interface->dscp()); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 2208 | // Verify previous value is not modified if dscp option is not set. |
| 2209 | cricket::VideoOptions options1; |
| 2210 | EXPECT_TRUE(channel_->SetOptions(options1)); |
| 2211 | EXPECT_EQ(talk_base::DSCP_AF41, network_interface->dscp()); |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 2212 | options.dscp.Set(false); |
| 2213 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 2214 | EXPECT_EQ(talk_base::DSCP_DEFAULT, network_interface->dscp()); |
| 2215 | channel_->SetInterface(NULL); |
| 2216 | } |
| 2217 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2218 | |
| 2219 | TEST_F(WebRtcVideoMediaChannelTest, SetOptionsSucceedsWhenSending) { |
| 2220 | cricket::VideoOptions options; |
| 2221 | options.conference_mode.Set(true); |
| 2222 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 2223 | |
| 2224 | // Verify SetOptions returns true on a different options. |
| 2225 | cricket::VideoOptions options2; |
| 2226 | options2.adapt_input_to_cpu_usage.Set(true); |
| 2227 | EXPECT_TRUE(channel_->SetOptions(options2)); |
| 2228 | |
| 2229 | // Set send codecs on the channel and start sending. |
| 2230 | std::vector<cricket::VideoCodec> codecs; |
| 2231 | codecs.push_back(kVP8Codec); |
| 2232 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 2233 | EXPECT_TRUE(channel_->SetSend(true)); |
| 2234 | |
| 2235 | // Verify SetOptions returns true if channel is already sending. |
| 2236 | cricket::VideoOptions options3; |
| 2237 | options3.conference_mode.Set(true); |
| 2238 | EXPECT_TRUE(channel_->SetOptions(options3)); |
| 2239 | } |
| 2240 | |
| 2241 | // Tests empty StreamParams is rejected. |
| 2242 | TEST_F(WebRtcVideoMediaChannelTest, RejectEmptyStreamParams) { |
| 2243 | Base::RejectEmptyStreamParams(); |
| 2244 | } |
| 2245 | |
| 2246 | |
| 2247 | TEST_F(WebRtcVideoMediaChannelTest, AdaptResolution16x10) { |
| 2248 | Base::AdaptResolution16x10(); |
| 2249 | } |
| 2250 | |
| 2251 | TEST_F(WebRtcVideoMediaChannelTest, AdaptResolution4x3) { |
| 2252 | Base::AdaptResolution4x3(); |
| 2253 | } |
| 2254 | |
| 2255 | TEST_F(WebRtcVideoMediaChannelTest, MuteStream) { |
| 2256 | Base::MuteStream(); |
| 2257 | } |
| 2258 | |
| 2259 | TEST_F(WebRtcVideoMediaChannelTest, MultipleSendStreams) { |
| 2260 | Base::MultipleSendStreams(); |
| 2261 | } |
| 2262 | |
| 2263 | // TODO(juberti): Restore this test once we support sending 0 fps. |
| 2264 | TEST_F(WebRtcVideoMediaChannelTest, DISABLED_AdaptDropAllFrames) { |
| 2265 | Base::AdaptDropAllFrames(); |
| 2266 | } |
| 2267 | // TODO(juberti): Understand why we get decode errors on this test. |
| 2268 | TEST_F(WebRtcVideoMediaChannelTest, DISABLED_AdaptFramerate) { |
| 2269 | Base::AdaptFramerate(); |
| 2270 | } |
| 2271 | |
| 2272 | TEST_F(WebRtcVideoMediaChannelTest, SetSendStreamFormat0x0) { |
| 2273 | Base::SetSendStreamFormat0x0(); |
| 2274 | } |
| 2275 | |
| 2276 | // TODO(zhurunz): Fix the flakey test. |
| 2277 | TEST_F(WebRtcVideoMediaChannelTest, DISABLED_SetSendStreamFormat) { |
| 2278 | Base::SetSendStreamFormat(); |
| 2279 | } |
| 2280 | |
| 2281 | TEST_F(WebRtcVideoMediaChannelTest, TwoStreamsSendAndReceive) { |
| 2282 | Base::TwoStreamsSendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30, |
| 2283 | 0)); |
| 2284 | } |
| 2285 | |
| 2286 | TEST_F(WebRtcVideoMediaChannelTest, TwoStreamsReUseFirstStream) { |
| 2287 | Base::TwoStreamsReUseFirstStream(cricket::VideoCodec(100, "VP8", 640, 400, 30, |
| 2288 | 0)); |
| 2289 | } |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 2290 | |
buildbot@webrtc.org | 0b3c6c3 | 2014-04-17 10:03:57 +0000 | [diff] [blame] | 2291 | TEST_F(WebRtcVideoMediaChannelTest, DISABLED_TwoStreamsSendAndUnsignalledRecv) { |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 2292 | Base::TwoStreamsSendAndUnsignalledRecv(cricket::VideoCodec(100, "VP8", 640, |
| 2293 | 400, 30, 0)); |
| 2294 | } |
| 2295 | |
henrike@webrtc.org | 806768a | 2014-02-27 21:03:09 +0000 | [diff] [blame] | 2296 | TEST_F(WebRtcVideoMediaChannelTest, |
henrike@webrtc.org | 18e5911 | 2014-03-14 17:19:38 +0000 | [diff] [blame] | 2297 | TwoStreamsSendAndFailUnsignalledRecv) { |
henrike@webrtc.org | 806768a | 2014-02-27 21:03:09 +0000 | [diff] [blame] | 2298 | webrtc::Trace::set_level_filter(webrtc::kTraceAll); |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 2299 | Base::TwoStreamsSendAndFailUnsignalledRecv( |
| 2300 | cricket::VideoCodec(100, "VP8", 640, 400, 30, 0)); |
| 2301 | } |
| 2302 | |
| 2303 | TEST_F(WebRtcVideoMediaChannelTest, |
henrike@webrtc.org | 18e5911 | 2014-03-14 17:19:38 +0000 | [diff] [blame] | 2304 | TwoStreamsSendAndFailUnsignalledRecvInOneToOne) { |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 2305 | Base::TwoStreamsSendAndFailUnsignalledRecvInOneToOne( |
| 2306 | cricket::VideoCodec(100, "VP8", 640, 400, 30, 0)); |
| 2307 | } |
| 2308 | |
| 2309 | TEST_F(WebRtcVideoMediaChannelTest, |
henrike@webrtc.org | 18e5911 | 2014-03-14 17:19:38 +0000 | [diff] [blame] | 2310 | TwoStreamsAddAndRemoveUnsignalledRecv) { |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 2311 | Base::TwoStreamsAddAndRemoveUnsignalledRecv(cricket::VideoCodec(100, "VP8", |
| 2312 | 640, 400, 30, |
| 2313 | 0)); |
| 2314 | } |