From fa9c76cc2a1bfdafd7bbd537eedde3fce9076138 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 23 Apr 2021 14:06:20 +0200 Subject: [PATCH] VRG: accept RenderPacket by ug_send_frame --- README.md | 1 + src/libug.cpp | 8 +++----- src/libug.h | 2 +- test_libug_sender.c | 5 ++++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3a416d998..2b745c877 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ Changes ### 2021-04-23 - UltraGrid now honors `RenderPacket::dx_row_pitch` and `RenderPacket::dx_row_pitch_uv` for uncompressed stream (not for JPEG yet) +- `ug_send_frame` now accepts and sends RenderPacket ### 2021-03-22 - VRG now allocates buffers with cudaMallocHost, passed to library is with diff --git a/src/libug.cpp b/src/libug.cpp index 73758752d..b27a9eaa1 100644 --- a/src/libug.cpp +++ b/src/libug.cpp @@ -132,17 +132,15 @@ struct ug_sender *ug_sender_init(const struct ug_sender_parameters *init_params) return s; } -void ug_send_frame(struct ug_sender *s, const char *data, libug_pixfmt_t codec, int width, int height, uint32_t seq) +void ug_send_frame(struct ug_sender *s, const char *data, libug_pixfmt_t pixel_format, int width, int height, struct RenderPacket *pkt) { struct video_frame *f = vf_alloc(1); - f->color_spec = (codec_t) codec; + f->color_spec = (codec_t) pixel_format; f->tiles[0].width = width; f->tiles[0].height = height; f->fps = 120; f->interlacing = PROGRESSIVE; - struct RenderPacket render_packet{}; - render_packet.frame = seq; - f->render_packet = render_packet; + f->render_packet = *pkt; f->tiles[0].data = const_cast(data); f->tiles[0].data_len = vc_get_datalen(width, height, f->color_spec); diff --git a/src/libug.h b/src/libug.h index bd4ee8d2f..9f87c06b7 100644 --- a/src/libug.h +++ b/src/libug.h @@ -64,7 +64,7 @@ LIBUG_DLL struct ug_sender *ug_sender_init(const struct ug_sender_parameters *in * * This function is blocking. */ -LIBUG_DLL void ug_send_frame(struct ug_sender *state, const char *data, libug_pixfmt_t pixel_format, int width, int height, uint32_t seq); +LIBUG_DLL void ug_send_frame(struct ug_sender *state, const char *data, libug_pixfmt_t pixel_format, int width, int height, struct RenderPacket *pkt); LIBUG_DLL void ug_sender_done(struct ug_sender *state); struct ug_receiver; diff --git a/test_libug_sender.c b/test_libug_sender.c index 335b58117..03532f4ca 100644 --- a/test_libug_sender.c +++ b/test_libug_sender.c @@ -8,6 +8,8 @@ #include +#include "src/vrgstream-fallback.h" + #define DEFAULT_WIDTH 1920 #define DEFAULT_HEIGHT 1080 #define FPS 30.0 @@ -105,7 +107,8 @@ int main(int argc, char *argv[]) { uint32_t frames = 0; uint32_t frames_last = 0; while (1) { - ug_send_frame(s, (char *) test + width * 4 * (frames % 768), UG_RGBA, width, height, frames); + struct RenderPacket pkt = { .frame = frames }; + ug_send_frame(s, (char *) test + width * 4 * (frames % 768), UG_RGBA, width, height, &pkt); frames += 1; time_t seconds = time(NULL) - t0; if (seconds > 0) {