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 __version__ = "$Rev: 6654 $"
33
34
36 def ret(*_args):
37 for spec in args:
38 if len(spec) == 3:
39 key = spec[2]
40 else:
41 key = lambda x: x
42 index = spec[0]
43 value = spec[1]
44 if len(_args) <= index or key(_args[index]) != value:
45 return
46 return proc (*_args)
47 return ret
48
50 def bus_watch_func(bus, message):
51 proc(*args, **kwargs)
52 bus_watch_func = arg_filtered(bus_watch_func,
53 (1, element, lambda x: x.src),
54 (1, [from_state, to_state, gst.STATE_VOID_PENDING],
55 lambda x: x.parse_state_changed()))
56 parent = element
57 while parent.get_parent():
58 parent = parent.get_parent()
59 b = parent.get_bus()
60 b.connect('message::state-changed', bus_watch_func)
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