blob: abc1a01119df4007f8d97aed267f7d66c045c621 [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};
77static const uint32 kRtxSsrc1[] = {4};
78static 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
753// Test that RTX packets are routed to the correct video channel.
754TEST_F(WebRtcVideoEngineTestFake, TestReceiveRtx) {
755 EXPECT_TRUE(SetupEngine());
756
757 // Setup three channels with associated RTX streams.
758 int channel_num[ARRAY_SIZE(kSsrcs3)];
759 for (size_t i = 0; i < ARRAY_SIZE(kSsrcs3); ++i) {
760 cricket::StreamParams params =
761 cricket::StreamParams::CreateLegacy(kSsrcs3[i]);
762 params.AddFidSsrc(kSsrcs3[i], kRtxSsrcs3[i]);
763 EXPECT_TRUE(channel_->AddRecvStream(params));
764 channel_num[i] = vie_.GetLastChannel();
765 }
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], kRtxSsrcs3[1]);
783 talk_base::Buffer packet(data, kDataLength);
784 talk_base::PacketTime packet_time;
785 channel_->OnPacketReceived(&packet, packet_time);
786 EXPECT_NE(rtx_codec.id, vie_.GetLastRecvdPayloadType(channel_num[0]));
787 EXPECT_EQ(rtx_codec.id, vie_.GetLastRecvdPayloadType(channel_num[1]));
788 EXPECT_NE(rtx_codec.id, vie_.GetLastRecvdPayloadType(channel_num[2]));
789}
790
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000791// Test that channel connects and disconnects external capturer correctly.
792TEST_F(WebRtcVideoEngineTestFake, HasExternalCapturer) {
793 EXPECT_TRUE(SetupEngine());
794 int channel_num = vie_.GetLastChannel();
795
796 EXPECT_EQ(1, vie_.GetNumCapturers());
797 int capture_id = vie_.GetCaptureId(channel_num);
798 EXPECT_EQ(channel_num, vie_.GetCaptureChannelId(capture_id));
799
800 // Delete the channel should disconnect the capturer.
801 delete channel_;
802 channel_ = NULL;
803 EXPECT_EQ(0, vie_.GetNumCapturers());
804}
805
806// Test that channel adds and removes renderer correctly.
807TEST_F(WebRtcVideoEngineTestFake, HasRenderer) {
808 EXPECT_TRUE(SetupEngine());
809 int channel_num = vie_.GetLastChannel();
810
811 EXPECT_TRUE(vie_.GetHasRenderer(channel_num));
812 EXPECT_FALSE(vie_.GetRenderStarted(channel_num));
813}
814
815// Test that rtcp is enabled on the channel.
816TEST_F(WebRtcVideoEngineTestFake, RtcpEnabled) {
817 EXPECT_TRUE(SetupEngine());
818 int channel_num = vie_.GetLastChannel();
819 EXPECT_EQ(webrtc::kRtcpCompound_RFC4585, vie_.GetRtcpStatus(channel_num));
820}
821
822// Test that key frame request method is set on the channel.
823TEST_F(WebRtcVideoEngineTestFake, KeyFrameRequestEnabled) {
824 EXPECT_TRUE(SetupEngine());
825 int channel_num = vie_.GetLastChannel();
826 EXPECT_EQ(webrtc::kViEKeyFrameRequestPliRtcp,
827 vie_.GetKeyFrameRequestMethod(channel_num));
828}
829
830// Test that remb receive and send is enabled for the default channel in a 1:1
831// call.
832TEST_F(WebRtcVideoEngineTestFake, RembEnabled) {
833 EXPECT_TRUE(SetupEngine());
834 int channel_num = vie_.GetLastChannel();
835 EXPECT_TRUE(channel_->AddSendStream(
836 cricket::StreamParams::CreateLegacy(1)));
837 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
838 EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num));
839 EXPECT_TRUE(channel_->SetSend(true));
840 EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num));
841 EXPECT_TRUE(vie_.GetRembStatusContribute(channel_num));
842}
843
844// When in conference mode, test that remb is enabled on a receive channel but
845// not for the default channel and that it uses the default channel for sending
846// remb packets.
847TEST_F(WebRtcVideoEngineTestFake, RembEnabledOnReceiveChannels) {
848 EXPECT_TRUE(SetupEngine());
849 int default_channel = vie_.GetLastChannel();
850 cricket::VideoOptions options;
851 options.conference_mode.Set(true);
852 EXPECT_TRUE(channel_->SetOptions(options));
853 EXPECT_TRUE(channel_->AddSendStream(
854 cricket::StreamParams::CreateLegacy(1)));
855 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
856 EXPECT_TRUE(vie_.GetRembStatusBwPartition(default_channel));
857 EXPECT_TRUE(vie_.GetRembStatusContribute(default_channel));
858 EXPECT_TRUE(channel_->SetSend(true));
859 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
860 int new_channel_num = vie_.GetLastChannel();
861 EXPECT_NE(default_channel, new_channel_num);
862
863 EXPECT_TRUE(vie_.GetRembStatusBwPartition(default_channel));
864 EXPECT_TRUE(vie_.GetRembStatusContribute(default_channel));
865 EXPECT_FALSE(vie_.GetRembStatusBwPartition(new_channel_num));
866 EXPECT_TRUE(vie_.GetRembStatusContribute(new_channel_num));
867}
868
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000869TEST_F(WebRtcVideoEngineTestFake, RecvStreamWithRtx) {
870 EXPECT_TRUE(SetupEngine());
871 int default_channel = vie_.GetLastChannel();
872 cricket::VideoOptions options;
873 options.conference_mode.Set(true);
874 EXPECT_TRUE(channel_->SetOptions(options));
875 EXPECT_TRUE(channel_->AddSendStream(
876 cricket::CreateSimWithRtxStreamParams("cname",
877 MAKE_VECTOR(kSsrcs3),
878 MAKE_VECTOR(kRtxSsrcs3))));
879 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
880 EXPECT_TRUE(channel_->SetSend(true));
881 EXPECT_TRUE(channel_->AddRecvStream(
882 cricket::CreateSimWithRtxStreamParams("cname",
883 MAKE_VECTOR(kSsrcs1),
884 MAKE_VECTOR(kRtxSsrc1))));
885 int new_channel_num = vie_.GetLastChannel();
886 EXPECT_NE(default_channel, new_channel_num);
887 EXPECT_EQ(4, vie_.GetRemoteRtxSsrc(new_channel_num));
888}
889
890TEST_F(WebRtcVideoEngineTestFake, RecvStreamNoRtx) {
891 EXPECT_TRUE(SetupEngine());
892 int default_channel = vie_.GetLastChannel();
893 cricket::VideoOptions options;
894 options.conference_mode.Set(true);
895 EXPECT_TRUE(channel_->SetOptions(options));
896 EXPECT_TRUE(channel_->AddSendStream(
897 cricket::CreateSimWithRtxStreamParams("cname",
898 MAKE_VECTOR(kSsrcs3),
899 MAKE_VECTOR(kRtxSsrcs3))));
900 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
901 EXPECT_TRUE(channel_->SetSend(true));
902 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
903 int new_channel_num = vie_.GetLastChannel();
904 EXPECT_NE(default_channel, new_channel_num);
905 EXPECT_EQ(-1, vie_.GetRemoteRtxSsrc(new_channel_num));
906}
907
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000908// Test support for RTP timestamp offset header extension.
buildbot@webrtc.org150835e2014-05-06 15:54:38 +0000909TEST_F(WebRtcVideoEngineTestFake, SendRtpTimestampOffsetHeaderExtensions) {
910 TestSetSendRtpHeaderExtensions(kRtpTimestampOffsetHeaderExtension);
911}
912TEST_F(WebRtcVideoEngineTestFake, RecvRtpTimestampOffsetHeaderExtensions) {
913 TestSetRecvRtpHeaderExtensions(kRtpTimestampOffsetHeaderExtension);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000914}
915
916// Test support for absolute send time header extension.
buildbot@webrtc.org150835e2014-05-06 15:54:38 +0000917TEST_F(WebRtcVideoEngineTestFake, SendAbsoluteSendTimeHeaderExtensions) {
918 TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension);
919}
920TEST_F(WebRtcVideoEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) {
921 TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000922}
923
924TEST_F(WebRtcVideoEngineTestFake, LeakyBucketTest) {
925 EXPECT_TRUE(SetupEngine());
926
927 // Verify this is off by default.
928 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1)));
929 int first_send_channel = vie_.GetLastChannel();
930 EXPECT_FALSE(vie_.GetTransmissionSmoothingStatus(first_send_channel));
931
932 // Enable the experiment and verify.
933 cricket::VideoOptions options;
934 options.conference_mode.Set(true);
935 options.video_leaky_bucket.Set(true);
936 EXPECT_TRUE(channel_->SetOptions(options));
937 EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(first_send_channel));
938
939 // Add a receive channel and verify leaky bucket isn't enabled.
940 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
941 int recv_channel_num = vie_.GetLastChannel();
942 EXPECT_NE(first_send_channel, recv_channel_num);
943 EXPECT_FALSE(vie_.GetTransmissionSmoothingStatus(recv_channel_num));
944
945 // Add a new send stream and verify leaky bucket is enabled from start.
946 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3)));
947 int second_send_channel = vie_.GetLastChannel();
948 EXPECT_NE(first_send_channel, second_send_channel);
949 EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(second_send_channel));
950}
951
henrike@webrtc.org6e3dbc22014-03-25 17:09:47 +0000952// Verify that SuspendBelowMinBitrate is enabled if it is set in the options.
953TEST_F(WebRtcVideoEngineTestFake, SuspendBelowMinBitrateTest) {
954 EXPECT_TRUE(SetupEngine());
955
956 // Verify this is off by default.
957 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1)));
958 int first_send_channel = vie_.GetLastChannel();
959 EXPECT_FALSE(vie_.GetSuspendBelowMinBitrateStatus(first_send_channel));
960
961 // Enable the experiment and verify.
962 cricket::VideoOptions options;
963 options.suspend_below_min_bitrate.Set(true);
964 EXPECT_TRUE(channel_->SetOptions(options));
965 EXPECT_TRUE(vie_.GetSuspendBelowMinBitrateStatus(first_send_channel));
966
967 // Add a new send stream and verify suspend_below_min_bitrate is enabled.
968 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2)));
969 int second_send_channel = vie_.GetLastChannel();
970 EXPECT_NE(first_send_channel, second_send_channel);
971 EXPECT_TRUE(vie_.GetSuspendBelowMinBitrateStatus(second_send_channel));
972}
973
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000974TEST_F(WebRtcVideoEngineTestFake, BufferedModeLatency) {
975 EXPECT_TRUE(SetupEngine());
976
977 // Verify this is off by default.
978 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1)));
979 int first_send_channel = vie_.GetLastChannel();
980 EXPECT_EQ(0, vie_.GetSenderTargetDelay(first_send_channel));
981 EXPECT_EQ(0, vie_.GetReceiverTargetDelay(first_send_channel));
982
983 // Enable the experiment and verify. The default channel will have both
984 // sender and receiver buffered mode enabled.
985 cricket::VideoOptions options;
986 options.conference_mode.Set(true);
987 options.buffered_mode_latency.Set(100);
988 EXPECT_TRUE(channel_->SetOptions(options));
989 EXPECT_EQ(100, vie_.GetSenderTargetDelay(first_send_channel));
990 EXPECT_EQ(100, vie_.GetReceiverTargetDelay(first_send_channel));
991
992 // Add a receive channel and verify sender buffered mode isn't enabled.
993 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
994 int recv_channel_num = vie_.GetLastChannel();
995 EXPECT_NE(first_send_channel, recv_channel_num);
996 EXPECT_EQ(0, vie_.GetSenderTargetDelay(recv_channel_num));
997 EXPECT_EQ(100, vie_.GetReceiverTargetDelay(recv_channel_num));
998
999 // Add a new send stream and verify sender buffered mode is enabled.
1000 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3)));
1001 int second_send_channel = vie_.GetLastChannel();
1002 EXPECT_NE(first_send_channel, second_send_channel);
1003 EXPECT_EQ(100, vie_.GetSenderTargetDelay(second_send_channel));
1004 EXPECT_EQ(0, vie_.GetReceiverTargetDelay(second_send_channel));
1005
1006 // Disable sender buffered mode and verify.
1007 options.buffered_mode_latency.Set(cricket::kBufferedModeDisabled);
1008 EXPECT_TRUE(channel_->SetOptions(options));
1009 EXPECT_EQ(0, vie_.GetSenderTargetDelay(first_send_channel));
1010 EXPECT_EQ(0, vie_.GetReceiverTargetDelay(first_send_channel));
1011 EXPECT_EQ(0, vie_.GetSenderTargetDelay(second_send_channel));
1012 EXPECT_EQ(0, vie_.GetReceiverTargetDelay(second_send_channel));
1013 EXPECT_EQ(0, vie_.GetSenderTargetDelay(recv_channel_num));
1014 EXPECT_EQ(0, vie_.GetReceiverTargetDelay(recv_channel_num));
1015}
1016
1017TEST_F(WebRtcVideoEngineTestFake, AdditiveVideoOptions) {
1018 EXPECT_TRUE(SetupEngine());
1019
1020 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1)));
1021 int first_send_channel = vie_.GetLastChannel();
1022 EXPECT_EQ(0, vie_.GetSenderTargetDelay(first_send_channel));
1023 EXPECT_EQ(0, vie_.GetReceiverTargetDelay(first_send_channel));
1024
1025 cricket::VideoOptions options1;
1026 options1.buffered_mode_latency.Set(100);
1027 EXPECT_TRUE(channel_->SetOptions(options1));
1028 EXPECT_EQ(100, vie_.GetSenderTargetDelay(first_send_channel));
1029 EXPECT_EQ(100, vie_.GetReceiverTargetDelay(first_send_channel));
1030 EXPECT_FALSE(vie_.GetTransmissionSmoothingStatus(first_send_channel));
1031
1032 cricket::VideoOptions options2;
1033 options2.video_leaky_bucket.Set(true);
1034 EXPECT_TRUE(channel_->SetOptions(options2));
1035 EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(first_send_channel));
1036 // The buffered_mode_latency still takes effect.
1037 EXPECT_EQ(100, vie_.GetSenderTargetDelay(first_send_channel));
1038 EXPECT_EQ(100, vie_.GetReceiverTargetDelay(first_send_channel));
1039
1040 options1.buffered_mode_latency.Set(50);
1041 EXPECT_TRUE(channel_->SetOptions(options1));
1042 EXPECT_EQ(50, vie_.GetSenderTargetDelay(first_send_channel));
1043 EXPECT_EQ(50, vie_.GetReceiverTargetDelay(first_send_channel));
1044 // The video_leaky_bucket still takes effect.
1045 EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(first_send_channel));
1046}
1047
henrike@webrtc.orgb0ecc1c2014-03-26 22:44:28 +00001048TEST_F(WebRtcVideoEngineTestFake, SetCpuOveruseOptionsWithCaptureJitterMethod) {
1049 EXPECT_TRUE(SetupEngine());
1050
1051 // Verify this is off by default.
1052 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1)));
1053 int first_send_channel = vie_.GetLastChannel();
1054 webrtc::CpuOveruseOptions cpu_option =
1055 vie_.GetCpuOveruseOptions(first_send_channel);
1056 EXPECT_EQ(0, cpu_option.low_capture_jitter_threshold_ms);
1057 EXPECT_EQ(0, cpu_option.high_capture_jitter_threshold_ms);
1058 EXPECT_FALSE(cpu_option.enable_capture_jitter_method);
1059 EXPECT_FALSE(cpu_option.enable_encode_usage_method);
1060
1061 // Set low and high threshold and verify that cpu options are set.
1062 cricket::VideoOptions options;
1063 options.conference_mode.Set(true);
1064 options.cpu_underuse_threshold.Set(10);
1065 options.cpu_overuse_threshold.Set(20);
1066 EXPECT_TRUE(channel_->SetOptions(options));
1067 cpu_option = vie_.GetCpuOveruseOptions(first_send_channel);
1068 EXPECT_EQ(10, cpu_option.low_capture_jitter_threshold_ms);
1069 EXPECT_EQ(20, cpu_option.high_capture_jitter_threshold_ms);
1070 EXPECT_TRUE(cpu_option.enable_capture_jitter_method);
1071 EXPECT_FALSE(cpu_option.enable_encode_usage_method);
1072
1073 // Add a receive channel and verify that cpu options are not set.
1074 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
1075 int recv_channel_num = vie_.GetLastChannel();
1076 EXPECT_NE(first_send_channel, recv_channel_num);
1077 cpu_option = vie_.GetCpuOveruseOptions(recv_channel_num);
1078 EXPECT_EQ(0, cpu_option.low_capture_jitter_threshold_ms);
1079 EXPECT_EQ(0, cpu_option.high_capture_jitter_threshold_ms);
1080 EXPECT_FALSE(cpu_option.enable_capture_jitter_method);
1081 EXPECT_FALSE(cpu_option.enable_encode_usage_method);
1082
1083 // Add a new send stream and verify that cpu options are set from start.
1084 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3)));
1085 int second_send_channel = vie_.GetLastChannel();
1086 EXPECT_NE(first_send_channel, second_send_channel);
1087 cpu_option = vie_.GetCpuOveruseOptions(second_send_channel);
1088 EXPECT_EQ(10, cpu_option.low_capture_jitter_threshold_ms);
1089 EXPECT_EQ(20, cpu_option.high_capture_jitter_threshold_ms);
1090 EXPECT_TRUE(cpu_option.enable_capture_jitter_method);
1091 EXPECT_FALSE(cpu_option.enable_encode_usage_method);
1092}
1093
1094TEST_F(WebRtcVideoEngineTestFake, SetInvalidCpuOveruseThresholds) {
1095 EXPECT_TRUE(SetupEngine());
1096 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1)));
1097 int channel_num = vie_.GetLastChannel();
1098
1099 // Only low threshold set. Verify that cpu options are not set.
1100 cricket::VideoOptions options;
1101 options.conference_mode.Set(true);
1102 options.cpu_underuse_threshold.Set(10);
1103 EXPECT_TRUE(channel_->SetOptions(options));
1104 webrtc::CpuOveruseOptions cpu_option = vie_.GetCpuOveruseOptions(channel_num);
1105 EXPECT_EQ(0, cpu_option.low_capture_jitter_threshold_ms);
1106 EXPECT_EQ(0, cpu_option.high_capture_jitter_threshold_ms);
1107 EXPECT_FALSE(cpu_option.enable_capture_jitter_method);
1108 EXPECT_FALSE(cpu_option.enable_encode_usage_method);
1109
1110 // Set high threshold to a negative value. Verify that options are not set.
1111 options.cpu_overuse_threshold.Set(-1);
1112 EXPECT_TRUE(channel_->SetOptions(options));
1113 cpu_option = vie_.GetCpuOveruseOptions(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 // Low and high threshold valid. Verify that cpu options are set.
1120 options.cpu_overuse_threshold.Set(20);
1121 EXPECT_TRUE(channel_->SetOptions(options));
1122 cpu_option = vie_.GetCpuOveruseOptions(channel_num);
1123 EXPECT_EQ(10, cpu_option.low_capture_jitter_threshold_ms);
1124 EXPECT_EQ(20, cpu_option.high_capture_jitter_threshold_ms);
1125 EXPECT_TRUE(cpu_option.enable_capture_jitter_method);
1126 EXPECT_FALSE(cpu_option.enable_encode_usage_method);
1127}
1128
1129TEST_F(WebRtcVideoEngineTestFake, SetCpuOveruseOptionsWithEncodeUsageMethod) {
1130 EXPECT_TRUE(SetupEngine());
1131 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1)));
1132 int first_send_channel = vie_.GetLastChannel();
1133
1134 // Set low and high threshold and enable encode usage method.
1135 // Verify that cpu options are set.
1136 cricket::VideoOptions options;
1137 options.conference_mode.Set(true);
1138 options.cpu_underuse_threshold.Set(10);
1139 options.cpu_overuse_threshold.Set(20);
1140 options.cpu_overuse_encode_usage.Set(true);
1141 EXPECT_TRUE(channel_->SetOptions(options));
1142 webrtc::CpuOveruseOptions cpu_option =
1143 vie_.GetCpuOveruseOptions(first_send_channel);
1144 EXPECT_EQ(10, cpu_option.low_encode_usage_threshold_percent);
1145 EXPECT_EQ(20, cpu_option.high_encode_usage_threshold_percent);
1146 EXPECT_FALSE(cpu_option.enable_capture_jitter_method);
1147 EXPECT_TRUE(cpu_option.enable_encode_usage_method);
1148
1149 // Add a new send stream and verify that cpu options are set from start.
1150 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3)));
1151 int second_send_channel = vie_.GetLastChannel();
1152 EXPECT_NE(first_send_channel, second_send_channel);
1153 cpu_option = vie_.GetCpuOveruseOptions(second_send_channel);
1154 EXPECT_EQ(10, cpu_option.low_encode_usage_threshold_percent);
1155 EXPECT_EQ(20, cpu_option.high_encode_usage_threshold_percent);
1156 EXPECT_FALSE(cpu_option.enable_capture_jitter_method);
1157 EXPECT_TRUE(cpu_option.enable_encode_usage_method);
1158}
henrike@webrtc.orgb0ecc1c2014-03-26 22:44:28 +00001159
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001160// Test that AddRecvStream doesn't create new channel for 1:1 call.
1161TEST_F(WebRtcVideoEngineTestFake, AddRecvStream1On1) {
1162 EXPECT_TRUE(SetupEngine());
1163 int channel_num = vie_.GetLastChannel();
1164 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
1165 EXPECT_EQ(channel_num, vie_.GetLastChannel());
1166}
1167
henrika@webrtc.orgaebb1ad2014-01-14 10:00:58 +00001168// Test that NACK, PLI and REMB are enabled for internal codec.
1169TEST_F(WebRtcVideoEngineTestFake, InternalCodecFeedbackParams) {
1170 EXPECT_TRUE(SetupEngine());
1171
1172 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
1173 // Vp8 will appear at the beginning.
1174 size_t pos = 0;
1175 EXPECT_EQ("VP8", codecs[pos].name);
1176 VerifyCodecFeedbackParams(codecs[pos]);
1177}
1178
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001179// Test that AddRecvStream doesn't change remb for 1:1 call.
1180TEST_F(WebRtcVideoEngineTestFake, NoRembChangeAfterAddRecvStream) {
1181 EXPECT_TRUE(SetupEngine());
1182 int channel_num = vie_.GetLastChannel();
1183 EXPECT_TRUE(channel_->AddSendStream(
1184 cricket::StreamParams::CreateLegacy(1)));
1185 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
1186 EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num));
1187 EXPECT_TRUE(vie_.GetRembStatusContribute(channel_num));
1188 EXPECT_TRUE(channel_->SetSend(true));
1189 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
1190 EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num));
1191 EXPECT_TRUE(vie_.GetRembStatusContribute(channel_num));
1192}
1193
1194// Verify default REMB setting and that it can be turned on and off.
1195TEST_F(WebRtcVideoEngineTestFake, RembOnOff) {
1196 EXPECT_TRUE(SetupEngine());
1197 int channel_num = vie_.GetLastChannel();
1198 // Verify REMB sending is always off by default.
1199 EXPECT_FALSE(vie_.GetRembStatusBwPartition(channel_num));
1200
1201 // Verify that REMB is turned on when setting default codecs since the
1202 // default codecs have REMB enabled.
1203 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
1204 EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num));
1205
1206 // Verify that REMB is turned off when codecs without REMB are set.
1207 std::vector<cricket::VideoCodec> codecs = engine_.codecs();
1208 // Clearing the codecs' FeedbackParams and setting send codecs should disable
1209 // REMB.
1210 for (std::vector<cricket::VideoCodec>::iterator iter = codecs.begin();
1211 iter != codecs.end(); ++iter) {
1212 // Intersecting with empty will clear the FeedbackParams.
1213 cricket::FeedbackParams empty_params;
1214 iter->feedback_params.Intersect(empty_params);
1215 EXPECT_TRUE(iter->feedback_params.params().empty());
1216 }
1217 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1218 EXPECT_FALSE(vie_.GetRembStatusBwPartition(channel_num));
1219}
1220
1221// Test that nack is enabled on the channel if we don't offer red/fec.
1222TEST_F(WebRtcVideoEngineTestFake, NackEnabled) {
1223 EXPECT_TRUE(SetupEngine());
1224 int channel_num = vie_.GetLastChannel();
1225 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
1226 codecs.resize(1); // toss out red and ulpfec
1227 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1228 EXPECT_TRUE(vie_.GetNackStatus(channel_num));
buildbot@webrtc.org4b83a472014-06-05 21:11:28 +00001229 EXPECT_FALSE(vie_.GetHybridNackFecStatus(channel_num));
1230 EXPECT_FALSE(vie_.GetFecStatus(channel_num));
1231}
1232
1233// Test that FEC is enabled and NACK is disabled if we offer
1234// RED/FEC and we disable nack.
1235TEST_F(WebRtcVideoEngineTestFake, FecEnabled) {
1236 EXPECT_TRUE(SetupEngine());
1237 int channel_num = vie_.GetLastChannel();
1238 std::vector<cricket::VideoCodec> codecs = engine_.codecs();
1239 // Clearing the codecs' FeedbackParams and setting send codecs should disable
1240 // NACK.
1241 for (std::vector<cricket::VideoCodec>::iterator iter = codecs.begin();
1242 iter != codecs.end(); ++iter) {
1243 // Intersecting with empty will clear the FeedbackParams.
1244 cricket::FeedbackParams empty_params;
1245 iter->feedback_params.Intersect(empty_params);
1246 EXPECT_TRUE(iter->feedback_params.params().empty());
1247 }
1248 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1249 EXPECT_TRUE(vie_.GetFecStatus(channel_num));
1250 EXPECT_FALSE(vie_.GetHybridNackFecStatus(channel_num));
1251 EXPECT_FALSE(vie_.GetNackStatus(channel_num));
1252}
1253
1254// Test that FEC and NACK are disabled if we don't offer
1255// RED/FEC and we disable nack.
1256TEST_F(WebRtcVideoEngineTestFake, NackFecDisabled) {
1257 EXPECT_TRUE(SetupEngine());
1258 int channel_num = vie_.GetLastChannel();
1259 std::vector<cricket::VideoCodec> codecs = engine_.codecs();
1260 codecs.resize(1); // toss out red and ulpfec
1261 // Clearing the codecs' FeedbackParams and setting send codecs should disable
1262 // NACK.
1263 for (std::vector<cricket::VideoCodec>::iterator iter = codecs.begin();
1264 iter != codecs.end(); ++iter) {
1265 // Intersecting with empty will clear the FeedbackParams.
1266 cricket::FeedbackParams empty_params;
1267 iter->feedback_params.Intersect(empty_params);
1268 EXPECT_TRUE(iter->feedback_params.params().empty());
1269 }
1270 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1271 EXPECT_FALSE(vie_.GetFecStatus(channel_num));
1272 EXPECT_FALSE(vie_.GetHybridNackFecStatus(channel_num));
1273 EXPECT_FALSE(vie_.GetNackStatus(channel_num));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001274}
1275
1276// Test that we enable hybrid NACK FEC mode.
1277TEST_F(WebRtcVideoEngineTestFake, HybridNackFec) {
1278 EXPECT_TRUE(SetupEngine());
1279 int channel_num = vie_.GetLastChannel();
1280 EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs()));
1281 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
1282 EXPECT_TRUE(vie_.GetHybridNackFecStatus(channel_num));
1283 EXPECT_FALSE(vie_.GetNackStatus(channel_num));
buildbot@webrtc.org4b83a472014-06-05 21:11:28 +00001284 EXPECT_FALSE(vie_.GetFecStatus(channel_num));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001285}
1286
1287// Test that we enable hybrid NACK FEC mode when calling SetSendCodecs and
1288// SetReceiveCodecs in reversed order.
1289TEST_F(WebRtcVideoEngineTestFake, HybridNackFecReversedOrder) {
1290 EXPECT_TRUE(SetupEngine());
1291 int channel_num = vie_.GetLastChannel();
1292 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
1293 EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs()));
1294 EXPECT_TRUE(vie_.GetHybridNackFecStatus(channel_num));
1295 EXPECT_FALSE(vie_.GetNackStatus(channel_num));
buildbot@webrtc.org4b83a472014-06-05 21:11:28 +00001296 EXPECT_FALSE(vie_.GetFecStatus(channel_num));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001297}
1298
1299// Test NACK vs Hybrid NACK/FEC interop call setup, i.e. only use NACK even if
1300// red/fec is offered as receive codec.
1301TEST_F(WebRtcVideoEngineTestFake, VideoProtectionInterop) {
1302 EXPECT_TRUE(SetupEngine());
1303 int channel_num = vie_.GetLastChannel();
1304 std::vector<cricket::VideoCodec> recv_codecs(engine_.codecs());
1305 std::vector<cricket::VideoCodec> send_codecs(engine_.codecs());
1306 // Only add VP8 as send codec.
1307 send_codecs.resize(1);
1308 EXPECT_TRUE(channel_->SetRecvCodecs(recv_codecs));
1309 EXPECT_TRUE(channel_->SetSendCodecs(send_codecs));
1310 EXPECT_FALSE(vie_.GetHybridNackFecStatus(channel_num));
1311 EXPECT_TRUE(vie_.GetNackStatus(channel_num));
buildbot@webrtc.org4b83a472014-06-05 21:11:28 +00001312 EXPECT_FALSE(vie_.GetFecStatus(channel_num));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001313}
1314
1315// Test NACK vs Hybrid NACK/FEC interop call setup, i.e. only use NACK even if
1316// red/fec is offered as receive codec. Call order reversed compared to
1317// VideoProtectionInterop.
1318TEST_F(WebRtcVideoEngineTestFake, VideoProtectionInteropReversed) {
1319 EXPECT_TRUE(SetupEngine());
1320 int channel_num = vie_.GetLastChannel();
1321 std::vector<cricket::VideoCodec> recv_codecs(engine_.codecs());
1322 std::vector<cricket::VideoCodec> send_codecs(engine_.codecs());
1323 // Only add VP8 as send codec.
1324 send_codecs.resize(1);
1325 EXPECT_TRUE(channel_->SetSendCodecs(send_codecs));
1326 EXPECT_TRUE(channel_->SetRecvCodecs(recv_codecs));
1327 EXPECT_FALSE(vie_.GetHybridNackFecStatus(channel_num));
1328 EXPECT_TRUE(vie_.GetNackStatus(channel_num));
buildbot@webrtc.org4b83a472014-06-05 21:11:28 +00001329 EXPECT_FALSE(vie_.GetFecStatus(channel_num));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001330}
1331
1332// Test that NACK, not hybrid mode, is enabled in conference mode.
1333TEST_F(WebRtcVideoEngineTestFake, HybridNackFecConference) {
1334 EXPECT_TRUE(SetupEngine());
1335 // Setup the send channel.
1336 int send_channel_num = vie_.GetLastChannel();
1337 cricket::VideoOptions options;
1338 options.conference_mode.Set(true);
1339 EXPECT_TRUE(channel_->SetOptions(options));
1340 EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs()));
1341 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
1342 EXPECT_FALSE(vie_.GetHybridNackFecStatus(send_channel_num));
1343 EXPECT_TRUE(vie_.GetNackStatus(send_channel_num));
buildbot@webrtc.org4b83a472014-06-05 21:11:28 +00001344 EXPECT_FALSE(vie_.GetFecStatus(send_channel_num));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001345 // Add a receive stream.
1346 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
1347 int receive_channel_num = vie_.GetLastChannel();
1348 EXPECT_FALSE(vie_.GetHybridNackFecStatus(receive_channel_num));
1349 EXPECT_TRUE(vie_.GetNackStatus(receive_channel_num));
buildbot@webrtc.org4b83a472014-06-05 21:11:28 +00001350 EXPECT_FALSE(vie_.GetFecStatus(receive_channel_num));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001351}
1352
1353// Test that when AddRecvStream in conference mode, a new channel is created
1354// for receiving. And the new channel's "original channel" is the send channel.
1355TEST_F(WebRtcVideoEngineTestFake, AddRemoveRecvStreamConference) {
1356 EXPECT_TRUE(SetupEngine());
1357 // Setup the send channel.
1358 int send_channel_num = vie_.GetLastChannel();
1359 cricket::VideoOptions options;
1360 options.conference_mode.Set(true);
1361 EXPECT_TRUE(channel_->SetOptions(options));
1362 // Add a receive stream.
1363 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
1364 int receive_channel_num = vie_.GetLastChannel();
1365 EXPECT_EQ(send_channel_num, vie_.GetOriginalChannelId(receive_channel_num));
1366 EXPECT_TRUE(channel_->RemoveRecvStream(1));
1367 EXPECT_FALSE(vie_.IsChannel(receive_channel_num));
1368}
1369
henrike@webrtc.org6e3dbc22014-03-25 17:09:47 +00001370// Test that adding/removing stream with 0 ssrc should fail (and not crash).
1371// For crbug/351699 and 350988.
1372TEST_F(WebRtcVideoEngineTestFake, AddRemoveRecvStreamWith0Ssrc) {
1373 EXPECT_TRUE(SetupEngine());
1374 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
1375 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(0)));
1376 EXPECT_FALSE(channel_->RemoveRecvStream(0));
1377 EXPECT_TRUE(channel_->RemoveRecvStream(1));
1378}
1379
1380TEST_F(WebRtcVideoEngineTestFake, AddRemoveSendStreamWith0Ssrc) {
1381 EXPECT_TRUE(SetupEngine());
1382 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1)));
1383 EXPECT_FALSE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(0)));
1384 EXPECT_FALSE(channel_->RemoveSendStream(0));
1385 EXPECT_TRUE(channel_->RemoveSendStream(1));
1386}
1387
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001388// Test that we can create a channel and start/stop rendering out on it.
1389TEST_F(WebRtcVideoEngineTestFake, SetRender) {
1390 EXPECT_TRUE(SetupEngine());
1391 int channel_num = vie_.GetLastChannel();
1392
1393 // Verify we can start/stop/start/stop rendering.
1394 EXPECT_TRUE(channel_->SetRender(true));
1395 EXPECT_TRUE(vie_.GetRenderStarted(channel_num));
1396 EXPECT_TRUE(channel_->SetRender(false));
1397 EXPECT_FALSE(vie_.GetRenderStarted(channel_num));
1398 EXPECT_TRUE(channel_->SetRender(true));
1399 EXPECT_TRUE(vie_.GetRenderStarted(channel_num));
1400 EXPECT_TRUE(channel_->SetRender(false));
1401 EXPECT_FALSE(vie_.GetRenderStarted(channel_num));
1402}
1403
1404// Test that we can create a channel and start/stop sending out on it.
1405TEST_F(WebRtcVideoEngineTestFake, SetSend) {
1406 EXPECT_TRUE(SetupEngine());
1407 int channel_num = vie_.GetLastChannel();
wu@webrtc.orgb9a088b2014-02-13 23:18:49 +00001408 // Verify receiving is also started.
1409 EXPECT_TRUE(vie_.GetReceive(channel_num));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001410
1411 // Set send codecs on the channel.
1412 std::vector<cricket::VideoCodec> codecs;
1413 codecs.push_back(kVP8Codec);
1414 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1415 EXPECT_TRUE(channel_->AddSendStream(
1416 cricket::StreamParams::CreateLegacy(123)));
1417
1418 // Verify we can start/stop/start/stop sending.
1419 EXPECT_TRUE(channel_->SetSend(true));
1420 EXPECT_TRUE(vie_.GetSend(channel_num));
1421 EXPECT_TRUE(channel_->SetSend(false));
1422 EXPECT_FALSE(vie_.GetSend(channel_num));
1423 EXPECT_TRUE(channel_->SetSend(true));
1424 EXPECT_TRUE(vie_.GetSend(channel_num));
1425 EXPECT_TRUE(channel_->SetSend(false));
1426 EXPECT_FALSE(vie_.GetSend(channel_num));
1427}
1428
1429// Test that we set bandwidth properly when using full auto bandwidth mode.
1430TEST_F(WebRtcVideoEngineTestFake, SetBandwidthAuto) {
1431 EXPECT_TRUE(SetupEngine());
1432 int channel_num = vie_.GetLastChannel();
1433 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +00001434 EXPECT_TRUE(channel_->SetMaxSendBandwidth(cricket::kAutoBandwidth));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001435 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height);
1436}
1437
1438// Test that we set bandwidth properly when using auto with upper bound.
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +00001439TEST_F(WebRtcVideoEngineTestFake, SetBandwidthCapped) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001440 EXPECT_TRUE(SetupEngine());
1441 int channel_num = vie_.GetLastChannel();
1442 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +00001443 EXPECT_TRUE(channel_->SetMaxSendBandwidth(768000));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001444 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, 768U);
1445}
1446
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +00001447// Test that we reduce the start bandwidth when the requested max is less than
1448// the default start bandwidth.
1449TEST_F(WebRtcVideoEngineTestFake, SetMaxBandwidthBelowDefaultStart) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001450 EXPECT_TRUE(SetupEngine());
1451 int channel_num = vie_.GetLastChannel();
1452 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +00001453 int max_bandwidth_kbps = (kMinBandwidthKbps + kStartBandwidthKbps) / 2;
1454 EXPECT_TRUE(channel_->SetMaxSendBandwidth(max_bandwidth_kbps * 1000));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001455 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0,
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +00001456 max_bandwidth_kbps, kMinBandwidthKbps, max_bandwidth_kbps);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001457}
1458
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +00001459// Test that we reduce the min bandwidth when the requested max is less than
1460// the min bandwidth.
1461TEST_F(WebRtcVideoEngineTestFake, SetMaxBandwidthBelowMin) {
1462 EXPECT_TRUE(SetupEngine());
1463 int channel_num = vie_.GetLastChannel();
1464 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
1465 int max_bandwidth_kbps = kMinBandwidthKbps / 2;
1466 EXPECT_TRUE(channel_->SetMaxSendBandwidth(max_bandwidth_kbps * 1000));
1467 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0,
1468 max_bandwidth_kbps, max_bandwidth_kbps, max_bandwidth_kbps);
1469}
1470
1471// Test that the start bandwidth can be controlled separately from the max
1472// bandwidth.
1473TEST_F(WebRtcVideoEngineTestFake, SetStartBandwidth) {
1474 EXPECT_TRUE(SetupEngine());
1475 int channel_num = vie_.GetLastChannel();
1476 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
1477 int start_bandwidth_kbps = kStartBandwidthKbps + 1;
1478 EXPECT_TRUE(channel_->SetStartSendBandwidth(start_bandwidth_kbps * 1000));
1479 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0,
1480 kMaxBandwidthKbps, kMinBandwidthKbps, start_bandwidth_kbps);
1481
1482 // Check that SetMaxSendBandwidth doesn't overwrite the start bandwidth.
1483 int max_bandwidth_kbps = kMaxBandwidthKbps + 1;
1484 EXPECT_TRUE(channel_->SetMaxSendBandwidth(max_bandwidth_kbps * 1000));
1485 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0,
1486 max_bandwidth_kbps, kMinBandwidthKbps, start_bandwidth_kbps);
1487}
1488
wu@webrtc.org1e6cb2c2014-03-24 17:01:50 +00001489// Test that the start bandwidth can be controlled by experiment.
1490TEST_F(WebRtcVideoEngineTestFake, SetStartBandwidthOption) {
1491 EXPECT_TRUE(SetupEngine());
1492 int channel_num = vie_.GetLastChannel();
1493 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
1494 int start_bandwidth_kbps = kStartBandwidthKbps;
1495 EXPECT_TRUE(channel_->SetStartSendBandwidth(start_bandwidth_kbps * 1000));
1496 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0,
1497 kMaxBandwidthKbps, kMinBandwidthKbps, start_bandwidth_kbps);
1498
1499 // Set the start bitrate option.
1500 start_bandwidth_kbps = 1000;
1501 cricket::VideoOptions options;
1502 options.video_start_bitrate.Set(
1503 start_bandwidth_kbps);
1504 EXPECT_TRUE(channel_->SetOptions(options));
1505
1506 // Check that start bitrate has changed to the new value.
1507 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0,
1508 kMaxBandwidthKbps, kMinBandwidthKbps, start_bandwidth_kbps);
1509}
1510
buildbot@webrtc.orgd1ae89f2014-05-08 19:19:26 +00001511// Test that SetMaxSendBandwidth works as expected in conference mode.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001512TEST_F(WebRtcVideoEngineTestFake, SetBandwidthInConference) {
1513 EXPECT_TRUE(SetupEngine());
1514 int channel_num = vie_.GetLastChannel();
1515 cricket::VideoOptions options;
1516 options.conference_mode.Set(true);
1517 EXPECT_TRUE(channel_->SetOptions(options));
1518 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
1519 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height);
1520
1521 // Set send bandwidth.
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +00001522 EXPECT_TRUE(channel_->SetMaxSendBandwidth(768000));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001523
buildbot@webrtc.orgd1ae89f2014-05-08 19:19:26 +00001524 // Verify that the max bitrate has changed.
1525 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0,
1526 768, kMinBandwidthKbps, kStartBandwidthKbps);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001527}
1528
buildbot@webrtc.orgd1ae89f2014-05-08 19:19:26 +00001529
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001530// Test that sending screencast frames doesn't change bitrate.
1531TEST_F(WebRtcVideoEngineTestFake, SetBandwidthScreencast) {
1532 EXPECT_TRUE(SetupEngine());
1533 int channel_num = vie_.GetLastChannel();
1534
1535 // Set send codec.
1536 cricket::VideoCodec codec(kVP8Codec);
1537 std::vector<cricket::VideoCodec> codec_list;
1538 codec_list.push_back(codec);
1539 EXPECT_TRUE(channel_->AddSendStream(
1540 cricket::StreamParams::CreateLegacy(123)));
1541 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +00001542 EXPECT_TRUE(channel_->SetMaxSendBandwidth(111000));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001543 EXPECT_TRUE(channel_->SetSend(true));
1544
1545 SendI420ScreencastFrame(kVP8Codec.width, kVP8Codec.height);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +00001546 VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, 111);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001547}
1548
1549
1550// Test SetSendSsrc.
1551TEST_F(WebRtcVideoEngineTestFake, SetSendSsrcAndCname) {
1552 EXPECT_TRUE(SetupEngine());
1553 int channel_num = vie_.GetLastChannel();
1554
1555 cricket::StreamParams stream;
1556 stream.ssrcs.push_back(1234);
1557 stream.cname = "cname";
1558 channel_->AddSendStream(stream);
1559
1560 unsigned int ssrc = 0;
1561 EXPECT_EQ(0, vie_.GetLocalSSRC(channel_num, ssrc));
1562 EXPECT_EQ(1234U, ssrc);
1563 EXPECT_EQ(1, vie_.GetNumSsrcs(channel_num));
1564
1565 char rtcp_cname[256];
1566 EXPECT_EQ(0, vie_.GetRTCPCName(channel_num, rtcp_cname));
1567 EXPECT_STREQ("cname", rtcp_cname);
1568}
1569
1570
1571// Test that the local SSRC is the same on sending and receiving channels if the
1572// receive channel is created before the send channel.
1573TEST_F(WebRtcVideoEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) {
1574 EXPECT_TRUE(SetupEngine());
1575
1576 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
1577 int receive_channel_num = vie_.GetLastChannel();
1578 cricket::StreamParams stream = cricket::StreamParams::CreateLegacy(1234);
1579 EXPECT_TRUE(channel_->AddSendStream(stream));
1580 int send_channel_num = vie_.GetLastChannel();
1581 unsigned int ssrc = 0;
1582 EXPECT_EQ(0, vie_.GetLocalSSRC(send_channel_num, ssrc));
1583 EXPECT_EQ(1234U, ssrc);
1584 EXPECT_EQ(1, vie_.GetNumSsrcs(send_channel_num));
1585 ssrc = 0;
1586 EXPECT_EQ(0, vie_.GetLocalSSRC(receive_channel_num, ssrc));
1587 EXPECT_EQ(1234U, ssrc);
1588 EXPECT_EQ(1, vie_.GetNumSsrcs(receive_channel_num));
1589}
1590
1591
1592// Test SetOptions with denoising flag.
1593TEST_F(WebRtcVideoEngineTestFake, SetOptionsWithDenoising) {
1594 EXPECT_TRUE(SetupEngine());
1595 EXPECT_EQ(1, vie_.GetNumCapturers());
1596 int channel_num = vie_.GetLastChannel();
1597 int capture_id = vie_.GetCaptureId(channel_num);
1598 // Set send codecs on the channel.
1599 std::vector<cricket::VideoCodec> codecs;
1600 codecs.push_back(kVP8Codec);
1601 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1602
1603 // Set options with OPT_VIDEO_NOISE_REDUCTION flag.
1604 cricket::VideoOptions options;
1605 options.video_noise_reduction.Set(true);
1606 EXPECT_TRUE(channel_->SetOptions(options));
1607
1608 // Verify capture has denoising turned on.
1609 webrtc::VideoCodec send_codec;
1610 memset(&send_codec, 0, sizeof(send_codec)); // avoid uninitialized warning
1611 EXPECT_EQ(0, vie_.GetSendCodec(channel_num, send_codec));
1612 EXPECT_TRUE(send_codec.codecSpecific.VP8.denoisingOn);
1613 EXPECT_FALSE(vie_.GetCaptureDenoising(capture_id));
1614
1615 // Set options back to zero.
1616 options.video_noise_reduction.Set(false);
1617 EXPECT_TRUE(channel_->SetOptions(options));
1618
1619 // Verify capture has denoising turned off.
1620 EXPECT_EQ(0, vie_.GetSendCodec(channel_num, send_codec));
1621 EXPECT_FALSE(send_codec.codecSpecific.VP8.denoisingOn);
1622 EXPECT_FALSE(vie_.GetCaptureDenoising(capture_id));
1623}
1624
wu@webrtc.orga8910d22014-01-23 22:12:45 +00001625TEST_F(WebRtcVideoEngineTestFake, MultipleSendStreamsWithOneCapturer) {
wu@webrtc.org24301a62013-12-13 19:17:43 +00001626 EXPECT_TRUE(SetupEngine());
1627
1628 // Start the capturer
1629 cricket::FakeVideoCapturer capturer;
1630 cricket::VideoFormat capture_format_vga = cricket::VideoFormat(640, 480,
1631 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420);
1632 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_vga));
1633
1634 // Add send streams and connect the capturer
1635 for (unsigned int i = 0; i < sizeof(kSsrcs2)/sizeof(kSsrcs2[0]); ++i) {
1636 EXPECT_TRUE(channel_->AddSendStream(
1637 cricket::StreamParams::CreateLegacy(kSsrcs2[i])));
1638 // Register the capturer to the ssrc.
1639 EXPECT_TRUE(channel_->SetCapturer(kSsrcs2[i], &capturer));
1640 }
1641
1642 const int channel0 = vie_.GetChannelFromLocalSsrc(kSsrcs2[0]);
1643 ASSERT_NE(-1, channel0);
1644 const int channel1 = vie_.GetChannelFromLocalSsrc(kSsrcs2[1]);
1645 ASSERT_NE(-1, channel1);
1646 ASSERT_NE(channel0, channel1);
1647
wu@webrtc.orgb9a088b2014-02-13 23:18:49 +00001648 // Both channels should have started receiving after created.
1649 EXPECT_TRUE(vie_.GetReceive(channel0));
1650 EXPECT_TRUE(vie_.GetReceive(channel1));
1651
wu@webrtc.org24301a62013-12-13 19:17:43 +00001652 // Set send codec.
1653 std::vector<cricket::VideoCodec> codecs;
1654 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0);
1655 codecs.push_back(send_codec);
1656 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1657
wu@webrtc.orgb9a088b2014-02-13 23:18:49 +00001658 EXPECT_TRUE(channel_->SetSend(true));
1659 EXPECT_TRUE(vie_.GetSend(channel0));
1660 EXPECT_TRUE(vie_.GetSend(channel1));
1661
wu@webrtc.org24301a62013-12-13 19:17:43 +00001662 EXPECT_TRUE(capturer.CaptureFrame());
1663 EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel0));
1664 EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel1));
1665
1666 EXPECT_TRUE(channel_->RemoveSendStream(kSsrcs2[0]));
1667 EXPECT_TRUE(capturer.CaptureFrame());
1668 // channel0 is the default channel, so it won't be deleted.
1669 // But it should be disconnected from the capturer.
1670 EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel0));
1671 EXPECT_EQ(2, vie_.GetIncomingFrameNum(channel1));
1672
1673 EXPECT_TRUE(channel_->RemoveSendStream(kSsrcs2[1]));
1674 EXPECT_TRUE(capturer.CaptureFrame());
1675 EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel0));
1676 // channel1 has already been deleted.
1677 EXPECT_EQ(-1, vie_.GetIncomingFrameNum(channel1));
1678}
1679
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001680
buildbot@webrtc.orga18b4c92014-05-06 17:48:14 +00001681TEST_F(WebRtcVideoEngineTestFake, SendReceiveBitratesStats) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001682 EXPECT_TRUE(SetupEngine());
1683 cricket::VideoOptions options;
1684 options.conference_mode.Set(true);
1685 EXPECT_TRUE(channel_->SetOptions(options));
1686 EXPECT_TRUE(channel_->AddSendStream(
1687 cricket::StreamParams::CreateLegacy(1)));
buildbot@webrtc.orga18b4c92014-05-06 17:48:14 +00001688 int first_send_channel = vie_.GetLastChannel();
1689 EXPECT_TRUE(channel_->AddSendStream(
1690 cricket::StreamParams::CreateLegacy(2)));
1691 int second_send_channel = vie_.GetLastChannel();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001692 cricket::VideoCodec codec(kVP8Codec720p);
1693 std::vector<cricket::VideoCodec> codec_list;
1694 codec_list.push_back(codec);
1695 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
1696
1697 EXPECT_TRUE(channel_->AddRecvStream(
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001698 cricket::StreamParams::CreateLegacy(3)));
buildbot@webrtc.orga18b4c92014-05-06 17:48:14 +00001699 int first_receive_channel = vie_.GetLastChannel();
1700 EXPECT_NE(first_send_channel, first_receive_channel);
1701 EXPECT_TRUE(channel_->AddRecvStream(
1702 cricket::StreamParams::CreateLegacy(4)));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001703 int second_receive_channel = vie_.GetLastChannel();
1704 EXPECT_NE(first_receive_channel, second_receive_channel);
1705
1706 cricket::VideoMediaInfo info;
wu@webrtc.orgb9a088b2014-02-13 23:18:49 +00001707 EXPECT_TRUE(channel_->GetStats(cricket::StatsOptions(), &info));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001708 ASSERT_EQ(1U, info.bw_estimations.size());
1709 ASSERT_EQ(0, info.bw_estimations[0].actual_enc_bitrate);
1710 ASSERT_EQ(0, info.bw_estimations[0].transmit_bitrate);
1711 ASSERT_EQ(0, info.bw_estimations[0].retransmit_bitrate);
1712 ASSERT_EQ(0, info.bw_estimations[0].available_send_bandwidth);
1713 ASSERT_EQ(0, info.bw_estimations[0].available_recv_bandwidth);
1714 ASSERT_EQ(0, info.bw_estimations[0].target_enc_bitrate);
1715
1716 // Start sending and receiving on one of the channels and verify bitrates.
buildbot@webrtc.orga18b4c92014-05-06 17:48:14 +00001717 EXPECT_EQ(0, vie_.StartSend(first_send_channel));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001718 int send_video_bitrate = 800;
1719 int send_fec_bitrate = 100;
1720 int send_nack_bitrate = 20;
1721 int send_total_bitrate = send_video_bitrate + send_fec_bitrate +
1722 send_nack_bitrate;
buildbot@webrtc.orga18b4c92014-05-06 17:48:14 +00001723 int send_bandwidth = 1900;
1724 vie_.SetSendBitrates(first_send_channel, send_video_bitrate, send_fec_bitrate,
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001725 send_nack_bitrate);
buildbot@webrtc.orga18b4c92014-05-06 17:48:14 +00001726 vie_.SetSendBandwidthEstimate(first_send_channel, send_bandwidth);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001727
1728 EXPECT_EQ(0, vie_.StartReceive(first_receive_channel));
buildbot@webrtc.orga18b4c92014-05-06 17:48:14 +00001729 int receive_bandwidth = 600;
1730 vie_.SetReceiveBandwidthEstimate(first_receive_channel, receive_bandwidth);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001731
1732 info.Clear();
wu@webrtc.orgb9a088b2014-02-13 23:18:49 +00001733 EXPECT_TRUE(channel_->GetStats(cricket::StatsOptions(), &info));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001734 ASSERT_EQ(1U, info.bw_estimations.size());
1735 ASSERT_EQ(send_video_bitrate, info.bw_estimations[0].actual_enc_bitrate);
1736 ASSERT_EQ(send_total_bitrate, info.bw_estimations[0].transmit_bitrate);
1737 ASSERT_EQ(send_nack_bitrate, info.bw_estimations[0].retransmit_bitrate);
1738 ASSERT_EQ(send_bandwidth, info.bw_estimations[0].available_send_bandwidth);
buildbot@webrtc.orga18b4c92014-05-06 17:48:14 +00001739 ASSERT_EQ(receive_bandwidth, info.bw_estimations[0].available_recv_bandwidth);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001740 ASSERT_EQ(send_video_bitrate, info.bw_estimations[0].target_enc_bitrate);
1741
1742 // Start receiving on the second channel and verify received rate.
buildbot@webrtc.orga18b4c92014-05-06 17:48:14 +00001743 EXPECT_EQ(0, vie_.StartSend(second_send_channel));
1744 vie_.SetSendBitrates(second_send_channel,
1745 send_video_bitrate,
1746 send_fec_bitrate,
1747 send_nack_bitrate);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001748 EXPECT_EQ(0, vie_.StartReceive(second_receive_channel));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001749
1750 info.Clear();
wu@webrtc.orgb9a088b2014-02-13 23:18:49 +00001751 EXPECT_TRUE(channel_->GetStats(cricket::StatsOptions(), &info));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001752 ASSERT_EQ(1U, info.bw_estimations.size());
buildbot@webrtc.orga18b4c92014-05-06 17:48:14 +00001753 ASSERT_EQ(2 * send_video_bitrate, info.bw_estimations[0].actual_enc_bitrate);
1754 ASSERT_EQ(2 * send_total_bitrate, info.bw_estimations[0].transmit_bitrate);
1755 ASSERT_EQ(2 * send_nack_bitrate, info.bw_estimations[0].retransmit_bitrate);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001756 ASSERT_EQ(send_bandwidth, info.bw_estimations[0].available_send_bandwidth);
buildbot@webrtc.orga18b4c92014-05-06 17:48:14 +00001757 ASSERT_EQ(receive_bandwidth, info.bw_estimations[0].available_recv_bandwidth);
1758 ASSERT_EQ(2 * send_video_bitrate, info.bw_estimations[0].target_enc_bitrate);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001759}
1760
1761TEST_F(WebRtcVideoEngineTestFake, TestSetAdaptInputToCpuUsage) {
1762 EXPECT_TRUE(SetupEngine());
1763 cricket::VideoOptions options_in, options_out;
1764 bool cpu_adapt = false;
1765 channel_->SetOptions(options_in);
1766 EXPECT_TRUE(channel_->GetOptions(&options_out));
1767 EXPECT_FALSE(options_out.adapt_input_to_cpu_usage.Get(&cpu_adapt));
1768 // Set adapt input CPU usage option.
1769 options_in.adapt_input_to_cpu_usage.Set(true);
1770 EXPECT_TRUE(channel_->SetOptions(options_in));
1771 EXPECT_TRUE(channel_->GetOptions(&options_out));
1772 EXPECT_TRUE(options_out.adapt_input_to_cpu_usage.Get(&cpu_adapt));
1773 EXPECT_TRUE(cpu_adapt);
1774}
1775
1776TEST_F(WebRtcVideoEngineTestFake, TestSetCpuThreshold) {
1777 EXPECT_TRUE(SetupEngine());
1778 float low, high;
1779 cricket::VideoOptions options_in, options_out;
1780 // Verify that initial values are set.
1781 EXPECT_TRUE(channel_->GetOptions(&options_out));
1782 EXPECT_TRUE(options_out.system_low_adaptation_threshhold.Get(&low));
1783 EXPECT_EQ(low, 0.65f);
1784 EXPECT_TRUE(options_out.system_high_adaptation_threshhold.Get(&high));
1785 EXPECT_EQ(high, 0.85f);
1786 // Set new CPU threshold values.
1787 options_in.system_low_adaptation_threshhold.Set(0.45f);
1788 options_in.system_high_adaptation_threshhold.Set(0.95f);
1789 EXPECT_TRUE(channel_->SetOptions(options_in));
1790 EXPECT_TRUE(channel_->GetOptions(&options_out));
1791 EXPECT_TRUE(options_out.system_low_adaptation_threshhold.Get(&low));
1792 EXPECT_EQ(low, 0.45f);
1793 EXPECT_TRUE(options_out.system_high_adaptation_threshhold.Get(&high));
1794 EXPECT_EQ(high, 0.95f);
1795}
1796
1797TEST_F(WebRtcVideoEngineTestFake, TestSetInvalidCpuThreshold) {
1798 EXPECT_TRUE(SetupEngine());
1799 float low, high;
1800 cricket::VideoOptions options_in, options_out;
1801 // Valid range is [0, 1].
1802 options_in.system_low_adaptation_threshhold.Set(-1.5f);
1803 options_in.system_high_adaptation_threshhold.Set(1.5f);
1804 EXPECT_TRUE(channel_->SetOptions(options_in));
1805 EXPECT_TRUE(channel_->GetOptions(&options_out));
1806 EXPECT_TRUE(options_out.system_low_adaptation_threshhold.Get(&low));
1807 EXPECT_EQ(low, 0.0f);
1808 EXPECT_TRUE(options_out.system_high_adaptation_threshhold.Get(&high));
1809 EXPECT_EQ(high, 1.0f);
1810}
1811
1812
henrika@webrtc.orgaebb1ad2014-01-14 10:00:58 +00001813TEST_F(WebRtcVideoEngineTestFake, ResetCodecOnScreencast) {
1814 EXPECT_TRUE(SetupEngine());
1815 cricket::VideoOptions options;
1816 options.video_noise_reduction.Set(true);
1817 EXPECT_TRUE(channel_->SetOptions(options));
1818
1819 // Set send codec.
1820 cricket::VideoCodec codec(kVP8Codec);
1821 std::vector<cricket::VideoCodec> codec_list;
1822 codec_list.push_back(codec);
1823 EXPECT_TRUE(channel_->AddSendStream(
1824 cricket::StreamParams::CreateLegacy(123)));
1825 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
1826 EXPECT_TRUE(channel_->SetSend(true));
wu@webrtc.org05e7b442014-04-01 17:44:24 +00001827 EXPECT_EQ(1, vie_.GetNumSetSendCodecs());
henrika@webrtc.orgaebb1ad2014-01-14 10:00:58 +00001828
1829 webrtc::VideoCodec gcodec;
1830 memset(&gcodec, 0, sizeof(gcodec));
1831 int channel_num = vie_.GetLastChannel();
1832 EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec));
1833 EXPECT_TRUE(gcodec.codecSpecific.VP8.denoisingOn);
1834
1835 // Send a screencast frame with the same size.
1836 // Verify that denoising is turned off.
1837 SendI420ScreencastFrame(kVP8Codec.width, kVP8Codec.height);
wu@webrtc.org05e7b442014-04-01 17:44:24 +00001838 EXPECT_EQ(2, vie_.GetNumSetSendCodecs());
henrika@webrtc.orgaebb1ad2014-01-14 10:00:58 +00001839 EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec));
1840 EXPECT_FALSE(gcodec.codecSpecific.VP8.denoisingOn);
1841}
1842
1843
1844TEST_F(WebRtcVideoEngineTestFake, DontRegisterDecoderIfFactoryIsNotGiven) {
1845 engine_.SetExternalDecoderFactory(NULL);
1846 EXPECT_TRUE(SetupEngine());
1847 int channel_num = vie_.GetLastChannel();
1848
1849 std::vector<cricket::VideoCodec> codecs;
1850 codecs.push_back(kVP8Codec);
1851 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1852
1853 EXPECT_EQ(0, vie_.GetNumExternalDecoderRegistered(channel_num));
1854}
1855
1856TEST_F(WebRtcVideoEngineTestFake, RegisterDecoderIfFactoryIsGiven) {
1857 decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8);
1858 engine_.SetExternalDecoderFactory(&decoder_factory_);
1859 EXPECT_TRUE(SetupEngine());
1860 int channel_num = vie_.GetLastChannel();
1861
1862 std::vector<cricket::VideoCodec> codecs;
1863 codecs.push_back(kVP8Codec);
1864 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1865
1866 EXPECT_TRUE(vie_.ExternalDecoderRegistered(channel_num, 100));
1867 EXPECT_EQ(1, vie_.GetNumExternalDecoderRegistered(channel_num));
1868}
1869
1870TEST_F(WebRtcVideoEngineTestFake, DontRegisterDecoderMultipleTimes) {
1871 decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8);
1872 engine_.SetExternalDecoderFactory(&decoder_factory_);
1873 EXPECT_TRUE(SetupEngine());
1874 int channel_num = vie_.GetLastChannel();
1875
1876 std::vector<cricket::VideoCodec> codecs;
1877 codecs.push_back(kVP8Codec);
1878 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1879
1880 EXPECT_TRUE(vie_.ExternalDecoderRegistered(channel_num, 100));
1881 EXPECT_EQ(1, vie_.GetNumExternalDecoderRegistered(channel_num));
1882 EXPECT_EQ(1, decoder_factory_.GetNumCreatedDecoders());
1883
1884 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1885 EXPECT_EQ(1, vie_.GetNumExternalDecoderRegistered(channel_num));
1886 EXPECT_EQ(1, decoder_factory_.GetNumCreatedDecoders());
1887}
1888
1889TEST_F(WebRtcVideoEngineTestFake, DontRegisterDecoderForNonVP8) {
1890 decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8);
1891 engine_.SetExternalDecoderFactory(&decoder_factory_);
1892 EXPECT_TRUE(SetupEngine());
1893 int channel_num = vie_.GetLastChannel();
1894
1895 std::vector<cricket::VideoCodec> codecs;
1896 codecs.push_back(kRedCodec);
1897 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1898
1899 EXPECT_EQ(0, vie_.GetNumExternalDecoderRegistered(channel_num));
1900}
1901
1902TEST_F(WebRtcVideoEngineTestFake, DontRegisterEncoderIfFactoryIsNotGiven) {
1903 engine_.SetExternalEncoderFactory(NULL);
1904 EXPECT_TRUE(SetupEngine());
1905 int channel_num = vie_.GetLastChannel();
1906
1907 std::vector<cricket::VideoCodec> codecs;
1908 codecs.push_back(kVP8Codec);
1909 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1910
1911 EXPECT_EQ(0, vie_.GetNumExternalEncoderRegistered(channel_num));
1912}
1913
1914TEST_F(WebRtcVideoEngineTestFake, RegisterEncoderIfFactoryIsGiven) {
1915 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
1916 engine_.SetExternalEncoderFactory(&encoder_factory_);
1917 EXPECT_TRUE(SetupEngine());
1918 int channel_num = vie_.GetLastChannel();
1919
1920 std::vector<cricket::VideoCodec> codecs;
1921 codecs.push_back(kVP8Codec);
1922 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1923
1924 EXPECT_TRUE(channel_->AddSendStream(
1925 cricket::StreamParams::CreateLegacy(kSsrc)));
1926
1927 EXPECT_TRUE(vie_.ExternalEncoderRegistered(channel_num, 100));
1928 EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num));
1929
1930 // Remove stream previously added to free the external encoder instance.
1931 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc));
1932}
1933
1934TEST_F(WebRtcVideoEngineTestFake, DontRegisterEncoderMultipleTimes) {
1935 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
1936 engine_.SetExternalEncoderFactory(&encoder_factory_);
1937 EXPECT_TRUE(SetupEngine());
1938 int channel_num = vie_.GetLastChannel();
1939
1940 std::vector<cricket::VideoCodec> codecs;
1941 codecs.push_back(kVP8Codec);
1942 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1943
1944 EXPECT_TRUE(channel_->AddSendStream(
1945 cricket::StreamParams::CreateLegacy(kSsrc)));
1946
1947 EXPECT_TRUE(vie_.ExternalEncoderRegistered(channel_num, 100));
1948 EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num));
henrika@webrtc.orgaebb1ad2014-01-14 10:00:58 +00001949
1950 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1951 EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num));
henrika@webrtc.orgaebb1ad2014-01-14 10:00:58 +00001952
1953 // Remove stream previously added to free the external encoder instance.
1954 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc));
1955}
1956
1957TEST_F(WebRtcVideoEngineTestFake, RegisterEncoderWithMultipleSendStreams) {
1958 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
1959 engine_.SetExternalEncoderFactory(&encoder_factory_);
1960 EXPECT_TRUE(SetupEngine());
1961
1962 std::vector<cricket::VideoCodec> codecs;
1963 codecs.push_back(kVP8Codec);
1964 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1965 EXPECT_EQ(1, vie_.GetTotalNumExternalEncoderRegistered());
1966
1967 // When we add the first stream (1234), it reuses the default send channel,
1968 // so it doesn't increase the registration count of external encoders.
1969 EXPECT_TRUE(channel_->AddSendStream(
1970 cricket::StreamParams::CreateLegacy(1234)));
1971 EXPECT_EQ(1, vie_.GetTotalNumExternalEncoderRegistered());
1972
1973 // When we add the second stream (2345), it creates a new channel and
1974 // increments the registration count.
1975 EXPECT_TRUE(channel_->AddSendStream(
1976 cricket::StreamParams::CreateLegacy(2345)));
1977 EXPECT_EQ(2, vie_.GetTotalNumExternalEncoderRegistered());
1978
1979 // At this moment the total registration count is two, but only one encoder
1980 // is registered per channel.
1981 int channel_num = vie_.GetLastChannel();
1982 EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num));
1983
1984 // Removing send streams decrements the registration count.
1985 EXPECT_TRUE(channel_->RemoveSendStream(1234));
1986 EXPECT_EQ(1, vie_.GetTotalNumExternalEncoderRegistered());
1987
1988 // When we remove the last send stream, it also destroys the last send
1989 // channel and causes the registration count to drop to zero. It is a little
1990 // weird, but not a bug.
1991 EXPECT_TRUE(channel_->RemoveSendStream(2345));
1992 EXPECT_EQ(0, vie_.GetTotalNumExternalEncoderRegistered());
1993}
1994
1995TEST_F(WebRtcVideoEngineTestFake, DontRegisterEncoderForNonVP8) {
1996 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecGeneric,
1997 "GENERIC");
1998 engine_.SetExternalEncoderFactory(&encoder_factory_);
1999 EXPECT_TRUE(SetupEngine());
2000 int channel_num = vie_.GetLastChannel();
2001
2002 // Note: unlike the SetRecvCodecs, we must set a valid video codec for
2003 // channel_->SetSendCodecs() to succeed.
2004 std::vector<cricket::VideoCodec> codecs;
2005 codecs.push_back(kVP8Codec);
2006 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
2007
2008 EXPECT_EQ(0, vie_.GetNumExternalEncoderRegistered(channel_num));
2009}
2010
2011// Test that NACK, PLI and REMB are enabled for external codec.
2012TEST_F(WebRtcVideoEngineTestFake, ExternalCodecFeedbackParams) {
2013 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecGeneric,
2014 "GENERIC");
2015 engine_.SetExternalEncoderFactory(&encoder_factory_);
2016 encoder_factory_.NotifyCodecsAvailable();
2017 EXPECT_TRUE(SetupEngine());
2018
2019 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
2020 // The external codec will appear at last.
2021 size_t pos = codecs.size() - 1;
2022 EXPECT_EQ("GENERIC", codecs[pos].name);
2023 VerifyCodecFeedbackParams(codecs[pos]);
2024}
2025
2026// Test external codec with be added to the end of the supported codec list.
2027TEST_F(WebRtcVideoEngineTestFake, ExternalCodecAddedToTheEnd) {
2028 EXPECT_TRUE(SetupEngine());
2029
2030 std::vector<cricket::VideoCodec> codecs(engine_.codecs());
2031 EXPECT_EQ("VP8", codecs[0].name);
2032
2033 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecGeneric,
2034 "GENERIC");
2035 engine_.SetExternalEncoderFactory(&encoder_factory_);
2036 encoder_factory_.NotifyCodecsAvailable();
2037
2038 codecs = engine_.codecs();
2039 cricket::VideoCodec internal_codec = codecs[0];
2040 cricket::VideoCodec external_codec = codecs[codecs.size() - 1];
2041 // The external codec will appear at last.
2042 EXPECT_EQ("GENERIC", external_codec.name);
2043 // The internal codec is preferred.
2044 EXPECT_GE(internal_codec.preference, external_codec.preference);
2045}
2046
2047// Test that external codec with be ignored if it has the same name as one of
2048// the internal codecs.
2049TEST_F(WebRtcVideoEngineTestFake, ExternalCodecIgnored) {
2050 EXPECT_TRUE(SetupEngine());
2051
2052 std::vector<cricket::VideoCodec> internal_codecs(engine_.codecs());
2053 EXPECT_EQ("VP8", internal_codecs[0].name);
2054
2055 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
2056 engine_.SetExternalEncoderFactory(&encoder_factory_);
2057 encoder_factory_.NotifyCodecsAvailable();
2058
2059 std::vector<cricket::VideoCodec> codecs = engine_.codecs();
2060 EXPECT_EQ("VP8", codecs[0].name);
2061 EXPECT_EQ(internal_codecs[0].height, codecs[0].height);
2062 EXPECT_EQ(internal_codecs[0].width, codecs[0].width);
2063 // Verify the last codec is not the external codec.
2064 EXPECT_NE("VP8", codecs[codecs.size() - 1].name);
2065}
2066
2067TEST_F(WebRtcVideoEngineTestFake, UpdateEncoderCodecsAfterSetFactory) {
2068 engine_.SetExternalEncoderFactory(&encoder_factory_);
2069 EXPECT_TRUE(SetupEngine());
2070 int channel_num = vie_.GetLastChannel();
2071
2072 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
2073 encoder_factory_.NotifyCodecsAvailable();
2074 std::vector<cricket::VideoCodec> codecs;
2075 codecs.push_back(kVP8Codec);
2076 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
2077
2078 EXPECT_TRUE(channel_->AddSendStream(
2079 cricket::StreamParams::CreateLegacy(kSsrc)));
2080
2081 EXPECT_TRUE(vie_.ExternalEncoderRegistered(channel_num, 100));
2082 EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num));
henrika@webrtc.orgaebb1ad2014-01-14 10:00:58 +00002083
2084 // Remove stream previously added to free the external encoder instance.
2085 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc));
2086}
2087
2088// Tests that OnReadyToSend will be propagated into ViE.
2089TEST_F(WebRtcVideoEngineTestFake, OnReadyToSend) {
2090 EXPECT_TRUE(SetupEngine());
2091 int channel_num = vie_.GetLastChannel();
2092 EXPECT_TRUE(vie_.GetIsTransmitting(channel_num));
2093
2094 channel_->OnReadyToSend(false);
2095 EXPECT_FALSE(vie_.GetIsTransmitting(channel_num));
2096
2097 channel_->OnReadyToSend(true);
2098 EXPECT_TRUE(vie_.GetIsTransmitting(channel_num));
2099}
2100
2101#if 0
2102TEST_F(WebRtcVideoEngineTestFake, CaptureFrameTimestampToNtpTimestamp) {
2103 EXPECT_TRUE(SetupEngine());
2104 int capture_id = vie_.GetCaptureId(vie_.GetLastChannel());
2105
2106 // Set send codec.
2107 cricket::VideoCodec codec(kVP8Codec);
2108 std::vector<cricket::VideoCodec> codec_list;
2109 codec_list.push_back(codec);
2110 EXPECT_TRUE(channel_->AddSendStream(
2111 cricket::StreamParams::CreateLegacy(123)));
2112 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
2113 EXPECT_TRUE(channel_->SetSend(true));
2114
2115 int64 timestamp = time(NULL) * talk_base::kNumNanosecsPerSec;
2116 SendI420ScreencastFrameWithTimestamp(
2117 kVP8Codec.width, kVP8Codec.height, timestamp);
2118 EXPECT_EQ(talk_base::UnixTimestampNanosecsToNtpMillisecs(timestamp),
2119 vie_.GetCaptureLastTimestamp(capture_id));
2120
2121 SendI420ScreencastFrameWithTimestamp(kVP8Codec.width, kVP8Codec.height, 0);
2122 EXPECT_EQ(0, vie_.GetCaptureLastTimestamp(capture_id));
2123}
2124#endif
2125
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002126/////////////////////////
2127// Tests with real ViE //
2128/////////////////////////
2129
2130// Tests that we can find codecs by name or id.
2131TEST_F(WebRtcVideoEngineTest, FindCodec) {
2132 // We should not need to init engine in order to get codecs.
2133 const std::vector<cricket::VideoCodec>& c = engine_.codecs();
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +00002134 EXPECT_EQ(4U, c.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002135
2136 cricket::VideoCodec vp8(104, "VP8", 320, 200, 30, 0);
2137 EXPECT_TRUE(engine_.FindCodec(vp8));
2138
2139 cricket::VideoCodec vp8_ci(104, "vp8", 320, 200, 30, 0);
2140 EXPECT_TRUE(engine_.FindCodec(vp8));
2141
2142 cricket::VideoCodec vp8_diff_fr_diff_pref(104, "VP8", 320, 200, 50, 50);
2143 EXPECT_TRUE(engine_.FindCodec(vp8_diff_fr_diff_pref));
2144
2145 cricket::VideoCodec vp8_diff_id(95, "VP8", 320, 200, 30, 0);
2146 EXPECT_FALSE(engine_.FindCodec(vp8_diff_id));
2147 vp8_diff_id.id = 97;
2148 EXPECT_TRUE(engine_.FindCodec(vp8_diff_id));
2149
2150 cricket::VideoCodec vp8_diff_res(104, "VP8", 320, 111, 30, 0);
2151 EXPECT_FALSE(engine_.FindCodec(vp8_diff_res));
2152
2153 // PeerConnection doesn't negotiate the resolution at this point.
2154 // Test that FindCodec can handle the case when width/height is 0.
2155 cricket::VideoCodec vp8_zero_res(104, "VP8", 0, 0, 30, 0);
2156 EXPECT_TRUE(engine_.FindCodec(vp8_zero_res));
2157
2158 cricket::VideoCodec red(101, "RED", 0, 0, 30, 0);
2159 EXPECT_TRUE(engine_.FindCodec(red));
2160
2161 cricket::VideoCodec red_ci(101, "red", 0, 0, 30, 0);
2162 EXPECT_TRUE(engine_.FindCodec(red));
2163
2164 cricket::VideoCodec fec(102, "ULPFEC", 0, 0, 30, 0);
2165 EXPECT_TRUE(engine_.FindCodec(fec));
2166
2167 cricket::VideoCodec fec_ci(102, "ulpfec", 0, 0, 30, 0);
2168 EXPECT_TRUE(engine_.FindCodec(fec));
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +00002169
2170 cricket::VideoCodec rtx(96, "rtx", 0, 0, 30, 0);
buildbot@webrtc.orgdd4742a2014-05-07 14:50:35 +00002171 rtx.SetParam("apt", kVP8Codec.id);
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +00002172 EXPECT_TRUE(engine_.FindCodec(rtx));
2173}
2174
2175TEST_F(WebRtcVideoEngineTest, RtxCodecHasAptSet) {
2176 std::vector<cricket::VideoCodec>::const_iterator it;
2177 bool apt_checked = false;
2178 for (it = engine_.codecs().begin(); it != engine_.codecs().end(); ++it) {
2179 if (_stricmp(cricket::kRtxCodecName, it->name.c_str()) && it->id != 96) {
2180 continue;
2181 }
2182 int apt;
2183 EXPECT_TRUE(it->GetParam("apt", &apt));
2184 EXPECT_EQ(100, apt);
2185 apt_checked = true;
2186 }
2187 EXPECT_TRUE(apt_checked);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002188}
2189
2190TEST_F(WebRtcVideoEngineTest, StartupShutdown) {
2191 EXPECT_TRUE(engine_.Init(talk_base::Thread::Current()));
2192 engine_.Terminate();
2193}
2194
2195TEST_PRE_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainNewCodec)
2196TEST_POST_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainNewCodec)
2197
2198TEST_PRE_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainRunningCodec)
2199TEST_POST_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainRunningCodec)
2200
2201// TODO(juberti): Figure out why ViE is munging the COM refcount.
2202#ifdef WIN32
2203TEST_F(WebRtcVideoEngineTest, DISABLED_CheckCoInitialize) {
2204 Base::CheckCoInitialize();
2205}
2206#endif
2207
2208TEST_F(WebRtcVideoEngineTest, CreateChannel) {
2209 EXPECT_TRUE(engine_.Init(talk_base::Thread::Current()));
2210 cricket::VideoMediaChannel* channel = engine_.CreateChannel(NULL);
2211 EXPECT_TRUE(channel != NULL);
2212 delete channel;
2213}
2214
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002215TEST_F(WebRtcVideoMediaChannelTest, SetRecvCodecs) {
2216 std::vector<cricket::VideoCodec> codecs;
2217 codecs.push_back(kVP8Codec);
2218 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
2219}
2220TEST_F(WebRtcVideoMediaChannelTest, SetRecvCodecsWrongPayloadType) {
2221 std::vector<cricket::VideoCodec> codecs;
2222 codecs.push_back(kVP8Codec);
2223 codecs[0].id = 99;
2224 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
2225}
2226TEST_F(WebRtcVideoMediaChannelTest, SetRecvCodecsUnsupportedCodec) {
2227 std::vector<cricket::VideoCodec> codecs;
2228 codecs.push_back(kVP8Codec);
2229 codecs.push_back(cricket::VideoCodec(101, "VP1", 640, 400, 30, 0));
2230 EXPECT_FALSE(channel_->SetRecvCodecs(codecs));
2231}
2232
mallinath@webrtc.org92fdfeb2014-02-17 18:49:41 +00002233TEST_F(WebRtcVideoMediaChannelTest, GetRtpSendTimeExtension) {
2234 // Enable RTP timestamp extension.
2235 const int id = 12;
2236 std::vector<cricket::RtpHeaderExtension> extensions;
2237 extensions.push_back(cricket::RtpHeaderExtension(
2238 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", id));
2239
2240 // Verify the send extension id.
2241 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions));
2242 EXPECT_EQ(id, channel_->GetRtpSendTimeExtnId());
2243}
2244
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002245TEST_F(WebRtcVideoMediaChannelTest, SetSend) {
2246 Base::SetSend();
2247}
2248TEST_F(WebRtcVideoMediaChannelTest, SetSendWithoutCodecs) {
2249 Base::SetSendWithoutCodecs();
2250}
2251TEST_F(WebRtcVideoMediaChannelTest, SetSendSetsTransportBufferSizes) {
2252 Base::SetSendSetsTransportBufferSizes();
2253}
2254
2255TEST_F(WebRtcVideoMediaChannelTest, SendAndReceiveVp8Vga) {
2256 SendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30, 0));
2257}
2258TEST_F(WebRtcVideoMediaChannelTest, SendAndReceiveVp8Qvga) {
2259 SendAndReceive(cricket::VideoCodec(100, "VP8", 320, 200, 30, 0));
2260}
2261TEST_F(WebRtcVideoMediaChannelTest, SendAndReceiveH264SvcQqvga) {
2262 SendAndReceive(cricket::VideoCodec(100, "VP8", 160, 100, 30, 0));
2263}
2264TEST_F(WebRtcVideoMediaChannelTest, SendManyResizeOnce) {
2265 SendManyResizeOnce();
2266}
2267
buildbot@webrtc.orgce4201d2014-05-21 16:22:51 +00002268TEST_F(WebRtcVideoMediaChannelTest, DISABLED_SendVp8HdAndReceiveAdaptedVp8Vga) {
henrike@webrtc.org28654cb2013-07-22 21:07:49 +00002269 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002270 channel_->UpdateAspectRatio(1280, 720);
2271 video_capturer_.reset(new cricket::FakeVideoCapturer);
2272 const std::vector<cricket::VideoFormat>* formats =
2273 video_capturer_->GetSupportedFormats();
2274 cricket::VideoFormat capture_format_hd = (*formats)[0];
2275 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(capture_format_hd));
2276 EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get()));
2277
2278 // Capture format HD -> adapt (OnOutputFormatRequest VGA) -> VGA.
2279 cricket::VideoCodec codec(100, "VP8", 1280, 720, 30, 0);
2280 EXPECT_TRUE(SetOneCodec(codec));
2281 codec.width /= 2;
2282 codec.height /= 2;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002283 EXPECT_TRUE(SetSend(true));
2284 EXPECT_TRUE(channel_->SetRender(true));
2285 EXPECT_EQ(0, renderer_.num_rendered_frames());
2286 EXPECT_TRUE(SendFrame());
2287 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
2288}
2289
2290// TODO(juberti): Fix this test to tolerate missing stats.
2291TEST_F(WebRtcVideoMediaChannelTest, DISABLED_GetStats) {
2292 Base::GetStats();
2293}
2294
2295// TODO(juberti): Fix this test to tolerate missing stats.
2296TEST_F(WebRtcVideoMediaChannelTest, DISABLED_GetStatsMultipleRecvStreams) {
2297 Base::GetStatsMultipleRecvStreams();
2298}
2299
2300TEST_F(WebRtcVideoMediaChannelTest, GetStatsMultipleSendStreams) {
2301 Base::GetStatsMultipleSendStreams();
2302}
2303
2304TEST_F(WebRtcVideoMediaChannelTest, SetSendBandwidth) {
2305 Base::SetSendBandwidth();
2306}
2307TEST_F(WebRtcVideoMediaChannelTest, SetSendSsrc) {
2308 Base::SetSendSsrc();
2309}
2310TEST_F(WebRtcVideoMediaChannelTest, SetSendSsrcAfterSetCodecs) {
2311 Base::SetSendSsrcAfterSetCodecs();
2312}
2313
2314TEST_F(WebRtcVideoMediaChannelTest, SetRenderer) {
2315 Base::SetRenderer();
2316}
2317
2318TEST_F(WebRtcVideoMediaChannelTest, AddRemoveRecvStreams) {
2319 Base::AddRemoveRecvStreams();
2320}
2321
2322TEST_F(WebRtcVideoMediaChannelTest, AddRemoveRecvStreamAndRender) {
2323 Base::AddRemoveRecvStreamAndRender();
2324}
2325
2326TEST_F(WebRtcVideoMediaChannelTest, AddRemoveRecvStreamsNoConference) {
2327 Base::AddRemoveRecvStreamsNoConference();
2328}
2329
2330TEST_F(WebRtcVideoMediaChannelTest, AddRemoveSendStreams) {
2331 Base::AddRemoveSendStreams();
2332}
2333
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002334TEST_F(WebRtcVideoMediaChannelTest, SimulateConference) {
2335 Base::SimulateConference();
2336}
2337
2338TEST_F(WebRtcVideoMediaChannelTest, AddRemoveCapturer) {
2339 Base::AddRemoveCapturer();
2340}
2341
2342TEST_F(WebRtcVideoMediaChannelTest, RemoveCapturerWithoutAdd) {
2343 Base::RemoveCapturerWithoutAdd();
2344}
2345
2346TEST_F(WebRtcVideoMediaChannelTest, AddRemoveCapturerMultipleSources) {
2347 Base::AddRemoveCapturerMultipleSources();
2348}
2349
wu@webrtc.orgde305012013-10-31 15:40:38 +00002350// This test verifies DSCP settings are properly applied on video media channel.
2351TEST_F(WebRtcVideoMediaChannelTest, TestSetDscpOptions) {
2352 talk_base::scoped_ptr<cricket::FakeNetworkInterface> network_interface(
2353 new cricket::FakeNetworkInterface);
2354 channel_->SetInterface(network_interface.get());
2355 cricket::VideoOptions options;
2356 options.dscp.Set(true);
2357 EXPECT_TRUE(channel_->SetOptions(options));
2358 EXPECT_EQ(talk_base::DSCP_AF41, network_interface->dscp());
henrika@webrtc.orgaebb1ad2014-01-14 10:00:58 +00002359 // Verify previous value is not modified if dscp option is not set.
2360 cricket::VideoOptions options1;
2361 EXPECT_TRUE(channel_->SetOptions(options1));
2362 EXPECT_EQ(talk_base::DSCP_AF41, network_interface->dscp());
wu@webrtc.orgde305012013-10-31 15:40:38 +00002363 options.dscp.Set(false);
2364 EXPECT_TRUE(channel_->SetOptions(options));
2365 EXPECT_EQ(talk_base::DSCP_DEFAULT, network_interface->dscp());
2366 channel_->SetInterface(NULL);
2367}
2368
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002369
2370TEST_F(WebRtcVideoMediaChannelTest, SetOptionsSucceedsWhenSending) {
2371 cricket::VideoOptions options;
2372 options.conference_mode.Set(true);
2373 EXPECT_TRUE(channel_->SetOptions(options));
2374
2375 // Verify SetOptions returns true on a different options.
2376 cricket::VideoOptions options2;
2377 options2.adapt_input_to_cpu_usage.Set(true);
2378 EXPECT_TRUE(channel_->SetOptions(options2));
2379
2380 // Set send codecs on the channel and start sending.
2381 std::vector<cricket::VideoCodec> codecs;
2382 codecs.push_back(kVP8Codec);
2383 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
2384 EXPECT_TRUE(channel_->SetSend(true));
2385
2386 // Verify SetOptions returns true if channel is already sending.
2387 cricket::VideoOptions options3;
2388 options3.conference_mode.Set(true);
2389 EXPECT_TRUE(channel_->SetOptions(options3));
2390}
2391
2392// Tests empty StreamParams is rejected.
2393TEST_F(WebRtcVideoMediaChannelTest, RejectEmptyStreamParams) {
2394 Base::RejectEmptyStreamParams();
2395}
2396
2397
2398TEST_F(WebRtcVideoMediaChannelTest, AdaptResolution16x10) {
2399 Base::AdaptResolution16x10();
2400}
2401
2402TEST_F(WebRtcVideoMediaChannelTest, AdaptResolution4x3) {
2403 Base::AdaptResolution4x3();
2404}
2405
2406TEST_F(WebRtcVideoMediaChannelTest, MuteStream) {
2407 Base::MuteStream();
2408}
2409
2410TEST_F(WebRtcVideoMediaChannelTest, MultipleSendStreams) {
2411 Base::MultipleSendStreams();
2412}
2413
2414// TODO(juberti): Restore this test once we support sending 0 fps.
2415TEST_F(WebRtcVideoMediaChannelTest, DISABLED_AdaptDropAllFrames) {
2416 Base::AdaptDropAllFrames();
2417}
2418// TODO(juberti): Understand why we get decode errors on this test.
2419TEST_F(WebRtcVideoMediaChannelTest, DISABLED_AdaptFramerate) {
2420 Base::AdaptFramerate();
2421}
2422
2423TEST_F(WebRtcVideoMediaChannelTest, SetSendStreamFormat0x0) {
2424 Base::SetSendStreamFormat0x0();
2425}
2426
2427// TODO(zhurunz): Fix the flakey test.
2428TEST_F(WebRtcVideoMediaChannelTest, DISABLED_SetSendStreamFormat) {
2429 Base::SetSendStreamFormat();
2430}
2431
2432TEST_F(WebRtcVideoMediaChannelTest, TwoStreamsSendAndReceive) {
2433 Base::TwoStreamsSendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30,
2434 0));
2435}
2436
2437TEST_F(WebRtcVideoMediaChannelTest, TwoStreamsReUseFirstStream) {
2438 Base::TwoStreamsReUseFirstStream(cricket::VideoCodec(100, "VP8", 640, 400, 30,
2439 0));
2440}
henrike@webrtc.org704bf9e2014-02-27 17:52:04 +00002441
buildbot@webrtc.org0b3c6c32014-04-17 10:03:57 +00002442TEST_F(WebRtcVideoMediaChannelTest, DISABLED_TwoStreamsSendAndUnsignalledRecv) {
henrike@webrtc.org704bf9e2014-02-27 17:52:04 +00002443 Base::TwoStreamsSendAndUnsignalledRecv(cricket::VideoCodec(100, "VP8", 640,
2444 400, 30, 0));
2445}
2446
henrike@webrtc.org806768a2014-02-27 21:03:09 +00002447TEST_F(WebRtcVideoMediaChannelTest,
henrike@webrtc.org18e59112014-03-14 17:19:38 +00002448 TwoStreamsSendAndFailUnsignalledRecv) {
henrike@webrtc.org806768a2014-02-27 21:03:09 +00002449 webrtc::Trace::set_level_filter(webrtc::kTraceAll);
henrike@webrtc.org704bf9e2014-02-27 17:52:04 +00002450 Base::TwoStreamsSendAndFailUnsignalledRecv(
2451 cricket::VideoCodec(100, "VP8", 640, 400, 30, 0));
2452}
2453
2454TEST_F(WebRtcVideoMediaChannelTest,
henrike@webrtc.org18e59112014-03-14 17:19:38 +00002455 TwoStreamsSendAndFailUnsignalledRecvInOneToOne) {
henrike@webrtc.org704bf9e2014-02-27 17:52:04 +00002456 Base::TwoStreamsSendAndFailUnsignalledRecvInOneToOne(
2457 cricket::VideoCodec(100, "VP8", 640, 400, 30, 0));
2458}
2459
2460TEST_F(WebRtcVideoMediaChannelTest,
henrike@webrtc.org18e59112014-03-14 17:19:38 +00002461 TwoStreamsAddAndRemoveUnsignalledRecv) {
henrike@webrtc.org704bf9e2014-02-27 17:52:04 +00002462 Base::TwoStreamsAddAndRemoveUnsignalledRecv(cricket::VideoCodec(100, "VP8",
2463 640, 400, 30,
2464 0));
2465}