MCPcopy Index your code
hub / github.com/GStreamer/gst-python / FileSource

Class FileSource

old_examples/filesrc.py:32–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30import gst
31
32class FileSource(gst.BaseSrc):
33 __gsttemplates__ = (
34 gst.PadTemplate("src",
35 gst.PAD_SRC,
36 gst.PAD_ALWAYS,
37 gst.caps_new_any()),
38 )
39
40 blocksize = 4096
41 fd = None
42
43 def __init__(self, name):
44 self.__gobject_init__()
45 self.curoffset = 0
46 self.set_name(name)
47
48 def set_property(self, name, value):
49 if name == 'location':
50 self.fd = open(value, 'r')
51
52 def do_create(self, offset, size):
53 if offset != self.curoffset:
54 self.fd.seek(offset, 0)
55 data = self.fd.read(self.blocksize)
56 if data:
57 self.curoffset += len(data)
58 return gst.FLOW_OK, gst.Buffer(data)
59 else:
60 return gst.FLOW_UNEXPECTED, None
61gobject.type_register(FileSource)
62
63def main(args):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected