Skip to content

Commit a02c0a3

Browse files
Fix: unify gstreamer arguments across plugins (#1034)
Using functions from gst_mtl_common to make all arguments in gstreamer plugins cross compatible, order the arguments in the header files.
1 parent be8d5dc commit a02c0a3

13 files changed

+248
-826
lines changed

ecosystem/gstreamer_plugin/gst_mtl_common.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ gboolean gst_mtl_common_parse_sampling(gint sampling, enum st30_sampling* st_sam
209209
void gst_mtl_common_init_general_argumetns(GObjectClass* gobject_class) {
210210
g_object_class_install_property(
211211
gobject_class, PROP_GENERAL_LOG_LEVEL,
212-
g_param_spec_boolean("silent", "Silent", "Turn on silent mode.", FALSE,
213-
G_PARAM_READWRITE));
212+
g_param_spec_uint("log-level", "Log Level", "Set the log level (INFO 1 to CRIT 5).",
213+
1, MTL_LOG_LEVEL_MAX, 1,
214+
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
214215

215216
g_object_class_install_property(
216217
gobject_class, PROP_GENERAL_DEV_ARGS_PORT,
@@ -391,3 +392,35 @@ gboolean gst_mtl_common_parse_dev_arguments(struct mtl_init_params* mtl_init_par
391392
gst_mtl_port_idx++;
392393
return ret;
393394
}
395+
396+
mtl_handle gst_mtl_common_init_handle(struct mtl_init_params* p, StDevArgs* devArgs,
397+
guint* log_level) {
398+
struct mtl_init_params mtl_init_params = {0};
399+
400+
if (!p || !devArgs || !log_level) {
401+
GST_ERROR("Invalid input");
402+
return NULL;
403+
}
404+
405+
mtl_init_params.num_ports = 0;
406+
407+
if (gst_mtl_common_parse_dev_arguments(&mtl_init_params, devArgs) == FALSE) {
408+
GST_ERROR("Failed to parse dev arguments");
409+
return NULL;
410+
}
411+
mtl_init_params.flags |= MTL_FLAG_BIND_NUMA;
412+
413+
/*
414+
* Log levels range from 1 to LOG_LEVEL_MAX.
415+
* We avoid using 0 (DEBUG) in normal scenarios,
416+
* so it's acceptable to use 0 as a placeholder.
417+
*/
418+
if (*log_level && *log_level < MTL_LOG_LEVEL_MAX) {
419+
mtl_init_params.log_level = *log_level;
420+
} else {
421+
mtl_init_params.log_level = MTL_LOG_LEVEL_INFO;
422+
}
423+
*log_level = mtl_init_params.log_level;
424+
425+
return mtl_init(&mtl_init_params);
426+
}

ecosystem/gstreamer_plugin/gst_mtl_common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@
1919
#define PAYLOAD_TYPE_VIDEO (112)
2020
#define PAYLOAD_TYPE_ANCILLARY (113)
2121

22+
#ifndef NS_PER_MS
2223
#define NS_PER_MS (1000 * 1000)
24+
#endif
25+
26+
#ifndef NS_PER_S
27+
#define NS_PER_S (1000 * NS_PER_MS)
28+
#endif
2329

2430
enum {
2531
PROP_GENERAL_0,
@@ -95,4 +101,7 @@ void gst_mtl_common_get_general_argumetns(GObject* object, guint prop_id,
95101
StDevArgs* devArgs, SessionPortArgs* portArgs,
96102
guint* log_level);
97103

104+
mtl_handle gst_mtl_common_init_handle(struct mtl_init_params* p, StDevArgs* devArgs,
105+
guint* log_level);
106+
98107
#endif /* __GST_MTL_COMMON_H__ */

0 commit comments

Comments
 (0)