OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifdef HAVE_WEBRTC_VIDEO | 11 #ifdef HAVE_WEBRTC_VIDEO |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <map> | 14 #include <map> |
| 15 #include <memory> |
15 #include <vector> | 16 #include <vector> |
16 | 17 |
17 #include "webrtc/base/arraysize.h" | 18 #include "webrtc/base/arraysize.h" |
18 #include "webrtc/base/gunit.h" | 19 #include "webrtc/base/gunit.h" |
19 #include "webrtc/base/stringutils.h" | 20 #include "webrtc/base/stringutils.h" |
20 #include "webrtc/media/base/testutils.h" | 21 #include "webrtc/media/base/testutils.h" |
21 #include "webrtc/media/base/videoengine_unittest.h" | 22 #include "webrtc/media/base/videoengine_unittest.h" |
22 #include "webrtc/media/engine/fakewebrtccall.h" | 23 #include "webrtc/media/engine/fakewebrtccall.h" |
23 #include "webrtc/media/engine/fakewebrtcvideoengine.h" | 24 #include "webrtc/media/engine/fakewebrtcvideoengine.h" |
24 #include "webrtc/media/engine/simulcast.h" | 25 #include "webrtc/media/engine/simulcast.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 135 |
135 VideoMediaChannel* SetUpForExternalDecoderFactory( | 136 VideoMediaChannel* SetUpForExternalDecoderFactory( |
136 cricket::WebRtcVideoDecoderFactory* decoder_factory, | 137 cricket::WebRtcVideoDecoderFactory* decoder_factory, |
137 const std::vector<VideoCodec>& codecs); | 138 const std::vector<VideoCodec>& codecs); |
138 | 139 |
139 void TestExtendedEncoderOveruse(bool use_external_encoder); | 140 void TestExtendedEncoderOveruse(bool use_external_encoder); |
140 | 141 |
141 webrtc::test::ScopedFieldTrials override_field_trials_; | 142 webrtc::test::ScopedFieldTrials override_field_trials_; |
142 // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly | 143 // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly |
143 // initialized when the constructor is called. | 144 // initialized when the constructor is called. |
144 rtc::scoped_ptr<webrtc::Call> call_; | 145 std::unique_ptr<webrtc::Call> call_; |
145 WebRtcVoiceEngine voice_engine_; | 146 WebRtcVoiceEngine voice_engine_; |
146 WebRtcVideoEngine2 engine_; | 147 WebRtcVideoEngine2 engine_; |
147 VideoCodec default_codec_; | 148 VideoCodec default_codec_; |
148 VideoCodec default_red_codec_; | 149 VideoCodec default_red_codec_; |
149 VideoCodec default_ulpfec_codec_; | 150 VideoCodec default_ulpfec_codec_; |
150 std::map<int, int> default_apt_rtx_types_; | 151 std::map<int, int> default_apt_rtx_types_; |
151 }; | 152 }; |
152 | 153 |
153 TEST_F(WebRtcVideoEngine2Test, DefaultRtxCodecHasAssociatedPayloadTypeSet) { | 154 TEST_F(WebRtcVideoEngine2Test, DefaultRtxCodecHasAssociatedPayloadTypeSet) { |
154 std::vector<VideoCodec> engine_codecs = engine_.codecs(); | 155 std::vector<VideoCodec> engine_codecs = engine_.codecs(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionBeforeCapturer) { | 224 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionBeforeCapturer) { |
224 // Allocate the capturer first to prevent early destruction before channel's | 225 // Allocate the capturer first to prevent early destruction before channel's |
225 // dtor is called. | 226 // dtor is called. |
226 cricket::FakeVideoCapturer capturer; | 227 cricket::FakeVideoCapturer capturer; |
227 | 228 |
228 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 229 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
229 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 230 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
230 cricket::VideoSendParameters parameters; | 231 cricket::VideoSendParameters parameters; |
231 parameters.codecs.push_back(kVp8Codec); | 232 parameters.codecs.push_back(kVp8Codec); |
232 | 233 |
233 rtc::scoped_ptr<VideoMediaChannel> channel( | 234 std::unique_ptr<VideoMediaChannel> channel( |
234 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); | 235 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); |
235 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); | 236 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); |
236 | 237 |
237 // Add CVO extension. | 238 // Add CVO extension. |
238 const int id = 1; | 239 const int id = 1; |
239 parameters.extensions.push_back( | 240 parameters.extensions.push_back( |
240 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); | 241 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); |
241 EXPECT_TRUE(channel->SetSendParameters(parameters)); | 242 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
242 | 243 |
243 // Set capturer. | 244 // Set capturer. |
244 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); | 245 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); |
245 | 246 |
246 // Verify capturer has turned off applying rotation. | 247 // Verify capturer has turned off applying rotation. |
247 EXPECT_FALSE(capturer.GetApplyRotation()); | 248 EXPECT_FALSE(capturer.GetApplyRotation()); |
248 | 249 |
249 // Verify removing header extension turns on applying rotation. | 250 // Verify removing header extension turns on applying rotation. |
250 parameters.extensions.clear(); | 251 parameters.extensions.clear(); |
251 EXPECT_TRUE(channel->SetSendParameters(parameters)); | 252 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
252 EXPECT_TRUE(capturer.GetApplyRotation()); | 253 EXPECT_TRUE(capturer.GetApplyRotation()); |
253 } | 254 } |
254 | 255 |
255 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionAfterCapturer) { | 256 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionAfterCapturer) { |
256 cricket::FakeVideoCapturer capturer; | 257 cricket::FakeVideoCapturer capturer; |
257 | 258 |
258 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 259 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
259 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 260 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
260 cricket::VideoSendParameters parameters; | 261 cricket::VideoSendParameters parameters; |
261 parameters.codecs.push_back(kVp8Codec); | 262 parameters.codecs.push_back(kVp8Codec); |
262 | 263 |
263 rtc::scoped_ptr<VideoMediaChannel> channel( | 264 std::unique_ptr<VideoMediaChannel> channel( |
264 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); | 265 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); |
265 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); | 266 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); |
266 | 267 |
267 // Set capturer. | 268 // Set capturer. |
268 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); | 269 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); |
269 | 270 |
270 // Add CVO extension. | 271 // Add CVO extension. |
271 const int id = 1; | 272 const int id = 1; |
272 parameters.extensions.push_back( | 273 parameters.extensions.push_back( |
273 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); | 274 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); |
274 EXPECT_TRUE(channel->SetSendParameters(parameters)); | 275 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
275 | 276 |
276 // Verify capturer has turned off applying rotation. | 277 // Verify capturer has turned off applying rotation. |
277 EXPECT_FALSE(capturer.GetApplyRotation()); | 278 EXPECT_FALSE(capturer.GetApplyRotation()); |
278 | 279 |
279 // Verify removing header extension turns on applying rotation. | 280 // Verify removing header extension turns on applying rotation. |
280 parameters.extensions.clear(); | 281 parameters.extensions.clear(); |
281 EXPECT_TRUE(channel->SetSendParameters(parameters)); | 282 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
282 EXPECT_TRUE(capturer.GetApplyRotation()); | 283 EXPECT_TRUE(capturer.GetApplyRotation()); |
283 } | 284 } |
284 | 285 |
285 TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) { | 286 TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) { |
286 engine_.Init(); | 287 engine_.Init(); |
287 rtc::scoped_ptr<VideoMediaChannel> channel( | 288 std::unique_ptr<VideoMediaChannel> channel( |
288 engine_.CreateChannel(call_.get(), MediaConfig(), VideoOptions())); | 289 engine_.CreateChannel(call_.get(), MediaConfig(), VideoOptions())); |
289 | 290 |
290 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); | 291 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); |
291 | 292 |
292 EXPECT_FALSE(channel->SetSend(true)) | 293 EXPECT_FALSE(channel->SetSend(true)) |
293 << "Channel should not start without codecs."; | 294 << "Channel should not start without codecs."; |
294 EXPECT_TRUE(channel->SetSend(false)) | 295 EXPECT_TRUE(channel->SetSend(false)) |
295 << "Channel should be stoppable even without set codecs."; | 296 << "Channel should be stoppable even without set codecs."; |
296 } | 297 } |
297 | 298 |
298 TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) { | 299 TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) { |
299 engine_.Init(); | 300 engine_.Init(); |
300 rtc::scoped_ptr<VideoMediaChannel> channel( | 301 std::unique_ptr<VideoMediaChannel> channel( |
301 engine_.CreateChannel(call_.get(), MediaConfig(), VideoOptions())); | 302 engine_.CreateChannel(call_.get(), MediaConfig(), VideoOptions())); |
302 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); | 303 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); |
303 VideoMediaInfo info; | 304 VideoMediaInfo info; |
304 channel->GetStats(&info); | 305 channel->GetStats(&info); |
305 } | 306 } |
306 | 307 |
307 TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) { | 308 TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) { |
308 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 309 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
309 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 310 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
310 cricket::VideoSendParameters parameters; | 311 cricket::VideoSendParameters parameters; |
311 parameters.codecs.push_back(kVp8Codec); | 312 parameters.codecs.push_back(kVp8Codec); |
312 | 313 |
313 rtc::scoped_ptr<VideoMediaChannel> channel( | 314 std::unique_ptr<VideoMediaChannel> channel( |
314 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); | 315 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); |
315 | 316 |
316 EXPECT_TRUE( | 317 EXPECT_TRUE( |
317 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 318 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
318 ASSERT_EQ(1u, encoder_factory.encoders().size()); | 319 ASSERT_EQ(1u, encoder_factory.encoders().size()); |
319 EXPECT_TRUE(channel->SetSend(true)); | 320 EXPECT_TRUE(channel->SetSend(true)); |
320 | 321 |
321 cricket::FakeVideoCapturer capturer; | 322 cricket::FakeVideoCapturer capturer; |
322 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); | 323 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); |
323 EXPECT_EQ(cricket::CS_RUNNING, | 324 EXPECT_EQ(cricket::CS_RUNNING, |
(...skipping 16 matching lines...) Expand all Loading... |
340 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); | 341 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); |
341 EXPECT_EQ(0u, encoder_factory.encoders().size()); | 342 EXPECT_EQ(0u, encoder_factory.encoders().size()); |
342 } | 343 } |
343 | 344 |
344 void WebRtcVideoEngine2Test::TestExtendedEncoderOveruse( | 345 void WebRtcVideoEngine2Test::TestExtendedEncoderOveruse( |
345 bool use_external_encoder) { | 346 bool use_external_encoder) { |
346 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 347 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
347 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 348 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
348 cricket::VideoSendParameters parameters; | 349 cricket::VideoSendParameters parameters; |
349 parameters.codecs.push_back(kVp8Codec); | 350 parameters.codecs.push_back(kVp8Codec); |
350 rtc::scoped_ptr<VideoMediaChannel> channel; | 351 std::unique_ptr<VideoMediaChannel> channel; |
351 FakeCall* fake_call = new FakeCall(webrtc::Call::Config()); | 352 FakeCall* fake_call = new FakeCall(webrtc::Call::Config()); |
352 call_.reset(fake_call); | 353 call_.reset(fake_call); |
353 if (use_external_encoder) { | 354 if (use_external_encoder) { |
354 channel.reset( | 355 channel.reset( |
355 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); | 356 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); |
356 } else { | 357 } else { |
357 engine_.Init(); | 358 engine_.Init(); |
358 channel.reset( | 359 channel.reset( |
359 engine_.CreateChannel(call_.get(), MediaConfig(), VideoOptions())); | 360 engine_.CreateChannel(call_.get(), MediaConfig(), VideoOptions())); |
360 } | 361 } |
(...skipping 16 matching lines...) Expand all Loading... |
377 TEST_F(WebRtcVideoEngine2Test, DisablesFullEncoderTimeForNonExternalEncoders) { | 378 TEST_F(WebRtcVideoEngine2Test, DisablesFullEncoderTimeForNonExternalEncoders) { |
378 TestExtendedEncoderOveruse(false); | 379 TestExtendedEncoderOveruse(false); |
379 } | 380 } |
380 | 381 |
381 TEST_F(WebRtcVideoEngine2Test, CanConstructDecoderForVp9EncoderFactory) { | 382 TEST_F(WebRtcVideoEngine2Test, CanConstructDecoderForVp9EncoderFactory) { |
382 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 383 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
383 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9"); | 384 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9"); |
384 std::vector<cricket::VideoCodec> codecs; | 385 std::vector<cricket::VideoCodec> codecs; |
385 codecs.push_back(kVp9Codec); | 386 codecs.push_back(kVp9Codec); |
386 | 387 |
387 rtc::scoped_ptr<VideoMediaChannel> channel( | 388 std::unique_ptr<VideoMediaChannel> channel( |
388 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 389 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
389 | 390 |
390 EXPECT_TRUE( | 391 EXPECT_TRUE( |
391 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 392 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
392 } | 393 } |
393 | 394 |
394 TEST_F(WebRtcVideoEngine2Test, PropagatesInputFrameTimestamp) { | 395 TEST_F(WebRtcVideoEngine2Test, PropagatesInputFrameTimestamp) { |
395 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 396 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
396 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 397 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
397 std::vector<cricket::VideoCodec> codecs; | 398 std::vector<cricket::VideoCodec> codecs; |
398 codecs.push_back(kVp8Codec); | 399 codecs.push_back(kVp8Codec); |
399 | 400 |
400 FakeCall* fake_call = new FakeCall(webrtc::Call::Config()); | 401 FakeCall* fake_call = new FakeCall(webrtc::Call::Config()); |
401 call_.reset(fake_call); | 402 call_.reset(fake_call); |
402 rtc::scoped_ptr<VideoMediaChannel> channel( | 403 std::unique_ptr<VideoMediaChannel> channel( |
403 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 404 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
404 | 405 |
405 EXPECT_TRUE( | 406 EXPECT_TRUE( |
406 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 407 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
407 | 408 |
408 FakeVideoCapturer capturer; | 409 FakeVideoCapturer capturer; |
409 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); | 410 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); |
410 capturer.Start(cricket::VideoFormat(1280, 720, | 411 capturer.Start(cricket::VideoFormat(1280, 720, |
411 cricket::VideoFormat::FpsToInterval(60), | 412 cricket::VideoFormat::FpsToInterval(60), |
412 cricket::FOURCC_I420)); | 413 cricket::FOURCC_I420)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 453 |
453 TEST_F(WebRtcVideoEngine2Test, | 454 TEST_F(WebRtcVideoEngine2Test, |
454 ProducesIncreasingTimestampsWithResetInputSources) { | 455 ProducesIncreasingTimestampsWithResetInputSources) { |
455 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 456 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
456 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 457 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
457 std::vector<cricket::VideoCodec> codecs; | 458 std::vector<cricket::VideoCodec> codecs; |
458 codecs.push_back(kVp8Codec); | 459 codecs.push_back(kVp8Codec); |
459 | 460 |
460 FakeCall* fake_call = new FakeCall(webrtc::Call::Config()); | 461 FakeCall* fake_call = new FakeCall(webrtc::Call::Config()); |
461 call_.reset(fake_call); | 462 call_.reset(fake_call); |
462 rtc::scoped_ptr<VideoMediaChannel> channel( | 463 std::unique_ptr<VideoMediaChannel> channel( |
463 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 464 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
464 | 465 |
465 EXPECT_TRUE( | 466 EXPECT_TRUE( |
466 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 467 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
467 channel->SetSend(true); | 468 channel->SetSend(true); |
468 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0]; | 469 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0]; |
469 | 470 |
470 FakeVideoCapturer capturer1; | 471 FakeVideoCapturer capturer1; |
471 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer1)); | 472 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer1)); |
472 | 473 |
473 cricket::CapturedFrame frame; | 474 cricket::CapturedFrame frame; |
474 frame.width = 1280; | 475 frame.width = 1280; |
475 frame.height = 720; | 476 frame.height = 720; |
476 frame.fourcc = cricket::FOURCC_I420; | 477 frame.fourcc = cricket::FOURCC_I420; |
477 frame.data_size = frame.width * frame.height + | 478 frame.data_size = frame.width * frame.height + |
478 2 * ((frame.width + 1) / 2) * ((frame.height + 1) / 2); | 479 2 * ((frame.width + 1) / 2) * ((frame.height + 1) / 2); |
479 rtc::scoped_ptr<char[]> data(new char[frame.data_size]); | 480 std::unique_ptr<char[]> data(new char[frame.data_size]); |
480 frame.data = data.get(); | 481 frame.data = data.get(); |
481 memset(frame.data, 1, frame.data_size); | 482 memset(frame.data, 1, frame.data_size); |
482 const int kInitialTimestamp = 123456; | 483 const int kInitialTimestamp = 123456; |
483 frame.time_stamp = kInitialTimestamp; | 484 frame.time_stamp = kInitialTimestamp; |
484 | 485 |
485 // Deliver initial frame. | 486 // Deliver initial frame. |
486 capturer1.SignalCapturedFrame(&frame); | 487 capturer1.SignalCapturedFrame(&frame); |
487 // Deliver next frame 1 second later. | 488 // Deliver next frame 1 second later. |
488 frame.time_stamp += rtc::kNumNanosecsPerSec; | 489 frame.time_stamp += rtc::kNumNanosecsPerSec; |
489 rtc::Thread::Current()->SleepMs(1000); | 490 rtc::Thread::Current()->SleepMs(1000); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 | 537 |
537 return channel; | 538 return channel; |
538 } | 539 } |
539 | 540 |
540 TEST_F(WebRtcVideoEngine2Test, UsesSimulcastAdapterForVp8Factories) { | 541 TEST_F(WebRtcVideoEngine2Test, UsesSimulcastAdapterForVp8Factories) { |
541 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 542 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
542 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 543 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
543 std::vector<cricket::VideoCodec> codecs; | 544 std::vector<cricket::VideoCodec> codecs; |
544 codecs.push_back(kVp8Codec); | 545 codecs.push_back(kVp8Codec); |
545 | 546 |
546 rtc::scoped_ptr<VideoMediaChannel> channel( | 547 std::unique_ptr<VideoMediaChannel> channel( |
547 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 548 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
548 | 549 |
549 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); | 550 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); |
550 | 551 |
551 EXPECT_TRUE( | 552 EXPECT_TRUE( |
552 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); | 553 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); |
553 EXPECT_TRUE(channel->SetSend(true)); | 554 EXPECT_TRUE(channel->SetSend(true)); |
554 | 555 |
555 cricket::FakeVideoCapturer capturer; | 556 cricket::FakeVideoCapturer capturer; |
556 EXPECT_TRUE(channel->SetCapturer(ssrcs.front(), &capturer)); | 557 EXPECT_TRUE(channel->SetCapturer(ssrcs.front(), &capturer)); |
(...skipping 19 matching lines...) Expand all Loading... |
576 channel.reset(); | 577 channel.reset(); |
577 ASSERT_EQ(0u, encoder_factory.encoders().size()); | 578 ASSERT_EQ(0u, encoder_factory.encoders().size()); |
578 } | 579 } |
579 | 580 |
580 TEST_F(WebRtcVideoEngine2Test, ChannelWithExternalH264CanChangeToInternalVp8) { | 581 TEST_F(WebRtcVideoEngine2Test, ChannelWithExternalH264CanChangeToInternalVp8) { |
581 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 582 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
582 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); | 583 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); |
583 std::vector<cricket::VideoCodec> codecs; | 584 std::vector<cricket::VideoCodec> codecs; |
584 codecs.push_back(kH264Codec); | 585 codecs.push_back(kH264Codec); |
585 | 586 |
586 rtc::scoped_ptr<VideoMediaChannel> channel( | 587 std::unique_ptr<VideoMediaChannel> channel( |
587 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 588 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
588 | 589 |
589 EXPECT_TRUE( | 590 EXPECT_TRUE( |
590 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 591 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
591 ASSERT_EQ(1u, encoder_factory.encoders().size()); | 592 ASSERT_EQ(1u, encoder_factory.encoders().size()); |
592 | 593 |
593 cricket::VideoSendParameters parameters; | 594 cricket::VideoSendParameters parameters; |
594 parameters.codecs.push_back(kVp8Codec); | 595 parameters.codecs.push_back(kVp8Codec); |
595 EXPECT_TRUE(channel->SetSendParameters(parameters)); | 596 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
596 ASSERT_EQ(0u, encoder_factory.encoders().size()); | 597 ASSERT_EQ(0u, encoder_factory.encoders().size()); |
597 } | 598 } |
598 | 599 |
599 TEST_F(WebRtcVideoEngine2Test, | 600 TEST_F(WebRtcVideoEngine2Test, |
600 DontUseExternalEncoderFactoryForUnsupportedCodecs) { | 601 DontUseExternalEncoderFactoryForUnsupportedCodecs) { |
601 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 602 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
602 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); | 603 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); |
603 std::vector<cricket::VideoCodec> codecs; | 604 std::vector<cricket::VideoCodec> codecs; |
604 codecs.push_back(kVp8Codec); | 605 codecs.push_back(kVp8Codec); |
605 | 606 |
606 rtc::scoped_ptr<VideoMediaChannel> channel( | 607 std::unique_ptr<VideoMediaChannel> channel( |
607 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 608 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
608 | 609 |
609 EXPECT_TRUE( | 610 EXPECT_TRUE( |
610 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 611 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
611 // Make sure DestroyVideoEncoder was called on the factory. | 612 // Make sure DestroyVideoEncoder was called on the factory. |
612 ASSERT_EQ(0u, encoder_factory.encoders().size()); | 613 ASSERT_EQ(0u, encoder_factory.encoders().size()); |
613 } | 614 } |
614 | 615 |
615 TEST_F(WebRtcVideoEngine2Test, | 616 TEST_F(WebRtcVideoEngine2Test, |
616 UsesSimulcastAdapterForVp8WithCombinedVP8AndH264Factory) { | 617 UsesSimulcastAdapterForVp8WithCombinedVP8AndH264Factory) { |
617 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 618 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
618 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 619 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
619 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); | 620 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); |
620 | 621 |
621 std::vector<cricket::VideoCodec> codecs; | 622 std::vector<cricket::VideoCodec> codecs; |
622 codecs.push_back(kVp8Codec); | 623 codecs.push_back(kVp8Codec); |
623 | 624 |
624 rtc::scoped_ptr<VideoMediaChannel> channel( | 625 std::unique_ptr<VideoMediaChannel> channel( |
625 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 626 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
626 | 627 |
627 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); | 628 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); |
628 | 629 |
629 EXPECT_TRUE( | 630 EXPECT_TRUE( |
630 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); | 631 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); |
631 EXPECT_TRUE(channel->SetSend(true)); | 632 EXPECT_TRUE(channel->SetSend(true)); |
632 | 633 |
633 // Send a fake frame, or else the media engine will configure the simulcast | 634 // Send a fake frame, or else the media engine will configure the simulcast |
634 // encoder adapter at a low-enough size that it'll only create a single | 635 // encoder adapter at a low-enough size that it'll only create a single |
(...skipping 15 matching lines...) Expand all Loading... |
650 | 651 |
651 TEST_F(WebRtcVideoEngine2Test, | 652 TEST_F(WebRtcVideoEngine2Test, |
652 DestroysNonSimulcastEncoderFromCombinedVP8AndH264Factory) { | 653 DestroysNonSimulcastEncoderFromCombinedVP8AndH264Factory) { |
653 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 654 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
654 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 655 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
655 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); | 656 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); |
656 | 657 |
657 std::vector<cricket::VideoCodec> codecs; | 658 std::vector<cricket::VideoCodec> codecs; |
658 codecs.push_back(kH264Codec); | 659 codecs.push_back(kH264Codec); |
659 | 660 |
660 rtc::scoped_ptr<VideoMediaChannel> channel( | 661 std::unique_ptr<VideoMediaChannel> channel( |
661 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 662 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
662 | 663 |
663 EXPECT_TRUE( | 664 EXPECT_TRUE( |
664 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 665 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
665 ASSERT_EQ(1u, encoder_factory.encoders().size()); | 666 ASSERT_EQ(1u, encoder_factory.encoders().size()); |
666 EXPECT_EQ(webrtc::kVideoCodecH264, | 667 EXPECT_EQ(webrtc::kVideoCodecH264, |
667 encoder_factory.encoders()[0]->GetCodecSettings().codecType); | 668 encoder_factory.encoders()[0]->GetCodecSettings().codecType); |
668 | 669 |
669 channel.reset(); | 670 channel.reset(); |
670 // Make sure DestroyVideoEncoder was called on the factory. | 671 // Make sure DestroyVideoEncoder was called on the factory. |
671 ASSERT_EQ(0u, encoder_factory.encoders().size()); | 672 ASSERT_EQ(0u, encoder_factory.encoders().size()); |
672 } | 673 } |
673 | 674 |
674 TEST_F(WebRtcVideoEngine2Test, SimulcastDisabledForH264) { | 675 TEST_F(WebRtcVideoEngine2Test, SimulcastDisabledForH264) { |
675 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 676 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
676 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); | 677 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); |
677 std::vector<cricket::VideoCodec> codecs; | 678 std::vector<cricket::VideoCodec> codecs; |
678 codecs.push_back(kH264Codec); | 679 codecs.push_back(kH264Codec); |
679 | 680 |
680 rtc::scoped_ptr<VideoMediaChannel> channel( | 681 std::unique_ptr<VideoMediaChannel> channel( |
681 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 682 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
682 | 683 |
683 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); | 684 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); |
684 EXPECT_TRUE( | 685 EXPECT_TRUE( |
685 channel->AddSendStream(cricket::CreateSimStreamParams("cname", ssrcs))); | 686 channel->AddSendStream(cricket::CreateSimStreamParams("cname", ssrcs))); |
686 | 687 |
687 // Send a frame of 720p. This should trigger a "real" encoder initialization. | 688 // Send a frame of 720p. This should trigger a "real" encoder initialization. |
688 cricket::VideoFormat format( | 689 cricket::VideoFormat format( |
689 1280, 720, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420); | 690 1280, 720, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420); |
690 cricket::FakeVideoCapturer capturer; | 691 cricket::FakeVideoCapturer capturer; |
(...skipping 25 matching lines...) Expand all Loading... |
716 EXPECT_EQ("VP8", internal_codec.name); | 717 EXPECT_EQ("VP8", internal_codec.name); |
717 EXPECT_EQ("FakeExternalCodec", external_codec.name); | 718 EXPECT_EQ("FakeExternalCodec", external_codec.name); |
718 } | 719 } |
719 | 720 |
720 TEST_F(WebRtcVideoEngine2Test, RegisterExternalDecodersIfSupported) { | 721 TEST_F(WebRtcVideoEngine2Test, RegisterExternalDecodersIfSupported) { |
721 cricket::FakeWebRtcVideoDecoderFactory decoder_factory; | 722 cricket::FakeWebRtcVideoDecoderFactory decoder_factory; |
722 decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); | 723 decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); |
723 cricket::VideoRecvParameters parameters; | 724 cricket::VideoRecvParameters parameters; |
724 parameters.codecs.push_back(kVp8Codec); | 725 parameters.codecs.push_back(kVp8Codec); |
725 | 726 |
726 rtc::scoped_ptr<VideoMediaChannel> channel( | 727 std::unique_ptr<VideoMediaChannel> channel( |
727 SetUpForExternalDecoderFactory(&decoder_factory, parameters.codecs)); | 728 SetUpForExternalDecoderFactory(&decoder_factory, parameters.codecs)); |
728 | 729 |
729 EXPECT_TRUE( | 730 EXPECT_TRUE( |
730 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 731 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
731 ASSERT_EQ(1u, decoder_factory.decoders().size()); | 732 ASSERT_EQ(1u, decoder_factory.decoders().size()); |
732 | 733 |
733 // Setting codecs of the same type should not reallocate the decoder. | 734 // Setting codecs of the same type should not reallocate the decoder. |
734 EXPECT_TRUE(channel->SetRecvParameters(parameters)); | 735 EXPECT_TRUE(channel->SetRecvParameters(parameters)); |
735 EXPECT_EQ(1, decoder_factory.GetNumCreatedDecoders()); | 736 EXPECT_EQ(1, decoder_factory.GetNumCreatedDecoders()); |
736 | 737 |
737 // Remove stream previously added to free the external decoder instance. | 738 // Remove stream previously added to free the external decoder instance. |
738 EXPECT_TRUE(channel->RemoveRecvStream(kSsrc)); | 739 EXPECT_TRUE(channel->RemoveRecvStream(kSsrc)); |
739 EXPECT_EQ(0u, decoder_factory.decoders().size()); | 740 EXPECT_EQ(0u, decoder_factory.decoders().size()); |
740 } | 741 } |
741 | 742 |
742 // Verifies that we can set up decoders that are not internally supported. | 743 // Verifies that we can set up decoders that are not internally supported. |
743 TEST_F(WebRtcVideoEngine2Test, RegisterExternalH264DecoderIfSupported) { | 744 TEST_F(WebRtcVideoEngine2Test, RegisterExternalH264DecoderIfSupported) { |
744 // TODO(pbos): Do not assume that encoder/decoder support is symmetric. We | 745 // TODO(pbos): Do not assume that encoder/decoder support is symmetric. We |
745 // can't even query the WebRtcVideoDecoderFactory for supported codecs. | 746 // can't even query the WebRtcVideoDecoderFactory for supported codecs. |
746 // For now we add a FakeWebRtcVideoEncoderFactory to add H264 to supported | 747 // For now we add a FakeWebRtcVideoEncoderFactory to add H264 to supported |
747 // codecs. | 748 // codecs. |
748 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 749 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
749 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); | 750 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); |
750 engine_.SetExternalEncoderFactory(&encoder_factory); | 751 engine_.SetExternalEncoderFactory(&encoder_factory); |
751 cricket::FakeWebRtcVideoDecoderFactory decoder_factory; | 752 cricket::FakeWebRtcVideoDecoderFactory decoder_factory; |
752 decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264); | 753 decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264); |
753 std::vector<cricket::VideoCodec> codecs; | 754 std::vector<cricket::VideoCodec> codecs; |
754 codecs.push_back(kH264Codec); | 755 codecs.push_back(kH264Codec); |
755 | 756 |
756 rtc::scoped_ptr<VideoMediaChannel> channel( | 757 std::unique_ptr<VideoMediaChannel> channel( |
757 SetUpForExternalDecoderFactory(&decoder_factory, codecs)); | 758 SetUpForExternalDecoderFactory(&decoder_factory, codecs)); |
758 | 759 |
759 EXPECT_TRUE( | 760 EXPECT_TRUE( |
760 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 761 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
761 ASSERT_EQ(1u, decoder_factory.decoders().size()); | 762 ASSERT_EQ(1u, decoder_factory.decoders().size()); |
762 } | 763 } |
763 | 764 |
764 class WebRtcVideoChannel2BaseTest | 765 class WebRtcVideoChannel2BaseTest |
765 : public VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> { | 766 : public VideoMediaChannelTest<WebRtcVideoEngine2, WebRtcVideoChannel2> { |
766 protected: | 767 protected: |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset); | 1037 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset); |
1037 } | 1038 } |
1038 } | 1039 } |
1039 if (with_rtx) { | 1040 if (with_rtx) { |
1040 return AddSendStream( | 1041 return AddSendStream( |
1041 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); | 1042 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
1042 } | 1043 } |
1043 return AddSendStream(CreateSimStreamParams("cname", ssrcs)); | 1044 return AddSendStream(CreateSimStreamParams("cname", ssrcs)); |
1044 } | 1045 } |
1045 | 1046 |
1046 rtc::scoped_ptr<FakeCall> fake_call_; | 1047 std::unique_ptr<FakeCall> fake_call_; |
1047 rtc::scoped_ptr<VideoMediaChannel> channel_; | 1048 std::unique_ptr<VideoMediaChannel> channel_; |
1048 cricket::VideoSendParameters send_parameters_; | 1049 cricket::VideoSendParameters send_parameters_; |
1049 cricket::VideoRecvParameters recv_parameters_; | 1050 cricket::VideoRecvParameters recv_parameters_; |
1050 uint32_t last_ssrc_; | 1051 uint32_t last_ssrc_; |
1051 }; | 1052 }; |
1052 | 1053 |
1053 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { | 1054 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { |
1054 const uint32_t kVideoSsrc = 123; | 1055 const uint32_t kVideoSsrc = 123; |
1055 const std::string kSyncLabel = "AvSyncLabel"; | 1056 const std::string kSyncLabel = "AvSyncLabel"; |
1056 | 1057 |
1057 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc); | 1058 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc); |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2263 EXPECT_FALSE(stream->IsSending()); | 2264 EXPECT_FALSE(stream->IsSending()); |
2264 | 2265 |
2265 EXPECT_TRUE(channel_->SetSend(true)); | 2266 EXPECT_TRUE(channel_->SetSend(true)); |
2266 FakeVideoSendStream* new_stream = AddSendStream(); | 2267 FakeVideoSendStream* new_stream = AddSendStream(); |
2267 EXPECT_TRUE(new_stream->IsSending()) | 2268 EXPECT_TRUE(new_stream->IsSending()) |
2268 << "Send stream created after SetSend(true) not sending initially."; | 2269 << "Send stream created after SetSend(true) not sending initially."; |
2269 } | 2270 } |
2270 | 2271 |
2271 // This test verifies DSCP settings are properly applied on video media channel. | 2272 // This test verifies DSCP settings are properly applied on video media channel. |
2272 TEST_F(WebRtcVideoChannel2Test, TestSetDscpOptions) { | 2273 TEST_F(WebRtcVideoChannel2Test, TestSetDscpOptions) { |
2273 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface( | 2274 std::unique_ptr<cricket::FakeNetworkInterface> network_interface( |
2274 new cricket::FakeNetworkInterface); | 2275 new cricket::FakeNetworkInterface); |
2275 MediaConfig config; | 2276 MediaConfig config; |
2276 rtc::scoped_ptr<VideoMediaChannel> channel; | 2277 std::unique_ptr<VideoMediaChannel> channel; |
2277 | 2278 |
2278 channel.reset(engine_.CreateChannel(call_.get(), config, VideoOptions())); | 2279 channel.reset(engine_.CreateChannel(call_.get(), config, VideoOptions())); |
2279 channel->SetInterface(network_interface.get()); | 2280 channel->SetInterface(network_interface.get()); |
2280 // Default value when DSCP is disabled should be DSCP_DEFAULT. | 2281 // Default value when DSCP is disabled should be DSCP_DEFAULT. |
2281 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); | 2282 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); |
2282 | 2283 |
2283 config.enable_dscp = true; | 2284 config.enable_dscp = true; |
2284 channel.reset(engine_.CreateChannel(call_.get(), config, VideoOptions())); | 2285 channel.reset(engine_.CreateChannel(call_.get(), config, VideoOptions())); |
2285 channel->SetInterface(network_interface.get()); | 2286 channel->SetInterface(network_interface.get()); |
2286 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); | 2287 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3056 fake_call_.GetVideoReceiveStreams().size(); | 3057 fake_call_.GetVideoReceiveStreams().size(); |
3057 EXPECT_TRUE(channel_->AddRecvStream(sp)); | 3058 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
3058 std::vector<FakeVideoReceiveStream*> streams = | 3059 std::vector<FakeVideoReceiveStream*> streams = |
3059 fake_call_.GetVideoReceiveStreams(); | 3060 fake_call_.GetVideoReceiveStreams(); |
3060 EXPECT_EQ(num_streams + 1, streams.size()); | 3061 EXPECT_EQ(num_streams + 1, streams.size()); |
3061 return streams[streams.size() - 1]; | 3062 return streams[streams.size() - 1]; |
3062 } | 3063 } |
3063 | 3064 |
3064 FakeCall fake_call_; | 3065 FakeCall fake_call_; |
3065 WebRtcVideoEngine2 engine_; | 3066 WebRtcVideoEngine2 engine_; |
3066 rtc::scoped_ptr<VideoMediaChannel> channel_; | 3067 std::unique_ptr<VideoMediaChannel> channel_; |
3067 uint32_t last_ssrc_; | 3068 uint32_t last_ssrc_; |
3068 }; | 3069 }; |
3069 | 3070 |
3070 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { | 3071 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { |
3071 VerifySimulcastSettings(kVp8Codec, 2, 2); | 3072 VerifySimulcastSettings(kVp8Codec, 2, 2); |
3072 } | 3073 } |
3073 | 3074 |
3074 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { | 3075 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { |
3075 VerifySimulcastSettings(kVp8Codec720p, 3, 3); | 3076 VerifySimulcastSettings(kVp8Codec720p, 3, 3); |
3076 } | 3077 } |
3077 | 3078 |
3078 // Test that we normalize send codec format size in simulcast. | 3079 // Test that we normalize send codec format size in simulcast. |
3079 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 3080 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
3080 cricket::VideoCodec codec(kVp8Codec270p); | 3081 cricket::VideoCodec codec(kVp8Codec270p); |
3081 codec.width += 1; | 3082 codec.width += 1; |
3082 codec.height += 1; | 3083 codec.height += 1; |
3083 VerifySimulcastSettings(codec, 2, 2); | 3084 VerifySimulcastSettings(codec, 2, 2); |
3084 } | 3085 } |
3085 } // namespace cricket | 3086 } // namespace cricket |
3086 | 3087 |
3087 #endif // HAVE_WEBRTC_VIDEO | 3088 #endif // HAVE_WEBRTC_VIDEO |
OLD | NEW |