3 # -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
5 # Copyright (c) 2015,Thibault Saunier <thibault.saunier@collabora.com>
6 # 2015,Vineeth T M <vineeth.tm@samsung.com>
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.
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.
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.
24 The GstValidate default testsuite
27 from gi.repository import Gst
28 from gi.repository import GObject
30 TEST_MANAGER = "validate"
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,
40 def get_pipe_and_populate(test_manager, klass, fname, prop, loop):
41 prop_value = Gst.ElementFactory.make(fname, None).get_property(prop.name)
43 if prop.value_type == GObject.TYPE_BOOLEAN:
48 cname = fname + " %s=%s" % (prop.name, bool_value)
49 tname = fname + "%s=%s" % (prop.name, bool_value)
50 elif pspec_is_numeric(prop):
52 int_value = prop.default_value
54 int_value = prop.minimum
56 int_value = prop.maximum
57 cname = fname + " %s=%s" % (prop.name, int_value)
58 tname = fname + "%s=%s" % (prop.name, int_value)
60 cname = fname + " %s=%s" % (prop.name, prop_value)
61 tname = fname + "%s=%s" % (prop.name, prop_value)
64 cpipe = "audiotestsrc num-buffers=20 ! %s " % (cname)
65 sink = "! audioconvert ! %(audiosink)s"
66 elif "Video" in klass:
68 cname = "glfilterbin filter = %s" % (cname)
69 cpipe = "videotestsrc num-buffers=20 ! %s " % (cname)
70 sink = "! videoconvert ! %(videosink)s"
74 if test_manager.options.mute:
77 cpipe += "%s" % (sink)
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."),
107 valid_scenarios = ["play_15s"]
109 factories = Gst.Registry.get().get_feature_list(Gst.ElementFactory)
110 for element_factory in factories:
115 klass = element_factory.get_metadata("klass")
116 fname = element_factory.get_name()
120 if "Audio" not in klass and "Video" not in klass:
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:
132 elif padtemplate.direction == Gst.PadDirection.SINK:
134 elif "video/x-raw" in structure.get_name():
135 if padtemplate.direction == Gst.PadDirection.SRC:
137 elif padtemplate.direction == Gst.PadDirection.SINK:
140 if (audiosink is False and videosink is False) or (audiosrc is False and videosrc is False):
143 element = Gst.ElementFactory.make(fname, None)
145 print("Could not create element: %s" % fname)
148 props = GObject.list_properties(element)
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:
153 if (prop.flags & GObject.ParamFlags.WRITABLE) and \
154 (prop.flags & GObject.ParamFlags.READABLE):
155 if prop.value_type == GObject.TYPE_BOOLEAN:
157 elif pspec_is_numeric(prop):
164 description = get_pipe_and_populate(test_manager, klass,
166 if None is not description:
167 pipelines_descriptions.append(description)
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))