debug
This commit is contained in:
parent
f5840b46d2
commit
a4713448d7
2
build.sh
2
build.sh
|
@ -1 +1 @@
|
||||||
g++ -shared -fPIC -std=c++11 $(python3 -m pybind11 --includes) -I./include -L./lib -L/usr/lib/x86_64-linux-gnu -lMRTCEngine -lpython3.10 -Wl,-rpath='$ORIGIN/lib' -o rtc_plugins$(python3-config --extension-suffix) rtc_plugins.cpp util/RTCContext.cpp
|
g++ -shared -fPIC -std=c++17 $(python3 -m pybind11 --includes) -I./include -L./lib -L/usr/lib/x86_64-linux-gnu -lMRTCEngine -lpython3.10 -Wl,-rpath='$ORIGIN/lib' -o rtc_plugins$(python3-config --extension-suffix) rtc_plugins.cpp util/RTCContext.cpp
|
||||||
|
|
|
@ -1,26 +1,11 @@
|
||||||
#define IMPLEMENT_NUMPY_API
|
|
||||||
#include "util/RTCContext.h"
|
#include "util/RTCContext.h"
|
||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
#include <pybind11/numpy.h> // pybind11 的 NumPy 支持
|
#include <pybind11/numpy.h> // pybind11 的 NumPy 支持
|
||||||
#include <pybind11/detail/common.h>
|
|
||||||
|
|
||||||
namespace py = pybind11;
|
namespace py = pybind11;
|
||||||
#include "util/RTCContext.h"
|
#include "util/RTCContext.h"
|
||||||
|
|
||||||
// 初始化 NumPy(适配 pybind11)
|
|
||||||
void init_numpy() {
|
|
||||||
if (import_array() < 0) {
|
|
||||||
throw py::bind_already_set(); // 自动捕获 NumPy 初始化错误
|
|
||||||
}
|
|
||||||
std::cout << "NumPy API addr: " << PyArray_API << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
int init(const char* selfUserId, const char* selfDisplayName, const char* selfRoomId, py::object callback) {
|
int init(const char* selfUserId, const char* selfDisplayName, const char* selfRoomId, py::object callback) {
|
||||||
if (!PyArray_API) {
|
|
||||||
std::cout << "PyArray_API is null in outer init" << std::endl;
|
|
||||||
} else {
|
|
||||||
std::cout << "PyArray_API is not null in outer init" << std::endl;
|
|
||||||
}
|
|
||||||
RTCContext::instance().setPyCallback(callback);
|
RTCContext::instance().setPyCallback(callback);
|
||||||
bool res = RTCContext::instance().init(selfUserId, selfDisplayName, selfRoomId);
|
bool res = RTCContext::instance().init(selfUserId, selfDisplayName, selfRoomId);
|
||||||
if (res) {
|
if (res) {
|
||||||
|
@ -30,11 +15,6 @@ int init(const char* selfUserId, const char* selfDisplayName, const char* selfRo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int initRecv(const char* destRoomId, const char* srcUserId, const int16_t destChannelIndex) {
|
int initRecv(const char* destRoomId, const char* srcUserId, const int16_t destChannelIndex) {
|
||||||
if (!PyArray_API) {
|
|
||||||
std::cout << "PyArray_API is null in outer initRecv" << std::endl;
|
|
||||||
} else {
|
|
||||||
std::cout << "PyArray_API is not null in outer initRecv" << std::endl;
|
|
||||||
}
|
|
||||||
bool res = RTCContext::instance().initRecv(destRoomId, srcUserId, destChannelIndex);
|
bool res = RTCContext::instance().initRecv(destRoomId, srcUserId, destChannelIndex);
|
||||||
if (res) {
|
if (res) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -84,7 +64,6 @@ int16_t getDataCount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_MODULE(rtc_plugins, m) {
|
PYBIND11_MODULE(rtc_plugins, m) {
|
||||||
init_numpy();
|
|
||||||
// 可选:暴露 RetAudioFrame 类(需额外绑定)
|
// 可选:暴露 RetAudioFrame 类(需额外绑定)
|
||||||
py::class_<RetAudioFrame>(m, "RetAudioFrame")
|
py::class_<RetAudioFrame>(m, "RetAudioFrame")
|
||||||
.def_readwrite("data", &RetAudioFrame::data)
|
.def_readwrite("data", &RetAudioFrame::data)
|
||||||
|
|
|
@ -258,7 +258,7 @@ RetAudioFrame RTCContext::getData() {
|
||||||
}
|
}
|
||||||
return {}; // 返回空对象
|
return {}; // 返回空对象
|
||||||
}
|
}
|
||||||
np::ndarray RTCContext::getNumpyData() {
|
py::array_t<int16_t> RTCContext::getNumpyData() {
|
||||||
std::cout << "step1" << std::endl;
|
std::cout << "step1" << std::endl;
|
||||||
std::lock_guard<std::mutex> lock(dataMutex_);
|
std::lock_guard<std::mutex> lock(dataMutex_);
|
||||||
RetAudioFrame frame = getData();
|
RetAudioFrame frame = getData();
|
||||||
|
|
Loading…
Reference in New Issue