Update PySendCreate

This commit is contained in:
Naoto Kondo
2020-04-24 11:55:01 +09:00
parent 8bfb3e6195
commit 2f4fc104c7
3 changed files with 56 additions and 6 deletions

27
src/PySendCreate.cpp Normal file
View File

@@ -0,0 +1,27 @@
#include "PySendCreate.hpp"
PySendCreate::PySendCreate(const std::string &ndi_name_,
const std::string &groupds_, bool clock_video_,
bool clock_audio_)
: _ndi_name(ndi_name_), _groups(groupds_) {
p_ndi_name = _ndi_name.c_str();
p_groups = _groups.c_str();
clock_video = clock_video_;
clock_audio = clock_audio_;
}
PySendCreate::~PySendCreate() {}
const std::string &PySendCreate::getNdiName() const { return _ndi_name; }
void PySendCreate::setNdiName(const std::string &name) {
_ndi_name = name;
p_ndi_name = _ndi_name.c_str();
}
const std::string &PySendCreate::getGroups() const { return _groups; }
void PySendCreate::setGroups(const std::string &groups) {
_groups = groups;
p_groups = _groups.c_str();
}

20
src/PySendCreate.hpp Normal file
View File

@@ -0,0 +1,20 @@
#include <string>
#include <Processing.NDI.Lib.h>
class PySendCreate : public NDIlib_send_create_t {
public:
PySendCreate(const std::string &ndi_name_, const std::string &groups_,
bool clock_video_, bool clock_audio_);
virtual ~PySendCreate();
const std::string &getNdiName() const;
void setNdiName(const std::string &name);
const std::string &getGroups() const;
void setGroups(const std::string &groups);
private:
std::string _ndi_name;
std::string _groups;
};

View File

@@ -3,6 +3,7 @@
#include "PyAudioFrame.hpp" #include "PyAudioFrame.hpp"
#include "PyMetadataFrame.hpp" #include "PyMetadataFrame.hpp"
#include "PySendCreate.hpp"
#include "PySource.hpp" #include "PySource.hpp"
#include "PyVideoFrame.hpp" #include "PyVideoFrame.hpp"
@@ -436,14 +437,16 @@ PYBIND11_MODULE(NDIlib, m) {
py::arg("instance"), py::arg("times")); py::arg("instance"), py::arg("times"));
// Processing.NDI.Send // Processing.NDI.Send
py::class_<NDIlib_send_create_t>(m, "SendCreate") py::class_<PySendCreate>(m, "SendCreate")
.def(py::init<const char *, const char *, bool, bool>(), .def(py::init<const std::string &, const std::string &, bool, bool>(),
py::arg("ndi_name") = nullptr, py::arg("groups") = nullptr, py::arg("ndi_name") = nullptr, py::arg("groups") = nullptr,
py::arg("clock_video") = true, py::arg("clock_audio") = true) py::arg("clock_video") = true, py::arg("clock_audio") = true)
.def_readwrite("ndi_name", &NDIlib_send_create_t::p_ndi_name) .def_property("ndi_name", &PySendCreate::getNdiName,
.def_readwrite("groups", &NDIlib_send_create_t::p_groups) &PySendCreate::setNdiName)
.def_readwrite("clock_video", &NDIlib_send_create_t::clock_video) .def_property("groups", &PySendCreate::getGroups,
.def_readwrite("clock_audio", &NDIlib_send_create_t::clock_audio); &PySendCreate::setGroups)
.def_readwrite("clock_video", &PySendCreate::clock_video)
.def_readwrite("clock_audio", &PySendCreate::clock_audio);
m.def("send_create", &NDIlib_send_create, m.def("send_create", &NDIlib_send_create,
py::arg("create_settings") = nullptr); py::arg("create_settings") = nullptr);