/** * gst_query_type_register: * @nick: The nick of the new query * @description: The description of the new query * * Create a new GstQueryType based on the nick or return an * already registered query with that nick * * Returns: A new GstQueryType or an already registered query * with the same nick. */ GstQueryType gst_query_type_register (const gchar * nick, const gchar * description) { GstQueryTypeDefinition *query; GstQueryType lookup; g_return_val_if_fail (nick != NULL, 0); g_return_val_if_fail (description != NULL, 0); lookup = gst_query_type_get_by_nick (nick); if (lookup != GST_QUERY_NONE) return lookup; query = g_new0 (GstQueryTypeDefinition, 1); query->value = _n_values; query->nick = g_strdup (nick); query->description = g_strdup (description); query->quark = g_quark_from_static_string (query->nick); g_static_mutex_lock (&mutex); g_hash_table_insert (_nick_to_query, query->nick, query); g_hash_table_insert (_query_type_to_nick, GINT_TO_POINTER (query->value), query); _gst_queries = g_list_append (_gst_queries, query); _n_values++; g_static_mutex_unlock (&mutex); return query->value; }
/* * Class method: find(nick) * nick: the nick of an existing query type. * * Returns: a reference to the Gst::QueryType object registered with the * given nick, or nil if this query was not registered. */ static VALUE rb_gst_querytype_find (VALUE self, VALUE nick) { GstQueryType type = gst_query_type_get_by_nick (RVAL2CSTR (nick)); return type != GST_QUERY_NONE ? RGST_QUERY_TYPE_NEW (&type) : Qnil; }