Skip to content

Commit

Permalink
Fix retry_frame corner case
Browse files Browse the repository at this point in the history
rename the mtl init mtl to init handle
  • Loading branch information
DawidWesierski4 committed Jan 9, 2025
1 parent c0bce7c commit be79404
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ecosystem/gstreamer_plugin/gst_mtl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion ecosystem/gstreamer_plugin/gst_mtl_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */
24 changes: 22 additions & 2 deletions ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions ecosystem/gstreamer_plugin/gst_mtl_st30p_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
25 changes: 18 additions & 7 deletions ecosystem/gstreamer_plugin/gst_mtl_st30p_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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));
Expand All @@ -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");
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ecosystem/gstreamer_plugin/gst_mtl_st40_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit be79404

Please sign in to comment.