46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
#include <boost/python/module.hpp>
|
|
#include <boost/python/def.hpp>
|
|
#include <stdio.h>
|
|
|
|
|
|
#include "./util/RTCContext.h"
|
|
namespace py = boost::python;
|
|
|
|
int init(const char* selfUserId, const char* selfDisplayName, const char* selfRoomId, boost::python::object callback) {
|
|
RTCContext::instance().setPyCallback(callback);
|
|
bool res = RTCContext::instance().init(selfUserId, selfDisplayName, selfRoomId);
|
|
if (res) {
|
|
return 0;
|
|
} else {
|
|
return -1;
|
|
}
|
|
}
|
|
int initRecv(const char* destRoomId, const char* srcUserId, const int16_t destChannelIndex) {
|
|
bool res = RTCContext::instance().initRecv(destRoomId, srcUserId, destChannelIndex);
|
|
if (res) {
|
|
return 0;
|
|
} else {
|
|
return -1;
|
|
}
|
|
}
|
|
int initSend(const char* destRoomId, const int16_t destChannelIndex) {
|
|
bool res = RTCContext::instance().initSend(destRoomId, destChannelIndex);
|
|
if (res) {
|
|
return 0;
|
|
} else {
|
|
return -1;
|
|
}
|
|
}
|
|
int sendCustomAudioData(const int16_t destChannelIndex, py::object pyData, int32_t sampleRate, uint64_t channelNum,
|
|
uint64_t dataLen) {
|
|
PyObject* pyObj = pyData.ptr();
|
|
void* dataPtr = PyArray_DATA((PyArrayObject*)pyObj);
|
|
return RTCContext::instance().sendCustomAudioData(destChannelIndex, customData, sampleRate, channelNum, dataLen);
|
|
}
|
|
|
|
BOOST_PYTHON_MODULE(rtc_plugins) {
|
|
py::def("init", &init);
|
|
py::def("initRecv", &initRecv);
|
|
py::def("initSend", &initSend);
|
|
py::def("sendCustomAudioData", &sendCustomAudioData);
|
|
} |