typedef struct _ini_item_media_source_s {
const char *source_element;
+ gchar **source_element_properties;
/* video source pipeline */
const char *v_raw_format;
int v_width;
int _gst_build_pipeline(webrtc_s *webrtc);
void _gst_destroy_pipeline(webrtc_s *webrtc);
int _gst_pipeline_set_state(webrtc_s *webrtc, GstState state);
+void _gst_set_element_properties(GstElement *element, gchar **key_value_pairs);
int _add_media_source(webrtc_s *webrtc, int type, unsigned int *source_id);
int _add_media_source_internal(webrtc_s *webrtc, int type, unsigned int *source_id);
int _remove_media_source(webrtc_s *webrtc, unsigned int source_id);
/* items for media source */
#define INI_ITEM_SOURCE_ELEMENT "source element"
+#define INI_ITEM_SOURCE_ELEMENT_PROPERTIES "source element properties"
#define INI_ITEM_VIDEO_RAW_FORMAT "video raw format"
#define INI_ITEM_VIDEO_WIDTH "video width"
#define INI_ITEM_VIDEO_HEIGHT "video height"
RET_IF(source == NULL, "source is NULL");
__dump_item(INI_ITEM_SOURCE_ELEMENT, INI_ITEM_TYPE_STRING, (void *)source->source_element);
+ __dump_item(INI_ITEM_SOURCE_ELEMENT_PROPERTIES, INI_ITEM_TYPE_STRINGS, (void *)source->source_element_properties);
__dump_item(INI_ITEM_VIDEO_RAW_FORMAT, INI_ITEM_TYPE_STRING, (void *)source->v_raw_format);
__dump_item(INI_ITEM_VIDEO_WIDTH, INI_ITEM_TYPE_INT, &source->v_width);
__dump_item(INI_ITEM_VIDEO_HEIGHT, INI_ITEM_TYPE_INT, &source->v_height);
RET_IF(source == NULL, "source is NULL");
+ if (source->source_element_properties) {
+ g_strfreev(source->source_element_properties);
+ source->source_element_properties = NULL;
+ }
+
g_free(source);
}
if (g_strcmp0(category, INI_CATEGORY_MEDIA_SOURCE) == 0)
is_default = true;
- if (!is_default)
+ if (!is_default) {
source->source_element = __ini_get_string(ini->dict, category, INI_ITEM_SOURCE_ELEMENT, NULL);
+ __ini_read_list(ini->dict, category, INI_ITEM_SOURCE_ELEMENT_PROPERTIES, &source->source_element_properties);
+ }
source->v_raw_format = __ini_get_string(ini->dict, category, INI_ITEM_VIDEO_RAW_FORMAT,
is_default ? DEFAULT_VIDEO_RAW_FORMAT : ini->media_source.v_raw_format);
return WEBRTC_ERROR_NONE;
}
+static void __parse_type_and_set_value(GType type, GstElement *element, gchar **key_value_pair)
+{
+ RET_IF(element == NULL, "element is NULL");
+ RET_IF(key_value_pair == NULL, "key_value_pairs is NULL");
+ RET_IF(key_value_pair[0] == NULL, "key is NULL");
+ RET_IF(key_value_pair[1] == NULL, "value is NULL");
+
+ switch (type) {
+ case G_TYPE_STRING:
+ g_object_set(G_OBJECT(element), key_value_pair[0], key_value_pair[1], NULL);
+ break;
+ case G_TYPE_INT:
+ case G_TYPE_INT64:
+ case G_TYPE_ENUM: {
+ gint64 value = g_ascii_strtoll((const gchar *)key_value_pair[1], NULL, 10);
+ g_object_set(G_OBJECT(element), key_value_pair[0], value, NULL);
+ break;
+ }
+ case G_TYPE_UINT:
+ case G_TYPE_UINT64:
+ case G_TYPE_BOOLEAN: {
+ guint64 value = g_ascii_strtoll((const gchar *)key_value_pair[1], NULL, 10);
+ g_object_set(G_OBJECT(element), key_value_pair[0], value, NULL);
+ break;
+ }
+ case G_TYPE_FLOAT:
+ case G_TYPE_DOUBLE: {
+ gdouble value = g_ascii_strtod((const gchar *)key_value_pair[1], NULL);
+ g_object_set(G_OBJECT(element), key_value_pair[0], value, NULL);
+ break;
+ }
+ default:
+ LOG_DEBUG("not supported type(0x%x) exactly, but try it with int64 type", (unsigned int)type); /* e.g.) custom enum type falls through here */
+ gint64 value = g_ascii_strtoll((const gchar *)key_value_pair[1], NULL, 10);
+ g_object_set(G_OBJECT(element), key_value_pair[0], value, NULL);
+ break;
+ }
+
+ LOG_DEBUG("element[%s] property[%s] value[type:0x%x, %s]", GST_ELEMENT_NAME(element), key_value_pair[0], (unsigned int)type, key_value_pair[1]);
+}
+
+void _gst_set_element_properties(GstElement *element, gchar **key_value_pairs)
+{
+ gchar **key_value_pair;
+ GParamSpec *param_spec;
+
+ RET_IF(element == NULL, "element is NULL");
+
+ if (!key_value_pairs)
+ return;
+
+ while (key_value_pairs && *key_value_pairs) {
+ key_value_pair = g_strsplit(*key_value_pairs++, "=", 2);
+
+ if (!g_strcmp0(key_value_pair[0], "") || !g_strcmp0(key_value_pair[1], "")) {
+ LOG_ERROR("invalid key_value_pair, key[%s], value[%s]", key_value_pair[0], key_value_pair[1]);
+ g_strfreev(key_value_pair);
+ continue;
+ }
+
+ if (!(param_spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(element)), g_strstrip(key_value_pair[0])))) {
+ LOG_ERROR("element[%s] does not have this property[%s]", GST_ELEMENT_NAME(element), key_value_pair[0]);
+ g_strfreev(key_value_pair);
+ continue;
+ }
+
+ __parse_type_and_set_value(param_spec->value_type, element, key_value_pair);
+
+ g_strfreev(key_value_pair);
+ }
+}
+
static gboolean __check_id_equal_cb(gpointer key, gpointer value, gpointer user_data)
{
webrtc_gst_slot_s *slot = value;