Skip to content

Commit

Permalink
Fix retry_frame corner case
Browse files Browse the repository at this point in the history
  • Loading branch information
DawidWesierski4 committed Jan 9, 2025
1 parent c0bce7c commit f45a055
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 16 deletions.
22 changes: 21 additions & 1 deletion 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 @@ -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;
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
6 changes: 6 additions & 0 deletions ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c
Original file line number Diff line number Diff line change
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
5 changes: 4 additions & 1 deletion 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 @@ -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;
Expand Down
39 changes: 25 additions & 14 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 Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit f45a055

Please sign in to comment.