This commit is contained in:
wangjiyu 2025-04-15 15:35:24 +08:00
parent 16962bf871
commit d10c751a06
2 changed files with 24 additions and 53 deletions

View File

@ -6,29 +6,30 @@ void RTCContext::onRoom(uint32_t typeId, RTCENGINE_NAMESPACE::MRTCRoomInfo& room
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
isOnRoom_ = true; isOnRoom_ = true;
} }
void RTCContext::onConsumer(uint32_t msgId, const char* roomId, const char* peerId, RTCENGINE_NAMESPACE::MRTCConsumerInfo& consumerInfo) { void RTCContext::onConsumer(uint32_t msgId, const char* roomId, const char* peerId,
std::cout << "RTCContext::onConsumer():" << consumerInfo.roomId << "," << consumerInfo.displayName << "," << consumerInfo.channelIndex; RTCENGINE_NAMESPACE::MRTCConsumerInfo& consumerInfo) {
std::lock_guard<std::mutex> lock(mutex_); std::cout << "RTCContext::onConsumer():" << consumerInfo.roomId << "," << consumerInfo.displayName << ","
isOnConsumer_ = true; << consumerInfo.channelIndex << std::endl;
std::cout << "registerSoundLevelListener" << std::endl; if (isRecv_) {
int16_t ret1 = rtcEngine_->registerSoundLevelListener(mrtc::TYPE_AUDIO_SOURCE_CUSTOM, consumerInfo.roomId, std::lock_guard<std::mutex> lock(mutex_);
peerId, consumerInfo.channelIndex, this); std::cout << "registerSoundLevelListener" << std::endl;
if (0 != ret1) int16_t ret1 = rtcEngine_->registerSoundLevelListener(mrtc::TYPE_AUDIO_SOURCE_CUSTOM, consumerInfo.roomId,
{ peerId, consumerInfo.channelIndex, this);
std::cout << "RTCContext::instance().registerSoundLevelListener() inUser failed, ret:" << ret1; if (0 != ret1) {
return; std::cout << "RTCContext::instance().registerSoundLevelListener() inUser failed, ret:" << ret1;
} return;
}
std::cout << "muteAudio" << std::endl; std::cout << "muteAudio" << std::endl;
int16_t ret2 = rtcEngine_->muteAudio(consumerInfo.roomId, peerId, mrtc::TYPE_AUDIO_SOURCE_CUSTOM, false, consumerInfo.channelIndex); int16_t ret2 = rtcEngine_->muteAudio(consumerInfo.roomId, peerId, mrtc::TYPE_AUDIO_SOURCE_CUSTOM,
if (0 != ret2) false, consumerInfo.channelIndex);
{ if (0 != ret2) {
std::cout << "RTCContext::instance().muteAudio() failed, ret:" << ret2; std::cout << "RTCContext::instance().muteAudio() failed, ret:" << ret2;
return; return;
} }
std::cout << "init recv succ" << std::endl; std::cout << "init recv succ" << std::endl;
//std::cout << "RTCContext::onConsumer()" << std::endl; }
} }
void RTCContext::onRender(const char* roomId, const char* peerId, void RTCContext::onRender(const char* roomId, const char* peerId,
RTCENGINE_NAMESPACE::MRTCVideoSourceType sourceType, const RTCENGINE_NAMESPACE::MRTCVideoFrame& videoFrame) { RTCENGINE_NAMESPACE::MRTCVideoSourceType sourceType, const RTCENGINE_NAMESPACE::MRTCVideoFrame& videoFrame) {
@ -241,37 +242,7 @@ bool RTCContext::init(const char* selfUserId, const char* selfDisplayName, const
} }
bool RTCContext::initRecv(const char* destRoomId, const char* srcUserId, const int16_t destChannelIndex) bool RTCContext::initRecv(const char* destRoomId, const char* srcUserId, const int16_t destChannelIndex)
{ {
std::cout << "initRecv, numpyApi_:" << numpyApi_[93] << std::endl; isRecv_ = true;
if (!numpyApi_ || !numpyApi_[93]) { // 93是PyArray_SimpleNew的偏移量
std::cout << "numpyApi_ is null in initRecv" << std::endl;
} else {
std::cout << "numpyApi_ is not null in initRecv" << std::endl;
}
/*
while (!isOnConsumer_)
{
std::cout << "wait for OnConsumer" << std::endl;
sleep(3);
}
std::cout << "registerSoundLevelListener" << std::endl;
int16_t ret1 = rtcEngine_->registerSoundLevelListener(mrtc::TYPE_AUDIO_SOURCE_CUSTOM, destRoomId,
srcUserId, destChannelIndex, this);
if (0 != ret1)
{
std::cout << "RTCContext::instance().registerSoundLevelListener() inUser failed, ret:" << ret1;
return false;
}
std::cout << "muteAudio" << std::endl;
int16_t ret2 = rtcEngine_->muteAudio(destRoomId, srcUserId, mrtc::TYPE_AUDIO_SOURCE_CUSTOM, false, destChannelIndex);
if (0 != ret2)
{
std::cout << "RTCContext::instance().muteAudio() failed, ret:" << ret2;
return false;
}
std::cout << "init recv succ" << std::endl;
*/
return true; return true;
} }

View File

@ -104,7 +104,7 @@ private:
mrtc::IMRTCEngine * rtcEngine_ = nullptr; mrtc::IMRTCEngine * rtcEngine_ = nullptr;
void* pData_ = nullptr; void* pData_ = nullptr;
bool isOnRoom_ = false; bool isOnRoom_ = false;
bool isOnConsumer_ = false; bool isRecv_ = false;
bool isJoinMultiRoom_ = false; bool isJoinMultiRoom_ = false;
bool isMultiRoom_ = false; bool isMultiRoom_ = false;
boost::python::object pyCallback_; boost::python::object pyCallback_;