configurable_frame_size_encoder.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #ifndef TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_
  11. #define TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include <functional>
  15. #include <memory>
  16. #include <vector>
  17. #include "absl/types/optional.h"
  18. #include "api/video/video_bitrate_allocation.h"
  19. #include "api/video/video_frame.h"
  20. #include "api/video_codecs/video_codec.h"
  21. #include "api/video_codecs/video_encoder.h"
  22. #include "modules/video_coding/include/video_codec_interface.h"
  23. namespace webrtc {
  24. namespace test {
  25. class ConfigurableFrameSizeEncoder : public VideoEncoder {
  26. public:
  27. explicit ConfigurableFrameSizeEncoder(size_t max_frame_size);
  28. ~ConfigurableFrameSizeEncoder() override;
  29. void SetFecControllerOverride(
  30. FecControllerOverride* fec_controller_override) override;
  31. int32_t InitEncode(const VideoCodec* codec_settings,
  32. const Settings& settings) override;
  33. int32_t Encode(const VideoFrame& input_image,
  34. const std::vector<VideoFrameType>* frame_types) override;
  35. int32_t RegisterEncodeCompleteCallback(
  36. EncodedImageCallback* callback) override;
  37. int32_t Release() override;
  38. void SetRates(const RateControlParameters& parameters) override;
  39. int32_t SetFrameSize(size_t size);
  40. void SetCodecType(VideoCodecType codec_type_);
  41. void RegisterPostEncodeCallback(
  42. std::function<void(void)> post_encode_callback);
  43. private:
  44. EncodedImageCallback* callback_;
  45. absl::optional<std::function<void(void)>> post_encode_callback_;
  46. size_t current_frame_size_;
  47. VideoCodecType codec_type_;
  48. };
  49. } // namespace test
  50. } // namespace webrtc
  51. #endif // TEST_CONFIGURABLE_FRAME_SIZE_ENCODER_H_