1
# PiTiVi , Non-linear video editor
3
# pitivi/elements/extractionsink.py
5
# Copyright (c) 2005, Edward Hervey <bilboed@bilboed.com>
6
# Copyright (c) 2011, Benjamin M. Schwartz <bens@alum.mit.edu>
8
# This program is free software; you can redistribute it and/or
9
# modify it under the terms of the GNU Lesser General Public
10
# License as published by the Free Software Foundation; either
11
# version 2.1 of the License, or (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
# Lesser General Public License for more details.
18
# You should have received a copy of the GNU Lesser General Public
19
# License along with this program; if not, write to the
20
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21
# Boston, MA 02110-1301, USA.
24
Extract audio samples without storing the whole waveform in memory
29
gobject.threads_init()
31
from pitivi.utils import native_endianness, call_false
34
class ExtractionSink(gst.BaseSink):
37
Passes audio data directly to a provided L{Extractee}
41
"audio/x-raw-float, width=(int) 32, "
42
"endianness = (int) %s, "
44
"rate = (int) [1, 96000]"
55
gst.BaseSink.__init__(self)
56
self.props.sync = False
62
def set_extractee(self, extractee):
63
self.extractee = extractee
65
def set_stopped_cb(self, cb):
69
self.samples = array.array('f')
72
def do_set_caps(self, caps):
73
if not caps[0].get_name() == "audio/x-raw-float":
75
self.rate = caps[0]["rate"]
76
self.channels = caps[0]["channels"]
79
def do_render(self, buf):
80
if self.extractee is not None:
81
self.extractee.receive(array.array('f', buf.data))
84
def do_preroll(self, buf):
87
def do_event(self, ev):
88
self.info("Got event of type %s" % ev.type)
89
if ev.type == gst.EVENT_EOS:
91
gobject.idle_add(call_false, self._cb)
94
gobject.type_register(ExtractionSink)