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.common.i18n import N_, gettexter
26 from flumotion.component import feedcomponent
27
28 __version__ = "$Rev: 7162 $"
29 T_ = gettexter()
30
31
37
38
39 -class VideoTest(feedcomponent.ParseLaunchComponent):
40 componentMediumClass = VideoTestMedium
41
43 self.uiState.addKey('pattern', 0)
44
46 format = properties.get('format', 'video/x-raw-yuv')
47
48 if format == 'video/x-raw-yuv':
49 format = '%s,format=(fourcc)I420' % format
50
51
52 struct = gst.structure_from_string(format)
53 for k in 'width', 'height':
54 if k in properties:
55 struct[k] = properties[k]
56
57 if 'framerate' in properties:
58 framerate = properties['framerate']
59 struct['framerate'] = gst.Fraction(framerate[0], framerate[1])
60
61
62 struct['pixel-aspect-ratio']= gst.Fraction(1, 1)
63 if 'pixel-aspect-ratio' in properties:
64 par = properties['pixel-aspect-ratio']
65 struct['pixel-aspect-ratio'] = gst.Fraction(par[0], par[1])
66
67
68 if format == 'video/x-raw-rgb':
69 struct['red_mask'] = 0xff00
70 caps = gst.Caps(struct)
71
72 is_live = 'is-live=true'
73
74 overlay = ""
75 overlayTimestamps = properties.get('overlay-timestamps', False)
76 if overlayTimestamps:
77 overlay = " timeoverlay ! "
78
79 return "videotestsrc %s name=source ! " % is_live + overlay + \
80 "identity name=identity silent=TRUE ! %s" % caps
81
82
83
88
89 source = self.get_element('source')
90 source.connect('notify::pattern', notify_pattern)
91 if 'pattern' in properties:
92 source.set_property('pattern', properties['pattern'])
93
94 if 'drop-probability' in properties:
95 vt = gstreamer.get_plugin_version('coreelements')
96 if not vt:
97 raise errors.MissingElementError('identity')
98 if not vt > (0, 10, 12, 0):
99 self.addMessage(
100 messages.Warning(T_(N_(
101 "The 'drop-probability' property is specified, but "
102 "it only works with GStreamer core newer than 0.10.12."
103 " You should update your version of GStreamer."))))
104 else:
105 drop_probability = properties['drop-probability']
106 if drop_probability < 0.0 or drop_probability > 1.0:
107 self.addMessage(
108 messages.Warning(T_(N_(
109 "The 'drop-probability' property can only be "
110 "between 0.0 and 1.0."))))
111 else:
112 identity = self.get_element('identity')
113 identity.set_property('drop-probability',
114 drop_probability)
115