This document describes how to get started with the GME APIs for Unreal.
This document only describes the most important APIs to help you get started with GME. For more information on APIs, please see the API documentation.
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.To use the voice feature, get the ITMGContext
object first.
ITMGContext* context = ITMGContextGetInstance();
context->SetTMGDelegate(this);
For more information on how to get parameters, please see Access Guide.
This API requires the 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).
The SDK must be initialized so that a room can be entered.
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 |
std::string appid = TCHAR_TO_UTF8(CurrentWidget->editAppID->GetText().ToString().operator*());
std::string userId = TCHAR_TO_UTF8(CurrentWidget->editUserID->GetText().ToString().operator*());
ITMGContextGetInstance()->Init(appid.c_str(), userId.c_str());
Event callbacks can be triggered by periodically calling the Poll
API in Tick
.
class ITMGContext {
protected:
virtual ~ITMGContext() {}
public:
virtual void Poll()= 0;
}
// Declaration in the header file
virtual void Tick(float DeltaSeconds);
// Code implementation
void AUEDemoLevelScriptActor::Tick(float DeltaSeconds)
{
ITMGContextGetInstance()->Poll();
}
Generate 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* | Permission key from the Tencent Cloud Console. |
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);
When a client enters a room with the generated authentication information, the 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.
ITMGContext virtual int EnterRoom(const char* roomID, ITMG_ROOM_TYPE roomType, const char* authBuff, 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 |
For more information on how to choose a room audio type, please see Sound Quality Selection.
ITMGContext* context = ITMGContextGetInstance();
context->EnterRoom(roomID, ITMG_ROOM_TYPE_STANDARD, (char*)retAuthBuff,bufferLen);
After the client enters the room, the message 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:
{
// Process
break;
}
}
}
This API is used to enable/disable the mic. Mic and speaker are not enabled by default after room entry.
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);
This API is used to enable/disable the speaker.
ITMGAudioCtrl virtual int EnableSpeaker(bool enabled)
Parameter | Type | Description |
---|---|---|
enable | bool | To disable the speaker, set this parameter to false ; otherwise, set it to true . |
ITMGContextGetInstance()->GetAudioCtrl()->EnableSpeaker(true);
Was this page helpful?