| 28 | namespace py = pybind11; |
| 29 | |
| 30 | void engine_bind(py::module &m) { |
| 31 | using namespace bmf; |
| 32 | |
| 33 | py::class_<BMFGraph>(m, "Graph") |
| 34 | .def_nogil(py::init<std::string const &, bool, bool>(), |
| 35 | py::arg("graph_config"), py::arg("is_path") = false, |
| 36 | py::arg("need_merge") = true) |
| 37 | .def_nogil("uid", &BMFGraph::uid) |
| 38 | .def_nogil("start", &BMFGraph::start) |
| 39 | .def_nogil("update", &BMFGraph::update, py::arg("config"), |
| 40 | py::arg("is_path")) |
| 41 | .def_nogil("close", &BMFGraph::close) |
| 42 | .def_nogil("force_close", &BMFGraph::force_close) |
| 43 | .def_nogil("add_input_stream_packet", |
| 44 | &BMFGraph::add_input_stream_packet, py::arg("stream_name"), |
| 45 | py::arg("packet"), py::arg("block") = false) |
| 46 | .def_nogil("poll_output_stream_packet", |
| 47 | &BMFGraph::poll_output_stream_packet, py::arg("stream_name"), |
| 48 | py::arg("block") = true) |
| 49 | .def_nogil("status", &BMFGraph::status); |
| 50 | |
| 51 | py::class_<BMFModule>(m, "Module") |
| 52 | .def_nogil(py::init<std::string const &, std::string const &, |
| 53 | std::string const &, std::string const &, |
| 54 | std::string const &>(), |
| 55 | py::arg("module_name"), py::arg("option"), |
| 56 | py::arg("module_type") = "", py::arg("module_path") = "", |
| 57 | py::arg("module_entry") = "") |
| 58 | .def_nogil("uid", &BMFModule::uid) |
| 59 | .def_nogil("process", &BMFModule::process, py::arg("task")) |
| 60 | .def_nogil("reset", &BMFModule::reset) |
| 61 | .def_nogil("init", &BMFModule::init) |
| 62 | .def_nogil("close", &BMFModule::close) |
| 63 | .def_nogil("dynamic_reset", &BMFModule::dynamic_reset) |
| 64 | ; |
| 65 | |
| 66 | py::class_<BMFCallback>(m, "Callback") |
| 67 | .def(py::init([](py::function &cb) { |
| 68 | return std::make_unique<BMFCallback>( |
| 69 | [=](bmf_sdk::CBytes para) -> bmf_sdk::CBytes { |
| 70 | py::gil_scoped_acquire gil; |
| 71 | auto res = cb(py::cast(para)); |
| 72 | return py::cast<bmf_sdk::CBytes>(res); |
| 73 | }); |
| 74 | })) |
| 75 | .def("uid", &BMFCallback::uid); |
| 76 | |
| 77 | // Trace interface |
| 78 | py::enum_<bmf_sdk::TraceType>(m, "TraceType") |
| 79 | .value("INTERLATENCY", bmf_sdk::TraceType::INTERLATENCY) |
| 80 | .value("PROCESSING", bmf_sdk::TraceType::PROCESSING) |
| 81 | .value("SCHEDULE", bmf_sdk::TraceType::SCHEDULE) |
| 82 | .value("QUEUE_INFO", bmf_sdk::TraceType::QUEUE_INFO) |
| 83 | .value("THROUGHPUT", bmf_sdk::TraceType::THROUGHPUT) |
| 84 | .value("CUSTOM", bmf_sdk::TraceType::CUSTOM) |
| 85 | .value("TRACE_START", bmf_sdk::TraceType::TRACE_START); |
| 86 | |
| 87 | py::enum_<bmf_sdk::TracePhase>(m, "TracePhase") |
no test coverage detected