This document describes how to quickly integrate the TRTC SDK for Unreal Engine into your project.
Download the SDK and its source code.
Copy the TRTCSDK
folder to the Source/[project_name] directory of your project ([project_name] is the name of your project).
Add the following function to the [project_name].Build.cs file in your project.
// Load the TRTC library for different platforms
private void loadTRTCSDK(ReadOnlyTargetRules Target)
{
string _TRTCSDKPath = Path.GetFullPath(Path.Combine(ModuleDirectory, "TRTCSDK"));
bEnableUndefinedIdentifierWarnings = false;
if (Target.Platform == UnrealTargetPlatform.Android)
{
// Load the Android header file
PublicIncludePaths.Add(Path.Combine(_TRTCSDKPath, "include/Android"));
PrivateDependencyModuleNames.AddRange(new string[] { "Launch" });
// Load the Android APL file
AdditionalPropertiesForReceipt.Add(new ReceiptProperty("AndroidPlugin", Path.Combine(ModuleDirectory, "TRTCSDK", "Android", "APL_armv7.xml")));
string Architecture = "armeabi-v7a";
// string Architecture = "arm64-v8a";
// string Architecture = "armeabi";
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory,"TRTCSDK", "Android", Architecture, "libtraeimp-rtmp.so"));
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory,"TRTCSDK", "Android", Architecture, "libliteavsdk.so"));
}else if (Target.Platform == UnrealTargetPlatform.IOS)
{
// Load the iOS header file
PublicIncludePaths.Add(Path.Combine(_TRTCSDKPath, "include/iOS"));
PublicAdditionalLibraries.AddRange(new string[] {
"resolv",
"z",
"c++",
});
PublicFrameworks.AddRange(
new string[] {
"CoreML",
"VideoToolbox",
"Accelerate",
"CFNetwork",
"OpenGLES",
"AVFoundation",
"CoreTelephony"
}
);
PublicAdditionalFrameworks.Add(new UEBuildFramework( "TXLiteAVSDK_TRTC",_TRTCSDKPath+"/ios/TXLiteAVSDK_TRTC.framework.zip", ""));
}else if(Target.Platform == UnrealTargetPlatform.Mac)
{
// Load the macOS header file
PublicIncludePaths.Add(Path.Combine(_TRTCSDKPath, "include/Mac"));
PublicAdditionalLibraries.AddRange(new string[] {
"resolv",
"z",
"c++",
"bz2",
});
PublicFrameworks.AddRange(
new string[] {
"AppKit",
"IOKit",
"CoreVideo",
"CFNetwork",
"OpenGl",
"CoreGraphics",
"Accelerate",
"CoreFoundation",
"SystemConfiguration",
"AudioToolbox",
"VideoToolbox",
"CoreTelephony",
"CoreWLAN",
"AVFoundation",
"CoreMedia",
"CoreAudio",
"AudioUnit",
"Accelerate",
});
PublicFrameworks.Add(Path.Combine(_TRTCSDKPath, "Mac", "Release","TXLiteAVSDK_TRTC_Mac.framework"));
}else if (Target.Platform == UnrealTargetPlatform.Win64)
{
// Load the 64-bit Windows header file
PublicIncludePaths.Add(Path.Combine(_TRTCSDKPath, "include/win64"));
PublicAdditionalLibraries.Add(Path.Combine(_TRTCSDKPath, "win64", "Release","liteav.lib"));
PublicDelayLoadDLLs.Add(Path.Combine(_TRTCSDKPath, "win64", "Release", "liteav.dll"));
PublicDelayLoadDLLs.Add(Path.Combine(_TRTCSDKPath, "win64", "Release", "LiteAvAudioHook.dll"));
PublicDelayLoadDLLs.Add(Path.Combine(_TRTCSDKPath, "win64", "Release", "LiteAvAudioHookService.dll"));
PublicDelayLoadDLLs.Add(Path.Combine(_TRTCSDKPath, "win64", "Release", "openh264.dll"));
PublicDelayLoadDLLs.Add(Path.Combine(_TRTCSDKPath, "win64", "Release", "TRAE.dll"));
RuntimeDependencies.Add("$(BinaryOutputDir)/liteav.dll", Path.Combine(_TRTCSDKPath, "win64", "Release", "liteav.dll"));
RuntimeDependencies.Add("$(BinaryOutputDir)/LiteAvAudioHook.dll", Path.Combine(_TRTCSDKPath, "win64", "Release", "LiteAvAudioHook.dll"));
RuntimeDependencies.Add("$(BinaryOutputDir)/LiteAvAudioHookService.dll", Path.Combine(_TRTCSDKPath, "win64", "Release", "LiteAvAudioHookService.dll"));
RuntimeDependencies.Add("$(BinaryOutputDir)/openh264.dll", Path.Combine(_TRTCSDKPath, "win64", "Release", "openh264.dll"));
RuntimeDependencies.Add("$(BinaryOutputDir)/TRAE.dll", Path.Combine(_TRTCSDKPath, "win64", "Release", "TRAE.dll"));
}
}
Call the function in the [project_name].Build.cs file.
You have integrated the TRTC SDK into your project and can now use it in the CPP file.#include "ITRTCCloud.h"
// Get a TRTC singleton
#if PLATFORM_ANDROID
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv()) {
void* activity = (void*) FAndroidApplication::GetGameActivityThis();
// For Android, pass in the context object
pTRTCCloud = getTRTCShareInstance(activity);
}
#else
pTRTCCloud = getTRTCShareInstance();
#endif
// Register event callbacks
pTRTCCloud->addCallback(this);
// Get the version number
std::string version = pTRTCCloud->getSDKVersion();
// Enter a room
trtc::TRTCParams params;
params.userId = "123";
params.roomId = 110;
params.sdkAppId = SDKAppID;
params.userSig = GenerateTestUserSig().genTestUserSig(params.userId, SDKAppID, SECRETKEY);
pTRTCCloud->enterRoom(params, trtc::TRTCAppSceneVideoCall);
xxx.app
file compiled in the previous step and select Show Package Contents.<key>NSCameraUsageDescription</key>
<string>Video calls are possible only with camera permission.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Audio calls are possible only with mic access.</string>
Was this page helpful?