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 {
|
|
|
|
|
2020-02-08 15:26:38 +00:00
|
|
|
struct packet_raw_t : public AVPacket {
|
2021-05-11 21:30:56 +00:00
|
|
|
void init_packet() {
|
2021-05-17 19:21:57 +00:00
|
|
|
pts = AV_NOPTS_VALUE;
|
|
|
|
dts = AV_NOPTS_VALUE;
|
|
|
|
pos = -1;
|
|
|
|
duration = 0;
|
|
|
|
flags = 0;
|
|
|
|
stream_index = 0;
|
|
|
|
buf = nullptr;
|
|
|
|
side_data = nullptr;
|
|
|
|
side_data_elems = 0;
|
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() {
|
|
|
|
av_packet_unref(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *channel_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
using packet_t = std::unique_ptr<packet_raw_t>;
|
2019-12-08 20:16:02 +00:00
|
|
|
using packet_queue_t = std::shared_ptr<safe::queue_t<packet_t>>;
|
2019-12-11 18:06:52 +00:00
|
|
|
using idr_event_t = std::shared_ptr<safe::event_t<std::pair<int64_t, int64_t>>>;
|
2020-02-08 15:26:38 +00:00
|
|
|
using img_event_t = std::shared_ptr<safe::event_t<std::shared_ptr<platf::img_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
|
|
|
};
|
|
|
|
|
2020-02-08 15:26:38 +00:00
|
|
|
void capture(
|
2020-02-09 23:33:12 +00:00
|
|
|
safe::signal_t *shutdown_event,
|
2020-02-08 15:26:38 +00:00
|
|
|
packet_queue_t packets,
|
|
|
|
idr_event_t idr_events,
|
|
|
|
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
|