remove submodule created by mistake. This should be created as a normal folder
[platform/upstream/gst-devtools.git] / validate / testsuites / validateelements.py
1
2
3 # -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
4 #
5 # Copyright (c) 2015,Thibault Saunier <thibault.saunier@collabora.com>
6 #               2015,Vineeth T M <vineeth.tm@samsung.com>
7 #
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 # Lesser General Public License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this program; if not, write to the
20 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 # Boston, MA 02110-1301, USA.
22
23 """
24 The GstValidate default testsuite
25 """
26
27 from gi.repository import Gst
28 from gi.repository import GObject
29
30 TEST_MANAGER = "validate"
31
32
33 def pspec_is_numeric(prop):
34     return prop.value_type in [GObject.TYPE_INT, GObject.TYPE_INT64,
35                                GObject.TYPE_UINT, GObject.TYPE_UINT64,
36                                GObject.TYPE_LONG, GObject.TYPE_ULONG,
37                                GObject.TYPE_DOUBLE]
38
39
40 def get_pipe_and_populate(test_manager, klass, fname, prop, loop):
41     prop_value = Gst.ElementFactory.make(fname, None).get_property(prop.name)
42
43     if prop.value_type == GObject.TYPE_BOOLEAN:
44         if loop is 1:
45             bool_value = False
46         else:
47             bool_value = True
48         cname = fname + " %s=%s" % (prop.name, bool_value)
49         tname = fname + "%s=%s" % (prop.name, bool_value)
50     elif pspec_is_numeric(prop):
51         if loop is 2:
52             int_value = prop.default_value
53         elif loop is 1:
54             int_value = prop.minimum
55         else:
56             int_value = prop.maximum
57         cname = fname + " %s=%s" % (prop.name, int_value)
58         tname = fname + "%s=%s" % (prop.name, int_value)
59     else:
60         cname = fname + " %s=%s" % (prop.name, prop_value)
61         tname = fname + "%s=%s" % (prop.name, prop_value)
62
63     if "Audio" in klass:
64         cpipe = "audiotestsrc num-buffers=20 ! %s " % (cname)
65         sink = "! audioconvert ! %(audiosink)s"
66     elif "Video" in klass:
67         if "gl" in fname:
68             cname = "glfilterbin filter = %s" % (cname)
69         cpipe = "videotestsrc num-buffers=20 ! %s " % (cname)
70         sink = "! videoconvert ! %(videosink)s"
71     else:
72         return None
73
74     if test_manager.options.mute:
75         cpipe += "! fakesink"
76     else:
77         cpipe += "%s" % (sink)
78
79     return (tname, cpipe)
80
81
82 def setup_tests(test_manager, options):
83     print("Setting up tests to validate all elements")
84     pipelines_descriptions = []
85     test_manager.set_default_blacklist([
86         ("validate.launch_pipeline.videocrop*",
87          "https://bugzilla.gnome.org/show_bug.cgi?id=743910"),
88         ("validate.launch_pipeline.videobox*",
89          "https://bugzilla.gnome.org/show_bug.cgi?id=743909"),
90         ("validate.launch_pipeline.simplevideomark*",
91          "https://bugzilla.gnome.org/show_bug.cgi?id=743908"),
92         ("validate.launch_pipeline.exclusion*",
93          "https://bugzilla.gnome.org/show_bug.cgi?id=743907"),
94         ("validate.launch_pipeline.frei0r*",
95          "video filter plugins"),
96         ("validate.launch_pipeline.*interleavechannel-positions-from-input=False*",
97          "https://bugzilla.gnome.org/show_bug.cgi?id=744211"),
98         ("validate.launch_pipeline.spectrum*",
99          "https://bugzilla.gnome.org/show_bug.cgi?id=744213"),
100         ("validate.launch_pipeline.smpte*",
101          "smpte cannot be tested with simple pipeline. Hence excluding"),
102         ("validate.launch_pipeline.gleffects_laplacian*",
103          "https://bugzilla.gnome.org/show_bug.cgi?id=748393"),
104         ("validate.launch_pipeline.glfilterbin*",
105          "glfilter bin doesnt launch."),
106     ])
107     valid_scenarios = ["play_15s"]
108     Gst.init(None)
109     factories = Gst.Registry.get().get_feature_list(Gst.ElementFactory)
110     for element_factory in factories:
111         audiosrc = False
112         audiosink = False
113         videosrc = False
114         videosink = False
115         klass = element_factory.get_metadata("klass")
116         fname = element_factory.get_name()
117
118         if "band" in fname:
119             continue
120         if "Audio" not in klass and "Video" not in klass:
121             continue
122
123         padstemplates = element_factory.get_static_pad_templates()
124         for padtemplate in padstemplates:
125             if padtemplate.static_caps.string:
126                 caps = padtemplate.get_caps()
127                 for i in xrange(caps.get_size()):
128                     structure = caps.get_structure(i)
129                     if "audio/x-raw" in structure.get_name():
130                         if padtemplate.direction == Gst.PadDirection.SRC:
131                             audiosrc = True
132                         elif padtemplate.direction == Gst.PadDirection.SINK:
133                             audiosink = True
134                     elif "video/x-raw" in structure.get_name():
135                         if padtemplate.direction == Gst.PadDirection.SRC:
136                             videosrc = True
137                         elif padtemplate.direction == Gst.PadDirection.SINK:
138                             videosink = True
139
140         if (audiosink is False and videosink is False) or (audiosrc is False and videosrc is False):
141             continue
142
143         element = Gst.ElementFactory.make(fname, None)
144         if element is None:
145             print("Could not create element: %s" % fname)
146             continue
147
148         props = GObject.list_properties(element)
149         for prop in props:
150             if "name" in prop.name or "parent" in prop.name or "qos" in prop.name or \
151                "latency" in prop.name or "message-forward" in prop.name:
152                 continue
153             if (prop.flags & GObject.ParamFlags.WRITABLE) and \
154                (prop.flags & GObject.ParamFlags.READABLE):
155                 if prop.value_type == GObject.TYPE_BOOLEAN:
156                     loop = 2
157                 elif pspec_is_numeric(prop):
158                     loop = 3
159                 else:
160                     loop = 0
161
162                 while loop:
163                     loop -= 1
164                     description = get_pipe_and_populate(test_manager, klass,
165                                                         fname, prop, loop)
166                     if None is not description:
167                         pipelines_descriptions.append(description)
168
169     # No restriction about scenarios that are potentially used
170     test_manager.add_scenarios(valid_scenarios)
171     test_manager.add_generators(test_manager.GstValidatePipelineTestsGenerator
172                                 ("validate_elements", test_manager,
173                                     pipelines_descriptions=pipelines_descriptions,
174                                     valid_scenarios=valid_scenarios))
175
176     return True