1 /* 2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_VIDEO_CODING_UTILITY_SIMULCAST_TEST_FIXTURE_IMPL_H_ 12 #define MODULES_VIDEO_CODING_UTILITY_SIMULCAST_TEST_FIXTURE_IMPL_H_ 13 14 #include <memory> 15 #include <vector> 16 17 #include "api/test/mock_video_decoder.h" 18 #include "api/test/mock_video_encoder.h" 19 #include "api/test/simulcast_test_fixture.h" 20 #include "api/video/i420_buffer.h" 21 #include "api/video/video_frame.h" 22 #include "api/video_codecs/video_decoder_factory.h" 23 #include "api/video_codecs/video_encoder_factory.h" 24 #include "modules/video_coding/utility/simulcast_rate_allocator.h" 25 26 namespace webrtc { 27 namespace test { 28 29 class SimulcastTestFixtureImpl final : public SimulcastTestFixture { 30 public: 31 SimulcastTestFixtureImpl(std::unique_ptr<VideoEncoderFactory> encoder_factory, 32 std::unique_ptr<VideoDecoderFactory> decoder_factory, 33 SdpVideoFormat video_format); 34 ~SimulcastTestFixtureImpl() final; 35 36 // Implements SimulcastTestFixture. 37 void TestKeyFrameRequestsOnAllStreams() override; 38 void TestPaddingAllStreams() override; 39 void TestPaddingTwoStreams() override; 40 void TestPaddingTwoStreamsOneMaxedOut() override; 41 void TestPaddingOneStream() override; 42 void TestPaddingOneStreamTwoMaxedOut() override; 43 void TestSendAllStreams() override; 44 void TestDisablingStreams() override; 45 void TestActiveStreams() override; 46 void TestSwitchingToOneStream() override; 47 void TestSwitchingToOneOddStream() override; 48 void TestSwitchingToOneSmallStream() override; 49 void TestSpatioTemporalLayers333PatternEncoder() override; 50 void TestSpatioTemporalLayers321PatternEncoder() override; 51 void TestStrideEncodeDecode() override; 52 void TestDecodeWidthHeightSet() override; 53 54 static void DefaultSettings(VideoCodec* settings, 55 const int* temporal_layer_profile, 56 VideoCodecType codec_type, 57 bool reverse_layer_order = false); 58 59 private: 60 class TestEncodedImageCallback; 61 class TestDecodedImageCallback; 62 63 void SetUpCodec(const int* temporal_layer_profile); 64 void SetUpRateAllocator(); 65 void SetRates(uint32_t bitrate_kbps, uint32_t fps); 66 void RunActiveStreamsTest(const std::vector<bool> active_streams); 67 void UpdateActiveStreams(const std::vector<bool> active_streams); 68 void ExpectStreams(VideoFrameType frame_type, 69 const std::vector<bool> expected_streams_active); 70 void ExpectStreams(VideoFrameType frame_type, int expected_video_streams); 71 void VerifyTemporalIdxAndSyncForAllSpatialLayers( 72 TestEncodedImageCallback* encoder_callback, 73 const int* expected_temporal_idx, 74 const bool* expected_layer_sync, 75 int num_spatial_layers); 76 void SwitchingToOneStream(int width, int height); 77 78 std::unique_ptr<VideoEncoder> encoder_; 79 MockEncodedImageCallback encoder_callback_; 80 std::unique_ptr<VideoDecoder> decoder_; 81 MockDecodedImageCallback decoder_callback_; 82 VideoCodec settings_; 83 rtc::scoped_refptr<I420Buffer> input_buffer_; 84 std::unique_ptr<VideoFrame> input_frame_; 85 std::unique_ptr<SimulcastRateAllocator> rate_allocator_; 86 VideoCodecType codec_type_; 87 }; 88 89 } // namespace test 90 } // namespace webrtc 91 92 #endif // MODULES_VIDEO_CODING_UTILITY_SIMULCAST_TEST_FIXTURE_IMPL_H_ 93