Do not use wrapper class for MetadataFrame
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
#include "PyMetadataFrame.hpp"
|
||||
|
||||
PyMetadataFrame::PyMetadataFrame(int length_, int64_t timecode_,
|
||||
const std::string &data_)
|
||||
: _data(data_) {
|
||||
length = length_;
|
||||
timecode = timecode_;
|
||||
p_data = &_data[0];
|
||||
}
|
||||
|
||||
PyMetadataFrame::~PyMetadataFrame() {}
|
||||
|
||||
const std::string &PyMetadataFrame::getData() const { return _data; }
|
||||
|
||||
void PyMetadataFrame::setData(const std::string &data) {
|
||||
_data = data;
|
||||
p_data = &_data[0];
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#include <string>
|
||||
|
||||
#include <Processing.NDI.Lib.h>
|
||||
|
||||
class PyMetadataFrame : public NDIlib_metadata_frame_t {
|
||||
public:
|
||||
PyMetadataFrame(int length_, int64_t timecode_, const std::string &data_);
|
||||
virtual ~PyMetadataFrame();
|
||||
|
||||
const std::string &getData() const;
|
||||
void setData(const std::string &data);
|
||||
|
||||
private:
|
||||
std::string _data;
|
||||
};
|
||||
25
src/main.cpp
25
src/main.cpp
@@ -2,7 +2,6 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
|
||||
#include "PyAudioFrame.hpp"
|
||||
#include "PyMetadataFrame.hpp"
|
||||
#include "PyVideoFrame.hpp"
|
||||
|
||||
namespace py = pybind11;
|
||||
@@ -190,14 +189,24 @@ PYBIND11_MODULE(NDIlib, m) {
|
||||
&PyAudioFrameV3::setMetadata)
|
||||
.def_readwrite("timestamp", &PyAudioFrameV3::timestamp);
|
||||
|
||||
py::class_<PyMetadataFrame>(m, "MetadataFrame")
|
||||
.def(py::init<int, int64_t, const std::string &>(), py::arg("length") = 0,
|
||||
py::class_<NDIlib_metadata_frame_t>(m, "MetadataFrame")
|
||||
.def(py::init<int, int64_t, char *>(), py::arg("length") = 0,
|
||||
py::arg("timecode") = NDIlib_send_timecode_synthesize,
|
||||
py::arg("data") = nullptr)
|
||||
.def_readwrite("length", &PyMetadataFrame::length)
|
||||
.def_readwrite("timecode", &PyMetadataFrame::timecode)
|
||||
.def_property("data", &PyMetadataFrame::getData,
|
||||
&PyMetadataFrame::setData);
|
||||
py::arg("p_data") = nullptr)
|
||||
.def_readwrite("length", &NDIlib_metadata_frame_t::length)
|
||||
.def_readwrite("timecode", &NDIlib_metadata_frame_t::timecode)
|
||||
.def_property(
|
||||
"data",
|
||||
[](const NDIlib_metadata_frame_t &self) {
|
||||
auto ustr = PyUnicode_DecodeLocale(self.p_data, nullptr);
|
||||
return py::reinterpret_steal<py::str>(ustr);
|
||||
},
|
||||
[](NDIlib_metadata_frame_t &self, const std::string &data) {
|
||||
static std::unordered_map<NDIlib_metadata_frame_t *, std::string>
|
||||
strs;
|
||||
strs[&self] = py::str(data);
|
||||
self.p_data = strs[&self].data();
|
||||
});
|
||||
|
||||
py::class_<NDIlib_tally_t>(m, "Tally")
|
||||
.def(py::init<bool, bool>(), py::arg("on_program") = false,
|
||||
|
||||
Reference in New Issue
Block a user