@@ -66,6 +66,16 @@ int getBytesPerPixel(GLenum format) {
66
66
}
67
67
}
68
68
69
+ struct SenderInfo {
70
+ SenderInfo (std::string name, unsigned int w, unsigned int h): width(w), height(h), dxShareHandle(NULL ), dwFormat(0 ) {}
71
+
72
+ std::string name;
73
+ unsigned int width;
74
+ unsigned int height;
75
+ HANDLE dxShareHandle;
76
+ DWORD dwFormat;
77
+ };
78
+
69
79
template <typename T>
70
80
py::class_<T> &addCommonDefs (py::class_<T> &clazz) {
71
81
return clazz
@@ -75,7 +85,28 @@ py::class_<T> &addCommonDefs(py::class_<T> &clazz) {
75
85
.def (" getCPUshare" , &T::GetCPUshare)
76
86
.def (" setCPUshare" , &T::SetCPUshare)
77
87
.def (" createOpenGL" , &T::CreateOpenGL)
78
- .def (" closeOpenGL" , &T::CloseOpenGL);
88
+ .def (" closeOpenGL" , &T::CloseOpenGL)
89
+ .def (" setActiveSender" , &T::SetActiveSender)
90
+ .def (" getActiveSender" , [](T& spoutWrapper) -> py::object {
91
+ std::vector<char > senderNameBuf (256 );
92
+ if (spoutWrapper.GetActiveSender (senderNameBuf.data ())) {
93
+ return py::str (senderNameBuf.data ());
94
+ } else {
95
+ return py::none ();
96
+ }
97
+ })
98
+ .def (" getSenderInfo" , [](T& spoutWrapper, std::string senderName) -> py::object {
99
+ unsigned int width;
100
+ unsigned int height;
101
+ HANDLE dxShareHandle;
102
+ DWORD dwFormat;
103
+
104
+ if (spoutWrapper.GetSenderInfo (senderName.c_str (), width, height, dxShareHandle, dwFormat)) {
105
+ return py::cast (new SenderInfo (senderName, width, height));
106
+ } else {
107
+ return py::none ();
108
+ }
109
+ });
79
110
}
80
111
81
112
PYBIND11_MODULE (_spoutgl, m) {
@@ -85,6 +116,11 @@ PYBIND11_MODULE(_spoutgl, m) {
85
116
86
117
.. currentmodule:: SpoutGL
87
118
)pbdoc" ;
119
+
120
+ py::class_<SenderInfo>(m, " SenderInfo" )
121
+ .def_readonly (" name" , &SenderInfo::name)
122
+ .def_readonly (" width" , &SenderInfo::width)
123
+ .def_readonly (" height" , &SenderInfo::height);
88
124
89
125
addCommonDefs (py::class_<SpoutSender>(m, " SpoutSender" )
90
126
.def (py::init<>())
@@ -168,6 +204,7 @@ PYBIND11_MODULE(_spoutgl, m) {
168
204
py::gil_scoped_release release; // Safe? https://mail.python.org/pipermail/python-dev/2018-July/154652.html
169
205
return receiver.ReceiveImage (static_cast <unsigned char *>(bufferInfo.ptr ), glFormat, invert, hostFbo);
170
206
})
207
+ .def (" getSenderList" , &SpoutReceiver::GetSenderList)
171
208
.def (" getSenderName" , &SpoutReceiver::GetSenderWidth)
172
209
.def (" getSenderWidth" , &SpoutReceiver::GetSenderWidth)
173
210
.def (" getSenderHeight" , &SpoutReceiver::GetSenderHeight)
0 commit comments