2019-12-03 19:23:33 +00:00
|
|
|
//
|
|
|
|
// Created by loki on 6/9/19.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef SUNSHINE_VIDEO_H
|
|
|
|
#define SUNSHINE_VIDEO_H
|
|
|
|
|
2021-05-11 21:30:56 +00:00
|
|
|
#include "input.h"
|
2020-02-08 15:26:38 +00:00
|
|
|
#include "platform/common.h"
|
2021-05-17 19:21:57 +00:00
|
|
|
#include "thread_safe.h"
|
2020-02-08 15:26:38 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
}
|
2019-12-03 19:23:33 +00:00
|
|
|
|
|
|
|
struct AVPacket;
|
|
|
|
namespace video {
|
|
|
|
|
2022-04-12 21:13:05 +00:00
|
|
|
struct packet_raw_t {
|
2021-05-11 21:30:56 +00:00
|
|
|
void init_packet() {
|
2022-04-12 21:13:05 +00:00
|
|
|
this->av_packet = av_packet_alloc();
|
2021-05-11 21:30:56 +00:00
|
|
|
}
|
|
|
|
|
2020-02-08 15:26:38 +00:00
|
|
|
template<class P>
|
|
|
|
explicit packet_raw_t(P *user_data) : channel_data { user_data } {
|
2021-05-11 21:30:56 +00:00
|
|
|
init_packet();
|
2020-02-08 15:26:38 +00:00
|
|
|
}
|
|
|
|
|
2021-05-11 21:30:56 +00:00
|
|
|
explicit packet_raw_t(std::nullptr_t) : channel_data { nullptr } {
|
|
|
|
init_packet();
|
2020-02-08 15:26:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~packet_raw_t() {
|
2022-04-12 21:13:05 +00:00
|
|
|
av_packet_unref(this->av_packet);
|
2020-02-08 15:26:38 +00:00
|
|
|
}
|
|
|
|
|
2021-06-18 15:27:56 +00:00
|
|
|
struct replace_t {
|
2021-06-13 19:29:32 +00:00
|
|
|
std::string_view old;
|
2021-06-18 15:27:56 +00:00
|
|
|
std::string_view _new;
|
|
|
|
|
2021-07-18 09:05:34 +00:00
|
|
|
KITTY_DEFAULT_CONSTR_MOVE(replace_t)
|
2021-06-18 15:27:56 +00:00
|
|
|
|
|
|
|
replace_t(std::string_view old, std::string_view _new) noexcept : old { std::move(old) }, _new { std::move(_new) } {}
|
|
|
|
};
|
|
|
|
|
2022-04-12 21:13:05 +00:00
|
|
|
AVPacket *av_packet;
|
2021-06-18 15:27:56 +00:00
|
|
|
std::vector<replace_t> *replacements;
|
2020-02-08 15:26:38 +00:00
|
|
|
void *channel_data;
|
|
|
|
};
|
|
|
|
|
2021-06-22 20:26:11 +00:00
|
|
|
using packet_t = std::unique_ptr<packet_raw_t>;
|
2019-12-03 19:23:33 +00:00
|
|
|
|
|
|
|
struct config_t {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int framerate;
|
|
|
|
int bitrate;
|
|
|
|
int slicesPerFrame;
|
2020-01-18 02:45:14 +00:00
|
|
|
int numRefFrames;
|
2020-01-20 03:46:45 +00:00
|
|
|
int encoderCscMode;
|
|
|
|
int videoFormat;
|
|
|
|
int dynamicRange;
|
2019-12-03 19:23:33 +00:00
|
|
|
};
|
|
|
|
|
2021-06-04 19:12:06 +00:00
|
|
|
using float4 = float[4];
|
|
|
|
using float3 = float[3];
|
|
|
|
using float2 = float[2];
|
|
|
|
|
|
|
|
struct __attribute__((__aligned__(16))) color_t {
|
|
|
|
float4 color_vec_y;
|
|
|
|
float4 color_vec_u;
|
|
|
|
float4 color_vec_v;
|
|
|
|
float2 range_y;
|
|
|
|
float2 range_uv;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern color_t colors[4];
|
|
|
|
|
2020-02-08 15:26:38 +00:00
|
|
|
void capture(
|
2021-06-22 20:26:11 +00:00
|
|
|
safe::mail_t mail,
|
2020-02-08 15:26:38 +00:00
|
|
|
config_t config,
|
|
|
|
void *channel_data);
|
2020-03-31 19:18:33 +00:00
|
|
|
|
2020-04-13 21:15:24 +00:00
|
|
|
int init();
|
2021-05-17 19:21:57 +00:00
|
|
|
} // namespace video
|
2019-12-03 19:23:33 +00:00
|
|
|
|
|
|
|
#endif //SUNSHINE_VIDEO_H
|