OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "webrtc/test/gtest.h" | 27 #include "webrtc/test/gtest.h" |
28 #include "webrtc/video/send_statistics_proxy.h" | 28 #include "webrtc/video/send_statistics_proxy.h" |
29 #include "webrtc/video/video_stream_encoder.h" | 29 #include "webrtc/video/video_stream_encoder.h" |
30 | 30 |
31 namespace { | 31 namespace { |
32 // TODO(kthelgason): Lower this limit when better testing | 32 // TODO(kthelgason): Lower this limit when better testing |
33 // on MediaCodec and fallback implementations are in place. | 33 // on MediaCodec and fallback implementations are in place. |
34 const int kMinPixelsPerFrame = 320 * 180; | 34 const int kMinPixelsPerFrame = 320 * 180; |
35 const int kMinFramerateFps = 2; | 35 const int kMinFramerateFps = 2; |
36 const int64_t kFrameTimeoutMs = 100; | 36 const int64_t kFrameTimeoutMs = 100; |
37 const unsigned char kNumSlDummy = 0; | |
38 } // namespace | 37 } // namespace |
39 | 38 |
40 namespace webrtc { | 39 namespace webrtc { |
41 | 40 |
42 using DegredationPreference = VideoSendStream::DegradationPreference; | 41 using DegredationPreference = VideoSendStream::DegradationPreference; |
43 using ScaleReason = AdaptationObserverInterface::AdaptReason; | 42 using ScaleReason = AdaptationObserverInterface::AdaptReason; |
44 using ::testing::_; | 43 using ::testing::_; |
45 using ::testing::Return; | 44 using ::testing::Return; |
46 | 45 |
47 namespace { | 46 namespace { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 VideoSendStream::DegradationPreference::kMaintainFramerate); | 310 VideoSendStream::DegradationPreference::kMaintainFramerate); |
312 video_stream_encoder_->SetStartBitrate(kTargetBitrateBps); | 311 video_stream_encoder_->SetStartBitrate(kTargetBitrateBps); |
313 video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config), | 312 video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config), |
314 kMaxPayloadLength, nack_enabled); | 313 kMaxPayloadLength, nack_enabled); |
315 video_stream_encoder_->WaitUntilTaskQueueIsIdle(); | 314 video_stream_encoder_->WaitUntilTaskQueueIsIdle(); |
316 } | 315 } |
317 | 316 |
318 void ResetEncoder(const std::string& payload_name, | 317 void ResetEncoder(const std::string& payload_name, |
319 size_t num_streams, | 318 size_t num_streams, |
320 size_t num_temporal_layers, | 319 size_t num_temporal_layers, |
321 unsigned char num_spatial_layers, | |
322 bool nack_enabled, | 320 bool nack_enabled, |
323 bool screenshare) { | 321 bool screenshare) { |
324 video_send_config_.encoder_settings.payload_name = payload_name; | 322 video_send_config_.encoder_settings.payload_name = payload_name; |
325 | 323 |
326 VideoEncoderConfig video_encoder_config; | 324 VideoEncoderConfig video_encoder_config; |
327 video_encoder_config.number_of_streams = num_streams; | 325 video_encoder_config.number_of_streams = num_streams; |
328 video_encoder_config.max_bitrate_bps = kTargetBitrateBps; | 326 video_encoder_config.max_bitrate_bps = kTargetBitrateBps; |
329 video_encoder_config.video_stream_factory = | 327 video_encoder_config.video_stream_factory = |
330 new rtc::RefCountedObject<VideoStreamFactory>(num_temporal_layers, | 328 new rtc::RefCountedObject<VideoStreamFactory>(num_temporal_layers, |
331 kDefaultFramerate); | 329 kDefaultFramerate); |
332 video_encoder_config.content_type = | 330 video_encoder_config.content_type = |
333 screenshare ? VideoEncoderConfig::ContentType::kScreen | 331 screenshare ? VideoEncoderConfig::ContentType::kScreen |
334 : VideoEncoderConfig::ContentType::kRealtimeVideo; | 332 : VideoEncoderConfig::ContentType::kRealtimeVideo; |
335 if (payload_name == "VP9") { | |
336 VideoCodecVP9 vp9_settings = VideoEncoder::GetDefaultVp9Settings(); | |
337 vp9_settings.numberOfSpatialLayers = num_spatial_layers; | |
338 video_encoder_config.encoder_specific_settings = | |
339 new rtc::RefCountedObject< | |
340 VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings); | |
341 } | |
342 ConfigureEncoder(std::move(video_encoder_config), nack_enabled); | 333 ConfigureEncoder(std::move(video_encoder_config), nack_enabled); |
343 } | 334 } |
344 | 335 |
345 VideoFrame CreateFrame(int64_t ntp_time_ms, | 336 VideoFrame CreateFrame(int64_t ntp_time_ms, |
346 rtc::Event* destruction_event) const { | 337 rtc::Event* destruction_event) const { |
347 VideoFrame frame(new rtc::RefCountedObject<TestBuffer>( | 338 VideoFrame frame(new rtc::RefCountedObject<TestBuffer>( |
348 destruction_event, codec_width_, codec_height_), | 339 destruction_event, codec_width_, codec_height_), |
349 99, 99, kVideoRotation_0); | 340 99, 99, kVideoRotation_0); |
350 frame.set_ntp_time_ms(ntp_time_ms); | 341 frame.set_ntp_time_ms(ntp_time_ms); |
351 return frame; | 342 return frame; |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 EXPECT_EQ(codec_height_, fake_encoder_.codec_config().height); | 792 EXPECT_EQ(codec_height_, fake_encoder_.codec_config().height); |
802 EXPECT_EQ(2, sink_.number_of_reconfigurations()); | 793 EXPECT_EQ(2, sink_.number_of_reconfigurations()); |
803 | 794 |
804 video_stream_encoder_->Stop(); | 795 video_stream_encoder_->Stop(); |
805 } | 796 } |
806 | 797 |
807 TEST_F(VideoStreamEncoderTest, Vp8ResilienceIsOffFor1S1TLWithNackEnabled) { | 798 TEST_F(VideoStreamEncoderTest, Vp8ResilienceIsOffFor1S1TLWithNackEnabled) { |
808 const bool kNackEnabled = true; | 799 const bool kNackEnabled = true; |
809 const size_t kNumStreams = 1; | 800 const size_t kNumStreams = 1; |
810 const size_t kNumTl = 1; | 801 const size_t kNumTl = 1; |
811 ResetEncoder("VP8", kNumStreams, kNumTl, kNumSlDummy, kNackEnabled, false); | 802 ResetEncoder("VP8", kNumStreams, kNumTl, kNackEnabled, false); |
812 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 803 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
813 | 804 |
814 // Capture a frame and wait for it to synchronize with the encoder thread. | 805 // Capture a frame and wait for it to synchronize with the encoder thread. |
815 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); | 806 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); |
816 WaitForEncodedFrame(1); | 807 WaitForEncodedFrame(1); |
817 // The encoder have been configured once when the first frame is received. | 808 // The encoder have been configured once when the first frame is received. |
818 EXPECT_EQ(1, sink_.number_of_reconfigurations()); | 809 EXPECT_EQ(1, sink_.number_of_reconfigurations()); |
819 EXPECT_EQ(kVideoCodecVP8, fake_encoder_.codec_config().codecType); | 810 EXPECT_EQ(kVideoCodecVP8, fake_encoder_.codec_config().codecType); |
820 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams); | 811 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams); |
821 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers); | 812 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers); |
822 // Resilience is off for no temporal layers with nack on. | 813 // Resilience is off for no temporal layers with nack on. |
823 EXPECT_EQ(kResilienceOff, fake_encoder_.codec_config().VP8()->resilience); | 814 EXPECT_EQ(kResilienceOff, fake_encoder_.codec_config().VP8()->resilience); |
824 video_stream_encoder_->Stop(); | 815 video_stream_encoder_->Stop(); |
825 } | 816 } |
826 | 817 |
827 TEST_F(VideoStreamEncoderTest, Vp8ResilienceIsOffFor2S1TlWithNackEnabled) { | 818 TEST_F(VideoStreamEncoderTest, Vp8ResilienceIsOffFor2S1TlWithNackEnabled) { |
828 const bool kNackEnabled = true; | 819 const bool kNackEnabled = true; |
829 const size_t kNumStreams = 2; | 820 const size_t kNumStreams = 2; |
830 const size_t kNumTl = 1; | 821 const size_t kNumTl = 1; |
831 ResetEncoder("VP8", kNumStreams, kNumTl, kNumSlDummy, kNackEnabled, false); | 822 ResetEncoder("VP8", kNumStreams, kNumTl, kNackEnabled, false); |
832 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 823 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
833 | 824 |
834 // Capture a frame and wait for it to synchronize with the encoder thread. | 825 // Capture a frame and wait for it to synchronize with the encoder thread. |
835 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); | 826 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); |
836 WaitForEncodedFrame(1); | 827 WaitForEncodedFrame(1); |
837 // The encoder have been configured once when the first frame is received. | 828 // The encoder have been configured once when the first frame is received. |
838 EXPECT_EQ(1, sink_.number_of_reconfigurations()); | 829 EXPECT_EQ(1, sink_.number_of_reconfigurations()); |
839 EXPECT_EQ(kVideoCodecVP8, fake_encoder_.codec_config().codecType); | 830 EXPECT_EQ(kVideoCodecVP8, fake_encoder_.codec_config().codecType); |
840 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams); | 831 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams); |
841 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers); | 832 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers); |
842 // Resilience is off for no temporal layers and >1 streams with nack on. | 833 // Resilience is off for no temporal layers and >1 streams with nack on. |
843 EXPECT_EQ(kResilienceOff, fake_encoder_.codec_config().VP8()->resilience); | 834 EXPECT_EQ(kResilienceOff, fake_encoder_.codec_config().VP8()->resilience); |
844 video_stream_encoder_->Stop(); | 835 video_stream_encoder_->Stop(); |
845 } | 836 } |
846 | 837 |
847 TEST_F(VideoStreamEncoderTest, Vp8ResilienceIsOnFor1S1TLWithNackDisabled) { | 838 TEST_F(VideoStreamEncoderTest, Vp8ResilienceIsOnFor1S1TLWithNackDisabled) { |
848 const bool kNackEnabled = false; | 839 const bool kNackEnabled = false; |
849 const size_t kNumStreams = 1; | 840 const size_t kNumStreams = 1; |
850 const size_t kNumTl = 1; | 841 const size_t kNumTl = 1; |
851 ResetEncoder("VP8", kNumStreams, kNumTl, kNumSlDummy, kNackEnabled, false); | 842 ResetEncoder("VP8", kNumStreams, kNumTl, kNackEnabled, false); |
852 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 843 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
853 | 844 |
854 // Capture a frame and wait for it to synchronize with the encoder thread. | 845 // Capture a frame and wait for it to synchronize with the encoder thread. |
855 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); | 846 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); |
856 WaitForEncodedFrame(1); | 847 WaitForEncodedFrame(1); |
857 // The encoder have been configured once when the first frame is received. | 848 // The encoder have been configured once when the first frame is received. |
858 EXPECT_EQ(1, sink_.number_of_reconfigurations()); | 849 EXPECT_EQ(1, sink_.number_of_reconfigurations()); |
859 EXPECT_EQ(kVideoCodecVP8, fake_encoder_.codec_config().codecType); | 850 EXPECT_EQ(kVideoCodecVP8, fake_encoder_.codec_config().codecType); |
860 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams); | 851 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams); |
861 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers); | 852 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers); |
862 // Resilience is on for no temporal layers with nack off. | 853 // Resilience is on for no temporal layers with nack off. |
863 EXPECT_EQ(kResilientStream, fake_encoder_.codec_config().VP8()->resilience); | 854 EXPECT_EQ(kResilientStream, fake_encoder_.codec_config().VP8()->resilience); |
864 video_stream_encoder_->Stop(); | 855 video_stream_encoder_->Stop(); |
865 } | 856 } |
866 | 857 |
867 TEST_F(VideoStreamEncoderTest, Vp8ResilienceIsOnFor1S2TlWithNackEnabled) { | 858 TEST_F(VideoStreamEncoderTest, Vp8ResilienceIsOnFor1S2TlWithNackEnabled) { |
868 const bool kNackEnabled = true; | 859 const bool kNackEnabled = true; |
869 const size_t kNumStreams = 1; | 860 const size_t kNumStreams = 1; |
870 const size_t kNumTl = 2; | 861 const size_t kNumTl = 2; |
871 ResetEncoder("VP8", kNumStreams, kNumTl, kNumSlDummy, kNackEnabled, false); | 862 ResetEncoder("VP8", kNumStreams, kNumTl, kNackEnabled, false); |
872 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 863 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
873 | 864 |
874 // Capture a frame and wait for it to synchronize with the encoder thread. | 865 // Capture a frame and wait for it to synchronize with the encoder thread. |
875 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); | 866 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); |
876 WaitForEncodedFrame(1); | 867 WaitForEncodedFrame(1); |
877 // The encoder have been configured once when the first frame is received. | 868 // The encoder have been configured once when the first frame is received. |
878 EXPECT_EQ(1, sink_.number_of_reconfigurations()); | 869 EXPECT_EQ(1, sink_.number_of_reconfigurations()); |
879 EXPECT_EQ(kVideoCodecVP8, fake_encoder_.codec_config().codecType); | 870 EXPECT_EQ(kVideoCodecVP8, fake_encoder_.codec_config().codecType); |
880 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams); | 871 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams); |
881 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers); | 872 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP8()->numberOfTemporalLayers); |
882 // Resilience is on for temporal layers. | 873 // Resilience is on for temporal layers. |
883 EXPECT_EQ(kResilientStream, fake_encoder_.codec_config().VP8()->resilience); | 874 EXPECT_EQ(kResilientStream, fake_encoder_.codec_config().VP8()->resilience); |
884 video_stream_encoder_->Stop(); | 875 video_stream_encoder_->Stop(); |
885 } | 876 } |
886 | 877 |
887 TEST_F(VideoStreamEncoderTest, Vp9ResilienceIsOffFor1SL1TLWithNackEnabled) { | |
888 const bool kNackEnabled = true; | |
889 const size_t kNumStreams = 1; | |
890 const size_t kNumTl = 1; | |
891 const unsigned char kNumSl = 1; | |
892 ResetEncoder("VP9", kNumStreams, kNumTl, kNumSl, kNackEnabled, false); | |
893 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | |
894 | |
895 // Capture a frame and wait for it to synchronize with the encoder thread. | |
896 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); | |
897 sink_.WaitForEncodedFrame(1); | |
898 // The encoder have been configured once when the first frame is received. | |
899 EXPECT_EQ(1, sink_.number_of_reconfigurations()); | |
900 EXPECT_EQ(kVideoCodecVP9, fake_encoder_.codec_config().codecType); | |
901 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams); | |
902 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP9()->numberOfTemporalLayers); | |
903 EXPECT_EQ(kNumSl, fake_encoder_.codec_config().VP9()->numberOfSpatialLayers); | |
904 // Resilience is off for no spatial and temporal layers with nack on. | |
905 EXPECT_FALSE(fake_encoder_.codec_config().VP9()->resilienceOn); | |
906 video_stream_encoder_->Stop(); | |
907 } | |
908 | |
909 TEST_F(VideoStreamEncoderTest, Vp9ResilienceIsOnFor1SL1TLWithNackDisabled) { | |
910 const bool kNackEnabled = false; | |
911 const size_t kNumStreams = 1; | |
912 const size_t kNumTl = 1; | |
913 const unsigned char kNumSl = 1; | |
914 ResetEncoder("VP9", kNumStreams, kNumTl, kNumSl, kNackEnabled, false); | |
915 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | |
916 | |
917 // Capture a frame and wait for it to synchronize with the encoder thread. | |
918 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); | |
919 sink_.WaitForEncodedFrame(1); | |
920 // The encoder have been configured once when the first frame is received. | |
921 EXPECT_EQ(1, sink_.number_of_reconfigurations()); | |
922 EXPECT_EQ(kVideoCodecVP9, fake_encoder_.codec_config().codecType); | |
923 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams); | |
924 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP9()->numberOfTemporalLayers); | |
925 EXPECT_EQ(kNumSl, fake_encoder_.codec_config().VP9()->numberOfSpatialLayers); | |
926 // Resilience is on if nack is off. | |
927 EXPECT_TRUE(fake_encoder_.codec_config().VP9()->resilienceOn); | |
928 video_stream_encoder_->Stop(); | |
929 } | |
930 | |
931 TEST_F(VideoStreamEncoderTest, Vp9ResilienceIsOnFor2SL1TLWithNackEnabled) { | |
932 const bool kNackEnabled = true; | |
933 const size_t kNumStreams = 1; | |
934 const size_t kNumTl = 1; | |
935 const unsigned char kNumSl = 2; | |
936 ResetEncoder("VP9", kNumStreams, kNumTl, kNumSl, kNackEnabled, false); | |
937 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | |
938 | |
939 // Capture a frame and wait for it to synchronize with the encoder thread. | |
940 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); | |
941 sink_.WaitForEncodedFrame(1); | |
942 // The encoder have been configured once when the first frame is received. | |
943 EXPECT_EQ(1, sink_.number_of_reconfigurations()); | |
944 EXPECT_EQ(kVideoCodecVP9, fake_encoder_.codec_config().codecType); | |
945 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams); | |
946 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP9()->numberOfTemporalLayers); | |
947 EXPECT_EQ(kNumSl, fake_encoder_.codec_config().VP9()->numberOfSpatialLayers); | |
948 // Resilience is on for spatial layers. | |
949 EXPECT_TRUE(fake_encoder_.codec_config().VP9()->resilienceOn); | |
950 video_stream_encoder_->Stop(); | |
951 } | |
952 | |
953 TEST_F(VideoStreamEncoderTest, Vp9ResilienceIsOnFor1SL2TLWithNackEnabled) { | |
954 const bool kNackEnabled = true; | |
955 const size_t kNumStreams = 1; | |
956 const size_t kNumTl = 2; | |
957 const unsigned char kNumSl = 1; | |
958 ResetEncoder("VP9", kNumStreams, kNumTl, kNumSl, kNackEnabled, false); | |
959 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | |
960 | |
961 // Capture a frame and wait for it to synchronize with the encoder thread. | |
962 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); | |
963 sink_.WaitForEncodedFrame(1); | |
964 // The encoder have been configured once when the first frame is received. | |
965 EXPECT_EQ(1, sink_.number_of_reconfigurations()); | |
966 EXPECT_EQ(kVideoCodecVP9, fake_encoder_.codec_config().codecType); | |
967 EXPECT_EQ(kNumStreams, fake_encoder_.codec_config().numberOfSimulcastStreams); | |
968 EXPECT_EQ(kNumTl, fake_encoder_.codec_config().VP9()->numberOfTemporalLayers); | |
969 EXPECT_EQ(kNumSl, fake_encoder_.codec_config().VP9()->numberOfSpatialLayers); | |
970 // Resilience is on for temporal layers. | |
971 EXPECT_TRUE(fake_encoder_.codec_config().VP9()->resilienceOn); | |
972 video_stream_encoder_->Stop(); | |
973 } | |
974 | |
975 TEST_F(VideoStreamEncoderTest, SwitchSourceDeregisterEncoderAsSink) { | 878 TEST_F(VideoStreamEncoderTest, SwitchSourceDeregisterEncoderAsSink) { |
976 EXPECT_TRUE(video_source_.has_sinks()); | 879 EXPECT_TRUE(video_source_.has_sinks()); |
977 test::FrameForwarder new_video_source; | 880 test::FrameForwarder new_video_source; |
978 video_stream_encoder_->SetSource( | 881 video_stream_encoder_->SetSource( |
979 &new_video_source, | 882 &new_video_source, |
980 VideoSendStream::DegradationPreference::kMaintainFramerate); | 883 VideoSendStream::DegradationPreference::kMaintainFramerate); |
981 EXPECT_FALSE(video_source_.has_sinks()); | 884 EXPECT_FALSE(video_source_.has_sinks()); |
982 EXPECT_TRUE(new_video_source.has_sinks()); | 885 EXPECT_TRUE(new_video_source.has_sinks()); |
983 | 886 |
984 video_stream_encoder_->Stop(); | 887 video_stream_encoder_->Stop(); |
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2553 EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution); | 2456 EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution); |
2554 EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_framerate); | 2457 EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_framerate); |
2555 EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes); | 2458 EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes); |
2556 | 2459 |
2557 video_stream_encoder_->Stop(); | 2460 video_stream_encoder_->Stop(); |
2558 } | 2461 } |
2559 | 2462 |
2560 TEST_F(VideoStreamEncoderTest, FailingInitEncodeDoesntCauseCrash) { | 2463 TEST_F(VideoStreamEncoderTest, FailingInitEncodeDoesntCauseCrash) { |
2561 fake_encoder_.ForceInitEncodeFailure(true); | 2464 fake_encoder_.ForceInitEncodeFailure(true); |
2562 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 2465 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
2563 ResetEncoder("VP8", 2, 1, 1, true, false); | 2466 ResetEncoder("VP8", 2, 1, true, false); |
2564 const int kFrameWidth = 1280; | 2467 const int kFrameWidth = 1280; |
2565 const int kFrameHeight = 720; | 2468 const int kFrameHeight = 720; |
2566 video_source_.IncomingCapturedFrame( | 2469 video_source_.IncomingCapturedFrame( |
2567 CreateFrame(1, kFrameWidth, kFrameHeight)); | 2470 CreateFrame(1, kFrameWidth, kFrameHeight)); |
2568 ExpectDroppedFrame(); | 2471 ExpectDroppedFrame(); |
2569 video_stream_encoder_->Stop(); | 2472 video_stream_encoder_->Stop(); |
2570 } | 2473 } |
2571 | 2474 |
2572 // TODO(sprang): Extend this with fps throttling and any "balanced" extensions. | 2475 // TODO(sprang): Extend this with fps throttling and any "balanced" extensions. |
2573 TEST_F(VideoStreamEncoderTest, | 2476 TEST_F(VideoStreamEncoderTest, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2700 | 2603 |
2701 TEST_F(VideoStreamEncoderTest, DoesntAdaptDownPastMinFramerate) { | 2604 TEST_F(VideoStreamEncoderTest, DoesntAdaptDownPastMinFramerate) { |
2702 const int kFramerateFps = 5; | 2605 const int kFramerateFps = 5; |
2703 const int kFrameIntervalMs = rtc::kNumMillisecsPerSec / kFramerateFps; | 2606 const int kFrameIntervalMs = rtc::kNumMillisecsPerSec / kFramerateFps; |
2704 const int kMinFpsFrameInterval = rtc::kNumMillisecsPerSec / kMinFramerateFps; | 2607 const int kMinFpsFrameInterval = rtc::kNumMillisecsPerSec / kMinFramerateFps; |
2705 const int kFrameWidth = 1280; | 2608 const int kFrameWidth = 1280; |
2706 const int kFrameHeight = 720; | 2609 const int kFrameHeight = 720; |
2707 | 2610 |
2708 // Reconfigure encoder with two temporal layers and screensharing, which will | 2611 // Reconfigure encoder with two temporal layers and screensharing, which will |
2709 // disable frame dropping and make testing easier. | 2612 // disable frame dropping and make testing easier. |
2710 ResetEncoder("VP8", 1, 2, 1, true, true); | 2613 ResetEncoder("VP8", 1, 2, true, true); |
2711 | 2614 |
2712 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 2615 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
2713 video_stream_encoder_->SetSource( | 2616 video_stream_encoder_->SetSource( |
2714 &video_source_, | 2617 &video_source_, |
2715 VideoSendStream::DegradationPreference::kMaintainResolution); | 2618 VideoSendStream::DegradationPreference::kMaintainResolution); |
2716 video_source_.set_adaptation_enabled(true); | 2619 video_source_.set_adaptation_enabled(true); |
2717 | 2620 |
2718 int64_t timestamp_ms = fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec; | 2621 int64_t timestamp_ms = fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec; |
2719 | 2622 |
2720 // Trigger overuse as much as we can. | 2623 // Trigger overuse as much as we can. |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3273 // Bitrate observer should not be called. | 3176 // Bitrate observer should not be called. |
3274 EXPECT_CALL(bitrate_observer, OnBitrateAllocationUpdated(_)).Times(0); | 3177 EXPECT_CALL(bitrate_observer, OnBitrateAllocationUpdated(_)).Times(0); |
3275 video_source_.IncomingCapturedFrame( | 3178 video_source_.IncomingCapturedFrame( |
3276 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); | 3179 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); |
3277 ExpectDroppedFrame(); | 3180 ExpectDroppedFrame(); |
3278 | 3181 |
3279 video_stream_encoder_->Stop(); | 3182 video_stream_encoder_->Stop(); |
3280 } | 3183 } |
3281 | 3184 |
3282 } // namespace webrtc | 3185 } // namespace webrtc |
OLD | NEW |