2023-05-07 18:12:39 -04:00
|
|
|
/**
|
|
|
|
* @file src/video.h
|
|
|
|
* @brief todo
|
|
|
|
*/
|
2023-05-07 15:01:44 -04:00
|
|
|
#pragma once
|
2019-12-03 20:23:33 +01:00
|
|
|
|
2021-05-11 23:30:56 +02:00
|
|
|
#include "input.h"
|
2020-02-08 16:26:38 +01:00
|
|
|
#include "platform/common.h"
|
2021-05-17 21:21:57 +02:00
|
|
|
#include "thread_safe.h"
|
2020-02-08 16:26:38 +01:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
}
|
2019-12-03 20:23:33 +01:00
|
|
|
|
|
|
|
struct AVPacket;
|
|
|
|
namespace video {
|
|
|
|
|
2023-03-27 21:45:29 -04:00
|
|
|
struct packet_raw_t {
|
|
|
|
void
|
|
|
|
init_packet() {
|
|
|
|
this->av_packet = av_packet_alloc();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class P>
|
|
|
|
explicit packet_raw_t(P *user_data):
|
|
|
|
channel_data { user_data } {
|
|
|
|
init_packet();
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit packet_raw_t(std::nullptr_t):
|
|
|
|
channel_data { nullptr } {
|
|
|
|
init_packet();
|
|
|
|
}
|
|
|
|
|
|
|
|
~packet_raw_t() {
|
2023-05-22 17:21:17 -05:00
|
|
|
av_packet_free(&this->av_packet);
|
2023-03-27 21:45:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct replace_t {
|
|
|
|
std::string_view old;
|
|
|
|
std::string_view _new;
|
|
|
|
|
|
|
|
KITTY_DEFAULT_CONSTR_MOVE(replace_t)
|
|
|
|
|
|
|
|
replace_t(std::string_view old, std::string_view _new) noexcept:
|
|
|
|
old { std::move(old) }, _new { std::move(_new) } {}
|
|
|
|
};
|
|
|
|
|
|
|
|
AVPacket *av_packet;
|
|
|
|
std::vector<replace_t> *replacements;
|
|
|
|
void *channel_data;
|
2023-04-18 19:03:52 +03:00
|
|
|
|
|
|
|
std::optional<std::chrono::steady_clock::time_point> frame_timestamp;
|
2023-03-27 21:45:29 -04:00
|
|
|
};
|
2021-05-11 23:30:56 +02:00
|
|
|
|
2023-03-27 21:45:29 -04:00
|
|
|
using packet_t = std::unique_ptr<packet_raw_t>;
|
2020-02-08 16:26:38 +01:00
|
|
|
|
2023-03-27 21:45:29 -04:00
|
|
|
struct hdr_info_raw_t {
|
|
|
|
explicit hdr_info_raw_t(bool enabled):
|
|
|
|
enabled { enabled }, metadata {} {};
|
|
|
|
explicit hdr_info_raw_t(bool enabled, const SS_HDR_METADATA &metadata):
|
|
|
|
enabled { enabled }, metadata { metadata } {};
|
2020-02-08 16:26:38 +01:00
|
|
|
|
2023-03-27 21:45:29 -04:00
|
|
|
bool enabled;
|
|
|
|
SS_HDR_METADATA metadata;
|
|
|
|
};
|
2020-02-08 16:26:38 +01:00
|
|
|
|
2023-03-27 21:45:29 -04:00
|
|
|
using hdr_info_t = std::unique_ptr<hdr_info_raw_t>;
|
|
|
|
|
|
|
|
struct config_t {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int framerate;
|
|
|
|
int bitrate;
|
|
|
|
int slicesPerFrame;
|
|
|
|
int numRefFrames;
|
|
|
|
int encoderCscMode;
|
|
|
|
int videoFormat;
|
|
|
|
int dynamicRange;
|
|
|
|
};
|
2021-06-18 17:27:56 +02:00
|
|
|
|
2023-03-27 21:45:29 -04:00
|
|
|
using float4 = float[4];
|
|
|
|
using float3 = float[3];
|
|
|
|
using float2 = float[2];
|
2021-06-18 17:27:56 +02:00
|
|
|
|
2023-03-27 21:45:29 -04:00
|
|
|
struct alignas(16) color_t {
|
|
|
|
float4 color_vec_y;
|
|
|
|
float4 color_vec_u;
|
|
|
|
float4 color_vec_v;
|
|
|
|
float2 range_y;
|
|
|
|
float2 range_uv;
|
2021-06-18 17:27:56 +02:00
|
|
|
};
|
|
|
|
|
2023-03-27 21:45:29 -04:00
|
|
|
extern color_t colors[6];
|
|
|
|
|
2023-04-16 15:15:19 -05:00
|
|
|
extern int active_hevc_mode;
|
|
|
|
|
2023-03-27 21:45:29 -04:00
|
|
|
void
|
|
|
|
capture(
|
|
|
|
safe::mail_t mail,
|
|
|
|
config_t config,
|
|
|
|
void *channel_data);
|
|
|
|
|
|
|
|
int
|
2023-04-09 16:34:07 -05:00
|
|
|
probe_encoders();
|
2023-03-27 21:45:29 -04:00
|
|
|
} // namespace video
|