sprang@webrtc.org | 8b88192 | 2013-12-10 10:05:17 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_ |
| 12 | #define TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_ |
sprang@webrtc.org | 8b88192 | 2013-12-10 10:05:17 +0000 | [diff] [blame] | 13 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
| 16 | #include <functional> |
kwiberg | bfefb03 | 2016-05-01 14:53:46 -0700 | [diff] [blame] | 17 | #include <memory> |
sprang@webrtc.org | 8b88192 | 2013-12-10 10:05:17 +0000 | [diff] [blame] | 18 | #include <vector> |
| 19 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 20 | #include "absl/types/optional.h" |
| 21 | #include "api/video/video_bitrate_allocation.h" |
| 22 | #include "api/video/video_frame.h" |
| 23 | #include "api/video_codecs/video_codec.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 24 | #include "api/video_codecs/video_encoder.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 25 | #include "modules/video_coding/include/video_codec_interface.h" |
sprang@webrtc.org | 8b88192 | 2013-12-10 10:05:17 +0000 | [diff] [blame] | 26 | |
| 27 | namespace webrtc { |
| 28 | namespace test { |
| 29 | |
| 30 | class ConfigurableFrameSizeEncoder : public VideoEncoder { |
| 31 | public: |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 32 | explicit ConfigurableFrameSizeEncoder(size_t max_frame_size); |
Ilya Nikolaevskiy | b0588e6 | 2018-08-27 14:12:27 +0200 | [diff] [blame] | 33 | ~ConfigurableFrameSizeEncoder() override; |
sprang@webrtc.org | 8b88192 | 2013-12-10 10:05:17 +0000 | [diff] [blame] | 34 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 35 | int32_t InitEncode(const VideoCodec* codec_settings, |
Elad Alon | 370f93a | 2019-06-11 14:57:57 +0200 | [diff] [blame] | 36 | const Settings& settings) override; |
sprang@webrtc.org | 8b88192 | 2013-12-10 10:05:17 +0000 | [diff] [blame] | 37 | |
Miguel Casas-Sanchez | 4765070 | 2015-05-29 17:21:40 -0700 | [diff] [blame] | 38 | int32_t Encode(const VideoFrame& input_image, |
Niels Möller | 87e2d78 | 2019-03-07 10:18:23 +0100 | [diff] [blame] | 39 | const std::vector<VideoFrameType>* frame_types) override; |
sprang@webrtc.org | 8b88192 | 2013-12-10 10:05:17 +0000 | [diff] [blame] | 40 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 41 | int32_t RegisterEncodeCompleteCallback( |
| 42 | EncodedImageCallback* callback) override; |
sprang@webrtc.org | 8b88192 | 2013-12-10 10:05:17 +0000 | [diff] [blame] | 43 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 44 | int32_t Release() override; |
sprang@webrtc.org | 8b88192 | 2013-12-10 10:05:17 +0000 | [diff] [blame] | 45 | |
Erik Språng | 16cb8f5 | 2019-04-12 13:59:09 +0200 | [diff] [blame] | 46 | void SetRates(const RateControlParameters& parameters) override; |
sprang@webrtc.org | 8b88192 | 2013-12-10 10:05:17 +0000 | [diff] [blame] | 47 | |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 48 | int32_t SetFrameSize(size_t size); |
sprang@webrtc.org | 8b88192 | 2013-12-10 10:05:17 +0000 | [diff] [blame] | 49 | |
Philip Eliasson | d52a1a6 | 2018-09-07 13:03:55 +0000 | [diff] [blame] | 50 | void SetCodecType(VideoCodecType codec_type_); |
| 51 | |
Niels Möller | 759f959 | 2018-10-09 14:57:01 +0200 | [diff] [blame] | 52 | void RegisterPostEncodeCallback( |
| 53 | std::function<void(void)> post_encode_callback); |
| 54 | |
sprang@webrtc.org | 8b88192 | 2013-12-10 10:05:17 +0000 | [diff] [blame] | 55 | private: |
| 56 | EncodedImageCallback* callback_; |
Niels Möller | 759f959 | 2018-10-09 14:57:01 +0200 | [diff] [blame] | 57 | absl::optional<std::function<void(void)>> post_encode_callback_; |
| 58 | |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 59 | const size_t max_frame_size_; |
| 60 | size_t current_frame_size_; |
kwiberg | bfefb03 | 2016-05-01 14:53:46 -0700 | [diff] [blame] | 61 | std::unique_ptr<uint8_t[]> buffer_; |
Philip Eliasson | d52a1a6 | 2018-09-07 13:03:55 +0000 | [diff] [blame] | 62 | VideoCodecType codec_type_; |
sprang@webrtc.org | 8b88192 | 2013-12-10 10:05:17 +0000 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | } // namespace test |
| 66 | } // namespace webrtc |
| 67 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 68 | #endif // TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_ |