diff --git a/src/util/RTCContext.cpp b/src/util/RTCContext.cpp index 639e9e7..658cf5a 100644 --- a/src/util/RTCContext.cpp +++ b/src/util/RTCContext.cpp @@ -13,6 +13,8 @@ void RTCContext::onRoom(uint32_t typeId, RTCENGINE_NAMESPACE::MRTCRoomInfo& room } void RTCContext::onConsumer(uint32_t msgId, const char* roomId, const char* peerId, RTCENGINE_NAMESPACE::MRTCConsumerInfo& consumerInfo) { LOG_DEBUG << "RTCContext::onConsumer():" << consumerInfo.roomId << "," << consumerInfo.displayName << "," << consumerInfo.channelIndex; + std::lock_guard lock(mutex_); + isOnConsumer = true; //LOG_DEBUG << "RTCContext::onConsumer()"; } void RTCContext::onRender(const char* roomId, const char* peerId, @@ -97,9 +99,9 @@ bool RTCContext::init() } bool RTCContext::initRecv() { - while (!isOnRoom) + while (!isOnConsumer) { - LOG_DEBUG << "wait for room"; + LOG_DEBUG << "wait for OnConsumer"; sleep(3); } LOG_DEBUG << "registerSoundLevelListener"; @@ -110,7 +112,6 @@ bool RTCContext::init() LOG_DEBUG << "RTCContext::instance().registerSoundLevelListener() inUser failed, ret:" << ret1; return false; } - /* LOG_DEBUG << "muteAudio"; int16_t ret2 = rtcEngine_->muteAudio(inRoomId, inUserId, mrtc::TYPE_AUDIO_SOURCE_CUSTOM, false, inChannelIndex); if (0 != ret2) @@ -118,7 +119,6 @@ bool RTCContext::init() LOG_DEBUG << "RTCContext::instance().muteAudio() failed, ret:" << ret2; return false; } - */ LOG_DEBUG << "init recv succ"; return true; @@ -127,7 +127,7 @@ bool RTCContext::init() { while (!isOnRoom) { - LOG_DEBUG << "wait for room"; + LOG_DEBUG << "wait for OnRoom"; sleep(3); } LOG_DEBUG << "join multi room"; diff --git a/src/util/RTCContext.h b/src/util/RTCContext.h index dae6efe..cbd40f5 100644 --- a/src/util/RTCContext.h +++ b/src/util/RTCContext.h @@ -7,6 +7,7 @@ #include // C++17 #include "trantor/utils/Logger.h" namespace fs = std::filesystem; +#define ENV_PRODUCT //#define SEND_MODE class RTCContext : @@ -18,8 +19,18 @@ class RTCContext : public RTCENGINE_NAMESPACE::IMRTCProduerCallBack { public: +#ifdef ENV_PRODUCT + const char* appid = "1357389261426393088"; + const char* appSecrectKey = "gytr3qrrznsgac2lbdchfg0l4ltqx4x3nf4my0yt1dbx7riz1gnnsnhblrlc2j4o1lx4vdu495lifv8s7jyrmfxtq9lif9rusxnur5smdn5cjopstxp5dim7p52xrezp"; + const char* domain = "rtc.migu.cn"; + const unsigned short port = 34443; +#else const char* appid = "1357413779192676352"; const char* appSecrectKey = "q04ex8bivag3mn8ncf504t5lw4asldbc1k2rfbhoy54u7lsqqkmkzp33x0h4d9ww9z3f1deiel34m191lj4k5dc7utidom9s1izg88jhouv1bwy62q372ly9dmd63g4u"; + const char* domain = "dorytest.migu.cn"; + const unsigned short port = 34443; +#endif + #ifdef SEND_MODE const char* inUserId = "inuser1"; #else @@ -36,9 +47,8 @@ public: const char* inRoomId = outRoomId; const int16_t inChannelIndex = outChannelIndex; #endif - const char* domain = "dorytest.migu.cn"; - const unsigned short port = 34443; bool isOnRoom = false; + bool isOnConsumer = false; static RTCContext& instance() {