Skip to content

Commit

Permalink
Merge pull request Tencent-RTC#55 from 3598906645/release-10.6.11181
Browse files Browse the repository at this point in the history
release-10.6.11181
  • Loading branch information
masonqiaoA authored Sep 2, 2022
2 parents 55cbb99 + c33dd95 commit d625cef
Show file tree
Hide file tree
Showing 18 changed files with 306 additions and 123 deletions.
2 changes: 2 additions & 0 deletions Android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ build/
.cxx
*.codecc/
/build.yml
tuicore
tuiofflinepush
12 changes: 5 additions & 7 deletions Android/README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ TUILiveRoom
### Step 2. Download the source code and configure the project

1. Open the demo project `TUILiveRoom` with Android Studio (3.5 or above).
2. Find and open the `TUILiveRoom/Android/debug/src/main/java/com/tencent/liteav/debug/GenerateGlobalConfig.java`file.
3. Set parameters in `GenerateGlobalConfig.java` as follows:
2. Find and open the `TUILiveRoom/Android/debug/src/main/java/com/tencent/liteav/debug/GenerateTestUserSig.java`file.
3. Set parameters in `GenerateTestUserSig.java` as follows:

<ul>
<li>SDKAPPID: 0 by default. Replace it with your actual `SDKAPPID`.</li>
Expand Down Expand Up @@ -75,9 +75,7 @@ You can open the source code project `TUILiveRoom/Android` in Android Studio 3.5
|---------|---------|
| <img src="https://liteav.sdk.qcloud.com/doc/res/trtc/picture/zh-cn/user_b_ios.png" width="320"/> | <img src="https://qcloudimg.tencent-cloud.cn/raw/fe39e76723f304de52b9d677a8cebf97.png" width="320"/> |

## Have any questions?
Welcome to join our Telegram Group to communicate with our professional engineers! We are more than happy to hear from you~
Click to join: https://t.me/+EPk6TMZEZMM5OGY1
Or scan the QR code
## FAQs

