blob: c9ff1829030c56ec5bd1e9cb8e21fa08072a28b1 [file] [log] [blame]
pbos@webrtc.org87e1f972014-05-13 11:07:01 +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 <map>
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +000029#include <vector>
pbos@webrtc.org87e1f972014-05-13 11:07:01 +000030
31#include "talk/base/gunit.h"
32#include "talk/media/base/testutils.h"
33#include "talk/media/base/videoengine_unittest.h"
34#include "talk/media/webrtc/webrtcvideoengine2.h"
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +000035#include "talk/media/webrtc/webrtcvideoengine2_unittest.h"
pbos@webrtc.org87e1f972014-05-13 11:07:01 +000036#include "talk/media/webrtc/webrtcvideochannelfactory.h"
pbos@webrtc.org87e1f972014-05-13 11:07:01 +000037
38namespace {
39static const cricket::VideoCodec kVp8Codec720p(100, "VP8", 1280, 720, 30, 0);
40static const cricket::VideoCodec kVp8Codec360p(100, "VP8", 640, 360, 30, 0);
41static const cricket::VideoCodec kVp8Codec270p(100, "VP8", 480, 270, 30, 0);
42static const cricket::VideoCodec kVp8Codec180p(100, "VP8", 320, 180, 30, 0);
43
44static const cricket::VideoCodec kVp8Codec(100, "VP8", 640, 400, 30, 0);
45static const cricket::VideoCodec kVp9Codec(101, "VP9", 640, 400, 30, 0);
46static const cricket::VideoCodec kRedCodec(116, "red", 0, 0, 0, 0);
47static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec", 0, 0, 0, 0);
48
49static const uint32 kSsrcs1[] = {1};
50static const uint32 kRtxSsrcs1[] = {4};
pbos@webrtc.orgaa775872014-06-13 12:27:38 +000051
52void VerifyCodecHasDefaultFeedbackParams(const cricket::VideoCodec& codec) {
53 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
54 cricket::kRtcpFbParamNack, cricket::kParamValueEmpty)));
55 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
56 cricket::kRtcpFbParamNack, cricket::kRtcpFbNackParamPli)));
57 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
58 cricket::kRtcpFbParamRemb, cricket::kParamValueEmpty)));
59 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
60 cricket::kRtcpFbParamCcm, cricket::kRtcpFbCcmParamFir)));
61}
62
pbos@webrtc.org87e1f972014-05-13 11:07:01 +000063} // namespace
64
65namespace cricket {
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +000066FakeVideoSendStream::FakeVideoSendStream(
67 const webrtc::VideoSendStream::Config& config,
68 const std::vector<webrtc::VideoStream>& video_streams)
69 : sending_(false), config_(config), video_streams_(video_streams) {
70}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +000071
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +000072webrtc::VideoSendStream::Config FakeVideoSendStream::GetConfig() {
73 return config_;
74}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +000075
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +000076std::vector<webrtc::VideoStream> FakeVideoSendStream::GetVideoStreams() {
77 return video_streams_;
78}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +000079
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +000080bool FakeVideoSendStream::IsSending() {
81 return sending_;
82}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +000083
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +000084webrtc::VideoSendStream::Stats FakeVideoSendStream::GetStats() const {
85 return webrtc::VideoSendStream::Stats();
86}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +000087
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +000088bool FakeVideoSendStream::ReconfigureVideoEncoder(
89 const std::vector<webrtc::VideoStream>& streams,
90 const void* encoder_specific) {
91 video_streams_ = streams;
92 return true;
93}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +000094
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +000095webrtc::VideoSendStreamInput* FakeVideoSendStream::Input() {
96 // TODO(pbos): Fix.
97 return NULL;
98}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +000099
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000100void FakeVideoSendStream::Start() {
101 sending_ = true;
102}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000103
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000104void FakeVideoSendStream::Stop() {
105 sending_ = false;
106}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000107
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000108FakeVideoReceiveStream::FakeVideoReceiveStream(
109 const webrtc::VideoReceiveStream::Config& config)
110 : config_(config), receiving_(false) {
111}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000112
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000113webrtc::VideoReceiveStream::Config FakeVideoReceiveStream::GetConfig() {
114 return config_;
115}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000116
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000117webrtc::VideoReceiveStream::Stats FakeVideoReceiveStream::GetStats() const {
118 return webrtc::VideoReceiveStream::Stats();
119}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000120
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000121void FakeVideoReceiveStream::Start() {
122 receiving_ = true;
123}
124void FakeVideoReceiveStream::Stop() {
125 receiving_ = false;
126}
127void FakeVideoReceiveStream::GetCurrentReceiveCodec(webrtc::VideoCodec* codec) {
128}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000129
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000130FakeCall::FakeCall() { SetVideoCodecs(GetDefaultVideoCodecs()); }
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000131
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000132FakeCall::~FakeCall() {
133 EXPECT_EQ(0u, video_send_streams_.size());
134 EXPECT_EQ(0u, video_receive_streams_.size());
135}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000136
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000137void FakeCall::SetVideoCodecs(const std::vector<webrtc::VideoCodec> codecs) {
138 codecs_ = codecs;
139}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000140
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000141std::vector<FakeVideoSendStream*> FakeCall::GetVideoSendStreams() {
142 return video_send_streams_;
143}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000144
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000145std::vector<FakeVideoReceiveStream*> FakeCall::GetVideoReceiveStreams() {
146 return video_receive_streams_;
147}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000148
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000149webrtc::VideoCodec FakeCall::GetEmptyVideoCodec() {
150 webrtc::VideoCodec codec;
151 codec.minBitrate = 300;
152 codec.startBitrate = 800;
153 codec.maxBitrate = 1500;
154 codec.maxFramerate = 10;
155 codec.width = 640;
156 codec.height = 480;
157 codec.qpMax = 56;
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000158
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000159 return codec;
160}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000161
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000162webrtc::VideoCodec FakeCall::GetVideoCodecVp8() {
163 webrtc::VideoCodec vp8_codec = GetEmptyVideoCodec();
164 vp8_codec.codecType = webrtc::kVideoCodecVP8;
165 strcpy(vp8_codec.plName, kVp8Codec.name.c_str());
166 vp8_codec.plType = kVp8Codec.id;
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000167
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000168 return vp8_codec;
169}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000170
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000171webrtc::VideoCodec FakeCall::GetVideoCodecVp9() {
172 webrtc::VideoCodec vp9_codec = GetEmptyVideoCodec();
173 // TODO(pbos): Add a correct codecType when webrtc has one.
174 vp9_codec.codecType = webrtc::kVideoCodecVP8;
175 strcpy(vp9_codec.plName, kVp9Codec.name.c_str());
176 vp9_codec.plType = kVp9Codec.id;
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000177
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000178 return vp9_codec;
179}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000180
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000181std::vector<webrtc::VideoCodec> FakeCall::GetDefaultVideoCodecs() {
182 std::vector<webrtc::VideoCodec> codecs;
183 codecs.push_back(GetVideoCodecVp8());
184 // codecs.push_back(GetVideoCodecVp9());
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000185
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000186 return codecs;
187}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000188
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000189webrtc::VideoSendStream::Config FakeCall::GetDefaultSendConfig() {
190 webrtc::VideoSendStream::Config config;
191 // TODO(pbos): Encoder settings.
192 // config.codec = GetVideoCodecVp8();
193 return config;
194}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000195
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000196webrtc::VideoSendStream* FakeCall::CreateVideoSendStream(
197 const webrtc::VideoSendStream::Config& config,
198 const std::vector<webrtc::VideoStream>& video_streams,
199 const void* encoder_settings) {
200 FakeVideoSendStream* fake_stream =
201 new FakeVideoSendStream(config, video_streams);
202 video_send_streams_.push_back(fake_stream);
203 return fake_stream;
204}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000205
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000206void FakeCall::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) {
207 FakeVideoSendStream* fake_stream =
208 static_cast<FakeVideoSendStream*>(send_stream);
209 for (size_t i = 0; i < video_send_streams_.size(); ++i) {
210 if (video_send_streams_[i] == fake_stream) {
211 delete video_send_streams_[i];
212 video_send_streams_.erase(video_send_streams_.begin() + i);
213 return;
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000214 }
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000215 }
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000216 ADD_FAILURE() << "DestroyVideoSendStream called with unknown paramter.";
217}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000218
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000219webrtc::VideoReceiveStream::Config FakeCall::GetDefaultReceiveConfig() {
220 return webrtc::VideoReceiveStream::Config();
221}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000222
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000223webrtc::VideoReceiveStream* FakeCall::CreateVideoReceiveStream(
224 const webrtc::VideoReceiveStream::Config& config) {
225 video_receive_streams_.push_back(new FakeVideoReceiveStream(config));
226 return video_receive_streams_[video_receive_streams_.size() - 1];
227}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000228
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000229void FakeCall::DestroyVideoReceiveStream(
230 webrtc::VideoReceiveStream* receive_stream) {
231 FakeVideoReceiveStream* fake_stream =
232 static_cast<FakeVideoReceiveStream*>(receive_stream);
233 for (size_t i = 0; i < video_receive_streams_.size(); ++i) {
234 if (video_receive_streams_[i] == fake_stream) {
235 delete video_receive_streams_[i];
236 video_receive_streams_.erase(video_receive_streams_.begin() + i);
237 return;
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000238 }
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000239 }
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000240 ADD_FAILURE() << "DestroyVideoReceiveStream called with unknown paramter.";
241}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000242
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000243webrtc::PacketReceiver* FakeCall::Receiver() {
244 // TODO(pbos): Fix this.
245 return NULL;
246}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000247
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000248uint32_t FakeCall::SendBitrateEstimate() {
249 return 0;
250}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000251
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000252uint32_t FakeCall::ReceiveBitrateEstimate() {
253 return 0;
254}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000255
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000256FakeWebRtcVideoChannel2::FakeWebRtcVideoChannel2(
257 FakeCall* call,
258 WebRtcVideoEngine2* engine,
259 VoiceMediaChannel* voice_channel)
260 : WebRtcVideoChannel2(call, engine, engine->GetVideoEncoderFactory()),
261 fake_call_(call),
262 voice_channel_(voice_channel) {
263}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000264
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000265FakeWebRtcVideoChannel2::~FakeWebRtcVideoChannel2() {
266}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000267
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000268VoiceMediaChannel* FakeWebRtcVideoChannel2::GetVoiceChannel() {
269 return voice_channel_;
270}
271FakeCall* FakeWebRtcVideoChannel2::GetFakeCall() {
272 return fake_call_;
273}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000274
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000275FakeWebRtcVideoChannel2* FakeWebRtcVideoMediaChannelFactory::GetFakeChannel(
276 VideoMediaChannel* channel) {
277 return channel_map_[channel];
278}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000279
pbos@webrtc.org1ef658d2014-06-10 08:53:05 +0000280WebRtcVideoChannel2* FakeWebRtcVideoMediaChannelFactory::Create(
281 WebRtcVideoEngine2* engine,
282 VoiceMediaChannel* voice_channel) {
283 FakeWebRtcVideoChannel2* channel =
284 new FakeWebRtcVideoChannel2(new FakeCall(), engine, voice_channel);
285 channel_map_[channel] = channel;
286 return channel;
287}
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000288
289class WebRtcVideoEngine2Test : public testing::Test {
290 public:
pbos@webrtc.org6bb62902014-06-13 09:34:13 +0000291 WebRtcVideoEngine2Test() : engine_(&factory_) {
292 std::vector<VideoCodec> engine_codecs = engine_.codecs();
293 assert(!engine_codecs.empty());
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000294 bool codec_set = false;
pbos@webrtc.org6bb62902014-06-13 09:34:13 +0000295 for (size_t i = 0; i < engine_codecs.size(); ++i) {
296 if (engine_codecs[i].name == "red") {
297 default_red_codec_ = engine_codecs[i];
298 } else if (engine_codecs[i].name == "ulpfec") {
299 default_ulpfec_codec_ = engine_codecs[i];
300 } else if (engine_codecs[i].name == "rtx") {
301 default_rtx_codec_ = engine_codecs[i];
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000302 } else if (!codec_set) {
pbos@webrtc.org6bb62902014-06-13 09:34:13 +0000303 default_codec_ = engine_codecs[i];
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000304 codec_set = true;
305 }
306 }
307
308 assert(codec_set);
309 }
310
311 protected:
312 FakeWebRtcVideoMediaChannelFactory factory_;
313 WebRtcVideoEngine2 engine_;
314 VideoCodec default_codec_;
315 VideoCodec default_red_codec_;
316 VideoCodec default_ulpfec_codec_;
317 VideoCodec default_rtx_codec_;
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000318};
319
320TEST_F(WebRtcVideoEngine2Test, CreateChannel) {
321 talk_base::scoped_ptr<VideoMediaChannel> channel(engine_.CreateChannel(NULL));
322 ASSERT_TRUE(channel.get() != NULL) << "Could not create channel.";
323 EXPECT_TRUE(factory_.GetFakeChannel(channel.get()) != NULL)
324 << "Channel not created through factory.";
325}
326
327TEST_F(WebRtcVideoEngine2Test, CreateChannelWithVoiceEngine) {
328 VoiceMediaChannel* voice_channel = reinterpret_cast<VoiceMediaChannel*>(0x42);
329 talk_base::scoped_ptr<VideoMediaChannel> channel(
330 engine_.CreateChannel(voice_channel));
331 ASSERT_TRUE(channel.get() != NULL) << "Could not create channel.";
332
333 FakeWebRtcVideoChannel2* fake_channel =
334 factory_.GetFakeChannel(channel.get());
335 ASSERT_TRUE(fake_channel != NULL) << "Channel not created through factory.";
336
337 EXPECT_TRUE(fake_channel->GetVoiceChannel() != NULL)
338 << "VoiceChannel not set.";
339 EXPECT_EQ(voice_channel, fake_channel->GetVoiceChannel())
340 << "Different VoiceChannel set than the provided one.";
341}
342
pbos@webrtc.org2352cb32014-06-13 11:47:28 +0000343TEST_F(WebRtcVideoEngine2Test, FindCodec) {
344 const std::vector<cricket::VideoCodec>& c = engine_.codecs();
345 EXPECT_EQ(4U, c.size());
346
347 cricket::VideoCodec vp8(104, "VP8", 320, 200, 30, 0);
348 EXPECT_TRUE(engine_.FindCodec(vp8));
349
350 cricket::VideoCodec vp8_ci(104, "vp8", 320, 200, 30, 0);
351 EXPECT_TRUE(engine_.FindCodec(vp8));
352
353 cricket::VideoCodec vp8_diff_fr_diff_pref(104, "VP8", 320, 200, 50, 50);
354 EXPECT_TRUE(engine_.FindCodec(vp8_diff_fr_diff_pref));
355
356 cricket::VideoCodec vp8_diff_id(95, "VP8", 320, 200, 30, 0);
357 EXPECT_FALSE(engine_.FindCodec(vp8_diff_id));
358 vp8_diff_id.id = 97;
359 EXPECT_TRUE(engine_.FindCodec(vp8_diff_id));
360
361 cricket::VideoCodec vp8_diff_res(104, "VP8", 320, 111, 30, 0);
362 EXPECT_FALSE(engine_.FindCodec(vp8_diff_res));
363
364 // PeerConnection doesn't negotiate the resolution at this point.
365 // Test that FindCodec can handle the case when width/height is 0.
366 cricket::VideoCodec vp8_zero_res(104, "VP8", 0, 0, 30, 0);
367 EXPECT_TRUE(engine_.FindCodec(vp8_zero_res));
368
369 cricket::VideoCodec red(101, "RED", 0, 0, 30, 0);
370 EXPECT_TRUE(engine_.FindCodec(red));
371
372 cricket::VideoCodec red_ci(101, "red", 0, 0, 30, 0);
373 EXPECT_TRUE(engine_.FindCodec(red));
374
375 cricket::VideoCodec fec(102, "ULPFEC", 0, 0, 30, 0);
376 EXPECT_TRUE(engine_.FindCodec(fec));
377
378 cricket::VideoCodec fec_ci(102, "ulpfec", 0, 0, 30, 0);
379 EXPECT_TRUE(engine_.FindCodec(fec));
380
381 cricket::VideoCodec rtx(96, "rtx", 0, 0, 30, 0);
382 EXPECT_TRUE(engine_.FindCodec(rtx));
383}
384
385TEST_F(WebRtcVideoEngine2Test, DefaultRtxCodecHasAssociatedPayloadTypeSet) {
386 std::vector<VideoCodec> engine_codecs = engine_.codecs();
387 for (size_t i = 0; i < engine_codecs.size(); ++i) {
388 if (engine_codecs[i].name != kRtxCodecName)
389 continue;
390 int associated_payload_type;
391 EXPECT_TRUE(engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType,
392 &associated_payload_type));
393 EXPECT_EQ(default_codec_.id, associated_payload_type);
394 return;
395 }
396 FAIL() << "No RTX codec found among default codecs.";
397}
398
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000399class WebRtcVideoChannel2BaseTest
400 : public VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> {
401 protected:
402 virtual cricket::VideoCodec DefaultCodec() OVERRIDE { return kVp8Codec; }
403 typedef VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> Base;
404};
405
406// TODO(pbos): Fix WebRtcVideoEngine2BaseTest, where we want CheckCoInitialize.
407#if 0
408// TODO(juberti): Figure out why ViE is munging the COM refcount.
409#ifdef WIN32
410TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_CheckCoInitialize) {
411 Base::CheckCoInitialize();
412}
413#endif
414#endif
415
416TEST_F(WebRtcVideoChannel2BaseTest, SetSend) { Base::SetSend(); }
417
418TEST_F(WebRtcVideoChannel2BaseTest, SetSendWithoutCodecs) {
419 Base::SetSendWithoutCodecs();
420}
421
422TEST_F(WebRtcVideoChannel2BaseTest, SetSendSetsTransportBufferSizes) {
423 Base::SetSendSetsTransportBufferSizes();
424}
425
426// TODO(juberti): Fix this test to tolerate missing stats.
427TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_GetStats) { Base::GetStats(); }
428
429// TODO(juberti): Fix this test to tolerate missing stats.
430TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_GetStatsMultipleRecvStreams) {
431 Base::GetStatsMultipleRecvStreams();
432}
433
434TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_GetStatsMultipleSendStreams) {
435 Base::GetStatsMultipleSendStreams();
436}
437
438TEST_F(WebRtcVideoChannel2BaseTest, SetSendBandwidth) {
439 Base::SetSendBandwidth();
440}
441TEST_F(WebRtcVideoChannel2BaseTest, SetSendSsrc) { Base::SetSendSsrc(); }
442TEST_F(WebRtcVideoChannel2BaseTest, SetSendSsrcAfterSetCodecs) {
443 Base::SetSendSsrcAfterSetCodecs();
444}
445
446TEST_F(WebRtcVideoChannel2BaseTest, SetRenderer) { Base::SetRenderer(); }
447
448TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveRecvStreams) {
449 Base::AddRemoveRecvStreams();
450}
451
452TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_AddRemoveRecvStreamAndRender) {
453 Base::AddRemoveRecvStreamAndRender();
454}
455
456TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveRecvStreamsNoConference) {
457 Base::AddRemoveRecvStreamsNoConference();
458}
459
460TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveSendStreams) {
461 Base::AddRemoveSendStreams();
462}
463
464TEST_F(WebRtcVideoChannel2BaseTest, SimulateConference) {
465 Base::SimulateConference();
466}
467
468TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveCapturer) {
469 Base::AddRemoveCapturer();
470}
471
472TEST_F(WebRtcVideoChannel2BaseTest, RemoveCapturerWithoutAdd) {
473 Base::RemoveCapturerWithoutAdd();
474}
475
476TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveCapturerMultipleSources) {
477 Base::AddRemoveCapturerMultipleSources();
478}
479
480// TODO(pbos): Figure out why this fails so often.
481TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_HighAspectHighHeightCapturer) {
482 Base::HighAspectHighHeightCapturer();
483}
484
485TEST_F(WebRtcVideoChannel2BaseTest, RejectEmptyStreamParams) {
486 Base::RejectEmptyStreamParams();
487}
488
489TEST_F(WebRtcVideoChannel2BaseTest, AdaptResolution16x10) {
490 Base::AdaptResolution16x10();
491}
492
493TEST_F(WebRtcVideoChannel2BaseTest, AdaptResolution4x3) {
494 Base::AdaptResolution4x3();
495}
496
497TEST_F(WebRtcVideoChannel2BaseTest, MuteStream) { Base::MuteStream(); }
498
499TEST_F(WebRtcVideoChannel2BaseTest, MultipleSendStreams) {
500 Base::MultipleSendStreams();
501}
502
503// TODO(juberti): Restore this test once we support sending 0 fps.
504TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_AdaptDropAllFrames) {
505 Base::AdaptDropAllFrames();
506}
507// TODO(juberti): Understand why we get decode errors on this test.
508TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_AdaptFramerate) {
509 Base::AdaptFramerate();
510}
511
512TEST_F(WebRtcVideoChannel2BaseTest, SetSendStreamFormat0x0) {
513 Base::SetSendStreamFormat0x0();
514}
515
516// TODO(zhurunz): Fix the flakey test.
517TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_SetSendStreamFormat) {
518 Base::SetSendStreamFormat();
519}
520
521TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsSendAndReceive) {
522 Base::TwoStreamsSendAndReceive(kVp8Codec);
523}
524
525TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsReUseFirstStream) {
526 Base::TwoStreamsReUseFirstStream(kVp8Codec);
527}
528
529class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test {
530 public:
531 virtual void SetUp() OVERRIDE {
532 channel_.reset(engine_.CreateChannel(NULL));
533 fake_channel_ = factory_.GetFakeChannel(channel_.get());
534 last_ssrc_ = 123;
535 ASSERT_TRUE(fake_channel_ != NULL)
536 << "Channel not created through factory.";
537 }
538
539 protected:
540 FakeVideoSendStream* AddSendStream() {
541 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++));
542 }
543
544 FakeVideoSendStream* AddSendStream(const StreamParams& sp) {
545 size_t num_streams =
546 fake_channel_->GetFakeCall()->GetVideoSendStreams().size();
547 EXPECT_TRUE(channel_->AddSendStream(sp));
548 std::vector<FakeVideoSendStream*> streams =
549 fake_channel_->GetFakeCall()->GetVideoSendStreams();
550 EXPECT_EQ(num_streams + 1, streams.size());
551 return streams[streams.size() - 1];
552 }
553
554 std::vector<FakeVideoSendStream*> GetFakeSendStreams() {
555 return fake_channel_->GetFakeCall()->GetVideoSendStreams();
556 }
557
558 FakeVideoReceiveStream* AddRecvStream() {
559 return AddRecvStream(StreamParams::CreateLegacy(last_ssrc_++));
560 }
561
562 FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) {
563 size_t num_streams =
564 fake_channel_->GetFakeCall()->GetVideoReceiveStreams().size();
565 EXPECT_TRUE(channel_->AddRecvStream(sp));
566 std::vector<FakeVideoReceiveStream*> streams =
567 fake_channel_->GetFakeCall()->GetVideoReceiveStreams();
568 EXPECT_EQ(num_streams + 1, streams.size());
569 return streams[streams.size() - 1];
570 }
571
572 void SetSendCodecsShouldWorkForBitrates(const char* min_bitrate,
573 const char* max_bitrate) {
574 std::vector<VideoCodec> codecs;
575 codecs.push_back(kVp8Codec);
576 codecs[0].params[kCodecParamMinBitrate] = min_bitrate;
577 codecs[0].params[kCodecParamMaxBitrate] = max_bitrate;
578 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
579
580 FakeVideoSendStream* stream = AddSendStream();
581
pbos@webrtc.org72544872014-06-06 10:49:19 +0000582 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams();
583 ASSERT_EQ(1u, video_streams.size());
584 EXPECT_EQ(atoi(min_bitrate), video_streams.back().min_bitrate_bps / 1000);
585 EXPECT_EQ(atoi(max_bitrate), video_streams.back().max_bitrate_bps / 1000);
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000586
587 VideoCodec codec;
588 EXPECT_TRUE(channel_->GetSendCodec(&codec));
589 EXPECT_EQ(min_bitrate, codec.params[kCodecParamMinBitrate]);
590 EXPECT_EQ(max_bitrate, codec.params[kCodecParamMaxBitrate]);
591 }
592
593 void ExpectEqualCodecs(const VideoCodec video_codec,
594 const webrtc::VideoCodec& webrtc_codec) {
595 EXPECT_STREQ(video_codec.name.c_str(), webrtc_codec.plName);
596 EXPECT_EQ(video_codec.id, webrtc_codec.plType);
597 EXPECT_EQ(video_codec.width, webrtc_codec.width);
598 EXPECT_EQ(video_codec.height, webrtc_codec.height);
599 EXPECT_EQ(video_codec.framerate, webrtc_codec.maxFramerate);
600 }
601 talk_base::scoped_ptr<VideoMediaChannel> channel_;
602 FakeWebRtcVideoChannel2* fake_channel_;
603 uint32 last_ssrc_;
604};
605
606TEST_F(WebRtcVideoChannel2Test, DISABLED_MaxBitrateResetsWithConferenceMode) {
607 FAIL() << "Not implemented."; // TODO(pbos): Implement.
608}
609
610TEST_F(WebRtcVideoChannel2Test, DISABLED_StartSendBitrate) {
611 // TODO(pbos): Is this test testing vie_ ? this is confusing. No API to set
612 // start send bitrate from outside? Add defaults here that should be kept?
613 std::vector<cricket::VideoCodec> codec_list;
614 codec_list.push_back(kVp8Codec);
615 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
616 const unsigned int kVideoMinSendBitrateKbps = 50;
617 const unsigned int kVideoTargetSendBitrateKbps = 300;
618 const unsigned int kVideoMaxSendBitrateKbps = 2000;
619 FakeVideoSendStream* stream = AddSendStream();
pbos@webrtc.org72544872014-06-06 10:49:19 +0000620 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams();
621 ASSERT_EQ(1u, video_streams.size());
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000622 EXPECT_EQ(kVideoMinSendBitrateKbps,
pbos@webrtc.org72544872014-06-06 10:49:19 +0000623 video_streams.back().min_bitrate_bps / 1000);
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000624 EXPECT_EQ(kVideoTargetSendBitrateKbps,
pbos@webrtc.org72544872014-06-06 10:49:19 +0000625 video_streams.back().target_bitrate_bps / 1000);
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000626 EXPECT_EQ(kVideoMaxSendBitrateKbps,
pbos@webrtc.org72544872014-06-06 10:49:19 +0000627 video_streams.back().max_bitrate_bps / 1000);
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000628#if 0
629 // TODO(pbos): un-#if
630 VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
631 kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
632 kVideoDefaultStartSendBitrateKbps);
633 EXPECT_EQ(0, vie_.StartSend(send_channel));
634
635 // Increase the send bitrate and verify it is used as start bitrate.
636 const unsigned int kVideoSendBitrateBps = 768000;
637 vie_.SetSendBitrates(send_channel, kVideoSendBitrateBps, 0, 0);
638 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
639 VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
640 kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
641 kVideoSendBitrateBps / 1000);
642
643 // Never set a start bitrate higher than the max bitrate.
644 vie_.SetSendBitrates(send_channel, kVideoMaxSendBitrateKbps + 500, 0, 0);
645 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
646 VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
647 kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
648 kVideoDefaultStartSendBitrateKbps);
649
650 // Use the default start bitrate if the send bitrate is lower.
651 vie_.SetSendBitrates(send_channel, kVideoDefaultStartSendBitrateKbps - 50, 0,
652 0);
653 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
654 VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
655 kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
656 kVideoDefaultStartSendBitrateKbps);
657#endif
658}
659
660TEST_F(WebRtcVideoChannel2Test, DISABLED_RtcpEnabled) {
661 // Note(pbos): This is a receiver-side setting, dumbo.
662 FAIL() << "Not implemented."; // TODO(pbos): Implement.
663}
664
665TEST_F(WebRtcVideoChannel2Test, DISABLED_KeyFrameRequestEnabled) {
666 FAIL() << "Not implemented."; // TODO(pbos): Implement.
667}
668
669TEST_F(WebRtcVideoChannel2Test, RembIsEnabledByDefault) {
670 FakeVideoReceiveStream* stream = AddRecvStream();
671 EXPECT_TRUE(stream->GetConfig().rtp.remb);
672}
673
674TEST_F(WebRtcVideoChannel2Test, DISABLED_RembEnabledOnReceiveChannels) {
675 FAIL() << "Not implemented."; // TODO(pbos): Implement.
676}
677
pbos@webrtc.org2352cb32014-06-13 11:47:28 +0000678TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) {
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000679 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
680 EXPECT_TRUE(channel_->SetSend(true));
681 cricket::VideoOptions options;
682 options.conference_mode.Set(true);
683 EXPECT_TRUE(channel_->SetOptions(options));
684
685 // Send side.
686 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1);
687 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1);
688 FakeVideoSendStream* send_stream = AddSendStream(
689 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
690
691 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size());
692 for (size_t i = 0; i < rtx_ssrcs.size(); ++i)
693 EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]);
694
695 // Receiver side.
696 FakeVideoReceiveStream* recv_stream = AddRecvStream(
697 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
698 ASSERT_GT(recv_stream->GetConfig().rtp.rtx.size(), 0u)
699 << "No SSRCs for RTX configured by AddRecvStream.";
700 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.rtx.size())
701 << "This test only works with one receive codec. Please update the test.";
702 EXPECT_EQ(rtx_ssrcs[0],
703 recv_stream->GetConfig().rtp.rtx.begin()->second.ssrc);
704 // TODO(pbos): Make sure we set the RTX for correct payloads etc.
705}
706
pbos@webrtc.org2352cb32014-06-13 11:47:28 +0000707TEST_F(WebRtcVideoChannel2Test, RecvStreamWithRtx) {
708 // Setup one channel with an associated RTX stream.
709 cricket::StreamParams params =
710 cricket::StreamParams::CreateLegacy(kSsrcs1[0]);
711 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]);
712 FakeVideoReceiveStream* recv_stream = AddRecvStream(params);
713 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.rtx.size());
714 EXPECT_EQ(kRtxSsrcs1[0],
715 recv_stream->GetConfig().rtp.rtx.begin()->second.ssrc);
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000716}
717
pbos@webrtc.org2352cb32014-06-13 11:47:28 +0000718TEST_F(WebRtcVideoChannel2Test, RecvStreamNoRtx) {
719 // Setup one channel without an associated RTX stream.
720 cricket::StreamParams params =
721 cricket::StreamParams::CreateLegacy(kSsrcs1[0]);
722 FakeVideoReceiveStream* recv_stream = AddRecvStream(params);
723 ASSERT_TRUE(recv_stream->GetConfig().rtp.rtx.empty());
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000724}
725
726TEST_F(WebRtcVideoChannel2Test, DISABLED_RtpTimestampOffsetHeaderExtensions) {
727 FAIL() << "Not implemented."; // TODO(pbos): Implement.
728}
729
730TEST_F(WebRtcVideoChannel2Test, DISABLED_AbsoluteSendTimeHeaderExtensions) {
731 FAIL() << "Not implemented."; // TODO(pbos): Implement.
732}
733
734TEST_F(WebRtcVideoChannel2Test, DISABLED_LeakyBucketTest) {
735 FAIL() << "Not implemented."; // TODO(pbos): Implement.
736}
737
738TEST_F(WebRtcVideoChannel2Test, DISABLED_BufferedModeLatency) {
739 FAIL() << "Not implemented."; // TODO(pbos): Implement.
740}
741
742TEST_F(WebRtcVideoChannel2Test, DISABLED_AdditiveVideoOptions) {
743 FAIL() << "Not implemented."; // TODO(pbos): Implement.
744}
745
746TEST_F(WebRtcVideoChannel2Test, AddRecvStreamOnlyUsesOneReceiveStream) {
747 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
748 EXPECT_EQ(1u, fake_channel_->GetFakeCall()->GetVideoReceiveStreams().size());
749}
750
751TEST_F(WebRtcVideoChannel2Test, DISABLED_NoRembChangeAfterAddRecvStream) {
752 FAIL() << "Not implemented."; // TODO(pbos): Implement.
753}
754
755TEST_F(WebRtcVideoChannel2Test, DISABLED_RembOnOff) {
756 FAIL() << "Not implemented."; // TODO(pbos): Implement.
757}
758
pbos@webrtc.orgaa775872014-06-13 12:27:38 +0000759TEST_F(WebRtcVideoChannel2Test, NackIsEnabledByDefault) {
760 VerifyCodecHasDefaultFeedbackParams(default_codec_);
761
pbos@webrtc.org84f5e342014-05-30 07:35:47 +0000762 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
763 EXPECT_TRUE(channel_->SetSend(true));
764
765 // Send side.
766 FakeVideoSendStream* send_stream =
767 AddSendStream(cricket::StreamParams::CreateLegacy(1));
768 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0);
769
770 // Receiver side.
771 FakeVideoReceiveStream* recv_stream =
772 AddRecvStream(cricket::StreamParams::CreateLegacy(1));
773 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0);
774
775 // Nack history size should match between sender and receiver.
776 EXPECT_EQ(send_stream->GetConfig().rtp.nack.rtp_history_ms,
777 recv_stream->GetConfig().rtp.nack.rtp_history_ms);
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000778}
779
pbos@webrtc.orgaa775872014-06-13 12:27:38 +0000780TEST_F(WebRtcVideoChannel2Test, NackCanBeDisabled) {
781 std::vector<VideoCodec> codecs;
782 codecs.push_back(kVp8Codec);
783
784 // Send side.
785 ASSERT_TRUE(channel_->SetSendCodecs(codecs));
786 FakeVideoSendStream* send_stream =
787 AddSendStream(cricket::StreamParams::CreateLegacy(1));
788 EXPECT_EQ(0, send_stream->GetConfig().rtp.nack.rtp_history_ms);
789
790 // Receiver side.
791 ASSERT_TRUE(channel_->SetRecvCodecs(codecs));
792 FakeVideoReceiveStream* recv_stream =
793 AddRecvStream(cricket::StreamParams::CreateLegacy(1));
794 EXPECT_EQ(0, recv_stream->GetConfig().rtp.nack.rtp_history_ms);
795}
796
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000797TEST_F(WebRtcVideoChannel2Test, DISABLED_VideoProtectionInterop) {
798 FAIL() << "Not implemented."; // TODO(pbos): Implement.
799}
800
801TEST_F(WebRtcVideoChannel2Test, DISABLED_VideoProtectionInteropReversed) {
802 FAIL() << "Not implemented."; // TODO(pbos): Implement.
803}
804
805TEST_F(WebRtcVideoChannel2Test, DISABLED_HybridNackFecConference) {
806 FAIL() << "Not implemented."; // TODO(pbos): Implement.
807}
808
809TEST_F(WebRtcVideoChannel2Test, DISABLED_AddRemoveRecvStreamConference) {
810 FAIL() << "Not implemented."; // TODO(pbos): Implement.
811}
812
813TEST_F(WebRtcVideoChannel2Test, DISABLED_SetRender) {
814 FAIL() << "Not implemented."; // TODO(pbos): Implement.
815}
816
817TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthAuto) {
818 FAIL() << "Not implemented."; // TODO(pbos): Implement.
819}
820
821TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthAutoCapped) {
822 FAIL() << "Not implemented."; // TODO(pbos): Implement.
823}
824
825TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthFixed) {
826 FAIL() << "Not implemented."; // TODO(pbos): Implement.
827}
828
829TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthInConference) {
830 FAIL() << "Not implemented."; // TODO(pbos): Implement.
831}
832
833TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthScreencast) {
834 FAIL() << "Not implemented."; // TODO(pbos): Implement.
835}
836
837TEST_F(WebRtcVideoChannel2Test, DISABLED_SetSendSsrcAndCname) {
838 FAIL() << "Not implemented."; // TODO(pbos): Implement.
839}
840
841TEST_F(WebRtcVideoChannel2Test,
842 DISABLED_SetSendSsrcAfterCreatingReceiveChannel) {
843 FAIL() << "Not implemented."; // TODO(pbos): Implement.
844}
845
846TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsWithDenoising) {
847 FAIL() << "Not implemented."; // TODO(pbos): Implement.
848}
849
850TEST_F(WebRtcVideoChannel2Test, DISABLED_MultipleSendStreamsWithOneCapturer) {
851 FAIL() << "Not implemented."; // TODO(pbos): Implement.
852}
853
854TEST_F(WebRtcVideoChannel2Test, DISABLED_DISABLED_SendReceiveBitratesStats) {
855 FAIL() << "Not implemented."; // TODO(pbos): Implement.
856}
857
858TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetAdaptInputToCpuUsage) {
859 FAIL() << "Not implemented."; // TODO(pbos): Implement.
860}
861
862TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetCpuThreshold) {
863 FAIL() << "Not implemented."; // TODO(pbos): Implement.
864}
865
866TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetInvalidCpuThreshold) {
867 FAIL() << "Not implemented."; // TODO(pbos): Implement.
868}
869
870TEST_F(WebRtcVideoChannel2Test, DISABLED_WebRtcShouldLog) {
871 FAIL() << "Not implemented."; // TODO(pbos): Implement.
872}
873
874TEST_F(WebRtcVideoChannel2Test, DISABLED_WebRtcShouldNotLog) {
875 FAIL() << "Not implemented."; // TODO(pbos): Implement.
876}
877
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000878TEST_F(WebRtcVideoChannel2Test, SetDefaultSendCodecs) {
pbos@webrtc.org6bb62902014-06-13 09:34:13 +0000879 ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000880
881 VideoCodec codec;
882 EXPECT_TRUE(channel_->GetSendCodec(&codec));
pbos@webrtc.org6bb62902014-06-13 09:34:13 +0000883 EXPECT_TRUE(codec.Matches(engine_.codecs()[0]));
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000884
885 // Using a RTX setup to verify that the default RTX payload type is good.
886 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1);
887 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1);
888 FakeVideoSendStream* stream = AddSendStream(
889 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
890 webrtc::VideoSendStream::Config config = stream->GetConfig();
891 // TODO(pbos): Replace ExpectEqualCodecs.
pbos@webrtc.org6bb62902014-06-13 09:34:13 +0000892 // ExpectEqualCodecs(engine_.codecs()[0], config.codec);
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000893
894 // Make sure NACK and FEC are enabled on the correct payload types.
895 EXPECT_EQ(1000, config.rtp.nack.rtp_history_ms);
896 EXPECT_EQ(default_ulpfec_codec_.id, config.rtp.fec.ulpfec_payload_type);
897 EXPECT_EQ(default_red_codec_.id, config.rtp.fec.red_payload_type);
898 // TODO(pbos): Verify that the rtx ssrc is set, correct, not taken by anything
899 // else.
900 // ASSERT_EQ(1u, config.rtp.rtx.ssrcs.size());
901 EXPECT_EQ(static_cast<int>(default_rtx_codec_.id),
902 config.rtp.rtx.payload_type);
903 // TODO(juberti): Check RTCP, PLI, TMMBR.
904}
905
906TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) {
907 std::vector<VideoCodec> codecs;
908 codecs.push_back(kVp8Codec);
909 ASSERT_TRUE(channel_->SetSendCodecs(codecs));
910
911 FakeVideoSendStream* stream = AddSendStream();
912 webrtc::VideoSendStream::Config config = stream->GetConfig();
913
914 EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type);
915 EXPECT_EQ(-1, config.rtp.fec.red_payload_type);
916}
917
918TEST_F(WebRtcVideoChannel2Test,
919 DISABLED_SetSendCodecRejectsRtxWithoutAssociatedPayloadType) {
920 FAIL() << "Not implemented."; // TODO(pbos): Implement.
921}
922
923TEST_F(WebRtcVideoChannel2Test,
924 DISABLED_SetSendCodecRejectsRtxWithoutMatchingVideoCodec) {
925 FAIL() << "Not implemented."; // TODO(pbos): Implement.
926}
927
928TEST_F(WebRtcVideoChannel2Test,
929 DISABLED_SetCodecsWithoutFecDisablesCurrentFec) {
930 FAIL() << "Not implemented."; // TODO(pbos): Implement.
931}
932
933TEST_F(WebRtcVideoChannel2Test, DISABLED_SetSendCodecsChangesExistingStreams) {
934 FAIL(); // TODO(pbos): Implement, make sure that it's changing running
935 // streams. Should it?
936}
937
938TEST_F(WebRtcVideoChannel2Test,
939 DISABLED_ConstrainsSetCodecsAccordingToEncoderConfig) {
940 FAIL() << "Not implemented."; // TODO(pbos): Implement.
941}
942
943TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMinMaxBitrate) {
944 SetSendCodecsShouldWorkForBitrates("10", "20");
945}
946
947TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) {
pbos@webrtc.org6bb62902014-06-13 09:34:13 +0000948 std::vector<VideoCodec> video_codecs = engine_.codecs();
949 video_codecs[0].params[kCodecParamMinBitrate] = "30";
950 video_codecs[0].params[kCodecParamMaxBitrate] = "20";
951 EXPECT_FALSE(channel_->SetSendCodecs(video_codecs));
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000952}
953
954TEST_F(WebRtcVideoChannel2Test, SetSendCodecsAcceptLargeMinMaxBitrate) {
955 SetSendCodecsShouldWorkForBitrates("1000", "2000");
956}
957
958TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) {
959 static const char* kMaxQuantization = "21";
960 std::vector<VideoCodec> codecs;
961 codecs.push_back(kVp8Codec);
962 codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization;
963 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
pbos@webrtc.org72544872014-06-06 10:49:19 +0000964 EXPECT_EQ(static_cast<unsigned int>(atoi(kMaxQuantization)),
965 AddSendStream()->GetVideoStreams().back().max_qp);
pbos@webrtc.org87e1f972014-05-13 11:07:01 +0000966
967 VideoCodec codec;
968 EXPECT_TRUE(channel_->GetSendCodec(&codec));
969 EXPECT_EQ(kMaxQuantization, codec.params[kCodecParamMaxQuantization]);
970}
971
972TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadDimensions) {
973 std::vector<cricket::VideoCodec> codecs;
974 codecs.push_back(kVp8Codec);
975
976 codecs[0].width = 0;
977 EXPECT_FALSE(channel_->SetSendCodecs(codecs))
978 << "Codec set though codec width is zero.";
979
980 codecs[0].width = kVp8Codec.width;
981 codecs[0].height = 0;
982 EXPECT_FALSE(channel_->SetSendCodecs(codecs))
983 << "Codec set though codec height is zero.";
984}
985
986TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadPayloadTypes) {
987 // TODO(pbos): Should we only allow the dynamic range?
988 static const size_t kNumIncorrectPayloads = 4;
989 static const int kIncorrectPayloads[kNumIncorrectPayloads] = {-2, -1, 128,
990 129};
991 std::vector<cricket::VideoCodec> codecs;
992 codecs.push_back(kVp8Codec);
993 for (size_t i = 0; i < kNumIncorrectPayloads; ++i) {
994 int payload_type = kIncorrectPayloads[i];
995 codecs[0].id = payload_type;
996 EXPECT_FALSE(channel_->SetSendCodecs(codecs))
997 << "Bad payload type '" << payload_type << "' accepted.";
998 }
999}
1000
1001TEST_F(WebRtcVideoChannel2Test, SetSendCodecsAcceptAllValidPayloadTypes) {
1002 std::vector<cricket::VideoCodec> codecs;
1003 codecs.push_back(kVp8Codec);
1004 for (int payload_type = 0; payload_type <= 127; ++payload_type) {
1005 codecs[0].id = payload_type;
1006 EXPECT_TRUE(channel_->SetSendCodecs(codecs))
1007 << "Payload type '" << payload_type << "' rejected.";
1008 }
1009}
1010
1011TEST_F(WebRtcVideoChannel2Test, DISABLED_ResetVieSendCodecOnNewFrameSize) {
1012 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1013}
1014
1015TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) {
1016 std::vector<cricket::VideoCodec> codecs;
1017 codecs.push_back(kVp8Codec);
1018 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1019}
1020
pbos@webrtc.org2352cb32014-06-13 11:47:28 +00001021// Test that we set our inbound RTX codecs properly.
1022TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) {
1023 std::vector<cricket::VideoCodec> codecs;
1024 codecs.push_back(kVp8Codec);
1025 cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0);
1026 codecs.push_back(rtx_codec);
1027 EXPECT_FALSE(channel_->SetRecvCodecs(codecs))
1028 << "RTX codec without associated payload should be rejected.";
1029
1030 codecs[1].SetParam("apt", kVp8Codec.id + 1);
1031 EXPECT_FALSE(channel_->SetRecvCodecs(codecs))
1032 << "RTX codec with invalid associated payload type should be rejected.";
1033
1034 codecs[1].SetParam("apt", kVp8Codec.id);
1035 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1036
1037 cricket::VideoCodec rtx_codec2(97, "rtx", 0, 0, 0, 0);
1038 rtx_codec2.SetParam("apt", rtx_codec.id);
1039 codecs.push_back(rtx_codec2);
1040
1041 EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) << "RTX codec with another RTX "
1042 "as associated payload type "
1043 "should be rejected.";
1044}
1045
pbos@webrtc.org87e1f972014-05-13 11:07:01 +00001046TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentPayloadType) {
1047 std::vector<cricket::VideoCodec> codecs;
1048 codecs.push_back(kVp8Codec);
1049 codecs[0].id = 99;
1050 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1051}
1052
1053TEST_F(WebRtcVideoChannel2Test, DISABLED_SetRecvCodecsAcceptDefaultCodecs) {
1054 EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs()));
1055 // (I've added this one.) Make sure they propagate down to VideoReceiveStream!
1056 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1057}
1058
1059TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) {
1060 std::vector<VideoCodec> codecs;
1061 codecs.push_back(kVp8Codec);
1062 codecs.push_back(VideoCodec(101, "WTF3", 640, 400, 30, 0));
1063 EXPECT_FALSE(channel_->SetRecvCodecs(codecs));
1064}
1065
1066// TODO(pbos): Enable VP9 through external codec support
1067TEST_F(WebRtcVideoChannel2Test,
1068 DISABLED_SetRecvCodecsAcceptsMultipleVideoCodecs) {
1069 std::vector<VideoCodec> codecs;
1070 codecs.push_back(kVp8Codec);
1071 codecs.push_back(kVp9Codec);
1072 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1073}
1074
1075TEST_F(WebRtcVideoChannel2Test,
1076 DISABLED_SetRecvCodecsSetsFecForAllVideoCodecs) {
1077 std::vector<VideoCodec> codecs;
1078 codecs.push_back(kVp8Codec);
1079 codecs.push_back(kVp9Codec);
1080 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1081 FAIL(); // TODO(pbos): Verify that the FEC parameters are set for all codecs.
1082}
1083
1084TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectDuplicateFecPayloads) {
1085 std::vector<VideoCodec> codecs;
1086 codecs.push_back(kVp8Codec);
1087 codecs.push_back(kRedCodec);
1088 codecs[1].id = codecs[0].id;
1089 EXPECT_FALSE(channel_->SetRecvCodecs(codecs));
1090}
1091
1092TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectDuplicateCodecPayloads) {
1093 std::vector<VideoCodec> codecs;
1094 codecs.push_back(kVp8Codec);
1095 codecs.push_back(kVp9Codec);
1096 codecs[1].id = codecs[0].id;
1097 EXPECT_FALSE(channel_->SetRecvCodecs(codecs));
1098}
1099
1100TEST_F(WebRtcVideoChannel2Test,
1101 SetRecvCodecsAcceptSameCodecOnMultiplePayloadTypes) {
1102 std::vector<VideoCodec> codecs;
1103 codecs.push_back(kVp8Codec);
1104 codecs.push_back(kVp8Codec);
1105 codecs[1].id += 1;
1106 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1107}
1108
1109TEST_F(WebRtcVideoChannel2Test, SendStreamNotSendingByDefault) {
1110 EXPECT_FALSE(AddSendStream()->IsSending());
1111}
1112
1113TEST_F(WebRtcVideoChannel2Test, DISABLED_ReceiveStreamReceivingByDefault) {
1114 // Is this test correct though? Auto-receive? Enable receive on first packet?
1115 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1116}
1117
1118TEST_F(WebRtcVideoChannel2Test, SetSend) {
1119 AddSendStream();
1120 EXPECT_FALSE(channel_->SetSend(true))
1121 << "Channel should not start without codecs.";
1122 EXPECT_TRUE(channel_->SetSend(false))
1123 << "Channel should be stoppable even without set codecs.";
1124
1125 std::vector<cricket::VideoCodec> codecs;
1126 codecs.push_back(kVp8Codec);
1127 channel_->SetSendCodecs(codecs);
1128 std::vector<FakeVideoSendStream*> streams = GetFakeSendStreams();
1129 ASSERT_EQ(1u, streams.size());
1130 FakeVideoSendStream* stream = streams.back();
1131
1132 EXPECT_FALSE(stream->IsSending());
1133
1134 // false->true
1135 EXPECT_TRUE(channel_->SetSend(true));
1136 EXPECT_TRUE(stream->IsSending());
1137 // true->true
1138 EXPECT_TRUE(channel_->SetSend(true));
1139 EXPECT_TRUE(stream->IsSending());
1140 // true->false
1141 EXPECT_TRUE(channel_->SetSend(false));
1142 EXPECT_FALSE(stream->IsSending());
1143 // false->false
1144 EXPECT_TRUE(channel_->SetSend(false));
1145 EXPECT_FALSE(stream->IsSending());
1146
1147 EXPECT_TRUE(channel_->SetSend(true));
1148 FakeVideoSendStream* new_stream = AddSendStream();
1149 EXPECT_TRUE(new_stream->IsSending())
1150 << "Send stream created after SetSend(true) not sending initially.";
1151}
1152
1153TEST_F(WebRtcVideoChannel2Test, DISABLED_SendAndReceiveVp8Vga) {
1154 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1155}
1156
1157TEST_F(WebRtcVideoChannel2Test, DISABLED_SendAndReceiveVp8Qvga) {
1158 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1159}
1160
1161TEST_F(WebRtcVideoChannel2Test, DISABLED_SendAndReceiveH264SvcQqvga) {
1162 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1163}
1164
1165TEST_F(WebRtcVideoChannel2Test, DISABLED_SendManyResizeOnce) {
1166 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1167}
1168
1169TEST_F(WebRtcVideoChannel2Test, DISABLED_SendVp8HdAndReceiveAdaptedVp8Vga) {
1170 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1171}
1172
1173TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetDscpOptions) {
1174 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1175}
1176
1177TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsWithMaxBitrate) {
1178 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1179}
1180
1181TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsWithLoweredBitrate) {
1182 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1183}
1184
1185TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsSucceedsWhenSending) {
1186 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1187}
1188
1189TEST_F(WebRtcVideoChannel2Test, DISABLED_ResetCodecOnScreencast) {
1190 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1191}
1192
1193TEST_F(WebRtcVideoChannel2Test, DISABLED_DontResetCodecOnSendFrame) {
1194 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1195}
1196
1197TEST_F(WebRtcVideoChannel2Test,
1198 DISABLED_DontRegisterDecoderIfFactoryIsNotGiven) {
1199 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1200}
1201
1202TEST_F(WebRtcVideoChannel2Test, DISABLED_RegisterDecoderIfFactoryIsGiven) {
1203 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1204}
1205
1206TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterDecoderMultipleTimes) {
1207 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1208}
1209
1210TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterDecoderForNonVP8) {
1211 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1212}
1213
1214TEST_F(WebRtcVideoChannel2Test,
1215 DISABLED_DontRegisterEncoderIfFactoryIsNotGiven) {
1216 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1217}
1218
1219TEST_F(WebRtcVideoChannel2Test, DISABLED_RegisterEncoderIfFactoryIsGiven) {
1220 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1221}
1222
1223TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterEncoderMultipleTimes) {
1224 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1225}
1226
1227TEST_F(WebRtcVideoChannel2Test,
1228 DISABLED_RegisterEncoderWithMultipleSendStreams) {
1229 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1230}
1231
1232TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterEncoderForNonVP8) {
1233 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1234}
1235
1236TEST_F(WebRtcVideoChannel2Test, DISABLED_FeedbackParamsForNonVP8) {
1237 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1238}
1239
1240TEST_F(WebRtcVideoChannel2Test, DISABLED_ExternalCodecAddedToTheEnd) {
1241 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1242}
1243
1244TEST_F(WebRtcVideoChannel2Test, DISABLED_ExternalCodecIgnored) {
1245 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1246}
1247
1248TEST_F(WebRtcVideoChannel2Test, DISABLED_UpdateEncoderCodecsAfterSetFactory) {
1249 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1250}
1251
1252TEST_F(WebRtcVideoChannel2Test, DISABLED_OnReadyToSend) {
1253 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1254}
1255
1256TEST_F(WebRtcVideoChannel2Test, DISABLED_CaptureFrameTimestampToNtpTimestamp) {
1257 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1258}
1259} // namespace cricket