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