blob: e18a87cd7e362465f2e36a211a13b12f4d635b8e [file] [log] [blame]
sprang@webrtc.org8b881922013-12-10 10:05:171/*
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 04:47:3111#include "test/configurable_frame_size_encoder.h"
sprang@webrtc.org8b881922013-12-10 10:05:1712
13#include <string.h>
Jonas Olssona4d87372019-07-05 17:08:3314
Yves Gerey3e707812018-11-28 15:47:4915#include <cstdint>
16#include <type_traits>
17#include <utility>
sprang@webrtc.org8b881922013-12-10 10:05:1718
Niels Möller4dc66c52018-10-05 12:17:5819#include "api/video/encoded_image.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3120#include "modules/video_coding/include/video_codec_interface.h"
Yves Gerey3e707812018-11-28 15:47:4921#include "modules/video_coding/include/video_error_codes.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3122#include "rtc_base/checks.h"
pbos@webrtc.orgab990ae2014-09-17 09:02:2523
sprang@webrtc.org8b881922013-12-10 10:05:1724namespace webrtc {
25namespace test {
26
27ConfigurableFrameSizeEncoder::ConfigurableFrameSizeEncoder(
pkasting@chromium.org4591fbd2014-11-20 22:28:1428 size_t max_frame_size)
sprang@webrtc.org8b881922013-12-10 10:05:1729 : callback_(NULL),
sprang@webrtc.org8b881922013-12-10 10:05:1730 current_frame_size_(max_frame_size),
Niels Möller12f465c2020-09-23 10:45:1731 codec_type_(kVideoCodecGeneric) {}
sprang@webrtc.org8b881922013-12-10 10:05:1732
33ConfigurableFrameSizeEncoder::~ConfigurableFrameSizeEncoder() {}
34
Elad Alon8f01c4e2019-06-28 13:19:4335void ConfigurableFrameSizeEncoder::SetFecControllerOverride(
36 FecControllerOverride* fec_controller_override) {
37 // Ignored.
38}
39
sprang@webrtc.org8b881922013-12-10 10:05:1740int32_t ConfigurableFrameSizeEncoder::InitEncode(
41 const VideoCodec* codec_settings,
Elad Alon370f93a2019-06-11 12:57:5742 const Settings& settings) {
sprang@webrtc.org8b881922013-12-10 10:05:1743 return WEBRTC_VIDEO_CODEC_OK;
44}
45
46int32_t ConfigurableFrameSizeEncoder::Encode(
Miguel Casas-Sanchez47650702015-05-30 00:21:4047 const VideoFrame& inputImage,
Niels Möller87e2d782019-03-07 09:18:2348 const std::vector<VideoFrameType>* frame_types) {
Niels Möller12f465c2020-09-23 10:45:1749 EncodedImage encodedImage;
50 auto buffer = EncodedImageBuffer::Create(current_frame_size_);
51 memset(buffer->data(), 0, current_frame_size_);
52 encodedImage.SetEncodedData(buffer);
sprang@webrtc.org8b881922013-12-10 10:05:1753 encodedImage._encodedHeight = inputImage.height();
54 encodedImage._encodedWidth = inputImage.width();
Niels Möller8f7ce222019-03-21 14:43:5855 encodedImage._frameType = VideoFrameType::kVideoFrameKey;
Per K0fa90882024-03-13 08:52:4156 encodedImage.SetRtpTimestamp(inputImage.rtp_timestamp());
sprang@webrtc.org8b881922013-12-10 10:05:1757 encodedImage.capture_time_ms_ = inputImage.render_time_ms();
Philip Eliassond52a1a62018-09-07 13:03:5558 CodecSpecificInfo specific{};
59 specific.codecType = codec_type_;
Danil Chapovalov2549f172020-08-12 15:30:3660 callback_->OnEncodedImage(encodedImage, &specific);
Niels Möller759f9592018-10-09 12:57:0161 if (post_encode_callback_) {
62 (*post_encode_callback_)();
63 }
sprang@webrtc.org8b881922013-12-10 10:05:1764 return WEBRTC_VIDEO_CODEC_OK;
65}
66
67int32_t ConfigurableFrameSizeEncoder::RegisterEncodeCompleteCallback(
68 EncodedImageCallback* callback) {
69 callback_ = callback;
70 return WEBRTC_VIDEO_CODEC_OK;
71}
72
73int32_t ConfigurableFrameSizeEncoder::Release() {
74 return WEBRTC_VIDEO_CODEC_OK;
75}
76
Erik Språng16cb8f52019-04-12 11:59:0977void ConfigurableFrameSizeEncoder::SetRates(
78 const RateControlParameters& parameters) {}
sprang@webrtc.org8b881922013-12-10 10:05:1779
Wan-Teh Changbd866842023-02-14 23:26:4080VideoEncoder::EncoderInfo ConfigurableFrameSizeEncoder::GetEncoderInfo() const {
81 return EncoderInfo();
82}
83
pkasting@chromium.org4591fbd2014-11-20 22:28:1484int32_t ConfigurableFrameSizeEncoder::SetFrameSize(size_t size) {
sprang@webrtc.org8b881922013-12-10 10:05:1785 current_frame_size_ = size;
86 return WEBRTC_VIDEO_CODEC_OK;
87}
88
Philip Eliassond52a1a62018-09-07 13:03:5589void ConfigurableFrameSizeEncoder::SetCodecType(VideoCodecType codec_type) {
90 codec_type_ = codec_type;
91}
92
Niels Möller759f9592018-10-09 12:57:0193void ConfigurableFrameSizeEncoder::RegisterPostEncodeCallback(
94 std::function<void(void)> post_encode_callback) {
95 post_encode_callback_ = std::move(post_encode_callback);
96}
97
sprang@webrtc.org8b881922013-12-10 10:05:1798} // namespace test
99} // namespace webrtc