1 #include <pybind11/pybind11.h>
2 #include <pybind11/stl.h>
3 #include <kms++/kms++.h>
4 #include <kms++util/kms++util.h>
5 #include <kms++util/videodevice.h>
6
7 namespace py = pybind11;
8
9 using namespace kms;
10 using namespace std;
11
init_pyvid(py::module & m)12 void init_pyvid(py::module& m)
13 {
14 py::class_<VideoDevice>(m, "VideoDevice")
15 .def(py::init<const string&>())
16 .def_property_readonly("fd", &VideoDevice::fd)
17 .def_property_readonly("has_capture", &VideoDevice::has_capture)
18 .def_property_readonly("has_output", &VideoDevice::has_output)
19 .def_property_readonly("has_m2m", &VideoDevice::has_m2m)
20 .def_property_readonly("capture_streamer", &VideoDevice::get_capture_streamer)
21 .def_property_readonly("output_streamer", &VideoDevice::get_output_streamer)
22 .def_property_readonly("discrete_frame_sizes", &VideoDevice::get_discrete_frame_sizes)
23 .def_property_readonly("frame_sizes", &VideoDevice::get_frame_sizes)
24 .def("get_capture_devices", &VideoDevice::get_capture_devices);
25
26 py::class_<VideoStreamer>(m, "VideoStreamer")
27 .def_property_readonly("fd", &VideoStreamer::fd)
28 .def_property_readonly("ports", &VideoStreamer::get_ports)
29 .def("set_port", &VideoStreamer::set_port)
30 .def_property_readonly("formats", &VideoStreamer::get_formats)
31 .def("set_format", &VideoStreamer::set_format)
32 .def("get_selection", [](VideoStreamer* self) {
33 uint32_t left, top, width, height;
34 self->get_selection(left, top, width, height);
35 return make_tuple(left, top, width, height);
36 })
37 .def("set_selection", [](VideoStreamer* self, uint32_t left, uint32_t top, uint32_t width, uint32_t height) {
38 self->set_selection(left, top, width, height);
39 return make_tuple(left, top, width, height);
40 })
41 .def("set_queue_size", &VideoStreamer::set_queue_size)
42 .def("queue", &VideoStreamer::queue)
43 .def("dequeue", &VideoStreamer::dequeue)
44 .def("stream_on", &VideoStreamer::stream_on)
45 .def("stream_off", &VideoStreamer::stream_off);
46 }
47