<img src="https://qcloudimg.tencent-cloud.cn/raw/9c67ed5746575e256b81ce5a60216c5a.jpg" width="320"/>
- [FAQs About TUI Scenario-Specific Solution](https://cloud.tencent.com/developer/article/1952880)
- [Contact us](https://intl.cloud.tencent.com/contact-us)
4 changes: 2 additions & 2 deletions Android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ TUILiveRoom
### 第二步:下载源码,配置工程

1. 使用 Android Studio(3.5及以上的版本)打开源码工程`TUILiveRoom `
2. 找到并打开`TUILiveRoom/Android/debug/src/main/java/com/tencent/liteav/debug/GenerateGlobalConfig.java`文件。
3. 设置`GenerateGlobalConfig.java`文件中的相关参数:
2. 找到并打开`TUILiveRoom/Android/debug/src/main/java/com/tencent/liteav/debug/GenerateTestUserSig.java`文件。
3. 设置`GenerateTestUserSig.java`文件中的相关参数:

<ul>
<li>SDKAPPID:默认为 0 ,请设置为实际申请的SDKAPPID。</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.tencent.liteav.basic.AvatarConstant;
import com.tencent.liteav.basic.UserModel;
import com.tencent.liteav.basic.UserModelManager;
import com.tencent.liteav.debug.GenerateGlobalConfig;
import com.tencent.liteav.debug.GenerateTestUserSig;

import java.util.Random;

Expand Down Expand Up @@ -66,7 +66,7 @@ private void login() {
int index = new Random().nextInt(AvatarConstant.USER_AVATAR_ARRAY.length);
String coverUrl = AvatarConstant.USER_AVATAR_ARRAY[index];
userModel.userAvatar = coverUrl;
userModel.userSig = GenerateGlobalConfig.genTestUserSig(userId);
userModel.userSig = GenerateTestUserSig.genTestUserSig(userId);
final UserModelManager manager = UserModelManager.getInstance();
manager.setUserModel(userModel);
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.tencent.liteav.basic.IntentUtils;

import com.tencent.liteav.basic.UserModelManager;
import com.tencent.liteav.debug.GenerateGlobalConfig;
import com.tencent.liteav.debug.GenerateTestUserSig;
import com.tencent.liteav.liveroom.TUILiveRoom;
import com.tencent.liteav.liveroom.ui.common.utils.TCConstants;
import com.tencent.qcloud.tuicore.TUILogin;
Expand Down Expand Up @@ -81,8 +81,8 @@ public void onUserSigExpired() {
if (TextUtils.isEmpty(userId)) {
Toast.makeText(this, getString(R.string.toast_login_success), Toast.LENGTH_SHORT).show();
}
TUILogin.login(this, GenerateGlobalConfig.SDKAPPID, userId,
GenerateGlobalConfig.genTestUserSig(userId), new TUICallback() {
TUILogin.login(this, GenerateTestUserSig.SDKAPPID, userId,
GenerateTestUserSig.genTestUserSig(userId), new TUICallback() {
@Override
public void onSuccess() {

Expand Down
16 changes: 9 additions & 7 deletions Android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
buildscript {

repositories {
jcenter()
google()
mavenCentral()

// TUIOfflinePush : configure HMS Core SDK Maven address, delete it without the Huawei offline push function.
maven { url 'https://developer.huawei.com/repo/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// TUIOfflinePush: Huawei, delete it without Huawei offline push function
classpath 'com.huawei.agconnect:agcp:1.4.1.300'

// TUIOfflinePush : Google(FCM), delete it without Google offline push function
classpath 'com.google.gms:google-services:4.3.10'
}
}

Expand All @@ -23,10 +25,10 @@ allprojects {
dirs project(':app').file('libs')
dirs project(':tuibeauty').file('libs')
}
jcenter()
google()
mavenCentral()

// TUIOfflinePush : delete it without the Huawei offline push function.
maven { url 'https://developer.huawei.com/repo/' }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,72 @@
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

/**
* Module: GenerateGlobalConfig
* <p>
* 此文件提供有关于小直播编译过程中需要配置等所有变量,需要您根据自己的产品参数自行设置
* <p>
* 更多细节见腾讯云官网文档:https://cloud.tencent.com/document/product/454/38625
/*
*
*
* Description: Generates UserSig for testing. UserSig is a security signature designed
* by Tencent Cloud for its cloud services.
* It is calculated based on `SDKAppID`, `UserID`,
* and `EXPIRETIME` using the HMAC-SHA256 encryption algorithm.
*
* Attention: For the following reasons, do not use the code below in your commercial application.
*
* The code may be able to calculate UserSig correctly, b
* ut it is only for quick testing of the SDK’s basic features,
* not for commercial applications.
* `SECRETKEY` in client code can be easily decompiled and reversed, especially on web.
* Once your key is disclosed, attackers will be able to steal your Tencent Cloud traffic.
*
* The correct method is to deploy the `UserSig` calculation code and encryption key on your server
* so that your application can request a `UserSig` from your server,
* which will calculate it whenever one is needed.
* Given that it is more difficult to hack a server than a client application,
* server-end calculation can better protect your key.
*
* Reference: https://cloud.tencent.com/document/product/269/32688#Server
*/
public class GenerateGlobalConfig {
public class GenerateTestUserSig {

/**
* 腾讯云直播license管理页面(https://console.cloud.tencent.com/live/license)
* 当前应用的License LicenseUrl
* Tencent Cloud SDKAppID. Set it to the SDKAppID of your account.
* <p>
* License Management View (https://console.cloud.tencent.com/live/license)
* License URL of your application
* You can view your `SDKAppId` after creating an application in the [Tencent Cloud IM console](https://console.cloud.tencent.com/avc).
* SDKAppID uniquely identifies a Tencent Cloud account.
*/
public static final String LICENSEURL = "请替换成您的licenseURL";
public static final int SDKAPPID = PLACEHOLDER;


/**
* 腾讯云直播license管理页面(https://console.cloud.tencent.com/live/license)
* 当前应用的License Key
* Signature validity period, which should not be set too short
* <p>
* License Management View (https://console.cloud.tencent.com/live/license)
* License key of your application
* Unit: Second
* Default value: 604800 (seven days)
*/
public static final String LICENSEURLKEY = "请替换成您的licenseKey";
private static final int EXPIRETIME = 604800;

/**
* 配置的后台服务域名,类似:https://service-3vscss6c-xxxxxxxxxxx.gz.apigw.tencentcs.com"
* Sends request for the pull/push address from the backend
* <p>
* 小直播后台提供有登录、房间列表等服务,更多细节见文档:https://cloud.tencent.com/document/product/454/38625
* key: url_push Gets the RTMP push address
* key: url_play_flv Gets the FLV playback address
*/
public static final String SERVERLESSURL = "PLACEHOLDER";
public static final String URL_FETCH_PUSH_URL = "PLACEHOLDER";

/**
* 配置的播放域名
* Follow the steps below to obtain the key required for UserSig calculation.
* <p>
* 腾讯云域名管理页面:https://console.cloud.tencent.com/live/domainmanage
* Step 1. Log in to the [IM console](https://console.cloud.tencent.com/avc). If you don't have an application yet, create one.
* Step 2. Click your application and find “Basic Information”.
* Step 3. Click “Display Key” to view the key used for UserSig calculation.
* Copy and paste the key to the variable below.
* <p>
* Note: This method is for testing only. Before commercial launch,
* please migrate the UserSig calculation code and key to your backend server
* to prevent key disclosure and traffic stealing.
* Documentation: https://cloud.tencent.com/document/product/269/32688#Server
*/
public static final String PLAY_DOMAIN = "PLACEHOLDER";
private static final String SECRETKEY = "PLACEHOLDER";


/**
* Xmagic美颜证书url
Expand All @@ -70,67 +96,78 @@ public class GenerateGlobalConfig {
*/
public static final String XMAGIC_LICENSE_KEY = "PLACEHOLDER";


/**
* 腾讯云 SDKAppId,需要替换为您自己账号下的 SDKAppId。
* 腾讯云直播license管理页面(https://console.cloud.tencent.com/live/license)
* 当前应用的License LicenseUrl
* <p>
* 进入腾讯云云通信[控制台](https://console.cloud.tencent.com/avc ) 创建应用,即可看到 SDKAppId,
* 它是腾讯云用于区分客户的唯一标识。
* License Management View (https://console.cloud.tencent.com/live/license)
* License URL of your application
*/
public static final int SDKAPPID = PLACEHOLDER;

public static final String LICENSEURL = "请替换成您的licenseURL";

/**
* 签名过期时间,建议不要设置的过短
* 腾讯云直播license管理页面(https://console.cloud.tencent.com/live/license)
* 当前应用的License Key
* <p>
* 时间单位:秒
* 默认时间:7 x 24 x 60 x 60 = 604800 = 7 天
* License Management View (https://console.cloud.tencent.com/live/license)
* License key of your application
*/
private static final int EXPIRETIME = 604800;
public static final String LICENSEURLKEY = "请替换成您的licenseKey";

/**
* 计算签名用的加密密钥,获取步骤如下:
* 配置的后台服务域名,类似:https://service-3vscss6c-xxxxxxxxxxx.gz.apigw.tencentcs.com"
* <p>
* step1. 进入腾讯云云通信[控制台](https://console.cloud.tencent.com/avc ) ,如果还没有应用就创建一个,
* step2. 单击“应用配置”进入基础配置页面,并进一步找到“帐号体系集成”部分。
* step3. 点击“查看密钥”按钮,就可以看到计算 UserSig 使用的加密的密钥了,请将其拷贝并复制到如下的变量中
* 小直播后台提供有登录、房间列表等服务,更多细节见文档:https://cloud.tencent.com/document/product/454/38625
*/
public static final String SERVERLESSURL = "PLACEHOLDER";

/**
* 配置的播放域名
* <p>
* 注意:该方案仅适用于调试Demo,正式上线前请将 UserSig 计算代码和密钥迁移到您的后台服务器上,以避免加密密钥泄露导致的流量盗用。
* 文档:https://cloud.tencent.com/document/product/269/32688#Server
* 腾讯云域名管理页面:https://console.cloud.tencent.com/live/domainmanage
*/
private static final String SECRETKEY = "PLACEHOLDER";
public static final String PLAY_DOMAIN = "PLACEHOLDER";

/**
* 计算 UserSig 签名
* Calculating UserSig
* <p>
* 函数内部使用 HMAC-SHA256 非对称加密算法,对 SDKAPPID、userId 和 EXPIRETIME 进行加密。
* The asymmetric encryption algorithm HMAC-SHA256 is used in the
* function to calculate UserSig based on `SDKAppID`, `UserID`, and `EXPIRETIME`.
*
* @note: 请不要将如下代码发布到您的线上正式版本的 App 中,原因如下:
* @note: For the following reasons, do not use the code below in your commercial application.
* <p>
* 本文件中的代码虽然能够正确计算出 UserSig,但仅适合快速调通 SDK 的基本功能,不适合线上产品,
* 这是因为客户端代码中的 SECRETKEY 很容易被反编译逆向破解,尤其是 Web 端的代码被破解的难度几乎为零。
* 一旦您的密钥泄露,攻击者就可以计算出正确的 UserSig 来盗用您的腾讯云流量。
* The code may be able to calculate UserSig correctly,
* but it is only for quick testing of the SDK’s basic features,
* not for commercial applications.
* SECRETKEY in client code can be easily decompiled and reversed, especially on web.
* Once your key is disclosed, attackers will be able to steal your Tencent Cloud traffic.
* <p>
* 正确的做法是将 UserSig 的计算代码和加密密钥放在您的业务服务器上,然后由 App 按需向您的服务器获取实时算出的 UserSig。
* 由于破解服务器的成本要高于破解客户端 App,所以服务器计算的方案能够更好地保护您的加密密钥。
* The correct method is to deploy the `UserSig` calculation code and encryption key on your server
* so that your application can request a `UserSig` from your server,
* which will calculate it whenever one is needed.
* Given that it is more difficult to hack a server than a client application,
* server-end calculation can better protect your key.
* <p>
* 文档:https://cloud.tencent.com/document/product/269/32688#Server
* Documentation: https://cloud.tencent.com/document/product/269/32688#Server
*/
public static String genTestUserSig(String userId) {
return genTLSSignature(SDKAPPID, userId, EXPIRETIME, null, SECRETKEY);
}

/**
* 生成 tls 票据
* Generating a TLS Ticket
*
* @param sdkappid 应用的 appid
* @param userId 用户 id
* @param expire 有效期,单位是秒
* @param userbuf 默认填写null
* @param priKeyContent 生成 tls 票据使用的私钥内容
* @return 如果出错,会返回为空,或者有异常打印,成功返回有效的票据
* @param sdkappid `appid` of your application
* @param userId User ID
* @param expire Validity period in seconds
* @param userbuf `null` by default
* @param priKeyContent Private key required for generating a TLS ticket
* @return If an error occurs, an empty string will be returned or exceptions printed.
* If the operation succeeds, a valid ticket will be returned.
*/
private static String genTLSSignature(long sdkappid, String userId, long expire,
byte[] userbuf, String priKeyContent) {
private static String genTLSSignature(long sdkappid, String userId,
long expire, byte[] userbuf, String priKeyContent) {
if (TextUtils.isEmpty(priKeyContent)) {
return "";
}
Expand Down Expand Up @@ -215,4 +252,5 @@ private static byte[] base64EncodeUrl(byte[] input) {
}
return base64;
}

}
4 changes: 2 additions & 2 deletions Android/tuiliveroom/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ dependencies {
api "com.squareup.retrofit2:retrofit:2.2.0"
api "com.squareup.okhttp3:okhttp:3.11.0"
api "com.github.bumptech.glide:glide:4.12.0"
api "com.github.ctiao:DanmakuFlameMaster:0.5.3"
api "com.github.ctiao:DanmakuFlameMaster:0.3.8"
api "de.hdodenhof:circleimageview:3.1.0"
api "com.google.code.gson:gson:2.3.1"
api "com.blankj:utilcode:1.25.9"
api "com.blankj:utilcode:1.30.7"
api rootProject.ext.liteavSdk
api rootProject.ext.imSdk
api project(':tuibeauty')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.tencent.liteav.basic;

public interface AvatarConstant {
String USER_AVATAR_ARRAY [] = {
String[] USER_AVATAR_ARRAY = {
"https://liteav.sdk.qcloud.com/app/res/picture/voiceroom/avatar/user_avatar1.png",
"https://liteav.sdk.qcloud.com/app/res/picture/voiceroom/avatar/user_avatar2.png",
"https://liteav.sdk.qcloud.com/app/res/picture/voiceroom/avatar/user_avatar3.png",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public static void loadImage(Context context, ImageView imageView, String url, @
loadImage(context, imageView, url, errorResId, radius);
}

public static void loadImage(Context context, ImageView imageView, String url, @DrawableRes int errorResId, int radius) {
public static void loadImage(Context context, ImageView imageView, String url,
@DrawableRes int errorResId, int radius) {
if (TextUtils.isEmpty(url)) {
if (imageView != null && errorResId != 0) {
imageView.setImageResource(errorResId);
Expand Down Expand Up @@ -75,7 +76,8 @@ public static Bitmap getImage(Context context, String url, int width, int height
return null;
}

public static void loadImageThumbnail(Context context, ImageView imageView, String url, @DrawableRes int resourceId, int radius) {
public static void loadImageThumbnail(Context context, ImageView imageView,
String url, @DrawableRes int resourceId, int radius) {
Glide.with(context).load(url)
.apply(new RequestOptions().placeholder(resourceId).error(resourceId).centerCrop()
.transform(new GlideRoundTransform(imageView.getContext(), radius)))
Expand Down Expand Up @@ -120,7 +122,9 @@ protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, in
}

private static Bitmap roundCrop(BitmapPool pool, Bitmap source) {
if (source == null) return null;
if (source == null) {
return null;
}

Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
if (result == null) {
Expand Down
Loading

0 comments on commit d625cef

Please sign in to comment.