This commit is contained in:
wangjiyu 2025-04-15 17:19:02 +08:00
parent 012a95f475
commit 2fd9f33a68
2 changed files with 9 additions and 5 deletions

View File

@ -39,12 +39,11 @@ void RTCContext::onCallBackMessage(uint32_t msgId, const char* msg) {
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
if (msgId == (uint32_t)mrtc::JOIN_MULTI_ROOM_SUCCESS) { if (msgId == (uint32_t)mrtc::JOIN_MULTI_ROOM_SUCCESS) {
std::cout << "receive join multi room callback" << msgId; std::cout << "receive join multi room callback" << msgId << std::endl;
isJoinMultiRoom_ = true; isJoinMultiRoom_ = true;
} }
std::cout << "RTCContext::onCallBackMessage(), msgId:" << msgId << ", msg:" << msg; std::cout << "RTCContext::onCallBackMessage(), msgId:" << msgId << ", msg:" << msg << std::endl;
//std::cout << "RTCContext::onCallBackMessage()" << std::endl;
} }
void RTCContext::onCallBackCustomData(RTCENGINE_NAMESPACE::MRTCCustomDataObject object) { void RTCContext::onCallBackCustomData(RTCENGINE_NAMESPACE::MRTCCustomDataObject object) {
//std::cout << "RTCContext::onCallBackCustomData(), obj:" << object.peerId << "," << object.data << "," << object.data_length; //std::cout << "RTCContext::onCallBackCustomData(), obj:" << object.peerId << "," << object.data << "," << object.data_length;
@ -70,7 +69,7 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
std::cerr << "Python 解释器未初始化!" << std::endl; std::cerr << "Python 解释器未初始化!" << std::endl;
return; return;
} }
PyGILState_STATE gstate = PyGILState_Ensure(); //PyGILState_STATE gstate = PyGILState_Ensure();
namespace py = boost::python; namespace py = boost::python;
try { try {
@ -109,7 +108,6 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
} }
*/ */
//PyGILState_STATE gstate = PyGILState_Ensure();
np::ndarray audioArray = np::from_data( np::ndarray audioArray = np::from_data(
audioFrame.data, // 数据指针 audioFrame.data, // 数据指针
dtype, // 数据类型 (int16) dtype, // 数据类型 (int16)
@ -181,6 +179,7 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
PyGILState_Release(gstate); PyGILState_Release(gstate);
std::cerr << "Audio process error: " << e.what() << std::endl; std::cerr << "Audio process error: " << e.what() << std::endl;
} }
PyGILState_Release(gstate);
} }
void RTCContext::onProducer(uint32_t msgId, mrtc::MRTCProducerInfo& info) void RTCContext::onProducer(uint32_t msgId, mrtc::MRTCProducerInfo& info)
@ -290,6 +289,9 @@ bool RTCContext::initSend(const char* srcRoomId, const char* destRoomId, const i
std::cout << "init send succ" << std::endl; std::cout << "init send succ" << std::endl;
return true; return true;
} }
bool RTCContext::initGIL() {
isGIL_ = true;
}
void RTCContext::destorySend(const int16_t selfChannelIndex) void RTCContext::destorySend(const int16_t selfChannelIndex)
{ {

View File

@ -85,6 +85,7 @@ public:
bool init(const char* selfUserId, const char* selfDisplayName, const char* selfRoomId); bool init(const char* selfUserId, const char* selfDisplayName, const char* selfRoomId);
bool initRecv(const char* destRoomId, const char* srcUserId, const int16_t destChannelIndex); bool initRecv(const char* destRoomId, const char* srcUserId, const int16_t destChannelIndex);
bool initSend(const char* srcRoomId, const char* destRoomId, const int16_t destChannelIndex, uint8_t channelNum); bool initSend(const char* srcRoomId, const char* destRoomId, const int16_t destChannelIndex, uint8_t channelNum);
bool initGIL();
void* getpData() const; void* getpData() const;
void setpData(void* pData); void setpData(void* pData);
@ -107,6 +108,7 @@ private:
bool isRecv_ = false; bool isRecv_ = false;
bool isJoinMultiRoom_ = false; bool isJoinMultiRoom_ = false;
bool isMultiRoom_ = false; bool isMultiRoom_ = false;
bool isGIL_ = false;
boost::python::object pyCallback_; boost::python::object pyCallback_;
void ** numpyApi_; void ** numpyApi_;
void onRoom(uint32_t typeId, RTCENGINE_NAMESPACE::MRTCRoomInfo& roomInfo); void onRoom(uint32_t typeId, RTCENGINE_NAMESPACE::MRTCRoomInfo& roomInfo);