28 py::module utils_module = m.def_submodule(
"utils");
30 .def(py::init<unsigned int, uint64_t, string&, bool>(), py::arg(
"batch_size"), py::arg(
"interval"), py::arg(
"source_type"), py::arg(
"show_name"))
31 .def(
"apply", [](PerfMonitor&
self,
Node& node,
string& tips) {
32 self.apply(node, tips);
35 py::arg(
"node"), py::arg(
"tips"))
38 .def(
"add_stream", [](PerfMonitor&
self, uint32_t source_id,
string& uri,
string& sensor_id,
string& sensor_name) {
39 self.addStream(source_id, uri.c_str(), sensor_id.c_str(), sensor_name.c_str());
52 return "EngineFileMonitor(started=" + std::to_string(
self.
started) +
")";
55 .def_property_readonly(
"codec", [](
const AudioStreamInfo&
self) {
return self.codec; })
56 .def_property_readonly(
"channels", [](
const AudioStreamInfo&
self) {
return self.channels; })
57 .def_property_readonly(
"sampling_rate", [](
const AudioStreamInfo&
self) {
return self.sampling_rate; })
58 .def(
"__repr__", [](
const AudioStreamInfo&
self) {
59 return "AudioStreamInfo(codec=" +
self.codec +
60 ", channels=" + std::to_string(
self.channels) +
61 ", sampling_rate=" + std::to_string(
self.sampling_rate) +
")";
64 .def_property_readonly(
"codec", [](
const VideoStreamInfo&
self) {
return self.codec; })
65 .def_property_readonly(
"width", [](
const VideoStreamInfo&
self) {
return self.width; })
66 .def_property_readonly(
"height", [](
const VideoStreamInfo&
self) {
return self.height; })
67 .def_property_readonly(
"framerate", [](
const VideoStreamInfo&
self) {
68 return pybind11::make_tuple(
self.framerate.num,
self.framerate.denom);
70 .def(
"__repr__", [](
const VideoStreamInfo&
self) {
71 return "VideoStreamInfo(codec=" +
self.codec +
72 ", width=" + std::to_string(
self.
width) +
73 ", height=" + std::to_string(
self.height) +
74 ", framerate=" + std::to_string(
self.framerate.num) +
"/" + std::to_string(
self.framerate.denom) +
")";
77 .def_property_readonly(
"live", [](
const MediaInfo&
self) {
return self.live; })
78 .def_property_readonly(
"duration", [](
const MediaInfo&
self) {
return self.duration; })
79 .def_property_readonly(
"streams", [](
const MediaInfo&
self) {
80 pybind11::list py_list;
81 for (
auto& s :
self.streams) {
83 AudioStreamInfo* audio =
dynamic_cast<AudioStreamInfo*
>(p);
84 VideoStreamInfo* video =
dynamic_cast<VideoStreamInfo*
>(p);
86 py_list.append(*audio);
88 py_list.append(*video);
93 .def(
"__bool__", [](
const MediaInfo&
self) {
return !
self.error; })
95 .def(
"__repr__", [](
const MediaInfo&
self) {
96 pybind11::list py_list;
97 for (
auto& s :
self.streams) {
99 AudioStreamInfo* audio =
dynamic_cast<AudioStreamInfo*
>(p);
100 VideoStreamInfo* video =
dynamic_cast<VideoStreamInfo*
>(p);
102 py_list.append(*audio);
104 py_list.append(*video);
107 return "MediaInfo(live=" + std::to_string(
self.live) +
108 ", duration=" + std::to_string(
self.duration) +
109 ", streams=" + py::repr(py_list).cast<std::string>() +
")";