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