Commit 9b69a811 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

Make reader and writer classes picklable

Fixes #16
parent c492c79b
Pipeline #39660 failed with stage
in 4 minutes and 51 seconds
......@@ -28,7 +28,7 @@ static auto s_reader = bob::extension::ClassDoc(
.add_parameter("filename", "str", "The file path to the file you want to read data from")
.add_parameter("check", "bool", "Format and codec will be extracted from the video metadata.")
);
static auto s_fullname = BOB_EXT_MODULE_PREFIX ".reader";
static void PyBobIoVideoReader_Delete (PyBobIoVideoReaderObject* o) {
o->v.reset();
......@@ -557,7 +557,7 @@ PyTypeObject PyBobIoVideoReaderIterator_Type = {
bool init_BobIoVideoReader(PyObject* module){
// initialize the reader
PyBobIoVideoReader_Type.tp_name = s_reader.name();
PyBobIoVideoReader_Type.tp_name = s_fullname;
PyBobIoVideoReader_Type.tp_basicsize = sizeof(PyBobIoVideoReaderObject);
PyBobIoVideoReader_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
PyBobIoVideoReader_Type.tp_doc = s_reader.doc();
......
......@@ -19,6 +19,13 @@ from bob.io.base import load
INPUT_VIDEO = test_utils.datafile('test.mov', __name__)
def test_picklability():
from . import reader, writer
import pickle
assert reader is pickle.loads(pickle.dumps(reader))
assert writer is pickle.loads(pickle.dumps(writer))
def test_codec_support():
# Describes all encoders
......
......@@ -34,6 +34,7 @@ static auto s_writer = bob::extension::ClassDoc(
.add_parameter("format", "str", "[Default: ``''``] If you must, specify a valid FFmpeg output format name and that will be used to encode the video on the output file. Leave it empty to guess from the filename extension")
.add_parameter("check", "bool", "[Default: ``True``] ")
);
static auto s_fullname = BOB_EXT_MODULE_PREFIX ".writer";
static void PyBobIoVideoWriter_Delete (PyBobIoVideoWriterObject* o) {
......@@ -482,7 +483,7 @@ PyTypeObject PyBobIoVideoWriter_Type = {
bool init_BobIoVideoWriter(PyObject* module){
// initialize the writer
PyBobIoVideoWriter_Type.tp_name = s_writer.name();
PyBobIoVideoWriter_Type.tp_name = s_fullname;
PyBobIoVideoWriter_Type.tp_basicsize = sizeof(PyBobIoVideoWriterObject);
PyBobIoVideoWriter_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
PyBobIoVideoWriter_Type.tp_doc = s_writer.doc();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment