Important API | Description |
Init | Initializes GME |
Poll | Triggers event callback |
EnterRoom | Enters room |
EnableMic | Enables mic |
EnableSpeaker | Enables speaker |
AV_OK
will be returned with the value being 0.Poll
API should be called periodically for GME to trigger event callbacks.ITMGContext
object first.ITMGContext* context = ITMGContextGetInstance();context->SetTMGDelegate(this);
AppID
from the Tencent Cloud Console and the openID
as parameters. The openID
uniquely identifies a user with the rules stipulated by the application developer and must be unique in the application (currently, only INT64 is supported).ITMGContext virtual int Init(const char* sdkAppId, const char* openID)
Parameter | Type | Description |
sdkAppId | char* | AppId from the Tencent Cloud Console |
openId | char* | OpenID can only be in Int64 type (converted to char*) with a value greater than 10,000, which is used to identify the user |
#define SDKAPPID3RD "1400089356"cosnt char* openId="10001";ITMGContext* context = ITMGContextGetInstance();context->Init(SDKAPPID3RD, openId);
Poll
API in update
.class ITMGContext {protected:virtual ~ITMGContext() {}public:virtual void Poll()= 0;}
ITMGContextGetInstance()->Poll();
AuthBuffer
for encryption and authentication of relevant features. For release in the production environment, please use the backend deployment key as detailed in Authentication Key.To get authentication for voice messaging and speech-to-text, the room ID parameter must be set to null
.int QAVSDK_AuthBuffer_GenAuthBuffer(unsigned int dwSdkAppID, const char* strRoomID, const char* strOpenID,const char* strKey, unsigned char* strAuthBuffer, unsigned int bufferLength);
Parameter | Type | Description |
dwSdkAppID | int | AppId from the Tencent Cloud Console. |
strRoomID | char* | Room ID, which can contain up to 127 characters (for voice messaging and speech-to-text feature, enter null ). |
strOpenID | char* | User ID, which is the same as openID during initialization. |
strKey | char* | |
strAuthBuffer | char* | Returned authbuff . |
bufferLength | int | Length of the authbuff passed in. 500 is recommended. |
unsigned int bufferLen = 512;unsigned char retAuthBuff[512] = {0};QAVSDK_AuthBuffer_GenAuthBuffer(atoi(SDKAPPID3RD), roomId, "10001", AUTHKEY,retAuthBuff,bufferLen);
ITMG_MAIN_EVENT_TYPE_ENTER_ROOM
message will be received as a callback. Mic and speaker are not enabled by default after room entry. The returned value of AV_OK
indicates a success.
For entering a common voice chat room that does not involve range voice, use the common room entry API. For more information, please see Range Voice.ITMGContext virtual int EnterRoom(const char* roomID, ITMG_ROOM_TYPE roomType, const char* authBuffer, int buffLen)
Parameter | Type | Description |
roomID | char* | Room ID, which can contain up to 127 characters |
roomType | ITMG_ROOM_TYPE | Room audio type |
authBuffer | char* | Authentication key |
buffLen | int | Authentication key length |
ITMGContext* context = ITMGContextGetInstance();context->EnterRoom(roomID, ITMG_ROOM_TYPE_STANDARD, (char*)retAuthBuff,bufferLen);
ITMG_MAIN_EVENT_TYPE_ENTER_ROOM
will be sent and identified in the OnEvent
function.void TMGTestScene::OnEvent(ITMG_MAIN_EVENT_TYPE eventType,const char* data){switch (eventType) {case ITMG_MAIN_EVENT_TYPE_ENTER_ROOM:{// Processbreak;}}}
ITMGAudioCtrl virtual int EnableMic(bool bEnabled)
Parameter | Type | Description |
bEnabled | bool | To enable the mic, set this parameter to true ; otherwise, set it to false . |
ITMGContextGetInstance()->GetAudioCtrl()->EnableMic(true);
ITMGAudioCtrl virtual int EnableSpeaker(bool enable )
Parameter | Type | Description |
enable | bool | To disable the speaker, set this parameter to false ; otherwise, set it to true . |
ITMGContextGetInstance()->GetAudioCtrl()->EnableSpeaker(true);
문제 해결에 도움이 되었나요?