mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-04-11 00:56:13 +00:00
refactoring
This commit is contained in:
@@ -20,10 +20,6 @@
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
|
||||
|
||||
@@ -22,20 +22,6 @@
|
||||
|
||||
#include "rawsink.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/logging.h"
|
||||
|
||||
|
||||
static int _sem_wait_monotonic(sem_t *sem, long double timeout);
|
||||
|
||||
@@ -181,14 +167,14 @@ void rawsink_put(
|
||||
goto error;
|
||||
}
|
||||
|
||||
# define SH(_field) rawsink->shared->_field = _field
|
||||
SH(format);
|
||||
SH(width);
|
||||
SH(height);
|
||||
SH(grab_ts);
|
||||
SH(size);
|
||||
# define COPY(_field) rawsink->shared->_field = _field
|
||||
COPY(format);
|
||||
COPY(width);
|
||||
COPY(height);
|
||||
COPY(grab_ts);
|
||||
COPY(size);
|
||||
memcpy(rawsink->shared->data, data, size);
|
||||
# undef SH
|
||||
# undef COPY
|
||||
|
||||
if (sem_post(rawsink->signal_sem) < 0) {
|
||||
LOG_PERROR("RAWSINK: Can't post %s", rawsink->signal_name);
|
||||
@@ -237,14 +223,14 @@ int rawsink_get(
|
||||
WAIT_SEM(signal);
|
||||
WAIT_SEM(lock);
|
||||
|
||||
# define SH(_field) *_field = rawsink->shared->_field
|
||||
SH(format);
|
||||
SH(width);
|
||||
SH(height);
|
||||
SH(grab_ts);
|
||||
SH(size);
|
||||
# define COPY(_field) *_field = rawsink->shared->_field
|
||||
COPY(format);
|
||||
COPY(width);
|
||||
COPY(height);
|
||||
COPY(grab_ts);
|
||||
COPY(size);
|
||||
memcpy(data, rawsink->shared->data, *size);
|
||||
# undef SH
|
||||
# undef COPY
|
||||
|
||||
if (sem_post(rawsink->lock_sem) < 0) {
|
||||
LOG_PERROR("RAWSINK: Can't post %s", rawsink->lock_name);
|
||||
|
||||
@@ -23,10 +23,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/logging.h"
|
||||
|
||||
|
||||
#ifndef CFG_RAWSINK_MAX_DATA
|
||||
|
||||
@@ -22,29 +22,6 @@
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sys/select.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
#include <linux/v4l2-controls.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/logging.h"
|
||||
#include "../common/threading.h"
|
||||
|
||||
#include "xioctl.h"
|
||||
|
||||
|
||||
static const struct {
|
||||
const char *name;
|
||||
|
||||
@@ -22,11 +22,29 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sys/select.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <linux/videodev2.h>
|
||||
#include <linux/v4l2-controls.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/logging.h"
|
||||
#include "../common/threading.h"
|
||||
|
||||
#include "xioctl.h"
|
||||
|
||||
#ifdef WITH_RAWSINK
|
||||
# include "../rawsink/rawsink.h"
|
||||
|
||||
@@ -22,26 +22,6 @@
|
||||
|
||||
#include "encoder.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <strings.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/threading.h"
|
||||
#include "../common/logging.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "picture.h"
|
||||
|
||||
#include "encoders/cpu/encoder.h"
|
||||
#include "encoders/hw/encoder.h"
|
||||
#ifdef WITH_OMX
|
||||
# include "encoders/omx/encoder.h"
|
||||
#endif
|
||||
|
||||
|
||||
static const struct {
|
||||
const char *name;
|
||||
|
||||
@@ -22,18 +22,27 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <strings.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/threading.h"
|
||||
#include "../common/logging.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "picture.h"
|
||||
|
||||
#include "encoders/cpu/encoder.h"
|
||||
#include "encoders/hw/encoder.h"
|
||||
|
||||
#ifdef WITH_OMX
|
||||
# include "encoders/omx/encoder.h"
|
||||
|
||||
# define ENCODER_TYPES_OMX_HINT ", OMX"
|
||||
|
||||
# ifndef CFG_MAX_GLITCHED_RESOLUTIONS
|
||||
# define CFG_MAX_GLITCHED_RESOLUTIONS 1024
|
||||
# endif
|
||||
|
||||
@@ -27,18 +27,6 @@
|
||||
|
||||
#include "encoder.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <jpeglib.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "../../../common/tools.h"
|
||||
#include "../../picture.h"
|
||||
#include "../../device.h"
|
||||
|
||||
|
||||
struct _jpeg_dest_manager_t {
|
||||
struct jpeg_destination_mgr mgr; // Default manager
|
||||
|
||||
@@ -22,8 +22,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../device.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <jpeglib.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "../../../common/tools.h"
|
||||
#include "../../picture.h"
|
||||
#include "../../device.h"
|
||||
|
||||
|
||||
void cpu_encoder_compress_buffer(struct hw_buffer_t *hw, struct picture_t *picture, unsigned quality);
|
||||
|
||||
@@ -27,20 +27,6 @@
|
||||
|
||||
#include "encoder.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "../../../common/tools.h"
|
||||
#include "../../../common/logging.h"
|
||||
#include "../../xioctl.h"
|
||||
#include "../../picture.h"
|
||||
#include "../../device.h"
|
||||
|
||||
#include "huffman.h"
|
||||
|
||||
|
||||
void _copy_plus_huffman(const struct hw_buffer_t *src, struct picture_t *dest);
|
||||
static bool _is_huffman(const unsigned char *data);
|
||||
|
||||
@@ -22,8 +22,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../device.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "../../../common/tools.h"
|
||||
#include "../../../common/logging.h"
|
||||
#include "../../xioctl.h"
|
||||
#include "../../picture.h"
|
||||
#include "../../device.h"
|
||||
|
||||
#include "huffman.h"
|
||||
|
||||
|
||||
int hw_encoder_prepare(struct device_t *dev, unsigned quality);
|
||||
|
||||
@@ -22,15 +22,6 @@
|
||||
|
||||
#include "component.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <IL/OMX_Core.h>
|
||||
#include <IL/OMX_Component.h>
|
||||
|
||||
#include "../../../common/logging.h"
|
||||
|
||||
#include "formatters.h"
|
||||
|
||||
|
||||
static int _component_wait_port_changed(OMX_HANDLETYPE *component, OMX_U32 port, OMX_BOOL enabled);
|
||||
static int _component_wait_state_changed(OMX_HANDLETYPE *component, OMX_STATETYPE wanted);
|
||||
|
||||
@@ -23,10 +23,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <IL/OMX_Core.h>
|
||||
#include <IL/OMX_Component.h>
|
||||
|
||||
#include "../../../common/logging.h"
|
||||
|
||||
#include "formatters.h"
|
||||
|
||||
|
||||
#define OMX_INIT_STRUCTURE(_var) { \
|
||||
memset(&(_var), 0, sizeof(_var)); \
|
||||
|
||||
@@ -22,28 +22,6 @@
|
||||
|
||||
#include "encoder.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include <bcm_host.h>
|
||||
#include <IL/OMX_Core.h>
|
||||
#include <IL/OMX_Component.h>
|
||||
#include <IL/OMX_Broadcom.h>
|
||||
#include <interface/vcos/vcos_semaphore.h>
|
||||
|
||||
#include "../../../common/logging.h"
|
||||
#include "../../../common/tools.h"
|
||||
#include "../../device.h"
|
||||
#include "../../picture.h"
|
||||
|
||||
#include "formatters.h"
|
||||
#include "component.h"
|
||||
|
||||
|
||||
static const OMX_U32 _INPUT_PORT = 340;
|
||||
static const OMX_U32 _OUTPUT_PORT = 341;
|
||||
|
||||
@@ -22,14 +22,29 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include <bcm_host.h>
|
||||
#include <IL/OMX_Core.h>
|
||||
#include <IL/OMX_Component.h>
|
||||
#include <IL/OMX_Broadcom.h>
|
||||
#include <interface/vcos/vcos_semaphore.h>
|
||||
|
||||
#include "../../../common/logging.h"
|
||||
#include "../../../common/tools.h"
|
||||
#include "../../device.h"
|
||||
#include "../../picture.h"
|
||||
|
||||
#include "formatters.h"
|
||||
#include "component.h"
|
||||
|
||||
|
||||
#ifndef CFG_OMX_MAX_ENCODERS
|
||||
# define CFG_OMX_MAX_ENCODERS 3 // Raspberry Pi limitation
|
||||
#endif
|
||||
|
||||
@@ -22,14 +22,6 @@
|
||||
|
||||
#include "formatters.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <IL/OMX_IVCommon.h>
|
||||
#include <IL/OMX_Core.h>
|
||||
|
||||
#include "../../../common/tools.h"
|
||||
|
||||
|
||||
#define CASE_TO_STRING(_value) \
|
||||
case _value: { return #_value; }
|
||||
|
||||
@@ -22,10 +22,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <IL/OMX_IVCommon.h>
|
||||
#include <IL/OMX_Core.h>
|
||||
#include <IL/OMX_Image.h>
|
||||
|
||||
#include "../../../common/tools.h"
|
||||
#include "../../../common/logging.h"
|
||||
|
||||
|
||||
|
||||
@@ -22,18 +22,6 @@
|
||||
|
||||
#include "gpio.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <gpiod.h>
|
||||
|
||||
#include "../../common/tools.h"
|
||||
#include "../../common/logging.h"
|
||||
#include "../../common/threading.h"
|
||||
|
||||
|
||||
struct gpio_t gpio = {
|
||||
.path = "/dev/gpiochip0",
|
||||
|
||||
@@ -22,13 +22,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <gpiod.h>
|
||||
|
||||
#include "../../common/tools.h"
|
||||
#include "../../common/logging.h"
|
||||
#include "../../common/threading.h"
|
||||
|
||||
|
||||
struct gpio_output_t {
|
||||
|
||||
@@ -22,28 +22,6 @@
|
||||
|
||||
#include "options.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../common/config.h"
|
||||
#include "../common/logging.h"
|
||||
#include "../common/process.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "encoder.h"
|
||||
#include "http/server.h"
|
||||
#ifdef WITH_GPIO
|
||||
# include "gpio/gpio.h"
|
||||
#endif
|
||||
|
||||
|
||||
enum _OPT_VALUES {
|
||||
_O_DEVICE = 'd',
|
||||
|
||||
@@ -22,9 +22,27 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../common/config.h"
|
||||
#include "../common/logging.h"
|
||||
#include "../common/process.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "encoder.h"
|
||||
#include "http/server.h"
|
||||
#ifdef WITH_GPIO
|
||||
# include "gpio/gpio.h"
|
||||
#endif
|
||||
|
||||
|
||||
struct options_t {
|
||||
|
||||
@@ -22,14 +22,6 @@
|
||||
|
||||
#include "picture.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/logging.h"
|
||||
|
||||
|
||||
struct picture_t *picture_init(void) {
|
||||
struct picture_t *picture;
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/logging.h"
|
||||
|
||||
|
||||
struct picture_t {
|
||||
|
||||
@@ -22,29 +22,6 @@
|
||||
|
||||
#include "stream.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdatomic.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/threading.h"
|
||||
#include "../common/logging.h"
|
||||
|
||||
#include "picture.h"
|
||||
#include "device.h"
|
||||
#include "encoder.h"
|
||||
#ifdef WITH_RAWSINK
|
||||
# include "../rawsink/rawsink.h"
|
||||
#endif
|
||||
#ifdef WITH_GPIO
|
||||
# include "gpio/gpio.h"
|
||||
#endif
|
||||
|
||||
|
||||
struct _worker_t {
|
||||
pthread_t tid;
|
||||
|
||||
@@ -22,14 +22,28 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdatomic.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/threading.h"
|
||||
#include "../common/logging.h"
|
||||
|
||||
#include "picture.h"
|
||||
#include "device.h"
|
||||
#include "encoder.h"
|
||||
#ifdef WITH_RAWSINK
|
||||
# include "../rawsink/rawsink.h"
|
||||
#endif
|
||||
#ifdef WITH_GPIO
|
||||
# include "gpio/gpio.h"
|
||||
#endif
|
||||
|
||||
|
||||
struct process_t {
|
||||
|
||||
Reference in New Issue
Block a user