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 TEST_FAKE_VP8_ENCODER_H_ 12 #define TEST_FAKE_VP8_ENCODER_H_ 13 14 #include <stddef.h> 15 #include <stdint.h> 16 17 #include <memory> 18 19 #include "api/fec_controller_override.h" 20 #include "api/sequence_checker.h" 21 #include "api/video/encoded_image.h" 22 #include "api/video_codecs/video_codec.h" 23 #include "api/video_codecs/video_encoder.h" 24 #include "api/video_codecs/vp8_frame_buffer_controller.h" 25 #include "api/video_codecs/vp8_temporal_layers.h" 26 #include "modules/video_coding/include/video_codec_interface.h" 27 #include "rtc_base/thread_annotations.h" 28 #include "system_wrappers/include/clock.h" 29 #include "test/fake_encoder.h" 30 31 namespace webrtc { 32 namespace test { 33 34 class FakeVp8Encoder : public FakeEncoder { 35 public: 36 explicit FakeVp8Encoder(Clock* clock); 37 virtual ~FakeVp8Encoder() = default; 38 39 int32_t InitEncode(const VideoCodec* config, 40 const Settings& settings) override; 41 42 int32_t Release() override; 43 44 EncoderInfo GetEncoderInfo() const override; 45 46 private: 47 CodecSpecificInfo PopulateCodecSpecific(size_t size_bytes, 48 VideoFrameType frame_type, 49 int stream_idx, 50 uint32_t timestamp); 51 52 CodecSpecificInfo EncodeHook( 53 EncodedImage& encoded_image, 54 rtc::scoped_refptr<EncodedImageBuffer> buffer) override; 55 56 SequenceChecker sequence_checker_; 57 58 class FakeFecControllerOverride : public FecControllerOverride { 59 public: 60 ~FakeFecControllerOverride() override = default; 61 SetFecAllowed(bool fec_allowed)62 void SetFecAllowed(bool fec_allowed) override {} 63 }; 64 65 FakeFecControllerOverride fec_controller_override_ 66 RTC_GUARDED_BY(sequence_checker_); 67 68 std::unique_ptr<Vp8FrameBufferController> frame_buffer_controller_ 69 RTC_GUARDED_BY(sequence_checker_); 70 }; 71 72 } // namespace test 73 } // namespace webrtc 74 75 #endif // TEST_FAKE_VP8_ENCODER_H_ 76