mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-05-27 15:56:22 +00:00
refactoring
This commit is contained in:
@@ -65,7 +65,7 @@ static struct blank_t *_blank_init_internal() {
|
|||||||
A_CALLOC(blank, 1);
|
A_CALLOC(blank, 1);
|
||||||
|
|
||||||
A_CALLOC(blank->picture.data, ARRAY_LEN(BLANK_JPEG_DATA));
|
A_CALLOC(blank->picture.data, ARRAY_LEN(BLANK_JPEG_DATA));
|
||||||
memcpy(blank->picture.data, BLANK_JPEG_DATA, ARRAY_LEN(BLANK_JPEG_DATA) * sizeof(*blank->picture.data));
|
memcpy(blank->picture.data, BLANK_JPEG_DATA, ARRAY_LEN(BLANK_JPEG_DATA));
|
||||||
|
|
||||||
blank->picture.used = ARRAY_LEN(BLANK_JPEG_DATA);
|
blank->picture.used = ARRAY_LEN(BLANK_JPEG_DATA);
|
||||||
blank->picture.allocated = ARRAY_LEN(BLANK_JPEG_DATA);
|
blank->picture.allocated = ARRAY_LEN(BLANK_JPEG_DATA);
|
||||||
@@ -112,7 +112,7 @@ static struct blank_t *_blank_init_external(const char *path) {
|
|||||||
A_REALLOC(blank->picture.data, blank->picture.allocated);
|
A_REALLOC(blank->picture.data, blank->picture.allocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t readed = fread(blank->picture.data + blank->picture.used, sizeof(*blank->picture.data), CHUNK_SIZE, fp);
|
size_t readed = fread(blank->picture.data + blank->picture.used, 1, CHUNK_SIZE, fp);
|
||||||
blank->picture.used += readed;
|
blank->picture.used += readed;
|
||||||
|
|
||||||
if (readed < CHUNK_SIZE) {
|
if (readed < CHUNK_SIZE) {
|
||||||
|
|||||||
@@ -645,8 +645,9 @@ static void _http_callback_stream_write(struct bufferevent *buf_event, void *v_c
|
|||||||
"Content-Length: %zu" RN
|
"Content-Length: %zu" RN
|
||||||
"X-Timestamp: %.06Lf" RN
|
"X-Timestamp: %.06Lf" RN
|
||||||
"%s",
|
"%s",
|
||||||
EXPOSED(picture.used) * sizeof(*EXPOSED(picture.data)),
|
EXPOSED(picture.used),
|
||||||
get_now_real(), (client->extra_headers ? "" : RN)
|
get_now_real(),
|
||||||
|
(client->extra_headers ? "" : RN)
|
||||||
));
|
));
|
||||||
if (client->extra_headers) {
|
if (client->extra_headers) {
|
||||||
assert(evbuffer_add_printf(buf,
|
assert(evbuffer_add_printf(buf,
|
||||||
@@ -679,10 +680,7 @@ static void _http_callback_stream_write(struct bufferevent *buf_event, void *v_c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!evbuffer_add(buf,
|
assert(!evbuffer_add(buf, (void *)EXPOSED(picture.data), EXPOSED(picture.used)));
|
||||||
(void *)EXPOSED(picture.data),
|
|
||||||
EXPOSED(picture.used) * sizeof(*EXPOSED(picture.data))
|
|
||||||
));
|
|
||||||
assert(evbuffer_add_printf(buf, RN "--" BOUNDARY RN));
|
assert(evbuffer_add_printf(buf, RN "--" BOUNDARY RN));
|
||||||
|
|
||||||
if (client->advance_headers) {
|
if (client->advance_headers) {
|
||||||
@@ -828,8 +826,7 @@ static bool _expose_new_picture(struct http_server_t *server) {
|
|||||||
EXPOSED(expose_begin_time) = get_now_monotonic();
|
EXPOSED(expose_begin_time) = get_now_monotonic();
|
||||||
|
|
||||||
# define MEM_STREAM_TO_EXPOSED \
|
# define MEM_STREAM_TO_EXPOSED \
|
||||||
EXPOSED(picture.data), STREAM(picture.data), \
|
EXPOSED(picture.data), STREAM(picture.data), STREAM(picture.used)
|
||||||
STREAM(picture.used) * sizeof(*STREAM(picture.data))
|
|
||||||
|
|
||||||
if (server->drop_same_frames) {
|
if (server->drop_same_frames) {
|
||||||
if (
|
if (
|
||||||
@@ -894,7 +891,7 @@ static bool _expose_blank_picture(struct http_server_t *server) {
|
|||||||
EXPOSED(picture.allocated) = BLANK(picture.used);
|
EXPOSED(picture.allocated) = BLANK(picture.used);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(EXPOSED(picture.data), BLANK(picture.data), BLANK(picture.used) * sizeof(*EXPOSED(picture.data)));
|
memcpy(EXPOSED(picture.data), BLANK(picture.data), BLANK(picture.used));
|
||||||
|
|
||||||
EXPOSED(picture.used) = BLANK(picture.used);
|
EXPOSED(picture.used) = BLANK(picture.used);
|
||||||
|
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ static void _stream_expose_picture(struct stream_t *stream, unsigned buf_index)
|
|||||||
stream->picture.used = PICTURE(used);
|
stream->picture.used = PICTURE(used);
|
||||||
stream->picture.allocated = PICTURE(allocated);
|
stream->picture.allocated = PICTURE(allocated);
|
||||||
|
|
||||||
memcpy(stream->picture.data, PICTURE(data), stream->picture.used * sizeof(*stream->picture.data));
|
memcpy(stream->picture.data, PICTURE(data), stream->picture.used);
|
||||||
|
|
||||||
stream->picture.grab_time = PICTURE(grab_time);
|
stream->picture.grab_time = PICTURE(grab_time);
|
||||||
stream->picture.encode_begin_time = PICTURE(encode_begin_time);
|
stream->picture.encode_begin_time = PICTURE(encode_begin_time);
|
||||||
|
|||||||
Reference in New Issue
Block a user