mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 06:46:38 +00:00
element: Fix requesting of pads with string templates
Previously it was only possible to request them with the exact template name, e.g. 'src_%s', but not with "instantiated" names that would match this template, e.g.'src_foo_bar'. This is now possible and a test was added for this, in addition to fixing a previously invalid test. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2635>
This commit is contained in:
parent
a040450685
commit
a3cbaa8209
2 changed files with 36 additions and 30 deletions
|
@ -1052,7 +1052,7 @@ gst_element_is_valid_request_template_name (const gchar * templ_name,
|
|||
/* %s is not allowed for multiple specifiers, just a single specifier can be
|
||||
* accepted in gst_pad_template_new() and can not be mixed with other
|
||||
* specifier '%u' and '%d' */
|
||||
if (*(templ_name_ptr + 1) == 's' && g_strcmp0 (templ_name, name) == 0) {
|
||||
if (*(templ_name_ptr + 1) == 's') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -654,7 +654,6 @@ GST_START_TEST (test_request_pad_templates)
|
|||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
const gchar *pad_name, *templ_name;
|
||||
GSList *padname_blacklists = NULL, *item;
|
||||
GError *err = NULL;
|
||||
|
||||
padnames = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
@ -703,23 +702,7 @@ GST_START_TEST (test_request_pad_templates)
|
|||
g_hash_table_insert (padnames, (gpointer) "src_%s", (gpointer) "src_%s");
|
||||
g_hash_table_insert (padnames, (gpointer) "src_%u_%s",
|
||||
(gpointer) "src_%u_%s");
|
||||
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%u%u");
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%u_%d");
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%u_%u_");
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%u_%s_%s");
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%s_%u");
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%s_%s");
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%s_%s_%s");
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%s_blah");
|
||||
g_hash_table_insert (padnames, (gpointer) "src_foo_bar", (gpointer) "src_%s");
|
||||
|
||||
test = g_object_new (gst_test_element3_get_type (), NULL);
|
||||
|
||||
|
@ -742,16 +725,6 @@ GST_START_TEST (test_request_pad_templates)
|
|||
gst_object_unref (pad);
|
||||
}
|
||||
|
||||
item = padname_blacklists;
|
||||
|
||||
/* check invalid request pad name */
|
||||
while (item) {
|
||||
pad_name = (const gchar *) (item->data);
|
||||
item = g_slist_next (item);
|
||||
pad = gst_element_request_pad_simple (GST_ELEMENT (test), pad_name);
|
||||
fail_unless (pad == NULL);
|
||||
}
|
||||
|
||||
/* check it working with some APIs
|
||||
* gst_element_link/link_pads */
|
||||
sink = gst_element_factory_make ("fakesink", "sink");
|
||||
|
@ -782,13 +755,45 @@ GST_START_TEST (test_request_pad_templates)
|
|||
if (err) {
|
||||
g_error_free (err);
|
||||
}
|
||||
g_slist_free (padname_blacklists);
|
||||
g_hash_table_unref (padnames);
|
||||
gst_object_unref (pipeline);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_forbidden_pad_template_names)
|
||||
{
|
||||
const gchar *pad_name;
|
||||
GSList *padname_blacklists = NULL, *item;
|
||||
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%u%u");
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%u_%s_%s");
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%s_%u");
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%s_%s");
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%s_%s_%s");
|
||||
padname_blacklists =
|
||||
g_slist_append (padname_blacklists, (gpointer) "src_%s_blah");
|
||||
|
||||
item = padname_blacklists;
|
||||
|
||||
/* check invalid request pad name */
|
||||
while (item) {
|
||||
pad_name = (const gchar *) (item->data);
|
||||
item = g_slist_next (item);
|
||||
ASSERT_WARNING (gst_pad_template_new (pad_name, GST_PAD_SRC,
|
||||
GST_PAD_REQUEST, GST_CAPS_ANY));
|
||||
}
|
||||
|
||||
g_slist_free (padname_blacklists);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static gboolean run_foreach_thread;
|
||||
|
||||
/* thread function that just adds/removes pads while main thread iterates pads */
|
||||
|
@ -922,6 +927,7 @@ gst_element_suite (void)
|
|||
tcase_add_test (tc_chain, test_pad_templates);
|
||||
tcase_add_test (tc_chain, test_property_notify_message);
|
||||
tcase_add_test (tc_chain, test_request_pad_templates);
|
||||
tcase_add_test (tc_chain, test_forbidden_pad_template_names);
|
||||
tcase_add_test (tc_chain, test_foreach_pad);
|
||||
|
||||
return s;
|
||||
|
|
Loading…
Reference in a new issue