本文主要介绍如何快速地将腾讯云 TRTC SDK(Unreal Engine)集成到您的项目中,只要按照如下步骤进行配置,就可以完成 SDK 的集成工作。
下载 SDK 及配套的 SDK 源码。
解压后,把项目中的 TRTCSDK
文件夹拷贝到您项目中的 Source/[project_name] 目录下,其中 [project_name] 表示你项目的名称。
编辑你项目中的 [project_name].Build.cs文件。添加下面函数
// 加载各个平台TRTC底层库
private void loadTRTCSDK(ReadOnlyTargetRules Target)
{
string _TRTCSDKPath = Path.GetFullPath(Path.Combine(ModuleDirectory, "TRTCSDK"));
bEnableUndefinedIdentifierWarnings = false;
if (Target.Platform == UnrealTargetPlatform.Android)
{
// 加载Android头文件
PublicIncludePaths.Add(Path.Combine(_TRTCSDKPath, "include/Android"));
PrivateDependencyModuleNames.AddRange(new string[] { "Launch" });
// 加载Android APL文件
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)
{
// 加载iOS头文件
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)
{
// 加载MacOs头文件
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)
{
// 加载Win64头文件
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"));
}
}
在**[project_name].Build.cs**文件调用该函数
到目前为止你已经集成了TRTC SDK。可在你的cpp 文件中使用TRTC了。#include "ITRTCCloud.h"
// 获取TRTC单例对象
#if PLATFORM_ANDROID
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv()) {
void* activity = (void*) FAndroidApplication::GetGameActivityThis();
// 安卓这里需要传入当前上下文对象
pTRTCCloud = getTRTCShareInstance(activity);
}
#else
pTRTCCloud = getTRTCShareInstance();
#endif
// 注册事件回调
pTRTCCloud->addCallback(this);
// 获取版本号
std::string version = pTRTCCloud->getSDKVersion();
// 进入房间
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);
<key>NSCameraUsageDescription</key>
<string>授权摄像头权限才能正常视频通话</string>
<key>NSMicrophoneUsageDescription</key>
<string>授权麦克风权限才能正常语音通话</string>
本页内容是否解决了您的问题?