blob: 390b2b113a8e0bcc75d796e04f379d398f1808c0 [file] [log] [blame]
sprang@webrtc.org8b881922013-12-10 10:05:17 +00001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_
12#define TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_
sprang@webrtc.org8b881922013-12-10 10:05:17 +000013
Yves Gerey3e707812018-11-28 16:47:49 +010014#include <stddef.h>
15#include <stdint.h>
16#include <functional>
kwibergbfefb032016-05-01 14:53:46 -070017#include <memory>
sprang@webrtc.org8b881922013-12-10 10:05:17 +000018#include <vector>
19
Yves Gerey3e707812018-11-28 16:47:49 +010020#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 Bonadei92ea95e2017-09-15 06:47:31 +020024#include "api/video_codecs/video_encoder.h"
Yves Gerey3e707812018-11-28 16:47:49 +010025#include "common_types.h" // NOLINT(build/include)
26#include "modules/video_coding/include/video_codec_interface.h"
sprang@webrtc.org8b881922013-12-10 10:05:17 +000027
28namespace webrtc {
29namespace test {
30
31class ConfigurableFrameSizeEncoder : public VideoEncoder {
32 public:
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000033 explicit ConfigurableFrameSizeEncoder(size_t max_frame_size);
Ilya Nikolaevskiyb0588e62018-08-27 14:12:27 +020034 ~ConfigurableFrameSizeEncoder() override;
sprang@webrtc.org8b881922013-12-10 10:05:17 +000035
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000036 int32_t InitEncode(const VideoCodec* codec_settings,
37 int32_t number_of_cores,
38 size_t max_payload_size) override;
sprang@webrtc.org8b881922013-12-10 10:05:17 +000039
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070040 int32_t Encode(const VideoFrame& input_image,
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000041 const CodecSpecificInfo* codec_specific_info,
pbos22993e12015-10-19 02:39:06 -070042 const std::vector<FrameType>* frame_types) override;
sprang@webrtc.org8b881922013-12-10 10:05:17 +000043
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000044 int32_t RegisterEncodeCompleteCallback(
45 EncodedImageCallback* callback) override;
sprang@webrtc.org8b881922013-12-10 10:05:17 +000046
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000047 int32_t Release() override;
sprang@webrtc.org8b881922013-12-10 10:05:17 +000048
Erik Språng566124a2018-04-23 12:32:22 +020049 int32_t SetRateAllocation(const VideoBitrateAllocation& allocation,
Erik Språng08127a92016-11-16 16:41:30 +010050 uint32_t framerate) override;
sprang@webrtc.org8b881922013-12-10 10:05:17 +000051
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000052 int32_t SetFrameSize(size_t size);
sprang@webrtc.org8b881922013-12-10 10:05:17 +000053
Philip Eliassond52a1a62018-09-07 13:03:55 +000054 void SetCodecType(VideoCodecType codec_type_);
55
Niels Möller759f9592018-10-09 14:57:01 +020056 void RegisterPostEncodeCallback(
57 std::function<void(void)> post_encode_callback);
58
sprang@webrtc.org8b881922013-12-10 10:05:17 +000059 private:
60 EncodedImageCallback* callback_;
Niels Möller759f9592018-10-09 14:57:01 +020061 absl::optional<std::function<void(void)>> post_encode_callback_;
62
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000063 const size_t max_frame_size_;
64 size_t current_frame_size_;
kwibergbfefb032016-05-01 14:53:46 -070065 std::unique_ptr<uint8_t[]> buffer_;
Philip Eliassond52a1a62018-09-07 13:03:55 +000066 VideoCodecType codec_type_;
sprang@webrtc.org8b881922013-12-10 10:05:17 +000067};
68
69} // namespace test
70} // namespace webrtc
71
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020072#endif // TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_