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: 7162 $"
33
34
36
37 def ret(*_args):
38 for spec in args:
39 if len(spec) == 3:
40 key = spec[2]
41 else:
42 key = lambda x: x
43 index = spec[0]
44 value = spec[1]
45 if len(_args) <= index or key(_args[index]) != value:
46 return
47 return proc(*_args)
48 return ret
49
50
52
53 def bus_watch_func(bus, message):
54 proc(*args, **kwargs)
55 bus_watch_func = arg_filtered(bus_watch_func,
56 (1, element, lambda x: x.src),
57 (1, [from_state, to_state, gst.STATE_VOID_PENDING],
58 lambda x: x.parse_state_changed()))
59 parent = element
60 while parent.get_parent():
61 parent = parent.get_parent()
62 b = parent.get_bus()
63 b.connect('message::state-changed', bus_watch_func)
64
65
66 -class BTTV(feedcomponent.ParseLaunchComponent):
67
69 device = properties['device']
70 width = properties.get('width', 320)
71 height = properties.get('height', 240)
72
73
74 device_width = width
75 device_height = height
76
77
78
79 framerate = properties.get('framerate', (25, 1))
80 framerate_string = '%d/%d' % (framerate[0], framerate[1])
81
82 pipeline = ('v4lsrc name=source device=%s copy-mode=true ! '
83 'video/x-raw-yuv,width=%d,height=%d ! videoscale ! '
84 'video/x-raw-yuv,width=%d,height=%d ! videorate ! '
85 'video/x-raw-yuv,framerate=%s') % (device,
86 device_width,
87 device_height,
88 width, height,
89 framerate_string)
90 return pipeline
91
110
112 self.debug("bttv READY->PAUSED, setting channel %s and norm %s" % (
113 channel, norm))
114 if channel:
115 c = element.find_channel_by_name(channel)
116 if c:
117 self.debug("set channel to %s" % channel)
118 element.set_channel(c)
119 if norm:
120 c = element.find_norm_by_name(norm)
121 if c:
122 self.debug("set norm to %s" % norm)
123 element.set_norm(c)
124