From be79404266b9e7809d2640c09c9cc5df16a5efca 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 rename the mtl init mtl to init handle --- ecosystem/gstreamer_plugin/gst_mtl_common.c | 2 +- ecosystem/gstreamer_plugin/gst_mtl_common.h | 2 +- ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c | 24 ++++++++++++++++-- ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c | 8 +++++- ecosystem/gstreamer_plugin/gst_mtl_st30p_rx.c | 7 ++++-- ecosystem/gstreamer_plugin/gst_mtl_st30p_tx.c | 25 +++++++++++++------ ecosystem/gstreamer_plugin/gst_mtl_st40_rx.c | 2 +- 7 files changed, 55 insertions(+), 15 deletions(-) diff --git a/ecosystem/gstreamer_plugin/gst_mtl_common.c b/ecosystem/gstreamer_plugin/gst_mtl_common.c index 1dec4ceb8..bd8c7d1c8 100644 --- a/ecosystem/gstreamer_plugin/gst_mtl_common.c +++ b/ecosystem/gstreamer_plugin/gst_mtl_common.c @@ -393,7 +393,7 @@ gboolean gst_mtl_common_parse_dev_arguments(struct mtl_init_params* mtl_init_par return ret; } -mtl_handle gst_mtl_common_mtl_init(struct mtl_init_params* p, StDevArgs* devArgs, +mtl_handle gst_mtl_common_init_handle(struct mtl_init_params* p, StDevArgs* devArgs, guint* log_level) { struct mtl_init_params mtl_init_params = {0}; diff --git a/ecosystem/gstreamer_plugin/gst_mtl_common.h b/ecosystem/gstreamer_plugin/gst_mtl_common.h index ec70984a7..b86b2769f 100644 --- a/ecosystem/gstreamer_plugin/gst_mtl_common.h +++ b/ecosystem/gstreamer_plugin/gst_mtl_common.h @@ -101,7 +101,7 @@ void gst_mtl_common_get_general_argumetns(GObject* object, guint prop_id, StDevArgs* devArgs, SessionPortArgs* portArgs, guint* log_level); -mtl_handle gst_mtl_common_mtl_init(struct mtl_init_params* p, StDevArgs* devArgs, +mtl_handle gst_mtl_common_init_handle(struct mtl_init_params* p, StDevArgs* devArgs, guint* log_level); #endif /* __GST_MTL_COMMON_H__ */ \ No newline at end of file diff --git a/ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c b/ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c index e70e26e3b..a1e57f493 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, @@ -201,13 +208,20 @@ static gboolean gst_mtl_st20p_rx_start(GstBaseSrc* basesrc) { GST_DEBUG("Media Transport Initialization start"); src->mtl_lib_handle = - gst_mtl_common_mtl_init(&mtl_init_params, &(src->devArgs), &(src->log_level)); + gst_mtl_common_init_handle(&mtl_init_params, &(src->devArgs), &(src->log_level)); if (!src->mtl_lib_handle) { GST_ERROR("Could not initialize MTL"); 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..b9c9c5ff7 100644 --- a/ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c +++ b/ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c @@ -179,7 +179,7 @@ static gboolean gst_mtl_st20p_tx_start(GstBaseSink* bsink) { gst_base_sink_set_async_enabled(bsink, FALSE); sink->mtl_lib_handle = - gst_mtl_common_mtl_init(&mtl_init_params, &(sink->devArgs), &(sink->log_level)); + gst_mtl_common_init_handle(&mtl_init_params, &(sink->devArgs), &(sink->log_level)); if (!sink->mtl_lib_handle) { GST_ERROR("Could not initialize MTL"); @@ -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..716976339 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, @@ -193,13 +194,15 @@ static gboolean gst_mtl_st30p_rx_start(GstBaseSrc* basesrc) { GST_DEBUG("Media Transport Initialization start"); src->mtl_lib_handle = - gst_mtl_common_mtl_init(&mtl_init_params, &(src->devArgs), &(src->log_level)); + gst_mtl_common_init_handle(&mtl_init_params, &(src->devArgs), &(src->log_level)); if (!src->mtl_lib_handle) { GST_ERROR("Could not initialize MTL"); 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..01eb4e672 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)); @@ -185,7 +190,7 @@ static gboolean gst_mtl_st30p_tx_start(GstBaseSink* bsink) { gst_base_sink_set_async_enabled(bsink, FALSE); sink->mtl_lib_handle = - gst_mtl_common_mtl_init(&mtl_init_params, &(sink->devArgs), &(sink->log_level)); + gst_mtl_common_init_handle(&mtl_init_params, &(sink->devArgs), &(sink->log_level)); if (!sink->mtl_lib_handle) { GST_ERROR("Could not initialize MTL"); @@ -224,10 +229,13 @@ static void gst_mtl_st30p_tx_set_property(GObject* object, guint prop_id, } switch (prop_id) { - case PROP_TX_FRAMERATE: + 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_TX_FRAMEBUFF_NUM: + case PROP_ST30P_TX_FRAMEBUFF_NUM: self->framebuffer_num = g_value_get_uint(value); break; default: @@ -247,10 +255,13 @@ static void gst_mtl_st30p_tx_get_property(GObject* object, guint prop_id, GValue } switch (prop_id) { - case PROP_TX_FRAMERATE: + 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_TX_FRAMEBUFF_NUM: + case PROP_ST30P_TX_FRAMEBUFF_NUM: g_value_set_uint(value, sink->framebuffer_num); break; default: diff --git a/ecosystem/gstreamer_plugin/gst_mtl_st40_rx.c b/ecosystem/gstreamer_plugin/gst_mtl_st40_rx.c index 0c75aa320..02e2e42cf 100644 --- a/ecosystem/gstreamer_plugin/gst_mtl_st40_rx.c +++ b/ecosystem/gstreamer_plugin/gst_mtl_st40_rx.c @@ -192,7 +192,7 @@ static gboolean gst_mtl_st40_rx_start(GstBaseSrc* basesrc) { GST_DEBUG("Media Transport Initialization start"); src->mtl_lib_handle = - gst_mtl_common_mtl_init(&mtl_init_params, &(src->devArgs), &(src->log_level)); + gst_mtl_common_init_handle(&mtl_init_params, &(src->devArgs), &(src->log_level)); if (!src->mtl_lib_handle) { GST_ERROR("Could not initialize MTL");