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 import gst.interfaces
24
25 from flumotion.common import log
26
27 from flumotion.component import feedcomponent
28 from flumotion.component.effects.colorbalance import colorbalance
29
30
31 __all__ = ['BTTV']
32
34 def ret(*_args):
35 for spec in args:
36 if len(spec) == 3:
37 key = spec[2]
38 else:
39 key = lambda x: x
40 index = spec[0]
41 value = spec[1]
42 if len(_args) <= index or key(_args[index]) != value:
43 return
44 return proc (*_args)
45 return ret
46
48 def bus_watch_func(bus, message):
49 proc(*args, **kwargs)
50 bus_watch_func = arg_filtered(bus_watch_func,
51 (1, element, lambda x: x.src),
52 (1, [from_state, to_state, gst.STATE_VOID_PENDING],
53 lambda x: x.parse_state_changed()))
54 parent = element
55 while parent.get_parent():
56 parent = parent.get_parent()
57 b = parent.get_bus()
58 b.connect('message::state-changed', bus_watch_func)
59
60 -class BTTV(feedcomponent.ParseLaunchComponent):
61
63 device = properties['device']
64 width = properties.get('width', 320)
65 height = properties.get('height', 240)
66
67
68 device_width = width
69 device_height = height
70
71
72
73 framerate = properties.get('framerate', (25, 1))
74 framerate_string = '%d/%d' % (framerate[0], framerate[1])
75
76 pipeline = ('v4lsrc name=source device=%s copy-mode=true ! '
77 'video/x-raw-yuv,width=%d,height=%d ! videoscale ! '
78 'video/x-raw-yuv,width=%d,height=%d ! videorate ! '
79 'video/x-raw-yuv,framerate=%s') % (device,
80 device_width,
81 device_height,
82 width, height,
83 framerate_string)
84 return pipeline
85
104
106 self.debug("bttv READY->PAUSED, setting channel %s and norm %s" % (
107 channel, norm))
108 if channel:
109 c = element.find_channel_by_name(channel)
110 if c:
111 self.debug("set channel to %s" % channel)
112 element.set_channel(c)
113 if norm:
114 c = element.find_norm_by_name(norm)
115 if c:
116 self.debug("set norm to %s" % norm)
117 element.set_norm(c)
118