From f45a05596a5dec39adf54cfc8bf288fd2cb86ade Mon Sep 17 00:00:00 2001 From: dawidwesierski4 Date: Thu, 9 Jan 2025 16:56:00 +0100 Subject: [PATCH] Fix retry_frame corner case --- ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c | 22 ++++++++++- ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c | 6 +++ ecosystem/gstreamer_plugin/gst_mtl_st30p_rx.c | 5 ++- ecosystem/gstreamer_plugin/gst_mtl_st30p_tx.c | 39 ++++++++++++------- 4 files changed, 56 insertions(+), 16 deletions(-) diff --git a/ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c b/ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c index e70e26e3b..2f16e29bd 100644 --- a/ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c +++ b/ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c @@ -90,7 +90,8 @@ GST_DEBUG_CATEGORY_STATIC(gst_mtl_st20p_rx_debug); #endif enum { - PROP_ST20P_RX_FRAMERATE = PROP_GENERAL_MAX, + PROP_ST20P_RX_RETRY = PROP_GENERAL_MAX, + PROP_ST20P_RX_FRAMERATE, PROP_ST20P_RX_FRAMEBUFF_NUM, PROP_ST20P_RX_WIDTH, PROP_ST20P_RX_HEIGHT, @@ -156,6 +157,12 @@ static void gst_mtl_st20p_rx_class_init(Gst_Mtl_St20p_RxClass* klass) { gst_mtl_common_init_general_argumetns(gobject_class); + g_object_class_install_property( + gobject_class, PROP_ST20P_RX_RETRY, + g_param_spec_uint("retry", "Retry Count", + "Number of times the MTL will try to get a frame.", 0, G_MAXUINT, + 10, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property( gobject_class, PROP_ST20P_RX_FRAMERATE, g_param_spec_uint("rx-fps", "Video framerate", "Framerate of the video.", 0, @@ -208,6 +215,13 @@ static gboolean gst_mtl_st20p_rx_start(GstBaseSrc* basesrc) { return FALSE; } + if (src->retry_frame == 0) + src->retry_frame = 10; + else if (src->retry_frame < 3) { + GST_WARNING("Retry count is too low, setting to 3"); + src->retry_frame = 3; + } + if (src->width == 0 || src->height == 0) { GST_ERROR("Invalid resolution: %dx%d", src->width, src->height); return FALSE; @@ -305,6 +319,9 @@ static void gst_mtl_st20p_rx_set_property(GObject* object, guint prop_id, } switch (prop_id) { + case PROP_ST20P_RX_RETRY: + self->retry_frame = g_value_get_uint(value); + break; case PROP_ST20P_RX_FRAMERATE: self->framerate = g_value_get_uint(value); break; @@ -340,6 +357,9 @@ static void gst_mtl_st20p_rx_get_property(GObject* object, guint prop_id, GValue } switch (prop_id) { + case PROP_ST20P_RX_RETRY: + g_value_set_uint(value, src->retry_frame); + break; case PROP_ST20P_RX_FRAMERATE: g_value_set_uint(value, src->framerate); break; diff --git a/ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c b/ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c index 63f3b38b0..3a525b949 100644 --- a/ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c +++ b/ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c @@ -224,6 +224,9 @@ static void gst_mtl_st20p_tx_set_property(GObject* object, guint prop_id, } switch (prop_id) { + case PROP_ST20P_TX_RETRY: + self->retry_frame = g_value_get_uint(value); + break; case PROP_ST20P_TX_FRAMERATE: self->framerate = g_value_get_uint(value); break; @@ -247,6 +250,9 @@ static void gst_mtl_st20p_tx_get_property(GObject* object, guint prop_id, GValue } switch (prop_id) { + case PROP_ST20P_TX_RETRY: + g_value_set_uint(value, sink->retry_frame); + break; case PROP_ST20P_TX_FRAMERATE: g_value_set_uint(value, sink->framerate); break; diff --git a/ecosystem/gstreamer_plugin/gst_mtl_st30p_rx.c b/ecosystem/gstreamer_plugin/gst_mtl_st30p_rx.c index c2168e09f..69f195ba5 100644 --- a/ecosystem/gstreamer_plugin/gst_mtl_st30p_rx.c +++ b/ecosystem/gstreamer_plugin/gst_mtl_st30p_rx.c @@ -90,7 +90,8 @@ GST_DEBUG_CATEGORY_STATIC(gst_mtl_st30p_rx_debug); #endif enum { - PROP_ST30P_RX_FRAMERATE = PROP_GENERAL_MAX, + PROP_ST30P_RX_RETRY = PROP_GENERAL_MAX, + PROP_ST30P_RX_FRAMERATE, PROP_ST30P_RX_FRAMEBUFF_NUM, PROP_ST30P_RX_CHANNEL, PROP_ST30P_RX_SAMPLING, @@ -200,6 +201,8 @@ static gboolean gst_mtl_st30p_rx_start(GstBaseSrc* basesrc) { return FALSE; } + src->retry_frame = 10; /* TODO add support for parameter */ + ops_rx->name = "st30src"; ops_rx->channel = src->channel; ops_rx->port.num_port = 1; diff --git a/ecosystem/gstreamer_plugin/gst_mtl_st30p_tx.c b/ecosystem/gstreamer_plugin/gst_mtl_st30p_tx.c index 033a14028..16ac5f3af 100644 --- a/ecosystem/gstreamer_plugin/gst_mtl_st30p_tx.c +++ b/ecosystem/gstreamer_plugin/gst_mtl_st30p_tx.c @@ -90,7 +90,12 @@ GST_DEBUG_CATEGORY_STATIC(gst_mtl_st30p_tx_debug); #define PACKAGE_VERSION "1.0" #endif -enum { PROP_TX_FRAMERATE = PROP_GENERAL_MAX, PROP_TX_FRAMEBUFF_NUM, PROP_MAX }; +enum { + PROP_ST30P_TX_RETRY = PROP_GENERAL_MAX, + PROP_ST30P_TX_FRAMERATE, + PROP_ST30P_TX_FRAMEBUFF_NUM, + PROP_MAX +}; /* pad template */ static GstStaticPadTemplate gst_mtl_st30p_tx_sink_pad_template = @@ -169,7 +174,7 @@ static void gst_mtl_st30p_tx_class_init(Gst_Mtl_St30p_TxClass* klass) { gst_mtl_common_init_general_argumetns(gobject_class); g_object_class_install_property( - gobject_class, PROP_TX_FRAMEBUFF_NUM, + gobject_class, PROP_ST30P_TX_FRAMEBUFF_NUM, g_param_spec_uint("tx-framebuff-num", "Number of framebuffers", "Number of framebuffers to be used for transmission.", 0, G_MAXUINT, 3, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); @@ -224,12 +229,15 @@ static void gst_mtl_st30p_tx_set_property(GObject* object, guint prop_id, } switch (prop_id) { - case PROP_TX_FRAMERATE: - self->framerate = g_value_get_uint(value); - break; - case PROP_TX_FRAMEBUFF_NUM: - self->framebuffer_num = g_value_get_uint(value); - break; + case PROP_ST30P_TX_RETRY: + self->retry_frame = g_value_get_uint(value); + break; + case PROP_ST30P_TX_FRAMERATE: + self->framerate = g_value_get_uint(value); + break; + case PROP_ST30P_TX_FRAMEBUFF_NUM: + self->framebuffer_num = g_value_get_uint(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -247,12 +255,15 @@ static void gst_mtl_st30p_tx_get_property(GObject* object, guint prop_id, GValue } switch (prop_id) { - case PROP_TX_FRAMERATE: - g_value_set_uint(value, sink->framerate); - break; - case PROP_TX_FRAMEBUFF_NUM: - g_value_set_uint(value, sink->framebuffer_num); - break; + case PROP_ST30P_TX_RETRY: + g_value_set_uint(value, sink->retry_frame); + break; + case PROP_ST30P_TX_FRAMERATE: + g_value_set_uint(value, sink->framerate); + break; + case PROP_ST30P_TX_FRAMEBUFF_NUM: + g_value_set_uint(value, sink->framebuffer_num); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break;