Skip to content

Commit

Permalink
Fix: unify gstreamer arguments across plugins
Browse files Browse the repository at this point in the history
Using functions from gst_mtl_common to make all
arguments in gstreamer plugins cross compatible,
order the arguments in the header files.
  • Loading branch information
DawidWesierski4 committed Jan 9, 2025
1 parent 7190b73 commit c606cad
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 603 deletions.
4 changes: 2 additions & 2 deletions ecosystem/gstreamer_plugin/gst_mtl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ gboolean gst_mtl_common_parse_sampling(gint sampling, enum st30_sampling* st_sam
void gst_mtl_common_init_general_argumetns(GObjectClass* gobject_class) {
g_object_class_install_property(
gobject_class, PROP_GENERAL_LOG_LEVEL,
g_param_spec_boolean("silent", "Silent", "Turn on silent mode.", FALSE,
G_PARAM_READWRITE));
g_param_spec_int("log-level", "Log Level", "Set the log level.", 0, G_MAXUINT, 0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_GENERAL_DEV_ARGS_PORT,
Expand Down
6 changes: 6 additions & 0 deletions ecosystem/gstreamer_plugin/gst_mtl_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
#define PAYLOAD_TYPE_VIDEO (112)
#define PAYLOAD_TYPE_ANCILLARY (113)

#ifndef NS_PER_MS
#define NS_PER_MS (1000 * 1000)
#endif

#ifndef NS_PER_S
#define NS_PER_S (1000 * NS_PER_MS)
#endif

enum {
PROP_GENERAL_0,
Expand Down
226 changes: 44 additions & 182 deletions ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,12 @@ GST_DEBUG_CATEGORY_STATIC(gst_mtl_st20p_rx_debug);
#endif

enum {
PROP_0,
PROP_SILENT,
PROP_RX_DEV_ARGS_PORT,
PROP_RX_DEV_ARGS_SIP,
PROP_RX_DEV_ARGS_DMA_DEV,
PROP_RX_PORT_PORT,
PROP_RX_PORT_IP,
PROP_RX_PORT_UDP_PORT,
PROP_RX_PORT_PAYLOAD_TYPE,
PROP_RX_PORT_RX_QUEUES,
PROP_RX_FRAMERATE,
PROP_RX_FRAMEBUFF_NUM,
PROP_RX_WIDTH,
PROP_RX_HEIGHT,
PROP_RX_INTERLACED,
PROP_RX_PIXEL_FORMAT,
PROP_ST20P_RX_FRAMERATE = PROP_GENERAL_MAX,
PROP_ST20P_RX_FRAMEBUFF_NUM,
PROP_ST20P_RX_WIDTH,
PROP_ST20P_RX_HEIGHT,
PROP_ST20P_RX_INTERLACED,
PROP_ST20P_RX_PIXEL_FORMAT,
PROP_MAX
};

Expand Down Expand Up @@ -164,89 +154,37 @@ static void gst_mtl_st20p_rx_class_init(Gst_Mtl_St20p_RxClass* klass) {
gstbasesrc_class->negotiate = GST_DEBUG_FUNCPTR(gst_mtl_st20p_rx_negotiate);
gstbasesrc_class->create = GST_DEBUG_FUNCPTR(gst_mtl_st20p_rx_create);

g_object_class_install_property(
gobject_class, PROP_SILENT,
g_param_spec_boolean("silent", "Silent", "Turn on silent mode.", FALSE,
G_PARAM_READWRITE));

g_object_class_install_property(
gobject_class, PROP_RX_DEV_ARGS_PORT,
g_param_spec_string("dev-port", "DPDK device port",
"DPDK port for synchronous ST 2110-20 uncompressed"
"video transmission, bound to the VFIO DPDK driver. ",
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_RX_DEV_ARGS_SIP,
g_param_spec_string("dev-ip", "Local device IP",
"Local IP address that the port will be "
"identified by. This is the address from which ARP "
"responses will be sent.",
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_RX_DEV_ARGS_DMA_DEV,
g_param_spec_string("dma-dev", "DPDK DMA port",
"DPDK port for the MTL direct memory functionality.", NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_RX_PORT_PORT,
g_param_spec_string("rx-port", "Transmission Device Port",
"DPDK device port initialized for the transmission.", NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_RX_PORT_IP,
g_param_spec_string("rx-ip", "Sender node's IP", "Receiving MTL node IP address.",
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_RX_PORT_UDP_PORT,
g_param_spec_uint("rx-udp-port", "Sender UDP port", "Receiving MTL node UDP port.",
0, G_MAXUINT, 20000, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_RX_PORT_PAYLOAD_TYPE,
g_param_spec_uint("rx-payload-type", "ST 2110 payload type",
"SMPTE ST 2110 payload type.", 0, G_MAXUINT, 112,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_mtl_common_init_general_argumetns(gobject_class);

g_object_class_install_property(
gobject_class, PROP_RX_PORT_RX_QUEUES,
g_param_spec_uint("rx-queues", "Number of RX queues",
"Number of RX queues to initialize in DPDK backend.", 0,
G_MAXUINT, 16, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_RX_FRAMERATE,
gobject_class, PROP_ST20P_RX_FRAMERATE,
g_param_spec_uint("rx-fps", "Video framerate", "Framerate of the video.", 0,
G_MAXUINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_RX_FRAMEBUFF_NUM,
gobject_class, PROP_ST20P_RX_FRAMEBUFF_NUM,
g_param_spec_uint("rx-framebuff-num", "Number of framebuffers",
"Number of framebuffers to be used for transmission.", 0,
G_MAXUINT, 3, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_RX_WIDTH,
gobject_class, PROP_ST20P_RX_WIDTH,
g_param_spec_uint("rx-width", "Video width", "Width of the video.", 0, G_MAXUINT,
1920, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_RX_HEIGHT,
gobject_class, PROP_ST20P_RX_HEIGHT,
g_param_spec_uint("rx-height", "Video height", "Height of the video.", 0, G_MAXUINT,
1080, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_RX_INTERLACED,
gobject_class, PROP_ST20P_RX_INTERLACED,
g_param_spec_boolean("rx-interlaced", "Interlaced video",
"Whether the video is interlaced.", FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property(
gobject_class, PROP_RX_PIXEL_FORMAT,
gobject_class, PROP_ST20P_RX_PIXEL_FORMAT,
g_param_spec_string("rx-pixel-format", "Pixel format", "Pixel format of the video.",
"v210", G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
Expand All @@ -262,54 +200,21 @@ static gboolean gst_mtl_st20p_rx_start(GstBaseSrc* basesrc) {
GST_DEBUG_OBJECT(src, "start");
GST_DEBUG("Media Transport Initialization start");

/* mtl is already initialzied */
if (src->mtl_lib_handle) {
GST_INFO("Mtl already initialized");
if (mtl_start(src->mtl_lib_handle)) {
GST_ERROR("Failed to start MTL");
return FALSE;
}
return TRUE;
} else {
strncpy(mtl_init_params.port[MTL_PORT_P], src->devArgs.port, MTL_PORT_MAX_LEN);

ret = inet_pton(AF_INET, src->devArgs.local_ip_string,
mtl_init_params.sip_addr[MTL_PORT_P]);
if (ret != 1) {
GST_ERROR("%s, sip %s is not valid ip address\n", __func__,
src->devArgs.local_ip_string);
/* Check for future support of multiple plugins initialized from the same handle.
* TODO: Add support for initializing multiple pipelines from a single handle. */
if (!src->mtl_lib_handle) {
if (!gst_mtl_common_parse_dev_arguments(&mtl_init_params, &(src->devArgs))) {
GST_ERROR("Failed to parse dev arguments");
return FALSE;
}

if (src->devArgs.rx_queues_cnt[MTL_PORT_P]) {
mtl_init_params.rx_queues_cnt[MTL_PORT_P] = src->devArgs.rx_queues_cnt[MTL_PORT_P];
} else {
mtl_init_params.rx_queues_cnt[MTL_PORT_P] = 16;
mtl_init_params.tx_queues_cnt[MTL_PORT_P] = 16;
}

mtl_init_params.num_ports++;

mtl_init_params.flags |= MTL_FLAG_BIND_NUMA;
if (src->silent) {
mtl_init_params.log_level = MTL_LOG_LEVEL_ERROR;
if (src->log_level && src->log_level < MTL_LOG_LEVEL_MAX) {
mtl_init_params.log_level = src->log_level;
} else {
mtl_init_params.log_level = MTL_LOG_LEVEL_INFO;
}

src->retry_frame = 10;

mtl_init_params.flags |= MTL_FLAG_BIND_NUMA;

if (src->devArgs.dma_dev) {
strncpy(mtl_init_params.dma_dev_port[0], src->devArgs.dma_dev, MTL_PORT_MAX_LEN);
}

if (src->mtl_lib_handle) {
GST_ERROR("MTL already initialized");
return FALSE;
}

src->mtl_lib_handle = mtl_init(&mtl_init_params);
if (!src->mtl_lib_handle) {
GST_ERROR("Could not initialize MTL");
Expand Down Expand Up @@ -407,51 +312,29 @@ static void gst_mtl_st20p_rx_set_property(GObject* object, guint prop_id,
const GValue* value, GParamSpec* pspec) {
Gst_Mtl_St20p_Rx* self = GST_MTL_ST20P_RX(object);

if (prop_id < PROP_GENERAL_MAX) {
gst_mtl_common_set_general_argumetns(object, prop_id, value, pspec, &(self->devArgs),
&(self->portArgs), &self->log_level);
return;
}

switch (prop_id) {
case PROP_SILENT:
self->silent = g_value_get_boolean(value);
break;
case PROP_RX_DEV_ARGS_PORT:
strncpy(self->devArgs.port, g_value_get_string(value), MTL_PORT_MAX_LEN);
break;
case PROP_RX_DEV_ARGS_SIP:
strncpy(self->devArgs.local_ip_string, g_value_get_string(value), MTL_PORT_MAX_LEN);
break;
case PROP_RX_DEV_ARGS_DMA_DEV:
strncpy(self->devArgs.dma_dev, g_value_get_string(value), MTL_PORT_MAX_LEN);
break;
case PROP_RX_PORT_PORT:
strncpy(self->portArgs.port, g_value_get_string(value), MTL_PORT_MAX_LEN);
break;
case PROP_RX_PORT_IP:
strncpy(self->portArgs.session_ip_string, g_value_get_string(value),
MTL_PORT_MAX_LEN);
break;
case PROP_RX_PORT_UDP_PORT:
self->portArgs.udp_port = g_value_get_uint(value);
break;
case PROP_RX_PORT_PAYLOAD_TYPE:
self->portArgs.payload_type = g_value_get_uint(value);
break;
case PROP_RX_PORT_RX_QUEUES:
self->devArgs.rx_queues_cnt[MTL_PORT_P] = g_value_get_uint(value);
break;
case PROP_RX_FRAMERATE:
case PROP_ST20P_RX_FRAMERATE:
self->framerate = g_value_get_uint(value);
break;
case PROP_RX_FRAMEBUFF_NUM:
case PROP_ST20P_RX_FRAMEBUFF_NUM:
self->framebuffer_num = g_value_get_uint(value);
break;
case PROP_RX_WIDTH:
case PROP_ST20P_RX_WIDTH:
self->width = g_value_get_uint(value);
break;
case PROP_RX_HEIGHT:
case PROP_ST20P_RX_HEIGHT:
self->height = g_value_get_uint(value);
break;
case PROP_RX_INTERLACED:
case PROP_ST20P_RX_INTERLACED:
self->interlaced = g_value_get_boolean(value);
break;
case PROP_RX_PIXEL_FORMAT:
case PROP_ST20P_RX_PIXEL_FORMAT:
strncpy(self->pixel_format, g_value_get_string(value), MTL_PORT_MAX_LEN);
break;
default:
Expand All @@ -464,50 +347,29 @@ static void gst_mtl_st20p_rx_get_property(GObject* object, guint prop_id, GValue
GParamSpec* pspec) {
Gst_Mtl_St20p_Rx* src = GST_MTL_ST20P_RX(object);

if (prop_id < PROP_GENERAL_MAX) {
gst_mtl_common_get_general_argumetns(object, prop_id, value, pspec, &(src->devArgs),
&(src->portArgs), &src->log_level);
return;
}

switch (prop_id) {
case PROP_SILENT:
g_value_set_boolean(value, src->silent);
break;
case PROP_RX_DEV_ARGS_PORT:
g_value_set_string(value, src->devArgs.port);
break;
case PROP_RX_DEV_ARGS_SIP:
g_value_set_string(value, src->devArgs.local_ip_string);
break;
case PROP_RX_DEV_ARGS_DMA_DEV:
g_value_set_string(value, src->devArgs.dma_dev);
break;
case PROP_RX_PORT_PORT:
g_value_set_string(value, src->portArgs.port);
break;
case PROP_RX_PORT_IP:
g_value_set_string(value, src->portArgs.session_ip_string);
break;
case PROP_RX_PORT_UDP_PORT:
g_value_set_uint(value, src->portArgs.udp_port);
break;
case PROP_RX_PORT_PAYLOAD_TYPE:
g_value_set_uint(value, src->portArgs.payload_type);
break;
case PROP_RX_PORT_RX_QUEUES:
g_value_set_uint(value, src->devArgs.rx_queues_cnt[MTL_PORT_P]);
break;
case PROP_RX_FRAMERATE:
case PROP_ST20P_RX_FRAMERATE:
g_value_set_uint(value, src->framerate);
break;
case PROP_RX_FRAMEBUFF_NUM:
case PROP_ST20P_RX_FRAMEBUFF_NUM:
g_value_set_uint(value, src->framebuffer_num);
break;
case PROP_RX_WIDTH:
case PROP_ST20P_RX_WIDTH:
g_value_set_uint(value, src->width);
break;
case PROP_RX_HEIGHT:
case PROP_ST20P_RX_HEIGHT:
g_value_set_uint(value, src->height);
break;
case PROP_RX_INTERLACED:
case PROP_ST20P_RX_INTERLACED:
g_value_set_boolean(value, src->interlaced);
break;
case PROP_RX_PIXEL_FORMAT:
case PROP_ST20P_RX_PIXEL_FORMAT:
g_value_set_string(value, src->pixel_format);
break;
default:
Expand Down
12 changes: 4 additions & 8 deletions ecosystem/gstreamer_plugin/gst_mtl_st20p_rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,15 @@ struct _Gst_Mtl_St20p_Rx {
GstBuffer* buffer;

/*< private >*/
struct st20p_rx_ops ops_rx;
gboolean silent;
struct st20p_rx_ops ops_rx; /* needed for caps negotiation */
guint log_level;
mtl_handle mtl_lib_handle;
st20p_rx_handle rx_handle;

/* arguments for incomplete frame buffers */
guint retry_frame;
guint frame_size;

/* arguments for imtl initialization device */
StDevArgs devArgs;
/* arguments for imtl rx session */
SessionPortArgs portArgs;
StDevArgs devArgs; /* imtl initialization device */
SessionPortArgs portArgs; /* imtl session device */

/* arguments for session */
guint width;
Expand Down
Loading

0 comments on commit c606cad

Please sign in to comment.