OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 FAIL() << "Video Rotation extension not in header-extension list."; | 270 FAIL() << "Video Rotation extension not in header-extension list."; |
271 } | 271 } |
272 | 272 |
273 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionBeforeCapturer) { | 273 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionBeforeCapturer) { |
274 // Allocate the capturer first to prevent early destruction before channel's | 274 // Allocate the capturer first to prevent early destruction before channel's |
275 // dtor is called. | 275 // dtor is called. |
276 cricket::FakeVideoCapturer capturer; | 276 cricket::FakeVideoCapturer capturer; |
277 | 277 |
278 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 278 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
279 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 279 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
280 std::vector<cricket::VideoCodec> codecs; | 280 cricket::VideoSendParameters parameters; |
281 codecs.push_back(kVp8Codec); | 281 parameters.codecs.push_back(kVp8Codec); |
282 | 282 |
283 rtc::scoped_ptr<VideoMediaChannel> channel( | 283 rtc::scoped_ptr<VideoMediaChannel> channel( |
284 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 284 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); |
285 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); | 285 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); |
286 | 286 |
287 // Add CVO extension. | 287 // Add CVO extension. |
288 const int id = 1; | 288 const int id = 1; |
289 std::vector<cricket::RtpHeaderExtension> extensions; | 289 parameters.extensions.push_back( |
290 extensions.push_back( | |
291 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); | 290 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); |
292 EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions)); | 291 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
293 | 292 |
294 // Set capturer. | 293 // Set capturer. |
295 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); | 294 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); |
296 | 295 |
297 // Verify capturer has turned off applying rotation. | 296 // Verify capturer has turned off applying rotation. |
298 EXPECT_FALSE(capturer.GetApplyRotation()); | 297 EXPECT_FALSE(capturer.GetApplyRotation()); |
299 | 298 |
300 // Verify removing header extension turns on applying rotation. | 299 // Verify removing header extension turns on applying rotation. |
301 extensions.clear(); | 300 parameters.extensions.clear(); |
302 EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions)); | 301 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
303 EXPECT_TRUE(capturer.GetApplyRotation()); | 302 EXPECT_TRUE(capturer.GetApplyRotation()); |
304 } | 303 } |
305 | 304 |
306 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionAfterCapturer) { | 305 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionAfterCapturer) { |
307 cricket::FakeVideoCapturer capturer; | 306 cricket::FakeVideoCapturer capturer; |
308 | 307 |
309 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 308 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
310 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 309 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
311 std::vector<cricket::VideoCodec> codecs; | 310 cricket::VideoSendParameters parameters; |
312 codecs.push_back(kVp8Codec); | 311 parameters.codecs.push_back(kVp8Codec); |
313 | 312 |
314 rtc::scoped_ptr<VideoMediaChannel> channel( | 313 rtc::scoped_ptr<VideoMediaChannel> channel( |
315 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 314 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); |
316 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); | 315 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); |
317 | 316 |
318 // Set capturer. | 317 // Set capturer. |
319 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); | 318 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); |
320 | 319 |
321 // Add CVO extension. | 320 // Add CVO extension. |
322 const int id = 1; | 321 const int id = 1; |
323 std::vector<cricket::RtpHeaderExtension> extensions; | 322 parameters.extensions.push_back( |
324 extensions.push_back( | |
325 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); | 323 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); |
326 EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions)); | 324 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
327 | 325 |
328 // Verify capturer has turned off applying rotation. | 326 // Verify capturer has turned off applying rotation. |
329 EXPECT_FALSE(capturer.GetApplyRotation()); | 327 EXPECT_FALSE(capturer.GetApplyRotation()); |
330 | 328 |
331 // Verify removing header extension turns on applying rotation. | 329 // Verify removing header extension turns on applying rotation. |
332 extensions.clear(); | 330 parameters.extensions.clear(); |
333 EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions)); | 331 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
334 EXPECT_TRUE(capturer.GetApplyRotation()); | 332 EXPECT_TRUE(capturer.GetApplyRotation()); |
335 } | 333 } |
336 | 334 |
337 TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) { | 335 TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) { |
338 engine_.Init(); | 336 engine_.Init(); |
339 rtc::scoped_ptr<VideoMediaChannel> channel( | 337 rtc::scoped_ptr<VideoMediaChannel> channel( |
340 engine_.CreateChannel(call_.get(), cricket::VideoOptions())); | 338 engine_.CreateChannel(call_.get(), cricket::VideoOptions())); |
341 | 339 |
342 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); | 340 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); |
343 | 341 |
344 EXPECT_FALSE(channel->SetSend(true)) | 342 EXPECT_FALSE(channel->SetSend(true)) |
345 << "Channel should not start without codecs."; | 343 << "Channel should not start without codecs."; |
346 EXPECT_TRUE(channel->SetSend(false)) | 344 EXPECT_TRUE(channel->SetSend(false)) |
347 << "Channel should be stoppable even without set codecs."; | 345 << "Channel should be stoppable even without set codecs."; |
348 } | 346 } |
349 | 347 |
350 TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) { | 348 TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) { |
351 engine_.Init(); | 349 engine_.Init(); |
352 rtc::scoped_ptr<VideoMediaChannel> channel( | 350 rtc::scoped_ptr<VideoMediaChannel> channel( |
353 engine_.CreateChannel(call_.get(), cricket::VideoOptions())); | 351 engine_.CreateChannel(call_.get(), cricket::VideoOptions())); |
354 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); | 352 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); |
355 VideoMediaInfo info; | 353 VideoMediaInfo info; |
356 channel->GetStats(&info); | 354 channel->GetStats(&info); |
357 } | 355 } |
358 | 356 |
359 TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) { | 357 TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) { |
360 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 358 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
361 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 359 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
362 std::vector<cricket::VideoCodec> codecs; | 360 cricket::VideoSendParameters parameters; |
363 codecs.push_back(kVp8Codec); | 361 parameters.codecs.push_back(kVp8Codec); |
364 | 362 |
365 rtc::scoped_ptr<VideoMediaChannel> channel( | 363 rtc::scoped_ptr<VideoMediaChannel> channel( |
366 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 364 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); |
367 | 365 |
368 EXPECT_TRUE( | 366 EXPECT_TRUE( |
369 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 367 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
370 ASSERT_EQ(1u, encoder_factory.encoders().size()); | 368 ASSERT_EQ(1u, encoder_factory.encoders().size()); |
371 EXPECT_TRUE(channel->SetSend(true)); | 369 EXPECT_TRUE(channel->SetSend(true)); |
372 | 370 |
373 cricket::FakeVideoCapturer capturer; | 371 cricket::FakeVideoCapturer capturer; |
374 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); | 372 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); |
375 EXPECT_EQ(cricket::CS_RUNNING, | 373 EXPECT_EQ(cricket::CS_RUNNING, |
376 capturer.Start(capturer.GetSupportedFormats()->front())); | 374 capturer.Start(capturer.GetSupportedFormats()->front())); |
377 EXPECT_TRUE(capturer.CaptureFrame()); | 375 EXPECT_TRUE(capturer.CaptureFrame()); |
378 EXPECT_TRUE_WAIT(encoder_factory.encoders()[0]->GetNumEncodedFrames() > 0, | 376 EXPECT_TRUE_WAIT(encoder_factory.encoders()[0]->GetNumEncodedFrames() > 0, |
379 kTimeout); | 377 kTimeout); |
380 | 378 |
381 // Sending one frame will have reallocated the encoder since input size | 379 // Sending one frame will have reallocated the encoder since input size |
382 // changes from a small default to the actual frame width/height. | 380 // changes from a small default to the actual frame width/height. |
383 int num_created_encoders = encoder_factory.GetNumCreatedEncoders(); | 381 int num_created_encoders = encoder_factory.GetNumCreatedEncoders(); |
384 EXPECT_EQ(num_created_encoders, 2); | 382 EXPECT_EQ(num_created_encoders, 2); |
385 | 383 |
386 // Setting codecs of the same type should not reallocate any encoders | 384 // Setting codecs of the same type should not reallocate any encoders |
387 // (expecting a no-op). | 385 // (expecting a no-op). |
388 EXPECT_TRUE(channel->SetSendCodecs(codecs)); | 386 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
389 EXPECT_EQ(num_created_encoders, encoder_factory.GetNumCreatedEncoders()); | 387 EXPECT_EQ(num_created_encoders, encoder_factory.GetNumCreatedEncoders()); |
390 | 388 |
391 // Remove stream previously added to free the external encoder instance. | 389 // Remove stream previously added to free the external encoder instance. |
392 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); | 390 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); |
393 EXPECT_EQ(0u, encoder_factory.encoders().size()); | 391 EXPECT_EQ(0u, encoder_factory.encoders().size()); |
394 } | 392 } |
395 | 393 |
396 TEST_F(WebRtcVideoEngine2Test, CanConstructDecoderForVp9EncoderFactory) { | 394 TEST_F(WebRtcVideoEngine2Test, CanConstructDecoderForVp9EncoderFactory) { |
397 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 395 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
398 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9"); | 396 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9"); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 } | 522 } |
525 | 523 |
526 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( | 524 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( |
527 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 525 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
528 const std::vector<VideoCodec>& codecs) { | 526 const std::vector<VideoCodec>& codecs) { |
529 engine_.SetExternalEncoderFactory(encoder_factory); | 527 engine_.SetExternalEncoderFactory(encoder_factory); |
530 engine_.Init(); | 528 engine_.Init(); |
531 | 529 |
532 VideoMediaChannel* channel = | 530 VideoMediaChannel* channel = |
533 engine_.CreateChannel(call_.get(), cricket::VideoOptions()); | 531 engine_.CreateChannel(call_.get(), cricket::VideoOptions()); |
534 EXPECT_TRUE(channel->SetSendCodecs(codecs)); | 532 cricket::VideoSendParameters parameters; |
| 533 parameters.codecs = codecs; |
| 534 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
535 | 535 |
536 return channel; | 536 return channel; |
537 } | 537 } |
538 | 538 |
539 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalDecoderFactory( | 539 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalDecoderFactory( |
540 cricket::WebRtcVideoDecoderFactory* decoder_factory, | 540 cricket::WebRtcVideoDecoderFactory* decoder_factory, |
541 const std::vector<VideoCodec>& codecs) { | 541 const std::vector<VideoCodec>& codecs) { |
542 engine_.SetExternalDecoderFactory(decoder_factory); | 542 engine_.SetExternalDecoderFactory(decoder_factory); |
543 engine_.Init(); | 543 engine_.Init(); |
544 | 544 |
545 VideoMediaChannel* channel = | 545 VideoMediaChannel* channel = |
546 engine_.CreateChannel(call_.get(), cricket::VideoOptions()); | 546 engine_.CreateChannel(call_.get(), cricket::VideoOptions()); |
547 EXPECT_TRUE(channel->SetRecvCodecs(codecs)); | 547 cricket::VideoRecvParameters parameters; |
| 548 parameters.codecs = codecs; |
| 549 EXPECT_TRUE(channel->SetRecvParameters(parameters)); |
548 | 550 |
549 return channel; | 551 return channel; |
550 } | 552 } |
551 | 553 |
552 TEST_F(WebRtcVideoEngine2Test, UsesSimulcastAdapterForVp8Factories) { | 554 TEST_F(WebRtcVideoEngine2Test, UsesSimulcastAdapterForVp8Factories) { |
553 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 555 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
554 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 556 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
555 std::vector<cricket::VideoCodec> codecs; | 557 std::vector<cricket::VideoCodec> codecs; |
556 codecs.push_back(kVp8Codec); | 558 codecs.push_back(kVp8Codec); |
557 | 559 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 std::vector<cricket::VideoCodec> codecs; | 597 std::vector<cricket::VideoCodec> codecs; |
596 codecs.push_back(kH264Codec); | 598 codecs.push_back(kH264Codec); |
597 | 599 |
598 rtc::scoped_ptr<VideoMediaChannel> channel( | 600 rtc::scoped_ptr<VideoMediaChannel> channel( |
599 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 601 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
600 | 602 |
601 EXPECT_TRUE( | 603 EXPECT_TRUE( |
602 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 604 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
603 ASSERT_EQ(1u, encoder_factory.encoders().size()); | 605 ASSERT_EQ(1u, encoder_factory.encoders().size()); |
604 | 606 |
605 codecs.clear(); | 607 cricket::VideoSendParameters parameters; |
606 codecs.push_back(kVp8Codec); | 608 parameters.codecs.push_back(kVp8Codec); |
607 EXPECT_TRUE(channel->SetSendCodecs(codecs)); | 609 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
608 | |
609 ASSERT_EQ(0u, encoder_factory.encoders().size()); | 610 ASSERT_EQ(0u, encoder_factory.encoders().size()); |
610 } | 611 } |
611 | 612 |
612 TEST_F(WebRtcVideoEngine2Test, | 613 TEST_F(WebRtcVideoEngine2Test, |
613 DontUseExternalEncoderFactoryForUnsupportedCodecs) { | 614 DontUseExternalEncoderFactoryForUnsupportedCodecs) { |
614 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 615 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
615 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); | 616 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); |
616 std::vector<cricket::VideoCodec> codecs; | 617 std::vector<cricket::VideoCodec> codecs; |
617 codecs.push_back(kVp8Codec); | 618 codecs.push_back(kVp8Codec); |
618 | 619 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 cricket::VideoCodec external_codec = codecs.back(); | 721 cricket::VideoCodec external_codec = codecs.back(); |
721 | 722 |
722 // The external codec will appear at last. | 723 // The external codec will appear at last. |
723 EXPECT_EQ("VP8", internal_codec.name); | 724 EXPECT_EQ("VP8", internal_codec.name); |
724 EXPECT_EQ("H264", external_codec.name); | 725 EXPECT_EQ("H264", external_codec.name); |
725 } | 726 } |
726 | 727 |
727 TEST_F(WebRtcVideoEngine2Test, RegisterExternalDecodersIfSupported) { | 728 TEST_F(WebRtcVideoEngine2Test, RegisterExternalDecodersIfSupported) { |
728 cricket::FakeWebRtcVideoDecoderFactory decoder_factory; | 729 cricket::FakeWebRtcVideoDecoderFactory decoder_factory; |
729 decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); | 730 decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); |
730 std::vector<cricket::VideoCodec> codecs; | 731 cricket::VideoRecvParameters parameters; |
731 codecs.push_back(kVp8Codec); | 732 parameters.codecs.push_back(kVp8Codec); |
732 | 733 |
733 rtc::scoped_ptr<VideoMediaChannel> channel( | 734 rtc::scoped_ptr<VideoMediaChannel> channel( |
734 SetUpForExternalDecoderFactory(&decoder_factory, codecs)); | 735 SetUpForExternalDecoderFactory(&decoder_factory, parameters.codecs)); |
735 | 736 |
736 EXPECT_TRUE( | 737 EXPECT_TRUE( |
737 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 738 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
738 ASSERT_EQ(1u, decoder_factory.decoders().size()); | 739 ASSERT_EQ(1u, decoder_factory.decoders().size()); |
739 | 740 |
740 // Setting codecs of the same type should not reallocate the decoder. | 741 // Setting codecs of the same type should not reallocate the decoder. |
741 EXPECT_TRUE(channel->SetRecvCodecs(codecs)); | 742 EXPECT_TRUE(channel->SetRecvParameters(parameters)); |
742 EXPECT_EQ(1, decoder_factory.GetNumCreatedDecoders()); | 743 EXPECT_EQ(1, decoder_factory.GetNumCreatedDecoders()); |
743 | 744 |
744 // Remove stream previously added to free the external decoder instance. | 745 // Remove stream previously added to free the external decoder instance. |
745 EXPECT_TRUE(channel->RemoveRecvStream(kSsrc)); | 746 EXPECT_TRUE(channel->RemoveRecvStream(kSsrc)); |
746 EXPECT_EQ(0u, decoder_factory.decoders().size()); | 747 EXPECT_EQ(0u, decoder_factory.decoders().size()); |
747 } | 748 } |
748 | 749 |
749 // Verifies that we can set up decoders that are not internally supported. | 750 // Verifies that we can set up decoders that are not internally supported. |
750 TEST_F(WebRtcVideoEngine2Test, RegisterExternalH264DecoderIfSupported) { | 751 TEST_F(WebRtcVideoEngine2Test, RegisterExternalH264DecoderIfSupported) { |
751 // TODO(pbos): Do not assume that encoder/decoder support is symmetric. We | 752 // TODO(pbos): Do not assume that encoder/decoder support is symmetric. We |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 | 897 |
897 class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { | 898 class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { |
898 public: | 899 public: |
899 WebRtcVideoChannel2Test() : last_ssrc_(0) {} | 900 WebRtcVideoChannel2Test() : last_ssrc_(0) {} |
900 void SetUp() override { | 901 void SetUp() override { |
901 fake_call_.reset(new FakeCall(webrtc::Call::Config())); | 902 fake_call_.reset(new FakeCall(webrtc::Call::Config())); |
902 engine_.Init(); | 903 engine_.Init(); |
903 channel_.reset( | 904 channel_.reset( |
904 engine_.CreateChannel(fake_call_.get(), cricket::VideoOptions())); | 905 engine_.CreateChannel(fake_call_.get(), cricket::VideoOptions())); |
905 last_ssrc_ = 123; | 906 last_ssrc_ = 123; |
906 ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs())); | 907 send_parameters_.codecs = engine_.codecs(); |
| 908 recv_parameters_.codecs = engine_.codecs(); |
| 909 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); |
907 } | 910 } |
908 | 911 |
909 protected: | 912 protected: |
910 virtual std::vector<cricket::VideoCodec> GetCodecs() { | 913 virtual std::vector<cricket::VideoCodec> GetCodecs() { |
911 return engine_.codecs(); | 914 return engine_.codecs(); |
912 } | 915 } |
913 | 916 |
914 FakeVideoSendStream* AddSendStream() { | 917 FakeVideoSendStream* AddSendStream() { |
915 return AddSendStream(StreamParams::CreateLegacy(++last_ssrc_)); | 918 return AddSendStream(StreamParams::CreateLegacy(++last_ssrc_)); |
916 } | 919 } |
(...skipping 23 matching lines...) Expand all Loading... |
940 EXPECT_EQ(num_streams + 1, streams.size()); | 943 EXPECT_EQ(num_streams + 1, streams.size()); |
941 return streams[streams.size() - 1]; | 944 return streams[streams.size() - 1]; |
942 } | 945 } |
943 | 946 |
944 void SetSendCodecsShouldWorkForBitrates(const char* min_bitrate_kbps, | 947 void SetSendCodecsShouldWorkForBitrates(const char* min_bitrate_kbps, |
945 int expected_min_bitrate_bps, | 948 int expected_min_bitrate_bps, |
946 const char* start_bitrate_kbps, | 949 const char* start_bitrate_kbps, |
947 int expected_start_bitrate_bps, | 950 int expected_start_bitrate_bps, |
948 const char* max_bitrate_kbps, | 951 const char* max_bitrate_kbps, |
949 int expected_max_bitrate_bps) { | 952 int expected_max_bitrate_bps) { |
950 std::vector<VideoCodec> codecs; | 953 auto& codecs = send_parameters_.codecs; |
| 954 codecs.clear(); |
951 codecs.push_back(kVp8Codec); | 955 codecs.push_back(kVp8Codec); |
952 codecs[0].params[kCodecParamMinBitrate] = min_bitrate_kbps; | 956 codecs[0].params[kCodecParamMinBitrate] = min_bitrate_kbps; |
953 codecs[0].params[kCodecParamStartBitrate] = start_bitrate_kbps; | 957 codecs[0].params[kCodecParamStartBitrate] = start_bitrate_kbps; |
954 codecs[0].params[kCodecParamMaxBitrate] = max_bitrate_kbps; | 958 codecs[0].params[kCodecParamMaxBitrate] = max_bitrate_kbps; |
955 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); | 959 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
956 | 960 |
957 EXPECT_EQ(expected_min_bitrate_bps, | 961 EXPECT_EQ(expected_min_bitrate_bps, |
958 fake_call_->GetConfig().bitrate_config.min_bitrate_bps); | 962 fake_call_->GetConfig().bitrate_config.min_bitrate_bps); |
959 EXPECT_EQ(expected_start_bitrate_bps, | 963 EXPECT_EQ(expected_start_bitrate_bps, |
960 fake_call_->GetConfig().bitrate_config.start_bitrate_bps); | 964 fake_call_->GetConfig().bitrate_config.start_bitrate_bps); |
961 EXPECT_EQ(expected_max_bitrate_bps, | 965 EXPECT_EQ(expected_max_bitrate_bps, |
962 fake_call_->GetConfig().bitrate_config.max_bitrate_bps); | 966 fake_call_->GetConfig().bitrate_config.max_bitrate_bps); |
963 } | 967 } |
964 | 968 |
965 void TestSetSendRtpHeaderExtensions(const std::string& cricket_ext, | 969 void TestSetSendRtpHeaderExtensions(const std::string& cricket_ext, |
966 const std::string& webrtc_ext) { | 970 const std::string& webrtc_ext) { |
967 // Enable extension. | 971 // Enable extension. |
968 const int id = 1; | 972 const int id = 1; |
969 std::vector<cricket::RtpHeaderExtension> extensions; | 973 cricket::VideoSendParameters parameters = send_parameters_; |
970 extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id)); | 974 parameters.extensions.push_back( |
971 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); | 975 cricket::RtpHeaderExtension(cricket_ext, id)); |
972 | 976 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
973 FakeVideoSendStream* send_stream = | 977 FakeVideoSendStream* send_stream = |
974 AddSendStream(cricket::StreamParams::CreateLegacy(123)); | 978 AddSendStream(cricket::StreamParams::CreateLegacy(123)); |
975 | 979 |
976 // Verify the send extension id. | 980 // Verify the send extension id. |
977 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); | 981 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); |
978 EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); | 982 EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); |
979 EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name); | 983 EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name); |
980 // Verify call with same set of extensions returns true. | 984 // Verify call with same set of extensions returns true. |
981 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); | 985 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
982 // Verify that SetSendRtpHeaderExtensions doesn't implicitly add them for | 986 // Verify that SetSendRtpHeaderExtensions doesn't implicitly add them for |
983 // receivers. | 987 // receivers. |
984 EXPECT_TRUE(AddRecvStream(cricket::StreamParams::CreateLegacy(123)) | 988 EXPECT_TRUE(AddRecvStream(cricket::StreamParams::CreateLegacy(123)) |
985 ->GetConfig() | 989 ->GetConfig() |
986 .rtp.extensions.empty()); | 990 .rtp.extensions.empty()); |
987 | 991 |
988 // Verify that existing RTP header extensions can be removed. | 992 // Verify that existing RTP header extensions can be removed. |
989 std::vector<cricket::RtpHeaderExtension> empty_extensions; | 993 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
990 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions)); | |
991 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); | 994 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); |
992 send_stream = fake_call_->GetVideoSendStreams()[0]; | 995 send_stream = fake_call_->GetVideoSendStreams()[0]; |
993 EXPECT_TRUE(send_stream->GetConfig().rtp.extensions.empty()); | 996 EXPECT_TRUE(send_stream->GetConfig().rtp.extensions.empty()); |
994 | 997 |
995 // Verify that adding receive RTP header extensions adds them for existing | 998 // Verify that adding receive RTP header extensions adds them for existing |
996 // streams. | 999 // streams. |
997 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); | 1000 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
998 send_stream = fake_call_->GetVideoSendStreams()[0]; | 1001 send_stream = fake_call_->GetVideoSendStreams()[0]; |
999 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); | 1002 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); |
1000 EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); | 1003 EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); |
1001 EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name); | 1004 EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name); |
1002 } | 1005 } |
1003 | 1006 |
1004 void TestSetRecvRtpHeaderExtensions(const std::string& cricket_ext, | 1007 void TestSetRecvRtpHeaderExtensions(const std::string& cricket_ext, |
1005 const std::string& webrtc_ext) { | 1008 const std::string& webrtc_ext) { |
1006 // Enable extension. | 1009 // Enable extension. |
1007 const int id = 1; | 1010 const int id = 1; |
1008 std::vector<cricket::RtpHeaderExtension> extensions; | 1011 cricket::VideoRecvParameters parameters = recv_parameters_; |
1009 extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id)); | 1012 parameters.extensions.push_back( |
1010 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); | 1013 cricket::RtpHeaderExtension(cricket_ext, id)); |
| 1014 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
1011 | 1015 |
1012 FakeVideoReceiveStream* recv_stream = | 1016 FakeVideoReceiveStream* recv_stream = |
1013 AddRecvStream(cricket::StreamParams::CreateLegacy(123)); | 1017 AddRecvStream(cricket::StreamParams::CreateLegacy(123)); |
1014 | 1018 |
1015 // Verify the recv extension id. | 1019 // Verify the recv extension id. |
1016 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); | 1020 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); |
1017 EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); | 1021 EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); |
1018 EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); | 1022 EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); |
1019 // Verify call with same set of extensions returns true. | 1023 // Verify call with same set of extensions returns true. |
1020 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); | 1024 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
1021 | 1025 |
1022 // Verify that SetRecvRtpHeaderExtensions doesn't implicitly add them for | 1026 // Verify that SetRecvRtpHeaderExtensions doesn't implicitly add them for |
1023 // senders. | 1027 // senders. |
1024 EXPECT_TRUE(AddSendStream(cricket::StreamParams::CreateLegacy(123)) | 1028 EXPECT_TRUE(AddSendStream(cricket::StreamParams::CreateLegacy(123)) |
1025 ->GetConfig() | 1029 ->GetConfig() |
1026 .rtp.extensions.empty()); | 1030 .rtp.extensions.empty()); |
1027 | 1031 |
1028 // Verify that existing RTP header extensions can be removed. | 1032 // Verify that existing RTP header extensions can be removed. |
1029 std::vector<cricket::RtpHeaderExtension> empty_extensions; | 1033 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
1030 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(empty_extensions)); | |
1031 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()); | 1034 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()); |
1032 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; | 1035 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; |
1033 EXPECT_TRUE(recv_stream->GetConfig().rtp.extensions.empty()); | 1036 EXPECT_TRUE(recv_stream->GetConfig().rtp.extensions.empty()); |
1034 | 1037 |
1035 // Verify that adding receive RTP header extensions adds them for existing | 1038 // Verify that adding receive RTP header extensions adds them for existing |
1036 // streams. | 1039 // streams. |
1037 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); | 1040 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
1038 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; | 1041 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; |
1039 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); | 1042 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); |
1040 EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); | 1043 EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); |
1041 EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); | 1044 EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); |
1042 } | 1045 } |
1043 | 1046 |
1044 void TestCpuAdaptation(bool enable_overuse, bool is_screenshare); | 1047 void TestCpuAdaptation(bool enable_overuse, bool is_screenshare); |
1045 void TestReceiverLocalSsrcConfiguration(bool receiver_first); | 1048 void TestReceiverLocalSsrcConfiguration(bool receiver_first); |
1046 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type, | 1049 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type, |
1047 bool expect_created_receive_stream); | 1050 bool expect_created_receive_stream); |
1048 | 1051 |
1049 FakeVideoSendStream* SetDenoisingOption(bool enabled) { | 1052 FakeVideoSendStream* SetDenoisingOption( |
1050 VideoOptions options; | 1053 const cricket::VideoSendParameters& parameters, bool enabled) { |
1051 options.video_noise_reduction.Set(enabled); | 1054 cricket::VideoSendParameters params = parameters; |
1052 channel_->SetOptions(options); | 1055 params.options.video_noise_reduction.Set(enabled); |
| 1056 channel_->SetSendParameters(params); |
1053 return fake_call_->GetVideoSendStreams().back(); | 1057 return fake_call_->GetVideoSendStreams().back(); |
1054 } | 1058 } |
1055 | 1059 |
1056 FakeVideoSendStream* SetUpSimulcast(bool enabled, bool with_rtx) { | 1060 FakeVideoSendStream* SetUpSimulcast(bool enabled, bool with_rtx) { |
1057 const int kRtxSsrcOffset = 0xDEADBEEF; | 1061 const int kRtxSsrcOffset = 0xDEADBEEF; |
1058 last_ssrc_ += 3; | 1062 last_ssrc_ += 3; |
1059 std::vector<uint32_t> ssrcs; | 1063 std::vector<uint32_t> ssrcs; |
1060 std::vector<uint32_t> rtx_ssrcs; | 1064 std::vector<uint32_t> rtx_ssrcs; |
1061 uint32_t num_streams = enabled ? 3 : 1; | 1065 uint32_t num_streams = enabled ? 3 : 1; |
1062 for (uint32_t i = 0; i < num_streams; ++i) { | 1066 for (uint32_t i = 0; i < num_streams; ++i) { |
1063 uint32_t ssrc = last_ssrc_ + i; | 1067 uint32_t ssrc = last_ssrc_ + i; |
1064 ssrcs.push_back(ssrc); | 1068 ssrcs.push_back(ssrc); |
1065 if (with_rtx) { | 1069 if (with_rtx) { |
1066 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset); | 1070 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset); |
1067 } | 1071 } |
1068 } | 1072 } |
1069 if (with_rtx) { | 1073 if (with_rtx) { |
1070 return AddSendStream( | 1074 return AddSendStream( |
1071 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); | 1075 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
1072 } | 1076 } |
1073 return AddSendStream(CreateSimStreamParams("cname", ssrcs)); | 1077 return AddSendStream(CreateSimStreamParams("cname", ssrcs)); |
1074 } | 1078 } |
1075 | 1079 |
1076 rtc::scoped_ptr<FakeCall> fake_call_; | 1080 rtc::scoped_ptr<FakeCall> fake_call_; |
1077 rtc::scoped_ptr<VideoMediaChannel> channel_; | 1081 rtc::scoped_ptr<VideoMediaChannel> channel_; |
| 1082 cricket::VideoSendParameters send_parameters_; |
| 1083 cricket::VideoRecvParameters recv_parameters_; |
1078 uint32 last_ssrc_; | 1084 uint32 last_ssrc_; |
1079 }; | 1085 }; |
1080 | 1086 |
1081 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { | 1087 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { |
1082 const uint32 kVideoSsrc = 123; | 1088 const uint32 kVideoSsrc = 123; |
1083 const std::string kSyncLabel = "AvSyncLabel"; | 1089 const std::string kSyncLabel = "AvSyncLabel"; |
1084 | 1090 |
1085 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc); | 1091 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc); |
1086 sp.sync_label = kSyncLabel; | 1092 sp.sync_label = kSyncLabel; |
1087 EXPECT_TRUE(channel_->AddRecvStream(sp)); | 1093 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
1088 | 1094 |
1089 EXPECT_EQ(1, fake_call_->GetVideoReceiveStreams().size()); | 1095 EXPECT_EQ(1, fake_call_->GetVideoReceiveStreams().size()); |
1090 EXPECT_EQ(kSyncLabel, | 1096 EXPECT_EQ(kSyncLabel, |
1091 fake_call_->GetVideoReceiveStreams()[0]->GetConfig().sync_group) | 1097 fake_call_->GetVideoReceiveStreams()[0]->GetConfig().sync_group) |
1092 << "SyncGroup should be set based on sync_label"; | 1098 << "SyncGroup should be set based on sync_label"; |
1093 } | 1099 } |
1094 | 1100 |
1095 TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) { | 1101 TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) { |
1096 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); | 1102 cricket::VideoSendParameters parameters; |
| 1103 parameters.codecs = engine_.codecs(); |
| 1104 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1097 EXPECT_TRUE(channel_->SetSend(true)); | 1105 EXPECT_TRUE(channel_->SetSend(true)); |
1098 cricket::VideoOptions options; | 1106 parameters.options.conference_mode.Set(true); |
1099 options.conference_mode.Set(true); | 1107 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1100 EXPECT_TRUE(channel_->SetOptions(options)); | |
1101 | 1108 |
1102 // Send side. | 1109 // Send side. |
1103 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); | 1110 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
1104 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); | 1111 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
1105 FakeVideoSendStream* send_stream = AddSendStream( | 1112 FakeVideoSendStream* send_stream = AddSendStream( |
1106 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); | 1113 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
1107 | 1114 |
1108 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size()); | 1115 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size()); |
1109 for (size_t i = 0; i < rtx_ssrcs.size(); ++i) | 1116 for (size_t i = 0; i < rtx_ssrcs.size(); ++i) |
1110 EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]); | 1117 EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 } | 1184 } |
1178 TEST_F(WebRtcVideoChannel2Test, RecvVideoRotationHeaderExtensions) { | 1185 TEST_F(WebRtcVideoChannel2Test, RecvVideoRotationHeaderExtensions) { |
1179 TestSetRecvRtpHeaderExtensions(kRtpVideoRotationHeaderExtension, | 1186 TestSetRecvRtpHeaderExtensions(kRtpVideoRotationHeaderExtension, |
1180 webrtc::RtpExtension::kVideoRotation); | 1187 webrtc::RtpExtension::kVideoRotation); |
1181 } | 1188 } |
1182 | 1189 |
1183 TEST_F(WebRtcVideoChannel2Test, IdenticalSendExtensionsDoesntRecreateStream) { | 1190 TEST_F(WebRtcVideoChannel2Test, IdenticalSendExtensionsDoesntRecreateStream) { |
1184 const int kTOffsetId = 1; | 1191 const int kTOffsetId = 1; |
1185 const int kAbsSendTimeId = 2; | 1192 const int kAbsSendTimeId = 2; |
1186 const int kVideoRotationId = 3; | 1193 const int kVideoRotationId = 3; |
1187 std::vector<cricket::RtpHeaderExtension> extensions; | 1194 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( |
1188 extensions.push_back(cricket::RtpHeaderExtension( | |
1189 kRtpAbsoluteSenderTimeHeaderExtension, kAbsSendTimeId)); | 1195 kRtpAbsoluteSenderTimeHeaderExtension, kAbsSendTimeId)); |
1190 extensions.push_back(cricket::RtpHeaderExtension( | 1196 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( |
1191 kRtpTimestampOffsetHeaderExtension, kTOffsetId)); | 1197 kRtpTimestampOffsetHeaderExtension, kTOffsetId)); |
1192 extensions.push_back(cricket::RtpHeaderExtension( | 1198 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( |
1193 kRtpVideoRotationHeaderExtension, kVideoRotationId)); | 1199 kRtpVideoRotationHeaderExtension, kVideoRotationId)); |
1194 | 1200 |
1195 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); | 1201 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
1196 FakeVideoSendStream* send_stream = | 1202 FakeVideoSendStream* send_stream = |
1197 AddSendStream(cricket::StreamParams::CreateLegacy(123)); | 1203 AddSendStream(cricket::StreamParams::CreateLegacy(123)); |
1198 | 1204 |
1199 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams()); | 1205 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams()); |
1200 ASSERT_EQ(3u, send_stream->GetConfig().rtp.extensions.size()); | 1206 ASSERT_EQ(3u, send_stream->GetConfig().rtp.extensions.size()); |
1201 | 1207 |
1202 // Setting the same extensions (even if in different order) shouldn't | 1208 // Setting the same extensions (even if in different order) shouldn't |
1203 // reallocate the stream. | 1209 // reallocate the stream. |
1204 std::reverse(extensions.begin(), extensions.end()); | 1210 std::reverse(send_parameters_.extensions.begin(), |
1205 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); | 1211 send_parameters_.extensions.end()); |
| 1212 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
1206 | 1213 |
1207 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams()); | 1214 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams()); |
1208 | 1215 |
1209 // Setting different extensions should recreate the stream. | 1216 // Setting different extensions should recreate the stream. |
1210 extensions.resize(1); | 1217 send_parameters_.extensions.resize(1); |
1211 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); | 1218 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
1212 | 1219 |
1213 EXPECT_EQ(2, fake_call_->GetNumCreatedSendStreams()); | 1220 EXPECT_EQ(2, fake_call_->GetNumCreatedSendStreams()); |
1214 } | 1221 } |
1215 | 1222 |
1216 TEST_F(WebRtcVideoChannel2Test, IdenticalRecvExtensionsDoesntRecreateStream) { | 1223 TEST_F(WebRtcVideoChannel2Test, IdenticalRecvExtensionsDoesntRecreateStream) { |
1217 const int kTOffsetId = 1; | 1224 const int kTOffsetId = 1; |
1218 const int kAbsSendTimeId = 2; | 1225 const int kAbsSendTimeId = 2; |
1219 const int kVideoRotationId = 3; | 1226 const int kVideoRotationId = 3; |
1220 std::vector<cricket::RtpHeaderExtension> extensions; | 1227 recv_parameters_.extensions.push_back(cricket::RtpHeaderExtension( |
1221 extensions.push_back(cricket::RtpHeaderExtension( | |
1222 kRtpAbsoluteSenderTimeHeaderExtension, kAbsSendTimeId)); | 1228 kRtpAbsoluteSenderTimeHeaderExtension, kAbsSendTimeId)); |
1223 extensions.push_back(cricket::RtpHeaderExtension( | 1229 recv_parameters_.extensions.push_back(cricket::RtpHeaderExtension( |
1224 kRtpTimestampOffsetHeaderExtension, kTOffsetId)); | 1230 kRtpTimestampOffsetHeaderExtension, kTOffsetId)); |
1225 extensions.push_back(cricket::RtpHeaderExtension( | 1231 recv_parameters_.extensions.push_back(cricket::RtpHeaderExtension( |
1226 kRtpVideoRotationHeaderExtension, kVideoRotationId)); | 1232 kRtpVideoRotationHeaderExtension, kVideoRotationId)); |
1227 | 1233 |
1228 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); | 1234 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
1229 FakeVideoReceiveStream* recv_stream = | 1235 FakeVideoReceiveStream* recv_stream = |
1230 AddRecvStream(cricket::StreamParams::CreateLegacy(123)); | 1236 AddRecvStream(cricket::StreamParams::CreateLegacy(123)); |
1231 | 1237 |
1232 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); | 1238 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); |
1233 ASSERT_EQ(3u, recv_stream->GetConfig().rtp.extensions.size()); | 1239 ASSERT_EQ(3u, recv_stream->GetConfig().rtp.extensions.size()); |
1234 | 1240 |
1235 // Setting the same extensions (even if in different order) shouldn't | 1241 // Setting the same extensions (even if in different order) shouldn't |
1236 // reallocate the stream. | 1242 // reallocate the stream. |
1237 std::reverse(extensions.begin(), extensions.end()); | 1243 std::reverse(recv_parameters_.extensions.begin(), |
1238 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); | 1244 recv_parameters_.extensions.end()); |
| 1245 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
1239 | 1246 |
1240 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); | 1247 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); |
1241 | 1248 |
1242 // Setting different extensions should recreate the stream. | 1249 // Setting different extensions should recreate the stream. |
1243 extensions.resize(1); | 1250 recv_parameters_.extensions.resize(1); |
1244 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); | 1251 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
1245 | 1252 |
1246 EXPECT_EQ(2, fake_call_->GetNumCreatedReceiveStreams()); | 1253 EXPECT_EQ(2, fake_call_->GetNumCreatedReceiveStreams()); |
1247 } | 1254 } |
1248 | 1255 |
1249 TEST_F(WebRtcVideoChannel2Test, | 1256 TEST_F(WebRtcVideoChannel2Test, |
1250 SetSendRtpHeaderExtensionsExcludeUnsupportedExtensions) { | 1257 SetSendRtpHeaderExtensionsExcludeUnsupportedExtensions) { |
1251 const int kUnsupportedId = 1; | 1258 const int kUnsupportedId = 1; |
1252 const int kTOffsetId = 2; | 1259 const int kTOffsetId = 2; |
1253 | 1260 |
1254 std::vector<cricket::RtpHeaderExtension> extensions; | 1261 send_parameters_.extensions.push_back( |
1255 extensions.push_back( | |
1256 cricket::RtpHeaderExtension(kUnsupportedExtensionName, kUnsupportedId)); | 1262 cricket::RtpHeaderExtension(kUnsupportedExtensionName, kUnsupportedId)); |
1257 extensions.push_back( | 1263 send_parameters_.extensions.push_back( |
1258 cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, kTOffsetId)); | 1264 cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, kTOffsetId)); |
1259 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); | 1265 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
1260 FakeVideoSendStream* send_stream = | 1266 FakeVideoSendStream* send_stream = |
1261 AddSendStream(cricket::StreamParams::CreateLegacy(123)); | 1267 AddSendStream(cricket::StreamParams::CreateLegacy(123)); |
1262 | 1268 |
1263 // Only timestamp offset extension is set to send stream, | 1269 // Only timestamp offset extension is set to send stream, |
1264 // unsupported rtp extension is ignored. | 1270 // unsupported rtp extension is ignored. |
1265 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); | 1271 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); |
1266 EXPECT_STREQ(webrtc::RtpExtension::kTOffset, | 1272 EXPECT_STREQ(webrtc::RtpExtension::kTOffset, |
1267 send_stream->GetConfig().rtp.extensions[0].name.c_str()); | 1273 send_stream->GetConfig().rtp.extensions[0].name.c_str()); |
1268 } | 1274 } |
1269 | 1275 |
1270 TEST_F(WebRtcVideoChannel2Test, | 1276 TEST_F(WebRtcVideoChannel2Test, |
1271 SetRecvRtpHeaderExtensionsExcludeUnsupportedExtensions) { | 1277 SetRecvRtpHeaderExtensionsExcludeUnsupportedExtensions) { |
1272 const int kUnsupportedId = 1; | 1278 const int kUnsupportedId = 1; |
1273 const int kTOffsetId = 2; | 1279 const int kTOffsetId = 2; |
1274 | 1280 |
1275 std::vector<cricket::RtpHeaderExtension> extensions; | 1281 recv_parameters_.extensions.push_back( |
1276 extensions.push_back( | |
1277 cricket::RtpHeaderExtension(kUnsupportedExtensionName, kUnsupportedId)); | 1282 cricket::RtpHeaderExtension(kUnsupportedExtensionName, kUnsupportedId)); |
1278 extensions.push_back( | 1283 recv_parameters_.extensions.push_back( |
1279 cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, kTOffsetId)); | 1284 cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, kTOffsetId)); |
1280 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); | 1285 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
1281 FakeVideoReceiveStream* recv_stream = | 1286 FakeVideoReceiveStream* recv_stream = |
1282 AddRecvStream(cricket::StreamParams::CreateLegacy(123)); | 1287 AddRecvStream(cricket::StreamParams::CreateLegacy(123)); |
1283 | 1288 |
1284 // Only timestamp offset extension is set to receive stream, | 1289 // Only timestamp offset extension is set to receive stream, |
1285 // unsupported rtp extension is ignored. | 1290 // unsupported rtp extension is ignored. |
1286 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); | 1291 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); |
1287 EXPECT_STREQ(webrtc::RtpExtension::kTOffset, | 1292 EXPECT_STREQ(webrtc::RtpExtension::kTOffset, |
1288 recv_stream->GetConfig().rtp.extensions[0].name.c_str()); | 1293 recv_stream->GetConfig().rtp.extensions[0].name.c_str()); |
1289 } | 1294 } |
1290 | 1295 |
1291 TEST_F(WebRtcVideoChannel2Test, SetSendRtpHeaderExtensionsRejectsIncorrectIds) { | 1296 TEST_F(WebRtcVideoChannel2Test, SetSendRtpHeaderExtensionsRejectsIncorrectIds) { |
1292 const int kIncorrectIds[] = {-2, -1, 0, 15, 16}; | 1297 const int kIncorrectIds[] = {-2, -1, 0, 15, 16}; |
1293 for (size_t i = 0; i < arraysize(kIncorrectIds); ++i) { | 1298 for (size_t i = 0; i < arraysize(kIncorrectIds); ++i) { |
1294 std::vector<cricket::RtpHeaderExtension> extensions; | 1299 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( |
1295 extensions.push_back(cricket::RtpHeaderExtension( | |
1296 webrtc::RtpExtension::kTOffset, kIncorrectIds[i])); | 1300 webrtc::RtpExtension::kTOffset, kIncorrectIds[i])); |
1297 EXPECT_FALSE(channel_->SetSendRtpHeaderExtensions(extensions)) | 1301 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)) |
1298 << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; | 1302 << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; |
1299 } | 1303 } |
1300 } | 1304 } |
1301 | 1305 |
1302 TEST_F(WebRtcVideoChannel2Test, SetRecvRtpHeaderExtensionsRejectsIncorrectIds) { | 1306 TEST_F(WebRtcVideoChannel2Test, SetRecvRtpHeaderExtensionsRejectsIncorrectIds) { |
1303 const int kIncorrectIds[] = {-2, -1, 0, 15, 16}; | 1307 const int kIncorrectIds[] = {-2, -1, 0, 15, 16}; |
1304 for (size_t i = 0; i < arraysize(kIncorrectIds); ++i) { | 1308 for (size_t i = 0; i < arraysize(kIncorrectIds); ++i) { |
1305 std::vector<cricket::RtpHeaderExtension> extensions; | 1309 recv_parameters_.extensions.push_back(cricket::RtpHeaderExtension( |
1306 extensions.push_back(cricket::RtpHeaderExtension( | |
1307 webrtc::RtpExtension::kTOffset, kIncorrectIds[i])); | 1310 webrtc::RtpExtension::kTOffset, kIncorrectIds[i])); |
1308 EXPECT_FALSE(channel_->SetRecvRtpHeaderExtensions(extensions)) | 1311 EXPECT_FALSE(channel_->SetRecvParameters(recv_parameters_)) |
1309 << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; | 1312 << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; |
1310 } | 1313 } |
1311 } | 1314 } |
1312 | 1315 |
1313 TEST_F(WebRtcVideoChannel2Test, SetSendRtpHeaderExtensionsRejectsDuplicateIds) { | 1316 TEST_F(WebRtcVideoChannel2Test, SetSendRtpHeaderExtensionsRejectsDuplicateIds) { |
1314 const int id = 1; | 1317 const int id = 1; |
1315 std::vector<cricket::RtpHeaderExtension> extensions; | 1318 send_parameters_.extensions.push_back( |
1316 extensions.push_back( | |
1317 cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); | 1319 cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); |
1318 extensions.push_back( | 1320 send_parameters_.extensions.push_back( |
1319 cricket::RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension, id)); | 1321 cricket::RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension, id)); |
1320 EXPECT_FALSE(channel_->SetSendRtpHeaderExtensions(extensions)); | 1322 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); |
1321 | 1323 |
1322 // Duplicate entries are also not supported. | 1324 // Duplicate entries are also not supported. |
1323 extensions.clear(); | 1325 send_parameters_.extensions.clear(); |
1324 extensions.push_back( | 1326 send_parameters_.extensions.push_back( |
1325 cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); | 1327 cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); |
1326 extensions.push_back(extensions.back()); | 1328 send_parameters_.extensions.push_back(send_parameters_.extensions.back()); |
1327 EXPECT_FALSE(channel_->SetSendRtpHeaderExtensions(extensions)); | 1329 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); |
1328 } | 1330 } |
1329 | 1331 |
1330 TEST_F(WebRtcVideoChannel2Test, SetRecvRtpHeaderExtensionsRejectsDuplicateIds) { | 1332 TEST_F(WebRtcVideoChannel2Test, SetRecvRtpHeaderExtensionsRejectsDuplicateIds) { |
1331 const int id = 1; | 1333 const int id = 1; |
1332 std::vector<cricket::RtpHeaderExtension> extensions; | 1334 recv_parameters_.extensions.push_back( |
1333 extensions.push_back( | |
1334 cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); | 1335 cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); |
1335 extensions.push_back( | 1336 recv_parameters_.extensions.push_back( |
1336 cricket::RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension, id)); | 1337 cricket::RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension, id)); |
1337 EXPECT_FALSE(channel_->SetRecvRtpHeaderExtensions(extensions)); | 1338 EXPECT_FALSE(channel_->SetRecvParameters(recv_parameters_)); |
1338 | 1339 |
1339 // Duplicate entries are also not supported. | 1340 // Duplicate entries are also not supported. |
1340 extensions.clear(); | 1341 recv_parameters_.extensions.clear(); |
1341 extensions.push_back( | 1342 recv_parameters_.extensions.push_back( |
1342 cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); | 1343 cricket::RtpHeaderExtension(webrtc::RtpExtension::kTOffset, id)); |
1343 extensions.push_back(extensions.back()); | 1344 recv_parameters_.extensions.push_back(recv_parameters_.extensions.back()); |
1344 EXPECT_FALSE(channel_->SetRecvRtpHeaderExtensions(extensions)); | 1345 EXPECT_FALSE(channel_->SetRecvParameters(recv_parameters_)); |
1345 } | 1346 } |
1346 | 1347 |
1347 TEST_F(WebRtcVideoChannel2Test, DISABLED_LeakyBucketTest) { | 1348 TEST_F(WebRtcVideoChannel2Test, DISABLED_LeakyBucketTest) { |
1348 FAIL() << "Not implemented."; // TODO(pbos): Implement. | 1349 FAIL() << "Not implemented."; // TODO(pbos): Implement. |
1349 } | 1350 } |
1350 | 1351 |
1351 TEST_F(WebRtcVideoChannel2Test, DISABLED_BufferedModeLatency) { | 1352 TEST_F(WebRtcVideoChannel2Test, DISABLED_BufferedModeLatency) { |
1352 FAIL() << "Not implemented."; // TODO(pbos): Implement. | 1353 FAIL() << "Not implemented."; // TODO(pbos): Implement. |
1353 } | 1354 } |
1354 | 1355 |
(...skipping 14 matching lines...) Expand all Loading... |
1369 TEST_F(WebRtcVideoChannel2Test, RembIsEnabledByDefault) { | 1370 TEST_F(WebRtcVideoChannel2Test, RembIsEnabledByDefault) { |
1370 FakeVideoReceiveStream* stream = AddRecvStream(); | 1371 FakeVideoReceiveStream* stream = AddRecvStream(); |
1371 EXPECT_TRUE(stream->GetConfig().rtp.remb); | 1372 EXPECT_TRUE(stream->GetConfig().rtp.remb); |
1372 } | 1373 } |
1373 | 1374 |
1374 TEST_F(WebRtcVideoChannel2Test, RembCanBeEnabledAndDisabled) { | 1375 TEST_F(WebRtcVideoChannel2Test, RembCanBeEnabledAndDisabled) { |
1375 FakeVideoReceiveStream* stream = AddRecvStream(); | 1376 FakeVideoReceiveStream* stream = AddRecvStream(); |
1376 EXPECT_TRUE(stream->GetConfig().rtp.remb); | 1377 EXPECT_TRUE(stream->GetConfig().rtp.remb); |
1377 | 1378 |
1378 // Verify that REMB is turned off when send(!) codecs without REMB are set. | 1379 // Verify that REMB is turned off when send(!) codecs without REMB are set. |
1379 std::vector<VideoCodec> codecs; | 1380 cricket::VideoSendParameters parameters; |
1380 codecs.push_back(kVp8Codec); | 1381 parameters.codecs.push_back(kVp8Codec); |
1381 EXPECT_TRUE(codecs[0].feedback_params.params().empty()); | 1382 EXPECT_TRUE(parameters.codecs[0].feedback_params.params().empty()); |
1382 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); | 1383 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1383 stream = fake_call_->GetVideoReceiveStreams()[0]; | 1384 stream = fake_call_->GetVideoReceiveStreams()[0]; |
1384 EXPECT_FALSE(stream->GetConfig().rtp.remb); | 1385 EXPECT_FALSE(stream->GetConfig().rtp.remb); |
1385 | 1386 |
1386 // Verify that REMB is turned on when setting default codecs since the | 1387 // Verify that REMB is turned on when setting default codecs since the |
1387 // default codecs have REMB enabled. | 1388 // default codecs have REMB enabled. |
1388 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); | 1389 parameters.codecs = engine_.codecs(); |
| 1390 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1389 stream = fake_call_->GetVideoReceiveStreams()[0]; | 1391 stream = fake_call_->GetVideoReceiveStreams()[0]; |
1390 EXPECT_TRUE(stream->GetConfig().rtp.remb); | 1392 EXPECT_TRUE(stream->GetConfig().rtp.remb); |
1391 } | 1393 } |
1392 | 1394 |
1393 TEST_F(WebRtcVideoChannel2Test, NackIsEnabledByDefault) { | 1395 TEST_F(WebRtcVideoChannel2Test, NackIsEnabledByDefault) { |
1394 VerifyCodecHasDefaultFeedbackParams(default_codec_); | 1396 VerifyCodecHasDefaultFeedbackParams(default_codec_); |
1395 | 1397 |
1396 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); | 1398 cricket::VideoSendParameters parameters; |
| 1399 parameters.codecs = engine_.codecs(); |
| 1400 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1397 EXPECT_TRUE(channel_->SetSend(true)); | 1401 EXPECT_TRUE(channel_->SetSend(true)); |
1398 | 1402 |
1399 // Send side. | 1403 // Send side. |
1400 FakeVideoSendStream* send_stream = | 1404 FakeVideoSendStream* send_stream = |
1401 AddSendStream(cricket::StreamParams::CreateLegacy(1)); | 1405 AddSendStream(cricket::StreamParams::CreateLegacy(1)); |
1402 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); | 1406 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
1403 | 1407 |
1404 // Receiver side. | 1408 // Receiver side. |
1405 FakeVideoReceiveStream* recv_stream = | 1409 FakeVideoReceiveStream* recv_stream = |
1406 AddRecvStream(cricket::StreamParams::CreateLegacy(1)); | 1410 AddRecvStream(cricket::StreamParams::CreateLegacy(1)); |
1407 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); | 1411 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
1408 | 1412 |
1409 // Nack history size should match between sender and receiver. | 1413 // Nack history size should match between sender and receiver. |
1410 EXPECT_EQ(send_stream->GetConfig().rtp.nack.rtp_history_ms, | 1414 EXPECT_EQ(send_stream->GetConfig().rtp.nack.rtp_history_ms, |
1411 recv_stream->GetConfig().rtp.nack.rtp_history_ms); | 1415 recv_stream->GetConfig().rtp.nack.rtp_history_ms); |
1412 } | 1416 } |
1413 | 1417 |
1414 TEST_F(WebRtcVideoChannel2Test, NackCanBeEnabledAndDisabled) { | 1418 TEST_F(WebRtcVideoChannel2Test, NackCanBeEnabledAndDisabled) { |
1415 FakeVideoSendStream* send_stream = AddSendStream(); | 1419 FakeVideoSendStream* send_stream = AddSendStream(); |
1416 FakeVideoReceiveStream* recv_stream = AddRecvStream(); | 1420 FakeVideoReceiveStream* recv_stream = AddRecvStream(); |
1417 | 1421 |
1418 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); | 1422 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
1419 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); | 1423 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
1420 | 1424 |
1421 // Verify that NACK is turned off when send(!) codecs without NACK are set. | 1425 // Verify that NACK is turned off when send(!) codecs without NACK are set. |
1422 std::vector<VideoCodec> codecs; | 1426 cricket::VideoSendParameters parameters; |
1423 codecs.push_back(kVp8Codec); | 1427 parameters.codecs.push_back(kVp8Codec); |
1424 EXPECT_TRUE(codecs[0].feedback_params.params().empty()); | 1428 EXPECT_TRUE(parameters.codecs[0].feedback_params.params().empty()); |
1425 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); | 1429 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1426 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; | 1430 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; |
1427 EXPECT_EQ(0, recv_stream->GetConfig().rtp.nack.rtp_history_ms); | 1431 EXPECT_EQ(0, recv_stream->GetConfig().rtp.nack.rtp_history_ms); |
1428 send_stream = fake_call_->GetVideoSendStreams()[0]; | 1432 send_stream = fake_call_->GetVideoSendStreams()[0]; |
1429 EXPECT_EQ(0, send_stream->GetConfig().rtp.nack.rtp_history_ms); | 1433 EXPECT_EQ(0, send_stream->GetConfig().rtp.nack.rtp_history_ms); |
1430 | 1434 |
1431 // Verify that NACK is turned on when setting default codecs since the | 1435 // Verify that NACK is turned on when setting default codecs since the |
1432 // default codecs have NACK enabled. | 1436 // default codecs have NACK enabled. |
1433 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); | 1437 parameters.codecs = engine_.codecs(); |
| 1438 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1434 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; | 1439 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; |
1435 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); | 1440 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
1436 send_stream = fake_call_->GetVideoSendStreams()[0]; | 1441 send_stream = fake_call_->GetVideoSendStreams()[0]; |
1437 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); | 1442 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
1438 } | 1443 } |
1439 | 1444 |
1440 TEST_F(WebRtcVideoChannel2Test, DISABLED_VideoProtectionInterop) { | 1445 TEST_F(WebRtcVideoChannel2Test, DISABLED_VideoProtectionInterop) { |
1441 FAIL() << "Not implemented."; // TODO(pbos): Implement. | 1446 FAIL() << "Not implemented."; // TODO(pbos): Implement. |
1442 } | 1447 } |
1443 | 1448 |
(...skipping 25 matching lines...) Expand all Loading... |
1469 FAIL() << "Not implemented."; // TODO(pbos): Implement. | 1474 FAIL() << "Not implemented."; // TODO(pbos): Implement. |
1470 } | 1475 } |
1471 | 1476 |
1472 TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthInConference) { | 1477 TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthInConference) { |
1473 FAIL() << "Not implemented."; // TODO(pbos): Implement. | 1478 FAIL() << "Not implemented."; // TODO(pbos): Implement. |
1474 } | 1479 } |
1475 | 1480 |
1476 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { | 1481 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { |
1477 static const int kScreenshareMinBitrateKbps = 800; | 1482 static const int kScreenshareMinBitrateKbps = 800; |
1478 cricket::VideoCodec codec = kVp8Codec360p; | 1483 cricket::VideoCodec codec = kVp8Codec360p; |
1479 std::vector<cricket::VideoCodec> codecs; | 1484 cricket::VideoSendParameters parameters; |
1480 codecs.push_back(codec); | 1485 parameters.codecs.push_back(codec); |
1481 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); | 1486 parameters.options.screencast_min_bitrate.Set(kScreenshareMinBitrateKbps); |
1482 VideoOptions options; | 1487 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1483 options.screencast_min_bitrate.Set(kScreenshareMinBitrateKbps); | |
1484 channel_->SetOptions(options); | |
1485 | 1488 |
1486 AddSendStream(); | 1489 AddSendStream(); |
1487 | 1490 |
1488 cricket::FakeVideoCapturer capturer; | 1491 cricket::FakeVideoCapturer capturer; |
1489 capturer.SetScreencast(false); | 1492 capturer.SetScreencast(false); |
1490 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 1493 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
1491 cricket::VideoFormat capture_format_hd = | 1494 cricket::VideoFormat capture_format_hd = |
1492 capturer.GetSupportedFormats()->front(); | 1495 capturer.GetSupportedFormats()->front(); |
1493 EXPECT_EQ(1280, capture_format_hd.width); | 1496 EXPECT_EQ(1280, capture_format_hd.width); |
1494 EXPECT_EQ(720, capture_format_hd.height); | 1497 EXPECT_EQ(720, capture_format_hd.height); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height); | 1530 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height); |
1528 EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty()); | 1531 EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty()); |
1529 | 1532 |
1530 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 1533 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
1531 } | 1534 } |
1532 | 1535 |
1533 TEST_F(WebRtcVideoChannel2Test, | 1536 TEST_F(WebRtcVideoChannel2Test, |
1534 ConferenceModeScreencastConfiguresTemporalLayer) { | 1537 ConferenceModeScreencastConfiguresTemporalLayer) { |
1535 static const int kConferenceScreencastTemporalBitrateBps = | 1538 static const int kConferenceScreencastTemporalBitrateBps = |
1536 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000; | 1539 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000; |
1537 VideoOptions options; | 1540 send_parameters_.options.conference_mode.Set(true); |
1538 options.conference_mode.Set(true); | 1541 channel_->SetSendParameters(send_parameters_); |
1539 channel_->SetOptions(options); | |
1540 | 1542 |
1541 AddSendStream(); | 1543 AddSendStream(); |
1542 | 1544 |
1543 cricket::FakeVideoCapturer capturer; | 1545 cricket::FakeVideoCapturer capturer; |
1544 capturer.SetScreencast(true); | 1546 capturer.SetScreencast(true); |
1545 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 1547 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
1546 cricket::VideoFormat capture_format_hd = | 1548 cricket::VideoFormat capture_format_hd = |
1547 capturer.GetSupportedFormats()->front(); | 1549 capturer.GetSupportedFormats()->front(); |
1548 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); | 1550 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); |
1549 | 1551 |
(...skipping 25 matching lines...) Expand all Loading... |
1575 DISABLED_SetSendSsrcAfterCreatingReceiveChannel) { | 1577 DISABLED_SetSendSsrcAfterCreatingReceiveChannel) { |
1576 FAIL() << "Not implemented."; // TODO(pbos): Implement. | 1578 FAIL() << "Not implemented."; // TODO(pbos): Implement. |
1577 } | 1579 } |
1578 | 1580 |
1579 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { | 1581 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { |
1580 FakeVideoSendStream* stream = AddSendStream(); | 1582 FakeVideoSendStream* stream = AddSendStream(); |
1581 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); | 1583 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); |
1582 } | 1584 } |
1583 | 1585 |
1584 TEST_F(WebRtcVideoChannel2Test, SetOptionsWithSuspendBelowMinBitrate) { | 1586 TEST_F(WebRtcVideoChannel2Test, SetOptionsWithSuspendBelowMinBitrate) { |
1585 VideoOptions options; | 1587 send_parameters_.options.suspend_below_min_bitrate.Set(true); |
1586 options.suspend_below_min_bitrate.Set(true); | 1588 channel_->SetSendParameters(send_parameters_); |
1587 channel_->SetOptions(options); | |
1588 | 1589 |
1589 FakeVideoSendStream* stream = AddSendStream(); | 1590 FakeVideoSendStream* stream = AddSendStream(); |
1590 EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate); | 1591 EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate); |
1591 | 1592 |
1592 options.suspend_below_min_bitrate.Set(false); | 1593 send_parameters_.options.suspend_below_min_bitrate.Set(false); |
1593 channel_->SetOptions(options); | 1594 channel_->SetSendParameters(send_parameters_); |
1594 | 1595 |
1595 stream = fake_call_->GetVideoSendStreams()[0]; | 1596 stream = fake_call_->GetVideoSendStreams()[0]; |
1596 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); | 1597 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); |
1597 } | 1598 } |
1598 | 1599 |
1599 TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) { | 1600 TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) { |
1600 FakeVideoSendStream* stream = AddSendStream(); | 1601 FakeVideoSendStream* stream = AddSendStream(); |
1601 webrtc::VideoCodecVP8 vp8_settings; | 1602 webrtc::VideoCodecVP8 vp8_settings; |
1602 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1603 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1603 EXPECT_TRUE(vp8_settings.denoisingOn); | 1604 EXPECT_TRUE(vp8_settings.denoisingOn); |
1604 } | 1605 } |
1605 | 1606 |
1606 TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) { | 1607 TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) { |
1607 std::vector<cricket::VideoCodec> codecs; | 1608 cricket::VideoSendParameters parameters; |
1608 codecs.push_back(kVp8Codec720p); | 1609 parameters.codecs.push_back(kVp8Codec720p); |
1609 ASSERT_TRUE(channel_->SetSendCodecs(codecs)); | 1610 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
1610 | 1611 |
1611 // Single-stream settings should apply with RTX as well (verifies that we | 1612 // Single-stream settings should apply with RTX as well (verifies that we |
1612 // check number of regular SSRCs and not StreamParams::ssrcs which contains | 1613 // check number of regular SSRCs and not StreamParams::ssrcs which contains |
1613 // both RTX and regular SSRCs). | 1614 // both RTX and regular SSRCs). |
1614 FakeVideoSendStream* stream = SetUpSimulcast(false, true); | 1615 FakeVideoSendStream* stream = SetUpSimulcast(false, true); |
1615 | 1616 |
1616 cricket::FakeVideoCapturer capturer; | 1617 cricket::FakeVideoCapturer capturer; |
1617 capturer.SetScreencast(false); | 1618 capturer.SetScreencast(false); |
1618 EXPECT_EQ(cricket::CS_RUNNING, | 1619 EXPECT_EQ(cricket::CS_RUNNING, |
1619 capturer.Start(capturer.GetSupportedFormats()->front())); | 1620 capturer.Start(capturer.GetSupportedFormats()->front())); |
1620 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 1621 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
1621 channel_->SetSend(true); | 1622 channel_->SetSend(true); |
1622 | 1623 |
1623 EXPECT_TRUE(capturer.CaptureFrame()); | 1624 EXPECT_TRUE(capturer.CaptureFrame()); |
1624 | 1625 |
1625 stream = SetDenoisingOption(false); | 1626 stream = SetDenoisingOption(parameters, false); |
1626 | 1627 |
1627 webrtc::VideoCodecVP8 vp8_settings; | 1628 webrtc::VideoCodecVP8 vp8_settings; |
1628 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1629 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1629 EXPECT_FALSE(vp8_settings.denoisingOn); | 1630 EXPECT_FALSE(vp8_settings.denoisingOn); |
1630 EXPECT_TRUE(vp8_settings.automaticResizeOn); | 1631 EXPECT_TRUE(vp8_settings.automaticResizeOn); |
1631 EXPECT_TRUE(vp8_settings.frameDroppingOn); | 1632 EXPECT_TRUE(vp8_settings.frameDroppingOn); |
1632 | 1633 |
1633 stream = SetDenoisingOption(true); | 1634 stream = SetDenoisingOption(parameters, true); |
1634 | 1635 |
1635 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1636 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1636 EXPECT_TRUE(vp8_settings.denoisingOn); | 1637 EXPECT_TRUE(vp8_settings.denoisingOn); |
1637 EXPECT_TRUE(vp8_settings.automaticResizeOn); | 1638 EXPECT_TRUE(vp8_settings.automaticResizeOn); |
1638 EXPECT_TRUE(vp8_settings.frameDroppingOn); | 1639 EXPECT_TRUE(vp8_settings.frameDroppingOn); |
1639 | 1640 |
1640 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 1641 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
1641 stream = SetUpSimulcast(true, false); | 1642 stream = SetUpSimulcast(true, false); |
1642 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 1643 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
1643 channel_->SetSend(true); | 1644 channel_->SetSend(true); |
1644 EXPECT_TRUE(capturer.CaptureFrame()); | 1645 EXPECT_TRUE(capturer.CaptureFrame()); |
1645 | 1646 |
1646 EXPECT_EQ(3, stream->GetVideoStreams().size()); | 1647 EXPECT_EQ(3, stream->GetVideoStreams().size()); |
1647 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1648 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1648 // Autmatic resize off when using simulcast. | 1649 // Autmatic resize off when using simulcast. |
1649 EXPECT_FALSE(vp8_settings.automaticResizeOn); | 1650 EXPECT_FALSE(vp8_settings.automaticResizeOn); |
1650 EXPECT_TRUE(vp8_settings.frameDroppingOn); | 1651 EXPECT_TRUE(vp8_settings.frameDroppingOn); |
1651 | 1652 |
1652 // In screen-share mode, denoising is forced off and simulcast disabled. | 1653 // In screen-share mode, denoising is forced off and simulcast disabled. |
1653 capturer.SetScreencast(true); | 1654 capturer.SetScreencast(true); |
1654 EXPECT_TRUE(capturer.CaptureFrame()); | 1655 EXPECT_TRUE(capturer.CaptureFrame()); |
1655 stream = SetDenoisingOption(false); | 1656 stream = SetDenoisingOption(parameters, false); |
1656 | 1657 |
1657 EXPECT_EQ(1, stream->GetVideoStreams().size()); | 1658 EXPECT_EQ(1, stream->GetVideoStreams().size()); |
1658 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1659 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1659 EXPECT_FALSE(vp8_settings.denoisingOn); | 1660 EXPECT_FALSE(vp8_settings.denoisingOn); |
1660 // Resizing and frame dropping always off for screen sharing. | 1661 // Resizing and frame dropping always off for screen sharing. |
1661 EXPECT_FALSE(vp8_settings.automaticResizeOn); | 1662 EXPECT_FALSE(vp8_settings.automaticResizeOn); |
1662 EXPECT_FALSE(vp8_settings.frameDroppingOn); | 1663 EXPECT_FALSE(vp8_settings.frameDroppingOn); |
1663 | 1664 |
1664 stream = SetDenoisingOption(true); | 1665 stream = SetDenoisingOption(parameters, true); |
1665 | 1666 |
1666 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1667 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1667 EXPECT_FALSE(vp8_settings.denoisingOn); | 1668 EXPECT_FALSE(vp8_settings.denoisingOn); |
1668 EXPECT_FALSE(vp8_settings.automaticResizeOn); | 1669 EXPECT_FALSE(vp8_settings.automaticResizeOn); |
1669 EXPECT_FALSE(vp8_settings.frameDroppingOn); | 1670 EXPECT_FALSE(vp8_settings.frameDroppingOn); |
1670 | 1671 |
1671 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 1672 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
1672 } | 1673 } |
1673 | 1674 |
1674 class Vp9SettingsTest : public WebRtcVideoChannel2Test { | 1675 class Vp9SettingsTest : public WebRtcVideoChannel2Test { |
1675 public: | 1676 public: |
1676 Vp9SettingsTest() : WebRtcVideoChannel2Test() { | 1677 Vp9SettingsTest() : WebRtcVideoChannel2Test() { |
1677 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9"); | 1678 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9"); |
1678 } | 1679 } |
1679 virtual ~Vp9SettingsTest() {} | 1680 virtual ~Vp9SettingsTest() {} |
1680 | 1681 |
1681 protected: | 1682 protected: |
1682 void SetUp() override { | 1683 void SetUp() override { |
1683 engine_.SetExternalEncoderFactory(&encoder_factory_); | 1684 engine_.SetExternalEncoderFactory(&encoder_factory_); |
1684 | 1685 |
1685 WebRtcVideoChannel2Test::SetUp(); | 1686 WebRtcVideoChannel2Test::SetUp(); |
1686 } | 1687 } |
1687 | 1688 |
1688 void TearDown() override { | 1689 void TearDown() override { |
1689 // Remove references to encoder_factory_ since this will be destroyed | 1690 // Remove references to encoder_factory_ since this will be destroyed |
1690 // before channel_ and engine_. | 1691 // before channel_ and engine_. |
1691 ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs())); | 1692 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); |
1692 } | 1693 } |
1693 | 1694 |
1694 cricket::FakeWebRtcVideoEncoderFactory encoder_factory_; | 1695 cricket::FakeWebRtcVideoEncoderFactory encoder_factory_; |
1695 }; | 1696 }; |
1696 | 1697 |
1697 TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) { | 1698 TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) { |
1698 std::vector<cricket::VideoCodec> codecs; | 1699 cricket::VideoSendParameters parameters; |
1699 codecs.push_back(kVp9Codec); | 1700 parameters.codecs.push_back(kVp9Codec); |
1700 ASSERT_TRUE(channel_->SetSendCodecs(codecs)); | 1701 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
1701 | 1702 |
1702 FakeVideoSendStream* stream = SetUpSimulcast(false, false); | 1703 FakeVideoSendStream* stream = SetUpSimulcast(false, false); |
1703 | 1704 |
1704 cricket::FakeVideoCapturer capturer; | 1705 cricket::FakeVideoCapturer capturer; |
1705 capturer.SetScreencast(false); | 1706 capturer.SetScreencast(false); |
1706 EXPECT_EQ(cricket::CS_RUNNING, | 1707 EXPECT_EQ(cricket::CS_RUNNING, |
1707 capturer.Start(capturer.GetSupportedFormats()->front())); | 1708 capturer.Start(capturer.GetSupportedFormats()->front())); |
1708 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 1709 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
1709 channel_->SetSend(true); | 1710 channel_->SetSend(true); |
1710 | 1711 |
1711 EXPECT_TRUE(capturer.CaptureFrame()); | 1712 EXPECT_TRUE(capturer.CaptureFrame()); |
1712 | 1713 |
1713 stream = SetDenoisingOption(false); | 1714 stream = SetDenoisingOption(parameters, false); |
1714 | 1715 |
1715 webrtc::VideoCodecVP9 vp9_settings; | 1716 webrtc::VideoCodecVP9 vp9_settings; |
1716 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; | 1717 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; |
1717 EXPECT_FALSE(vp9_settings.denoisingOn); | 1718 EXPECT_FALSE(vp9_settings.denoisingOn); |
1718 // Frame dropping always on for real time video. | 1719 // Frame dropping always on for real time video. |
1719 EXPECT_TRUE(vp9_settings.frameDroppingOn); | 1720 EXPECT_TRUE(vp9_settings.frameDroppingOn); |
1720 | 1721 |
1721 stream = SetDenoisingOption(true); | 1722 stream = SetDenoisingOption(parameters, true); |
1722 | 1723 |
1723 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; | 1724 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; |
1724 EXPECT_TRUE(vp9_settings.denoisingOn); | 1725 EXPECT_TRUE(vp9_settings.denoisingOn); |
1725 EXPECT_TRUE(vp9_settings.frameDroppingOn); | 1726 EXPECT_TRUE(vp9_settings.frameDroppingOn); |
1726 | 1727 |
1727 // In screen-share mode, denoising is forced off. | 1728 // In screen-share mode, denoising is forced off. |
1728 capturer.SetScreencast(true); | 1729 capturer.SetScreencast(true); |
1729 EXPECT_TRUE(capturer.CaptureFrame()); | 1730 EXPECT_TRUE(capturer.CaptureFrame()); |
1730 stream = SetDenoisingOption(false); | 1731 stream = SetDenoisingOption(parameters, false); |
1731 | 1732 |
1732 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; | 1733 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; |
1733 EXPECT_FALSE(vp9_settings.denoisingOn); | 1734 EXPECT_FALSE(vp9_settings.denoisingOn); |
1734 // Frame dropping always off for screen sharing. | 1735 // Frame dropping always off for screen sharing. |
1735 EXPECT_FALSE(vp9_settings.frameDroppingOn); | 1736 EXPECT_FALSE(vp9_settings.frameDroppingOn); |
1736 | 1737 |
1737 stream = SetDenoisingOption(false); | 1738 stream = SetDenoisingOption(parameters, false); |
1738 | 1739 |
1739 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; | 1740 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; |
1740 EXPECT_FALSE(vp9_settings.denoisingOn); | 1741 EXPECT_FALSE(vp9_settings.denoisingOn); |
1741 EXPECT_FALSE(vp9_settings.frameDroppingOn); | 1742 EXPECT_FALSE(vp9_settings.frameDroppingOn); |
1742 | 1743 |
1743 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 1744 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
1744 } | 1745 } |
1745 | 1746 |
1746 TEST_F(WebRtcVideoChannel2Test, DISABLED_MultipleSendStreamsWithOneCapturer) { | 1747 TEST_F(WebRtcVideoChannel2Test, DISABLED_MultipleSendStreamsWithOneCapturer) { |
1747 FAIL() << "Not implemented."; // TODO(pbos): Implement. | 1748 FAIL() << "Not implemented."; // TODO(pbos): Implement. |
(...skipping 11 matching lines...) Expand all Loading... |
1759 TestCpuAdaptation(false, false); | 1760 TestCpuAdaptation(false, false); |
1760 } | 1761 } |
1761 | 1762 |
1762 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) { | 1763 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) { |
1763 TestCpuAdaptation(true, true); | 1764 TestCpuAdaptation(true, true); |
1764 } | 1765 } |
1765 | 1766 |
1766 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, | 1767 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, |
1767 bool is_screenshare) { | 1768 bool is_screenshare) { |
1768 cricket::VideoCodec codec = kVp8Codec720p; | 1769 cricket::VideoCodec codec = kVp8Codec720p; |
1769 std::vector<cricket::VideoCodec> codecs; | 1770 cricket::VideoSendParameters parameters; |
1770 codecs.push_back(codec); | 1771 parameters.codecs.push_back(codec); |
1771 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); | |
1772 | |
1773 if (!enable_overuse) { | 1772 if (!enable_overuse) { |
1774 VideoOptions options; | 1773 parameters.options.cpu_overuse_detection.Set(false); |
1775 options.cpu_overuse_detection.Set(false); | |
1776 channel_->SetOptions(options); | |
1777 } | 1774 } |
| 1775 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1778 | 1776 |
1779 AddSendStream(); | 1777 AddSendStream(); |
1780 | 1778 |
1781 cricket::FakeVideoCapturer capturer; | 1779 cricket::FakeVideoCapturer capturer; |
1782 capturer.SetScreencast(is_screenshare); | 1780 capturer.SetScreencast(is_screenshare); |
1783 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 1781 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
1784 EXPECT_EQ(cricket::CS_RUNNING, | 1782 EXPECT_EQ(cricket::CS_RUNNING, |
1785 capturer.Start(capturer.GetSupportedFormats()->front())); | 1783 capturer.Start(capturer.GetSupportedFormats()->front())); |
1786 | 1784 |
1787 EXPECT_TRUE(channel_->SetSend(true)); | 1785 EXPECT_TRUE(channel_->SetSend(true)); |
(...skipping 27 matching lines...) Expand all Loading... |
1815 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); | 1813 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); |
1816 | 1814 |
1817 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 1815 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
1818 } | 1816 } |
1819 | 1817 |
1820 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeAndElapsedTimeCorrectly) { | 1818 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeAndElapsedTimeCorrectly) { |
1821 // Start at last timestamp to verify that wraparounds are estimated correctly. | 1819 // Start at last timestamp to verify that wraparounds are estimated correctly. |
1822 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu; | 1820 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu; |
1823 static const int64_t kInitialNtpTimeMs = 1247891230; | 1821 static const int64_t kInitialNtpTimeMs = 1247891230; |
1824 static const int kFrameOffsetMs = 20; | 1822 static const int kFrameOffsetMs = 20; |
1825 EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); | 1823 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
1826 | 1824 |
1827 FakeVideoReceiveStream* stream = AddRecvStream(); | 1825 FakeVideoReceiveStream* stream = AddRecvStream(); |
1828 cricket::FakeVideoRenderer renderer; | 1826 cricket::FakeVideoRenderer renderer; |
1829 EXPECT_TRUE(channel_->SetRenderer(last_ssrc_, &renderer)); | 1827 EXPECT_TRUE(channel_->SetRenderer(last_ssrc_, &renderer)); |
1830 EXPECT_TRUE(channel_->SetRender(true)); | 1828 EXPECT_TRUE(channel_->SetRender(true)); |
1831 | 1829 |
1832 webrtc::VideoFrame video_frame; | 1830 webrtc::VideoFrame video_frame; |
1833 CreateBlackFrame(&video_frame, 4, 4); | 1831 CreateBlackFrame(&video_frame, 4, 4); |
1834 video_frame.set_timestamp(kInitialTimestamp); | 1832 video_frame.set_timestamp(kInitialTimestamp); |
1835 // Initial NTP time is not available on the first frame, but should still be | 1833 // Initial NTP time is not available on the first frame, but should still be |
(...skipping 15 matching lines...) Expand all Loading... |
1851 renderer.last_frame_elapsed_time_ns()); | 1849 renderer.last_frame_elapsed_time_ns()); |
1852 | 1850 |
1853 // Verify that NTP time has been correctly deduced. | 1851 // Verify that NTP time has been correctly deduced. |
1854 cricket::VideoMediaInfo info; | 1852 cricket::VideoMediaInfo info; |
1855 ASSERT_TRUE(channel_->GetStats(&info)); | 1853 ASSERT_TRUE(channel_->GetStats(&info)); |
1856 ASSERT_EQ(1u, info.receivers.size()); | 1854 ASSERT_EQ(1u, info.receivers.size()); |
1857 EXPECT_EQ(kInitialNtpTimeMs, info.receivers[0].capture_start_ntp_time_ms); | 1855 EXPECT_EQ(kInitialNtpTimeMs, info.receivers[0].capture_start_ntp_time_ms); |
1858 } | 1856 } |
1859 | 1857 |
1860 TEST_F(WebRtcVideoChannel2Test, SetDefaultSendCodecs) { | 1858 TEST_F(WebRtcVideoChannel2Test, SetDefaultSendCodecs) { |
1861 ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs())); | 1859 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); |
1862 | 1860 |
1863 VideoCodec codec; | 1861 VideoCodec codec; |
1864 EXPECT_TRUE(channel_->GetSendCodec(&codec)); | 1862 EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
1865 EXPECT_TRUE(codec.Matches(engine_.codecs()[0])); | 1863 EXPECT_TRUE(codec.Matches(engine_.codecs()[0])); |
1866 | 1864 |
1867 // Using a RTX setup to verify that the default RTX payload type is good. | 1865 // Using a RTX setup to verify that the default RTX payload type is good. |
1868 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); | 1866 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
1869 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); | 1867 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
1870 FakeVideoSendStream* stream = AddSendStream( | 1868 FakeVideoSendStream* stream = AddSendStream( |
1871 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); | 1869 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
1872 webrtc::VideoSendStream::Config config = stream->GetConfig(); | 1870 webrtc::VideoSendStream::Config config = stream->GetConfig(); |
1873 | 1871 |
1874 // Make sure NACK and FEC are enabled on the correct payload types. | 1872 // Make sure NACK and FEC are enabled on the correct payload types. |
1875 EXPECT_EQ(1000, config.rtp.nack.rtp_history_ms); | 1873 EXPECT_EQ(1000, config.rtp.nack.rtp_history_ms); |
1876 EXPECT_EQ(default_ulpfec_codec_.id, config.rtp.fec.ulpfec_payload_type); | 1874 EXPECT_EQ(default_ulpfec_codec_.id, config.rtp.fec.ulpfec_payload_type); |
1877 EXPECT_EQ(default_red_codec_.id, config.rtp.fec.red_payload_type); | 1875 EXPECT_EQ(default_red_codec_.id, config.rtp.fec.red_payload_type); |
1878 | 1876 |
1879 EXPECT_EQ(1u, config.rtp.rtx.ssrcs.size()); | 1877 EXPECT_EQ(1u, config.rtp.rtx.ssrcs.size()); |
1880 EXPECT_EQ(kRtxSsrcs1[0], config.rtp.rtx.ssrcs[0]); | 1878 EXPECT_EQ(kRtxSsrcs1[0], config.rtp.rtx.ssrcs[0]); |
1881 VerifySendStreamHasRtxTypes(config, default_apt_rtx_types_); | 1879 VerifySendStreamHasRtxTypes(config, default_apt_rtx_types_); |
1882 // TODO(juberti): Check RTCP, PLI, TMMBR. | 1880 // TODO(juberti): Check RTCP, PLI, TMMBR. |
1883 } | 1881 } |
1884 | 1882 |
1885 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) { | 1883 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) { |
1886 std::vector<VideoCodec> codecs; | 1884 cricket::VideoSendParameters parameters; |
1887 codecs.push_back(kVp8Codec); | 1885 parameters.codecs.push_back(kVp8Codec); |
1888 ASSERT_TRUE(channel_->SetSendCodecs(codecs)); | 1886 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
1889 | 1887 |
1890 FakeVideoSendStream* stream = AddSendStream(); | 1888 FakeVideoSendStream* stream = AddSendStream(); |
1891 webrtc::VideoSendStream::Config config = stream->GetConfig(); | 1889 webrtc::VideoSendStream::Config config = stream->GetConfig(); |
1892 | 1890 |
1893 EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type); | 1891 EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type); |
1894 EXPECT_EQ(-1, config.rtp.fec.red_payload_type); | 1892 EXPECT_EQ(-1, config.rtp.fec.red_payload_type); |
1895 } | 1893 } |
1896 | 1894 |
1897 TEST_F(WebRtcVideoChannel2Test, | 1895 TEST_F(WebRtcVideoChannel2Test, |
1898 SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { | 1896 SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { |
1899 std::vector<VideoCodec> codecs; | 1897 cricket::VideoSendParameters parameters; |
1900 cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); | 1898 cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); |
1901 codecs.push_back(rtx_codec); | 1899 parameters.codecs.push_back(rtx_codec); |
1902 EXPECT_FALSE(channel_->SetSendCodecs(codecs)) | 1900 EXPECT_FALSE(channel_->SetSendParameters(parameters)) |
1903 << "RTX codec without associated payload type should be rejected."; | 1901 << "RTX codec without associated payload type should be rejected."; |
1904 } | 1902 } |
1905 | 1903 |
1906 TEST_F(WebRtcVideoChannel2Test, | 1904 TEST_F(WebRtcVideoChannel2Test, |
1907 SetSendCodecRejectsRtxWithoutMatchingVideoCodec) { | 1905 SetSendCodecRejectsRtxWithoutMatchingVideoCodec) { |
1908 std::vector<VideoCodec> codecs; | 1906 cricket::VideoSendParameters parameters; |
1909 cricket::VideoCodec rtx_codec = | 1907 cricket::VideoCodec rtx_codec = |
1910 cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id); | 1908 cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id); |
1911 codecs.push_back(kVp8Codec); | 1909 parameters.codecs.push_back(kVp8Codec); |
1912 codecs.push_back(rtx_codec); | 1910 parameters.codecs.push_back(rtx_codec); |
1913 ASSERT_TRUE(channel_->SetSendCodecs(codecs)); | 1911 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
1914 | 1912 |
1915 cricket::VideoCodec rtx_codec2 = | 1913 cricket::VideoCodec rtx_codec2 = |
1916 cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id + 1); | 1914 cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id + 1); |
1917 codecs.pop_back(); | 1915 parameters.codecs.pop_back(); |
1918 codecs.push_back(rtx_codec2); | 1916 parameters.codecs.push_back(rtx_codec2); |
1919 EXPECT_FALSE(channel_->SetSendCodecs(codecs)) | 1917 EXPECT_FALSE(channel_->SetSendParameters(parameters)) |
1920 << "RTX without matching video codec should be rejected."; | 1918 << "RTX without matching video codec should be rejected."; |
1921 } | 1919 } |
1922 | 1920 |
1923 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) { | 1921 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) { |
1924 std::vector<VideoCodec> codecs; | 1922 cricket::VideoSendParameters parameters; |
1925 codecs.push_back(kVp8Codec); | 1923 parameters.codecs.push_back(kVp8Codec); |
1926 codecs.push_back(kUlpfecCodec); | 1924 parameters.codecs.push_back(kUlpfecCodec); |
1927 ASSERT_TRUE(channel_->SetSendCodecs(codecs)); | 1925 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
1928 | 1926 |
1929 FakeVideoSendStream* stream = AddSendStream(); | 1927 FakeVideoSendStream* stream = AddSendStream(); |
1930 webrtc::VideoSendStream::Config config = stream->GetConfig(); | 1928 webrtc::VideoSendStream::Config config = stream->GetConfig(); |
1931 | 1929 |
1932 EXPECT_EQ(kUlpfecCodec.id, config.rtp.fec.ulpfec_payload_type); | 1930 EXPECT_EQ(kUlpfecCodec.id, config.rtp.fec.ulpfec_payload_type); |
1933 | 1931 |
1934 codecs.pop_back(); | 1932 parameters.codecs.pop_back(); |
1935 ASSERT_TRUE(channel_->SetSendCodecs(codecs)); | 1933 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
1936 stream = fake_call_->GetVideoSendStreams()[0]; | 1934 stream = fake_call_->GetVideoSendStreams()[0]; |
1937 ASSERT_TRUE(stream != NULL); | 1935 ASSERT_TRUE(stream != NULL); |
1938 config = stream->GetConfig(); | 1936 config = stream->GetConfig(); |
1939 EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type) | 1937 EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type) |
1940 << "SetSendCodec without FEC should disable current FEC."; | 1938 << "SetSendCodec without FEC should disable current FEC."; |
1941 } | 1939 } |
1942 | 1940 |
1943 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { | 1941 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { |
1944 std::vector<VideoCodec> codecs; | 1942 cricket::VideoSendParameters parameters; |
1945 codecs.push_back(kVp8Codec720p); | 1943 parameters.codecs.push_back(kVp8Codec720p); |
1946 ASSERT_TRUE(channel_->SetSendCodecs(codecs)); | 1944 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
1947 channel_->SetSend(true); | 1945 channel_->SetSend(true); |
1948 | 1946 |
1949 FakeVideoSendStream* stream = AddSendStream(); | 1947 FakeVideoSendStream* stream = AddSendStream(); |
1950 | 1948 |
1951 cricket::FakeVideoCapturer capturer; | 1949 cricket::FakeVideoCapturer capturer; |
1952 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 1950 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
1953 EXPECT_EQ(cricket::CS_RUNNING, | 1951 EXPECT_EQ(cricket::CS_RUNNING, |
1954 capturer.Start(capturer.GetSupportedFormats()->front())); | 1952 capturer.Start(capturer.GetSupportedFormats()->front())); |
1955 EXPECT_TRUE(capturer.CaptureFrame()); | 1953 EXPECT_TRUE(capturer.CaptureFrame()); |
1956 | 1954 |
1957 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); | 1955 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); |
1958 EXPECT_EQ(kVp8Codec720p.width, streams[0].width); | 1956 EXPECT_EQ(kVp8Codec720p.width, streams[0].width); |
1959 EXPECT_EQ(kVp8Codec720p.height, streams[0].height); | 1957 EXPECT_EQ(kVp8Codec720p.height, streams[0].height); |
1960 | 1958 |
1961 codecs.clear(); | 1959 parameters.codecs.clear(); |
1962 codecs.push_back(kVp8Codec360p); | 1960 parameters.codecs.push_back(kVp8Codec360p); |
1963 ASSERT_TRUE(channel_->SetSendCodecs(codecs)); | 1961 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
1964 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); | 1962 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); |
1965 EXPECT_EQ(kVp8Codec360p.width, streams[0].width); | 1963 EXPECT_EQ(kVp8Codec360p.width, streams[0].width); |
1966 EXPECT_EQ(kVp8Codec360p.height, streams[0].height); | 1964 EXPECT_EQ(kVp8Codec360p.height, streams[0].height); |
1967 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 1965 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
1968 } | 1966 } |
1969 | 1967 |
1970 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { | 1968 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { |
1971 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", | 1969 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", |
1972 200000); | 1970 200000); |
1973 } | 1971 } |
1974 | 1972 |
1975 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { | 1973 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { |
1976 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000); | 1974 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000); |
1977 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams(); | 1975 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams(); |
1978 ASSERT_EQ(1u, streams.size()); | 1976 ASSERT_EQ(1u, streams.size()); |
1979 EXPECT_EQ(10000000, streams[0].max_bitrate_bps); | 1977 EXPECT_EQ(10000000, streams[0].max_bitrate_bps); |
1980 } | 1978 } |
1981 | 1979 |
1982 TEST_F(WebRtcVideoChannel2Test, | 1980 TEST_F(WebRtcVideoChannel2Test, |
1983 SetSendCodecsWithoutBitratesUsesCorrectDefaults) { | 1981 SetSendCodecsWithoutBitratesUsesCorrectDefaults) { |
1984 SetSendCodecsShouldWorkForBitrates( | 1982 SetSendCodecsShouldWorkForBitrates( |
1985 "", 0, "", -1, "", -1); | 1983 "", 0, "", -1, "", -1); |
1986 } | 1984 } |
1987 | 1985 |
1988 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsCapsMinAndStartBitrate) { | 1986 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsCapsMinAndStartBitrate) { |
1989 SetSendCodecsShouldWorkForBitrates("-1", 0, "-100", -1, "", -1); | 1987 SetSendCodecsShouldWorkForBitrates("-1", 0, "-100", -1, "", -1); |
1990 } | 1988 } |
1991 | 1989 |
1992 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) { | 1990 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) { |
1993 std::vector<VideoCodec> video_codecs = engine_.codecs(); | 1991 send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "300"; |
1994 video_codecs[0].params[kCodecParamMinBitrate] = "300"; | 1992 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "200"; |
1995 video_codecs[0].params[kCodecParamMaxBitrate] = "200"; | 1993 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); |
1996 EXPECT_FALSE(channel_->SetSendCodecs(video_codecs)); | |
1997 } | 1994 } |
1998 | 1995 |
1999 TEST_F(WebRtcVideoChannel2Test, | 1996 TEST_F(WebRtcVideoChannel2Test, |
2000 SetMaxSendBandwidthShouldPreserveOtherBitrates) { | 1997 SetMaxSendBandwidthShouldPreserveOtherBitrates) { |
2001 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", | 1998 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", |
2002 200000); | 1999 200000); |
2003 channel_->SetMaxSendBandwidth(300000); | 2000 send_parameters_.max_bandwidth_bps = 300000; |
| 2001 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2004 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps) | 2002 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps) |
2005 << "Setting max bitrate should keep previous min bitrate."; | 2003 << "Setting max bitrate should keep previous min bitrate."; |
2006 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.start_bitrate_bps) | 2004 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.start_bitrate_bps) |
2007 << "Setting max bitrate should not reset start bitrate."; | 2005 << "Setting max bitrate should not reset start bitrate."; |
2008 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); | 2006 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); |
2009 } | 2007 } |
2010 | 2008 |
2011 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthShouldBeRemovable) { | 2009 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthShouldBeRemovable) { |
2012 channel_->SetMaxSendBandwidth(300000); | 2010 send_parameters_.max_bandwidth_bps = 300000; |
| 2011 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2013 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); | 2012 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); |
2014 // <= 0 means disable (infinite) max bitrate. | 2013 // <= 0 means disable (infinite) max bitrate. |
2015 channel_->SetMaxSendBandwidth(0); | 2014 send_parameters_.max_bandwidth_bps = 0; |
| 2015 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2016 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.max_bitrate_bps) | 2016 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.max_bitrate_bps) |
2017 << "Setting zero max bitrate did not reset start bitrate."; | 2017 << "Setting zero max bitrate did not reset start bitrate."; |
2018 } | 2018 } |
2019 | 2019 |
2020 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { | 2020 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { |
2021 std::vector<VideoCodec> codecs; | 2021 cricket::VideoSendParameters parameters; |
2022 codecs.push_back(kVp8Codec720p); | 2022 parameters.codecs.push_back(kVp8Codec720p); |
2023 ASSERT_TRUE(channel_->SetSendCodecs(codecs)); | 2023 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
2024 channel_->SetSend(true); | 2024 channel_->SetSend(true); |
2025 | 2025 |
2026 FakeVideoSendStream* stream = AddSendStream(); | 2026 FakeVideoSendStream* stream = AddSendStream(); |
2027 | 2027 |
2028 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); | 2028 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); |
2029 int initial_max_bitrate_bps = streams[0].max_bitrate_bps; | 2029 int initial_max_bitrate_bps = streams[0].max_bitrate_bps; |
2030 EXPECT_GT(initial_max_bitrate_bps, 0); | 2030 EXPECT_GT(initial_max_bitrate_bps, 0); |
2031 | 2031 |
2032 EXPECT_TRUE(channel_->SetMaxSendBandwidth(initial_max_bitrate_bps * 2)); | 2032 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; |
| 2033 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
2033 streams = stream->GetVideoStreams(); | 2034 streams = stream->GetVideoStreams(); |
2034 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps); | 2035 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps); |
2035 } | 2036 } |
2036 | 2037 |
2037 TEST_F(WebRtcVideoChannel2Test, | 2038 TEST_F(WebRtcVideoChannel2Test, |
2038 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) { | 2039 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) { |
2039 std::vector<VideoCodec> codecs; | 2040 cricket::VideoSendParameters parameters; |
2040 codecs.push_back(kVp8Codec720p); | 2041 parameters.codecs.push_back(kVp8Codec720p); |
2041 ASSERT_TRUE(channel_->SetSendCodecs(codecs)); | 2042 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
2042 channel_->SetSend(true); | 2043 channel_->SetSend(true); |
2043 | 2044 |
2044 FakeVideoSendStream* stream = AddSendStream( | 2045 FakeVideoSendStream* stream = AddSendStream( |
2045 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3))); | 2046 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3))); |
2046 | 2047 |
2047 // Send a frame to make sure this scales up to >1 stream (simulcast). | 2048 // Send a frame to make sure this scales up to >1 stream (simulcast). |
2048 cricket::FakeVideoCapturer capturer; | 2049 cricket::FakeVideoCapturer capturer; |
2049 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &capturer)); | 2050 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &capturer)); |
2050 EXPECT_EQ(cricket::CS_RUNNING, | 2051 EXPECT_EQ(cricket::CS_RUNNING, |
2051 capturer.Start(capturer.GetSupportedFormats()->front())); | 2052 capturer.Start(capturer.GetSupportedFormats()->front())); |
2052 EXPECT_TRUE(capturer.CaptureFrame()); | 2053 EXPECT_TRUE(capturer.CaptureFrame()); |
2053 | 2054 |
2054 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); | 2055 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); |
2055 ASSERT_GT(streams.size(), 1u) | 2056 ASSERT_GT(streams.size(), 1u) |
2056 << "Without simulcast this test doesn't make sense."; | 2057 << "Without simulcast this test doesn't make sense."; |
2057 int initial_max_bitrate_bps = 0; | 2058 int initial_max_bitrate_bps = 0; |
2058 for (auto& video_stream : streams) | 2059 for (auto& video_stream : streams) |
2059 initial_max_bitrate_bps += video_stream.max_bitrate_bps; | 2060 initial_max_bitrate_bps += video_stream.max_bitrate_bps; |
2060 EXPECT_GT(initial_max_bitrate_bps, 0); | 2061 EXPECT_GT(initial_max_bitrate_bps, 0); |
2061 | 2062 |
2062 EXPECT_TRUE(channel_->SetMaxSendBandwidth(initial_max_bitrate_bps * 2)); | 2063 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; |
| 2064 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
2063 streams = stream->GetVideoStreams(); | 2065 streams = stream->GetVideoStreams(); |
2064 int increased_max_bitrate_bps = 0; | 2066 int increased_max_bitrate_bps = 0; |
2065 for (auto& video_stream : streams) | 2067 for (auto& video_stream : streams) |
2066 increased_max_bitrate_bps += video_stream.max_bitrate_bps; | 2068 increased_max_bitrate_bps += video_stream.max_bitrate_bps; |
2067 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps); | 2069 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps); |
2068 | 2070 |
2069 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], nullptr)); | 2071 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], nullptr)); |
2070 } | 2072 } |
2071 | 2073 |
2072 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) { | 2074 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) { |
2073 static const char* kMaxQuantization = "21"; | 2075 static const char* kMaxQuantization = "21"; |
2074 std::vector<VideoCodec> codecs; | 2076 cricket::VideoSendParameters parameters; |
2075 codecs.push_back(kVp8Codec); | 2077 parameters.codecs.push_back(kVp8Codec); |
2076 codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization; | 2078 parameters.codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization; |
2077 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); | 2079 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
2078 EXPECT_EQ(static_cast<unsigned int>(atoi(kMaxQuantization)), | 2080 EXPECT_EQ(static_cast<unsigned int>(atoi(kMaxQuantization)), |
2079 AddSendStream()->GetVideoStreams().back().max_qp); | 2081 AddSendStream()->GetVideoStreams().back().max_qp); |
2080 | 2082 |
2081 VideoCodec codec; | 2083 VideoCodec codec; |
2082 EXPECT_TRUE(channel_->GetSendCodec(&codec)); | 2084 EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
2083 EXPECT_EQ(kMaxQuantization, codec.params[kCodecParamMaxQuantization]); | 2085 EXPECT_EQ(kMaxQuantization, codec.params[kCodecParamMaxQuantization]); |
2084 } | 2086 } |
2085 | 2087 |
2086 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadDimensions) { | 2088 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadDimensions) { |
2087 std::vector<cricket::VideoCodec> codecs; | 2089 cricket::VideoSendParameters parameters; |
2088 codecs.push_back(kVp8Codec); | 2090 parameters.codecs.push_back(kVp8Codec); |
2089 | 2091 |
2090 codecs[0].width = 0; | 2092 parameters.codecs[0].width = 0; |
2091 EXPECT_FALSE(channel_->SetSendCodecs(codecs)) | 2093 EXPECT_FALSE(channel_->SetSendParameters(parameters)) |
2092 << "Codec set though codec width is zero."; | 2094 << "Codec set though codec width is zero."; |
2093 | 2095 |
2094 codecs[0].width = kVp8Codec.width; | 2096 parameters.codecs[0].width = kVp8Codec.width; |
2095 codecs[0].height = 0; | 2097 parameters.codecs[0].height = 0; |
2096 EXPECT_FALSE(channel_->SetSendCodecs(codecs)) | 2098 EXPECT_FALSE(channel_->SetSendParameters(parameters)) |
2097 << "Codec set though codec height is zero."; | 2099 << "Codec set though codec height is zero."; |
2098 } | 2100 } |
2099 | 2101 |
2100 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadPayloadTypes) { | 2102 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectBadPayloadTypes) { |
2101 // TODO(pbos): Should we only allow the dynamic range? | 2103 // TODO(pbos): Should we only allow the dynamic range? |
2102 static const int kIncorrectPayloads[] = {-2, -1, 128, 129}; | 2104 static const int kIncorrectPayloads[] = {-2, -1, 128, 129}; |
2103 std::vector<cricket::VideoCodec> codecs; | 2105 cricket::VideoSendParameters parameters; |
2104 codecs.push_back(kVp8Codec); | 2106 parameters.codecs.push_back(kVp8Codec); |
2105 for (size_t i = 0; i < arraysize(kIncorrectPayloads); ++i) { | 2107 for (size_t i = 0; i < arraysize(kIncorrectPayloads); ++i) { |
2106 codecs[0].id = kIncorrectPayloads[i]; | 2108 parameters.codecs[0].id = kIncorrectPayloads[i]; |
2107 EXPECT_FALSE(channel_->SetSendCodecs(codecs)) | 2109 EXPECT_FALSE(channel_->SetSendParameters(parameters)) |
2108 << "Bad payload type '" << kIncorrectPayloads[i] << "' accepted."; | 2110 << "Bad payload type '" << kIncorrectPayloads[i] << "' accepted."; |
2109 } | 2111 } |
2110 } | 2112 } |
2111 | 2113 |
2112 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsAcceptAllValidPayloadTypes) { | 2114 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsAcceptAllValidPayloadTypes) { |
2113 std::vector<cricket::VideoCodec> codecs; | 2115 cricket::VideoSendParameters parameters; |
2114 codecs.push_back(kVp8Codec); | 2116 parameters.codecs.push_back(kVp8Codec); |
2115 for (int payload_type = 0; payload_type <= 127; ++payload_type) { | 2117 for (int payload_type = 0; payload_type <= 127; ++payload_type) { |
2116 codecs[0].id = payload_type; | 2118 parameters.codecs[0].id = payload_type; |
2117 EXPECT_TRUE(channel_->SetSendCodecs(codecs)) | 2119 EXPECT_TRUE(channel_->SetSendParameters(parameters)) |
2118 << "Payload type '" << payload_type << "' rejected."; | 2120 << "Payload type '" << payload_type << "' rejected."; |
2119 } | 2121 } |
2120 } | 2122 } |
2121 | 2123 |
2122 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) { | 2124 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) { |
2123 std::vector<cricket::VideoCodec> codecs; | 2125 cricket::VideoRecvParameters parameters; |
2124 codecs.push_back(kVp8Codec); | 2126 parameters.codecs.push_back(kVp8Codec); |
2125 EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); | 2127 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2126 } | 2128 } |
2127 | 2129 |
2128 // Test that we set our inbound RTX codecs properly. | 2130 // Test that we set our inbound RTX codecs properly. |
2129 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) { | 2131 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) { |
2130 std::vector<cricket::VideoCodec> codecs; | 2132 cricket::VideoRecvParameters parameters; |
2131 codecs.push_back(kVp8Codec); | 2133 parameters.codecs.push_back(kVp8Codec); |
2132 cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); | 2134 cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); |
2133 codecs.push_back(rtx_codec); | 2135 parameters.codecs.push_back(rtx_codec); |
2134 EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) | 2136 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) |
2135 << "RTX codec without associated payload should be rejected."; | 2137 << "RTX codec without associated payload should be rejected."; |
2136 | 2138 |
2137 codecs[1].SetParam("apt", kVp8Codec.id + 1); | 2139 parameters.codecs[1].SetParam("apt", kVp8Codec.id + 1); |
2138 EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) | 2140 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) |
2139 << "RTX codec with invalid associated payload type should be rejected."; | 2141 << "RTX codec with invalid associated payload type should be rejected."; |
2140 | 2142 |
2141 codecs[1].SetParam("apt", kVp8Codec.id); | 2143 parameters.codecs[1].SetParam("apt", kVp8Codec.id); |
2142 EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); | 2144 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2143 | 2145 |
2144 cricket::VideoCodec rtx_codec2(97, "rtx", 0, 0, 0, 0); | 2146 cricket::VideoCodec rtx_codec2(97, "rtx", 0, 0, 0, 0); |
2145 rtx_codec2.SetParam("apt", rtx_codec.id); | 2147 rtx_codec2.SetParam("apt", rtx_codec.id); |
2146 codecs.push_back(rtx_codec2); | 2148 parameters.codecs.push_back(rtx_codec2); |
2147 | 2149 |
2148 EXPECT_FALSE(channel_->SetRecvCodecs(codecs)) << "RTX codec with another RTX " | 2150 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) << |
2149 "as associated payload type " | 2151 "RTX codec with another RTX as associated payload type should be " |
2150 "should be rejected."; | 2152 "rejected."; |
2151 } | 2153 } |
2152 | 2154 |
2153 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentPayloadType) { | 2155 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentPayloadType) { |
2154 std::vector<cricket::VideoCodec> codecs; | 2156 cricket::VideoRecvParameters parameters; |
2155 codecs.push_back(kVp8Codec); | 2157 parameters.codecs.push_back(kVp8Codec); |
2156 codecs[0].id = 99; | 2158 parameters.codecs[0].id = 99; |
2157 EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); | 2159 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2158 } | 2160 } |
2159 | 2161 |
2160 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) { | 2162 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) { |
2161 EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); | 2163 cricket::VideoRecvParameters parameters; |
| 2164 parameters.codecs = engine_.codecs(); |
| 2165 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2162 | 2166 |
2163 FakeVideoReceiveStream* stream = AddRecvStream(); | 2167 FakeVideoReceiveStream* stream = AddRecvStream(); |
2164 webrtc::VideoReceiveStream::Config config = stream->GetConfig(); | 2168 webrtc::VideoReceiveStream::Config config = stream->GetConfig(); |
2165 EXPECT_EQ(engine_.codecs()[0].name, config.decoders[0].payload_name); | 2169 EXPECT_EQ(engine_.codecs()[0].name, config.decoders[0].payload_name); |
2166 EXPECT_EQ(engine_.codecs()[0].id, config.decoders[0].payload_type); | 2170 EXPECT_EQ(engine_.codecs()[0].id, config.decoders[0].payload_type); |
2167 } | 2171 } |
2168 | 2172 |
2169 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) { | 2173 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) { |
2170 std::vector<VideoCodec> codecs; | 2174 cricket::VideoRecvParameters parameters; |
2171 codecs.push_back(kVp8Codec); | 2175 parameters.codecs.push_back(kVp8Codec); |
2172 codecs.push_back(VideoCodec(101, "WTF3", 640, 400, 30, 0)); | 2176 parameters.codecs.push_back(VideoCodec(101, "WTF3", 640, 400, 30, 0)); |
2173 EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); | 2177 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); |
2174 } | 2178 } |
2175 | 2179 |
2176 // TODO(pbos): Enable VP9 through external codec support | 2180 // TODO(pbos): Enable VP9 through external codec support |
2177 TEST_F(WebRtcVideoChannel2Test, | 2181 TEST_F(WebRtcVideoChannel2Test, |
2178 DISABLED_SetRecvCodecsAcceptsMultipleVideoCodecs) { | 2182 DISABLED_SetRecvCodecsAcceptsMultipleVideoCodecs) { |
2179 std::vector<VideoCodec> codecs; | 2183 cricket::VideoRecvParameters parameters; |
2180 codecs.push_back(kVp8Codec); | 2184 parameters.codecs.push_back(kVp8Codec); |
2181 codecs.push_back(kVp9Codec); | 2185 parameters.codecs.push_back(kVp9Codec); |
2182 EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); | 2186 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2183 } | 2187 } |
2184 | 2188 |
2185 TEST_F(WebRtcVideoChannel2Test, | 2189 TEST_F(WebRtcVideoChannel2Test, |
2186 DISABLED_SetRecvCodecsSetsFecForAllVideoCodecs) { | 2190 DISABLED_SetRecvCodecsSetsFecForAllVideoCodecs) { |
2187 std::vector<VideoCodec> codecs; | 2191 cricket::VideoRecvParameters parameters; |
2188 codecs.push_back(kVp8Codec); | 2192 parameters.codecs.push_back(kVp8Codec); |
2189 codecs.push_back(kVp9Codec); | 2193 parameters.codecs.push_back(kVp9Codec); |
2190 EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); | 2194 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2191 FAIL(); // TODO(pbos): Verify that the FEC parameters are set for all codecs. | 2195 FAIL(); // TODO(pbos): Verify that the FEC parameters are set for all codecs. |
2192 } | 2196 } |
2193 | 2197 |
2194 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithoutFecDisablesFec) { | 2198 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithoutFecDisablesFec) { |
2195 std::vector<VideoCodec> codecs; | 2199 cricket::VideoSendParameters send_parameters; |
2196 codecs.push_back(kVp8Codec); | 2200 send_parameters.codecs.push_back(kVp8Codec); |
2197 codecs.push_back(kUlpfecCodec); | 2201 send_parameters.codecs.push_back(kUlpfecCodec); |
2198 ASSERT_TRUE(channel_->SetSendCodecs(codecs)); | 2202 ASSERT_TRUE(channel_->SetSendParameters(send_parameters)); |
2199 | 2203 |
2200 FakeVideoReceiveStream* stream = AddRecvStream(); | 2204 FakeVideoReceiveStream* stream = AddRecvStream(); |
2201 webrtc::VideoReceiveStream::Config config = stream->GetConfig(); | 2205 webrtc::VideoReceiveStream::Config config = stream->GetConfig(); |
2202 | 2206 |
2203 EXPECT_EQ(kUlpfecCodec.id, config.rtp.fec.ulpfec_payload_type); | 2207 EXPECT_EQ(kUlpfecCodec.id, config.rtp.fec.ulpfec_payload_type); |
2204 | 2208 |
2205 codecs.pop_back(); | 2209 cricket::VideoRecvParameters recv_parameters; |
2206 ASSERT_TRUE(channel_->SetRecvCodecs(codecs)); | 2210 recv_parameters.codecs.push_back(kVp8Codec); |
| 2211 ASSERT_TRUE(channel_->SetRecvParameters(recv_parameters)); |
2207 stream = fake_call_->GetVideoReceiveStreams()[0]; | 2212 stream = fake_call_->GetVideoReceiveStreams()[0]; |
2208 ASSERT_TRUE(stream != NULL); | 2213 ASSERT_TRUE(stream != NULL); |
2209 config = stream->GetConfig(); | 2214 config = stream->GetConfig(); |
2210 EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type) | 2215 EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type) |
2211 << "SetSendCodec without FEC should disable current FEC."; | 2216 << "SetSendCodec without FEC should disable current FEC."; |
2212 } | 2217 } |
2213 | 2218 |
2214 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectDuplicateFecPayloads) { | 2219 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectDuplicateFecPayloads) { |
2215 std::vector<VideoCodec> codecs; | 2220 cricket::VideoRecvParameters parameters; |
2216 codecs.push_back(kVp8Codec); | 2221 parameters.codecs.push_back(kVp8Codec); |
2217 codecs.push_back(kRedCodec); | 2222 parameters.codecs.push_back(kRedCodec); |
2218 codecs[1].id = codecs[0].id; | 2223 parameters.codecs[1].id = parameters.codecs[0].id; |
2219 EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); | 2224 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); |
2220 } | 2225 } |
2221 | 2226 |
2222 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectDuplicateCodecPayloads) { | 2227 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectDuplicateCodecPayloads) { |
2223 std::vector<VideoCodec> codecs; | 2228 cricket::VideoRecvParameters parameters; |
2224 codecs.push_back(kVp8Codec); | 2229 parameters.codecs.push_back(kVp8Codec); |
2225 codecs.push_back(kVp9Codec); | 2230 parameters.codecs.push_back(kVp9Codec); |
2226 codecs[1].id = codecs[0].id; | 2231 parameters.codecs[1].id = parameters.codecs[0].id; |
2227 EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); | 2232 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); |
2228 } | 2233 } |
2229 | 2234 |
2230 TEST_F(WebRtcVideoChannel2Test, | 2235 TEST_F(WebRtcVideoChannel2Test, |
2231 SetRecvCodecsAcceptSameCodecOnMultiplePayloadTypes) { | 2236 SetRecvCodecsAcceptSameCodecOnMultiplePayloadTypes) { |
2232 std::vector<VideoCodec> codecs; | 2237 cricket::VideoRecvParameters parameters; |
2233 codecs.push_back(kVp8Codec); | 2238 parameters.codecs.push_back(kVp8Codec); |
2234 codecs.push_back(kVp8Codec); | 2239 parameters.codecs.push_back(kVp8Codec); |
2235 codecs[1].id += 1; | 2240 parameters.codecs[1].id += 1; |
2236 EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); | 2241 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2237 } | 2242 } |
2238 | 2243 |
2239 // Test that setting the same codecs but with a different order and preference | 2244 // Test that setting the same codecs but with a different order and preference |
2240 // doesn't result in the stream being recreated. | 2245 // doesn't result in the stream being recreated. |
2241 TEST_F(WebRtcVideoChannel2Test, | 2246 TEST_F(WebRtcVideoChannel2Test, |
2242 SetRecvCodecsDifferentOrderAndPreferenceDoesntRecreateStream) { | 2247 SetRecvCodecsDifferentOrderAndPreferenceDoesntRecreateStream) { |
2243 std::vector<VideoCodec> codecs1; | 2248 cricket::VideoRecvParameters parameters1; |
2244 codecs1.push_back(kVp8Codec); | 2249 parameters1.codecs.push_back(kVp8Codec); |
2245 codecs1.push_back(kRedCodec); | 2250 parameters1.codecs.push_back(kRedCodec); |
2246 EXPECT_TRUE(channel_->SetRecvCodecs(codecs1)); | 2251 EXPECT_TRUE(channel_->SetRecvParameters(parameters1)); |
2247 | 2252 |
2248 AddRecvStream(cricket::StreamParams::CreateLegacy(123)); | 2253 AddRecvStream(cricket::StreamParams::CreateLegacy(123)); |
2249 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); | 2254 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); |
2250 | 2255 |
2251 std::vector<VideoCodec> codecs2; | 2256 cricket::VideoRecvParameters parameters2; |
2252 codecs2.push_back(kRedCodec); | 2257 parameters2.codecs.push_back(kRedCodec); |
2253 codecs2.push_back(kVp8Codec); | 2258 parameters2.codecs.push_back(kVp8Codec); |
2254 codecs2[1].preference += 1; | 2259 parameters2.codecs[1].preference += 1; |
2255 EXPECT_TRUE(channel_->SetRecvCodecs(codecs2)); | 2260 EXPECT_TRUE(channel_->SetRecvParameters(parameters2)); |
2256 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); | 2261 EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); |
2257 } | 2262 } |
2258 | 2263 |
2259 TEST_F(WebRtcVideoChannel2Test, SendStreamNotSendingByDefault) { | 2264 TEST_F(WebRtcVideoChannel2Test, SendStreamNotSendingByDefault) { |
2260 EXPECT_FALSE(AddSendStream()->IsSending()); | 2265 EXPECT_FALSE(AddSendStream()->IsSending()); |
2261 } | 2266 } |
2262 | 2267 |
2263 TEST_F(WebRtcVideoChannel2Test, ReceiveStreamReceivingByDefault) { | 2268 TEST_F(WebRtcVideoChannel2Test, ReceiveStreamReceivingByDefault) { |
2264 EXPECT_TRUE(AddRecvStream()->IsReceiving()); | 2269 EXPECT_TRUE(AddRecvStream()->IsReceiving()); |
2265 } | 2270 } |
(...skipping 19 matching lines...) Expand all Loading... |
2285 FakeVideoSendStream* new_stream = AddSendStream(); | 2290 FakeVideoSendStream* new_stream = AddSendStream(); |
2286 EXPECT_TRUE(new_stream->IsSending()) | 2291 EXPECT_TRUE(new_stream->IsSending()) |
2287 << "Send stream created after SetSend(true) not sending initially."; | 2292 << "Send stream created after SetSend(true) not sending initially."; |
2288 } | 2293 } |
2289 | 2294 |
2290 // This test verifies DSCP settings are properly applied on video media channel. | 2295 // This test verifies DSCP settings are properly applied on video media channel. |
2291 TEST_F(WebRtcVideoChannel2Test, TestSetDscpOptions) { | 2296 TEST_F(WebRtcVideoChannel2Test, TestSetDscpOptions) { |
2292 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface( | 2297 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface( |
2293 new cricket::FakeNetworkInterface); | 2298 new cricket::FakeNetworkInterface); |
2294 channel_->SetInterface(network_interface.get()); | 2299 channel_->SetInterface(network_interface.get()); |
2295 cricket::VideoOptions options; | 2300 cricket::VideoSendParameters parameters = send_parameters_; |
2296 EXPECT_TRUE(channel_->SetOptions(options)); | 2301 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
2297 EXPECT_EQ(rtc::DSCP_NO_CHANGE, network_interface->dscp()); | 2302 EXPECT_EQ(rtc::DSCP_NO_CHANGE, network_interface->dscp()); |
2298 options.dscp.Set(true); | 2303 parameters.options.dscp.Set(true); |
2299 EXPECT_TRUE(channel_->SetOptions(options)); | 2304 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
2300 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); | 2305 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); |
2301 // Verify previous value is not modified if dscp option is not set. | 2306 // Verify previous value is not modified if dscp option is not set. |
2302 cricket::VideoOptions options1; | 2307 cricket::VideoSendParameters parameters1 = send_parameters_; |
2303 EXPECT_TRUE(channel_->SetOptions(options1)); | 2308 EXPECT_TRUE(channel_->SetSendParameters(parameters1)); |
2304 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); | 2309 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); |
2305 options.dscp.Set(false); | 2310 parameters1.options.dscp.Set(false); |
2306 EXPECT_TRUE(channel_->SetOptions(options)); | 2311 EXPECT_TRUE(channel_->SetSendParameters(parameters1)); |
2307 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); | 2312 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); |
2308 channel_->SetInterface(NULL); | 2313 channel_->SetInterface(NULL); |
2309 } | 2314 } |
2310 | 2315 |
2311 TEST_F(WebRtcVideoChannel2Test, OnReadyToSendSignalsNetworkState) { | 2316 TEST_F(WebRtcVideoChannel2Test, OnReadyToSendSignalsNetworkState) { |
2312 EXPECT_EQ(webrtc::kNetworkUp, fake_call_->GetNetworkState()); | 2317 EXPECT_EQ(webrtc::kNetworkUp, fake_call_->GetNetworkState()); |
2313 | 2318 |
2314 channel_->OnReadyToSend(false); | 2319 channel_->OnReadyToSend(false); |
2315 EXPECT_EQ(webrtc::kNetworkDown, fake_call_->GetNetworkState()); | 2320 EXPECT_EQ(webrtc::kNetworkDown, fake_call_->GetNetworkState()); |
2316 | 2321 |
2317 channel_->OnReadyToSend(true); | 2322 channel_->OnReadyToSend(true); |
2318 EXPECT_EQ(webrtc::kNetworkUp, fake_call_->GetNetworkState()); | 2323 EXPECT_EQ(webrtc::kNetworkUp, fake_call_->GetNetworkState()); |
2319 } | 2324 } |
2320 | 2325 |
2321 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsSentCodecName) { | 2326 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsSentCodecName) { |
2322 std::vector<cricket::VideoCodec> codecs; | 2327 cricket::VideoSendParameters parameters; |
2323 codecs.push_back(kVp8Codec); | 2328 parameters.codecs.push_back(kVp8Codec); |
2324 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); | 2329 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
2325 | 2330 |
2326 AddSendStream(); | 2331 AddSendStream(); |
2327 | 2332 |
2328 cricket::VideoMediaInfo info; | 2333 cricket::VideoMediaInfo info; |
2329 ASSERT_TRUE(channel_->GetStats(&info)); | 2334 ASSERT_TRUE(channel_->GetStats(&info)); |
2330 EXPECT_EQ(kVp8Codec.name, info.senders[0].codec_name); | 2335 EXPECT_EQ(kVp8Codec.name, info.senders[0].codec_name); |
2331 } | 2336 } |
2332 | 2337 |
2333 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsCpuOveruseMetrics) { | 2338 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsCpuOveruseMetrics) { |
2334 FakeVideoSendStream* stream = AddSendStream(); | 2339 FakeVideoSendStream* stream = AddSendStream(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2367 // Capture format VGA. | 2372 // Capture format VGA. |
2368 cricket::FakeVideoCapturer video_capturer_vga; | 2373 cricket::FakeVideoCapturer video_capturer_vga; |
2369 const std::vector<cricket::VideoFormat>* formats = | 2374 const std::vector<cricket::VideoFormat>* formats = |
2370 video_capturer_vga.GetSupportedFormats(); | 2375 video_capturer_vga.GetSupportedFormats(); |
2371 cricket::VideoFormat capture_format_vga = (*formats)[1]; | 2376 cricket::VideoFormat capture_format_vga = (*formats)[1]; |
2372 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga)); | 2377 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga)); |
2373 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &video_capturer_vga)); | 2378 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &video_capturer_vga)); |
2374 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); | 2379 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); |
2375 | 2380 |
2376 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0); | 2381 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0); |
2377 std::vector<cricket::VideoCodec> codecs; | 2382 cricket::VideoSendParameters parameters; |
2378 codecs.push_back(send_codec); | 2383 parameters.codecs.push_back(send_codec); |
2379 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); | 2384 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
2380 EXPECT_TRUE(channel_->SetSend(true)); | 2385 EXPECT_TRUE(channel_->SetSend(true)); |
2381 | 2386 |
2382 // Verify that the CpuOveruseObserver is registered and trigger downgrade. | 2387 // Verify that the CpuOveruseObserver is registered and trigger downgrade. |
2383 cricket::VideoOptions options; | 2388 parameters.options.cpu_overuse_detection.Set(true); |
2384 options.cpu_overuse_detection.Set(true); | 2389 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
2385 EXPECT_TRUE(channel_->SetOptions(options)); | |
2386 | 2390 |
2387 // Trigger overuse. | 2391 // Trigger overuse. |
2388 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); | 2392 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); |
2389 webrtc::LoadObserver* overuse_callback = | 2393 webrtc::LoadObserver* overuse_callback = |
2390 fake_call_->GetVideoSendStreams().front()->GetConfig().overuse_callback; | 2394 fake_call_->GetVideoSendStreams().front()->GetConfig().overuse_callback; |
2391 ASSERT_TRUE(overuse_callback != NULL); | 2395 ASSERT_TRUE(overuse_callback != NULL); |
2392 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); | 2396 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); |
2393 | 2397 |
2394 // Capture format VGA -> adapt (OnCpuResolutionRequest downgrade) -> VGA/2. | 2398 // Capture format VGA -> adapt (OnCpuResolutionRequest downgrade) -> VGA/2. |
2395 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); | 2399 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2572 info.bw_estimations[0].target_enc_bitrate); | 2576 info.bw_estimations[0].target_enc_bitrate); |
2573 EXPECT_EQ(stats.media_bitrate_bps + stats2.media_bitrate_bps, | 2577 EXPECT_EQ(stats.media_bitrate_bps + stats2.media_bitrate_bps, |
2574 info.bw_estimations[0].actual_enc_bitrate); | 2578 info.bw_estimations[0].actual_enc_bitrate); |
2575 EXPECT_EQ(1 + 3 + 5 + 7, info.bw_estimations[0].transmit_bitrate) | 2579 EXPECT_EQ(1 + 3 + 5 + 7, info.bw_estimations[0].transmit_bitrate) |
2576 << "Bandwidth stats should take all streams into account."; | 2580 << "Bandwidth stats should take all streams into account."; |
2577 EXPECT_EQ(2 + 4 + 6 + 8, info.bw_estimations[0].retransmit_bitrate) | 2581 EXPECT_EQ(2 + 4 + 6 + 8, info.bw_estimations[0].retransmit_bitrate) |
2578 << "Bandwidth stats should take all streams into account."; | 2582 << "Bandwidth stats should take all streams into account."; |
2579 } | 2583 } |
2580 | 2584 |
2581 TEST_F(WebRtcVideoChannel2Test, DefaultReceiveStreamReconfiguresToUseRtx) { | 2585 TEST_F(WebRtcVideoChannel2Test, DefaultReceiveStreamReconfiguresToUseRtx) { |
2582 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); | 2586 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2583 | 2587 |
2584 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); | 2588 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
2585 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); | 2589 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
2586 | 2590 |
2587 ASSERT_EQ(0u, fake_call_->GetVideoReceiveStreams().size()); | 2591 ASSERT_EQ(0u, fake_call_->GetVideoReceiveStreams().size()); |
2588 const size_t kDataLength = 12; | 2592 const size_t kDataLength = 12; |
2589 uint8_t data[kDataLength]; | 2593 uint8_t data[kDataLength]; |
2590 memset(data, 0, sizeof(data)); | 2594 memset(data, 0, sizeof(data)); |
2591 rtc::SetBE32(&data[8], ssrcs[0]); | 2595 rtc::SetBE32(&data[8], ssrcs[0]); |
2592 rtc::Buffer packet(data, kDataLength); | 2596 rtc::Buffer packet(data, kDataLength); |
(...skipping 10 matching lines...) Expand all Loading... |
2603 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs))); | 2607 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs))); |
2604 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()) | 2608 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()) |
2605 << "AddRecvStream should've reconfigured, not added a new receiver."; | 2609 << "AddRecvStream should've reconfigured, not added a new receiver."; |
2606 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; | 2610 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; |
2607 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.rtx.size()); | 2611 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.rtx.size()); |
2608 EXPECT_EQ(rtx_ssrcs[0], | 2612 EXPECT_EQ(rtx_ssrcs[0], |
2609 recv_stream->GetConfig().rtp.rtx.begin()->second.ssrc); | 2613 recv_stream->GetConfig().rtp.rtx.begin()->second.ssrc); |
2610 } | 2614 } |
2611 | 2615 |
2612 TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithMissingSsrcsForRtx) { | 2616 TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithMissingSsrcsForRtx) { |
2613 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); | 2617 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2614 | 2618 |
2615 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); | 2619 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
2616 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); | 2620 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
2617 | 2621 |
2618 StreamParams sp = | 2622 StreamParams sp = |
2619 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); | 2623 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); |
2620 sp.ssrcs = ssrcs; // Without RTXs, this is the important part. | 2624 sp.ssrcs = ssrcs; // Without RTXs, this is the important part. |
2621 | 2625 |
2622 EXPECT_FALSE(channel_->AddSendStream(sp)); | 2626 EXPECT_FALSE(channel_->AddSendStream(sp)); |
2623 EXPECT_FALSE(channel_->AddRecvStream(sp)); | 2627 EXPECT_FALSE(channel_->AddRecvStream(sp)); |
2624 } | 2628 } |
2625 | 2629 |
2626 TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithOverlappingRtxSsrcs) { | 2630 TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithOverlappingRtxSsrcs) { |
2627 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); | 2631 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2628 | 2632 |
2629 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); | 2633 const std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs1); |
2630 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); | 2634 const std::vector<uint32> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); |
2631 | 2635 |
2632 StreamParams sp = | 2636 StreamParams sp = |
2633 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); | 2637 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); |
2634 | 2638 |
2635 EXPECT_TRUE(channel_->AddSendStream(sp)); | 2639 EXPECT_TRUE(channel_->AddSendStream(sp)); |
2636 EXPECT_TRUE(channel_->AddRecvStream(sp)); | 2640 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
2637 | 2641 |
2638 // The RTX SSRC is already used in previous streams, using it should fail. | 2642 // The RTX SSRC is already used in previous streams, using it should fail. |
2639 sp = cricket::StreamParams::CreateLegacy(rtx_ssrcs[0]); | 2643 sp = cricket::StreamParams::CreateLegacy(rtx_ssrcs[0]); |
2640 EXPECT_FALSE(channel_->AddSendStream(sp)); | 2644 EXPECT_FALSE(channel_->AddSendStream(sp)); |
2641 EXPECT_FALSE(channel_->AddRecvStream(sp)); | 2645 EXPECT_FALSE(channel_->AddRecvStream(sp)); |
2642 | 2646 |
2643 // After removing the original stream this should be fine to add (makes sure | 2647 // After removing the original stream this should be fine to add (makes sure |
2644 // that RTX ssrcs are not forever taken). | 2648 // that RTX ssrcs are not forever taken). |
2645 EXPECT_TRUE(channel_->RemoveSendStream(ssrcs[0])); | 2649 EXPECT_TRUE(channel_->RemoveSendStream(ssrcs[0])); |
2646 EXPECT_TRUE(channel_->RemoveRecvStream(ssrcs[0])); | 2650 EXPECT_TRUE(channel_->RemoveRecvStream(ssrcs[0])); |
2647 EXPECT_TRUE(channel_->AddSendStream(sp)); | 2651 EXPECT_TRUE(channel_->AddSendStream(sp)); |
2648 EXPECT_TRUE(channel_->AddRecvStream(sp)); | 2652 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
2649 } | 2653 } |
2650 | 2654 |
2651 TEST_F(WebRtcVideoChannel2Test, | 2655 TEST_F(WebRtcVideoChannel2Test, |
2652 RejectsAddingStreamsWithOverlappingSimulcastSsrcs) { | 2656 RejectsAddingStreamsWithOverlappingSimulcastSsrcs) { |
2653 static const uint32 kFirstStreamSsrcs[] = {1, 2, 3}; | 2657 static const uint32 kFirstStreamSsrcs[] = {1, 2, 3}; |
2654 static const uint32 kOverlappingStreamSsrcs[] = {4, 3, 5}; | 2658 static const uint32 kOverlappingStreamSsrcs[] = {4, 3, 5}; |
2655 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); | 2659 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2656 | 2660 |
2657 StreamParams sp = | 2661 StreamParams sp = |
2658 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kFirstStreamSsrcs)); | 2662 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kFirstStreamSsrcs)); |
2659 | 2663 |
2660 EXPECT_TRUE(channel_->AddSendStream(sp)); | 2664 EXPECT_TRUE(channel_->AddSendStream(sp)); |
2661 EXPECT_TRUE(channel_->AddRecvStream(sp)); | 2665 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
2662 | 2666 |
2663 // One of the SSRCs is already used in previous streams, using it should fail. | 2667 // One of the SSRCs is already used in previous streams, using it should fail. |
2664 sp = cricket::CreateSimStreamParams("cname", | 2668 sp = cricket::CreateSimStreamParams("cname", |
2665 MAKE_VECTOR(kOverlappingStreamSsrcs)); | 2669 MAKE_VECTOR(kOverlappingStreamSsrcs)); |
2666 EXPECT_FALSE(channel_->AddSendStream(sp)); | 2670 EXPECT_FALSE(channel_->AddSendStream(sp)); |
2667 EXPECT_FALSE(channel_->AddRecvStream(sp)); | 2671 EXPECT_FALSE(channel_->AddRecvStream(sp)); |
2668 | 2672 |
2669 // After removing the original stream this should be fine to add (makes sure | 2673 // After removing the original stream this should be fine to add (makes sure |
2670 // that RTX ssrcs are not forever taken). | 2674 // that RTX ssrcs are not forever taken). |
2671 EXPECT_TRUE(channel_->RemoveSendStream(kFirstStreamSsrcs[0])); | 2675 EXPECT_TRUE(channel_->RemoveSendStream(kFirstStreamSsrcs[0])); |
2672 EXPECT_TRUE(channel_->RemoveRecvStream(kFirstStreamSsrcs[0])); | 2676 EXPECT_TRUE(channel_->RemoveRecvStream(kFirstStreamSsrcs[0])); |
2673 EXPECT_TRUE(channel_->AddSendStream(sp)); | 2677 EXPECT_TRUE(channel_->AddSendStream(sp)); |
2674 EXPECT_TRUE(channel_->AddRecvStream(sp)); | 2678 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
2675 } | 2679 } |
2676 | 2680 |
2677 TEST_F(WebRtcVideoChannel2Test, ReportsSsrcGroupsInStats) { | 2681 TEST_F(WebRtcVideoChannel2Test, ReportsSsrcGroupsInStats) { |
2678 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); | 2682 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2679 | 2683 |
2680 static const uint32_t kSenderSsrcs[] = {4, 7, 10}; | 2684 static const uint32_t kSenderSsrcs[] = {4, 7, 10}; |
2681 static const uint32_t kSenderRtxSsrcs[] = {5, 8, 11}; | 2685 static const uint32_t kSenderRtxSsrcs[] = {5, 8, 11}; |
2682 | 2686 |
2683 StreamParams sender_sp = cricket::CreateSimWithRtxStreamParams( | 2687 StreamParams sender_sp = cricket::CreateSimWithRtxStreamParams( |
2684 "cname", MAKE_VECTOR(kSenderSsrcs), MAKE_VECTOR(kSenderRtxSsrcs)); | 2688 "cname", MAKE_VECTOR(kSenderSsrcs), MAKE_VECTOR(kSenderRtxSsrcs)); |
2685 | 2689 |
2686 EXPECT_TRUE(channel_->AddSendStream(sender_sp)); | 2690 EXPECT_TRUE(channel_->AddSendStream(sender_sp)); |
2687 | 2691 |
2688 static const uint32_t kReceiverSsrcs[] = {3}; | 2692 static const uint32_t kReceiverSsrcs[] = {3}; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2722 // Report no codec name for unknown playload types. | 2726 // Report no codec name for unknown playload types. |
2723 stats.current_payload_type = 3; | 2727 stats.current_payload_type = 3; |
2724 stream->SetStats(stats); | 2728 stream->SetStats(stats); |
2725 ASSERT_TRUE(channel_->GetStats(&info)); | 2729 ASSERT_TRUE(channel_->GetStats(&info)); |
2726 EXPECT_STREQ("", info.receivers[0].codec_name.c_str()); | 2730 EXPECT_STREQ("", info.receivers[0].codec_name.c_str()); |
2727 } | 2731 } |
2728 | 2732 |
2729 void WebRtcVideoChannel2Test::TestReceiveUnsignalledSsrcPacket( | 2733 void WebRtcVideoChannel2Test::TestReceiveUnsignalledSsrcPacket( |
2730 uint8_t payload_type, | 2734 uint8_t payload_type, |
2731 bool expect_created_receive_stream) { | 2735 bool expect_created_receive_stream) { |
2732 std::vector<VideoCodec> codecs(engine_.codecs()); | |
2733 // Add a RED RTX codec. | 2736 // Add a RED RTX codec. |
2734 VideoCodec red_rtx_codec = | 2737 VideoCodec red_rtx_codec = |
2735 VideoCodec::CreateRtxCodec(kRedRtxPayloadType, kDefaultRedPlType); | 2738 VideoCodec::CreateRtxCodec(kRedRtxPayloadType, kDefaultRedPlType); |
2736 codecs.push_back(red_rtx_codec); | 2739 recv_parameters_.codecs.push_back(red_rtx_codec); |
2737 EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); | 2740 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
2738 | 2741 |
2739 ASSERT_EQ(0u, fake_call_->GetVideoReceiveStreams().size()); | 2742 ASSERT_EQ(0u, fake_call_->GetVideoReceiveStreams().size()); |
2740 const size_t kDataLength = 12; | 2743 const size_t kDataLength = 12; |
2741 uint8_t data[kDataLength]; | 2744 uint8_t data[kDataLength]; |
2742 memset(data, 0, sizeof(data)); | 2745 memset(data, 0, sizeof(data)); |
2743 | 2746 |
2744 rtc::Set8(data, 1, payload_type); | 2747 rtc::Set8(data, 1, payload_type); |
2745 rtc::SetBE32(&data[8], kIncomingUnsignalledSsrc); | 2748 rtc::SetBE32(&data[8], kIncomingUnsignalledSsrc); |
2746 rtc::Buffer packet(data, kDataLength); | 2749 rtc::Buffer packet(data, kDataLength); |
2747 rtc::PacketTime packet_time; | 2750 rtc::PacketTime packet_time; |
(...skipping 25 matching lines...) Expand all Loading... |
2773 TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) { | 2776 TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) { |
2774 TestReceiveUnsignalledSsrcPacket(kDefaultUlpfecType, false); | 2777 TestReceiveUnsignalledSsrcPacket(kDefaultUlpfecType, false); |
2775 } | 2778 } |
2776 | 2779 |
2777 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { | 2780 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { |
2778 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false); | 2781 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false); |
2779 } | 2782 } |
2780 | 2783 |
2781 void WebRtcVideoChannel2Test::TestReceiverLocalSsrcConfiguration( | 2784 void WebRtcVideoChannel2Test::TestReceiverLocalSsrcConfiguration( |
2782 bool receiver_first) { | 2785 bool receiver_first) { |
2783 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); | 2786 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2784 | 2787 |
2785 const uint32_t kSenderSsrc = 0xC0FFEE; | 2788 const uint32_t kSenderSsrc = 0xC0FFEE; |
2786 const uint32_t kReceiverSsrc = 0x4711; | 2789 const uint32_t kReceiverSsrc = 0x4711; |
2787 | 2790 |
2788 if (receiver_first) { | 2791 if (receiver_first) { |
2789 AddRecvStream(StreamParams::CreateLegacy(kReceiverSsrc)); | 2792 AddRecvStream(StreamParams::CreateLegacy(kReceiverSsrc)); |
2790 std::vector<FakeVideoReceiveStream*> receive_streams = | 2793 std::vector<FakeVideoReceiveStream*> receive_streams = |
2791 fake_call_->GetVideoReceiveStreams(); | 2794 fake_call_->GetVideoReceiveStreams(); |
2792 ASSERT_EQ(1u, receive_streams.size()); | 2795 ASSERT_EQ(1u, receive_streams.size()); |
2793 // Bogus local SSRC when we have no sender. | 2796 // Bogus local SSRC when we have no sender. |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2966 channel_.reset(engine_.CreateChannel(&fake_call_, VideoOptions())); | 2969 channel_.reset(engine_.CreateChannel(&fake_call_, VideoOptions())); |
2967 last_ssrc_ = 123; | 2970 last_ssrc_ = 123; |
2968 } | 2971 } |
2969 | 2972 |
2970 protected: | 2973 protected: |
2971 void VerifySimulcastSettings(const VideoCodec& codec, | 2974 void VerifySimulcastSettings(const VideoCodec& codec, |
2972 VideoOptions::HighestBitrate bitrate_mode, | 2975 VideoOptions::HighestBitrate bitrate_mode, |
2973 size_t num_configured_streams, | 2976 size_t num_configured_streams, |
2974 size_t expected_num_streams, | 2977 size_t expected_num_streams, |
2975 SimulcastBitrateMode simulcast_bitrate_mode) { | 2978 SimulcastBitrateMode simulcast_bitrate_mode) { |
2976 cricket::VideoOptions options; | 2979 cricket::VideoSendParameters parameters; |
2977 options.video_highest_bitrate.Set(bitrate_mode); | 2980 parameters.options.video_highest_bitrate.Set(bitrate_mode); |
2978 EXPECT_TRUE(channel_->SetOptions(options)); | 2981 parameters.codecs.push_back(codec); |
2979 | 2982 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
2980 std::vector<VideoCodec> codecs; | |
2981 codecs.push_back(codec); | |
2982 ASSERT_TRUE(channel_->SetSendCodecs(codecs)); | |
2983 | 2983 |
2984 std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs3); | 2984 std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs3); |
2985 RTC_DCHECK(num_configured_streams <= ssrcs.size()); | 2985 RTC_DCHECK(num_configured_streams <= ssrcs.size()); |
2986 ssrcs.resize(num_configured_streams); | 2986 ssrcs.resize(num_configured_streams); |
2987 | 2987 |
2988 FakeVideoSendStream* stream = | 2988 FakeVideoSendStream* stream = |
2989 AddSendStream(CreateSimStreamParams("cname", ssrcs)); | 2989 AddSendStream(CreateSimStreamParams("cname", ssrcs)); |
2990 // Send a full-size frame to trigger a stream reconfiguration to use all | 2990 // Send a full-size frame to trigger a stream reconfiguration to use all |
2991 // expected simulcast layers. | 2991 // expected simulcast layers. |
2992 cricket::FakeVideoCapturer capturer; | 2992 cricket::FakeVideoCapturer capturer; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3207 // Ensures that the correct settings are applied to the codec when two temporal | 3207 // Ensures that the correct settings are applied to the codec when two temporal |
3208 // layer screencasting is enabled, and that the correct simulcast settings are | 3208 // layer screencasting is enabled, and that the correct simulcast settings are |
3209 // reapplied when disabling screencasting. | 3209 // reapplied when disabling screencasting. |
3210 TEST_F(WebRtcVideoChannel2SimulcastTest, | 3210 TEST_F(WebRtcVideoChannel2SimulcastTest, |
3211 DISABLED_TwoTemporalLayerScreencastSettings) { | 3211 DISABLED_TwoTemporalLayerScreencastSettings) { |
3212 // TODO(pbos): Implement. | 3212 // TODO(pbos): Implement. |
3213 FAIL() << "Not implemented."; | 3213 FAIL() << "Not implemented."; |
3214 } | 3214 } |
3215 | 3215 |
3216 } // namespace cricket | 3216 } // namespace cricket |
OLD | NEW |