1 | /* GStreamer |
---|
2 | * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> |
---|
3 | * |
---|
4 | * This library is free software; you can redistribute it and/or |
---|
5 | * modify it under the terms of the GNU Library General Public |
---|
6 | * License as published by the Free Software Foundation; either |
---|
7 | * version 2 of the License, or (at your option) any later version. |
---|
8 | * |
---|
9 | * This library is distributed in the hope that it will be useful, |
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
12 | * Library General Public License for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU Library General Public |
---|
15 | * License along with this library; if not, write to the |
---|
16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
17 | * Boston, MA 02111-1307, USA. |
---|
18 | */ |
---|
19 | |
---|
20 | #include <gst/gst.h> |
---|
21 | |
---|
22 | /* tests if gst_bin_get_(all_)by_interface works */ |
---|
23 | |
---|
24 | gint |
---|
25 | main (gint argc, gchar * argv[]) |
---|
26 | { |
---|
27 | GstBin *bin, *bin2; |
---|
28 | GList *list; |
---|
29 | GstElement *filesrc; |
---|
30 | |
---|
31 | gst_init (&argc, &argv); |
---|
32 | |
---|
33 | bin = GST_BIN (gst_bin_new (NULL)); |
---|
34 | g_assert (bin); |
---|
35 | |
---|
36 | filesrc = gst_element_factory_make ("filesrc", NULL); |
---|
37 | g_assert (filesrc); |
---|
38 | g_assert (GST_IS_URI_HANDLER (filesrc)); |
---|
39 | gst_bin_add (bin, filesrc); |
---|
40 | |
---|
41 | g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc); |
---|
42 | list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER); |
---|
43 | g_assert (g_list_length (list) == 1); |
---|
44 | g_assert (list->data == (gpointer) filesrc); |
---|
45 | g_list_free (list); |
---|
46 | |
---|
47 | gst_bin_add_many (bin, |
---|
48 | gst_element_factory_make ("identity", NULL), |
---|
49 | gst_element_factory_make ("identity", NULL), |
---|
50 | gst_element_factory_make ("identity", NULL), NULL); |
---|
51 | g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc); |
---|
52 | list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER); |
---|
53 | g_assert (g_list_length (list) == 1); |
---|
54 | g_assert (list->data == (gpointer) filesrc); |
---|
55 | g_list_free (list); |
---|
56 | |
---|
57 | bin2 = bin; |
---|
58 | bin = GST_BIN (gst_bin_new (NULL)); |
---|
59 | g_assert (bin); |
---|
60 | gst_bin_add_many (bin, |
---|
61 | gst_element_factory_make ("identity", NULL), |
---|
62 | gst_element_factory_make ("identity", NULL), |
---|
63 | GST_ELEMENT (bin2), gst_element_factory_make ("identity", NULL), NULL); |
---|
64 | g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc); |
---|
65 | list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER); |
---|
66 | g_assert (g_list_length (list) == 1); |
---|
67 | g_assert (list->data == (gpointer) filesrc); |
---|
68 | g_list_free (list); |
---|
69 | |
---|
70 | gst_bin_add (bin, gst_element_factory_make ("filesrc", NULL)); |
---|
71 | gst_bin_add (bin2, gst_element_factory_make ("filesrc", NULL)); |
---|
72 | list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER); |
---|
73 | g_assert (g_list_length (list) == 3); |
---|
74 | g_list_free (list); |
---|
75 | |
---|
76 | g_object_unref (bin); |
---|
77 | return 0; |
---|
78 | } |
---|