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