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: while True:
print("recv") print("recv")
audioData = np.array([0, 1, -1, 0], dtype=np.int16) #audioData = np.array([0, 1, -1, 0], dtype=np.int16)
ret = rtc_plugins.sendCustomAudioData(srcChannelIndex, audioData, 48000, 1, len(audioData)) #ret = rtc_plugins.sendCustomAudioData(srcChannelIndex, audioData, 48000, 1, len(audioData))
if ret != 0: #if ret != 0:
print(f"resend fail, ret:{ret}") # print(f"resend fail, ret:{ret}")
else: #else:
print("resend succ") # print("resend succ")
time.sleep(30) time.sleep(30)

View File

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