tencent cloud

Game Multimedia Engine

릴리스 노트
제품 소개
제품 개요
장점 및 특징
제품 기능
응용 시나리오
보안 및 컴플라이언스 인증
사용자 튜토리얼
SDK 다운로드 가이드
제품 기능 데모
기본 기능 데모
시나리오 기반 Demo
콘솔 가이드
사용량 조회
서비스 활성화
시작하기
Quick Integration of SDK
Quick Integration of Sample Project
기본 기능 개발 가이드
인증 키
실시간 음성 채팅 역할 설정
음질 선택
고급 기능 개발 가이드
서버 녹음
레인지 보이스
3D 음향 효과
음향 효과 및 반주
네트워크 오디오 스트림 포워딩 라우팅
사용자 지정 메시지 채널
회사 방화벽 제한을 해결하는 방법
Language Parameter Reference List
GME 채팅방 관리 통합
클라이언트 API
Unity SDK
SDK for Unreal Engine
Cocos2D SDK
SDK for Windows
SDK for iOS
SDK for Android
SDK for macOS
H5 SDK
Electron SDK
SDK for Flutter
SDK Version Upgrade Guide
에러 코드
Toolchain
Server APIs
History
Introduction
API Category
Usage APIs
Recording APIs
Making API Requests
Voice Chat APIs
Application APIs
Data Types
Error Codes
FAQ
제품 기능
문제 해결 가이드
과금
Sample Project 사용 문제
일반 문제
인증
방 입장 실패
사운드 및 오디오
네트워크
음성을 텍스트로 변환
프로그램 내보내기
Service Agreement
Service Level Agreement
문의하기
용어집
GME 정책
데이터 처리 및 보안 계약
개인 정보 보호 정책

Getting Started

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2024-01-18 15:11:45
This document describes how to get started with the GME APIs for Cocos2d.
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
Configure your project before using GME; otherwise, the SDK will not take effect.
After a GME API is called successfully, AV_OK will be returned with the value being 0.
GME APIs should be called in the same thread.
The Poll API should be called periodically for GME to trigger event callbacks.
For GME callback messages, please see the callback message list.
Operation on devices should be performed after successful room entry.
For detailed error codes, please see Error Codes.

Directions for Quick Access

1. Get a singleton

To use the voice feature, get the ITMGContext object first.

Sample code

ITMGContext* context = ITMGContextGetInstance();
context->SetTMGDelegate(this);

2. Initialize the SDK

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).
Note:
The SDK must be initialized so that a room can be entered

Function prototype

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

Sample code

#define SDKAPPID3RD "1400089356"
cosnt char* openId="10001";
ITMGContext* context = ITMGContextGetInstance();
context->Init(SDKAPPID3RD, openId);

3. Trigger event callback

Event callbacks can be triggered by periodically calling the Poll API in update.

Function prototype

class ITMGContext {
protected:
virtual ~ITMGContext() {}

public:
virtual void Poll()= 0;
}

Sample code

ITMGContextGetInstance()->Poll();

4. Authenticate

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.

Function prototype

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.

Sample code

unsigned int bufferLen = 512;
unsigned char retAuthBuff[512] = {0};
QAVSDK_AuthBuffer_GenAuthBuffer(atoi(SDKAPPID3RD), roomId, "10001", AUTHKEY,retAuthBuff,bufferLen);

5. Enter a room

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. 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.

Function prototype

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
For more information on how to choose a room audio type, please see Sound Quality Selection.

Sample code

ITMGContext* context = ITMGContextGetInstance();
context->EnterRoom(roomID, ITMG_ROOM_TYPE_STANDARD, (char*)retAuthBuff,bufferLen);

6. Receive callback for room entry

After the client enters the room, the message ITMG_MAIN_EVENT_TYPE_ENTER_ROOM will be sent and identified in the OnEvent function.

Sample code


void TMGTestScene::OnEvent(ITMG_MAIN_EVENT_TYPE eventType,const char* data){
switch (eventType) {
case ITMG_MAIN_EVENT_TYPE_ENTER_ROOM:
{
// Process
break;
}
}
}

7. Enable/Disable the mic

This API is used to enable/disable the mic. Mic and speaker are not enabled by default after room entry.

Function prototype

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.

Sample code

ITMGContextGetInstance()->GetAudioCtrl()->EnableMic(true);

8. Enable/Disable the speaker

This API is used to enable/disable the speaker.

Function prototype

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.

Sample code

ITMGContextGetInstance()->GetAudioCtrl()->EnableSpeaker(true);


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백