1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import gst
23
24 from flumotion.common import errors, gstreamer, messages
25 from flumotion.component import feedcomponent
26
27 from flumotion.common.messages import N_
28 T_ = messages.gettexter('flumotion')
29
30
31 -class VideoTest(feedcomponent.ParseLaunchComponent):
32
34 self.uiState.addKey('pattern', 0)
35
37 format = properties.get('format', 'video/x-raw-yuv')
38
39 if format == 'video/x-raw-yuv':
40 format = '%s,format=(fourcc)I420' % format
41
42
43 struct = gst.structure_from_string(format)
44 for k in 'width', 'height':
45 if k in properties:
46 struct[k] = properties[k]
47
48 if 'framerate' in properties:
49 framerate = properties['framerate']
50 struct['framerate'] = gst.Fraction(framerate[0], framerate[1])
51
52
53 if format == 'video/x-raw-rgb':
54 struct['red_mask'] = 0xff00
55 caps = gst.Caps(struct)
56
57 is_live = 'is-live=true'
58
59 return "videotestsrc %s name=source ! " \
60 "identity name=identity silent=TRUE ! %s" % (
61 is_live, caps)
62
63
67
68 source = self.get_element('source')
69 source.connect('notify::pattern', notify_pattern)
70 if 'pattern' in properties:
71 source.set_property('pattern', properties['pattern'])
72
73 if 'drop-probability' in properties:
74 vt = gstreamer.get_plugin_version('coreelements')
75 if not vt:
76 raise errors.MissingElementError('identity')
77 if not vt > (0, 10, 12, 0):
78 self.addMessage(
79 messages.Warning(T_(N_(
80 "The 'drop-probability' property is specified, but "
81 "it only works with GStreamer core newer than 0.10.12. "
82 "You should update your version of GStreamer."))))
83 else:
84 drop_probability = properties['drop-probability']
85 if drop_probability < 0.0 or drop_probability > 1.0:
86 self.addMessage(
87 messages.Warning(T_(N_(
88 "The 'drop-probability' property can only be "
89 "between 0.0 and 1.0."))))
90 else:
91 identity = self.get_element('identity')
92 identity.set_property('drop-probability',
93 drop_probability)
94