mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-05-28 00:06:24 +00:00
refactoring
This commit is contained in:
18
src/device.c
18
src/device.c
@@ -65,11 +65,11 @@ static int _device_open_format(struct device_t *dev);
|
|||||||
static void _device_open_alloc_picbufs(struct device_t *dev);
|
static void _device_open_alloc_picbufs(struct device_t *dev);
|
||||||
static int _device_open_mmap(struct device_t *dev);
|
static int _device_open_mmap(struct device_t *dev);
|
||||||
static int _device_open_queue_buffers(struct device_t *dev);
|
static int _device_open_queue_buffers(struct device_t *dev);
|
||||||
static int _device_apply_resolution(struct device_t *dev, const unsigned width, const unsigned height);
|
static int _device_apply_resolution(struct device_t *dev, unsigned width, unsigned height);
|
||||||
|
|
||||||
static const char *_format_to_string_auto(char *buf, const size_t size, const unsigned format);
|
static const char *_format_to_string_auto(char *buf, size_t size, unsigned format);
|
||||||
static const char *_format_to_string_null(const unsigned format);
|
static const char *_format_to_string_null(unsigned format);
|
||||||
static const char *_standard_to_string(const v4l2_std_id standard);
|
static const char *_standard_to_string(v4l2_std_id standard);
|
||||||
|
|
||||||
|
|
||||||
struct device_t *device_init() {
|
struct device_t *device_init() {
|
||||||
@@ -98,7 +98,7 @@ void device_destroy(struct device_t *dev) {
|
|||||||
free(dev);
|
free(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
int device_parse_format(const char *const str) {
|
int device_parse_format(const char *str) {
|
||||||
for (unsigned index = 0; index < ARRAY_LEN(_FORMATS); ++index) {
|
for (unsigned index = 0; index < ARRAY_LEN(_FORMATS); ++index) {
|
||||||
if (!strcasecmp(str, _FORMATS[index].name)) {
|
if (!strcasecmp(str, _FORMATS[index].name)) {
|
||||||
return _FORMATS[index].format;
|
return _FORMATS[index].format;
|
||||||
@@ -107,7 +107,7 @@ int device_parse_format(const char *const str) {
|
|||||||
return FORMAT_UNKNOWN;
|
return FORMAT_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
v4l2_std_id device_parse_standard(const char *const str) {
|
v4l2_std_id device_parse_standard(const char *str) {
|
||||||
for (unsigned index = 1; index < ARRAY_LEN(_STANDARDS); ++index) {
|
for (unsigned index = 1; index < ARRAY_LEN(_STANDARDS); ++index) {
|
||||||
if (!strcasecmp(str, _STANDARDS[index].name)) {
|
if (!strcasecmp(str, _STANDARDS[index].name)) {
|
||||||
return _STANDARDS[index].standard;
|
return _STANDARDS[index].standard;
|
||||||
@@ -423,7 +423,7 @@ static void _device_open_alloc_picbufs(struct device_t *dev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _device_apply_resolution(struct device_t *dev, const unsigned width, const unsigned height) {
|
static int _device_apply_resolution(struct device_t *dev, unsigned width, unsigned height) {
|
||||||
// Тут VIDEO_MIN_* не используются из-за странностей минимального разрешения при отсутствии сигнала
|
// Тут VIDEO_MIN_* не используются из-за странностей минимального разрешения при отсутствии сигнала
|
||||||
// у некоторых устройств, например Auvidea B101
|
// у некоторых устройств, например Auvidea B101
|
||||||
if (
|
if (
|
||||||
@@ -439,7 +439,7 @@ static int _device_apply_resolution(struct device_t *dev, const unsigned width,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *_format_to_string_auto(char *buf, const size_t size, const unsigned format) {
|
static const char *_format_to_string_auto(char *buf, size_t size, unsigned format) {
|
||||||
assert(size >= 8);
|
assert(size >= 8);
|
||||||
buf[0] = format & 0x7F;
|
buf[0] = format & 0x7F;
|
||||||
buf[1] = (format >> 8) & 0x7F;
|
buf[1] = (format >> 8) & 0x7F;
|
||||||
@@ -456,7 +456,7 @@ static const char *_format_to_string_auto(char *buf, const size_t size, const un
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *_format_to_string_null(const unsigned format) {
|
static const char *_format_to_string_null(unsigned format) {
|
||||||
for (unsigned index = 0; index < ARRAY_LEN(_FORMATS); ++index) {
|
for (unsigned index = 0; index < ARRAY_LEN(_FORMATS); ++index) {
|
||||||
if (format == _FORMATS[index].format) {
|
if (format == _FORMATS[index].format) {
|
||||||
return _FORMATS[index].name;
|
return _FORMATS[index].name;
|
||||||
|
|||||||
@@ -93,8 +93,8 @@ struct device_t {
|
|||||||
struct device_t *device_init();
|
struct device_t *device_init();
|
||||||
void device_destroy(struct device_t *dev);
|
void device_destroy(struct device_t *dev);
|
||||||
|
|
||||||
int device_parse_format(const char *const str);
|
int device_parse_format(const char *str);
|
||||||
v4l2_std_id device_parse_standard(const char *const str);
|
v4l2_std_id device_parse_standard(const char *str);
|
||||||
|
|
||||||
int device_open(struct device_t *dev);
|
int device_open(struct device_t *dev);
|
||||||
void device_close(struct device_t *dev);
|
void device_close(struct device_t *dev);
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ void encoder_destroy(struct encoder_t *encoder) {
|
|||||||
free(encoder);
|
free(encoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum encoder_type_t encoder_parse_type(const char *const str) {
|
enum encoder_type_t encoder_parse_type(const char *str) {
|
||||||
for (unsigned index = 0; index < ARRAY_LEN(_ENCODER_TYPES); ++index) {
|
for (unsigned index = 0; index < ARRAY_LEN(_ENCODER_TYPES); ++index) {
|
||||||
if (!strcasecmp(str, _ENCODER_TYPES[index].name)) {
|
if (!strcasecmp(str, _ENCODER_TYPES[index].name)) {
|
||||||
return _ENCODER_TYPES[index].type;
|
return _ENCODER_TYPES[index].type;
|
||||||
@@ -156,8 +156,7 @@ void encoder_prepare_live(struct encoder_t *encoder, struct device_t *dev) {
|
|||||||
|
|
||||||
#pragma GCC diagnostic ignored "-Wunused-label"
|
#pragma GCC diagnostic ignored "-Wunused-label"
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
int encoder_compress_buffer(struct encoder_t *encoder, struct device_t *dev,
|
int encoder_compress_buffer(struct encoder_t *encoder, struct device_t *dev, unsigned worker_number, unsigned buf_index) {
|
||||||
const unsigned worker_number, const unsigned buf_index) {
|
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
assert(encoder->run->type != ENCODER_TYPE_UNKNOWN);
|
assert(encoder->run->type != ENCODER_TYPE_UNKNOWN);
|
||||||
|
|||||||
@@ -65,10 +65,9 @@ struct encoder_t {
|
|||||||
struct encoder_t *encoder_init();
|
struct encoder_t *encoder_init();
|
||||||
void encoder_destroy(struct encoder_t *encoder);
|
void encoder_destroy(struct encoder_t *encoder);
|
||||||
|
|
||||||
enum encoder_type_t encoder_parse_type(const char *const str);
|
enum encoder_type_t encoder_parse_type(const char *str);
|
||||||
|
|
||||||
void encoder_prepare(struct encoder_t *encoder, struct device_t *dev);
|
void encoder_prepare(struct encoder_t *encoder, struct device_t *dev);
|
||||||
void encoder_prepare_live(struct encoder_t *encoder, struct device_t *dev);
|
void encoder_prepare_live(struct encoder_t *encoder, struct device_t *dev);
|
||||||
|
|
||||||
int encoder_compress_buffer(struct encoder_t *encoder, struct device_t *dev,
|
int encoder_compress_buffer(struct encoder_t *encoder, struct device_t *dev, unsigned worker_number, unsigned buf_index);
|
||||||
const unsigned worker_number, const unsigned buf_index);
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ static void _http_callback_stream_write(struct bufferevent *buf_event, void *v_c
|
|||||||
static void _http_callback_stream_error(struct bufferevent *buf_event, short what, void *v_ctx);
|
static void _http_callback_stream_error(struct bufferevent *buf_event, short what, void *v_ctx);
|
||||||
|
|
||||||
static void _http_exposed_refresh(int fd, short event, void *v_server);
|
static void _http_exposed_refresh(int fd, short event, void *v_server);
|
||||||
static void _http_queue_send_stream(struct http_server_t *server, const bool stream_updated, const bool picture_updated);
|
static void _http_queue_send_stream(struct http_server_t *server, bool stream_updated, bool picture_updated);
|
||||||
|
|
||||||
static bool _expose_new_picture(struct http_server_t *server);
|
static bool _expose_new_picture(struct http_server_t *server);
|
||||||
static bool _expose_blank_picture(struct http_server_t *server);
|
static bool _expose_blank_picture(struct http_server_t *server);
|
||||||
@@ -573,7 +573,7 @@ static void _http_callback_stream_error(UNUSED struct bufferevent *buf_event, UN
|
|||||||
free(client);
|
free(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _http_queue_send_stream(struct http_server_t *server, const bool stream_updated, const bool picture_updated) {
|
static void _http_queue_send_stream(struct http_server_t *server, bool stream_updated, bool picture_updated) {
|
||||||
struct evhttp_connection *conn;
|
struct evhttp_connection *conn;
|
||||||
struct bufferevent *buf_event;
|
struct bufferevent *buf_event;
|
||||||
long long now;
|
long long now;
|
||||||
|
|||||||
@@ -49,24 +49,27 @@ struct _mjpg_destination_mgr {
|
|||||||
|
|
||||||
static void _jpeg_set_dest_picture(j_compress_ptr jpeg, unsigned char *picture, unsigned long *written);
|
static void _jpeg_set_dest_picture(j_compress_ptr jpeg, unsigned char *picture, unsigned long *written);
|
||||||
|
|
||||||
static void _jpeg_write_scanlines_yuyv(struct jpeg_compress_struct *jpeg,
|
static void _jpeg_write_scanlines_yuyv(
|
||||||
|
struct jpeg_compress_struct *jpeg,
|
||||||
unsigned char *line_buffer, const unsigned char *data,
|
unsigned char *line_buffer, const unsigned char *data,
|
||||||
const unsigned width, const unsigned height);
|
unsigned width, unsigned height);
|
||||||
|
|
||||||
static void _jpeg_write_scanlines_uyvy(struct jpeg_compress_struct *jpeg,
|
static void _jpeg_write_scanlines_uyvy(
|
||||||
|
struct jpeg_compress_struct *jpeg,
|
||||||
unsigned char *line_buffer, const unsigned char *data,
|
unsigned char *line_buffer, const unsigned char *data,
|
||||||
const unsigned width, const unsigned height);
|
unsigned width, unsigned height);
|
||||||
|
|
||||||
static void _jpeg_write_scanlines_rgb565(struct jpeg_compress_struct *jpeg,
|
static void _jpeg_write_scanlines_rgb565(
|
||||||
|
struct jpeg_compress_struct *jpeg,
|
||||||
unsigned char *line_buffer, const unsigned char *data,
|
unsigned char *line_buffer, const unsigned char *data,
|
||||||
const unsigned width, const unsigned height);
|
unsigned width, unsigned height);
|
||||||
|
|
||||||
static void _jpeg_init_destination(j_compress_ptr jpeg);
|
static void _jpeg_init_destination(j_compress_ptr jpeg);
|
||||||
static boolean _jpeg_empty_output_buffer(j_compress_ptr jpeg);
|
static boolean _jpeg_empty_output_buffer(j_compress_ptr jpeg);
|
||||||
static void _jpeg_term_destination(j_compress_ptr jpeg);
|
static void _jpeg_term_destination(j_compress_ptr jpeg);
|
||||||
|
|
||||||
|
|
||||||
void jpeg_encoder_compress_buffer(struct device_t *dev, const unsigned index, const unsigned quality) {
|
void jpeg_encoder_compress_buffer(struct device_t *dev, unsigned index, unsigned quality) {
|
||||||
// This function based on compress_image_to_jpeg() from mjpg-streamer
|
// This function based on compress_image_to_jpeg() from mjpg-streamer
|
||||||
|
|
||||||
struct jpeg_compress_struct jpeg;
|
struct jpeg_compress_struct jpeg;
|
||||||
@@ -132,9 +135,10 @@ static void _jpeg_set_dest_picture(j_compress_ptr jpeg, unsigned char *picture,
|
|||||||
|
|
||||||
#define NORM_COMPONENT(_x) (((_x) > 255) ? 255 : (((_x) < 0) ? 0 : (_x)))
|
#define NORM_COMPONENT(_x) (((_x) > 255) ? 255 : (((_x) < 0) ? 0 : (_x)))
|
||||||
|
|
||||||
static void _jpeg_write_scanlines_yuyv(struct jpeg_compress_struct *jpeg,
|
static void _jpeg_write_scanlines_yuyv(
|
||||||
|
struct jpeg_compress_struct *jpeg,
|
||||||
unsigned char *line_buffer, const unsigned char *data,
|
unsigned char *line_buffer, const unsigned char *data,
|
||||||
const unsigned width, const unsigned height) {
|
unsigned width, unsigned height) {
|
||||||
|
|
||||||
JSAMPROW scanlines[1];
|
JSAMPROW scanlines[1];
|
||||||
unsigned z = 0;
|
unsigned z = 0;
|
||||||
@@ -166,9 +170,10 @@ static void _jpeg_write_scanlines_yuyv(struct jpeg_compress_struct *jpeg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _jpeg_write_scanlines_uyvy(struct jpeg_compress_struct *jpeg,
|
static void _jpeg_write_scanlines_uyvy(
|
||||||
|
struct jpeg_compress_struct *jpeg,
|
||||||
unsigned char *line_buffer, const unsigned char *data,
|
unsigned char *line_buffer, const unsigned char *data,
|
||||||
const unsigned width, const unsigned height) {
|
unsigned width, unsigned height) {
|
||||||
|
|
||||||
JSAMPROW scanlines[1];
|
JSAMPROW scanlines[1];
|
||||||
unsigned z = 0;
|
unsigned z = 0;
|
||||||
@@ -202,9 +207,10 @@ static void _jpeg_write_scanlines_uyvy(struct jpeg_compress_struct *jpeg,
|
|||||||
|
|
||||||
#undef NORM_COMPONENT
|
#undef NORM_COMPONENT
|
||||||
|
|
||||||
static void _jpeg_write_scanlines_rgb565(struct jpeg_compress_struct *jpeg,
|
static void _jpeg_write_scanlines_rgb565(
|
||||||
|
struct jpeg_compress_struct *jpeg,
|
||||||
unsigned char *line_buffer, const unsigned char *data,
|
unsigned char *line_buffer, const unsigned char *data,
|
||||||
const unsigned width, const unsigned height) {
|
unsigned width, unsigned height) {
|
||||||
|
|
||||||
JSAMPROW scanlines[1];
|
JSAMPROW scanlines[1];
|
||||||
|
|
||||||
|
|||||||
@@ -25,4 +25,4 @@
|
|||||||
#include "../device.h"
|
#include "../device.h"
|
||||||
|
|
||||||
|
|
||||||
void jpeg_encoder_compress_buffer(struct device_t *dev, const unsigned index, const unsigned quality);
|
void jpeg_encoder_compress_buffer(struct device_t *dev, unsigned index, unsigned quality);
|
||||||
|
|||||||
@@ -31,11 +31,11 @@
|
|||||||
#include "component.h"
|
#include "component.h"
|
||||||
|
|
||||||
|
|
||||||
static int _component_wait_port_changed(OMX_HANDLETYPE *component, const OMX_U32 port, const OMX_BOOL enabled);
|
static int _component_wait_port_changed(OMX_HANDLETYPE *component, OMX_U32 port, OMX_BOOL enabled);
|
||||||
static int _component_wait_state_changed(OMX_HANDLETYPE *component, const OMX_STATETYPE wanted);
|
static int _component_wait_state_changed(OMX_HANDLETYPE *component, OMX_STATETYPE wanted);
|
||||||
|
|
||||||
|
|
||||||
int component_enable_port(OMX_HANDLETYPE *component, const OMX_U32 port) {
|
int component_enable_port(OMX_HANDLETYPE *component, OMX_U32 port) {
|
||||||
OMX_ERRORTYPE error;
|
OMX_ERRORTYPE error;
|
||||||
|
|
||||||
LOG_DEBUG("Enabling OMX port %u ...", port);
|
LOG_DEBUG("Enabling OMX port %u ...", port);
|
||||||
@@ -46,7 +46,7 @@ int component_enable_port(OMX_HANDLETYPE *component, const OMX_U32 port) {
|
|||||||
return _component_wait_port_changed(component, port, OMX_TRUE);
|
return _component_wait_port_changed(component, port, OMX_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int component_disable_port(OMX_HANDLETYPE *component, const OMX_U32 port) {
|
int component_disable_port(OMX_HANDLETYPE *component, OMX_U32 port) {
|
||||||
OMX_ERRORTYPE error;
|
OMX_ERRORTYPE error;
|
||||||
|
|
||||||
LOG_DEBUG("Disabling OMX port %u ...", port);
|
LOG_DEBUG("Disabling OMX port %u ...", port);
|
||||||
@@ -57,7 +57,7 @@ int component_disable_port(OMX_HANDLETYPE *component, const OMX_U32 port) {
|
|||||||
return _component_wait_port_changed(component, port, OMX_FALSE);
|
return _component_wait_port_changed(component, port, OMX_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int component_get_portdef(OMX_HANDLETYPE *component, OMX_PARAM_PORTDEFINITIONTYPE *portdef, const OMX_U32 port) {
|
int component_get_portdef(OMX_HANDLETYPE *component, OMX_PARAM_PORTDEFINITIONTYPE *portdef, OMX_U32 port) {
|
||||||
OMX_ERRORTYPE error;
|
OMX_ERRORTYPE error;
|
||||||
|
|
||||||
OMX_INIT_STRUCTURE(*portdef);
|
OMX_INIT_STRUCTURE(*portdef);
|
||||||
@@ -82,8 +82,8 @@ int component_set_portdef(OMX_HANDLETYPE *component, OMX_PARAM_PORTDEFINITIONTYP
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int component_set_state(OMX_HANDLETYPE *component, const OMX_STATETYPE state) {
|
int component_set_state(OMX_HANDLETYPE *component, OMX_STATETYPE state) {
|
||||||
const char *const state_str = omx_state_to_string(state);
|
const char *state_str = omx_state_to_string(state);
|
||||||
OMX_ERRORTYPE error;
|
OMX_ERRORTYPE error;
|
||||||
int retries = 50;
|
int retries = 50;
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ int component_set_state(OMX_HANDLETYPE *component, const OMX_STATETYPE state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int _component_wait_port_changed(OMX_HANDLETYPE *component, const OMX_U32 port, const OMX_BOOL enabled) {
|
static int _component_wait_port_changed(OMX_HANDLETYPE *component, OMX_U32 port, OMX_BOOL enabled) {
|
||||||
OMX_ERRORTYPE error;
|
OMX_ERRORTYPE error;
|
||||||
OMX_PARAM_PORTDEFINITIONTYPE portdef;
|
OMX_PARAM_PORTDEFINITIONTYPE portdef;
|
||||||
int retries = 50;
|
int retries = 50;
|
||||||
@@ -133,7 +133,7 @@ static int _component_wait_port_changed(OMX_HANDLETYPE *component, const OMX_U32
|
|||||||
return (portdef.bEnabled == enabled ? 0 : -1);
|
return (portdef.bEnabled == enabled ? 0 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _component_wait_state_changed(OMX_HANDLETYPE *component, const OMX_STATETYPE wanted) {
|
static int _component_wait_state_changed(OMX_HANDLETYPE *component, OMX_STATETYPE wanted) {
|
||||||
OMX_ERRORTYPE error;
|
OMX_ERRORTYPE error;
|
||||||
OMX_STATETYPE state;
|
OMX_STATETYPE state;
|
||||||
int retries = 50;
|
int retries = 50;
|
||||||
|
|||||||
@@ -39,10 +39,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int component_enable_port(OMX_HANDLETYPE *component, const OMX_U32 port);
|
int component_enable_port(OMX_HANDLETYPE *component, OMX_U32 port);
|
||||||
int component_disable_port(OMX_HANDLETYPE *component, const OMX_U32 port);
|
int component_disable_port(OMX_HANDLETYPE *component, OMX_U32 port);
|
||||||
|
|
||||||
int component_get_portdef(OMX_HANDLETYPE *component, OMX_PARAM_PORTDEFINITIONTYPE *portdef, const OMX_U32 port);
|
int component_get_portdef(OMX_HANDLETYPE *component, OMX_PARAM_PORTDEFINITIONTYPE *portdef, OMX_U32 port);
|
||||||
int component_set_portdef(OMX_HANDLETYPE *component, OMX_PARAM_PORTDEFINITIONTYPE *portdef);
|
int component_set_portdef(OMX_HANDLETYPE *component, OMX_PARAM_PORTDEFINITIONTYPE *portdef);
|
||||||
|
|
||||||
int component_set_state(OMX_HANDLETYPE *component, const OMX_STATETYPE state);
|
int component_set_state(OMX_HANDLETYPE *component, OMX_STATETYPE state);
|
||||||
|
|||||||
@@ -52,17 +52,20 @@ static int _i_omx = 0;
|
|||||||
static int _omx_init_component(struct omx_encoder_t *omx);
|
static int _omx_init_component(struct omx_encoder_t *omx);
|
||||||
static int _omx_init_disable_ports(struct omx_encoder_t *omx);
|
static int _omx_init_disable_ports(struct omx_encoder_t *omx);
|
||||||
static int _omx_setup_input(struct omx_encoder_t *omx, struct device_t *dev);
|
static int _omx_setup_input(struct omx_encoder_t *omx, struct device_t *dev);
|
||||||
static int _omx_setup_output(struct omx_encoder_t *omx, const unsigned quality);
|
static int _omx_setup_output(struct omx_encoder_t *omx, unsigned quality);
|
||||||
static int _omx_encoder_clear_ports(struct omx_encoder_t *omx);
|
static int _omx_encoder_clear_ports(struct omx_encoder_t *omx);
|
||||||
|
|
||||||
static OMX_ERRORTYPE _omx_event_handler(UNUSED OMX_HANDLETYPE encoder,
|
static OMX_ERRORTYPE _omx_event_handler(
|
||||||
|
UNUSED OMX_HANDLETYPE encoder,
|
||||||
OMX_PTR v_omx, OMX_EVENTTYPE event, OMX_U32 data1,
|
OMX_PTR v_omx, OMX_EVENTTYPE event, OMX_U32 data1,
|
||||||
UNUSED OMX_U32 data2, UNUSED OMX_PTR event_data);
|
UNUSED OMX_U32 data2, UNUSED OMX_PTR event_data);
|
||||||
|
|
||||||
static OMX_ERRORTYPE _omx_input_required_handler(UNUSED OMX_HANDLETYPE encoder,
|
static OMX_ERRORTYPE _omx_input_required_handler(
|
||||||
|
UNUSED OMX_HANDLETYPE encoder,
|
||||||
OMX_PTR v_omx, UNUSED OMX_BUFFERHEADERTYPE *buffer);
|
OMX_PTR v_omx, UNUSED OMX_BUFFERHEADERTYPE *buffer);
|
||||||
|
|
||||||
static OMX_ERRORTYPE _omx_output_available_handler(UNUSED OMX_HANDLETYPE encoder,
|
static OMX_ERRORTYPE _omx_output_available_handler(
|
||||||
|
UNUSED OMX_HANDLETYPE encoder,
|
||||||
OMX_PTR v_omx, UNUSED OMX_BUFFERHEADERTYPE *buffer);
|
OMX_PTR v_omx, UNUSED OMX_BUFFERHEADERTYPE *buffer);
|
||||||
|
|
||||||
|
|
||||||
@@ -149,7 +152,7 @@ void omx_encoder_destroy(struct omx_encoder_t *omx) {
|
|||||||
free(omx);
|
free(omx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int omx_encoder_prepare_live(struct omx_encoder_t *omx, struct device_t *dev, const unsigned quality) {
|
int omx_encoder_prepare_live(struct omx_encoder_t *omx, struct device_t *dev, unsigned quality) {
|
||||||
if (component_set_state(&omx->encoder, OMX_StateIdle) < 0) {
|
if (component_set_state(&omx->encoder, OMX_StateIdle) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -168,7 +171,7 @@ int omx_encoder_prepare_live(struct omx_encoder_t *omx, struct device_t *dev, co
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int omx_encoder_compress_buffer(struct omx_encoder_t *omx, struct device_t *dev, const unsigned index) {
|
int omx_encoder_compress_buffer(struct omx_encoder_t *omx, struct device_t *dev, unsigned index) {
|
||||||
OMX_ERRORTYPE error;
|
OMX_ERRORTYPE error;
|
||||||
bool loaded = false;
|
bool loaded = false;
|
||||||
|
|
||||||
@@ -330,7 +333,7 @@ static int _omx_setup_input(struct omx_encoder_t *omx, struct device_t *dev) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _omx_setup_output(struct omx_encoder_t *omx, const unsigned quality) {
|
static int _omx_setup_output(struct omx_encoder_t *omx, unsigned quality) {
|
||||||
OMX_ERRORTYPE error;
|
OMX_ERRORTYPE error;
|
||||||
OMX_PARAM_PORTDEFINITIONTYPE portdef;
|
OMX_PARAM_PORTDEFINITIONTYPE portdef;
|
||||||
|
|
||||||
@@ -434,7 +437,8 @@ static int _omx_encoder_clear_ports(struct omx_encoder_t *omx) {
|
|||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static OMX_ERRORTYPE _omx_event_handler(UNUSED OMX_HANDLETYPE encoder,
|
static OMX_ERRORTYPE _omx_event_handler(
|
||||||
|
UNUSED OMX_HANDLETYPE encoder,
|
||||||
OMX_PTR v_omx, OMX_EVENTTYPE event, OMX_U32 data1,
|
OMX_PTR v_omx, OMX_EVENTTYPE event, OMX_U32 data1,
|
||||||
UNUSED OMX_U32 data2, UNUSED OMX_PTR event_data) {
|
UNUSED OMX_U32 data2, UNUSED OMX_PTR event_data) {
|
||||||
|
|
||||||
@@ -450,7 +454,8 @@ static OMX_ERRORTYPE _omx_event_handler(UNUSED OMX_HANDLETYPE encoder,
|
|||||||
return OMX_ErrorNone;
|
return OMX_ErrorNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
static OMX_ERRORTYPE _omx_input_required_handler(UNUSED OMX_HANDLETYPE encoder,
|
static OMX_ERRORTYPE _omx_input_required_handler(
|
||||||
|
UNUSED OMX_HANDLETYPE encoder,
|
||||||
OMX_PTR v_omx, UNUSED OMX_BUFFERHEADERTYPE *buffer) {
|
OMX_PTR v_omx, UNUSED OMX_BUFFERHEADERTYPE *buffer) {
|
||||||
|
|
||||||
// Called by OMX when the encoder component requires
|
// Called by OMX when the encoder component requires
|
||||||
@@ -463,7 +468,8 @@ static OMX_ERRORTYPE _omx_input_required_handler(UNUSED OMX_HANDLETYPE encoder,
|
|||||||
return OMX_ErrorNone;
|
return OMX_ErrorNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
static OMX_ERRORTYPE _omx_output_available_handler(UNUSED OMX_HANDLETYPE encoder,
|
static OMX_ERRORTYPE _omx_output_available_handler(
|
||||||
|
UNUSED OMX_HANDLETYPE encoder,
|
||||||
OMX_PTR v_omx, UNUSED OMX_BUFFERHEADERTYPE *buffer) {
|
OMX_PTR v_omx, UNUSED OMX_BUFFERHEADERTYPE *buffer) {
|
||||||
|
|
||||||
// Called by OMX when the encoder component has filled
|
// Called by OMX when the encoder component has filled
|
||||||
|
|||||||
@@ -52,5 +52,5 @@ struct omx_encoder_t {
|
|||||||
struct omx_encoder_t *omx_encoder_init();
|
struct omx_encoder_t *omx_encoder_init();
|
||||||
void omx_encoder_destroy(struct omx_encoder_t *omx);
|
void omx_encoder_destroy(struct omx_encoder_t *omx);
|
||||||
|
|
||||||
int omx_encoder_prepare_live(struct omx_encoder_t *omx, struct device_t *dev, const unsigned quality);
|
int omx_encoder_prepare_live(struct omx_encoder_t *omx, struct device_t *dev, unsigned quality);
|
||||||
int omx_encoder_compress_buffer(struct omx_encoder_t *omx, struct device_t *dev, const unsigned index);
|
int omx_encoder_compress_buffer(struct omx_encoder_t *omx, struct device_t *dev, unsigned index);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
assert(0 && _buf); \
|
assert(0 && _buf); \
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *omx_error_to_string(const OMX_ERRORTYPE error) {
|
const char *omx_error_to_string(OMX_ERRORTYPE error) {
|
||||||
switch (error) {
|
switch (error) {
|
||||||
CASE_TO_STRING(OMX_ErrorNone);
|
CASE_TO_STRING(OMX_ErrorNone);
|
||||||
CASE_TO_STRING(OMX_ErrorInsufficientResources);
|
CASE_TO_STRING(OMX_ErrorInsufficientResources);
|
||||||
@@ -70,7 +70,7 @@ const char *omx_error_to_string(const OMX_ERRORTYPE error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *omx_state_to_string(const OMX_STATETYPE state) {
|
const char *omx_state_to_string(OMX_STATETYPE state) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
CASE_TO_STRING(OMX_StateLoaded);
|
CASE_TO_STRING(OMX_StateLoaded);
|
||||||
CASE_TO_STRING(OMX_StateIdle);
|
CASE_TO_STRING(OMX_StateIdle);
|
||||||
|
|||||||
@@ -42,5 +42,5 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *omx_error_to_string(const OMX_ERRORTYPE error);
|
const char *omx_error_to_string(OMX_ERRORTYPE error);
|
||||||
const char *omx_state_to_string(const OMX_STATETYPE state);
|
const char *omx_state_to_string(OMX_STATETYPE state);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ static void _stream_init_workers(struct device_t *dev, struct workers_pool_t *po
|
|||||||
static void *_stream_worker_thread(void *v_ctx);
|
static void *_stream_worker_thread(void *v_ctx);
|
||||||
static void _stream_destroy_workers(struct device_t *dev, struct workers_pool_t *pool);
|
static void _stream_destroy_workers(struct device_t *dev, struct workers_pool_t *pool);
|
||||||
|
|
||||||
static int _stream_control(struct device_t *dev, const bool enable);
|
static int _stream_control(struct device_t *dev, bool enable);
|
||||||
static int _stream_grab_buffer(struct device_t *dev, struct v4l2_buffer *buf_info);
|
static int _stream_grab_buffer(struct device_t *dev, struct v4l2_buffer *buf_info);
|
||||||
static int _stream_release_buffer(struct device_t *dev, struct v4l2_buffer *buf_info);
|
static int _stream_release_buffer(struct device_t *dev, struct v4l2_buffer *buf_info);
|
||||||
static int _stream_handle_event(struct device_t *dev);
|
static int _stream_handle_event(struct device_t *dev);
|
||||||
@@ -500,7 +500,7 @@ static void _stream_destroy_workers(struct device_t *dev, struct workers_pool_t
|
|||||||
pool->workers = NULL;
|
pool->workers = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _stream_control(struct device_t *dev, const bool enable) {
|
static int _stream_control(struct device_t *dev, bool enable) {
|
||||||
if (enable != dev->run->capturing) {
|
if (enable != dev->run->capturing) {
|
||||||
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
#define UNUSED __attribute__((unused))
|
#define UNUSED __attribute__((unused))
|
||||||
|
|
||||||
|
|
||||||
INLINE char *bool_to_string(const bool flag) {
|
INLINE char *bool_to_string(bool flag) {
|
||||||
return (flag ? "true" : "false");
|
return (flag ? "true" : "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
#define XIOCTL_RETRIES 4
|
#define XIOCTL_RETRIES 4
|
||||||
|
|
||||||
|
|
||||||
INLINE int xioctl(const int fd, const int request, void *arg) {
|
INLINE int xioctl(int fd, int request, void *arg) {
|
||||||
int retries = XIOCTL_RETRIES;
|
int retries = XIOCTL_RETRIES;
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user