blob: 376f2958396ef72789b2c495a55c6e674ab9dbdb [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"
39#include "talk/media/base/videoengine_unittest.h"
40#include "talk/media/webrtc/fakewebrtcvideocapturemodule.h"
41#include "talk/media/webrtc/fakewebrtcvideoengine.h"
42#include "talk/media/webrtc/fakewebrtcvoiceengine.h"
43#include "talk/media/webrtc/webrtcvideocapturer.h"
44#include "talk/media/webrtc/webrtcvideoengine.h"
45#include "talk/media/webrtc/webrtcvideoframe.h"
46#include "talk/media/webrtc/webrtcvoiceengine.h"
47#include "talk/session/media/mediasession.h"
48#include "webrtc/system_wrappers/interface/trace.h"
49
50// Tests for the WebRtcVideoEngine/VideoChannel code.
51
52static const cricket::VideoCodec kVP8Codec720p(100, "VP8", 1280, 720, 30, 0);
53static const cricket::VideoCodec kVP8Codec360p(100, "VP8", 640, 360, 30, 0);
54static const cricket::VideoCodec kVP8Codec270p(100, "VP8", 480, 270, 30, 0);
55static const cricket::VideoCodec kVP8Codec180p(100, "VP8", 320, 180, 30, 0);
56
57static const cricket::VideoCodec kVP8Codec(100, "VP8", 640, 400, 30, 0);
58static const cricket::VideoCodec kRedCodec(101, "red", 0, 0, 0, 0);
59static const cricket::VideoCodec kUlpFecCodec(102, "ulpfec", 0, 0, 0, 0);
60static const cricket::VideoCodec* const kVideoCodecs[] = {
61 &kVP8Codec,
62 &kRedCodec,
63 &kUlpFecCodec
64};
65
66static const unsigned int kMinBandwidthKbps = 50;
67static const unsigned int kStartBandwidthKbps = 300;
68static const unsigned int kMaxBandwidthKbps = 2000;
69
70static const unsigned int kNumberOfTemporalLayers = 1;
71
72
73class FakeViEWrapper : public cricket::ViEWrapper {
74 public:
75 explicit FakeViEWrapper(cricket::FakeWebRtcVideoEngine* engine)
76 : cricket::ViEWrapper(engine, // base
77 engine, // codec
78 engine, // capture
79 engine, // network
80 engine, // render
81 engine, // rtp
82 engine, // image
83 engine) { // external decoder
84 }
85};
86
87// Test fixture to test WebRtcVideoEngine with a fake webrtc::VideoEngine.
88// Useful for testing failure paths.
89class WebRtcVideoEngineTestFake : public testing::Test {
90 public:
91 WebRtcVideoEngineTestFake()
92 : vie_(kVideoCodecs, ARRAY_SIZE(kVideoCodecs)),
93 cpu_monitor_(new talk_base::FakeCpuMonitor(
94 talk_base::Thread::Current())),
95 engine_(NULL, // cricket::WebRtcVoiceEngine
96 new FakeViEWrapper(&vie_), cpu_monitor_),
97 channel_(NULL),
98 voice_channel_(NULL) {
99 }
100 bool SetupEngine() {
101 bool result = engine_.Init(talk_base::Thread::Current());
102 if (result) {
103 channel_ = engine_.CreateChannel(voice_channel_);
104 result = (channel_ != NULL);
105 }
106 return result;
107 }
108 bool SendI420Frame(int width, int height) {
109 if (NULL == channel_) {
110 return false;
111 }
112 cricket::WebRtcVideoFrame frame;
113 size_t size = width * height * 3 / 2; // I420
114 talk_base::scoped_array<uint8> pixel(new uint8[size]);
115 if (!frame.Init(cricket::FOURCC_I420,
116 width, height, width, height,
117 pixel.get(), size, 1, 1, 0, 0, 0)) {
118 return false;
119 }
120 cricket::FakeVideoCapturer capturer;
121 channel_->SendFrame(&capturer, &frame);
122 return true;
123 }
124 bool SendI420ScreencastFrame(int width, int height) {
125 return SendI420ScreencastFrameWithTimestamp(width, height, 0);
126 }
127 bool SendI420ScreencastFrameWithTimestamp(
128 int width, int height, int64 timestamp) {
129 if (NULL == channel_) {
130 return false;
131 }
132 cricket::WebRtcVideoFrame frame;
133 size_t size = width * height * 3 / 2; // I420
134 talk_base::scoped_array<uint8> pixel(new uint8[size]);
135 if (!frame.Init(cricket::FOURCC_I420,
136 width, height, width, height,
137 pixel.get(), size, 1, 1, 0, timestamp, 0)) {
138 return false;
139 }
140 cricket::FakeVideoCapturer capturer;
141 capturer.SetScreencast(true);
142 channel_->SendFrame(&capturer, &frame);
143 return true;
144 }
145 void VerifyVP8SendCodec(int channel_num,
146 unsigned int width,
147 unsigned int height,
148 unsigned int layers = 0,
149 unsigned int max_bitrate = kMaxBandwidthKbps,
150 unsigned int min_bitrate = kMinBandwidthKbps,
151 unsigned int start_bitrate = kStartBandwidthKbps,
152 unsigned int fps = 30,
153 unsigned int max_quantization = 0
154 ) {
155 webrtc::VideoCodec gcodec;
156 EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec));
157
158 // Video codec properties.
159 EXPECT_EQ(webrtc::kVideoCodecVP8, gcodec.codecType);
160 EXPECT_STREQ("VP8", gcodec.plName);
161 EXPECT_EQ(100, gcodec.plType);
162 EXPECT_EQ(width, gcodec.width);
163 EXPECT_EQ(height, gcodec.height);
164 EXPECT_EQ(talk_base::_min(start_bitrate, max_bitrate), gcodec.startBitrate);
165 EXPECT_EQ(max_bitrate, gcodec.maxBitrate);
166 EXPECT_EQ(min_bitrate, gcodec.minBitrate);
167 EXPECT_EQ(fps, gcodec.maxFramerate);
168 // VP8 specific.
169 EXPECT_FALSE(gcodec.codecSpecific.VP8.pictureLossIndicationOn);
170 EXPECT_FALSE(gcodec.codecSpecific.VP8.feedbackModeOn);
171 EXPECT_EQ(webrtc::kComplexityNormal, gcodec.codecSpecific.VP8.complexity);
172 EXPECT_EQ(webrtc::kResilienceOff, gcodec.codecSpecific.VP8.resilience);
173 EXPECT_EQ(max_quantization, gcodec.qpMax);
174 }
175 virtual void TearDown() {
176 delete channel_;
177 engine_.Terminate();
178 }
179
180 protected:
181 cricket::FakeWebRtcVideoEngine vie_;
182 cricket::FakeWebRtcVideoDecoderFactory decoder_factory_;
183 cricket::FakeWebRtcVideoEncoderFactory encoder_factory_;
184 talk_base::FakeCpuMonitor* cpu_monitor_;
185 cricket::WebRtcVideoEngine engine_;
186 cricket::WebRtcVideoMediaChannel* channel_;
187 cricket::WebRtcVoiceMediaChannel* voice_channel_;
188};
189
190// Test fixtures to test WebRtcVideoEngine with a real webrtc::VideoEngine.
191class WebRtcVideoEngineTest
192 : public VideoEngineTest<cricket::WebRtcVideoEngine> {
193 protected:
194 typedef VideoEngineTest<cricket::WebRtcVideoEngine> Base;
195};
196class WebRtcVideoMediaChannelTest
197 : public VideoMediaChannelTest<
198 cricket::WebRtcVideoEngine, cricket::WebRtcVideoMediaChannel> {
199 protected:
200 typedef VideoMediaChannelTest<cricket::WebRtcVideoEngine,
201 cricket::WebRtcVideoMediaChannel> Base;
202 virtual cricket::VideoCodec DefaultCodec() { return kVP8Codec; }
203 virtual void SetUp() {
204 Base::SetUp();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000205 }
206 virtual void TearDown() {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000207 Base::TearDown();
208 }
209};
210
211/////////////////////////
212// Tests with fake ViE //
213/////////////////////////
214
215// Tests that our stub library "works".
216TEST_F(WebRtcVideoEngineTestFake, StartupShutdown) {
217 EXPECT_FALSE(vie_.IsInited());
218 EXPECT_TRUE(engine_.Init(talk_base::Thread::Current()));
219 EXPECT_TRUE(vie_.IsInited());
220 engine_.Terminate();
221}
222
223// Tests that webrtc logs are logged when they should be.
224TEST_F(WebRtcVideoEngineTest, WebRtcShouldLog) {
225 const char webrtc_log[] = "WebRtcVideoEngineTest.WebRtcShouldLog";
226 EXPECT_TRUE(engine_.Init(talk_base::Thread::Current()));
227 engine_.SetLogging(talk_base::LS_INFO, "");
228 std::string str;
229 talk_base::StringStream stream(str);
230 talk_base::LogMessage::AddLogToStream(&stream, talk_base::LS_INFO);
231 EXPECT_EQ(talk_base::LS_INFO, talk_base::LogMessage::GetLogToStream(&stream));
232 webrtc::Trace::Add(webrtc::kTraceStateInfo, webrtc::kTraceUndefined, 0,
233 webrtc_log);
234 EXPECT_TRUE_WAIT(std::string::npos != str.find(webrtc_log), 10);
235 talk_base::LogMessage::RemoveLogToStream(&stream);
236}
237
238// Tests that webrtc logs are not logged when they should't be.
239TEST_F(WebRtcVideoEngineTest, WebRtcShouldNotLog) {
240 const char webrtc_log[] = "WebRtcVideoEngineTest.WebRtcShouldNotLog";
241 EXPECT_TRUE(engine_.Init(talk_base::Thread::Current()));
242 // WebRTC should never be logged lower than LS_INFO.
243 engine_.SetLogging(talk_base::LS_WARNING, "");
244 std::string str;
245 talk_base::StringStream stream(str);
246 // Make sure that WebRTC is not logged, even at lowest severity
247 talk_base::LogMessage::AddLogToStream(&stream, talk_base::LS_SENSITIVE);
248 EXPECT_EQ(talk_base::LS_SENSITIVE,
249 talk_base::LogMessage::GetLogToStream(&stream));
250 webrtc::Trace::Add(webrtc::kTraceStateInfo, webrtc::kTraceUndefined, 0,
251 webrtc_log);
252 talk_base::Thread::Current()->ProcessMessages(10);
253 EXPECT_EQ(std::string::npos, str.find(webrtc_log));
254 talk_base::LogMessage::RemoveLogToStream(&stream);
255}
256
257// Tests that we can create and destroy a channel.
258TEST_F(WebRtcVideoEngineTestFake, CreateChannel) {
259 EXPECT_TRUE(engine_.Init(talk_base::Thread::Current()));
260 channel_ = engine_.CreateChannel(voice_channel_);
261 EXPECT_TRUE(channel_ != NULL);
262 EXPECT_EQ(1, engine_.GetNumOfChannels());
263 delete channel_;
264 channel_ = NULL;
265 EXPECT_EQ(0, engine_.GetNumOfChannels());
266}
267
268// Tests that we properly handle failures in CreateChannel.
269TEST_F(WebRtcVideoEngineTestFake, CreateChannelFail) {
270 vie_.set_fail_create_channel(true);
271 EXPECT_TRUE(engine_.Init(talk_base::Thread::Current()));
272 channel_ = engine_.CreateChannel(voice_channel_);
273 EXPECT_TRUE(channel_ == NULL);
274}
275
276// Tests that we properly handle failures in AllocateExternalCaptureDevice.
277TEST_F(WebRtcVideoEngineTestFake, AllocateExternalCaptureDeviceFail) {
278 vie_.set_fail_alloc_capturer(true);
279 EXPECT_TRUE(engine_.Init(talk_base::Thread::Current()));
280 channel_ = engine_.CreateChannel(voice_channel_);
281 EXPECT_TRUE(channel_ == NULL);
282}
283
284// Test that we apply our default codecs properly.
285TEST_F(WebRtcVideoEngineTestFake, SetSendCodecs) {
286 EXPECT_TRUE(SetupEngine());
287 int channel_num = vie_.GetLastChannel();
288 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
289 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
290 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height);
291 EXPECT_TRUE(vie_.GetHybridNackFecStatus(channel_num));
292 EXPECT_FALSE(vie_.GetNackStatus(channel_num));
293 // TODO(juberti): Check RTCP, PLI, TMMBR.
294}
295
296TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithMinMaxBitrate) {
297 EXPECT_TRUE(SetupEngine());
298 int channel_num = vie_.GetLastChannel();
299 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
300 codecs[0].params[cricket::kCodecParamMinBitrate] = "10";
301 codecs[0].params[cricket::kCodecParamMaxBitrate] = "20";
302 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
303
304 VerifyVP8SendCodec(
305 channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20);
306
307 cricket::VideoCodec codec;
308 EXPECT_TRUE(channel_->GetSendCodec(&codec));
309 EXPECT_EQ("10", codec.params[cricket::kCodecParamMinBitrate]);
310 EXPECT_EQ("20", codec.params[cricket::kCodecParamMaxBitrate]);
311}
312
313TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithMinMaxBitrateInvalid) {
314 EXPECT_TRUE(SetupEngine());
315 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
316 codecs[0].params[cricket::kCodecParamMinBitrate] = "30";
317 codecs[0].params[cricket::kCodecParamMaxBitrate] = "20";
318 EXPECT_FALSE(channel_->SetSendCodecs(codecs));
319}
320
321TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithLargeMinMaxBitrate) {
322 EXPECT_TRUE(SetupEngine());
323 int channel_num = vie_.GetLastChannel();
324 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
325 codecs[0].params[cricket::kCodecParamMinBitrate] = "1000";
326 codecs[0].params[cricket::kCodecParamMaxBitrate] = "2000";
327 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
328
329 VerifyVP8SendCodec(
330 channel_num, kVP8Codec.width, kVP8Codec.height, 0, 2000, 1000,
331 1000);
332}
333
334TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithMaxQuantization) {
335 EXPECT_TRUE(SetupEngine());
336 int channel_num = vie_.GetLastChannel();
337 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
338 codecs[0].params[cricket::kCodecParamMaxQuantization] = "21";
339 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
340
341 VerifyVP8SendCodec(
342 channel_num, kVP8Codec.width, kVP8Codec.height, 0, 2000, 50, 300,
343 30, 21);
344
345 cricket::VideoCodec codec;
346 EXPECT_TRUE(channel_->GetSendCodec(&codec));
347 EXPECT_EQ("21", codec.params[cricket::kCodecParamMaxQuantization]);
348}
349
350TEST_F(WebRtcVideoEngineTestFake, SetOptionsWithMaxBitrate) {
351 EXPECT_TRUE(SetupEngine());
352 int channel_num = vie_.GetLastChannel();
353 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
354 codecs[0].params[cricket::kCodecParamMinBitrate] = "10";
355 codecs[0].params[cricket::kCodecParamMaxBitrate] = "20";
356 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
357
358 VerifyVP8SendCodec(
359 channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20);
360
361 // Verify that max bitrate doesn't change after SetOptions().
362 cricket::VideoOptions options;
363 options.video_noise_reduction.Set(true);
364 EXPECT_TRUE(channel_->SetOptions(options));
365 VerifyVP8SendCodec(
366 channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20);
367
368 options.video_noise_reduction.Set(false);
369 options.conference_mode.Set(false);
370 EXPECT_TRUE(channel_->SetOptions(options));
371 VerifyVP8SendCodec(
372 channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20);
373}
374
375TEST_F(WebRtcVideoEngineTestFake, MaxBitrateResetWithConferenceMode) {
376 EXPECT_TRUE(SetupEngine());
377 int channel_num = vie_.GetLastChannel();
378 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
379 codecs[0].params[cricket::kCodecParamMinBitrate] = "10";
380 codecs[0].params[cricket::kCodecParamMaxBitrate] = "20";
381 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
382
383 VerifyVP8SendCodec(
384 channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20);
385
386 cricket::VideoOptions options;
387 options.conference_mode.Set(true);
388 EXPECT_TRUE(channel_->SetOptions(options));
389 options.conference_mode.Set(false);
390 EXPECT_TRUE(channel_->SetOptions(options));
391 VerifyVP8SendCodec(
392 channel_num, kVP8Codec.width, kVP8Codec.height, 0,
393 kMaxBandwidthKbps, 10, 20);
394}
395
396// Verify the current send bitrate is used as start bitrate when reconfiguring
397// the send codec.
398TEST_F(WebRtcVideoEngineTestFake, StartSendBitrate) {
399 EXPECT_TRUE(SetupEngine());
400 EXPECT_TRUE(channel_->AddSendStream(
401 cricket::StreamParams::CreateLegacy(1)));
402 int send_channel = vie_.GetLastChannel();
403 cricket::VideoCodec codec(kVP8Codec);
404 std::vector<cricket::VideoCodec> codec_list;
405 codec_list.push_back(codec);
406 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
407 const unsigned int kVideoMaxSendBitrateKbps = 2000;
408 const unsigned int kVideoMinSendBitrateKbps = 50;
409 const unsigned int kVideoDefaultStartSendBitrateKbps = 300;
410 VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
411 kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
412 kVideoDefaultStartSendBitrateKbps);
413 EXPECT_EQ(0, vie_.StartSend(send_channel));
414
415 // Increase the send bitrate and verify it is used as start bitrate.
416 const unsigned int kVideoSendBitrateBps = 768000;
417 vie_.SetSendBitrates(send_channel, kVideoSendBitrateBps, 0, 0);
418 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
419 VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
420 kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
421 kVideoSendBitrateBps / 1000);
422
423 // Never set a start bitrate higher than the max bitrate.
424 vie_.SetSendBitrates(send_channel, kVideoMaxSendBitrateKbps + 500, 0, 0);
425 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
426 VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
427 kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
428 kVideoDefaultStartSendBitrateKbps);
429
430 // Use the default start bitrate if the send bitrate is lower.
431 vie_.SetSendBitrates(send_channel, kVideoDefaultStartSendBitrateKbps - 50, 0,
432 0);
433 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
434 VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
435 kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
436 kVideoDefaultStartSendBitrateKbps);
437}
438
439
440// Test that we constrain send codecs properly.
441TEST_F(WebRtcVideoEngineTestFake, ConstrainSendCodecs) {
442 EXPECT_TRUE(SetupEngine());
443 int channel_num = vie_.GetLastChannel();
444
445 // Set max settings of 640x400x30.
446 EXPECT_TRUE(engine_.SetDefaultEncoderConfig(
447 cricket::VideoEncoderConfig(kVP8Codec)));
448
449 // Send codec format bigger than max setting.
450 cricket::VideoCodec codec(kVP8Codec);
451 codec.width = 1280;
452 codec.height = 800;
453 codec.framerate = 60;
454 std::vector<cricket::VideoCodec> codec_list;
455 codec_list.push_back(codec);
456
457 // Set send codec and verify codec has been constrained.
458 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
459 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height);
460}
461
462// Test that SetSendCodecs rejects bad format.
463TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsRejectBadFormat) {
464 EXPECT_TRUE(SetupEngine());
465 int channel_num = vie_.GetLastChannel();
466
467 // Set w = 0.
468 cricket::VideoCodec codec(kVP8Codec);
469 codec.width = 0;
470 std::vector<cricket::VideoCodec> codec_list;
471 codec_list.push_back(codec);
472
473 // Verify SetSendCodecs failed and send codec is not changed on engine.
474 EXPECT_FALSE(channel_->SetSendCodecs(codec_list));
475 webrtc::VideoCodec gcodec;
476 // Set plType to something other than the value to test against ensuring
477 // that failure will happen if it is not changed.
478 gcodec.plType = 1;
479 EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec));
480 EXPECT_EQ(0, gcodec.plType);
481
482 // Set h = 0.
483 codec_list[0].width = 640;
484 codec_list[0].height = 0;
485
486 // Verify SetSendCodecs failed and send codec is not changed on engine.
487 EXPECT_FALSE(channel_->SetSendCodecs(codec_list));
488 // Set plType to something other than the value to test against ensuring
489 // that failure will happen if it is not changed.
490 gcodec.plType = 1;
491 EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec));
492 EXPECT_EQ(0, gcodec.plType);
493}
494
495// Test that SetSendCodecs rejects bad codec.
496TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsRejectBadCodec) {
497 EXPECT_TRUE(SetupEngine());
498 int channel_num = vie_.GetLastChannel();
499
500 // Set bad codec name.
501 cricket::VideoCodec codec(kVP8Codec);
502 codec.name = "bad";
503 std::vector<cricket::VideoCodec> codec_list;
504 codec_list.push_back(codec);
505
506 // Verify SetSendCodecs failed and send codec is not changed on engine.
507 EXPECT_FALSE(channel_->SetSendCodecs(codec_list));
508 webrtc::VideoCodec gcodec;
509 // Set plType to something other than the value to test against ensuring
510 // that failure will happen if it is not changed.
511 gcodec.plType = 1;
512 EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec));
513 EXPECT_EQ(0, gcodec.plType);
514}
515
516// Test that vie send codec is reset on new video frame size.
517TEST_F(WebRtcVideoEngineTestFake, ResetVieSendCodecOnNewFrameSize) {
518 EXPECT_TRUE(SetupEngine());
519 int channel_num = vie_.GetLastChannel();
520
521 // Set send codec.
522 std::vector<cricket::VideoCodec> codec_list;
523 codec_list.push_back(kVP8Codec);
524 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
525 EXPECT_TRUE(channel_->AddSendStream(
526 cricket::StreamParams::CreateLegacy(123)));
527 EXPECT_TRUE(channel_->SetSend(true));
528
529 // Capture a smaller frame and verify vie send codec has been reset to
530 // the new size.
531 SendI420Frame(kVP8Codec.width / 2, kVP8Codec.height / 2);
532 VerifyVP8SendCodec(channel_num, kVP8Codec.width / 2, kVP8Codec.height / 2);
533
534 // Capture a frame bigger than send_codec_ and verify vie send codec has been
535 // reset (and clipped) to send_codec_.
536 SendI420Frame(kVP8Codec.width * 2, kVP8Codec.height * 2);
537 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height);
538}
539
540// Test that we set our inbound codecs properly.
541TEST_F(WebRtcVideoEngineTestFake, SetRecvCodecs) {
542 EXPECT_TRUE(SetupEngine());
543 int channel_num = vie_.GetLastChannel();
544
545 std::vector<cricket::VideoCodec> codecs;
546 codecs.push_back(kVP8Codec);
547 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
548
549 webrtc::VideoCodec wcodec;
550 EXPECT_TRUE(engine_.ConvertFromCricketVideoCodec(kVP8Codec, &wcodec));
551 EXPECT_TRUE(vie_.ReceiveCodecRegistered(channel_num, wcodec));
552}
553
554// Test that channel connects and disconnects external capturer correctly.
555TEST_F(WebRtcVideoEngineTestFake, HasExternalCapturer) {
556 EXPECT_TRUE(SetupEngine());
557 int channel_num = vie_.GetLastChannel();
558
559 EXPECT_EQ(1, vie_.GetNumCapturers());
560 int capture_id = vie_.GetCaptureId(channel_num);
561 EXPECT_EQ(channel_num, vie_.GetCaptureChannelId(capture_id));
562
563 // Delete the channel should disconnect the capturer.
564 delete channel_;
565 channel_ = NULL;
566 EXPECT_EQ(0, vie_.GetNumCapturers());
567}
568
569// Test that channel adds and removes renderer correctly.
570TEST_F(WebRtcVideoEngineTestFake, HasRenderer) {
571 EXPECT_TRUE(SetupEngine());
572 int channel_num = vie_.GetLastChannel();
573
574 EXPECT_TRUE(vie_.GetHasRenderer(channel_num));
575 EXPECT_FALSE(vie_.GetRenderStarted(channel_num));
576}
577
578// Test that rtcp is enabled on the channel.
579TEST_F(WebRtcVideoEngineTestFake, RtcpEnabled) {
580 EXPECT_TRUE(SetupEngine());
581 int channel_num = vie_.GetLastChannel();
582 EXPECT_EQ(webrtc::kRtcpCompound_RFC4585, vie_.GetRtcpStatus(channel_num));
583}
584
585// Test that key frame request method is set on the channel.
586TEST_F(WebRtcVideoEngineTestFake, KeyFrameRequestEnabled) {
587 EXPECT_TRUE(SetupEngine());
588 int channel_num = vie_.GetLastChannel();
589 EXPECT_EQ(webrtc::kViEKeyFrameRequestPliRtcp,
590 vie_.GetKeyFrameRequestMethod(channel_num));
591}
592
593// Test that remb receive and send is enabled for the default channel in a 1:1
594// call.
595TEST_F(WebRtcVideoEngineTestFake, RembEnabled) {
596 EXPECT_TRUE(SetupEngine());
597 int channel_num = vie_.GetLastChannel();
598 EXPECT_TRUE(channel_->AddSendStream(
599 cricket::StreamParams::CreateLegacy(1)));
600 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
601 EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num));
602 EXPECT_TRUE(channel_->SetSend(true));
603 EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num));
604 EXPECT_TRUE(vie_.GetRembStatusContribute(channel_num));
605}
606
607// When in conference mode, test that remb is enabled on a receive channel but
608// not for the default channel and that it uses the default channel for sending
609// remb packets.
610TEST_F(WebRtcVideoEngineTestFake, RembEnabledOnReceiveChannels) {
611 EXPECT_TRUE(SetupEngine());
612 int default_channel = vie_.GetLastChannel();
613 cricket::VideoOptions options;
614 options.conference_mode.Set(true);
615 EXPECT_TRUE(channel_->SetOptions(options));
616 EXPECT_TRUE(channel_->AddSendStream(
617 cricket::StreamParams::CreateLegacy(1)));
618 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
619 EXPECT_TRUE(vie_.GetRembStatusBwPartition(default_channel));
620 EXPECT_TRUE(vie_.GetRembStatusContribute(default_channel));
621 EXPECT_TRUE(channel_->SetSend(true));
622 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
623 int new_channel_num = vie_.GetLastChannel();
624 EXPECT_NE(default_channel, new_channel_num);
625
626 EXPECT_TRUE(vie_.GetRembStatusBwPartition(default_channel));
627 EXPECT_TRUE(vie_.GetRembStatusContribute(default_channel));
628 EXPECT_FALSE(vie_.GetRembStatusBwPartition(new_channel_num));
629 EXPECT_TRUE(vie_.GetRembStatusContribute(new_channel_num));
630}
631
632// Test support for RTP timestamp offset header extension.
633TEST_F(WebRtcVideoEngineTestFake, RtpTimestampOffsetHeaderExtensions) {
634 EXPECT_TRUE(SetupEngine());
635 int channel_num = vie_.GetLastChannel();
636 cricket::VideoOptions options;
637 options.conference_mode.Set(true);
638 EXPECT_TRUE(channel_->SetOptions(options));
639
640 // Verify extensions are off by default.
641 EXPECT_EQ(0, vie_.GetSendRtpTimestampOffsetExtensionId(channel_num));
642 EXPECT_EQ(0, vie_.GetReceiveRtpTimestampOffsetExtensionId(channel_num));
643
644 // Enable RTP timestamp extension.
645 const int id = 14;
646 std::vector<cricket::RtpHeaderExtension> extensions;
647 extensions.push_back(cricket::RtpHeaderExtension(
648 "urn:ietf:params:rtp-hdrext:toffset", id));
649
650 // Verify the send extension id.
651 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions));
652 EXPECT_EQ(id, vie_.GetSendRtpTimestampOffsetExtensionId(channel_num));
653
654 // Remove the extension id.
655 std::vector<cricket::RtpHeaderExtension> empty_extensions;
656 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions));
657 EXPECT_EQ(0, vie_.GetSendRtpTimestampOffsetExtensionId(channel_num));
658
659 // Verify receive extension id.
660 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions));
661 EXPECT_EQ(id, vie_.GetReceiveRtpTimestampOffsetExtensionId(channel_num));
662
663 // Add a new receive stream and verify the extension is set.
664 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
665 int new_channel_num = vie_.GetLastChannel();
666 EXPECT_NE(channel_num, new_channel_num);
667 EXPECT_EQ(id, vie_.GetReceiveRtpTimestampOffsetExtensionId(new_channel_num));
668
669 // Remove the extension id.
670 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(empty_extensions));
671 EXPECT_EQ(0, vie_.GetReceiveRtpTimestampOffsetExtensionId(channel_num));
672 EXPECT_EQ(0, vie_.GetReceiveRtpTimestampOffsetExtensionId(new_channel_num));
673}
674
675// Test support for absolute send time header extension.
676TEST_F(WebRtcVideoEngineTestFake, AbsoluteSendTimeHeaderExtensions) {
677 EXPECT_TRUE(SetupEngine());
678 int channel_num = vie_.GetLastChannel();
679 cricket::VideoOptions options;
680 options.conference_mode.Set(true);
681 EXPECT_TRUE(channel_->SetOptions(options));
682
683 // Verify extensions are off by default.
684 EXPECT_EQ(0, vie_.GetSendAbsoluteSendTimeExtensionId(channel_num));
685 EXPECT_EQ(0, vie_.GetReceiveAbsoluteSendTimeExtensionId(channel_num));
686
687 // Enable RTP timestamp extension.
688 const int id = 12;
689 std::vector<cricket::RtpHeaderExtension> extensions;
690 extensions.push_back(cricket::RtpHeaderExtension(
691 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", id));
692
693 // Verify the send extension id.
694 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions));
695 EXPECT_EQ(id, vie_.GetSendAbsoluteSendTimeExtensionId(channel_num));
696
697 // Remove the extension id.
698 std::vector<cricket::RtpHeaderExtension> empty_extensions;
699 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions));
700 EXPECT_EQ(0, vie_.GetSendAbsoluteSendTimeExtensionId(channel_num));
701
702 // Verify receive extension id.
703 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions));
704 EXPECT_EQ(id, vie_.GetReceiveAbsoluteSendTimeExtensionId(channel_num));
705
706 // Add a new receive stream and verify the extension is set.
707 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
708 int new_channel_num = vie_.GetLastChannel();
709 EXPECT_NE(channel_num, new_channel_num);
710 EXPECT_EQ(id, vie_.GetReceiveAbsoluteSendTimeExtensionId(new_channel_num));
711
712 // Remove the extension id.
713 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(empty_extensions));
714 EXPECT_EQ(0, vie_.GetReceiveAbsoluteSendTimeExtensionId(channel_num));
715 EXPECT_EQ(0, vie_.GetReceiveAbsoluteSendTimeExtensionId(new_channel_num));
716}
717
718TEST_F(WebRtcVideoEngineTestFake, LeakyBucketTest) {
719 EXPECT_TRUE(SetupEngine());
720
721 // Verify this is off by default.
722 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1)));
723 int first_send_channel = vie_.GetLastChannel();
724 EXPECT_FALSE(vie_.GetTransmissionSmoothingStatus(first_send_channel));
725
726 // Enable the experiment and verify.
727 cricket::VideoOptions options;
728 options.conference_mode.Set(true);
729 options.video_leaky_bucket.Set(true);
730 EXPECT_TRUE(channel_->SetOptions(options));
731 EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(first_send_channel));
732
733 // Add a receive channel and verify leaky bucket isn't enabled.
734 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
735 int recv_channel_num = vie_.GetLastChannel();
736 EXPECT_NE(first_send_channel, recv_channel_num);
737 EXPECT_FALSE(vie_.GetTransmissionSmoothingStatus(recv_channel_num));
738
739 // Add a new send stream and verify leaky bucket is enabled from start.
740 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3)));
741 int second_send_channel = vie_.GetLastChannel();
742 EXPECT_NE(first_send_channel, second_send_channel);
743 EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(second_send_channel));
744}
745
746TEST_F(WebRtcVideoEngineTestFake, BufferedModeLatency) {
747 EXPECT_TRUE(SetupEngine());
748
749 // Verify this is off by default.
750 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1)));
751 int first_send_channel = vie_.GetLastChannel();
752 EXPECT_EQ(0, vie_.GetSenderTargetDelay(first_send_channel));
753 EXPECT_EQ(0, vie_.GetReceiverTargetDelay(first_send_channel));
754
755 // Enable the experiment and verify. The default channel will have both
756 // sender and receiver buffered mode enabled.
757 cricket::VideoOptions options;
758 options.conference_mode.Set(true);
759 options.buffered_mode_latency.Set(100);
760 EXPECT_TRUE(channel_->SetOptions(options));
761 EXPECT_EQ(100, vie_.GetSenderTargetDelay(first_send_channel));
762 EXPECT_EQ(100, vie_.GetReceiverTargetDelay(first_send_channel));
763
764 // Add a receive channel and verify sender buffered mode isn't enabled.
765 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
766 int recv_channel_num = vie_.GetLastChannel();
767 EXPECT_NE(first_send_channel, recv_channel_num);
768 EXPECT_EQ(0, vie_.GetSenderTargetDelay(recv_channel_num));
769 EXPECT_EQ(100, vie_.GetReceiverTargetDelay(recv_channel_num));
770
771 // Add a new send stream and verify sender buffered mode is enabled.
772 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3)));
773 int second_send_channel = vie_.GetLastChannel();
774 EXPECT_NE(first_send_channel, second_send_channel);
775 EXPECT_EQ(100, vie_.GetSenderTargetDelay(second_send_channel));
776 EXPECT_EQ(0, vie_.GetReceiverTargetDelay(second_send_channel));
777
778 // Disable sender buffered mode and verify.
779 options.buffered_mode_latency.Set(cricket::kBufferedModeDisabled);
780 EXPECT_TRUE(channel_->SetOptions(options));
781 EXPECT_EQ(0, vie_.GetSenderTargetDelay(first_send_channel));
782 EXPECT_EQ(0, vie_.GetReceiverTargetDelay(first_send_channel));
783 EXPECT_EQ(0, vie_.GetSenderTargetDelay(second_send_channel));
784 EXPECT_EQ(0, vie_.GetReceiverTargetDelay(second_send_channel));
785 EXPECT_EQ(0, vie_.GetSenderTargetDelay(recv_channel_num));
786 EXPECT_EQ(0, vie_.GetReceiverTargetDelay(recv_channel_num));
787}
788
789TEST_F(WebRtcVideoEngineTestFake, AdditiveVideoOptions) {
790 EXPECT_TRUE(SetupEngine());
791
792 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1)));
793 int first_send_channel = vie_.GetLastChannel();
794 EXPECT_EQ(0, vie_.GetSenderTargetDelay(first_send_channel));
795 EXPECT_EQ(0, vie_.GetReceiverTargetDelay(first_send_channel));
796
797 cricket::VideoOptions options1;
798 options1.buffered_mode_latency.Set(100);
799 EXPECT_TRUE(channel_->SetOptions(options1));
800 EXPECT_EQ(100, vie_.GetSenderTargetDelay(first_send_channel));
801 EXPECT_EQ(100, vie_.GetReceiverTargetDelay(first_send_channel));
802 EXPECT_FALSE(vie_.GetTransmissionSmoothingStatus(first_send_channel));
803
804 cricket::VideoOptions options2;
805 options2.video_leaky_bucket.Set(true);
806 EXPECT_TRUE(channel_->SetOptions(options2));
807 EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(first_send_channel));
808 // The buffered_mode_latency still takes effect.
809 EXPECT_EQ(100, vie_.GetSenderTargetDelay(first_send_channel));
810 EXPECT_EQ(100, vie_.GetReceiverTargetDelay(first_send_channel));
811
812 options1.buffered_mode_latency.Set(50);
813 EXPECT_TRUE(channel_->SetOptions(options1));
814 EXPECT_EQ(50, vie_.GetSenderTargetDelay(first_send_channel));
815 EXPECT_EQ(50, vie_.GetReceiverTargetDelay(first_send_channel));
816 // The video_leaky_bucket still takes effect.
817 EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(first_send_channel));
818}
819
820// Test that AddRecvStream doesn't create new channel for 1:1 call.
821TEST_F(WebRtcVideoEngineTestFake, AddRecvStream1On1) {
822 EXPECT_TRUE(SetupEngine());
823 int channel_num = vie_.GetLastChannel();
824 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
825 EXPECT_EQ(channel_num, vie_.GetLastChannel());
826}
827
828// Test that AddRecvStream doesn't change remb for 1:1 call.
829TEST_F(WebRtcVideoEngineTestFake, NoRembChangeAfterAddRecvStream) {
830 EXPECT_TRUE(SetupEngine());
831 int channel_num = vie_.GetLastChannel();
832 EXPECT_TRUE(channel_->AddSendStream(
833 cricket::StreamParams::CreateLegacy(1)));
834 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
835 EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num));
836 EXPECT_TRUE(vie_.GetRembStatusContribute(channel_num));
837 EXPECT_TRUE(channel_->SetSend(true));
838 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
839 EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num));
840 EXPECT_TRUE(vie_.GetRembStatusContribute(channel_num));
841}
842
843// Verify default REMB setting and that it can be turned on and off.
844TEST_F(WebRtcVideoEngineTestFake, RembOnOff) {
845 EXPECT_TRUE(SetupEngine());
846 int channel_num = vie_.GetLastChannel();
847 // Verify REMB sending is always off by default.
848 EXPECT_FALSE(vie_.GetRembStatusBwPartition(channel_num));
849
850 // Verify that REMB is turned on when setting default codecs since the
851 // default codecs have REMB enabled.
852 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
853 EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num));
854
855 // Verify that REMB is turned off when codecs without REMB are set.
856 std::vector<cricket::VideoCodec> codecs = engine_.codecs();
857 // Clearing the codecs' FeedbackParams and setting send codecs should disable
858 // REMB.
859 for (std::vector<cricket::VideoCodec>::iterator iter = codecs.begin();
860 iter != codecs.end(); ++iter) {
861 // Intersecting with empty will clear the FeedbackParams.
862 cricket::FeedbackParams empty_params;
863 iter->feedback_params.Intersect(empty_params);
864 EXPECT_TRUE(iter->feedback_params.params().empty());
865 }
866 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
867 EXPECT_FALSE(vie_.GetRembStatusBwPartition(channel_num));
868}
869
870// Test that nack is enabled on the channel if we don't offer red/fec.
871TEST_F(WebRtcVideoEngineTestFake, NackEnabled) {
872 EXPECT_TRUE(SetupEngine());
873 int channel_num = vie_.GetLastChannel();
874 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
875 codecs.resize(1); // toss out red and ulpfec
876 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
877 EXPECT_TRUE(vie_.GetNackStatus(channel_num));
878}
879
880// Test that we enable hybrid NACK FEC mode.
881TEST_F(WebRtcVideoEngineTestFake, HybridNackFec) {
882 EXPECT_TRUE(SetupEngine());
883 int channel_num = vie_.GetLastChannel();
884 EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs()));
885 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
886 EXPECT_TRUE(vie_.GetHybridNackFecStatus(channel_num));
887 EXPECT_FALSE(vie_.GetNackStatus(channel_num));
888}
889
890// Test that we enable hybrid NACK FEC mode when calling SetSendCodecs and
891// SetReceiveCodecs in reversed order.
892TEST_F(WebRtcVideoEngineTestFake, HybridNackFecReversedOrder) {
893 EXPECT_TRUE(SetupEngine());
894 int channel_num = vie_.GetLastChannel();
895 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
896 EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs()));
897 EXPECT_TRUE(vie_.GetHybridNackFecStatus(channel_num));
898 EXPECT_FALSE(vie_.GetNackStatus(channel_num));
899}
900
901// Test NACK vs Hybrid NACK/FEC interop call setup, i.e. only use NACK even if
902// red/fec is offered as receive codec.
903TEST_F(WebRtcVideoEngineTestFake, VideoProtectionInterop) {
904 EXPECT_TRUE(SetupEngine());
905 int channel_num = vie_.GetLastChannel();
906 std::vector<cricket::VideoCodec> recv_codecs(engine_.codecs());
907 std::vector<cricket::VideoCodec> send_codecs(engine_.codecs());
908 // Only add VP8 as send codec.
909 send_codecs.resize(1);
910 EXPECT_TRUE(channel_->SetRecvCodecs(recv_codecs));
911 EXPECT_TRUE(channel_->SetSendCodecs(send_codecs));
912 EXPECT_FALSE(vie_.GetHybridNackFecStatus(channel_num));
913 EXPECT_TRUE(vie_.GetNackStatus(channel_num));
914}
915
916// Test NACK vs Hybrid NACK/FEC interop call setup, i.e. only use NACK even if
917// red/fec is offered as receive codec. Call order reversed compared to
918// VideoProtectionInterop.
919TEST_F(WebRtcVideoEngineTestFake, VideoProtectionInteropReversed) {
920 EXPECT_TRUE(SetupEngine());
921 int channel_num = vie_.GetLastChannel();
922 std::vector<cricket::VideoCodec> recv_codecs(engine_.codecs());
923 std::vector<cricket::VideoCodec> send_codecs(engine_.codecs());
924 // Only add VP8 as send codec.
925 send_codecs.resize(1);
926 EXPECT_TRUE(channel_->SetSendCodecs(send_codecs));
927 EXPECT_TRUE(channel_->SetRecvCodecs(recv_codecs));
928 EXPECT_FALSE(vie_.GetHybridNackFecStatus(channel_num));
929 EXPECT_TRUE(vie_.GetNackStatus(channel_num));
930}
931
932// Test that NACK, not hybrid mode, is enabled in conference mode.
933TEST_F(WebRtcVideoEngineTestFake, HybridNackFecConference) {
934 EXPECT_TRUE(SetupEngine());
935 // Setup the send channel.
936 int send_channel_num = vie_.GetLastChannel();
937 cricket::VideoOptions options;
938 options.conference_mode.Set(true);
939 EXPECT_TRUE(channel_->SetOptions(options));
940 EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs()));
941 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
942 EXPECT_FALSE(vie_.GetHybridNackFecStatus(send_channel_num));
943 EXPECT_TRUE(vie_.GetNackStatus(send_channel_num));
944 // Add a receive stream.
945 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
946 int receive_channel_num = vie_.GetLastChannel();
947 EXPECT_FALSE(vie_.GetHybridNackFecStatus(receive_channel_num));
948 EXPECT_TRUE(vie_.GetNackStatus(receive_channel_num));
949}
950
951// Test that when AddRecvStream in conference mode, a new channel is created
952// for receiving. And the new channel's "original channel" is the send channel.
953TEST_F(WebRtcVideoEngineTestFake, AddRemoveRecvStreamConference) {
954 EXPECT_TRUE(SetupEngine());
955 // Setup the send channel.
956 int send_channel_num = vie_.GetLastChannel();
957 cricket::VideoOptions options;
958 options.conference_mode.Set(true);
959 EXPECT_TRUE(channel_->SetOptions(options));
960 // Add a receive stream.
961 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
962 int receive_channel_num = vie_.GetLastChannel();
963 EXPECT_EQ(send_channel_num, vie_.GetOriginalChannelId(receive_channel_num));
964 EXPECT_TRUE(channel_->RemoveRecvStream(1));
965 EXPECT_FALSE(vie_.IsChannel(receive_channel_num));
966}
967
968// Test that we can create a channel and start/stop rendering out on it.
969TEST_F(WebRtcVideoEngineTestFake, SetRender) {
970 EXPECT_TRUE(SetupEngine());
971 int channel_num = vie_.GetLastChannel();
972
973 // Verify we can start/stop/start/stop rendering.
974 EXPECT_TRUE(channel_->SetRender(true));
975 EXPECT_TRUE(vie_.GetRenderStarted(channel_num));
976 EXPECT_TRUE(channel_->SetRender(false));
977 EXPECT_FALSE(vie_.GetRenderStarted(channel_num));
978 EXPECT_TRUE(channel_->SetRender(true));
979 EXPECT_TRUE(vie_.GetRenderStarted(channel_num));
980 EXPECT_TRUE(channel_->SetRender(false));
981 EXPECT_FALSE(vie_.GetRenderStarted(channel_num));
982}
983
984// Test that we can create a channel and start/stop sending out on it.
985TEST_F(WebRtcVideoEngineTestFake, SetSend) {
986 EXPECT_TRUE(SetupEngine());
987 int channel_num = vie_.GetLastChannel();
988
989 // Set send codecs on the channel.
990 std::vector<cricket::VideoCodec> codecs;
991 codecs.push_back(kVP8Codec);
992 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
993 EXPECT_TRUE(channel_->AddSendStream(
994 cricket::StreamParams::CreateLegacy(123)));
995
996 // Verify we can start/stop/start/stop sending.
997 EXPECT_TRUE(channel_->SetSend(true));
998 EXPECT_TRUE(vie_.GetSend(channel_num));
999 EXPECT_TRUE(channel_->SetSend(false));
1000 EXPECT_FALSE(vie_.GetSend(channel_num));
1001 EXPECT_TRUE(channel_->SetSend(true));
1002 EXPECT_TRUE(vie_.GetSend(channel_num));
1003 EXPECT_TRUE(channel_->SetSend(false));
1004 EXPECT_FALSE(vie_.GetSend(channel_num));
1005}
1006
1007// Test that we set bandwidth properly when using full auto bandwidth mode.
1008TEST_F(WebRtcVideoEngineTestFake, SetBandwidthAuto) {
1009 EXPECT_TRUE(SetupEngine());
1010 int channel_num = vie_.GetLastChannel();
1011 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
1012 EXPECT_TRUE(channel_->SetSendBandwidth(true, cricket::kAutoBandwidth));
1013 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height);
1014}
1015
1016// Test that we set bandwidth properly when using auto with upper bound.
1017TEST_F(WebRtcVideoEngineTestFake, SetBandwidthAutoCapped) {
1018 EXPECT_TRUE(SetupEngine());
1019 int channel_num = vie_.GetLastChannel();
1020 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
1021 EXPECT_TRUE(channel_->SetSendBandwidth(true, 768000));
1022 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, 768U);
1023}
1024
1025// Test that we set bandwidth properly when using a fixed bandwidth.
1026TEST_F(WebRtcVideoEngineTestFake, SetBandwidthFixed) {
1027 EXPECT_TRUE(SetupEngine());
1028 int channel_num = vie_.GetLastChannel();
1029 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
1030 EXPECT_TRUE(channel_->SetSendBandwidth(false, 768000));
1031 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0,
1032 768U, 768U, 768U);
1033}
1034
1035// Test that SetSendBandwidth is ignored in conference mode.
1036TEST_F(WebRtcVideoEngineTestFake, SetBandwidthInConference) {
1037 EXPECT_TRUE(SetupEngine());
1038 int channel_num = vie_.GetLastChannel();
1039 cricket::VideoOptions options;
1040 options.conference_mode.Set(true);
1041 EXPECT_TRUE(channel_->SetOptions(options));
1042 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
1043 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height);
1044
1045 // Set send bandwidth.
1046 EXPECT_TRUE(channel_->SetSendBandwidth(false, 768000));
1047
1048 // Verify bitrate not changed.
1049 webrtc::VideoCodec gcodec;
1050 EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec));
1051 EXPECT_EQ(kMinBandwidthKbps, gcodec.minBitrate);
1052 EXPECT_EQ(kStartBandwidthKbps, gcodec.startBitrate);
1053 EXPECT_EQ(kMaxBandwidthKbps, gcodec.maxBitrate);
1054 EXPECT_NE(768U, gcodec.minBitrate);
1055 EXPECT_NE(768U, gcodec.startBitrate);
1056 EXPECT_NE(768U, gcodec.maxBitrate);
1057}
1058
1059// Test that sending screencast frames doesn't change bitrate.
1060TEST_F(WebRtcVideoEngineTestFake, SetBandwidthScreencast) {
1061 EXPECT_TRUE(SetupEngine());
1062 int channel_num = vie_.GetLastChannel();
1063
1064 // Set send codec.
1065 cricket::VideoCodec codec(kVP8Codec);
1066 std::vector<cricket::VideoCodec> codec_list;
1067 codec_list.push_back(codec);
1068 EXPECT_TRUE(channel_->AddSendStream(
1069 cricket::StreamParams::CreateLegacy(123)));
1070 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
1071 EXPECT_TRUE(channel_->SetSendBandwidth(false, 111000));
1072 EXPECT_TRUE(channel_->SetSend(true));
1073
1074 SendI420ScreencastFrame(kVP8Codec.width, kVP8Codec.height);
1075 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0,
1076 111, 111, 111);
1077}
1078
1079
1080// Test SetSendSsrc.
1081TEST_F(WebRtcVideoEngineTestFake, SetSendSsrcAndCname) {
1082 EXPECT_TRUE(SetupEngine());
1083 int channel_num = vie_.GetLastChannel();
1084
1085 cricket::StreamParams stream;
1086 stream.ssrcs.push_back(1234);
1087 stream.cname = "cname";
1088 channel_->AddSendStream(stream);
1089
1090 unsigned int ssrc = 0;
1091 EXPECT_EQ(0, vie_.GetLocalSSRC(channel_num, ssrc));
1092 EXPECT_EQ(1234U, ssrc);
1093 EXPECT_EQ(1, vie_.GetNumSsrcs(channel_num));
1094
1095 char rtcp_cname[256];
1096 EXPECT_EQ(0, vie_.GetRTCPCName(channel_num, rtcp_cname));
1097 EXPECT_STREQ("cname", rtcp_cname);
1098}
1099
1100
1101// Test that the local SSRC is the same on sending and receiving channels if the
1102// receive channel is created before the send channel.
1103TEST_F(WebRtcVideoEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) {
1104 EXPECT_TRUE(SetupEngine());
1105
1106 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
1107 int receive_channel_num = vie_.GetLastChannel();
1108 cricket::StreamParams stream = cricket::StreamParams::CreateLegacy(1234);
1109 EXPECT_TRUE(channel_->AddSendStream(stream));
1110 int send_channel_num = vie_.GetLastChannel();
1111 unsigned int ssrc = 0;
1112 EXPECT_EQ(0, vie_.GetLocalSSRC(send_channel_num, ssrc));
1113 EXPECT_EQ(1234U, ssrc);
1114 EXPECT_EQ(1, vie_.GetNumSsrcs(send_channel_num));
1115 ssrc = 0;
1116 EXPECT_EQ(0, vie_.GetLocalSSRC(receive_channel_num, ssrc));
1117 EXPECT_EQ(1234U, ssrc);
1118 EXPECT_EQ(1, vie_.GetNumSsrcs(receive_channel_num));
1119}
1120
1121
1122// Test SetOptions with denoising flag.
1123TEST_F(WebRtcVideoEngineTestFake, SetOptionsWithDenoising) {
1124 EXPECT_TRUE(SetupEngine());
1125 EXPECT_EQ(1, vie_.GetNumCapturers());
1126 int channel_num = vie_.GetLastChannel();
1127 int capture_id = vie_.GetCaptureId(channel_num);
1128 // Set send codecs on the channel.
1129 std::vector<cricket::VideoCodec> codecs;
1130 codecs.push_back(kVP8Codec);
1131 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1132
1133 // Set options with OPT_VIDEO_NOISE_REDUCTION flag.
1134 cricket::VideoOptions options;
1135 options.video_noise_reduction.Set(true);
1136 EXPECT_TRUE(channel_->SetOptions(options));
1137
1138 // Verify capture has denoising turned on.
1139 webrtc::VideoCodec send_codec;
1140 memset(&send_codec, 0, sizeof(send_codec)); // avoid uninitialized warning
1141 EXPECT_EQ(0, vie_.GetSendCodec(channel_num, send_codec));
1142 EXPECT_TRUE(send_codec.codecSpecific.VP8.denoisingOn);
1143 EXPECT_FALSE(vie_.GetCaptureDenoising(capture_id));
1144
1145 // Set options back to zero.
1146 options.video_noise_reduction.Set(false);
1147 EXPECT_TRUE(channel_->SetOptions(options));
1148
1149 // Verify capture has denoising turned off.
1150 EXPECT_EQ(0, vie_.GetSendCodec(channel_num, send_codec));
1151 EXPECT_FALSE(send_codec.codecSpecific.VP8.denoisingOn);
1152 EXPECT_FALSE(vie_.GetCaptureDenoising(capture_id));
1153}
1154
1155
1156TEST_F(WebRtcVideoEngineTestFake, SendReceiveBitratesStats) {
1157 EXPECT_TRUE(SetupEngine());
1158 cricket::VideoOptions options;
1159 options.conference_mode.Set(true);
1160 EXPECT_TRUE(channel_->SetOptions(options));
1161 EXPECT_TRUE(channel_->AddSendStream(
1162 cricket::StreamParams::CreateLegacy(1)));
1163 int send_channel = vie_.GetLastChannel();
1164 cricket::VideoCodec codec(kVP8Codec720p);
1165 std::vector<cricket::VideoCodec> codec_list;
1166 codec_list.push_back(codec);
1167 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
1168
1169 EXPECT_TRUE(channel_->AddRecvStream(
1170 cricket::StreamParams::CreateLegacy(2)));
1171 int first_receive_channel = vie_.GetLastChannel();
1172 EXPECT_NE(send_channel, first_receive_channel);
1173 EXPECT_TRUE(channel_->AddRecvStream(
1174 cricket::StreamParams::CreateLegacy(3)));
1175 int second_receive_channel = vie_.GetLastChannel();
1176 EXPECT_NE(first_receive_channel, second_receive_channel);
1177
1178 cricket::VideoMediaInfo info;
1179 EXPECT_TRUE(channel_->GetStats(&info));
1180 ASSERT_EQ(1U, info.bw_estimations.size());
1181 ASSERT_EQ(0, info.bw_estimations[0].actual_enc_bitrate);
1182 ASSERT_EQ(0, info.bw_estimations[0].transmit_bitrate);
1183 ASSERT_EQ(0, info.bw_estimations[0].retransmit_bitrate);
1184 ASSERT_EQ(0, info.bw_estimations[0].available_send_bandwidth);
1185 ASSERT_EQ(0, info.bw_estimations[0].available_recv_bandwidth);
1186 ASSERT_EQ(0, info.bw_estimations[0].target_enc_bitrate);
1187
1188 // Start sending and receiving on one of the channels and verify bitrates.
1189 EXPECT_EQ(0, vie_.StartSend(send_channel));
1190 int send_video_bitrate = 800;
1191 int send_fec_bitrate = 100;
1192 int send_nack_bitrate = 20;
1193 int send_total_bitrate = send_video_bitrate + send_fec_bitrate +
1194 send_nack_bitrate;
1195 int send_bandwidth = 950;
1196 vie_.SetSendBitrates(send_channel, send_video_bitrate, send_fec_bitrate,
1197 send_nack_bitrate);
1198 vie_.SetSendBandwidthEstimate(send_channel, send_bandwidth);
1199
1200 EXPECT_EQ(0, vie_.StartReceive(first_receive_channel));
1201 int first_channel_receive_bandwidth = 600;
1202 vie_.SetReceiveBandwidthEstimate(first_receive_channel,
1203 first_channel_receive_bandwidth);
1204
1205 info.Clear();
1206 EXPECT_TRUE(channel_->GetStats(&info));
1207 ASSERT_EQ(1U, info.bw_estimations.size());
1208 ASSERT_EQ(send_video_bitrate, info.bw_estimations[0].actual_enc_bitrate);
1209 ASSERT_EQ(send_total_bitrate, info.bw_estimations[0].transmit_bitrate);
1210 ASSERT_EQ(send_nack_bitrate, info.bw_estimations[0].retransmit_bitrate);
1211 ASSERT_EQ(send_bandwidth, info.bw_estimations[0].available_send_bandwidth);
1212 ASSERT_EQ(first_channel_receive_bandwidth,
1213 info.bw_estimations[0].available_recv_bandwidth);
1214 ASSERT_EQ(send_video_bitrate, info.bw_estimations[0].target_enc_bitrate);
1215
1216 // Start receiving on the second channel and verify received rate.
1217 EXPECT_EQ(0, vie_.StartReceive(second_receive_channel));
1218 int second_channel_receive_bandwidth = 100;
1219 vie_.SetReceiveBandwidthEstimate(second_receive_channel,
1220 second_channel_receive_bandwidth);
1221
1222 info.Clear();
1223 EXPECT_TRUE(channel_->GetStats(&info));
1224 ASSERT_EQ(1U, info.bw_estimations.size());
1225 ASSERT_EQ(send_video_bitrate, info.bw_estimations[0].actual_enc_bitrate);
1226 ASSERT_EQ(send_total_bitrate, info.bw_estimations[0].transmit_bitrate);
1227 ASSERT_EQ(send_nack_bitrate, info.bw_estimations[0].retransmit_bitrate);
1228 ASSERT_EQ(send_bandwidth, info.bw_estimations[0].available_send_bandwidth);
1229 ASSERT_EQ(first_channel_receive_bandwidth + second_channel_receive_bandwidth,
1230 info.bw_estimations[0].available_recv_bandwidth);
1231 ASSERT_EQ(send_video_bitrate, info.bw_estimations[0].target_enc_bitrate);
1232}
1233
1234TEST_F(WebRtcVideoEngineTestFake, TestSetAdaptInputToCpuUsage) {
1235 EXPECT_TRUE(SetupEngine());
1236 cricket::VideoOptions options_in, options_out;
1237 bool cpu_adapt = false;
1238 channel_->SetOptions(options_in);
1239 EXPECT_TRUE(channel_->GetOptions(&options_out));
1240 EXPECT_FALSE(options_out.adapt_input_to_cpu_usage.Get(&cpu_adapt));
1241 // Set adapt input CPU usage option.
1242 options_in.adapt_input_to_cpu_usage.Set(true);
1243 EXPECT_TRUE(channel_->SetOptions(options_in));
1244 EXPECT_TRUE(channel_->GetOptions(&options_out));
1245 EXPECT_TRUE(options_out.adapt_input_to_cpu_usage.Get(&cpu_adapt));
1246 EXPECT_TRUE(cpu_adapt);
1247}
1248
1249TEST_F(WebRtcVideoEngineTestFake, TestSetCpuThreshold) {
1250 EXPECT_TRUE(SetupEngine());
1251 float low, high;
1252 cricket::VideoOptions options_in, options_out;
1253 // Verify that initial values are set.
1254 EXPECT_TRUE(channel_->GetOptions(&options_out));
1255 EXPECT_TRUE(options_out.system_low_adaptation_threshhold.Get(&low));
1256 EXPECT_EQ(low, 0.65f);
1257 EXPECT_TRUE(options_out.system_high_adaptation_threshhold.Get(&high));
1258 EXPECT_EQ(high, 0.85f);
1259 // Set new CPU threshold values.
1260 options_in.system_low_adaptation_threshhold.Set(0.45f);
1261 options_in.system_high_adaptation_threshhold.Set(0.95f);
1262 EXPECT_TRUE(channel_->SetOptions(options_in));
1263 EXPECT_TRUE(channel_->GetOptions(&options_out));
1264 EXPECT_TRUE(options_out.system_low_adaptation_threshhold.Get(&low));
1265 EXPECT_EQ(low, 0.45f);
1266 EXPECT_TRUE(options_out.system_high_adaptation_threshhold.Get(&high));
1267 EXPECT_EQ(high, 0.95f);
1268}
1269
1270TEST_F(WebRtcVideoEngineTestFake, TestSetInvalidCpuThreshold) {
1271 EXPECT_TRUE(SetupEngine());
1272 float low, high;
1273 cricket::VideoOptions options_in, options_out;
1274 // Valid range is [0, 1].
1275 options_in.system_low_adaptation_threshhold.Set(-1.5f);
1276 options_in.system_high_adaptation_threshhold.Set(1.5f);
1277 EXPECT_TRUE(channel_->SetOptions(options_in));
1278 EXPECT_TRUE(channel_->GetOptions(&options_out));
1279 EXPECT_TRUE(options_out.system_low_adaptation_threshhold.Get(&low));
1280 EXPECT_EQ(low, 0.0f);
1281 EXPECT_TRUE(options_out.system_high_adaptation_threshhold.Get(&high));
1282 EXPECT_EQ(high, 1.0f);
1283}
1284
1285
1286/////////////////////////
1287// Tests with real ViE //
1288/////////////////////////
1289
1290// Tests that we can find codecs by name or id.
1291TEST_F(WebRtcVideoEngineTest, FindCodec) {
1292 // We should not need to init engine in order to get codecs.
1293 const std::vector<cricket::VideoCodec>& c = engine_.codecs();
1294 EXPECT_EQ(3U, c.size());
1295
1296 cricket::VideoCodec vp8(104, "VP8", 320, 200, 30, 0);
1297 EXPECT_TRUE(engine_.FindCodec(vp8));
1298
1299 cricket::VideoCodec vp8_ci(104, "vp8", 320, 200, 30, 0);
1300 EXPECT_TRUE(engine_.FindCodec(vp8));
1301
1302 cricket::VideoCodec vp8_diff_fr_diff_pref(104, "VP8", 320, 200, 50, 50);
1303 EXPECT_TRUE(engine_.FindCodec(vp8_diff_fr_diff_pref));
1304
1305 cricket::VideoCodec vp8_diff_id(95, "VP8", 320, 200, 30, 0);
1306 EXPECT_FALSE(engine_.FindCodec(vp8_diff_id));
1307 vp8_diff_id.id = 97;
1308 EXPECT_TRUE(engine_.FindCodec(vp8_diff_id));
1309
1310 cricket::VideoCodec vp8_diff_res(104, "VP8", 320, 111, 30, 0);
1311 EXPECT_FALSE(engine_.FindCodec(vp8_diff_res));
1312
1313 // PeerConnection doesn't negotiate the resolution at this point.
1314 // Test that FindCodec can handle the case when width/height is 0.
1315 cricket::VideoCodec vp8_zero_res(104, "VP8", 0, 0, 30, 0);
1316 EXPECT_TRUE(engine_.FindCodec(vp8_zero_res));
1317
1318 cricket::VideoCodec red(101, "RED", 0, 0, 30, 0);
1319 EXPECT_TRUE(engine_.FindCodec(red));
1320
1321 cricket::VideoCodec red_ci(101, "red", 0, 0, 30, 0);
1322 EXPECT_TRUE(engine_.FindCodec(red));
1323
1324 cricket::VideoCodec fec(102, "ULPFEC", 0, 0, 30, 0);
1325 EXPECT_TRUE(engine_.FindCodec(fec));
1326
1327 cricket::VideoCodec fec_ci(102, "ulpfec", 0, 0, 30, 0);
1328 EXPECT_TRUE(engine_.FindCodec(fec));
1329}
1330
1331TEST_F(WebRtcVideoEngineTest, StartupShutdown) {
1332 EXPECT_TRUE(engine_.Init(talk_base::Thread::Current()));
1333 engine_.Terminate();
1334}
1335
1336TEST_PRE_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainNewCodec)
1337TEST_POST_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainNewCodec)
1338
1339TEST_PRE_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainRunningCodec)
1340TEST_POST_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainRunningCodec)
1341
1342// TODO(juberti): Figure out why ViE is munging the COM refcount.
1343#ifdef WIN32
1344TEST_F(WebRtcVideoEngineTest, DISABLED_CheckCoInitialize) {
1345 Base::CheckCoInitialize();
1346}
1347#endif
1348
1349TEST_F(WebRtcVideoEngineTest, CreateChannel) {
1350 EXPECT_TRUE(engine_.Init(talk_base::Thread::Current()));
1351 cricket::VideoMediaChannel* channel = engine_.CreateChannel(NULL);
1352 EXPECT_TRUE(channel != NULL);
1353 delete channel;
1354}
1355
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001356TEST_F(WebRtcVideoMediaChannelTest, SetRecvCodecs) {
1357 std::vector<cricket::VideoCodec> codecs;
1358 codecs.push_back(kVP8Codec);
1359 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1360}
1361TEST_F(WebRtcVideoMediaChannelTest, SetRecvCodecsWrongPayloadType) {
1362 std::vector<cricket::VideoCodec> codecs;
1363 codecs.push_back(kVP8Codec);
1364 codecs[0].id = 99;
1365 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1366}
1367TEST_F(WebRtcVideoMediaChannelTest, SetRecvCodecsUnsupportedCodec) {
1368 std::vector<cricket::VideoCodec> codecs;
1369 codecs.push_back(kVP8Codec);
1370 codecs.push_back(cricket::VideoCodec(101, "VP1", 640, 400, 30, 0));
1371 EXPECT_FALSE(channel_->SetRecvCodecs(codecs));
1372}
1373
1374TEST_F(WebRtcVideoMediaChannelTest, SetSend) {
1375 Base::SetSend();
1376}
1377TEST_F(WebRtcVideoMediaChannelTest, SetSendWithoutCodecs) {
1378 Base::SetSendWithoutCodecs();
1379}
1380TEST_F(WebRtcVideoMediaChannelTest, SetSendSetsTransportBufferSizes) {
1381 Base::SetSendSetsTransportBufferSizes();
1382}
1383
1384TEST_F(WebRtcVideoMediaChannelTest, SendAndReceiveVp8Vga) {
1385 SendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30, 0));
1386}
1387TEST_F(WebRtcVideoMediaChannelTest, SendAndReceiveVp8Qvga) {
1388 SendAndReceive(cricket::VideoCodec(100, "VP8", 320, 200, 30, 0));
1389}
1390TEST_F(WebRtcVideoMediaChannelTest, SendAndReceiveH264SvcQqvga) {
1391 SendAndReceive(cricket::VideoCodec(100, "VP8", 160, 100, 30, 0));
1392}
1393TEST_F(WebRtcVideoMediaChannelTest, SendManyResizeOnce) {
1394 SendManyResizeOnce();
1395}
1396
1397TEST_F(WebRtcVideoMediaChannelTest, SendVp8HdAndReceiveAdaptedVp8Vga) {
henrike@webrtc.org28654cb2013-07-22 21:07:49 +00001398 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001399 channel_->UpdateAspectRatio(1280, 720);
1400 video_capturer_.reset(new cricket::FakeVideoCapturer);
1401 const std::vector<cricket::VideoFormat>* formats =
1402 video_capturer_->GetSupportedFormats();
1403 cricket::VideoFormat capture_format_hd = (*formats)[0];
1404 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(capture_format_hd));
1405 EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get()));
1406
1407 // Capture format HD -> adapt (OnOutputFormatRequest VGA) -> VGA.
1408 cricket::VideoCodec codec(100, "VP8", 1280, 720, 30, 0);
1409 EXPECT_TRUE(SetOneCodec(codec));
1410 codec.width /= 2;
1411 codec.height /= 2;
1412 EXPECT_TRUE(channel_->SetSendStreamFormat(kSsrc, cricket::VideoFormat(
1413 codec.width, codec.height,
1414 cricket::VideoFormat::FpsToInterval(codec.framerate),
1415 cricket::FOURCC_ANY)));
1416 EXPECT_TRUE(SetSend(true));
1417 EXPECT_TRUE(channel_->SetRender(true));
1418 EXPECT_EQ(0, renderer_.num_rendered_frames());
1419 EXPECT_TRUE(SendFrame());
1420 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
1421}
1422
1423// TODO(juberti): Fix this test to tolerate missing stats.
1424TEST_F(WebRtcVideoMediaChannelTest, DISABLED_GetStats) {
1425 Base::GetStats();
1426}
1427
1428// TODO(juberti): Fix this test to tolerate missing stats.
1429TEST_F(WebRtcVideoMediaChannelTest, DISABLED_GetStatsMultipleRecvStreams) {
1430 Base::GetStatsMultipleRecvStreams();
1431}
1432
1433TEST_F(WebRtcVideoMediaChannelTest, GetStatsMultipleSendStreams) {
1434 Base::GetStatsMultipleSendStreams();
1435}
1436
1437TEST_F(WebRtcVideoMediaChannelTest, SetSendBandwidth) {
1438 Base::SetSendBandwidth();
1439}
1440TEST_F(WebRtcVideoMediaChannelTest, SetSendSsrc) {
1441 Base::SetSendSsrc();
1442}
1443TEST_F(WebRtcVideoMediaChannelTest, SetSendSsrcAfterSetCodecs) {
1444 Base::SetSendSsrcAfterSetCodecs();
1445}
1446
1447TEST_F(WebRtcVideoMediaChannelTest, SetRenderer) {
1448 Base::SetRenderer();
1449}
1450
1451TEST_F(WebRtcVideoMediaChannelTest, AddRemoveRecvStreams) {
1452 Base::AddRemoveRecvStreams();
1453}
1454
1455TEST_F(WebRtcVideoMediaChannelTest, AddRemoveRecvStreamAndRender) {
1456 Base::AddRemoveRecvStreamAndRender();
1457}
1458
1459TEST_F(WebRtcVideoMediaChannelTest, AddRemoveRecvStreamsNoConference) {
1460 Base::AddRemoveRecvStreamsNoConference();
1461}
1462
1463TEST_F(WebRtcVideoMediaChannelTest, AddRemoveSendStreams) {
1464 Base::AddRemoveSendStreams();
1465}
1466
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001467TEST_F(WebRtcVideoMediaChannelTest, SimulateConference) {
1468 Base::SimulateConference();
1469}
1470
1471TEST_F(WebRtcVideoMediaChannelTest, AddRemoveCapturer) {
1472 Base::AddRemoveCapturer();
1473}
1474
1475TEST_F(WebRtcVideoMediaChannelTest, RemoveCapturerWithoutAdd) {
1476 Base::RemoveCapturerWithoutAdd();
1477}
1478
1479TEST_F(WebRtcVideoMediaChannelTest, AddRemoveCapturerMultipleSources) {
1480 Base::AddRemoveCapturerMultipleSources();
1481}
1482
1483
1484TEST_F(WebRtcVideoMediaChannelTest, SetOptionsSucceedsWhenSending) {
1485 cricket::VideoOptions options;
1486 options.conference_mode.Set(true);
1487 EXPECT_TRUE(channel_->SetOptions(options));
1488
1489 // Verify SetOptions returns true on a different options.
1490 cricket::VideoOptions options2;
1491 options2.adapt_input_to_cpu_usage.Set(true);
1492 EXPECT_TRUE(channel_->SetOptions(options2));
1493
1494 // Set send codecs on the channel and start sending.
1495 std::vector<cricket::VideoCodec> codecs;
1496 codecs.push_back(kVP8Codec);
1497 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1498 EXPECT_TRUE(channel_->SetSend(true));
1499
1500 // Verify SetOptions returns true if channel is already sending.
1501 cricket::VideoOptions options3;
1502 options3.conference_mode.Set(true);
1503 EXPECT_TRUE(channel_->SetOptions(options3));
1504}
1505
1506// Tests empty StreamParams is rejected.
1507TEST_F(WebRtcVideoMediaChannelTest, RejectEmptyStreamParams) {
1508 Base::RejectEmptyStreamParams();
1509}
1510
1511
1512TEST_F(WebRtcVideoMediaChannelTest, AdaptResolution16x10) {
1513 Base::AdaptResolution16x10();
1514}
1515
1516TEST_F(WebRtcVideoMediaChannelTest, AdaptResolution4x3) {
1517 Base::AdaptResolution4x3();
1518}
1519
1520TEST_F(WebRtcVideoMediaChannelTest, MuteStream) {
1521 Base::MuteStream();
1522}
1523
1524TEST_F(WebRtcVideoMediaChannelTest, MultipleSendStreams) {
1525 Base::MultipleSendStreams();
1526}
1527
1528// TODO(juberti): Restore this test once we support sending 0 fps.
1529TEST_F(WebRtcVideoMediaChannelTest, DISABLED_AdaptDropAllFrames) {
1530 Base::AdaptDropAllFrames();
1531}
1532// TODO(juberti): Understand why we get decode errors on this test.
1533TEST_F(WebRtcVideoMediaChannelTest, DISABLED_AdaptFramerate) {
1534 Base::AdaptFramerate();
1535}
1536
1537TEST_F(WebRtcVideoMediaChannelTest, SetSendStreamFormat0x0) {
1538 Base::SetSendStreamFormat0x0();
1539}
1540
1541// TODO(zhurunz): Fix the flakey test.
1542TEST_F(WebRtcVideoMediaChannelTest, DISABLED_SetSendStreamFormat) {
1543 Base::SetSendStreamFormat();
1544}
1545
1546TEST_F(WebRtcVideoMediaChannelTest, TwoStreamsSendAndReceive) {
1547 Base::TwoStreamsSendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30,
1548 0));
1549}
1550
1551TEST_F(WebRtcVideoMediaChannelTest, TwoStreamsReUseFirstStream) {
1552 Base::TwoStreamsReUseFirstStream(cricket::VideoCodec(100, "VP8", 640, 400, 30,
1553 0));
1554}
1555
1556TEST_F(WebRtcVideoEngineTestFake, ResetCodecOnScreencast) {
1557 EXPECT_TRUE(SetupEngine());
1558 cricket::VideoOptions options;
1559 options.video_noise_reduction.Set(true);
1560 EXPECT_TRUE(channel_->SetOptions(options));
1561
1562 // Set send codec.
1563 cricket::VideoCodec codec(kVP8Codec);
1564 std::vector<cricket::VideoCodec> codec_list;
1565 codec_list.push_back(codec);
1566 EXPECT_TRUE(channel_->AddSendStream(
1567 cricket::StreamParams::CreateLegacy(123)));
1568 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
1569 EXPECT_TRUE(channel_->SetSend(true));
1570 EXPECT_EQ(1, vie_.num_set_send_codecs());
1571
1572 webrtc::VideoCodec gcodec;
1573 memset(&gcodec, 0, sizeof(gcodec));
1574 int channel_num = vie_.GetLastChannel();
1575 EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec));
1576 EXPECT_TRUE(gcodec.codecSpecific.VP8.denoisingOn);
1577
1578 // Send a screencast frame with the same size.
1579 // Verify that denoising is turned off.
1580 SendI420ScreencastFrame(kVP8Codec.width, kVP8Codec.height);
1581 EXPECT_EQ(2, vie_.num_set_send_codecs());
1582 EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec));
1583 EXPECT_FALSE(gcodec.codecSpecific.VP8.denoisingOn);
1584}
1585
1586
1587TEST_F(WebRtcVideoEngineTestFake, DontRegisterDecoderIfFactoryIsNotGiven) {
1588 engine_.SetExternalDecoderFactory(NULL);
1589 EXPECT_TRUE(SetupEngine());
1590 int channel_num = vie_.GetLastChannel();
1591
1592 std::vector<cricket::VideoCodec> codecs;
1593 codecs.push_back(kVP8Codec);
1594 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1595
1596 EXPECT_EQ(0, vie_.GetNumExternalDecoderRegistered(channel_num));
1597}
1598
1599TEST_F(WebRtcVideoEngineTestFake, RegisterDecoderIfFactoryIsGiven) {
1600 decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8);
1601 engine_.SetExternalDecoderFactory(&decoder_factory_);
1602 EXPECT_TRUE(SetupEngine());
1603 int channel_num = vie_.GetLastChannel();
1604
1605 std::vector<cricket::VideoCodec> codecs;
1606 codecs.push_back(kVP8Codec);
1607 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1608
1609 EXPECT_TRUE(vie_.ExternalDecoderRegistered(channel_num, 100));
1610 EXPECT_EQ(1, vie_.GetNumExternalDecoderRegistered(channel_num));
1611}
1612
1613TEST_F(WebRtcVideoEngineTestFake, DontRegisterDecoderMultipleTimes) {
1614 decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8);
1615 engine_.SetExternalDecoderFactory(&decoder_factory_);
1616 EXPECT_TRUE(SetupEngine());
1617 int channel_num = vie_.GetLastChannel();
1618
1619 std::vector<cricket::VideoCodec> codecs;
1620 codecs.push_back(kVP8Codec);
1621 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1622
1623 EXPECT_TRUE(vie_.ExternalDecoderRegistered(channel_num, 100));
1624 EXPECT_EQ(1, vie_.GetNumExternalDecoderRegistered(channel_num));
1625 EXPECT_EQ(1, decoder_factory_.GetNumCreatedDecoders());
1626
1627 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1628 EXPECT_EQ(1, vie_.GetNumExternalDecoderRegistered(channel_num));
1629 EXPECT_EQ(1, decoder_factory_.GetNumCreatedDecoders());
1630}
1631
1632TEST_F(WebRtcVideoEngineTestFake, DontRegisterDecoderForNonVP8) {
1633 decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8);
1634 engine_.SetExternalDecoderFactory(&decoder_factory_);
1635 EXPECT_TRUE(SetupEngine());
1636 int channel_num = vie_.GetLastChannel();
1637
1638 std::vector<cricket::VideoCodec> codecs;
1639 codecs.push_back(kRedCodec);
1640 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1641
1642 EXPECT_EQ(0, vie_.GetNumExternalDecoderRegistered(channel_num));
1643}
1644
1645TEST_F(WebRtcVideoEngineTestFake, DontRegisterEncoderIfFactoryIsNotGiven) {
1646 engine_.SetExternalEncoderFactory(NULL);
1647 EXPECT_TRUE(SetupEngine());
1648 int channel_num = vie_.GetLastChannel();
1649
1650 std::vector<cricket::VideoCodec> codecs;
1651 codecs.push_back(kVP8Codec);
1652 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1653
1654 EXPECT_EQ(0, vie_.GetNumExternalEncoderRegistered(channel_num));
1655}
1656
1657TEST_F(WebRtcVideoEngineTestFake, RegisterEncoderIfFactoryIsGiven) {
1658 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
1659 engine_.SetExternalEncoderFactory(&encoder_factory_);
1660 EXPECT_TRUE(SetupEngine());
1661 int channel_num = vie_.GetLastChannel();
1662
1663 std::vector<cricket::VideoCodec> codecs;
1664 codecs.push_back(kVP8Codec);
1665 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1666
1667 EXPECT_TRUE(vie_.ExternalEncoderRegistered(channel_num, 100));
1668 EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num));
1669}
1670
1671TEST_F(WebRtcVideoEngineTestFake, DontRegisterEncoderMultipleTimes) {
1672 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
1673 engine_.SetExternalEncoderFactory(&encoder_factory_);
1674 EXPECT_TRUE(SetupEngine());
1675 int channel_num = vie_.GetLastChannel();
1676
1677 std::vector<cricket::VideoCodec> codecs;
1678 codecs.push_back(kVP8Codec);
1679 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1680
1681 EXPECT_TRUE(vie_.ExternalEncoderRegistered(channel_num, 100));
1682 EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num));
1683 EXPECT_EQ(1, encoder_factory_.GetNumCreatedEncoders());
1684
1685 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1686 EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num));
1687 EXPECT_EQ(1, encoder_factory_.GetNumCreatedEncoders());
1688}
1689
1690TEST_F(WebRtcVideoEngineTestFake, RegisterEncoderWithMultipleSendStreams) {
1691 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
1692 engine_.SetExternalEncoderFactory(&encoder_factory_);
1693 EXPECT_TRUE(SetupEngine());
1694
1695 std::vector<cricket::VideoCodec> codecs;
1696 codecs.push_back(kVP8Codec);
1697 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1698 EXPECT_EQ(1, vie_.GetTotalNumExternalEncoderRegistered());
1699
1700 // When we add the first stream (1234), it reuses the default send channel,
1701 // so it doesn't increase the registration count of external encoders.
1702 EXPECT_TRUE(channel_->AddSendStream(
1703 cricket::StreamParams::CreateLegacy(1234)));
1704 EXPECT_EQ(1, vie_.GetTotalNumExternalEncoderRegistered());
1705
1706 // When we add the second stream (2345), it creates a new channel and
1707 // increments the registration count.
1708 EXPECT_TRUE(channel_->AddSendStream(
1709 cricket::StreamParams::CreateLegacy(2345)));
1710 EXPECT_EQ(2, vie_.GetTotalNumExternalEncoderRegistered());
1711
1712 // At this moment the total registration count is two, but only one encoder
1713 // is registered per channel.
1714 int channel_num = vie_.GetLastChannel();
1715 EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num));
1716
1717 // Removing send streams decrements the registration count.
1718 EXPECT_TRUE(channel_->RemoveSendStream(1234));
1719 EXPECT_EQ(1, vie_.GetTotalNumExternalEncoderRegistered());
1720
1721 // When we remove the last send stream, it also destroys the last send
1722 // channel and causes the registration count to drop to zero. It is a little
1723 // weird, but not a bug.
1724 EXPECT_TRUE(channel_->RemoveSendStream(2345));
1725 EXPECT_EQ(0, vie_.GetTotalNumExternalEncoderRegistered());
1726}
1727
1728TEST_F(WebRtcVideoEngineTestFake, DontRegisterEncoderForNonVP8) {
1729 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecGeneric,
1730 "GENERIC");
1731 engine_.SetExternalEncoderFactory(&encoder_factory_);
1732 EXPECT_TRUE(SetupEngine());
1733 int channel_num = vie_.GetLastChannel();
1734
1735 // Note: unlike the SetRecvCodecs, we must set a valid video codec for
1736 // channel_->SetSendCodecs() to succeed.
1737 std::vector<cricket::VideoCodec> codecs;
1738 codecs.push_back(kVP8Codec);
1739 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1740
1741 EXPECT_EQ(0, vie_.GetNumExternalEncoderRegistered(channel_num));
1742}
1743
1744// Test that NACK and REMB are enabled for external codec.
1745TEST_F(WebRtcVideoEngineTestFake, FeedbackParamsForNonVP8) {
1746 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecGeneric,
1747 "GENERIC");
1748 engine_.SetExternalEncoderFactory(&encoder_factory_);
1749 encoder_factory_.NotifyCodecsAvailable();
1750 EXPECT_TRUE(SetupEngine());
1751
1752 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
1753 EXPECT_EQ("GENERIC", codecs[0].name);
1754 EXPECT_TRUE(codecs[0].HasFeedbackParam(
1755 cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1756 cricket::kParamValueEmpty)));
1757 EXPECT_TRUE(codecs[0].HasFeedbackParam(
1758 cricket::FeedbackParam(cricket::kRtcpFbParamRemb,
1759 cricket::kParamValueEmpty)));
1760 EXPECT_TRUE(codecs[0].HasFeedbackParam(
1761 cricket::FeedbackParam(cricket::kRtcpFbParamCcm,
1762 cricket::kRtcpFbCcmParamFir)));
1763}
1764
1765TEST_F(WebRtcVideoEngineTestFake, UpdateEncoderCodecsAfterSetFactory) {
1766 engine_.SetExternalEncoderFactory(&encoder_factory_);
1767 EXPECT_TRUE(SetupEngine());
1768 int channel_num = vie_.GetLastChannel();
1769
1770 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
1771 encoder_factory_.NotifyCodecsAvailable();
1772 std::vector<cricket::VideoCodec> codecs;
1773 codecs.push_back(kVP8Codec);
1774 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1775
1776 EXPECT_TRUE(vie_.ExternalEncoderRegistered(channel_num, 100));
1777 EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num));
1778 EXPECT_EQ(1, encoder_factory_.GetNumCreatedEncoders());
1779}
1780
1781// Tests that OnReadyToSend will be propagated into ViE.
1782TEST_F(WebRtcVideoEngineTestFake, OnReadyToSend) {
1783 EXPECT_TRUE(SetupEngine());
1784 int channel_num = vie_.GetLastChannel();
1785 EXPECT_TRUE(vie_.GetIsTransmitting(channel_num));
1786
1787 channel_->OnReadyToSend(false);
1788 EXPECT_FALSE(vie_.GetIsTransmitting(channel_num));
1789
1790 channel_->OnReadyToSend(true);
1791 EXPECT_TRUE(vie_.GetIsTransmitting(channel_num));
1792}
1793
1794#if 0
1795TEST_F(WebRtcVideoEngineTestFake, CaptureFrameTimestampToNtpTimestamp) {
1796 EXPECT_TRUE(SetupEngine());
1797 int capture_id = vie_.GetCaptureId(vie_.GetLastChannel());
1798
1799 // Set send codec.
1800 cricket::VideoCodec codec(kVP8Codec);
1801 std::vector<cricket::VideoCodec> codec_list;
1802 codec_list.push_back(codec);
1803 EXPECT_TRUE(channel_->AddSendStream(
1804 cricket::StreamParams::CreateLegacy(123)));
1805 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
1806 EXPECT_TRUE(channel_->SetSend(true));
1807
1808 int64 timestamp = time(NULL) * talk_base::kNumNanosecsPerSec;
1809 SendI420ScreencastFrameWithTimestamp(
1810 kVP8Codec.width, kVP8Codec.height, timestamp);
1811 EXPECT_EQ(talk_base::UnixTimestampNanosecsToNtpMillisecs(timestamp),
1812 vie_.GetCaptureLastTimestamp(capture_id));
1813
1814 SendI420ScreencastFrameWithTimestamp(kVP8Codec.width, kVP8Codec.height, 0);
1815 EXPECT_EQ(0, vie_.GetCaptureLastTimestamp(capture_id));
1816}
1817#endif