summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-11 23:42:06 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-16 21:47:51 +0300
commita779ec31224ab217572a20587e89ce393e62b033 (patch)
treeebf8d0f9f580d97ce892b9aac95db44eab1a3bf7 /py
parentc65ffb7cd928894788411a3563aec87e22791ca8 (diff)
py: add pyvid
Diffstat (limited to 'py')
-rw-r--r--py/CMakeLists.txt2
-rw-r--r--py/pykms.cpp3
-rw-r--r--py/pyvid.cpp38
3 files changed, 42 insertions, 1 deletions
diff --git a/py/CMakeLists.txt b/py/CMakeLists.txt
index 562a3cf..1349ea5 100644
--- a/py/CMakeLists.txt
+++ b/py/CMakeLists.txt
@@ -10,7 +10,7 @@ endif()
include_directories(${PROJECT_SOURCE_DIR}/ext/pybind11/include)
-add_library(pykms SHARED pykms.cpp pykmsbase.cpp pykmsutil.cpp)
+add_library(pykms SHARED pykms.cpp pykmsbase.cpp pykmsutil.cpp pyvid.cpp)
target_link_libraries(pykms kms++ kms++util ${LIBDRM_LIBRARIES})
# Don't add a 'lib' prefix to the shared library
diff --git a/py/pykms.cpp b/py/pykms.cpp
index 57ca363..c759d23 100644
--- a/py/pykms.cpp
+++ b/py/pykms.cpp
@@ -9,6 +9,7 @@ using namespace std;
void init_pykmstest(py::module &m);
void init_pykmsbase(py::module &m);
+void init_pyvid(py::module &m);
class PyPageFlipHandlerBase : PageFlipHandlerBase
{
@@ -39,5 +40,7 @@ PYBIND11_PLUGIN(pykms) {
init_pykmstest(m);
+ init_pyvid(m);
+
return m.ptr();
}
diff --git a/py/pyvid.cpp b/py/pyvid.cpp
new file mode 100644
index 0000000..01177d5
--- /dev/null
+++ b/py/pyvid.cpp
@@ -0,0 +1,38 @@
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+#include <kms++/kms++.h>
+#include <kms++util/kms++util.h>
+#include <kms++util/videodevice.h>
+
+namespace py = pybind11;
+
+using namespace kms;
+using namespace std;
+
+void init_pyvid(py::module &m)
+{
+ py::class_<VideoDevice, VideoDevice*>(m, "VideoDevice")
+ .def(py::init<const string&>())
+ .def_property_readonly("fd", &VideoDevice::fd)
+ .def_property_readonly("has_capture", &VideoDevice::has_capture)
+ .def_property_readonly("has_output", &VideoDevice::has_output)
+ .def_property_readonly("has_m2m", &VideoDevice::has_m2m)
+ .def_property_readonly("capture_streamer", &VideoDevice::get_capture_streamer)
+ .def_property_readonly("output_streamer", &VideoDevice::get_output_streamer)
+ .def_property_readonly("discrete_frame_sizes", &VideoDevice::get_discrete_frame_sizes)
+ .def_property_readonly("frame_sizes", &VideoDevice::get_frame_sizes)
+ .def("get_capture_devices", &VideoDevice::get_capture_devices)
+ ;
+
+ py::class_<VideoStreamer, VideoStreamer*>(m, "VideoStreamer")
+ .def_property_readonly("fd", &VideoStreamer::fd)
+ .def_property_readonly("ports", &VideoStreamer::get_ports)
+ .def("set_port", &VideoStreamer::set_port)
+ .def_property_readonly("formats", &VideoStreamer::get_formats)
+ .def("set_format", &VideoStreamer::set_format)
+ .def("set_queue_size", &VideoStreamer::set_queue_size)
+ .def("queue", &VideoStreamer::queue)
+ .def("dequeue", &VideoStreamer::dequeue)
+ .def("stream_on", &VideoStreamer::stream_on)
+ ;
+}