From f7e26fcad32c86990fd21451133b130b0a69ef60 Mon Sep 17 00:00:00 2001 From: Will S Date: Thu, 2 Mar 2023 17:04:51 +0000 Subject: [PATCH 1/2] Ignore multi-frame messages --- src/zeromq/gstzmqsrc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/zeromq/gstzmqsrc.c b/src/zeromq/gstzmqsrc.c index bd02976..cc55a49 100644 --- a/src/zeromq/gstzmqsrc.c +++ b/src/zeromq/gstzmqsrc.c @@ -230,7 +230,16 @@ gst_zmq_src_create (GstPushSrc * psrc, GstBuffer ** outbuf) gst_buffer_unmap (*outbuf, &map); - zmq_msg_close (&msg); + // Ignore later frames in multi-frame messages + if (zmq_msg_more(&msg)) { + while (1) { + zmq_msg_t trailing; + zmq_msg_init(&trailing); + zmq_msg_recv(&trailing, src->socket, 0); + zmq_msg_close(&trailing); + if (!zmq_msg_more(&trailing)) break; + } + } GST_LOG_OBJECT (src, "delivered a buffer of size %" G_GSIZE_FORMAT " bytes", msg_size); From 08e815a9fb8373011b5a378b778b37cb1668575e Mon Sep 17 00:00:00 2001 From: Will S Date: Thu, 2 Mar 2023 17:26:43 +0000 Subject: [PATCH 2/2] Ignore multi-frame messages without creating new message objects --- src/zeromq/gstzmqsrc.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/zeromq/gstzmqsrc.c b/src/zeromq/gstzmqsrc.c index cc55a49..9d490a3 100644 --- a/src/zeromq/gstzmqsrc.c +++ b/src/zeromq/gstzmqsrc.c @@ -230,17 +230,15 @@ gst_zmq_src_create (GstPushSrc * psrc, GstBuffer ** outbuf) gst_buffer_unmap (*outbuf, &map); - // Ignore later frames in multi-frame messages - if (zmq_msg_more(&msg)) { - while (1) { - zmq_msg_t trailing; - zmq_msg_init(&trailing); - zmq_msg_recv(&trailing, src->socket, 0); - zmq_msg_close(&trailing); - if (!zmq_msg_more(&trailing)) break; - } + // Ignore later frames in multi-part messages + while (zmq_msg_more (&msg)) { + zmq_msg_close (&msg); + zmq_msg_init (&msg); + zmq_msg_recv (&msg, src->socket, 0); } + zmq_msg_close (&msg); + GST_LOG_OBJECT (src, "delivered a buffer of size %" G_GSIZE_FORMAT " bytes", msg_size); done: