.vcxproj
file resides..sln
project file, Solution Explorer in the right toolbar > Right-click menu for the project > Properties, and perform the following configurations:$(ProjectDir)SDK\\CPlusPlus\\Win64\\include
and $(ProjectDir)SDK\\CPlusPlus\\Win64\\include\\TRTC
.$(ProjectDir)SDK\\CPlusPlus\\Win64\\lib
.liteav.lib
.copy /Y $(ProjectDir)SDK\\CPlusPlus\\Win64\\lib\\*.dll $(OutDir)
.#include "ITRTCCloud.h"
ITRTCCloud: undefined identifier
.OnInitDialog
function:ITRTCCloud * pTRTCCloud = getTRTCShareInstance();CString szText;szText.Format(L"SDK version: %hs", pTRTCCloud->getSDKVersion());CWnd *pStatic = GetDlgItem(IDC_STATIC);pStatic->SetWindowTextW(szText);
"ITRTCCloud.h"
in the 'PROJECTNAME'.h file, make the class in this file publicly inherit from CWinApp and ITRTCCloudCallback, and declare listening events and TRTCCloud member variables.#include "ITRTCCloud.h" // 引入 TRTC 头文件// Replace the 'CLASSNAME' with your own project class nameclass CLASSNAME : public CWinApp, public ITRTCCloudCallback{public:// Replace the 'CLASSNAME' with your own project class nameCLASSNAME();// Overridespublic:virtual BOOL InitInstance();virtual void onError(TXLiteAVError errCode, const char* errMsg, void* extraInfo) override; // Listen for the 'onError' eventvirtual void onWarning(TXLiteAVWarning warningCode, const char* warningMsg, void* extrainfo) override; // Listen for the 'onWarning' eventvirtual void onEnterRoom(int result) override; // Listen for the 'onEnterRoom' eventvirtual void onExitRoom(int reason) override; // Listen for the 'onExitRoom' event// Get the TRTCCloud instancestatic CRTCWindowsApp* GetInstance(){return static_cast<CRTCWindowsApp*>(AfxGetApp());}// ImplementationDECLARE_MESSAGE_MAP()public:ITRTCCloud* trtc_cloud_; // Declare the TRTCCloud member variable};
getTRTCShareInstance
in the InitInstance
function of the 'PROJECTNAME'.h file.// Initialize the TRTCCloud instance and add event listeningtrtc_cloud_ = getTRTCShareInstance();trtc_cloud_->addCallback(this);
SetRegistryKey(_T("Local AppWizard-Generated Applications"))
method.// Handle the listening events, and replace 'CLASSNAME' with your own project class namevoid CLASSNAME::onError(TXLiteAVError errCode, const char* errMsg, void* extraInfo) {printf("errCode: %d, errMsg: %s, extraInfo: %p\\n", errCode, errMsg, extraInfo); // Listen for the "onError" event and print the corresponding information}void CLASSNAME::onWarning(TXLiteAVWarning warningCode, const char* warningMsg, void* extrainfo) {printf("warningCode: %d, warningMsg: %s, extraInfo: %p\\n", warningCode, warningMsg, extraInfo); // Listen for the "onWarning" event and print the corresponding information}void CLASSNAME::onEnterRoom(int result) { // Listen for the "onEnterRoom" event and print the corresponding informationif (result > 0) {printf("Enter room succeed");}else {printf("Enter room failed");}}void CLASSNAME::onExitRoom(int reason) { // Listen for the "onExitRoom" event and print the corresponding informationif (reason == 0) {printf("Exit current room by calling the 'exitRoom' api of sdk ...");} else if (reason == 1) {printf("Kicked out of the current room by server through the restful api...");} else if (reason == 2) {printf("Current room is dissolved by server through the restful api...");}}
TRTCParams
and call enterRoom
to successfully enter the room, which is usually called after clicking the Start Call button.Parameter | Type | Description |
sdkAppId | number | |
userId | string | User ID specified by you. |
userSig | string | |
roomId | number | Room ID specified by you, usually a unique room ID. |
// Replace the 'CLASSNAME' with your own project class namevoid CLASSNAME::OnBnClickedButton() {// 将以下 trtcParams 参数修改为自己的参数liteav::TRTCParams trtcParams;trtcParams.sdkAppId = 1400000123;trtcParams.userId = "denny";trtcParams.userSig = "xxx";trtcParams.roomId = 123321;// For multi-party video calls, `TRTC_APP_SCENE_LIVE` is recommendedtrtc_cloud_->enterRoom(trtcParams, liteav::TRTCAppSceneLIVE);}
setLocalRenderParams
for local preview, then call startLocalPreview
for local preview. After successfully calling enterRoom
, the stream push will start.// Replace the 'CLASSNAME' with your own project class namevoid CLASSNAME::OnBnClickedButton(){// Set local preview rendering parametersliteav::TRTCRenderParams render_params;render_params.mirrorType = liteav::TRTCVideoMirrorType_Enable;render_params.fillMode = TRTCVideoFillMode_Fill;ITRTCCloud* trtcCloud = CRTCWindowsApp::GetInstance()->trtc_cloud_;trtcCloud->setLocalRenderParams(render_params);// Initialize pLocalVideoViewCWnd* pLocalVideoView = GetDlgItem(AFX_IDC_PICTURE);if (pLocalVideoView != nullptr) {auto local_view = (liteav::TXView)(pLocalVideoView->GetSafeHwnd());// Preview the collected content locallytrtcCloud->startLocalPreview(local_view);}}
stopLocalPreview
to turn off the camera preview and stop pushing local video information.// 将 'CLASSNAME' 替换为您自己的项目类名void CLASSNAME::OnBnClickedButton(){trtcCloud->stopLocalPreview();}
startLocalAudio
to turn on microphone capture. Select one of the following sound Quality
parameters according to your requirements.// Enable microphone acquisition and set the current scene to: Voice mode// For high noise suppression capability, strong and weak network resistanceITRTCCloud* trtcCloud = CRTCWindowsApp::GetInstance()->trtc_cloud_;trtcCloud->startLocalAudio(TRTCAudioQualitySpeech);// Enable microphone acquisition, and set the current scene to: Music mode// For high fidelity acquisition, low sound quality loss, recommended to use with professional sound cardsITRTCCloud* trtcCloud = CRTCWindowsApp::GetInstance()->trtc_cloud_;trtcCloud->startLocalAudio(TRTCAudioQualityMusic);
stopLocalAudio
to turn off microphone collection and stop pushing local audio information.ITRTCCloud* trtcCloud = CRTCWindowsApp::GetInstance()->trtc_cloud_;trtcCloud->stopLocalAudio();
onUserVideoAvailable(userId, true)
notification, it means that there are video frames available to play in the road screen.startRemoteView/stopRemoteView
to play or stop the remote video.// Play the videoCWnd* pLocalVideoView = GetDlgItem(AFX_IDC_PICTURE);if (pLocalVideoView != nullptr) {auto local_view = (liteav::TXView)(pLocalVideoView->GetSafeHwnd());ITRTCCloud* trtcCloud = CRTCWindowsApp::GetInstance()->trtc_cloud_;trtcCloud->startRemoteView("denny", liteav::TRTCVideoStreamTypeBig, video_view); // Start playing denny's video}// Stop the videoITRTCCloud* trtcCloud = CRTCWindowsApp::GetInstance()->trtc_cloud_;trtcCloud->stopRemoteView("denny", liteav::TRTCVideoStreamTypeBig); // Stop playing denny's videotrtcCloud->stopAllRemoteView(); // Stop all videos
muteRemoteAudio
to mute or unmute the remote side's sound.// MuteITRTCCloud* trtcCloud = CRTCWindowsApp::GetInstance()->trtc_cloud_;trtcCloud->muteRemoteAudio("denny", true); // Mute dennytrtcCloud->muteAllRemoteAudio(true); // Mute all remote users// UnmuteITRTCCloud* trtcCloud = CRTCWindowsApp::GetInstance()->trtc_cloud_;trtcCloud->muteRemoteAudio("denny", false); // Unmute dennytrtcCloud->muteAllRemoteAudio(false); // Unmute all remote users
exitRoom
to exit the current room, and the TRTC SDK will notify you after check-out via the onExitRoom
callback event.// Exit current room, and replace the 'CLASSNAME' with your own project class namevoid CLASSNAME::OnBnClickedButton(){ITRTCCloud* trtcCloud = CRTCWindowsApp::GetInstance()->trtc_cloud_;trtcCloud->exitRoom();}
info_rtc@tencent.com
.
Was this page helpful?