mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-05-27 15:56:22 +00:00
refactoring and test recorder
This commit is contained in:
30
src/recorder/main.c
Normal file
30
src/recorder/main.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
#include "../common/logging.h"
|
||||
#include "../common/frame.h"
|
||||
#include "../rawsink/rawsink.h"
|
||||
#include "../h264/encoder.h"
|
||||
|
||||
int main(void) {
|
||||
LOGGING_INIT;
|
||||
log_level = 3;
|
||||
|
||||
frame_s *src = frame_init("src");
|
||||
frame_s *dest = frame_init("dest");
|
||||
h264_encoder_s *encoder = h264_encoder_init();
|
||||
rawsink_s *rawsink = rawsink_init("test", false, 0, 0, (long double)encoder->fps / (long double)encoder->gop);
|
||||
FILE *fp = fopen("test.h264", "wb");
|
||||
|
||||
if (rawsink) {
|
||||
int error = 0;
|
||||
while ((error = rawsink_client_get(rawsink, src)) != -1) {
|
||||
if (error == 0 /*|| (error == -2 && src->used > 0)*/) {
|
||||
if (!h264_encoder_compress(encoder, src, dest, false)) {
|
||||
LOG_INFO("frame %Lf", get_now_monotonic() - dest->grab_ts);
|
||||
/*fwrite(dest->data, 1, dest->used, fp);
|
||||
fflush(fp);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -29,9 +29,9 @@
|
||||
#include <jpeglib.h>
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/logging.h"
|
||||
#include "../common/frame.h"
|
||||
#include "../libs/common/tools.h"
|
||||
#include "../libs/common/logging.h"
|
||||
#include "../libs/common/frame.h"
|
||||
|
||||
#include "data/blank_jpeg.h"
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "../../common/config.h"
|
||||
#include "../../libs/common/config.h"
|
||||
|
||||
|
||||
extern const char *const HTML_INDEX_PAGE;
|
||||
|
||||
@@ -41,15 +41,15 @@
|
||||
#include <linux/videodev2.h>
|
||||
#include <linux/v4l2-controls.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/logging.h"
|
||||
#include "../common/threading.h"
|
||||
#include "../common/frame.h"
|
||||
#include "../libs/common/tools.h"
|
||||
#include "../libs/common/logging.h"
|
||||
#include "../libs/common/threading.h"
|
||||
#include "../libs/common/frame.h"
|
||||
|
||||
#include "xioctl.h"
|
||||
|
||||
#ifdef WITH_RAWSINK
|
||||
# include "../rawsink/rawsink.h"
|
||||
# include "../libs/rawsink/rawsink.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
#include <pthread.h>
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/threading.h"
|
||||
#include "../common/logging.h"
|
||||
#include "../common/frame.h"
|
||||
#include "../libs/common/tools.h"
|
||||
#include "../libs/common/threading.h"
|
||||
#include "../libs/common/logging.h"
|
||||
#include "../libs/common/frame.h"
|
||||
|
||||
#include "device.h"
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "../../../common/tools.h"
|
||||
#include "../../../common/frame.h"
|
||||
#include "../../../libs/common/tools.h"
|
||||
#include "../../../libs/common/frame.h"
|
||||
|
||||
|
||||
void cpu_encoder_compress(frame_s *src, frame_s *dest, unsigned quality);
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "../../../common/tools.h"
|
||||
#include "../../../common/logging.h"
|
||||
#include "../../../common/frame.h"
|
||||
#include "../../../libs/common/tools.h"
|
||||
#include "../../../libs/common/logging.h"
|
||||
#include "../../../libs/common/frame.h"
|
||||
#include "../../xioctl.h"
|
||||
#include "../../device.h"
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <IL/OMX_Core.h>
|
||||
#include <IL/OMX_Component.h>
|
||||
|
||||
#include "../../../common/logging.h"
|
||||
#include "../../../libs/common/logging.h"
|
||||
|
||||
#include "formatters.h"
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
#include <IL/OMX_Broadcom.h>
|
||||
#include <interface/vcos/vcos_semaphore.h>
|
||||
|
||||
#include "../../../common/tools.h"
|
||||
#include "../../../common/logging.h"
|
||||
#include "../../../common/frame.h"
|
||||
#include "../../../libs/common/tools.h"
|
||||
#include "../../../libs/common/logging.h"
|
||||
#include "../../../libs/common/frame.h"
|
||||
#include "../../device.h"
|
||||
|
||||
#include "formatters.h"
|
||||
|
||||
@@ -26,12 +26,6 @@
|
||||
#define CASE_TO_STRING(_value) \
|
||||
case _value: { return #_value; }
|
||||
|
||||
#define CASE_ASSERT(_msg, _value) default: { \
|
||||
char *_assert_buf; A_CALLOC(_assert_buf, 128); \
|
||||
sprintf(_assert_buf, _msg ": 0x%08x", _value); \
|
||||
assert(0 && _assert_buf); \
|
||||
}
|
||||
|
||||
const char *omx_error_to_string(OMX_ERRORTYPE error) {
|
||||
switch (error) {
|
||||
CASE_TO_STRING(OMX_ErrorNone);
|
||||
@@ -93,9 +87,8 @@ const char *omx_state_to_string(OMX_STATETYPE state) {
|
||||
CASE_TO_STRING(OMX_StateWaitForResources);
|
||||
// cppcheck-suppress constArgument
|
||||
// cppcheck-suppress knownArgument
|
||||
CASE_ASSERT("Unsupported OMX state", state);
|
||||
}
|
||||
assert(0 && "Unsupported OMX state");
|
||||
}
|
||||
|
||||
#undef CASE_ASSERT
|
||||
#undef CASE_TO_STRING
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
#include <IL/OMX_Core.h>
|
||||
#include <IL/OMX_Image.h>
|
||||
|
||||
#include "../../../common/tools.h"
|
||||
#include "../../../common/logging.h"
|
||||
#include "../../../libs/common/tools.h"
|
||||
#include "../../../libs/common/logging.h"
|
||||
|
||||
|
||||
#define LOG_ERROR_OMX(_error, _msg, ...) { \
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
#include <pthread.h>
|
||||
#include <gpiod.h>
|
||||
|
||||
#include "../../common/tools.h"
|
||||
#include "../../common/logging.h"
|
||||
#include "../../common/threading.h"
|
||||
#include "../../libs/common/tools.h"
|
||||
#include "../../libs/common/logging.h"
|
||||
#include "../../libs/common/threading.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../common/tools.h"
|
||||
#include "../../libs/common/tools.h"
|
||||
|
||||
|
||||
char *base64_encode(const uint8_t *str);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#include <event2/util.h>
|
||||
|
||||
#include "../../common/tools.h"
|
||||
#include "../../libs/common/tools.h"
|
||||
|
||||
|
||||
const char *guess_mime_type(const char *str);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include "../../common/tools.h"
|
||||
#include "../../libs/common/tools.h"
|
||||
|
||||
|
||||
char *simplify_request_path(const char *str);
|
||||
|
||||
@@ -53,11 +53,11 @@
|
||||
# error Required libevent-pthreads support
|
||||
#endif
|
||||
|
||||
#include "../../common/tools.h"
|
||||
#include "../../common/threading.h"
|
||||
#include "../../common/logging.h"
|
||||
#include "../../common/process.h"
|
||||
#include "../../common/frame.h"
|
||||
#include "../../libs/common/tools.h"
|
||||
#include "../../libs/common/threading.h"
|
||||
#include "../../libs/common/logging.h"
|
||||
#include "../../libs/common/process.h"
|
||||
#include "../../libs/common/frame.h"
|
||||
#include "../data/index_html.h"
|
||||
#include "../encoder.h"
|
||||
#include "../stream.h"
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "../../common/tools.h"
|
||||
#include "../../common/logging.h"
|
||||
#include "../../libs/common/tools.h"
|
||||
#include "../../libs/common/logging.h"
|
||||
|
||||
#include "path.h"
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
#include <event2/http.h>
|
||||
#include <event2/util.h>
|
||||
|
||||
#include "../../common/tools.h"
|
||||
#include "../../common/logging.h"
|
||||
#include "../../libs/common/tools.h"
|
||||
#include "../../libs/common/logging.h"
|
||||
|
||||
|
||||
evutil_socket_t evhttp_my_bind_unix(struct evhttp *http, const char *path, bool rm, mode_t mode);
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/threading.h"
|
||||
#include "../common/logging.h"
|
||||
#include "../libs/common/tools.h"
|
||||
#include "../libs/common/threading.h"
|
||||
#include "../libs/common/logging.h"
|
||||
|
||||
#include "options.h"
|
||||
#include "device.h"
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../common/config.h"
|
||||
#include "../common/logging.h"
|
||||
#include "../common/process.h"
|
||||
#include "../common/frame.h"
|
||||
#include "../libs/common/config.h"
|
||||
#include "../libs/common/logging.h"
|
||||
#include "../libs/common/process.h"
|
||||
#include "../libs/common/frame.h"
|
||||
#ifdef WITH_RAWSINK
|
||||
# include "../rawsink/rawsink.h"
|
||||
# include "../libs/rawsink/rawsink.h"
|
||||
#endif
|
||||
|
||||
#include "device.h"
|
||||
|
||||
@@ -32,16 +32,16 @@
|
||||
#include <pthread.h>
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/threading.h"
|
||||
#include "../common/logging.h"
|
||||
#include "../common/frame.h"
|
||||
#include "../libs/common/tools.h"
|
||||
#include "../libs/common/threading.h"
|
||||
#include "../libs/common/logging.h"
|
||||
#include "../libs/common/frame.h"
|
||||
|
||||
#include "blank.h"
|
||||
#include "device.h"
|
||||
#include "encoder.h"
|
||||
#ifdef WITH_RAWSINK
|
||||
# include "../rawsink/rawsink.h"
|
||||
# include "../libs/rawsink/rawsink.h"
|
||||
#endif
|
||||
#ifdef WITH_GPIO
|
||||
# include "gpio/gpio.h"
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "../common/tools.h"
|
||||
#include "../common/logging.h"
|
||||
#include "../libs/common/tools.h"
|
||||
#include "../libs/common/logging.h"
|
||||
|
||||
|
||||
#ifndef CFG_XIOCTL_RETRIES
|
||||
|
||||
Reference in New Issue
Block a user