1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 import gobject
19 import gst
20
21 from flumotion.common.i18n import gettexter
22 from flumotion.component import feedcomponent
23
24 __version__ = "$Rev$"
25 T_ = gettexter()
26
27
29 '''
30 I retimestamp incomming buffers adding a fixed delay.
31 '''
32
33 __gproperties__ = {
34 'delay': (float, 'delay (in ms)',
35 'Resynchronisation delay in milliseconds',
36 -1000000, 1000000, 0,
37 gobject.PARAM_READWRITE)}
38
39 _sinkpadtemplate = gst.PadTemplate("sink",
40 gst.PAD_SINK,
41 gst.PAD_ALWAYS,
42 gst.caps_from_string(
43 "audio/x-raw-float;"
44 "audio/x-raw-int"))
45
46 _srcpadtemplate = gst.PadTemplate("src",
47 gst.PAD_SRC,
48 gst.PAD_ALWAYS,
49 gst.caps_from_string(
50 "audio/x-raw-float;"
51 "audio/x-raw-int"))
52
54 gst.Element.__init__(self)
55
56 self.sinkpad = gst.Pad(self._sinkpadtemplate, "sink")
57 self.sinkpad.set_chain_function(self.chainfunc)
58 self.add_pad(self.sinkpad)
59
60 self.srcpad = gst.Pad(self._srcpadtemplate, "src")
61 self.add_pad(self.srcpad)
62
63 self._delay = long(delay * gst.MSECOND)
64 print self._delay
65
67 if property.name == "delay":
68 return self._delay
69 else:
70 raise AttributeError('unknown property %s' % property.name)
71
73 if property.name == "delay":
74 self._delay = long(value * gst.MSECOND)
75 else:
76 raise AttributeError('unknown property %s' % property.name)
77
79 if self._delay != 0:
80 buffer.make_metadata_writable
81 buffer.timestamp = buffer.timestamp + self._delay
82 self.srcpad.push(buffer)
83 return gst.FLOW_OK
84
85
87 """
88 Post processing audio effect to increase/decrease the audio delay an
89 synchronise it on the fly with the video stream.
90 """
91 logCategory = "audioresync-effect"
92
93 - def __init__(self, name, sourcePad, pipeline, delay):
94 """
95 @param element: the video source element on which the post
96 processing effect will be added
97 @param sourcePad: source pad used for linking the effect
98 @param pipeline: the pipeline of the element
99 @param delay: audio delay added
100 """
101 feedcomponent.PostProcEffect.__init__(self, name, sourcePad,
102 AudioResyncer(delay), pipeline)
103
109
111 self.effectBin.set_property("delay", delay)
112 return delay
113
115 return self.effectBin.get_property('delay')
116