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