mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-13 11:03:43 +00:00
using frame_s for rawsink
This commit is contained in:
@@ -129,18 +129,13 @@ void rawsink_destroy(rawsink_s *rawsink) {
|
|||||||
free(rawsink);
|
free(rawsink);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rawsink_server_put(
|
int rawsink_server_put(rawsink_s *rawsink, frame_s *raw) {
|
||||||
rawsink_s *rawsink,
|
|
||||||
const uint8_t *data, size_t size,
|
|
||||||
unsigned format, unsigned width, unsigned height,
|
|
||||||
long double grab_ts, bool online) {
|
|
||||||
|
|
||||||
long double now = get_now_monotonic();
|
long double now = get_now_monotonic();
|
||||||
|
|
||||||
assert(rawsink->server);
|
assert(rawsink->server);
|
||||||
|
|
||||||
if (size > RAWSINK_MAX_DATA) {
|
if (raw->used > RAWSINK_MAX_DATA) {
|
||||||
LOG_ERROR("RAWSINK: Can't put RAW frame: is too big (%zu > %zu)", size, RAWSINK_MAX_DATA);
|
LOG_ERROR("RAWSINK: Can't put RAW frame: is too big (%zu > %zu)", raw->used, RAWSINK_MAX_DATA);
|
||||||
return 0; // -2
|
return 0; // -2
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,14 +147,13 @@ int rawsink_server_put(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# define COPY(_field) rawsink->mem->_field = _field
|
# define COPY(_field) rawsink->mem->_field = raw->_field
|
||||||
|
COPY(used);
|
||||||
COPY(format);
|
COPY(format);
|
||||||
COPY(width);
|
COPY(width);
|
||||||
COPY(height);
|
COPY(height);
|
||||||
COPY(grab_ts);
|
COPY(grab_ts);
|
||||||
COPY(online);
|
memcpy(rawsink->mem->data, raw->data, raw->used);
|
||||||
COPY(size);
|
|
||||||
memcpy(rawsink->mem->data, data, size);
|
|
||||||
# undef COPY
|
# undef COPY
|
||||||
|
|
||||||
if (sem_post(rawsink->sig_sem) < 0) {
|
if (sem_post(rawsink->sig_sem) < 0) {
|
||||||
@@ -182,12 +176,7 @@ int rawsink_server_put(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rawsink_client_get( // cppcheck-suppress unusedFunction
|
int rawsink_client_get(rawsink_s *rawsink, frame_s *raw) { // cppcheck-suppress unusedFunction
|
||||||
rawsink_s *rawsink,
|
|
||||||
char *data, size_t *size,
|
|
||||||
unsigned *format, unsigned *width, unsigned *height,
|
|
||||||
long double *grab_ts, bool *online) {
|
|
||||||
|
|
||||||
assert(!rawsink->server); // Client only
|
assert(!rawsink->server); // Client only
|
||||||
|
|
||||||
if (_sem_timedwait_monotonic(rawsink->sig_sem, rawsink->timeout) < 0) {
|
if (_sem_timedwait_monotonic(rawsink->sig_sem, rawsink->timeout) < 0) {
|
||||||
@@ -205,14 +194,12 @@ int rawsink_client_get( // cppcheck-suppress unusedFunction
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# define COPY(_field) *_field = rawsink->mem->_field
|
# define COPY(_field) raw->_field = rawsink->mem->_field
|
||||||
COPY(format);
|
|
||||||
COPY(width);
|
COPY(width);
|
||||||
COPY(height);
|
COPY(height);
|
||||||
|
COPY(format);
|
||||||
COPY(grab_ts);
|
COPY(grab_ts);
|
||||||
COPY(online);
|
frame_set_data(raw, rawsink->mem->data, rawsink->mem->used);
|
||||||
COPY(size);
|
|
||||||
memcpy(data, rawsink->mem->data, *size);
|
|
||||||
# undef COPY
|
# undef COPY
|
||||||
|
|
||||||
if (flock(rawsink->fd, LOCK_UN) < 0) {
|
if (flock(rawsink->fd, LOCK_UN) < 0) {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
#include "../common/tools.h"
|
#include "../common/tools.h"
|
||||||
#include "../common/logging.h"
|
#include "../common/logging.h"
|
||||||
|
#include "../common/frame.h"
|
||||||
|
|
||||||
|
|
||||||
#ifndef CFG_RAWSINK_MAX_DATA
|
#ifndef CFG_RAWSINK_MAX_DATA
|
||||||
@@ -46,12 +47,11 @@
|
|||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned format;
|
size_t used;
|
||||||
unsigned width;
|
unsigned width;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
|
unsigned format;
|
||||||
long double grab_ts;
|
long double grab_ts;
|
||||||
bool online;
|
|
||||||
size_t size;
|
|
||||||
uint8_t data[RAWSINK_MAX_DATA];
|
uint8_t data[RAWSINK_MAX_DATA];
|
||||||
} rawsink_shared_s;
|
} rawsink_shared_s;
|
||||||
|
|
||||||
@@ -72,14 +72,5 @@ typedef struct {
|
|||||||
rawsink_s *rawsink_init(const char *name, bool server, mode_t mode, bool rm, unsigned timeout);
|
rawsink_s *rawsink_init(const char *name, bool server, mode_t mode, bool rm, unsigned timeout);
|
||||||
void rawsink_destroy(rawsink_s *rawsink);
|
void rawsink_destroy(rawsink_s *rawsink);
|
||||||
|
|
||||||
int rawsink_server_put(
|
int rawsink_server_put(rawsink_s *rawsink, frame_s *raw);
|
||||||
rawsink_s *rawsink,
|
int rawsink_client_get(rawsink_s *rawsink, frame_s *raw);
|
||||||
const uint8_t *data, size_t size,
|
|
||||||
unsigned format, unsigned witdh, unsigned height,
|
|
||||||
long double grab_ts, bool online);
|
|
||||||
|
|
||||||
int rawsink_client_get(
|
|
||||||
rawsink_s *rawsink,
|
|
||||||
char *data, size_t *size,
|
|
||||||
unsigned *format, unsigned *width, unsigned *height,
|
|
||||||
long double *grab_ts, bool *online);
|
|
||||||
|
|||||||
@@ -209,15 +209,10 @@ void stream_loop(stream_s *stream) {
|
|||||||
LOG_VERBOSE("Fluency: delay=%.03Lf, grab_after=%.03Lf", fluency_delay, grab_after);
|
LOG_VERBOSE("Fluency: delay=%.03Lf, grab_after=%.03Lf", fluency_delay, grab_after);
|
||||||
|
|
||||||
# ifdef WITH_RAWSINK
|
# ifdef WITH_RAWSINK
|
||||||
# define RAW(_next) DEV(run->hw_buffers[buf_index].raw._next)
|
if (stream->rawsink && rawsink_server_put(stream->rawsink, &DEV(run->hw_buffers[buf_index].raw)) < 0) {
|
||||||
if (stream->rawsink && rawsink_server_put(
|
|
||||||
stream->rawsink, RAW(data), RAW(used), RAW(format),
|
|
||||||
RAW(width), RAW(height), RAW(grab_ts), true
|
|
||||||
) < 0) {
|
|
||||||
stream->rawsink = NULL;
|
stream->rawsink = NULL;
|
||||||
LOG_ERROR("RAW sink completely disabled due error");
|
LOG_ERROR("RAW sink completely disabled due error");
|
||||||
}
|
}
|
||||||
# undef RAW
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
_workers_pool_assign(pool, ready_wr, buf_index);
|
_workers_pool_assign(pool, ready_wr, buf_index);
|
||||||
@@ -270,15 +265,10 @@ static _pool_s *_stream_init_loop(stream_s *stream) {
|
|||||||
while (!atomic_load(&stream->proc->stop)) {
|
while (!atomic_load(&stream->proc->stop)) {
|
||||||
if (_stream_expose_frame(stream, NULL, 0)) {
|
if (_stream_expose_frame(stream, NULL, 0)) {
|
||||||
# ifdef WITH_RAWSINK
|
# ifdef WITH_RAWSINK
|
||||||
# define BLANK(_next) stream->blank->_next
|
if (stream->rawsink && rawsink_server_put(stream->rawsink, stream->blank) < 0) {
|
||||||
if (stream->rawsink && rawsink_server_put(
|
|
||||||
stream->rawsink, BLANK(data), BLANK(used), V4L2_PIX_FMT_JPEG,
|
|
||||||
BLANK(width), BLANK(height), BLANK(grab_ts), false
|
|
||||||
) < 0) {
|
|
||||||
stream->rawsink = NULL;
|
stream->rawsink = NULL;
|
||||||
LOG_ERROR("RAW sink completely disabled due error");
|
LOG_ERROR("RAW sink completely disabled due error");
|
||||||
}
|
}
|
||||||
# undef BLANK
|
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user