mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-02 13:51:41 +00:00
fixes
This commit is contained in:
@@ -18,7 +18,7 @@ commands = cppcheck \
|
||||
--suppress=variableScope \
|
||||
--inline-suppr \
|
||||
-DCHAR_BIT=8 \
|
||||
-DWITH_RAWSINK \
|
||||
-DWITH_MEMSINK \
|
||||
-DWITH_OMX \
|
||||
-DWITH_GPIO \
|
||||
src
|
||||
|
||||
@@ -151,13 +151,13 @@ static int _h264_encoder_configure(h264_encoder_s *encoder, const frame_s *frame
|
||||
|
||||
# define IFMT(_next) RUN(input_port->format->_next)
|
||||
IFMT(type) = MMAL_ES_TYPE_VIDEO;
|
||||
char fourcc_buf[8];
|
||||
switch (frame->format) {
|
||||
case V4L2_PIX_FMT_YUYV: IFMT(encoding) = MMAL_ENCODING_YUYV; break;
|
||||
case V4L2_PIX_FMT_UYVY: IFMT(encoding) = MMAL_ENCODING_UYVY; break;
|
||||
case V4L2_PIX_FMT_RGB565: IFMT(encoding) = MMAL_ENCODING_RGB16; break;
|
||||
case V4L2_PIX_FMT_RGB24: IFMT(encoding) = MMAL_ENCODING_RGB24; break;
|
||||
default:
|
||||
char fourcc_buf[8];
|
||||
LOG_ERROR("Unsupported input format for MMAL (fourcc): %s", fourcc_to_string(frame->format, fourcc_buf, 8));
|
||||
goto error;
|
||||
}
|
||||
@@ -273,9 +273,9 @@ static void _h264_encoder_cleanup(h264_encoder_s *encoder) {
|
||||
|
||||
static int _h264_encoder_compress_raw(h264_encoder_s *encoder, const frame_s *src, frame_s *dest, bool force_key) {
|
||||
assert(src->used > 0);
|
||||
assert(src->width == encoder->i_width);
|
||||
assert(src->height == encoder->i_height);
|
||||
assert(src->format == encoder->i_format);
|
||||
assert(src->width == RUN(i_width));
|
||||
assert(src->height == RUN(i_height));
|
||||
assert(src->format == RUN(i_format));
|
||||
|
||||
MMAL_STATUS_T error;
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
#include <bcm_host.h>
|
||||
|
||||
#include "../common/logging.h"
|
||||
#include "../common/frame.h"
|
||||
#include "../memsink/memsink.h"
|
||||
#include "../h264/encoder.h"
|
||||
#include "../libs/common/logging.h"
|
||||
#include "../libs/common/frame.h"
|
||||
#include "../libs/memsink/memsink.h"
|
||||
#include "../libs/h264/encoder.h"
|
||||
|
||||
int main(void) {
|
||||
LOGGING_INIT;
|
||||
|
||||
@@ -32,7 +32,7 @@ static const struct {
|
||||
# ifdef WITH_OMX
|
||||
{"OMX", ENCODER_TYPE_OMX},
|
||||
# endif
|
||||
# ifdef WITH_RAWSINK
|
||||
# ifdef WITH_MEMSINK
|
||||
{"NOOP", ENCODER_TYPE_NOOP},
|
||||
# endif
|
||||
};
|
||||
@@ -151,7 +151,7 @@ void encoder_prepare(encoder_s *encoder, device_s *dev) {
|
||||
}
|
||||
}
|
||||
# endif
|
||||
# ifdef WITH_RAWSINK
|
||||
# ifdef WITH_MEMSINK
|
||||
else if (type == ENCODER_TYPE_NOOP) {
|
||||
ER(n_workers) = 1;
|
||||
quality = 0;
|
||||
@@ -172,7 +172,7 @@ void encoder_prepare(encoder_s *encoder, device_s *dev) {
|
||||
quality = dev->jpeg_quality;
|
||||
|
||||
ok:
|
||||
# ifdef WITH_RAWSINK
|
||||
# ifdef WITH_MEMSINK
|
||||
if (type == ENCODER_TYPE_NOOP) {
|
||||
LOG_INFO("Using JPEG NOOP encoder");
|
||||
} else
|
||||
@@ -227,7 +227,7 @@ int encoder_compress(encoder_s *encoder, unsigned worker_number, frame_s *src, f
|
||||
}
|
||||
}
|
||||
# endif
|
||||
# ifdef WITH_RAWSINK
|
||||
# ifdef WITH_MEMSINK
|
||||
else if (ER(type) == ENCODER_TYPE_NOOP) {
|
||||
LOG_VERBOSE("Compressing buffer using NOOP (do nothing)");
|
||||
usleep(5000); // Просто чтобы работала логика desired_fps
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
# define ENCODER_TYPES_OMX_HINT ""
|
||||
#endif
|
||||
|
||||
#ifdef WITH_RAWSINK
|
||||
#ifdef WITH_MEMSINK
|
||||
# define ENCODER_TYPES_NOOP_HINT ", NOOP"
|
||||
#else
|
||||
# define ENCODER_TYPES_NOOP_HINT ""
|
||||
@@ -70,7 +70,7 @@ typedef enum {
|
||||
# ifdef WITH_OMX
|
||||
ENCODER_TYPE_OMX,
|
||||
# endif
|
||||
# ifdef WITH_RAWSINK
|
||||
# ifdef WITH_MEMSINK
|
||||
ENCODER_TYPE_NOOP,
|
||||
# endif
|
||||
} encoder_type_e;
|
||||
|
||||
@@ -97,7 +97,8 @@ void omx_encoder_destroy(omx_encoder_s *omx) {
|
||||
}
|
||||
|
||||
if (omx->i_encoder) {
|
||||
if ((OMX_ERRORTYPE error = OMX_FreeHandle(omx->encoder)) != OMX_ErrorNone) {
|
||||
OMX_ERRORTYPE error;
|
||||
if ((error = OMX_FreeHandle(omx->encoder)) != OMX_ErrorNone) {
|
||||
LOG_ERROR_OMX(error, "Can't free OMX.broadcom.image_encode");
|
||||
}
|
||||
}
|
||||
@@ -139,7 +140,7 @@ int omx_encoder_compress(omx_encoder_s *omx, const frame_s *src, frame_s *dest)
|
||||
omx->output_available = false;
|
||||
omx->input_required = true;
|
||||
|
||||
const size_t slice_size = (IN(nAllocLen) < src->used ? IN(nAllocLen) : src->used);
|
||||
size_t slice_size = (IN(nAllocLen) < src->used ? IN(nAllocLen) : src->used);
|
||||
size_t pos = 0;
|
||||
|
||||
while (true) {
|
||||
|
||||
@@ -87,6 +87,7 @@ const char *omx_state_to_string(OMX_STATETYPE state) {
|
||||
CASE_TO_STRING(OMX_StateWaitForResources);
|
||||
// cppcheck-suppress constArgument
|
||||
// cppcheck-suppress knownArgument
|
||||
default: break;
|
||||
}
|
||||
assert(0 && "Unsupported OMX state");
|
||||
}
|
||||
|
||||
@@ -114,38 +114,28 @@ static void _install_signal_handlers(void) {
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
assert(argc >= 0);
|
||||
int exit_code = 0;
|
||||
|
||||
LOGGING_INIT;
|
||||
A_THREAD_RENAME("main");
|
||||
|
||||
# ifdef WITH_OMX
|
||||
bcm_host_init();
|
||||
OMX_ERRORTYPE omx_error;
|
||||
if ((omx_error = OMX_Init()) != OMX_ErrorNone) {
|
||||
LOG_ERROR_OMX(omx_error, "Can't initialize OMX Core");
|
||||
exit_code = -1;
|
||||
goto omx_error;
|
||||
}
|
||||
# endif
|
||||
|
||||
options_s *options = options_init(argc, argv);
|
||||
device_s *dev = device_init();
|
||||
encoder_s *encoder = encoder_init();
|
||||
stream_s *stream = stream_init(dev, encoder);
|
||||
server_s *server = server_init(stream);
|
||||
|
||||
int exit_code = 0;
|
||||
|
||||
if ((exit_code = options_parse(options, dev, encoder, stream, server)) == 0) {
|
||||
# ifdef WITH_OMX
|
||||
bool i_bcm_host = false;
|
||||
if (encoder->type == ENCODER_TYPE_OMX) {
|
||||
LOG_INFO("Initializing BCM Host ...");
|
||||
bcm_host_init();
|
||||
i_bcm_host = true;
|
||||
}
|
||||
bool i_omx_core = false
|
||||
if (encodeer->type == ENCODER_TYPE_OMX) {
|
||||
LOG_INFO("Initializing OMX Core ...");
|
||||
if ((OMX_ERRORTYPE error = OMX_Init()) != OMX_ErrorNone) {
|
||||
LOG_ERROR_OMX(error, "Can't initialize OMX Core");
|
||||
exit_code = -1;
|
||||
goto omx_error;
|
||||
}
|
||||
i_omx_core = true;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef WITH_GPIO
|
||||
gpio_init();
|
||||
# endif
|
||||
@@ -174,24 +164,20 @@ int main(int argc, char *argv[]) {
|
||||
gpio_set_prog_running(false);
|
||||
gpio_destroy();
|
||||
# endif
|
||||
|
||||
# ifdef WITH_OMX
|
||||
omx_error:
|
||||
if (i_omx_core) {
|
||||
OMX_Deinit();
|
||||
}
|
||||
if (i_bcm_host) {
|
||||
bcm_host_deinit();
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
server_destroy(server);
|
||||
stream_destroy(stream);
|
||||
encoder_destroy(encoder);
|
||||
device_destroy(dev);
|
||||
|
||||
options_destroy(options);
|
||||
|
||||
# ifdef WITH_OMX
|
||||
OMX_Deinit();
|
||||
omx_error:
|
||||
bcm_host_deinit();
|
||||
# endif
|
||||
|
||||
if (exit_code == 0) {
|
||||
LOG_INFO("Bye-bye");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user