This commit is contained in:
wangjiyu 2025-04-15 19:32:41 +08:00
parent 8d8c759e3e
commit 5179cc5aa7
2 changed files with 14 additions and 11 deletions

View File

@ -34,10 +34,10 @@ if ret != 0:
while True:
print("recv")
audioData = np.array([0, 1, -1, 0], dtype=np.int16)
ret = rtc_plugins.sendCustomAudioData(srcChannelIndex, audioData, 48000, 1, len(audioData))
if ret != 0:
print(f"resend fail, ret:{ret}")
else:
print("resend succ")
#audioData = np.array([0, 1, -1, 0], dtype=np.int16)
#ret = rtc_plugins.sendCustomAudioData(srcChannelIndex, audioData, 48000, 1, len(audioData))
#if ret != 0:
# print(f"resend fail, ret:{ret}")
#else:
# print("resend succ")
time.sleep(30)

View File

@ -60,6 +60,10 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
mrtc::MRTCAudioFrame& audioFrame,
mrtc::MRTCAudioSourceType audioSourceType)
{
namespace np = boost::python::numpy;
namespace py = boost::python;
Py_Initialize(); // 初始化 Python
np::initialize();
std::cout << "=== 开始音频处理 ===" << std::endl;
std::cout << "audioFrame:" << audioFrame.dataCount << "," << audioFrame.sampleRate << "," <<
audioFrame.numChannels << "," << audioFrame.channelIndex << std::endl;
@ -70,7 +74,6 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
PyGILState_STATE gstate = PyGILState_Ensure();
#endif
namespace py = boost::python;
try {
// 2. 输入参数校验
std::cout << "[2] 检查输入参数..." << std::endl;
@ -258,10 +261,10 @@ bool RTCContext::init(const char* selfUserId, const char* selfDisplayName, const
std::cout << "RTCContext::instance().registerListener() failed" << std::endl;
return false;
}
namespace py = boost::python;
namespace np = boost::python::numpy;
Py_Initialize(); // 初始化 Python
np::initialize();
//namespace py = boost::python;
//namespace np = boost::python::numpy;
//Py_Initialize(); // 初始化 Python
//np::initialize();
return true;
}