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 from twisted.internet import defer
24
25 from flumotion.common import errors, messages
26 from flumotion.component import feedcomponent
27
28 from flumotion.common.messages import N_
29 T_ = messages.gettexter('flumotion')
30
31
32
33 -class Firewire(feedcomponent.ParseLaunchComponent):
42
47
49 width = props.get('width', 240)
50 height = props.get('height', int(576 * width/720.))
51
52
53 self.fixRenamedProperties(props, [
54 ('scaled_width', 'scaled-width'),
55 ('is_square', 'is-square'),
56 ])
57 scaled_width = props.get('scaled-width', width)
58 is_square = props.get('is-square', False)
59 framerate = props.get('framerate', (30, 2))
60 framerate_float = float(framerate[0]) / framerate[1]
61
62 scale_correction = width - scaled_width
63
64 if 12.5 < framerate_float <= 25:
65 drop_factor = 1
66 elif 6.3 < framerate_float <= 12.5:
67 drop_factor = 2
68 elif 3.2 < framerate_float <= 6.3:
69 drop_factor = 4
70 else:
71 drop_factor = 8
72
73 if is_square:
74 square_pipe = ',pixel-aspect-ratio=(fraction)1/1'
75 else:
76 square_pipe = ''
77
78
79
80
81 if scale_correction > 0:
82
83
84
85 pad_pipe = '! ffmpegcolorspace ! videobox right=-%d ! video/x-raw-yuv,format=(fourcc)I420 ' % scale_correction
86 else:
87 pad_pipe = ''
88
89
90
91 interlaced_height = 288
92
93
94
95
96
97 template = ('dv1394src'
98 ' ! queue leaky=2 max-size-time=1000000000'
99 ' ! dvdemux name=demux'
100 ' demux. ! queue ! dvdec drop-factor=%(df)d'
101 ' ! video/x-raw-yuv,format=(fourcc)YUY2'
102 ' ! videorate ! videoscale'
103 ' ! video/x-raw-yuv,width=%(sw)s,height=%(ih)s%(sq)s'
104 ' ! videoscale'
105 ' ! video/x-raw-yuv,width=%(sw)s,height=%(h)s,framerate=%(fr)s,format=(fourcc)YUY2'
106 ' %(pp)s'
107 ' ! @feeder::video@'
108 ' demux. ! queue ! audio/x-raw-int ! volume name=setvolume'
109 ' ! level name=volumelevel message=true ! audiorate'
110 ' ! @feeder::audio@'
111 % dict(df=drop_factor, ih=interlaced_height,
112 sq=square_pipe, pp=pad_pipe,
113 sw=scaled_width, h=height,
114 fr=('%d/%d' % (framerate[0], framerate[1]))))
115
116 return template
117
129
131 return self.volume.get_property('volume')
132
134 """
135 @param value: float between 0.0 and 4.0
136 """
137 self.debug("Setting volume to %f" % (value))
138
139 self.volume.set_property('volume', value)
140
141
143 """
144 @param bus: the message bus sending the message
145 @param message: the message received
146 """
147 if message.structure.get_name() == "ieee1394-bus-reset":
148
149 s = message.structure
150
151
152 if 'current-device-change' in s:
153 if s['current-device-change'] != 0:
154
155
156
157
158 for m in self.state.get('messages'):
159 if m.id.startswith('firewire-bus-reset'):
160 self.state.remove('messages',m)
161
162 if s['current-device-change'] == 1:
163
164 m = messages.Info(T_(N_(
165 "The camera has now been reconnected.")),
166 id="firewire-bus-reset-%d" % s['nodecount'],
167 priority=40)
168 self.state.append('messages', m)
169 elif s['current-device-change'] == -1:
170
171 m = messages.Warning(T_(N_(
172 "The camera has been disconnected.")),
173 id="firewire-bus-reset-%d" % s['nodecount'],
174 priority=40)
175 self.state.append('messages', m)
176