1 /* 2 * Copyright (c) 2013 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_CONFIGURABLE_FRAME_SIZE_ENCODER_H_ 12 #define TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_ 13 14 #include <stddef.h> 15 #include <stdint.h> 16 17 #include <functional> 18 #include <memory> 19 #include <vector> 20 21 #include "absl/types/optional.h" 22 #include "api/video/video_bitrate_allocation.h" 23 #include "api/video/video_frame.h" 24 #include "api/video_codecs/video_codec.h" 25 #include "api/video_codecs/video_encoder.h" 26 #include "modules/video_coding/include/video_codec_interface.h" 27 28 namespace webrtc { 29 namespace test { 30 31 class ConfigurableFrameSizeEncoder : public VideoEncoder { 32 public: 33 explicit ConfigurableFrameSizeEncoder(size_t max_frame_size); 34 ~ConfigurableFrameSizeEncoder() override; 35 36 void SetFecControllerOverride( 37 FecControllerOverride* fec_controller_override) override; 38 39 int32_t InitEncode(const VideoCodec* codec_settings, 40 const Settings& settings) override; 41 42 int32_t Encode(const VideoFrame& input_image, 43 const std::vector<VideoFrameType>* frame_types) override; 44 45 int32_t RegisterEncodeCompleteCallback( 46 EncodedImageCallback* callback) override; 47 48 int32_t Release() override; 49 50 void SetRates(const RateControlParameters& parameters) override; 51 52 int32_t SetFrameSize(size_t size); 53 54 void SetCodecType(VideoCodecType codec_type_); 55 56 void RegisterPostEncodeCallback( 57 std::function<void(void)> post_encode_callback); 58 59 private: 60 EncodedImageCallback* callback_; 61 absl::optional<std::function<void(void)>> post_encode_callback_; 62 63 const size_t max_frame_size_; 64 size_t current_frame_size_; 65 std::unique_ptr<uint8_t[]> buffer_; 66 VideoCodecType codec_type_; 67 }; 68 69 } // namespace test 70 } // namespace webrtc 71 72 #endif // TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_ 73