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