2019-12-04 12:37:13 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef API_TEST_FRAME_GENERATOR_INTERFACE_H_
|
|
|
|
|
#define API_TEST_FRAME_GENERATOR_INTERFACE_H_
|
|
|
|
|
|
2024-08-13 05:43:47 -07:00
|
|
|
#include <cstddef>
|
2024-08-29 13:00:40 +00:00
|
|
|
#include <optional>
|
2019-12-04 12:37:13 +01:00
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
|
|
#include "api/scoped_refptr.h"
|
|
|
|
|
#include "api/video/video_frame.h"
|
|
|
|
|
#include "api/video/video_frame_buffer.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
class FrameGeneratorInterface {
|
|
|
|
|
public:
|
2023-02-17 12:49:58 +00:00
|
|
|
struct Resolution {
|
|
|
|
|
size_t width;
|
|
|
|
|
size_t height;
|
|
|
|
|
};
|
2019-12-04 12:37:13 +01:00
|
|
|
struct VideoFrameData {
|
|
|
|
|
VideoFrameData(rtc::scoped_refptr<VideoFrameBuffer> buffer,
|
2024-08-29 13:00:40 +00:00
|
|
|
std::optional<VideoFrame::UpdateRect> update_rect)
|
2019-12-04 12:37:13 +01:00
|
|
|
: buffer(std::move(buffer)), update_rect(update_rect) {}
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<VideoFrameBuffer> buffer;
|
2024-08-29 13:00:40 +00:00
|
|
|
std::optional<VideoFrame::UpdateRect> update_rect;
|
2019-12-04 12:37:13 +01:00
|
|
|
};
|
|
|
|
|
|
2020-09-28 10:16:00 +02:00
|
|
|
enum class OutputType { kI420, kI420A, kI010, kNV12 };
|
2020-09-28 12:04:11 +02:00
|
|
|
static const char* OutputTypeToString(OutputType type);
|
2019-12-04 12:37:13 +01:00
|
|
|
|
|
|
|
|
virtual ~FrameGeneratorInterface() = default;
|
|
|
|
|
|
|
|
|
|
// Returns VideoFrameBuffer and area where most of update was done to set them
|
|
|
|
|
// on the VideoFrame object.
|
|
|
|
|
virtual VideoFrameData NextFrame() = 0;
|
2024-08-01 15:45:35 +02:00
|
|
|
// Skips the next frame in case it doesn't need to be encoded.
|
|
|
|
|
// Default implementation is to call NextFrame and ignore the returned value.
|
|
|
|
|
virtual void SkipNextFrame() { NextFrame(); }
|
2019-12-04 12:37:13 +01:00
|
|
|
|
|
|
|
|
// Change the capture resolution.
|
|
|
|
|
virtual void ChangeResolution(size_t width, size_t height) = 0;
|
2023-02-17 12:49:58 +00:00
|
|
|
|
2023-02-17 16:17:27 +00:00
|
|
|
virtual Resolution GetResolution() const = 0;
|
2023-02-27 11:13:13 +01:00
|
|
|
|
|
|
|
|
// Returns the frames per second this generator is supposed to provide
|
|
|
|
|
// according to its data source. Not all frame generators know the frames per
|
2024-08-29 13:00:40 +00:00
|
|
|
// second of the data source, in such case this method returns std::nullopt.
|
|
|
|
|
virtual std::optional<int> fps() const = 0;
|
2019-12-04 12:37:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // API_TEST_FRAME_GENERATOR_INTERFACE_H_
|