diff --git a/OCDemo/README.md b/OCDemo/README.md
index 4a5698e..5c4f708 100644
--- a/OCDemo/README.md
+++ b/OCDemo/README.md
@@ -1,44 +1,44 @@
# TRTC MacOS Demo (Objective-C)
-这个开源示例Demo主要演示如何基于 [TRTC 实时音视频 SDK](https://cloud.tencent.com/document/product/647/32689),快速实现一些音视频场景的基本功能。
+This open source example Demo mainly demonstrates how to quickly implement some basic functions of audio and video scenarios based on [TRTC Real-time Audio and Video SDK](https://cloud.tencent.com/document/product/647/32689).
-在这个示例项目中包含了以下场景:
+The following scenarios are included in this sample project:
-- 视频通话
-- 视频互动直播
+- video call
+- Video interactive live broadcast
-## 环境要求
-- Xcode 10.2及以上版本
+## Environmental requirements
+- Xcode 10.2 and above
-## 前提条件
-您已 [注册腾讯云](https://cloud.tencent.com/document/product/378/17985) 账号,并完成 [实名认证](https://cloud.tencent.com/document/product/378/3629)。
+## Prerequisites
+You have [registered Tencent Cloud](https://cloud.tencent.com/document/product/378/17985) account and completed [real-name authentication](https://cloud.tencent.com/document/product/378 /3629).
-## 操作步骤
+## Steps
-### 步骤1:创建新的应用
-1. 登录实时音视频控制台,选择【开发辅助】>【[快速跑通Demo](https://console.cloud.tencent.com/trtc/quickstart)】。
-2. 单击【立即开始】,输入应用名称,例如`TestTRTC`,单击【创建应用】。
-3. 单击【我已下载】,会看到页面上展示了您的 SDKAppID 和密钥。
+### Step 1: Create a new application
+1. Log in to the real-time audio and video console, select [Development Assistance] > [Quick Run Demo] (https://console.cloud.tencent.com/trtc/quickstart)].
+2. Click [Start Now], enter the application name, such as `TestTRTC`, and click [Create Application].
+3. Click [I have downloaded] and you will see your SDKAppID and key displayed on the page.
-### 步骤2:配置 Demo 工程中的AppID和密钥
-1. 打开工程中的 [GenerateTestUserSig.h](TRTCDemo/TRTC/GenerateTestUserSig.h) 文件
-2. 配置`GenerateTestUserSig.h`文件中的相关参数:
-
- SDKAPPID:默认为0,请设置为实际的 SDKAppID。
- - SDKSECRETKEY:默认为空字符串,请设置为实际的密钥信息。
-
-3. 返回实时音视频控制台,单击【粘贴完成,下一步】。
-4. 单击【关闭指引,进入控制台管理应用】。
+### Step 2: Configure the AppID and key in the Demo project
+1. Open the [GenerateTestUserSig.h](TRTCDemo/TRTC/GenerateTestUserSig.h) file in the project
+2. Configure the relevant parameters in the `GenerateTestUserSig.h` file:
+ - SDKAPPID: The default is 0, please set it to the actual SDKAppID.
+ - SDKSECRETKEY: The default is an empty string, please set it to the actual key information.
+
+3. Return to the real-time audio and video console and click [Paste Complete, Next].
+4. Click [Close the guide and enter the console management application].
->!本文提到的生成 UserSig 的方案是在客户端代码中配置 SDKSECRETKEY,该方法中 SDKSECRETKEY 很容易被反编译逆向破解,一旦您的密钥泄露,攻击者就可以盗用您的腾讯云流量,因此**该方法仅适合本地跑通 Demo 和功能调试**。
->正确的 UserSig 签发方式是将 UserSig 的计算代码集成到您的服务端,并提供面向 App 的接口,在需要 UserSig 时由您的 App 向业务服务器发起请求获取动态 UserSig。更多详情请参见 [服务端生成 UserSig](https://cloud.tencent.com/document/product/647/17275#Server)。
+>! The solution to generate UserSig mentioned in this article is to configure SDKSECRETKEY in the client code. In this method, SDKSECRETKEY can easily be decompiled and reverse cracked. Once your key is leaked, the attacker can steal your Tencent Cloud traffic. Therefore **This method is only suitable for local run-through Demo and functional debugging**.
+>The correct way to issue UserSig is to integrate the UserSig calculation code into your server and provide an App-oriented interface. When UserSig is needed, your App initiates a request to the business server to obtain the dynamic UserSig. For more details, please see [Server-side generation of UserSig](https://cloud.tencent.com/document/product/647/17275#Server).
-## 5. 编译运行
-在终端窗口中 cd 到 Podfile 所在目录执行以下命令安装 TRTC SDK
+## 5. Compile and run
+In the terminal window, cd to the directory where the Podfile is located and execute the following command to install TRTC SDK
```
pod install
```
-或使用以下命令更新本地库版本:
+Or use the following command to update the local library version:
```
pod update
```
-使用 XCode (9.0 以上的版本) 打开源码目录下的 TRTCDemo.xcworkspace 工程,编译并运行 Demo 工程即可。
+Use XCode (version 9.0 or above) to open the TRTCDemo.xcworkspace project in the source directory, compile and run the Demo project.
\ No newline at end of file
diff --git a/OCDemo/TRTCDemo/TRTC/GenerateTestUserSig.h b/OCDemo/TRTCDemo/TRTC/GenerateTestUserSig.h
index 6650bb0..63c49a6 100644
--- a/OCDemo/TRTCDemo/TRTC/GenerateTestUserSig.h
+++ b/OCDemo/TRTCDemo/TRTC/GenerateTestUserSig.h
@@ -1,19 +1,19 @@
/*
- * Module: GenerateTestUserSig
+ * Module: GenerateTestUserSig
*
- * Function: 用于生成测试用的 UserSig,UserSig 是腾讯云为其云服务设计的一种安全保护签名。
- * 其计算方法是对 SDKAppID、UserID 和 EXPIRETIME 进行加密,加密算法为 HMAC-SHA256。
+ * Function: used to generate UserSig for testing. UserSig is a security protection signature designed by Tencent Cloud for its cloud services.
+ * The calculation method is to encrypt SDKAppID, UserID and EXPIRETIME, and the encryption algorithm is HMAC-SHA256.
*
- * Attention: 请不要将如下代码发布到您的线上正式版本的 App 中,原因如下:
+ * Attention: Please do not publish the following code into your online official version of the App for the following reasons:
*
- * 本文件中的代码虽然能够正确计算出 UserSig,但仅适合快速调通 SDK 的基本功能,不适合线上产品,
- * 这是因为客户端代码中的 SDKSECRETKEY 很容易被反编译逆向破解,尤其是 Web 端的代码被破解的难度几乎为零。
- * 一旦您的密钥泄露,攻击者就可以计算出正确的 UserSig 来盗用您的腾讯云流量。
+ * Although the code in this file can correctly calculate UserSig, it is only suitable for quickly adjusting the basic functions of the SDK and is not suitable for online products.
+ * This is because the SDKSECRETKEY in the client code is easily decompiled and reverse-engineered, especially the web-side code, which is almost zero difficulty in cracking.
+ * Once your key is leaked, an attacker can calculate the correct UserSig to steal your Tencent Cloud traffic.
*
- * 正确的做法是将 UserSig 的计算代码和加密密钥放在您的业务服务器上,然后由 App 按需向您的服务器获取实时算出的 UserSig。
- * 由于破解服务器的成本要高于破解客户端 App,所以服务器计算的方案能够更好地保护您的加密密钥。
+ * The correct approach is to put the UserSig calculation code and encryption key on your business server, and then have the App obtain the real-time calculated UserSig from your server on demand.
+ * Since it is more expensive to crack a server than a client app, a server-computed approach better protects your encryption keys.
*
- * Reference:https://cloud.tencent.com/document/product/647/17275#Server
+ * Reference: https://cloud.tencent.com/document/product/647/17275#Server
*/
#import
@@ -21,50 +21,50 @@
NS_ASSUME_NONNULL_BEGIN
/**
- * 腾讯云 SDKAppId,需要替换为您自己账号下的 SDKAppId。
+ * Tencent Cloud SDKAppId needs to be replaced with the SDKAppId under your own account.
*
- * 进入腾讯云实时音视频[控制台](https://console.cloud.tencent.com/rav ) 创建应用,即可看到 SDKAppId,
- * 它是腾讯云用于区分客户的唯一标识。
+ * Enter Tencent Cloud Real-time Audio and Video [Console] (https://console.cloud.tencent.com/rav) to create an application and you can see the SDKAppId.
+ * It is the unique identifier used by Tencent Cloud to distinguish customers.
*/
static const int _SDKAppID = 0;
/**
- * 签名过期时间,建议不要设置的过短
+ * It is recommended not to set the signature expiration time too short.
*
- * 时间单位:秒
- * 默认时间:7 x 24 x 60 x 60 = 604800 = 7 天
+ * Time unit: seconds
+ *Default time: 7 x 24 x 60 x 60 = 604800 = 7 days
*/
static const int _EXPIRETIME = 604800;
/**
- * 计算签名用的加密密钥,获取步骤如下:
+ * The encryption key used to calculate the signature, the steps to obtain are as follows:
*
- * step1. 进入腾讯云实时音视频[控制台](https://console.cloud.tencent.com/rav ),如果还没有应用就创建一个,
- * step2. 单击您的应用,并进一步找到“快速上手”部分。
- * step3. 点击“查看密钥”按钮,就可以看到计算 UserSig 使用的加密的密钥了,请将其拷贝并复制到如下的变量中
+ * step1. Enter Tencent Cloud Real-time Audio and Video [Console] (https://console.cloud.tencent.com/rav), if there is no application yet, create one.
+ * step2. Click on your app and further find the "Get Started" section.
+ * step3. Click the "View Key" button to see the encrypted key used to calculate UserSig. Please copy it to the following variable
*
- * 注意:该方案仅适用于调试Demo,正式上线前请将 UserSig 计算代码和密钥迁移到您的后台服务器上,以避免加密密钥泄露导致的流量盗用。
- * 文档:https://cloud.tencent.com/document/product/647/17275#Server
+ * Note: This solution is only suitable for debugging Demo. Please migrate the UserSig calculation code and key to your backend server before official launch to avoid traffic theft caused by encryption key leakage.
+ * Document: https://cloud.tencent.com/document/product/647/17275#Server
*/
static NSString * const _SDKSECRETKEY = @"";
@interface GenerateTestUserSig : NSObject
/**
- * 计算 UserSig 签名
+ * Calculate UserSig signature
*
- * 函数内部使用 HMAC-SHA256 非对称加密算法,对 SDKAPPID、userId 和 EXPIRETIME 进行加密。
+ * The HMAC-SHA256 asymmetric encryption algorithm is used internally to encrypt SDKAPPID, userId and EXPIRETIME.
*
- * @note: 请不要将如下代码发布到您的线上正式版本的 App 中,原因如下:
+ * @note: Please do not publish the following code into your online official version of the App for the following reasons:
*
- * 本文件中的代码虽然能够正确计算出 UserSig,但仅适合快速调通 SDK 的基本功能,不适合线上产品,
- * 这是因为客户端代码中的 SDKSECRETKEY 很容易被反编译逆向破解,尤其是 Web 端的代码被破解的难度几乎为零。
- * 一旦您的密钥泄露,攻击者就可以计算出正确的 UserSig 来盗用您的腾讯云流量。
+ * Although the code in this file can correctly calculate UserSig, it is only suitable for quickly adjusting the basic functions of the SDK and is not suitable for online products.
+ * This is because the SDKSECRETKEY in the client code is easily decompiled and reverse-engineered, especially the web-side code, which is almost zero difficulty in cracking.
+ * Once your key is compromised, an attacker can calculate the correct UserSig to steal your Tencent Cloud traffic.
*
- * 正确的做法是将 UserSig 的计算代码和加密密钥放在您的业务服务器上,然后由 App 按需向您的服务器获取实时算出的 UserSig。
- * 由于破解服务器的成本要高于破解客户端 App,所以服务器计算的方案能够更好地保护您的加密密钥。
+ * The correct approach is to put the UserSig calculation code and encryption key on your business server, and then have the App obtain the real-time calculated UserSig from your server on demand.
+ * Since it is more expensive to crack a server than a client app, a server-computed approach better protects your encryption keys.
*
- * 文档:https://cloud.tencent.com/document/product/647/17275#Server
+ * Document: https://cloud.tencent.com/document/product/647/17275#Server
*/
+ (NSString *)genTestUserSig:(NSString *)identifier;
@end
diff --git a/OCDemo/TRTCDemo/TRTC/Manager/TRTCUserManager.h b/OCDemo/TRTCDemo/TRTC/Manager/TRTCUserManager.h
index e516a83..e2b84eb 100644
--- a/OCDemo/TRTCDemo/TRTC/Manager/TRTCUserManager.h
+++ b/OCDemo/TRTCDemo/TRTC/Manager/TRTCUserManager.h
@@ -62,10 +62,10 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setRemoteNetQuality:(NSArray *)remoteQuality;
-/// 临时停止掉界面上不出现的视频
+/// Temporarily stop videos that do not appear on the interface
- (void)hideRenderViewExceptUser:(NSString *)userId;
-/// 恢复临时停止的视频
+/// Resume temporarily stopped video
- (void)recoverAllRenderViews;
@end
diff --git a/OCDemo/TRTCDemo/TRTC/RenderView/TXRenderView.m b/OCDemo/TRTCDemo/TRTC/RenderView/TXRenderView.m
index 39bc2fd..c2e5441 100644
--- a/OCDemo/TRTCDemo/TRTC/RenderView/TXRenderView.m
+++ b/OCDemo/TRTCDemo/TRTC/RenderView/TXRenderView.m
@@ -11,17 +11,17 @@
@interface TXRenderView ()
-// 视频页面
+// Video page
@property (weak) IBOutlet NSView *contentView;
-// 左下角的用户信息
+// User information in the lower left corner
@property (weak) IBOutlet NSView *userInfoView;
@property (weak) IBOutlet NSTextField *nameLabel;
@property (weak) IBOutlet NSImageView *audioStateView;
@property (weak) IBOutlet NSLevelIndicator *volumeView;
@property (weak) IBOutlet NSImageView *signalView;
-// 右上角的功能栏
+// Function bar in the upper right corner
@property (weak) IBOutlet NSStackView *functionBar;
@property (weak) IBOutlet NSButton *rotateButton;
@property (weak) IBOutlet NSButton *streamButton;
@@ -29,7 +29,7 @@ @interface TXRenderView ()
@property (weak) IBOutlet NSButton *muteAudioButton;
@property (weak) IBOutlet NSButton *toggleFillModeButton;
-// 无画面时显示的用户信息
+// User information displayed when there is no screen
@property (weak) IBOutlet NSImageView *avatarView;
@property (nonatomic) TRTCVideoRotation rotation;
diff --git a/OCDemo/TRTCDemo/TRTC/TRTCMainWindowController.h b/OCDemo/TRTCDemo/TRTC/TRTCMainWindowController.h
index 3deb79a..f6afbcf 100644
--- a/OCDemo/TRTCDemo/TRTC/TRTCMainWindowController.h
+++ b/OCDemo/TRTCDemo/TRTC/TRTCMainWindowController.h
@@ -1,13 +1,13 @@
/*
- * Module: TRTCMainWindowController
+ * Module: TRTCMainWindowController
*
- * Function: 使用TRTC SDK完成 1v1 和 1vn 的视频通话功能
+ * Function: Use TRTC SDK to complete 1v1 and 1vn video call functions
*
- * 1. 支持九宫格平铺和前后叠加两种不同的视频画面布局方式,该部分由 _layoutInBounds 方法来计算每个视频画面的位置排布和大小尺寸
+ * 1. Supports two different video screen layout methods: nine-square tiles and front-to-back overlay. This part uses the _layoutInBounds method to calculate the position, arrangement and size of each video screen.
*
- * 2. 支持对视频通话的分辨率、帧率和流畅模式进行调整,该部分由 TRTCSettingViewController 来实现
+ * 2. Supports adjusting the resolution, frame rate and smooth mode of video calls. This part is implemented by TRTCSettingViewController
*
- * 3. 创建或者加入某一个通话房间,需要先指定 roomid 和 userid,这部分由 TRTCNewWindowController 来实现
+ * 3. To create or join a call room, you need to specify roomid and userid first. This part is implemented by TRTCNewWindowController
*/
#import
@@ -17,29 +17,29 @@ NS_ASSUME_NONNULL_BEGIN
@interface TRTCMainWindowController : NSWindowController
-/// 录屏预览窗口
+/// Screen recording preview window
@property (strong) IBOutlet NSWindow *screenShareWindow;
-/// 跨房通话窗口
+/// Inter-room call window
@property (strong) IBOutlet NSWindow *connectRoomWindow;
@property (strong) NSString *connectRoomId;
@property (strong) NSString *connectUserId;
@property (assign, nonatomic, readonly) BOOL canConnectRoom;
@property (assign, nonatomic) BOOL connectingRoom;
-/// 音频设备选则列表
+/// Audio device selection list
@property (strong) IBOutlet NSTableView *audioSelectView;
-/// 视频设备选则列表
+/// Video equipment selection list
@property (strong) IBOutlet NSTableView *videoSelectView;
-/// 美颜窗口
+/// beauty window
@property (strong) IBOutlet NSPanel *beautyPanel;
-///是否开启美颜(磨皮)
+///Whether to turn on beauty treatment (dermabrasion)
@property BOOL beautyEnabled;
-// 以下为美颜参数
+// The following are beauty parameters
@property NSInteger beautyLevel;
@property NSInteger rednessLevel;
@property NSInteger whitenessLevel;
diff --git a/OCDemo/TRTCDemo/TRTC/TRTCMainWindowController.m b/OCDemo/TRTCDemo/TRTC/TRTCMainWindowController.m
index 4d1b080..b294292 100644
--- a/OCDemo/TRTCDemo/TRTC/TRTCMainWindowController.m
+++ b/OCDemo/TRTCDemo/TRTC/TRTCMainWindowController.m
@@ -3,7 +3,7 @@
// TXLiteAVMacDemo
//
// Created by ericxwli on 2018/10/10.
-// Copyright © 2018年 Tencent. All rights reserved.
+// Copyright © 2018 Tencent. All rights reserved.
//
#import "TRTCMainWindowController.h"
@@ -18,8 +18,8 @@
#import "TRTCUserManager.h"
#import
-// TRTC的bizid的appid用于转推直播流,https://console.cloud.tencent.com/rav 点击【应用】【帐号信息】
-// 在【直播信息】中可以看到bizid和appid,分别填到下面这两个符号
+// The appid of TRTC's bizid is used to retweet the live stream, https://console.cloud.tencent.com/rav click [Application] [Account Information]
+// You can see bizid and appid in [Live Broadcast Information], fill in the two symbols below respectively
#define TX_BIZID 0
#define TX_APPID 0
#define PLACE_HOLDER_LOCAL_MAIN @"$PLACE_HOLDER_LOCAL_MAIN$"
@@ -47,19 +47,19 @@ @interface TRTCMainWindowController () <
{
NSMutableDictionary *_mixTransCodeInfo;
}
-/// TRTC SDK 实例对象
+/// TRTC SDK instance object
@property(nonatomic,strong) TRTCCloud *trtcEngine;
@property (nonatomic, strong) TRTCUserManager *userManager;
-// 进房参数
+// Room entry parameters
@property(nonatomic,readonly,strong) TRTCParams *currentUserParam;
@property(nonatomic,readonly,assign) TRTCAppScene scene;
@property(nonatomic,readonly,assign) BOOL audioOnly;
-// 用于鼠标移出后隐藏菜单栏
+// Used to hide the menu bar after the mouse is moved out
@property(nonatomic,strong) NSTrackingArea *trackingArea;
-// 视频容器
+// video container
@property (weak) IBOutlet NSSplitView *splitView;
@property (weak) IBOutlet NSView *videoLayoutView;
@property (weak) IBOutlet TRTCMemberListView *memberListView;
@@ -84,22 +84,22 @@ @interface TRTCMainWindowController () <
@property(nonatomic,strong) NSMutableArray *speakerArr;
@property(nonatomic,strong) NSMutableArray *cameraArr;
-// 1. 画廊模式, 2. 演讲者模式
+// 1. Gallery mode, 2. Speaker mode
@property(nonatomic,assign) LayoutStyle layoutStyle;
-// 屏幕捕捉
+// screen capture
@property(nonatomic,strong) TXCaptureSourceWindowController *captureSourceWindowController;
@property(nonatomic,copy) NSString * presentingScreenCaptureUid;
-// 混流信息,key为uid value为roomId
+// Mixed flow information, key is uid and value is roomId
@property(nonatomic, strong) NSMutableDictionary* pkInfos;
-// 正在进行的屏幕分享源
+// Ongoing screen sharing source
@property(nonatomic, strong) TRTCScreenCaptureSourceInfo *screenCaptureInfo;
-// 显示屏幕分享按钮
+// Show screen sharing button
@property (nonatomic, strong) NSTitlebarAccessoryViewController *titleBarAccessoryViewController;
-// 演讲者模式
+// speaker mode
@property (weak) IBOutlet TRTCVideoListView *videoListView;
@property (weak) IBOutlet NSLayoutConstraint *videoListTrailing;
@property (weak) IBOutlet NSLayoutConstraint *videoListHeight;
@@ -150,10 +150,10 @@ - (void)_configPopUpMenu:(NSTableView *)tableView {
tableView.selectionHighlightStyle = NSTableViewSelectionHighlightStyleNone;
}
-// 窗口加载后初始化控件
+// Initialize controls after window loading
- (void)windowDidLoad {
[super windowDidLoad];
- // 重置美颜窗口位置与参数
+ // Reset the beauty window position and parameters
NSRect frame = self.beautyPanel.frame;
frame.origin.x = NSMinX(self.window.frame) - NSWidth(frame);
frame.origin.y = NSMaxY(self.window.frame) - NSHeight(frame);
@@ -161,16 +161,16 @@ - (void)windowDidLoad {
self.beautyEnabled = YES;
self.beautyLevel = self.rednessLevel = self.whitenessLevel = 5;
- // 配置窗口信息
+ // Configure window information
self.window.delegate = self;
self.window.title = [NSString stringWithFormat:@"房间%u",self.roomID];
self.window.backgroundColor = [NSColor whiteColor];
- // 本地视频预览 View
+ // Local video preview View
self.videoLayoutView.wantsLayer = YES;
self.videoLayoutView.layer.backgroundColor = [NSColor colorWithRed:0.18 green:0.18 blue:0.18 alpha:1.0].CGColor;
- // 底部工具栏
+ // bottom toolbar
self.anchorFunctionBar.wantsLayer = true;
self.anchorFunctionBar.layer.backgroundColor = [NSColor colorWithRed:0.18 green:0.18 blue:0.18 alpha:1.0].CGColor;
self.functionBar.wantsLayer = true;
@@ -194,29 +194,29 @@ - (void)windowDidLoad {
attributes:kButtonTitleAttr];
}
- // 配置底部工具栏自动隐藏
+ // Configure the bottom toolbar to automatically hide
[self setupTrackingArea];
- //音频选择列表
+ // audio selection list
[self _configPopUpMenu:self.audioSelectView];
self.audioSelectView.frame = CGRectMake(self.audioSelectView.frame.origin.x, self.audioSelectView.frame.origin.y, self.audioSelectView.frame.size.width, (self.micArr.count+self.speakerArr.count+1)*26);
[self _configPopUpMenu:self.videoSelectView];
self.videoSelectView.frame = CGRectMake(self.videoSelectView.frame.origin.x, self.videoSelectView.frame.origin.y, self.videoSelectView.frame.size.width, (self.micArr.count+1)*26);
- // 侧边视频列表
+ // Side video list
self.videoListView.delegate = self;
[self.videoListView observeUserManager:self.userManager];
[self.videoListView addObserver:self forKeyPath:@"tableHeight" options:NSKeyValueObservingOptionNew context:nil];
- // 成员列表
+ // Member list
[self.memberListView observeUserManager:self.userManager];
self.memberListView.hidden = YES;
- // 监听成员变化
+ // Monitor member changes
[self.userManager addObserver:self forKeyPath:@"userConfigs" options:NSKeyValueObservingOptionNew context:nil];
- // 进房
+ // Enter the room
[self enterRoom];
}
@@ -238,7 +238,7 @@ - (void)windowDidResize:(NSNotification *)notification {
[self updateVideoListHeight];
}
-#pragma mark - 窗口标题
+#pragma mark - window title
- (void)updateWindowTitle {
NSString *title = [NSString stringWithFormat:@"房间%u",self.roomID];
if (self.presentingScreenCaptureUid) {
@@ -262,7 +262,7 @@ - (void)mouseDown:(NSEvent *)event {
}
#pragma mark - Notification Observer
-//关闭窗口退出房间
+// Close the window and exit the room
-(void)windowWillClose:(NSNotification *)notification{
[self.trtcEngine exitRoom];
[self.trtcEngine stopLocalPreview];
@@ -294,7 +294,7 @@ - (NSString *)userId {
return _currentUserParam.userId;
}
-#pragma mark - 美颜参数更新
+#pragma mark - Beauty parameter update
- (void)_updateBeautySettings {
[self.trtcEngine setBeautyStyle:self.beautyStyle beautyLevel:self.beautyLevel whitenessLevel:self.whitenessLevel ruddinessLevel:self.rednessLevel];
}
@@ -307,17 +307,17 @@ - (BOOL)isSelectSpeakerDevice:(NSString *)deviceId{
return NO;
}
-// 判断是否是当前使用的麦克
+// Determine whether it is the currently used microphone
-(BOOL)isSelectedMicDevice:(NSString *)deviceId{
return [[self.trtcEngine getCurrentMicDevice].deviceId isEqualToString:deviceId];
}
-// 判断是否是当前使用的摄像头
+// Determine whether it is the currently used camera
-(BOOL)isSelectedCameraDevice:(NSString *)deviceId{
return [deviceId isEqualToString: [self.trtcEngine getCurrentCameraDevice].deviceId];
}
-#pragma mark - 控制栏按钮操作
+#pragma mark - Control bar button operations
- (IBAction)onClickAudioMute:(NSButton *)button {
button.image = [NSImage imageNamed:AudioIcon[button.state]];
button.attributedTitle = [[NSAttributedString alloc] initWithString:@[@"静音", @"解除静音"][button.state]
@@ -455,7 +455,7 @@ - (IBAction)onClickMuteAllAudioButton:(NSButton *)button {
[self.userManager muteAllRemoteAudio:mutesAudio];
}
-#pragma makr - 跨房通话
+#pragma makr - Inter-room calls
- (IBAction)onConnectAnotherRoom:(id)sender {
[self.window beginSheet:self.connectRoomWindow completionHandler:^(NSModalResponse returnCode) {
}];
@@ -500,12 +500,12 @@ + (NSSet *)keyPathsForValuesAffectingCanStopConnectRoom {
return [NSSet setWithObjects:@"connectingRoom", nil];
}
-// 更新美颜设置
+// Update beauty settings
- (void)didChangeValueForKey:(NSString *)key {
[super didChangeValueForKey:key];
if ([key isEqualToString:NSStringFromSelector(@selector(beautyEnabled))]) {
if (!self.beautyEnabled) {
- // 关闭美颜设置
+ // Turn off beauty settings
[self.trtcEngine setBeautyStyle:self.beautyStyle beautyLevel:0 whitenessLevel:0 ruddinessLevel:0];
}
}
@@ -525,7 +525,7 @@ - (void)didChangeValueForKey:(NSString *)key {
nil];
});
if ([keys containsObject:key]) {
- // 更新美颜设置参数
+ // Update beauty setting parameters
[self _updateBeautySettings];
}
}
@@ -538,7 +538,7 @@ - (BOOL)canStopConnectRoom {
return self.connectingRoom;
}
-#pragma mark - 播放录屏
+#pragma mark - Play screen recording
- (void)_playScreenCaptureForUser:(NSString *)userId {
if (![self.presentingScreenCaptureUid isEqualToString:userId]) {
[self.trtcEngine startRemoteSubStreamView:userId view:self.screenShareWindow.contentView];
@@ -548,7 +548,7 @@ - (void)_playScreenCaptureForUser:(NSString *)userId {
self.presentingScreenCaptureUid = userId;
}
-#pragma mark - 错误与警告
+#pragma mark - Errors and warnings
- (void)onError:(TXLiteAVError)errCode errMsg:(NSString *)errMsg extInfo:(NSDictionary *)extInfo {
if (errCode == ERR_SERVER_CENTER_ANOTHER_USER_PUSH_SUB_VIDEO) {
dispatch_async(dispatch_get_main_queue(), ^{
@@ -566,9 +566,9 @@ - (void)onError:(TXLiteAVError)errCode errMsg:(NSString *)errMsg extInfo:(NSDict
[self exitRoom];
}
}
-#pragma mark - 进房与音视频事件
+#pragma mark - house entry and audio and video events
/**
- * 加入视频房间:使用从 TRTCNewWindowController 实例化时传入的 TRTCParams
+ * Join the video room: use the TRTCParams passed in when instantiating from TRTCNewWindowController
*/
- (void)enterRoom {
TRTCParams *param = _currentUserParam;
@@ -597,7 +597,7 @@ - (void)enterRoom {
[self.userManager addUser:self.userId];
- // 开启视频采集预览
+ // Enable video capture preview
if (!self.audioOnly) {
[self.userManager setUser:self.userId videoAvailable:YES];
} else {
@@ -710,7 +710,7 @@ - (void)exitRoom {
[self.trtcEngine exitRoom];
}
-#pragma mark - 混流
+#pragma mark - mixed flow
- (void)stopCloudMixTranscoding {
_mixTransCodeInfo = [NSMutableDictionary dictionary];
[self.trtcEngine setMixTranscodingConfig:nil];
@@ -733,7 +733,7 @@ - (void)updateCloudMixtureParams
int videoWidth = 720;
int videoHeight = 1280;
- // 小画面宽高
+ // Small screen width and height
int subWidth = 180;
int subHeight = 320;
@@ -831,9 +831,10 @@ - (void)updateCloudMixtureParams
config.audioBitrate = 64;
config.audioChannels = 1;
- // 设置混流后主播的画面位置
+ // Set the anchor’s screen position after mixing
TRTCMixUser* broadCaster = [TRTCMixUser new];
- broadCaster.userId = mixMode == TRTCTranscodingConfigMode_Template_PresetLayout ? PLACE_HOLDER_LOCAL_MAIN : self.currentUserParam.userId; // 以主播uid为broadcaster为例
+ broadCaster.userId = mixMode == TRTCTranscodingConfigMode_Template_PresetLayout ?
+ PLACE_HOLDER_LOCAL_MAIN : self.currentUserParam.userId; // Take the anchor uid as broadcaster as an example
broadCaster.zOrder = 0;
broadCaster.rect = CGRectMake(0, 0, videoWidth, videoHeight);
broadCaster.roomID = nil;
@@ -841,7 +842,7 @@ - (void)updateCloudMixtureParams
NSMutableArray* mixUsers = [NSMutableArray new];
[mixUsers addObject:broadCaster];
- // 设置混流后各个小画面的位置
+ // Set the position of each small picture after mixing
NSDictionary* pkUsers = self.pkInfos;
int i = 0;
@@ -872,7 +873,7 @@ - (void)updateCloudMixtureParams
[_trtcEngine setMixTranscodingConfig:config];
}
-#pragma makr - 角色变化
+#pragma makr - role changes
- (void)roleChanged:(BOOL)isAudience {
[self.userManager setUser:self.userId videoAvailable:!isAudience];
[self.userManager setUser:self.userId audioAvailable:!isAudience];
@@ -880,7 +881,7 @@ - (void)roleChanged:(BOOL)isAudience {
}
-#pragma mark - 画面布局渲染
+#pragma mark - Screen layout rendering
- (void)updateLayoutVideoFrame {
if (self.layoutStyle == LayoutStyleGalleryView) {
@@ -928,7 +929,7 @@ - (void)layoutWithPresenterStyle {
[self.videoListView reloadData];
}
-#pragma mark - 连麦回调
+#pragma mark - Lianmai callback
- (void)onConnectOtherRoom:(NSString*)userId errCode:(TXLiteAVError)errCode errMsg:(nullable NSString *)errMsg;
{
if (errCode != 0) {
@@ -948,7 +949,7 @@ - (void)onDisconnectOtherRoom:(TXLiteAVError)errCode errMsg:(NSString *)errMsg {
self.connectingRoom = NO;
}
-#pragma mark - 音频设备列表
+#pragma mark - Audio device list
-(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
if (tableView == self.audioSelectView) {
return self.micArr.count + self.speakerArr.count + 1;
@@ -1109,7 +1110,7 @@ - (IBAction)onClickAudioSourceTableItem:(id)sender {
[audioArr addObject:@"音频设置"];
id object = [audioArr objectAtIndex:row];
if ([object isKindOfClass:[TRTCMediaDeviceInfo class]]) {
- //选择默认设备
+ // Select default device
TRTCMediaDeviceInfo *source = (TRTCMediaDeviceInfo *)object;
if ([self.micArr containsObject:object] ) {
[self.trtcEngine setCurrentMicDevice:source.deviceId];
diff --git a/OCDemo/TRTCDemo/TRTC/TRTCNewWindowController.h b/OCDemo/TRTCDemo/TRTC/TRTCNewWindowController.h
index cce82e1..67a6ef5 100644
--- a/OCDemo/TRTCDemo/TRTC/TRTCNewWindowController.h
+++ b/OCDemo/TRTCDemo/TRTC/TRTCNewWindowController.h
@@ -1,25 +1,25 @@
/*
- * Module: TRTCNewWindowController
+ * Module: TRTCNewWindowController
*
- * Function: 该界面可以让用户输入一个【房间号】和一个【用户名】
+ * Function: This interface allows the user to enter a [room number] and a [user name]
*
* Notice:
*
- * (1)房间号为数字类型,用户名为字符串类型
+ * (1) The room number is of numeric type, and the user name is of string type.
*
- * (2)在真实的使用场景中,房间号大多不是用户手动输入的,而是由后台业务服务器直接分配的,
- * 比如视频会议中的会议号是会控系统提前预定好的,客服系统中的房间号也是根据客服员工的工号决定的。
+ * (2) In real usage scenarios, most room numbers are not manually entered by users, but are directly assigned by the backend business server.
+ * For example, the conference number in the video conference is pre-booked by the conference control system, and the room number in the customer service system is also determined based on the customer service employee's work number.
*/
#import
#import "TRTCMainWindowController.h"
#import "SDKHeader.h"
-// 登录
+// Log in
@interface TRTCNewWindowController : NSWindowController
{
TRTCMainWindowController *_wc;
}
-// 房间号输入框
+// Room number input box
@property (strong) IBOutlet NSTextField *roomidField;
@property (strong) IBOutlet NSTextField *useridField;
@property BOOL audioOnly;
diff --git a/OCDemo/TRTCDemo/TRTC/TRTCNewWindowController.m b/OCDemo/TRTCDemo/TRTC/TRTCNewWindowController.m
index b9c01d4..c03d699 100644
--- a/OCDemo/TRTCDemo/TRTC/TRTCNewWindowController.m
+++ b/OCDemo/TRTCDemo/TRTC/TRTCNewWindowController.m
@@ -1,14 +1,14 @@
/*
- * Module: TRTCNewWindowController
+ * Module: TRTCNewWindowController
*
- * Function: 该界面可以让用户输入一个【房间号】和一个【用户名】
+ * Function: This interface allows the user to enter a [room number] and a [user name]
*
* Notice:
*
- * (1)房间号为数字类型,用户名为字符串类型
+ * (1) The room number is of numeric type, and the user name is of string type.
*
- * (2)在真实的使用场景中,房间号大多不是用户手动输入的,而是系统分配的,
- * 比如视频会议中的会议号是会控系统提前预定好的,客服系统中的房间号也是根据客服员工的工号决定的。
+ * (2) In real usage scenarios, most room numbers are not manually entered by the user, but assigned by the system.
+ * For example, the conference number in the video conference is pre-booked by the conference control system, and the room number in the customer service system is also determined based on the customer service employee's work number.
*/
#import "TRTCNewWindowController.h"
@@ -74,19 +74,19 @@ - (void)controlTextDidChange:(NSNotification *)notification {
}
/**
- * Function: 读取用户输入,并创建(或加入)音视频房间
+ * Function: Read user input and create (or join) audio and video rooms
*
- * 此段示例代码最主要的作用是组装 TRTC SDK 进房所需的 TRTCParams
+ * The main function of this sample code is to assemble the TRTCParams required by TRTC SDK to enter the room.
*
- * TRTCParams.sdkAppId => 可以在腾讯云实时音视频控制台(https://console.cloud.tencent.com/rav)获取
- * TRTCParams.userId => 此处即用户输入的用户名,它是一个字符串
- * TRTCParams.roomId => 此处即用户输入的音视频房间号,比如 125
- * TRTCParams.userSig => 此处示例代码展示了两种获取 usersig 的方式,一种是从【控制台】获取,一种是从【服务器】获取
+ * TRTCParams.sdkAppId => Can be obtained from Tencent Cloud real-time audio and video console (https://console.cloud.tencent.com/rav)
+ * TRTCParams.userId => This is the username entered by the user, which is a string
+ * TRTCParams.roomId => This is the audio and video room number entered by the user, such as 125
+ * TRTCParams.userSig => The sample code here shows two ways to obtain usersig, one is to obtain it from [Console] and the other is to obtain it from [Server]
*
- * (1)控制台获取:可以获得几组已经生成好的 userid 和 usersig,他们会被放在一个 json 格式的配置文件中,仅适合调试使用
- * (2)服务器获取:直接在服务器端用我们提供的源代码,根据 userid 实时计算 usersig,这种方式安全可靠,适合线上使用
+ * (1) Console acquisition: You can obtain several groups of generated userids and usersig. They will be placed in a json format configuration file, which is only suitable for debugging.
+ * (2) Server acquisition: Use the source code we provide directly on the server side to calculate usersig in real time based on userid. This method is safe and reliable and suitable for online use.
*
- * 参考文档:https://cloud.tencent.com/document/product/647/17275
+ * Reference document: https://cloud.tencent.com/document/product/647/17275
*/
- (IBAction)enter:(id)sender {
if (self.roomidField.stringValue.length == 0) {
diff --git a/OCDemo/TRTCDemo/TRTC/TRTCSettingWindowController.h b/OCDemo/TRTCDemo/TRTC/TRTCSettingWindowController.h
index f2487f2..0982f14 100644
--- a/OCDemo/TRTCDemo/TRTC/TRTCSettingWindowController.h
+++ b/OCDemo/TRTCDemo/TRTC/TRTCSettingWindowController.h
@@ -3,10 +3,10 @@
// TXLiteAVMacDemo
//
// Created by ericxwli on 2018/10/17.
-// Copyright © 2018年 Tencent. All rights reserved.
+// Copyright © 2018 Tencent. All rights reserved.
//
-// 用于对视频通话的分辨率、帧率和流畅模式进行调整,并支持记录下这些设置项
+// Used to adjust the resolution, frame rate and smooth mode of video calls, and supports recording these settings
#import
#import "SDKHeader.h"
@@ -38,78 +38,78 @@ typedef NS_ENUM(NSUInteger, TXAVSettingTabIndex) {
@property (nonatomic, strong, nullable) NSString *userID;
@property (nonatomic, strong, nullable) NSString *roomID;
-// 通话场景按钮
+// Call scene button
@property (strong) IBOutlet NSButton *callSceneButton;
-// 直播场景按钮
+// Live scene button
@property (strong) IBOutlet NSButton *liveSceneButton;
-// 优先流畅按钮
+// Prioritize smooth button
@property (strong) IBOutlet NSButton *smoothBtn;
-// 优先清晰按钮
+//Prioritize clear button
@property (strong) IBOutlet NSButton *clearBtn;
-// 客户端控
+//Client control
@property (strong) IBOutlet NSButton *clientBtn;
-// 云控
+// Cloud control
@property (strong) IBOutlet NSButton *cloudBtn;
-// 横屏
+// Horizontal screen
@property (strong) IBOutlet NSButton *portraitResolutionBtn;
@property (strong) IBOutlet NSButton *landscapeResolutionBtn;
-// 竖屏
+//vertical screen
-// 通用设置界面
+//General settings interface
@property (strong) IBOutlet NSView *generalSettingView;
-// 音频设置界面
+//Audio setting interface
@property (strong) IBOutlet NSView *audioSettingView;
-// 视频设置界面
+//Video setting interface
@property (strong) IBOutlet NSView *videoSettingView;
-// 设置界面容器
+//Set interface container
@property (strong) IBOutlet NSView *settingField;
-// 视频设置界面预览视图
+// Video settings interface preview view
@property (strong) IBOutlet NSView *cameraPreview;
-// 左边菜单
+// left menu
@property (strong) IBOutlet NSTableView *sidebarMenu;
-// 当前选中视频还是音频
+//Whether video or audio is currently selected
@property (assign, nonatomic) TXAVSettingTabIndex tabIndex;
-// 摄像头选择控件
+//Camera selection control
@property (strong) IBOutlet NSPopUpButton *cameraItems;
-// 扬声器选择控件
+// Speaker selection control
@property (strong) IBOutlet NSPopUpButton *speakerItems;
-// 麦克风选择控件
+// Microphone selection control
@property (strong) IBOutlet NSPopUpButton *micItems;
-// 分辨率选择控件
+//Resolution selection control
@property (strong) IBOutlet NSPopUpButton *resolutionItems;
-// fps选择控件
+// fps selection control
@property (strong) IBOutlet NSPopUpButton *fpsItems;
-// 码率显示
+// code rate display
@property (strong) IBOutlet NSTextField *bitrateLabel;
-// 码率滑杆
+// code rate slider
@property (strong) IBOutlet NSSlider *bitrateSlider;
-// 麦克风音量滑杆
+//Microphone volume slider
@property (strong) IBOutlet NSSlider *micVolumeSlider;
-// 扬声器音量滑杆
+// Speaker volume slider
@property (strong) IBOutlet NSSlider *speakerVolumeSlider;
-// 录音音量指示器
+//Recording volume indicator
@property (weak) IBOutlet NSLevelIndicator *volumeMeter;
-// 扬声器音量指示器
+// Speaker volume indicator
@property (weak) IBOutlet NSLevelIndicator *speakerVolumeMeter;
-// 分享按钮
+// Share button
@property (weak) IBOutlet NSButton *shareButton;
-// 设置BGM播放音量
+//Set BGM playback volume
@property (strong) IBOutlet NSSlider *BGMVolumeSlider;
-// 设置BGM远端播放音量
+//Set BGM remote playback volume
@property (strong) IBOutlet NSSlider *BGMPublishVolumeSlider;
-// 设备BGM本地播放音量
+//Device BGM local playback volume
@property (strong) IBOutlet NSSlider *BGMPlayoutVolumeSlider;
// For Cocoa Bindings
-// 推流设置
+// Push settings
@property (assign, nonatomic) BOOL pushDoubleStream;
@property (assign, nonatomic) BOOL playSmallStream;
@property (assign, nonatomic) BOOL showVolume;
-// 开启云端混流
+// Enable cloud mixing
@property (assign, nonatomic) TRTCTranscodingConfigMode mixMode;
@property (assign, nonatomic) BOOL isAudience;
@@ -126,25 +126,25 @@ typedef NS_ENUM(NSUInteger, TXAVSettingTabIndex) {
- (IBAction)onSelectSpeaker:(id)sender;
- (IBAction)onSelectMic:(id)sender;
-// 更改扬声器音量
+//Change speaker volume
- (IBAction)onSpeakerVolumChange:(id)sender;
-// 更改麦克风音量
+//Change microphone volume
- (IBAction)onMicVolumChange:(id)sender;
-// 分辨率选则
+// Resolution selection
- (IBAction)onSelectResolution:(id)sender;
-// 帧率选则
+// Frame rate selection
- (IBAction)onSelectFps:(NSPopUpButton *)sender;
-// 比特率选则
+//bitrate selection
- (IBAction)onSelectBitrate:(id)sender;
-// 麦克风测试
+// Microphone test
- (IBAction)onClickMicTest:(id)sender;
-// 开始扬声器测试
+// Start speaker test
- (IBAction)onClickSpeakerTest:(NSButton *)sender;
-// 更改流控模式,流畅还是清晰
+//Change the flow control mode, smooth or clear
- (IBAction)onClickQOSPreference:(NSButton *)sender;
-// 更改流控方式,使用SDK固定配置还是使用下发配置
+// Change the flow control method, use SDK fixed configuration or use distributed configuration
- (IBAction)onClickQOSControlMode:(NSButton *)sender;
-// 响应分享播放地址按钮
+//Response to share play address button
- (IBAction)onClickShowCloudMixURL:(id)sender;
@end
diff --git a/OCDemo/TRTCDemo/TRTC/TRTCSettingWindowController.m b/OCDemo/TRTCDemo/TRTC/TRTCSettingWindowController.m
index f898d0c..f179d11 100644
--- a/OCDemo/TRTCDemo/TRTC/TRTCSettingWindowController.m
+++ b/OCDemo/TRTCDemo/TRTC/TRTCSettingWindowController.m
@@ -3,10 +3,10 @@
// TXLiteAVMacDemo
//
// Created by ericxwli on 2018/10/17.
-// Copyright © 2018年 Tencent. All rights reserved.
+// Copyright © 2018 Tencent. All rights reserved.
//
//
-// 用于对视频通话的分辨率、帧率和流畅模式进行调整,并支持记录下这些设置项
+// Used to adjust the resolution, frame rate and smooth mode of video calls, and supports recording these settings
#import "TRTCSettingWindowController.h"
#import "GenerateTestUserSig.h"
@@ -54,35 +54,35 @@ @interface TRTCSettingWindowController ()
-### 步骤1:创建新的应用
-1. 登录实时音视频控制台,选择【开发辅助】>【[快速跑通Demo](https://console.cloud.tencent.com/trtc/quickstart)】。
-2. 单击【立即开始】,输入应用名称,例如`TestTRTC`,单击【创建应用】。
+### Step 1: Create a new application
+1. Log in to the real-time audio and video console, select [Development Assistance] > [Quick Run Demo] (https://console.cloud.tencent.com/trtc/quickstart)].
+2. Click [Start Now], enter the application name, such as `TestTRTC`, and click [Create Application].
-### 步骤2:下载 SDK 和 Demo 源码
-1. 鼠标移动至对应卡片,下载相关 SDK 及配套的 Demo 源码。
- 单击【[Github](https://github.com/tencentyun/TRTCSDK/tree/master/Mac)】跳转至 Github(或单击【[ZIP](https://liteav.sdk.qcloud.com/download/latest/TXLiteAVSDK_TRTC_Mac_latest.tar.bz2?_ga=1.195966252.185644906.1567570704)】)
- 
-
-2. 下载完成后,返回实时音视频控制台,单击【我已下载,下一步】,可以查看 SDKAPPID 和密钥信息。
+### Step 2: Download SDK and Demo source code
+1. Move the mouse to the corresponding card and download the relevant SDK and supporting Demo source code.
+ Click [[Github](https://github.com/tencentyun/TRTCSDK/tree/master/Mac)] to jump to Github (or click [[ZIP](https://liteav.sdk.qcloud.com /download/latest/TXLiteAVSDK_TRTC_Mac_latest.tar.bz2?_ga=1.195966252.185644906.1567570704)])
+ 
+
+2. After the download is completed, return to the real-time audio and video console and click [I have downloaded, Next] to view the SDKAPPID and key information.
-### 步骤3:配置 Demo 工程中的AppID和密钥
-1. 打开[GenerateTestUserSig.h](debug/GenerateTestUserSig.h)文件
-2. 配置`GenerateTestUserSig.h`文件中的相关参数:
- - SDKAPPID:默认为0,请设置为实际的 SDKAPPID。
- - SDKSECRETKEY:默认为空字符串,请设置为实际的密钥信息。
-
-3. 返回实时音视频控制台,单击【粘贴完成,下一步】。
-4. 单击【关闭指引,进入控制台管理应用】。
-
->!本文提到的生成 UserSig 的方案是在客户端代码中配置 SDKSECRETKEY,该方法中 SDKSECRETKEY 很容易被反编译逆向破解,一旦您的密钥泄露,攻击者就可以盗用您的腾讯云流量,因此**该方法仅适合本地跑通 Demo 和功能调试**。
->正确的 UserSig 签发方式是将 UserSig 的计算代码集成到您的服务端,并提供面向 App 的接口,在需要 UserSig 时由您的 App 向业务服务器发起请求获取动态 UserSig。更多详情请参见 [服务端生成 UserSig](https://cloud.tencent.com/document/product/647/17275#Server)。
-
-### 步骤4:编译运行
-使用 XCode(10.2及以上的版本)打开源码目录下的 TRTCSimpleDemo.xcworkspace 工程,编译并运行 Demo 工程即可。
+### Step 3: Configure the AppID and key in the Demo project
+1. Open the [GenerateTestUserSig.h](debug/GenerateTestUserSig.h) file
+2. Configure the relevant parameters in the `GenerateTestUserSig.h` file:
+ - SDKAPPID: The default is 0, please set it to the actual SDKAPPID.
+ - SDKSECRETKEY: The default is an empty string, please set it to the actual key information.
+
+3. Return to the real-time audio and video console and click [Paste Complete, Next].
+4. Click [Close the guide and enter the console management application].
+
+>! The solution to generate UserSig mentioned in this article is to configure SDKSECRETKEY in the client code. In this method, SDKSECRETKEY can easily be decompiled and reverse cracked. Once your key is leaked, the attacker can steal your Tencent Cloud traffic. Therefore **This method is only suitable for local run-through Demo and functional debugging**.
+>The correct way to issue UserSig is to integrate the UserSig calculation code into your server and provide an App-oriented interface. When UserSig is needed, your App initiates a request to the business server to obtain the dynamic UserSig. For more details, please see [Server-side generation of UserSig](https://cloud.tencent.com/document/product/647/17275#Server).
+
+### Step 4: Compile and run
+Use XCode (version 10.2 and above) to open the TRTCSimpleDemo.xcworkspace project in the source directory, compile and run the Demo project.
diff --git a/SwiftDemo/RTC/CustomCamera/RTCCustomCameraFrameRender.swift b/SwiftDemo/RTC/CustomCamera/RTCCustomCameraFrameRender.swift
index 827b480..8a62e84 100644
--- a/SwiftDemo/RTC/CustomCamera/RTCCustomCameraFrameRender.swift
+++ b/SwiftDemo/RTC/CustomCamera/RTCCustomCameraFrameRender.swift
@@ -9,11 +9,6 @@
import Cocoa
import TXLiteAVSDK_TRTC_Mac
-/*自定义视屏采集和渲染
- TRTC APP 支持自定义视频数据采集, 本文件展示如何自定义渲染采集到的数据
- 1、采集到的数据进行自定义渲染 API:onRenderVideoFrame()
- 更多细节,详见:https://cloud.tencent.com/document/product/647/34066
-*/
/*
Custom Video Capturing and Rendering
TRTC APP supports custom video data collection. This document shows how to customize the data collected by rendering.
diff --git a/SwiftDemo/RTC/CustomCamera/RTCCustomCameraHelper.swift b/SwiftDemo/RTC/CustomCamera/RTCCustomCameraHelper.swift
index af0f7dc..226de7f 100644
--- a/SwiftDemo/RTC/CustomCamera/RTCCustomCameraHelper.swift
+++ b/SwiftDemo/RTC/CustomCamera/RTCCustomCameraHelper.swift
@@ -15,14 +15,6 @@ enum AVCamSetupResult:Int32 {
case sessionConfigurationFailed
}
-/*
- 自定义视屏采集和渲染
- TRTC APP 支持自定义视频数据采集, 本文件展示如何使用AVFoundation库自定义采集数据
- 1、配置采集数据的输出设备和输入设备 API:configureSession()
- 2、将音视频输入输出设备添加到会话中 API:captureSession.addInput(audioDeviceInput)
- captureSession.addOutput(videoOutput)
- 更多细节,详见:https://cloud.tencent.com/document/product/647/34066
- */
/*
Custom Video Capturing and Rendering
TRTC app supports custom video data collection. This document shows how to use avfoundation library to customize data collection.
diff --git a/SwiftDemo/RTC/CustomCamera/RTCCustomCaptureViewController.swift b/SwiftDemo/RTC/CustomCamera/RTCCustomCaptureViewController.swift
index 342dbda..5773b4a 100644
--- a/SwiftDemo/RTC/CustomCamera/RTCCustomCaptureViewController.swift
+++ b/SwiftDemo/RTC/CustomCamera/RTCCustomCaptureViewController.swift
@@ -9,14 +9,6 @@
import TXLiteAVSDK_TRTC_Mac
import Cocoa
-/*
- 自定义视屏采集和渲染示例
- TRTC APP 支持自定义视频数据采集, 本文件展示如何发送自定义采集数据
- 1、进入TRTC房间 API:trtcCloud.enterRoom(params, appScene: .LIVE)
- 2、打开自定义采集功能 API:trtcCloud.enableCustomVideoCapture(.big, enable: true)
- 3、发送自定义采集数据 API:trtcCloud.enableCustomVideoCapture(.big, enable: true)
- 更多细节,详见:https://cloud.tencent.com/document/product/647/34066
- */
/*
Custom Video Capturing and Rendering
The TRTC app supports custom video capturing and rendering. This document shows how to send custom video data.
diff --git a/SwiftDemo/RTC/InteractiveVideo/RTCEntranceViewController.swift b/SwiftDemo/RTC/InteractiveVideo/RTCEntranceViewController.swift
index 7126a65..051caff 100644
--- a/SwiftDemo/RTC/InteractiveVideo/RTCEntranceViewController.swift
+++ b/SwiftDemo/RTC/InteractiveVideo/RTCEntranceViewController.swift
@@ -7,10 +7,6 @@
import Cocoa
-/*
- RTC视频通话的入口页面(可以设置房间id和用户id)
- RTC视频通话是基于房间来实现的,通话的双方要进入一个相同的房间id才能进行视频通话
-*/
/*
Room ID and user ID can be set on the RTC video call portal
RTC video call is implemented based on room. Both parties must enter the same room ID to make a video call
diff --git a/SwiftDemo/RTC/InteractiveVideo/RTCViewController.swift b/SwiftDemo/RTC/InteractiveVideo/RTCViewController.swift
index 6f32fe3..cbb60b0 100644
--- a/SwiftDemo/RTC/InteractiveVideo/RTCViewController.swift
+++ b/SwiftDemo/RTC/InteractiveVideo/RTCViewController.swift
@@ -8,13 +8,6 @@
import TXLiteAVSDK_TRTC_Mac
import Cocoa
-/*
- RTC视频通话的主页面
- 包含如下简单功能:
- - 进入/退出视频通话房间
- - 打开/关闭摄像头
- - 打开/关闭麦克风
-*/
/*
The main page of an RTC video call
Contains the following simple functions:
diff --git a/SwiftDemo/RTC/LocalRecord/RTCLocalRecordViewController.swift b/SwiftDemo/RTC/LocalRecord/RTCLocalRecordViewController.swift
index 3304a6e..8d0b27a 100644
--- a/SwiftDemo/RTC/LocalRecord/RTCLocalRecordViewController.swift
+++ b/SwiftDemo/RTC/LocalRecord/RTCLocalRecordViewController.swift
@@ -9,16 +9,6 @@
import TXLiteAVSDK_TRTC_Mac
import Cocoa
-/*
- 本地媒体录制示例
- TRTC APP 支持本地媒体录制功能
- 本文件展示如何集成本地媒体录制功能
- 1、进入TRTC房间。 API:trtcCloud.enterRoom(params, appScene: .videoCall)
- 2、开启本地录制。 API:trtcCloud.startLocalRecording(recordParams)
- 3、结束本地录制。 API:trtcCloud.stopLocalRecording()
- 4、设置TRTC的关键代码。 API:viewWillAppear()
- 参考文档:https://cloud.tencent.com/document/product/647/32258
- */
/*
Local Recording
The TRTC app supports local recording.
diff --git a/SwiftDemo/RTC/ScreenSharing/RTCScreenSharingViewController.swift b/SwiftDemo/RTC/ScreenSharing/RTCScreenSharingViewController.swift
index ad44ac5..e97052d 100644
--- a/SwiftDemo/RTC/ScreenSharing/RTCScreenSharingViewController.swift
+++ b/SwiftDemo/RTC/ScreenSharing/RTCScreenSharingViewController.swift
@@ -8,13 +8,6 @@
import TXLiteAVSDK_TRTC_Mac
import Cocoa
-/*
- 屏幕分享功能示例
- TRTC APP 支持设置屏幕分享功能
- 本文件展示如何集成设置屏幕分享功能
- 1、进入TRTC房间 API:trtcCloud.enterRoom(param, appScene: .videoCall)
- 2、打开屏幕分享功能 API:onShareScreenClicked(_ sender: NSButton)
- */
/*
Example of screen sharing
TRTC APP supports setting screen sharing function
diff --git a/SwiftDemo/RTC/SetAudioEffect/RTCSetAudioEffectViewController.swift b/SwiftDemo/RTC/SetAudioEffect/RTCSetAudioEffectViewController.swift
index 1a13b53..33c6e46 100644
--- a/SwiftDemo/RTC/SetAudioEffect/RTCSetAudioEffectViewController.swift
+++ b/SwiftDemo/RTC/SetAudioEffect/RTCSetAudioEffectViewController.swift
@@ -9,15 +9,6 @@
import TXLiteAVSDK_TRTC_Mac
import Cocoa
-/*
- 设置音效功能示例
- TRTC APP 支持设置音效功能
- 本文件展示如何集成设置音效功能
- 1、进入TRTC房间 API: trtcCloud.enterRoom(param, appScene: .LIVE)
- 2、选择变声 API: trtcCloud.sharedInstance().getAudioEffectManager().setVoiceChangerType(voicechange)
- 3、选择混响 API: trtcCloud.sharedInstance().getAudioEffectManager().setVoiceReverbType(reverb)
- 参考文档:https://cloud.tencent.com/document/product/647/32258
- */
/*
Setting Audio Effects
The TRTC app supports audio effect setting.
diff --git a/SwiftDemo/RTC/SetAudioQuality/RTCSetAudioQualityViewController.swift b/SwiftDemo/RTC/SetAudioQuality/RTCSetAudioQualityViewController.swift
index ff87a96..c17bf4d 100644
--- a/SwiftDemo/RTC/SetAudioQuality/RTCSetAudioQualityViewController.swift
+++ b/SwiftDemo/RTC/SetAudioQuality/RTCSetAudioQualityViewController.swift
@@ -9,14 +9,6 @@
import TXLiteAVSDK_TRTC_Mac
import Cocoa
-/*
-设置音频质量功能
- TRTC APP 设置音频质量功能
- 本文件展示如何集成设置音频质量功能
- 1、设置音频质量 API: trtcCloud.startLocalAudio(.music)
- 2、设置TRTC的关键代码 API:viewWillAppear()
- 参考文档:https://cloud.tencent.com/document/product/647/32258
- */
/*
Setting Audio Quality
TRTC Audio Quality Setting
diff --git a/SwiftDemo/RTC/SetBackgroundMusic/RTCSetBackgroundMusicViewController.swift b/SwiftDemo/RTC/SetBackgroundMusic/RTCSetBackgroundMusicViewController.swift
index 75a09f1..8afcc91 100644
--- a/SwiftDemo/RTC/SetBackgroundMusic/RTCSetBackgroundMusicViewController.swift
+++ b/SwiftDemo/RTC/SetBackgroundMusic/RTCSetBackgroundMusicViewController.swift
@@ -9,17 +9,6 @@
import TXLiteAVSDK_TRTC_Mac
import Cocoa
-/*
- 设置背景音乐功能示例
- TRTC APP 支持设置背景音乐功能
- 本文件展示如何集成设置背景音乐功能
- 1、进入TRTC房间 API: trtcCloud.enterRoom(params, appScene: .LIVE)
- 2、播放背景音乐 API:
- trtcCloud.getAudioEffectManager().startPlayMusic(bgmParam) { errCode in } onProgress: { progressMs, durationMs in } onComplete: { errCode in }
- 3、设置TRTC的关键代码 API: startPushStream()
- API:trtcCloud.getAudioEffectManager().startPlayMusic(bgmParam) { errCode in } onProgress: { progressMs, durationMs in } onComplete: { errCode in }
- 参考文档:https://cloud.tencent.com/document/product/647/32258
- */
/*
Setting Background Music
The TRTC app supports background music setting.
diff --git a/SwiftDemo/RTC/SetVideoQuality/RTCSetVideoQualityViewController.swift b/SwiftDemo/RTC/SetVideoQuality/RTCSetVideoQualityViewController.swift
index 64f4081..d6adb56 100644
--- a/SwiftDemo/RTC/SetVideoQuality/RTCSetVideoQualityViewController.swift
+++ b/SwiftDemo/RTC/SetVideoQuality/RTCSetVideoQualityViewController.swift
@@ -9,15 +9,6 @@
import TXLiteAVSDK_TRTC_Mac
import Cocoa
-/*
-设置画面质量功能
- TRTC APP 设置画面质量功能
- 本文件展示如何集成设置画面质量功能
- 1、设置分辨率 API: videoEncParam.videoResolution = videoConfigs[row].resolution;
- 2、设置码率 API: videoEncParam.videoBitrate = videoConfigs[row].bitrate;
- 3、设置帧率 API: trtcCloud.setVideoEncoderParam(videoEncParam);
- 参考文档:https://cloud.tencent.com/document/product/647/32236
- */
/*
Setting Video Quality
diff --git a/SwiftDemo/RTC/StringRoomId/RTCStringRoomIdViewController.swift b/SwiftDemo/RTC/StringRoomId/RTCStringRoomIdViewController.swift
index 438c355..de8f594 100644
--- a/SwiftDemo/RTC/StringRoomId/RTCStringRoomIdViewController.swift
+++ b/SwiftDemo/RTC/StringRoomId/RTCStringRoomIdViewController.swift
@@ -9,15 +9,6 @@
import TXLiteAVSDK_TRTC_Mac
import Cocoa
-/*
- 字符串房间号功能示例
- TRTC APP 支持字符串房间号功能
- 本文件展示如何集成字符串房间号功能
- 1、设置字符串房间号 API: param.roomId = UInt32((roomId as NSString).intValue)
- 2、进入TRTC房间 API: trtcCloud.enterRoom(params, appScene: .LIVE)
- 3、设置TRTC的关键代码 API: viewWillAppear()
- 参考文档:https://cloud.tencent.com/document/product/647/32258
- */
/*
String-type Room ID
The TRTC app supports string-type room IDs.
diff --git a/SwiftDemo/debug/GenerateTestUserSig.swift b/SwiftDemo/debug/GenerateTestUserSig.swift
index 2734db5..cd14228 100644
--- a/SwiftDemo/debug/GenerateTestUserSig.swift
+++ b/SwiftDemo/debug/GenerateTestUserSig.swift
@@ -1,19 +1,19 @@
/*
- * Module: GenerateTestUserSig
+ * Module: GenerateTestUserSig
*
- * Function: 用于生成测试用的 UserSig,UserSig 是腾讯云为其云服务设计的一种安全保护签名。
- * 其计算方法是对 SDKAPPID、UserID 和 EXPIRETIME 进行加密,加密算法为 HMAC-SHA256。
+ * Function: used to generate UserSig for testing. UserSig is a security protection signature designed by Tencent Cloud for its cloud services.
+ * The calculation method is to encrypt SDKAPPID, UserID and EXPIRETIME, and the encryption algorithm is HMAC-SHA256.
*
- * Attention: 请不要将如下代码发布到您的线上正式版本的 App 中,原因如下:
+ * Attention: Please do not publish the following code into your online official version of the App for the following reasons:
*
- * 本文件中的代码虽然能够正确计算出 UserSig,但仅适合快速调通 SDK 的基本功能,不适合线上产品,
- * 这是因为客户端代码中的 SDKSECRETKEY 很容易被反编译逆向破解,尤其是 Web 端的代码被破解的难度几乎为零。
- * 一旦您的密钥泄露,攻击者就可以计算出正确的 UserSig 来盗用您的腾讯云流量。
+ * Although the code in this file can correctly calculate UserSig, it is only suitable for quickly adjusting the basic functions of the SDK and is not suitable for online products.
+ * This is because the SDKSECRETKEY in the client code is easily decompiled and reverse-engineered, especially the web-side code, which is almost zero difficulty in cracking.
+ * Once your key is leaked, an attacker can calculate the correct UserSig to steal your Tencent Cloud traffic.
*
- * 正确的做法是将 UserSig 的计算代码和加密密钥放在您的业务服务器上,然后由 App 按需向您的服务器获取实时算出的 UserSig。
- * 由于破解服务器的成本要高于破解客户端 App,所以服务器计算的方案能够更好地保护您的加密密钥。
+ * The correct approach is to put the UserSig calculation code and encryption key on your business server, and then have the App obtain the real-time calculated UserSig from your server on demand.
+ * Since it is more expensive to crack a server than a client app, a server-computed approach better protects your encryption keys.
*
- * Reference:https://cloud.tencent.com/document/product/269/32688#Server
+ * Reference: https://cloud.tencent.com/document/product/269/32688#Server
*/
import Foundation
@@ -21,17 +21,17 @@ import CommonCrypto
import zlib
/**
- * 腾讯云直播license管理页面(https://console.cloud.tencent.com/live/license)
- * 当前应用的License LicenseUrl
+ * Tencent Cloud Live License Management Page (https://console.cloud.tencent.com/live/license)
+ * Currently applied license LicenseUrl
*
- * License Management View (https://console.cloud.tencent.com/live/license)
- * License URL of your application
+ * License management view (https://console.cloud.tencent.com/live/license)
+ * The license URL for your application
*/
let LICENSEURL = ""
/**
- * 腾讯云直播license管理页面(https://console.cloud.tencent.com/live/license)
- * 当前应用的License Key
+ * Tencent Cloud Live License Management Page (https://console.cloud.tencent.com/live/license)
+ * Currently applied License Key
*
* License Management View (https://console.cloud.tencent.com/live/license)
* License key of your application
@@ -39,97 +39,97 @@ let LICENSEURL = ""
let LICENSEURLKEY = ""
/**
- * 腾讯云 SDKAppId,需要替换为您自己账号下的 SDKAppId。
+ * Tencent Cloud SDKAppId needs to be replaced with the SDKAppId under your own account.
*
- * 进入腾讯云云通信[控制台](https://console.cloud.tencent.com/avc) 创建应用,即可看到 SDKAppId,
- * 它是腾讯云用于区分客户的唯一标识。
+ * Enter Tencent Cloud Communication [Console] (https://console.cloud.tencent.com/avc) to create an application and you will see the SDKAppId.
+ * is the unique identifier used by Tencent Cloud to distinguish customers.
*/
let SDKAPPID: Int = 0
/**
- * 签名过期时间,建议不要设置的过短
+ * It is recommended not to set the signature expiration time too short.
*
- * 时间单位:秒
- * 默认时间:7 x 24 x 60 x 60 = 604800 = 7 天
+ * Time unit: seconds
+ *Default time: 7 x 24 x 60 x 60 = 604800 = 7 days
*/
let EXPIRETIME: Int = 604800
/**
- * CDN发布功能 混流appId
+ * CDN publishing function mixed streaming appId
*/
let CDNAPPID = 0
/**
- * CDN发布功能 混流bizId
+ * CDN publishing function mixed bizId
*/
let CDNBIZID = 0
/**
- * CDN发布功能 混流CDN_URL
+ * CDN publishing function mixed flow CDN_URL
*/
let kCDN_URL: String = ""
/**
- * 计算签名用的加密密钥,获取步骤如下:
+ * The encryption key used to calculate the signature, the steps to obtain are as follows:
*
- * step1. 进入腾讯云云通信[控制台](https://console.cloud.tencent.com/avc) ,如果还没有应用就创建一个,
- * step2. 单击“应用配置”进入基础配置页面,并进一步找到“帐号体系集成”部分。
- * step3. 点击“查看密钥”按钮,就可以看到计算 UserSig 使用的加密的密钥了,请将其拷贝并复制到如下的变量中
+ * step1. Enter Tencent Cloud Communication [Console](https://console.cloud.tencent.com/avc), if there is no application yet, create one.
+ * step2. Click "Application Configuration" to enter the basic configuration page, and further find the "Account System Integration" section.
+ * step3. Click the "View Key" button to see the encrypted key used to calculate UserSig. Please copy it to the following variable
*
- * 注意:该方案仅适用于调试Demo,正式上线前请将 UserSig 计算代码和密钥迁移到您的后台服务器上,以避免加密密钥泄露导致的流量盗用。
- * 文档:https://cloud.tencent.com/document/product/269/32688#Server
+ * Note: This solution is only suitable for debugging Demo. Please migrate the UserSig calculation code and key to your backend server before official launch to avoid traffic theft caused by encryption key leakage.
+ * Document: https://cloud.tencent.com/document/product/269/32688#Server
*/
let SDKSECRETKEY = ""
/**
- * 计算 UserSig 签名
+ * Calculate UserSig signature
*
- * 函数内部使用 HMAC-SHA256 非对称加密算法,对 SDKAPPID、userId 和 EXPIRETIME 进行加密。
+ * The HMAC-SHA256 asymmetric encryption algorithm is used internally to encrypt SDKAPPID, userId and EXPIRETIME.
*
- * @note: 请不要将如下代码发布到您的线上正式版本的 App 中,原因如下:
+ * @note: Please do not publish the following code into your online official version of the App for the following reasons:
*
- * 本文件中的代码虽然能够正确计算出 UserSig,但仅适合快速调通 SDK 的基本功能,不适合线上产品,
- * 这是因为客户端代码中的 SDKSECRETKEY 很容易被反编译逆向破解,尤其是 Web 端的代码被破解的难度几乎为零。
- * 一旦您的密钥泄露,攻击者就可以计算出正确的 UserSig 来盗用您的腾讯云流量。
+ * Although the code in this file can correctly calculate UserSig, it is only suitable for quickly adjusting the basic functions of the SDK and is not suitable for online products.
+ * This is because the SDKSECRETKEY in the client code is easily decompiled and reverse-engineered, especially the web-side code, which is almost zero difficulty in cracking.
+ * Once your key is compromised, an attacker can calculate the correct UserSig to steal your Tencent Cloud traffic.
*
- * 正确的做法是将 UserSig 的计算代码和加密密钥放在您的业务服务器上,然后由 App 按需向您的服务器获取实时算出的 UserSig。
- * 由于破解服务器的成本要高于破解客户端 App,所以服务器计算的方案能够更好地保护您的加密密钥。
+ * The correct approach is to put the UserSig calculation code and encryption key on your business server, and then have the App obtain the real-time calculated UserSig from your server on demand.
+ * Since it is more expensive to crack a server than a client app, a server-computed approach better protects your encryption keys.
*
- * 文档:https://cloud.tencent.com/document/product/269/32688#Server
+ * Document: https://cloud.tencent.com/document/product/269/32688#Server
*/
let PUSHURL = ""
/**
- * 配置的拉流地址
+ * Configured streaming address
*
- * 腾讯云域名管理页面:https://console.cloud.tencent.com/live/domainmanage
+ * Tencent Cloud domain name management page: https://console.cloud.tencent.com/live/domainmanage
*/
let PLAY_DOMAIN: String = ""
/**
- * 配置的后台服务域名,类似:https://service-3vscss6c-xxxxxxxxxxx.gz.apigw.tencentcs.com"
+ * Configured background service domain name, similar to: https://service-3vscss6c-xxxxxxxxxxx.gz.apigw.tencentcs.com"
*
- * 小直播后台提供有登录、房间列表等服务,更多细节见文档:https://cloud.tencent.com/document/product/454/38625
+ * The small live broadcast backend provides services such as login and room list. For more details, please see the document: https://cloud.tencent.com/document/product/454/38625
*/
let SERVERLESSURL = ""
class GenerateTestUserSig {
/**
- * 计算 UserSig 签名
+ * Calculate UserSig signature
*
- * 函数内部使用 HMAC-SHA256 非对称加密算法,对 SDKAPPID、userId 和 EXPIRETIME 进行加密。
+ * The HMAC-SHA256 asymmetric encryption algorithm is used internally to encrypt SDKAPPID, userId and EXPIRETIME.
*
- * @note: 请不要将如下代码发布到您的线上正式版本的 App 中,原因如下:
+ * @note: Please do not publish the following code into your online official version of the App for the following reasons:
*
- * 本文件中的代码虽然能够正确计算出 UserSig,但仅适合快速调通 SDK 的基本功能,不适合线上产品,
- * 这是因为客户端代码中的 SDKSECRETKEY 很容易被反编译逆向破解,尤其是 Web 端的代码被破解的难度几乎为零。
- * 一旦您的密钥泄露,攻击者就可以计算出正确的 UserSig 来盗用您的腾讯云流量。
+ * Although the code in this file can correctly calculate UserSig, it is only suitable for quickly adjusting the basic functions of the SDK and is not suitable for online products.
+ * This is because the SDKSECRETKEY in the client code is easily decompiled and reverse-engineered, especially the web-side code, which is almost zero difficulty in cracking.
+ * Once your key is compromised, an attacker can calculate the correct UserSig to steal your Tencent Cloud traffic.
*
- * 正确的做法是将 UserSig 的计算代码和加密密钥放在您的业务服务器上,然后由 App 按需向您的服务器获取实时算出的 UserSig。
- * 由于破解服务器的成本要高于破解客户端 App,所以服务器计算的方案能够更好地保护您的加密密钥。
+ * The correct approach is to put the UserSig calculation code and encryption key on your business server, and then have the App obtain the real-time calculated UserSig from your server on demand.
+ * Since it is more expensive to crack a server than a client app, a server-computed approach better protects your encryption keys.
*
- * 文档:https://cloud.tencent.com/document/product/647/17275#Server
+ * Document: https://cloud.tencent.com/document/product/647/17275#Server
*/
class func genTestUserSig(identifier: String) -> String {
let current = CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970