blob: 28abbd1dee70bddbbc3db9ce8565f9858018393c [file] [log] [blame]
pbos@webrtc.orgb5a22b12014-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.org86f613d2014-06-10 08:53:05 +000029#include <vector>
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +000030
31#include "talk/base/gunit.h"
pbos@webrtc.orgcb859ec2014-07-15 08:28:20 +000032#include "talk/base/stringutils.h"
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +000033#include "talk/media/base/testutils.h"
34#include "talk/media/base/videoengine_unittest.h"
35#include "talk/media/webrtc/webrtcvideoengine2.h"
pbos@webrtc.org86f613d2014-06-10 08:53:05 +000036#include "talk/media/webrtc/webrtcvideoengine2_unittest.h"
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +000037#include "talk/media/webrtc/webrtcvideochannelfactory.h"
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +000038
39namespace {
40static const cricket::VideoCodec kVp8Codec720p(100, "VP8", 1280, 720, 30, 0);
41static const cricket::VideoCodec kVp8Codec360p(100, "VP8", 640, 360, 30, 0);
42static const cricket::VideoCodec kVp8Codec270p(100, "VP8", 480, 270, 30, 0);
43static const cricket::VideoCodec kVp8Codec180p(100, "VP8", 320, 180, 30, 0);
44
45static const cricket::VideoCodec kVp8Codec(100, "VP8", 640, 400, 30, 0);
46static const cricket::VideoCodec kVp9Codec(101, "VP9", 640, 400, 30, 0);
47static const cricket::VideoCodec kRedCodec(116, "red", 0, 0, 0, 0);
48static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec", 0, 0, 0, 0);
49
50static const uint32 kSsrcs1[] = {1};
51static const uint32 kRtxSsrcs1[] = {4};
pbos@webrtc.orgf99c2f22014-06-13 12:27:38 +000052
53void VerifyCodecHasDefaultFeedbackParams(const cricket::VideoCodec& codec) {
54 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
55 cricket::kRtcpFbParamNack, cricket::kParamValueEmpty)));
56 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
57 cricket::kRtcpFbParamNack, cricket::kRtcpFbNackParamPli)));
58 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
59 cricket::kRtcpFbParamRemb, cricket::kParamValueEmpty)));
60 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
61 cricket::kRtcpFbParamCcm, cricket::kRtcpFbCcmParamFir)));
62}
63
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +000064} // namespace
65
66namespace cricket {
pbos@webrtc.org86f613d2014-06-10 08:53:05 +000067FakeVideoSendStream::FakeVideoSendStream(
68 const webrtc::VideoSendStream::Config& config,
69 const std::vector<webrtc::VideoStream>& video_streams)
70 : sending_(false), config_(config), video_streams_(video_streams) {
71}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +000072
pbos@webrtc.org86f613d2014-06-10 08:53:05 +000073webrtc::VideoSendStream::Config FakeVideoSendStream::GetConfig() {
74 return config_;
75}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +000076
pbos@webrtc.org86f613d2014-06-10 08:53:05 +000077std::vector<webrtc::VideoStream> FakeVideoSendStream::GetVideoStreams() {
78 return video_streams_;
79}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +000080
pbos@webrtc.org86f613d2014-06-10 08:53:05 +000081bool FakeVideoSendStream::IsSending() {
82 return sending_;
83}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +000084
pbos@webrtc.org86f613d2014-06-10 08:53:05 +000085webrtc::VideoSendStream::Stats FakeVideoSendStream::GetStats() const {
86 return webrtc::VideoSendStream::Stats();
87}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +000088
pbos@webrtc.org86f613d2014-06-10 08:53:05 +000089bool FakeVideoSendStream::ReconfigureVideoEncoder(
90 const std::vector<webrtc::VideoStream>& streams,
91 const void* encoder_specific) {
92 video_streams_ = streams;
93 return true;
94}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +000095
pbos@webrtc.org86f613d2014-06-10 08:53:05 +000096webrtc::VideoSendStreamInput* FakeVideoSendStream::Input() {
97 // TODO(pbos): Fix.
98 return NULL;
99}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000100
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000101void FakeVideoSendStream::Start() {
102 sending_ = true;
103}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000104
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000105void FakeVideoSendStream::Stop() {
106 sending_ = false;
107}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000108
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000109FakeVideoReceiveStream::FakeVideoReceiveStream(
110 const webrtc::VideoReceiveStream::Config& config)
111 : config_(config), receiving_(false) {
112}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000113
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000114webrtc::VideoReceiveStream::Config FakeVideoReceiveStream::GetConfig() {
115 return config_;
116}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000117
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000118webrtc::VideoReceiveStream::Stats FakeVideoReceiveStream::GetStats() const {
119 return webrtc::VideoReceiveStream::Stats();
120}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000121
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000122void FakeVideoReceiveStream::Start() {
123 receiving_ = true;
124}
125void FakeVideoReceiveStream::Stop() {
126 receiving_ = false;
127}
128void FakeVideoReceiveStream::GetCurrentReceiveCodec(webrtc::VideoCodec* codec) {
129}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000130
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000131FakeCall::FakeCall() { SetVideoCodecs(GetDefaultVideoCodecs()); }
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000132
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000133FakeCall::~FakeCall() {
134 EXPECT_EQ(0u, video_send_streams_.size());
135 EXPECT_EQ(0u, video_receive_streams_.size());
136}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000137
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000138void FakeCall::SetVideoCodecs(const std::vector<webrtc::VideoCodec> codecs) {
139 codecs_ = codecs;
140}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000141
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000142std::vector<FakeVideoSendStream*> FakeCall::GetVideoSendStreams() {
143 return video_send_streams_;
144}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000145
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000146std::vector<FakeVideoReceiveStream*> FakeCall::GetVideoReceiveStreams() {
147 return video_receive_streams_;
148}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000149
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000150webrtc::VideoCodec FakeCall::GetEmptyVideoCodec() {
151 webrtc::VideoCodec codec;
152 codec.minBitrate = 300;
153 codec.startBitrate = 800;
154 codec.maxBitrate = 1500;
155 codec.maxFramerate = 10;
156 codec.width = 640;
157 codec.height = 480;
158 codec.qpMax = 56;
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000159
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000160 return codec;
161}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000162
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000163webrtc::VideoCodec FakeCall::GetVideoCodecVp8() {
164 webrtc::VideoCodec vp8_codec = GetEmptyVideoCodec();
165 vp8_codec.codecType = webrtc::kVideoCodecVP8;
pbos@webrtc.orgcb859ec2014-07-15 08:28:20 +0000166 talk_base::strcpyn(vp8_codec.plName, ARRAY_SIZE(vp8_codec.plName),
167 kVp8Codec.name.c_str());
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000168 vp8_codec.plType = kVp8Codec.id;
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000169
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000170 return vp8_codec;
171}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000172
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000173webrtc::VideoCodec FakeCall::GetVideoCodecVp9() {
174 webrtc::VideoCodec vp9_codec = GetEmptyVideoCodec();
175 // TODO(pbos): Add a correct codecType when webrtc has one.
176 vp9_codec.codecType = webrtc::kVideoCodecVP8;
pbos@webrtc.orgcb859ec2014-07-15 08:28:20 +0000177 talk_base::strcpyn(vp9_codec.plName, ARRAY_SIZE(vp9_codec.plName),
178 kVp9Codec.name.c_str());
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000179 vp9_codec.plType = kVp9Codec.id;
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000180
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000181 return vp9_codec;
182}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000183
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000184std::vector<webrtc::VideoCodec> FakeCall::GetDefaultVideoCodecs() {
185 std::vector<webrtc::VideoCodec> codecs;
186 codecs.push_back(GetVideoCodecVp8());
187 // codecs.push_back(GetVideoCodecVp9());
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000188
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000189 return codecs;
190}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000191
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000192webrtc::VideoSendStream* FakeCall::CreateVideoSendStream(
193 const webrtc::VideoSendStream::Config& config,
194 const std::vector<webrtc::VideoStream>& video_streams,
195 const void* encoder_settings) {
196 FakeVideoSendStream* fake_stream =
197 new FakeVideoSendStream(config, video_streams);
198 video_send_streams_.push_back(fake_stream);
199 return fake_stream;
200}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000201
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000202void FakeCall::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) {
203 FakeVideoSendStream* fake_stream =
204 static_cast<FakeVideoSendStream*>(send_stream);
205 for (size_t i = 0; i < video_send_streams_.size(); ++i) {
206 if (video_send_streams_[i] == fake_stream) {
207 delete video_send_streams_[i];
208 video_send_streams_.erase(video_send_streams_.begin() + i);
209 return;
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000210 }
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000211 }
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000212 ADD_FAILURE() << "DestroyVideoSendStream called with unknown paramter.";
213}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000214
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000215webrtc::VideoReceiveStream* FakeCall::CreateVideoReceiveStream(
216 const webrtc::VideoReceiveStream::Config& config) {
217 video_receive_streams_.push_back(new FakeVideoReceiveStream(config));
218 return video_receive_streams_[video_receive_streams_.size() - 1];
219}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000220
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000221void FakeCall::DestroyVideoReceiveStream(
222 webrtc::VideoReceiveStream* receive_stream) {
223 FakeVideoReceiveStream* fake_stream =
224 static_cast<FakeVideoReceiveStream*>(receive_stream);
225 for (size_t i = 0; i < video_receive_streams_.size(); ++i) {
226 if (video_receive_streams_[i] == fake_stream) {
227 delete video_receive_streams_[i];
228 video_receive_streams_.erase(video_receive_streams_.begin() + i);
229 return;
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000230 }
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000231 }
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000232 ADD_FAILURE() << "DestroyVideoReceiveStream called with unknown paramter.";
233}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000234
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000235webrtc::PacketReceiver* FakeCall::Receiver() {
236 // TODO(pbos): Fix this.
237 return NULL;
238}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000239
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000240uint32_t FakeCall::SendBitrateEstimate() {
241 return 0;
242}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000243
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000244uint32_t FakeCall::ReceiveBitrateEstimate() {
245 return 0;
246}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000247
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000248FakeWebRtcVideoChannel2::FakeWebRtcVideoChannel2(
249 FakeCall* call,
250 WebRtcVideoEngine2* engine,
251 VoiceMediaChannel* voice_channel)
252 : WebRtcVideoChannel2(call, engine, engine->GetVideoEncoderFactory()),
253 fake_call_(call),
254 voice_channel_(voice_channel) {
255}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000256
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000257FakeWebRtcVideoChannel2::~FakeWebRtcVideoChannel2() {
258}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000259
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000260VoiceMediaChannel* FakeWebRtcVideoChannel2::GetVoiceChannel() {
261 return voice_channel_;
262}
263FakeCall* FakeWebRtcVideoChannel2::GetFakeCall() {
264 return fake_call_;
265}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000266
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000267FakeWebRtcVideoChannel2* FakeWebRtcVideoMediaChannelFactory::GetFakeChannel(
268 VideoMediaChannel* channel) {
269 return channel_map_[channel];
270}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000271
pbos@webrtc.org86f613d2014-06-10 08:53:05 +0000272WebRtcVideoChannel2* FakeWebRtcVideoMediaChannelFactory::Create(
273 WebRtcVideoEngine2* engine,
274 VoiceMediaChannel* voice_channel) {
275 FakeWebRtcVideoChannel2* channel =
276 new FakeWebRtcVideoChannel2(new FakeCall(), engine, voice_channel);
277 channel_map_[channel] = channel;
278 return channel;
279}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000280
281class WebRtcVideoEngine2Test : public testing::Test {
282 public:
pbos@webrtc.org9fbb7172014-06-13 09:34:13 +0000283 WebRtcVideoEngine2Test() : engine_(&factory_) {
284 std::vector<VideoCodec> engine_codecs = engine_.codecs();
285 assert(!engine_codecs.empty());
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000286 bool codec_set = false;
pbos@webrtc.org9fbb7172014-06-13 09:34:13 +0000287 for (size_t i = 0; i < engine_codecs.size(); ++i) {
288 if (engine_codecs[i].name == "red") {
289 default_red_codec_ = engine_codecs[i];
290 } else if (engine_codecs[i].name == "ulpfec") {
291 default_ulpfec_codec_ = engine_codecs[i];
292 } else if (engine_codecs[i].name == "rtx") {
293 default_rtx_codec_ = engine_codecs[i];
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000294 } else if (!codec_set) {
pbos@webrtc.org9fbb7172014-06-13 09:34:13 +0000295 default_codec_ = engine_codecs[i];
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000296 codec_set = true;
297 }
298 }
299
300 assert(codec_set);
301 }
302
303 protected:
304 FakeWebRtcVideoMediaChannelFactory factory_;
305 WebRtcVideoEngine2 engine_;
306 VideoCodec default_codec_;
307 VideoCodec default_red_codec_;
308 VideoCodec default_ulpfec_codec_;
309 VideoCodec default_rtx_codec_;
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000310};
311
312TEST_F(WebRtcVideoEngine2Test, CreateChannel) {
313 talk_base::scoped_ptr<VideoMediaChannel> channel(engine_.CreateChannel(NULL));
314 ASSERT_TRUE(channel.get() != NULL) << "Could not create channel.";
315 EXPECT_TRUE(factory_.GetFakeChannel(channel.get()) != NULL)
316 << "Channel not created through factory.";
317}
318
319TEST_F(WebRtcVideoEngine2Test, CreateChannelWithVoiceEngine) {
320 VoiceMediaChannel* voice_channel = reinterpret_cast<VoiceMediaChannel*>(0x42);
321 talk_base::scoped_ptr<VideoMediaChannel> channel(
322 engine_.CreateChannel(voice_channel));
323 ASSERT_TRUE(channel.get() != NULL) << "Could not create channel.";
324
325 FakeWebRtcVideoChannel2* fake_channel =
326 factory_.GetFakeChannel(channel.get());
327 ASSERT_TRUE(fake_channel != NULL) << "Channel not created through factory.";
328
329 EXPECT_TRUE(fake_channel->GetVoiceChannel() != NULL)
330 << "VoiceChannel not set.";
331 EXPECT_EQ(voice_channel, fake_channel->GetVoiceChannel())
332 << "Different VoiceChannel set than the provided one.";
333}
334
pbos@webrtc.orge322a172014-06-13 11:47:28 +0000335TEST_F(WebRtcVideoEngine2Test, FindCodec) {
336 const std::vector<cricket::VideoCodec>& c = engine_.codecs();
337 EXPECT_EQ(4U, c.size());
338
339 cricket::VideoCodec vp8(104, "VP8", 320, 200, 30, 0);
340 EXPECT_TRUE(engine_.FindCodec(vp8));
341
342 cricket::VideoCodec vp8_ci(104, "vp8", 320, 200, 30, 0);
343 EXPECT_TRUE(engine_.FindCodec(vp8));
344
345 cricket::VideoCodec vp8_diff_fr_diff_pref(104, "VP8", 320, 200, 50, 50);
346 EXPECT_TRUE(engine_.FindCodec(vp8_diff_fr_diff_pref));
347
348 cricket::VideoCodec vp8_diff_id(95, "VP8", 320, 200, 30, 0);
349 EXPECT_FALSE(engine_.FindCodec(vp8_diff_id));
350 vp8_diff_id.id = 97;
351 EXPECT_TRUE(engine_.FindCodec(vp8_diff_id));
352
353 cricket::VideoCodec vp8_diff_res(104, "VP8", 320, 111, 30, 0);
354 EXPECT_FALSE(engine_.FindCodec(vp8_diff_res));
355
356 // PeerConnection doesn't negotiate the resolution at this point.
357 // Test that FindCodec can handle the case when width/height is 0.
358 cricket::VideoCodec vp8_zero_res(104, "VP8", 0, 0, 30, 0);
359 EXPECT_TRUE(engine_.FindCodec(vp8_zero_res));
360
361 cricket::VideoCodec red(101, "RED", 0, 0, 30, 0);
362 EXPECT_TRUE(engine_.FindCodec(red));
363
364 cricket::VideoCodec red_ci(101, "red", 0, 0, 30, 0);
365 EXPECT_TRUE(engine_.FindCodec(red));
366
367 cricket::VideoCodec fec(102, "ULPFEC", 0, 0, 30, 0);
368 EXPECT_TRUE(engine_.FindCodec(fec));
369
370 cricket::VideoCodec fec_ci(102, "ulpfec", 0, 0, 30, 0);
371 EXPECT_TRUE(engine_.FindCodec(fec));
372
373 cricket::VideoCodec rtx(96, "rtx", 0, 0, 30, 0);
374 EXPECT_TRUE(engine_.FindCodec(rtx));
375}
376
377TEST_F(WebRtcVideoEngine2Test, DefaultRtxCodecHasAssociatedPayloadTypeSet) {
378 std::vector<VideoCodec> engine_codecs = engine_.codecs();
379 for (size_t i = 0; i < engine_codecs.size(); ++i) {
380 if (engine_codecs[i].name != kRtxCodecName)
381 continue;
382 int associated_payload_type;
383 EXPECT_TRUE(engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType,
384 &associated_payload_type));
385 EXPECT_EQ(default_codec_.id, associated_payload_type);
386 return;
387 }
388 FAIL() << "No RTX codec found among default codecs.";
389}
390
pbos@webrtc.org587ef602014-06-16 17:32:02 +0000391TEST_F(WebRtcVideoEngine2Test, SupportsTimestampOffsetHeaderExtension) {
392 std::vector<RtpHeaderExtension> extensions = engine_.rtp_header_extensions();
393 ASSERT_FALSE(extensions.empty());
394 for (size_t i = 0; i < extensions.size(); ++i) {
395 if (extensions[i].uri == kRtpTimestampOffsetHeaderExtension) {
396 EXPECT_EQ(kRtpTimestampOffsetHeaderExtensionDefaultId, extensions[i].id);
397 return;
398 }
399 }
400 FAIL() << "Timestamp offset extension not in header-extension list.";
401}
402
403TEST_F(WebRtcVideoEngine2Test, SupportsAbsoluteSenderTimeHeaderExtension) {
404 std::vector<RtpHeaderExtension> extensions = engine_.rtp_header_extensions();
405 ASSERT_FALSE(extensions.empty());
406 for (size_t i = 0; i < extensions.size(); ++i) {
407 if (extensions[i].uri == kRtpAbsoluteSenderTimeHeaderExtension) {
408 EXPECT_EQ(kRtpAbsoluteSenderTimeHeaderExtensionDefaultId,
409 extensions[i].id);
410 return;
411 }
412 }
413 FAIL() << "Absolute Sender Time extension not in header-extension list.";
414}
415
pbos@webrtc.org5301b0f2014-07-17 08:51:46 +0000416TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) {
417 talk_base::scoped_ptr<VideoMediaChannel> channel(engine_.CreateChannel(NULL));
418
419 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123)));
420
421 EXPECT_FALSE(channel->SetSend(true))
422 << "Channel should not start without codecs.";
423 EXPECT_TRUE(channel->SetSend(false))
424 << "Channel should be stoppable even without set codecs.";
425}
426
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000427class WebRtcVideoChannel2BaseTest
428 : public VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> {
429 protected:
430 virtual cricket::VideoCodec DefaultCodec() OVERRIDE { return kVp8Codec; }
431 typedef VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> Base;
432};
433
434// TODO(pbos): Fix WebRtcVideoEngine2BaseTest, where we want CheckCoInitialize.
435#if 0
436// TODO(juberti): Figure out why ViE is munging the COM refcount.
437#ifdef WIN32
438TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_CheckCoInitialize) {
439 Base::CheckCoInitialize();
440}
441#endif
442#endif
443
444TEST_F(WebRtcVideoChannel2BaseTest, SetSend) { Base::SetSend(); }
445
446TEST_F(WebRtcVideoChannel2BaseTest, SetSendWithoutCodecs) {
447 Base::SetSendWithoutCodecs();
448}
449
450TEST_F(WebRtcVideoChannel2BaseTest, SetSendSetsTransportBufferSizes) {
451 Base::SetSendSetsTransportBufferSizes();
452}
453
454// TODO(juberti): Fix this test to tolerate missing stats.
455TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_GetStats) { Base::GetStats(); }
456
457// TODO(juberti): Fix this test to tolerate missing stats.
458TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_GetStatsMultipleRecvStreams) {
459 Base::GetStatsMultipleRecvStreams();
460}
461
462TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_GetStatsMultipleSendStreams) {
463 Base::GetStatsMultipleSendStreams();
464}
465
466TEST_F(WebRtcVideoChannel2BaseTest, SetSendBandwidth) {
467 Base::SetSendBandwidth();
468}
469TEST_F(WebRtcVideoChannel2BaseTest, SetSendSsrc) { Base::SetSendSsrc(); }
470TEST_F(WebRtcVideoChannel2BaseTest, SetSendSsrcAfterSetCodecs) {
471 Base::SetSendSsrcAfterSetCodecs();
472}
473
474TEST_F(WebRtcVideoChannel2BaseTest, SetRenderer) { Base::SetRenderer(); }
475
476TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveRecvStreams) {
477 Base::AddRemoveRecvStreams();
478}
479
480TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_AddRemoveRecvStreamAndRender) {
481 Base::AddRemoveRecvStreamAndRender();
482}
483
484TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveRecvStreamsNoConference) {
485 Base::AddRemoveRecvStreamsNoConference();
486}
487
488TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveSendStreams) {
489 Base::AddRemoveSendStreams();
490}
491
492TEST_F(WebRtcVideoChannel2BaseTest, SimulateConference) {
493 Base::SimulateConference();
494}
495
496TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveCapturer) {
497 Base::AddRemoveCapturer();
498}
499
500TEST_F(WebRtcVideoChannel2BaseTest, RemoveCapturerWithoutAdd) {
501 Base::RemoveCapturerWithoutAdd();
502}
503
504TEST_F(WebRtcVideoChannel2BaseTest, AddRemoveCapturerMultipleSources) {
505 Base::AddRemoveCapturerMultipleSources();
506}
507
508// TODO(pbos): Figure out why this fails so often.
509TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_HighAspectHighHeightCapturer) {
510 Base::HighAspectHighHeightCapturer();
511}
512
513TEST_F(WebRtcVideoChannel2BaseTest, RejectEmptyStreamParams) {
514 Base::RejectEmptyStreamParams();
515}
516
517TEST_F(WebRtcVideoChannel2BaseTest, AdaptResolution16x10) {
518 Base::AdaptResolution16x10();
519}
520
521TEST_F(WebRtcVideoChannel2BaseTest, AdaptResolution4x3) {
522 Base::AdaptResolution4x3();
523}
524
525TEST_F(WebRtcVideoChannel2BaseTest, MuteStream) { Base::MuteStream(); }
526
527TEST_F(WebRtcVideoChannel2BaseTest, MultipleSendStreams) {
528 Base::MultipleSendStreams();
529}
530
531// TODO(juberti): Restore this test once we support sending 0 fps.
532TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_AdaptDropAllFrames) {
533 Base::AdaptDropAllFrames();
534}
535// TODO(juberti): Understand why we get decode errors on this test.
536TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_AdaptFramerate) {
537 Base::AdaptFramerate();
538}
539
540TEST_F(WebRtcVideoChannel2BaseTest, SetSendStreamFormat0x0) {
541 Base::SetSendStreamFormat0x0();
542}
543
544// TODO(zhurunz): Fix the flakey test.
545TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_SetSendStreamFormat) {
546 Base::SetSendStreamFormat();
547}
548
549TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsSendAndReceive) {
550 Base::TwoStreamsSendAndReceive(kVp8Codec);
551}
552
553TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsReUseFirstStream) {
554 Base::TwoStreamsReUseFirstStream(kVp8Codec);
555}
556
557class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test {
558 public:
559 virtual void SetUp() OVERRIDE {
560 channel_.reset(engine_.CreateChannel(NULL));
561 fake_channel_ = factory_.GetFakeChannel(channel_.get());
562 last_ssrc_ = 123;
563 ASSERT_TRUE(fake_channel_ != NULL)
564 << "Channel not created through factory.";
pbos@webrtc.org5301b0f2014-07-17 08:51:46 +0000565 EXPECT_TRUE(fake_channel_->SetSendCodecs(engine_.codecs()));
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000566 }
567
568 protected:
569 FakeVideoSendStream* AddSendStream() {
570 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++));
571 }
572
573 FakeVideoSendStream* AddSendStream(const StreamParams& sp) {
574 size_t num_streams =
575 fake_channel_->GetFakeCall()->GetVideoSendStreams().size();
576 EXPECT_TRUE(channel_->AddSendStream(sp));
577 std::vector<FakeVideoSendStream*> streams =
578 fake_channel_->GetFakeCall()->GetVideoSendStreams();
579 EXPECT_EQ(num_streams + 1, streams.size());
580 return streams[streams.size() - 1];
581 }
582
583 std::vector<FakeVideoSendStream*> GetFakeSendStreams() {
584 return fake_channel_->GetFakeCall()->GetVideoSendStreams();
585 }
586
587 FakeVideoReceiveStream* AddRecvStream() {
588 return AddRecvStream(StreamParams::CreateLegacy(last_ssrc_++));
589 }
590
591 FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) {
592 size_t num_streams =
593 fake_channel_->GetFakeCall()->GetVideoReceiveStreams().size();
594 EXPECT_TRUE(channel_->AddRecvStream(sp));
595 std::vector<FakeVideoReceiveStream*> streams =
596 fake_channel_->GetFakeCall()->GetVideoReceiveStreams();
597 EXPECT_EQ(num_streams + 1, streams.size());
598 return streams[streams.size() - 1];
599 }
600
601 void SetSendCodecsShouldWorkForBitrates(const char* min_bitrate,
602 const char* max_bitrate) {
603 std::vector<VideoCodec> codecs;
604 codecs.push_back(kVp8Codec);
605 codecs[0].params[kCodecParamMinBitrate] = min_bitrate;
606 codecs[0].params[kCodecParamMaxBitrate] = max_bitrate;
607 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
608
609 FakeVideoSendStream* stream = AddSendStream();
610
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +0000611 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams();
612 ASSERT_EQ(1u, video_streams.size());
613 EXPECT_EQ(atoi(min_bitrate), video_streams.back().min_bitrate_bps / 1000);
614 EXPECT_EQ(atoi(max_bitrate), video_streams.back().max_bitrate_bps / 1000);
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000615
616 VideoCodec codec;
617 EXPECT_TRUE(channel_->GetSendCodec(&codec));
618 EXPECT_EQ(min_bitrate, codec.params[kCodecParamMinBitrate]);
619 EXPECT_EQ(max_bitrate, codec.params[kCodecParamMaxBitrate]);
620 }
621
pbos@webrtc.org587ef602014-06-16 17:32:02 +0000622 void TestSetSendRtpHeaderExtensions(const std::string& cricket_ext,
623 const std::string& webrtc_ext) {
624 // Enable extension.
625 const int id = 1;
626 std::vector<cricket::RtpHeaderExtension> extensions;
627 extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id));
628 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions));
629
630 FakeVideoSendStream* send_stream =
631 AddSendStream(cricket::StreamParams::CreateLegacy(123));
632
633 // Verify the send extension id.
634 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size());
635 EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id);
636 EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name);
637 // Verify call with same set of extensions returns true.
638 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions));
639 // Verify that SetSendRtpHeaderExtensions doesn't implicitly add them for
640 // receivers.
641 EXPECT_TRUE(AddRecvStream(cricket::StreamParams::CreateLegacy(123))
642 ->GetConfig()
643 .rtp.extensions.empty());
644
645 // Remove the extension id, verify that this doesn't reset extensions as
646 // they should be set before creating channels.
647 std::vector<cricket::RtpHeaderExtension> empty_extensions;
648 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions));
649 EXPECT_FALSE(send_stream->GetConfig().rtp.extensions.empty());
650 }
651
652 void TestSetRecvRtpHeaderExtensions(const std::string& cricket_ext,
653 const std::string& webrtc_ext) {
654 // Enable extension.
655 const int id = 1;
656 std::vector<cricket::RtpHeaderExtension> extensions;
657 extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id));
658 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions));
659
660 FakeVideoReceiveStream* recv_stream =
661 AddRecvStream(cricket::StreamParams::CreateLegacy(123));
662
663 // Verify the recv extension id.
664 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size());
665 EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id);
666 EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name);
667 // Verify call with same set of extensions returns true.
668 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions));
669 // Verify that SetRecvRtpHeaderExtensions doesn't implicitly add them for
670 // senders.
671 EXPECT_TRUE(AddSendStream(cricket::StreamParams::CreateLegacy(123))
672 ->GetConfig()
673 .rtp.extensions.empty());
674
675 // Remove the extension id, verify that this doesn't reset extensions as
676 // they should be set before creating channels.
677 std::vector<cricket::RtpHeaderExtension> empty_extensions;
678 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions));
679 EXPECT_FALSE(recv_stream->GetConfig().rtp.extensions.empty());
680 }
681
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000682 talk_base::scoped_ptr<VideoMediaChannel> channel_;
683 FakeWebRtcVideoChannel2* fake_channel_;
684 uint32 last_ssrc_;
685};
686
687TEST_F(WebRtcVideoChannel2Test, DISABLED_MaxBitrateResetsWithConferenceMode) {
688 FAIL() << "Not implemented."; // TODO(pbos): Implement.
689}
690
691TEST_F(WebRtcVideoChannel2Test, DISABLED_StartSendBitrate) {
692 // TODO(pbos): Is this test testing vie_ ? this is confusing. No API to set
693 // start send bitrate from outside? Add defaults here that should be kept?
694 std::vector<cricket::VideoCodec> codec_list;
695 codec_list.push_back(kVp8Codec);
696 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
697 const unsigned int kVideoMinSendBitrateKbps = 50;
698 const unsigned int kVideoTargetSendBitrateKbps = 300;
699 const unsigned int kVideoMaxSendBitrateKbps = 2000;
700 FakeVideoSendStream* stream = AddSendStream();
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +0000701 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams();
702 ASSERT_EQ(1u, video_streams.size());
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000703 EXPECT_EQ(kVideoMinSendBitrateKbps,
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +0000704 video_streams.back().min_bitrate_bps / 1000);
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000705 EXPECT_EQ(kVideoTargetSendBitrateKbps,
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +0000706 video_streams.back().target_bitrate_bps / 1000);
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000707 EXPECT_EQ(kVideoMaxSendBitrateKbps,
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +0000708 video_streams.back().max_bitrate_bps / 1000);
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000709#if 0
710 // TODO(pbos): un-#if
711 VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
712 kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
713 kVideoDefaultStartSendBitrateKbps);
714 EXPECT_EQ(0, vie_.StartSend(send_channel));
715
716 // Increase the send bitrate and verify it is used as start bitrate.
717 const unsigned int kVideoSendBitrateBps = 768000;
718 vie_.SetSendBitrates(send_channel, kVideoSendBitrateBps, 0, 0);
719 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
720 VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
721 kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
722 kVideoSendBitrateBps / 1000);
723
724 // Never set a start bitrate higher than the max bitrate.
725 vie_.SetSendBitrates(send_channel, kVideoMaxSendBitrateKbps + 500, 0, 0);
726 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
727 VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
728 kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
729 kVideoDefaultStartSendBitrateKbps);
730
731 // Use the default start bitrate if the send bitrate is lower.
732 vie_.SetSendBitrates(send_channel, kVideoDefaultStartSendBitrateKbps - 50, 0,
733 0);
734 EXPECT_TRUE(channel_->SetSendCodecs(codec_list));
735 VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0,
736 kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps,
737 kVideoDefaultStartSendBitrateKbps);
738#endif
739}
740
741TEST_F(WebRtcVideoChannel2Test, DISABLED_RtcpEnabled) {
742 // Note(pbos): This is a receiver-side setting, dumbo.
743 FAIL() << "Not implemented."; // TODO(pbos): Implement.
744}
745
746TEST_F(WebRtcVideoChannel2Test, DISABLED_KeyFrameRequestEnabled) {
747 FAIL() << "Not implemented."; // TODO(pbos): Implement.
748}
749
750TEST_F(WebRtcVideoChannel2Test, RembIsEnabledByDefault) {
751 FakeVideoReceiveStream* stream = AddRecvStream();
752 EXPECT_TRUE(stream->GetConfig().rtp.remb);
753}
754
755TEST_F(WebRtcVideoChannel2Test, DISABLED_RembEnabledOnReceiveChannels) {
756 FAIL() << "Not implemented."; // TODO(pbos): Implement.
757}
758
pbos@webrtc.orge322a172014-06-13 11:47:28 +0000759TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) {
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000760 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
761 EXPECT_TRUE(channel_->SetSend(true));
762 cricket::VideoOptions options;
763 options.conference_mode.Set(true);
764 EXPECT_TRUE(channel_->SetOptions(options));
765
766 // Send side.
767 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1);
768 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1);
769 FakeVideoSendStream* send_stream = AddSendStream(
770 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
771
772 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size());
773 for (size_t i = 0; i < rtx_ssrcs.size(); ++i)
774 EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]);
775
776 // Receiver side.
777 FakeVideoReceiveStream* recv_stream = AddRecvStream(
778 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
779 ASSERT_GT(recv_stream->GetConfig().rtp.rtx.size(), 0u)
780 << "No SSRCs for RTX configured by AddRecvStream.";
781 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.rtx.size())
782 << "This test only works with one receive codec. Please update the test.";
783 EXPECT_EQ(rtx_ssrcs[0],
784 recv_stream->GetConfig().rtp.rtx.begin()->second.ssrc);
785 // TODO(pbos): Make sure we set the RTX for correct payloads etc.
786}
787
pbos@webrtc.orge322a172014-06-13 11:47:28 +0000788TEST_F(WebRtcVideoChannel2Test, RecvStreamWithRtx) {
789 // Setup one channel with an associated RTX stream.
790 cricket::StreamParams params =
791 cricket::StreamParams::CreateLegacy(kSsrcs1[0]);
792 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]);
793 FakeVideoReceiveStream* recv_stream = AddRecvStream(params);
794 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.rtx.size());
795 EXPECT_EQ(kRtxSsrcs1[0],
796 recv_stream->GetConfig().rtp.rtx.begin()->second.ssrc);
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000797}
798
pbos@webrtc.orge322a172014-06-13 11:47:28 +0000799TEST_F(WebRtcVideoChannel2Test, RecvStreamNoRtx) {
800 // Setup one channel without an associated RTX stream.
801 cricket::StreamParams params =
802 cricket::StreamParams::CreateLegacy(kSsrcs1[0]);
803 FakeVideoReceiveStream* recv_stream = AddRecvStream(params);
804 ASSERT_TRUE(recv_stream->GetConfig().rtp.rtx.empty());
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000805}
806
pbos@webrtc.org587ef602014-06-16 17:32:02 +0000807TEST_F(WebRtcVideoChannel2Test, NoHeaderExtesionsByDefault) {
808 FakeVideoSendStream* send_stream =
809 AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0]));
810 ASSERT_TRUE(send_stream->GetConfig().rtp.extensions.empty());
811
812 FakeVideoReceiveStream* recv_stream =
813 AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrcs1[0]));
814 ASSERT_TRUE(recv_stream->GetConfig().rtp.extensions.empty());
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000815}
816
pbos@webrtc.org587ef602014-06-16 17:32:02 +0000817// Test support for RTP timestamp offset header extension.
818TEST_F(WebRtcVideoChannel2Test, SendRtpTimestampOffsetHeaderExtensions) {
819 TestSetSendRtpHeaderExtensions(kRtpTimestampOffsetHeaderExtension,
820 webrtc::RtpExtension::kTOffset);
821}
822TEST_F(WebRtcVideoChannel2Test, RecvRtpTimestampOffsetHeaderExtensions) {
823 TestSetRecvRtpHeaderExtensions(kRtpTimestampOffsetHeaderExtension,
824 webrtc::RtpExtension::kTOffset);
825}
826
827// Test support for absolute send time header extension.
828TEST_F(WebRtcVideoChannel2Test, SendAbsoluteSendTimeHeaderExtensions) {
829 TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension,
830 webrtc::RtpExtension::kAbsSendTime);
831}
832TEST_F(WebRtcVideoChannel2Test, RecvAbsoluteSendTimeHeaderExtensions) {
833 TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension,
834 webrtc::RtpExtension::kAbsSendTime);
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000835}
836
837TEST_F(WebRtcVideoChannel2Test, DISABLED_LeakyBucketTest) {
838 FAIL() << "Not implemented."; // TODO(pbos): Implement.
839}
840
841TEST_F(WebRtcVideoChannel2Test, DISABLED_BufferedModeLatency) {
842 FAIL() << "Not implemented."; // TODO(pbos): Implement.
843}
844
845TEST_F(WebRtcVideoChannel2Test, DISABLED_AdditiveVideoOptions) {
846 FAIL() << "Not implemented."; // TODO(pbos): Implement.
847}
848
849TEST_F(WebRtcVideoChannel2Test, AddRecvStreamOnlyUsesOneReceiveStream) {
850 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
851 EXPECT_EQ(1u, fake_channel_->GetFakeCall()->GetVideoReceiveStreams().size());
852}
853
854TEST_F(WebRtcVideoChannel2Test, DISABLED_NoRembChangeAfterAddRecvStream) {
855 FAIL() << "Not implemented."; // TODO(pbos): Implement.
856}
857
858TEST_F(WebRtcVideoChannel2Test, DISABLED_RembOnOff) {
859 FAIL() << "Not implemented."; // TODO(pbos): Implement.
860}
861
pbos@webrtc.orgf99c2f22014-06-13 12:27:38 +0000862TEST_F(WebRtcVideoChannel2Test, NackIsEnabledByDefault) {
863 VerifyCodecHasDefaultFeedbackParams(default_codec_);
864
pbos@webrtc.org19864742014-05-30 07:35:47 +0000865 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
866 EXPECT_TRUE(channel_->SetSend(true));
867
868 // Send side.
869 FakeVideoSendStream* send_stream =
870 AddSendStream(cricket::StreamParams::CreateLegacy(1));
871 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0);
872
873 // Receiver side.
874 FakeVideoReceiveStream* recv_stream =
875 AddRecvStream(cricket::StreamParams::CreateLegacy(1));
876 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0);
877
878 // Nack history size should match between sender and receiver.
879 EXPECT_EQ(send_stream->GetConfig().rtp.nack.rtp_history_ms,
880 recv_stream->GetConfig().rtp.nack.rtp_history_ms);
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000881}
882
pbos@webrtc.orgf99c2f22014-06-13 12:27:38 +0000883TEST_F(WebRtcVideoChannel2Test, NackCanBeDisabled) {
884 std::vector<VideoCodec> codecs;
885 codecs.push_back(kVp8Codec);
886
887 // Send side.
888 ASSERT_TRUE(channel_->SetSendCodecs(codecs));
889 FakeVideoSendStream* send_stream =
890 AddSendStream(cricket::StreamParams::CreateLegacy(1));
891 EXPECT_EQ(0, send_stream->GetConfig().rtp.nack.rtp_history_ms);
892
893 // Receiver side.
894 ASSERT_TRUE(channel_->SetRecvCodecs(codecs));
895 FakeVideoReceiveStream* recv_stream =
896 AddRecvStream(cricket::StreamParams::CreateLegacy(1));
897 EXPECT_EQ(0, recv_stream->GetConfig().rtp.nack.rtp_history_ms);
898}
899
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000900TEST_F(WebRtcVideoChannel2Test, DISABLED_VideoProtectionInterop) {
901 FAIL() << "Not implemented."; // TODO(pbos): Implement.
902}
903
904TEST_F(WebRtcVideoChannel2Test, DISABLED_VideoProtectionInteropReversed) {
905 FAIL() << "Not implemented."; // TODO(pbos): Implement.
906}
907
908TEST_F(WebRtcVideoChannel2Test, DISABLED_HybridNackFecConference) {
909 FAIL() << "Not implemented."; // TODO(pbos): Implement.
910}
911
912TEST_F(WebRtcVideoChannel2Test, DISABLED_AddRemoveRecvStreamConference) {
913 FAIL() << "Not implemented."; // TODO(pbos): Implement.
914}
915
916TEST_F(WebRtcVideoChannel2Test, DISABLED_SetRender) {
917 FAIL() << "Not implemented."; // TODO(pbos): Implement.
918}
919
920TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthAuto) {
921 FAIL() << "Not implemented."; // TODO(pbos): Implement.
922}
923
924TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthAutoCapped) {
925 FAIL() << "Not implemented."; // TODO(pbos): Implement.
926}
927
928TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthFixed) {
929 FAIL() << "Not implemented."; // TODO(pbos): Implement.
930}
931
932TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthInConference) {
933 FAIL() << "Not implemented."; // TODO(pbos): Implement.
934}
935
936TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthScreencast) {
937 FAIL() << "Not implemented."; // TODO(pbos): Implement.
938}
939
940TEST_F(WebRtcVideoChannel2Test, DISABLED_SetSendSsrcAndCname) {
941 FAIL() << "Not implemented."; // TODO(pbos): Implement.
942}
943
944TEST_F(WebRtcVideoChannel2Test,
945 DISABLED_SetSendSsrcAfterCreatingReceiveChannel) {
946 FAIL() << "Not implemented."; // TODO(pbos): Implement.
947}
948
949TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsWithDenoising) {
950 FAIL() << "Not implemented."; // TODO(pbos): Implement.
951}
952
953TEST_F(WebRtcVideoChannel2Test, DISABLED_MultipleSendStreamsWithOneCapturer) {
954 FAIL() << "Not implemented."; // TODO(pbos): Implement.
955}
956
957TEST_F(WebRtcVideoChannel2Test, DISABLED_DISABLED_SendReceiveBitratesStats) {
958 FAIL() << "Not implemented."; // TODO(pbos): Implement.
959}
960
961TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetAdaptInputToCpuUsage) {
962 FAIL() << "Not implemented."; // TODO(pbos): Implement.
963}
964
965TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetCpuThreshold) {
966 FAIL() << "Not implemented."; // TODO(pbos): Implement.
967}
968
969TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetInvalidCpuThreshold) {
970 FAIL() << "Not implemented."; // TODO(pbos): Implement.
971}
972
973TEST_F(WebRtcVideoChannel2Test, DISABLED_WebRtcShouldLog) {
974 FAIL() << "Not implemented."; // TODO(pbos): Implement.
975}
976
977TEST_F(WebRtcVideoChannel2Test, DISABLED_WebRtcShouldNotLog) {
978 FAIL() << "Not implemented."; // TODO(pbos): Implement.
979}
980
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000981TEST_F(WebRtcVideoChannel2Test, SetDefaultSendCodecs) {
pbos@webrtc.org9fbb7172014-06-13 09:34:13 +0000982 ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000983
984 VideoCodec codec;
985 EXPECT_TRUE(channel_->GetSendCodec(&codec));
pbos@webrtc.org9fbb7172014-06-13 09:34:13 +0000986 EXPECT_TRUE(codec.Matches(engine_.codecs()[0]));
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000987
988 // Using a RTX setup to verify that the default RTX payload type is good.
989 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1);
990 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1);
991 FakeVideoSendStream* stream = AddSendStream(
992 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
993 webrtc::VideoSendStream::Config config = stream->GetConfig();
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000994
995 // Make sure NACK and FEC are enabled on the correct payload types.
996 EXPECT_EQ(1000, config.rtp.nack.rtp_history_ms);
997 EXPECT_EQ(default_ulpfec_codec_.id, config.rtp.fec.ulpfec_payload_type);
998 EXPECT_EQ(default_red_codec_.id, config.rtp.fec.red_payload_type);
pbos@webrtc.org269605c2014-06-26 08:49:03 +0000999
1000 EXPECT_EQ(1u, config.rtp.rtx.ssrcs.size());
1001 EXPECT_EQ(kRtxSsrcs1[0], config.rtp.rtx.ssrcs[0]);
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +00001002 EXPECT_EQ(static_cast<int>(default_rtx_codec_.id),
1003 config.rtp.rtx.payload_type);
1004 // TODO(juberti): Check RTCP, PLI, TMMBR.
1005}
1006
1007TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) {
1008 std::vector<VideoCodec> codecs;
1009 codecs.push_back(kVp8Codec);
1010 ASSERT_TRUE(channel_->SetSendCodecs(codecs));
1011
1012 FakeVideoSendStream* stream = AddSendStream();
1013 webrtc::VideoSendStream::Config config = stream->GetConfig();
1014
1015 EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type);
1016 EXPECT_EQ(-1, config.rtp.fec.red_payload_type);
1017}
1018
1019TEST_F(WebRtcVideoChannel2Test,
pbos@webrtc.org269605c2014-06-26 08:49:03 +00001020 SetSendCodecRejectsRtxWithoutAssociatedPayloadType) {
1021 std::vector<VideoCodec> codecs;
1022 cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0);
1023 codecs.push_back(rtx_codec);
1024 EXPECT_FALSE(channel_->SetSendCodecs(codecs))
1025 << "RTX codec without associated payload type should be rejected.";
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +00001026}
1027
1028TEST_F(WebRtcVideoChannel2Test,
pbos@webrtc.org269605c2014-06-26 08:49:03 +00001029 SetSendCodecRejectsRtxWithoutMatchingVideoCodec) {
1030 std::vector<VideoCodec> codecs;
1031 cricket::VideoCodec rtx_codec =
1032 cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id);
1033 codecs.push_back(kVp8Codec);
1034 codecs.push_back(rtx_codec);
1035 ASSERT_TRUE(channel_->SetSendCodecs(codecs));
1036
1037 cricket::VideoCodec rtx_codec2 =
1038 cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id + 1);
1039 codecs.pop_back();
1040 codecs.push_back(rtx_codec2);
1041 EXPECT_FALSE(channel_->SetSendCodecs(codecs))
1042 << "RTX without matching video codec should be rejected.";
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +00001043}
1044
pbos@webrtc.org269605c2014-06-26 08:49:03 +00001045TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) {
1046 std::vector<VideoCodec> codecs;
1047 codecs.push_back(kVp8Codec);
1048 codecs.push_back(kUlpfecCodec);
1049 ASSERT_TRUE(channel_->SetSendCodecs(codecs));
1050
1051 FakeVideoSendStream* stream = AddSendStream();
1052 webrtc::VideoSendStream::Config config = stream->GetConfig();
1053
1054 EXPECT_EQ(kUlpfecCodec.id, config.rtp.fec.ulpfec_payload_type);
1055
1056 codecs.pop_back();
1057 ASSERT_TRUE(channel_->SetSendCodecs(codecs));
1058 stream = fake_channel_->GetFakeCall()->GetVideoSendStreams()[0];
1059 ASSERT_TRUE(stream != NULL);
1060 config = stream->GetConfig();
1061 EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type)
1062 << "SetSendCodec without FEC should disable current FEC.";
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +00001063}
1064
pbos@webrtc.org38ce7d02014-07-16 08:01:38 +00001065TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) {
1066 std::vector<VideoCodec> codecs;
1067 codecs.push_back(kVp8Codec720p);
1068 ASSERT_TRUE(channel_->SetSendCodecs(codecs));
1069
1070 std::vector<webrtc::VideoStream> streams =
1071 AddSendStream()->GetVideoStreams();
1072 EXPECT_EQ(kVp8Codec720p.width, streams[0].width);
1073 EXPECT_EQ(kVp8Codec720p.height, streams[0].height);
1074
1075 codecs.clear();
1076 codecs.push_back(kVp8Codec360p);
1077 ASSERT_TRUE(channel_->SetSendCodecs(codecs));
1078 streams = fake_channel_->GetFakeCall()->GetVideoSendStreams()[0]
1079 ->GetVideoStreams();
1080 EXPECT_EQ(kVp8Codec360p.width, streams[0].width);
1081 EXPECT_EQ(kVp8Codec360p.height, streams[0].height);
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +00001082}
1083
1084TEST_F(WebRtcVideoChannel2Test,
1085 DISABLED_ConstrainsSetCodecsAccordingToEncoderConfig) {
1086 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1087}
1088
1089TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMinMaxBitrate) {
1090 SetSendCodecsShouldWorkForBitrates("10", "20");
1091}
1092
1093TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) {
pbos@webrtc.org9fbb7172014-06-13 09:34:13 +00001094 std::vector<VideoCodec> video_codecs = engine_.codecs();
1095 video_codecs[0].params[kCodecParamMinBitrate] = "30";
1096 video_codecs[0].params[kCodecParamMaxBitrate] = "20";
1097 EXPECT_FALSE(channel_->SetSendCodecs(video_codecs));
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +00001098}
1099
1100TEST_F(WebRtcVideoChannel2Test, SetSendCodecsAcceptLargeMinMaxBitrate) {
1101 SetSendCodecsShouldWorkForBitrates("1000", "2000");
1102}
1103
1104TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) {
1105 static const char* kMaxQuantization = "21";
1106 std::vector<VideoCodec> codecs;
1107 codecs.push_back(kVp8Codec);
1108 codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization;
1109 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +00001110 EXPECT_EQ(static_cast<unsigned int>(atoi(kMaxQuantization)),
1111 AddSendStream()->GetVideoStreams().back().max_qp);
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +00001112
1113 VideoCodec codec;
1114 EXPECT_TRUE(channel_->GetSendCodec(&codec));
1115 EXPECT_EQ(kMaxQuantization, codec.params[kCodecParamMaxQuantization]);
1116}
1117
1118TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadDimensions) {
1119 std::vector<cricket::VideoCodec> codecs;
1120 codecs.push_back(kVp8Codec);
1121
1122 codecs[0].width = 0;
1123 EXPECT_FALSE(channel_->SetSendCodecs(codecs))
1124 << "Codec set though codec width is zero.";
1125
1126 codecs[0].width = kVp8Codec.width;
1127 codecs[0].height = 0;
1128 EXPECT_FALSE(channel_->SetSendCodecs(codecs))
1129 << "Codec set though codec height is zero.";
1130}
1131
1132TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadPayloadTypes) {
1133 // TODO(pbos): Should we only allow the dynamic range?
1134 static const size_t kNumIncorrectPayloads = 4;
1135 static const int kIncorrectPayloads[kNumIncorrectPayloads] = {-2, -1, 128,
1136 129};
1137 std::vector<cricket::VideoCodec> codecs;
1138 codecs.push_back(kVp8Codec);
1139 for (size_t i = 0; i < kNumIncorrectPayloads; ++i) {
1140 int payload_type = kIncorrectPayloads[i];
1141 codecs[0].id = payload_type;
1142 EXPECT_FALSE(channel_->SetSendCodecs(codecs))
1143 << "Bad payload type '" << payload_type << "' accepted.";
1144 }
1145}
1146
1147TEST_F(WebRtcVideoChannel2Test, SetSendCodecsAcceptAllValidPayloadTypes) {
1148 std::vector<cricket::VideoCodec> codecs;
1149 codecs.push_back(kVp8Codec);
1150 for (int payload_type = 0; payload_type <= 127; ++payload_type) {
1151 codecs[0].id = payload_type;
1152 EXPECT_TRUE(channel_->SetSendCodecs(codecs))
1153 << "Payload type '" << payload_type << "' rejected.";
1154 }
1155}
1156
1157TEST_F(WebRtcVideoChannel2Test, DISABLED_ResetVieSendCodecOnNewFrameSize) {
1158 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1159}
1160
1161TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) {
1162 std::vector<cricket::VideoCodec> codecs;
1163 codecs.push_back(kVp8Codec);
1164 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1165}
1166
pbos@webrtc.orge322a172014-06-13 11:47:28 +00001167// Test that we set our inbound RTX codecs properly.
1168TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) {
1169 std::vector<cricket::VideoCodec> codecs;
1170 codecs.push_back(kVp8Codec);
1171 cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0);
1172 codecs.push_back(rtx_codec);
1173 EXPECT_FALSE(channel_->SetRecvCodecs(codecs))
1174 << "RTX codec without associated payload should be rejected.";
1175
1176 codecs[1].SetParam("apt", kVp8Codec.id + 1);
1177 EXPECT_FALSE(channel_->SetRecvCodecs(codecs))
1178 << "RTX codec with invalid associated payload type should be rejected.";
1179
1180 codecs[1].SetParam("apt", kVp8Codec.id);
1181 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1182
1183 cricket::VideoCodec rtx_codec2(97, "rtx", 0, 0, 0, 0);
1184 rtx_codec2.SetParam("apt", rtx_codec.id);
1185 codecs.push_back(rtx_codec2);
1186
1187 EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) << "RTX codec with another RTX "
1188 "as associated payload type "
1189 "should be rejected.";
1190}
1191
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +00001192TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentPayloadType) {
1193 std::vector<cricket::VideoCodec> codecs;
1194 codecs.push_back(kVp8Codec);
1195 codecs[0].id = 99;
1196 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1197}
1198
pbos@webrtc.orgccbed3b2014-07-11 13:02:54 +00001199TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) {
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +00001200 EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs()));
pbos@webrtc.orgccbed3b2014-07-11 13:02:54 +00001201
1202 FakeVideoReceiveStream* stream = AddRecvStream();
1203 webrtc::VideoReceiveStream::Config config = stream->GetConfig();
1204 EXPECT_STREQ(engine_.codecs()[0].name.c_str(), config.codecs[0].plName);
1205 EXPECT_EQ(engine_.codecs()[0].id, config.codecs[0].plType);
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +00001206}
1207
1208TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) {
1209 std::vector<VideoCodec> codecs;
1210 codecs.push_back(kVp8Codec);
1211 codecs.push_back(VideoCodec(101, "WTF3", 640, 400, 30, 0));
1212 EXPECT_FALSE(channel_->SetRecvCodecs(codecs));
1213}
1214
1215// TODO(pbos): Enable VP9 through external codec support
1216TEST_F(WebRtcVideoChannel2Test,
1217 DISABLED_SetRecvCodecsAcceptsMultipleVideoCodecs) {
1218 std::vector<VideoCodec> codecs;
1219 codecs.push_back(kVp8Codec);
1220 codecs.push_back(kVp9Codec);
1221 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1222}
1223
1224TEST_F(WebRtcVideoChannel2Test,
1225 DISABLED_SetRecvCodecsSetsFecForAllVideoCodecs) {
1226 std::vector<VideoCodec> codecs;
1227 codecs.push_back(kVp8Codec);
1228 codecs.push_back(kVp9Codec);
1229 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1230 FAIL(); // TODO(pbos): Verify that the FEC parameters are set for all codecs.
1231}
1232
pbos@webrtc.org269605c2014-06-26 08:49:03 +00001233TEST_F(WebRtcVideoChannel2Test, DISABLED_SetRecvCodecsWithoutFecDisablesFec) {
1234 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1235}
1236
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +00001237TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectDuplicateFecPayloads) {
1238 std::vector<VideoCodec> codecs;
1239 codecs.push_back(kVp8Codec);
1240 codecs.push_back(kRedCodec);
1241 codecs[1].id = codecs[0].id;
1242 EXPECT_FALSE(channel_->SetRecvCodecs(codecs));
1243}
1244
1245TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectDuplicateCodecPayloads) {
1246 std::vector<VideoCodec> codecs;
1247 codecs.push_back(kVp8Codec);
1248 codecs.push_back(kVp9Codec);
1249 codecs[1].id = codecs[0].id;
1250 EXPECT_FALSE(channel_->SetRecvCodecs(codecs));
1251}
1252
1253TEST_F(WebRtcVideoChannel2Test,
1254 SetRecvCodecsAcceptSameCodecOnMultiplePayloadTypes) {
1255 std::vector<VideoCodec> codecs;
1256 codecs.push_back(kVp8Codec);
1257 codecs.push_back(kVp8Codec);
1258 codecs[1].id += 1;
1259 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
1260}
1261
1262TEST_F(WebRtcVideoChannel2Test, SendStreamNotSendingByDefault) {
1263 EXPECT_FALSE(AddSendStream()->IsSending());
1264}
1265
1266TEST_F(WebRtcVideoChannel2Test, DISABLED_ReceiveStreamReceivingByDefault) {
1267 // Is this test correct though? Auto-receive? Enable receive on first packet?
1268 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1269}
1270
1271TEST_F(WebRtcVideoChannel2Test, SetSend) {
pbos@webrtc.org5301b0f2014-07-17 08:51:46 +00001272 FakeVideoSendStream* stream = AddSendStream();
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +00001273 EXPECT_FALSE(stream->IsSending());
1274
1275 // false->true
1276 EXPECT_TRUE(channel_->SetSend(true));
1277 EXPECT_TRUE(stream->IsSending());
1278 // true->true
1279 EXPECT_TRUE(channel_->SetSend(true));
1280 EXPECT_TRUE(stream->IsSending());
1281 // true->false
1282 EXPECT_TRUE(channel_->SetSend(false));
1283 EXPECT_FALSE(stream->IsSending());
1284 // false->false
1285 EXPECT_TRUE(channel_->SetSend(false));
1286 EXPECT_FALSE(stream->IsSending());
1287
1288 EXPECT_TRUE(channel_->SetSend(true));
1289 FakeVideoSendStream* new_stream = AddSendStream();
1290 EXPECT_TRUE(new_stream->IsSending())
1291 << "Send stream created after SetSend(true) not sending initially.";
1292}
1293
1294TEST_F(WebRtcVideoChannel2Test, DISABLED_SendAndReceiveVp8Vga) {
1295 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1296}
1297
1298TEST_F(WebRtcVideoChannel2Test, DISABLED_SendAndReceiveVp8Qvga) {
1299 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1300}
1301
1302TEST_F(WebRtcVideoChannel2Test, DISABLED_SendAndReceiveH264SvcQqvga) {
1303 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1304}
1305
1306TEST_F(WebRtcVideoChannel2Test, DISABLED_SendManyResizeOnce) {
1307 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1308}
1309
1310TEST_F(WebRtcVideoChannel2Test, DISABLED_SendVp8HdAndReceiveAdaptedVp8Vga) {
1311 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1312}
1313
1314TEST_F(WebRtcVideoChannel2Test, DISABLED_TestSetDscpOptions) {
1315 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1316}
1317
1318TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsWithMaxBitrate) {
1319 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1320}
1321
1322TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsWithLoweredBitrate) {
1323 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1324}
1325
1326TEST_F(WebRtcVideoChannel2Test, DISABLED_SetOptionsSucceedsWhenSending) {
1327 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1328}
1329
1330TEST_F(WebRtcVideoChannel2Test, DISABLED_ResetCodecOnScreencast) {
1331 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1332}
1333
1334TEST_F(WebRtcVideoChannel2Test, DISABLED_DontResetCodecOnSendFrame) {
1335 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1336}
1337
1338TEST_F(WebRtcVideoChannel2Test,
1339 DISABLED_DontRegisterDecoderIfFactoryIsNotGiven) {
1340 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1341}
1342
1343TEST_F(WebRtcVideoChannel2Test, DISABLED_RegisterDecoderIfFactoryIsGiven) {
1344 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1345}
1346
1347TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterDecoderMultipleTimes) {
1348 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1349}
1350
1351TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterDecoderForNonVP8) {
1352 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1353}
1354
1355TEST_F(WebRtcVideoChannel2Test,
1356 DISABLED_DontRegisterEncoderIfFactoryIsNotGiven) {
1357 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1358}
1359
1360TEST_F(WebRtcVideoChannel2Test, DISABLED_RegisterEncoderIfFactoryIsGiven) {
1361 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1362}
1363
1364TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterEncoderMultipleTimes) {
1365 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1366}
1367
1368TEST_F(WebRtcVideoChannel2Test,
1369 DISABLED_RegisterEncoderWithMultipleSendStreams) {
1370 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1371}
1372
1373TEST_F(WebRtcVideoChannel2Test, DISABLED_DontRegisterEncoderForNonVP8) {
1374 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1375}
1376
1377TEST_F(WebRtcVideoChannel2Test, DISABLED_FeedbackParamsForNonVP8) {
1378 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1379}
1380
1381TEST_F(WebRtcVideoChannel2Test, DISABLED_ExternalCodecAddedToTheEnd) {
1382 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1383}
1384
1385TEST_F(WebRtcVideoChannel2Test, DISABLED_ExternalCodecIgnored) {
1386 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1387}
1388
1389TEST_F(WebRtcVideoChannel2Test, DISABLED_UpdateEncoderCodecsAfterSetFactory) {
1390 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1391}
1392
1393TEST_F(WebRtcVideoChannel2Test, DISABLED_OnReadyToSend) {
1394 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1395}
1396
1397TEST_F(WebRtcVideoChannel2Test, DISABLED_CaptureFrameTimestampToNtpTimestamp) {
1398 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1399}
1400} // namespace cricket