Do not use wrapper class for Source
This commit is contained in:
@@ -1,24 +0,0 @@
|
|||||||
#include "PySource.hpp"
|
|
||||||
|
|
||||||
PySource::PySource(const std::string &ndi_name_,
|
|
||||||
const std::string &url_address_)
|
|
||||||
: _ndi_name(ndi_name_), _url_address(url_address_) {
|
|
||||||
p_ndi_name = _ndi_name.c_str();
|
|
||||||
p_url_address = _url_address.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
PySource::~PySource() {}
|
|
||||||
|
|
||||||
const std::string &PySource::getNdiName() const { return _ndi_name; }
|
|
||||||
|
|
||||||
void PySource::setNdiName(const std::string &name) {
|
|
||||||
_ndi_name = name;
|
|
||||||
p_ndi_name = _ndi_name.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string &PySource::getUrlAddress() const { return _url_address; }
|
|
||||||
|
|
||||||
void PySource::setUrlAddress(const std::string &address) {
|
|
||||||
_url_address = address;
|
|
||||||
p_url_address = _url_address.c_str();
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
#include <string>
|
|
||||||
|
|
||||||
#include <Processing.NDI.Lib.h>
|
|
||||||
|
|
||||||
class PySource : public NDIlib_source_t {
|
|
||||||
public:
|
|
||||||
PySource(const std::string &ndi_name_, const std::string &url_address_);
|
|
||||||
virtual ~PySource();
|
|
||||||
|
|
||||||
const std::string &getNdiName() const;
|
|
||||||
void setNdiName(const std::string &name);
|
|
||||||
|
|
||||||
const std::string &getUrlAddress() const;
|
|
||||||
void setUrlAddress(const std::string &address);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string _ndi_name;
|
|
||||||
std::string _url_address;
|
|
||||||
};
|
|
||||||
32
src/main.cpp
32
src/main.cpp
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "PyAudioFrame.hpp"
|
#include "PyAudioFrame.hpp"
|
||||||
#include "PyMetadataFrame.hpp"
|
#include "PyMetadataFrame.hpp"
|
||||||
#include "PySource.hpp"
|
|
||||||
#include "PyVideoFrame.hpp"
|
#include "PyVideoFrame.hpp"
|
||||||
|
|
||||||
namespace py = pybind11;
|
namespace py = pybind11;
|
||||||
@@ -97,12 +96,31 @@ PYBIND11_MODULE(NDIlib, m) {
|
|||||||
|
|
||||||
m.attr("RECV_TIMESTAMP_UNDEFINED") = py::int_(INT64_MAX);
|
m.attr("RECV_TIMESTAMP_UNDEFINED") = py::int_(INT64_MAX);
|
||||||
|
|
||||||
py::class_<PySource>(m, "Source")
|
py::class_<NDIlib_source_t>(m, "Source")
|
||||||
.def(py::init<const std::string &, const std::string &>(),
|
.def(py::init<const char *, const char *>(),
|
||||||
py::arg("ndi_name") = nullptr, py::arg("url_address") = nullptr)
|
py::arg("p_ndi_name") = nullptr, py::arg("p_url_address") = nullptr)
|
||||||
.def_property("ndi_name", &PySource::getNdiName, &PySource::setNdiName)
|
.def_property(
|
||||||
.def_property("url_address", &PySource::getUrlAddress,
|
"ndi_name",
|
||||||
&PySource::setUrlAddress);
|
[](const NDIlib_source_t &self) {
|
||||||
|
auto ustr = PyUnicode_DecodeLocale(self.p_ndi_name, nullptr);
|
||||||
|
return py::reinterpret_steal<py::str>(ustr);
|
||||||
|
},
|
||||||
|
[](NDIlib_source_t &self, const std::string &name) {
|
||||||
|
static std::unordered_map<NDIlib_source_t *, std::string> strs;
|
||||||
|
strs[&self] = py::str(name);
|
||||||
|
self.p_ndi_name = strs[&self].c_str();
|
||||||
|
})
|
||||||
|
.def_property(
|
||||||
|
"url_address",
|
||||||
|
[](const NDIlib_source_t &self) {
|
||||||
|
auto ustr = PyUnicode_DecodeLocale(self.p_url_address, nullptr);
|
||||||
|
return py::reinterpret_steal<py::str>(ustr);
|
||||||
|
},
|
||||||
|
[](NDIlib_source_t &self, const std::string &address) {
|
||||||
|
static std::unordered_map<NDIlib_source_t *, std::string> strs;
|
||||||
|
strs[&self] = py::str(address);
|
||||||
|
self.p_url_address = strs[&self].c_str();
|
||||||
|
});
|
||||||
|
|
||||||
py::class_<PyVideoFrameV2>(m, "VideoFrameV2")
|
py::class_<PyVideoFrameV2>(m, "VideoFrameV2")
|
||||||
.def(py::init<int, int, NDIlib_FourCC_type_e, int, int, float,
|
.def(py::init<int, int, NDIlib_FourCC_type_e, int, int, float,
|
||||||
|
|||||||
Reference in New Issue
Block a user