Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ build/
*.codecc/
/build.yml
tuicore
tuiofflinepush
22 changes: 12 additions & 10 deletions Android/app/src/main/java/com/tencent/liteav/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,22 @@ public void onClick(View v) {
private void initData() {
final UserModel userModel = UserModelManager.getInstance().getUserModel();
mTRTCChatSalon = TRTCChatSalon.sharedInstance(this);
mTRTCChatSalon.login(GenerateTestUserSig.SDKAPPID, userModel.userId, userModel.userSig, new TRTCChatSalonCallback.ActionCallback() {
@Override
public void onCallback(int code, String msg) {
Log.d(TAG, "code: " + code + " msg:" + msg);
mTRTCChatSalon.setSelfProfile(userModel.userName, userModel.userAvatar, new TRTCChatSalonCallback.ActionCallback() {
mTRTCChatSalon.login(GenerateTestUserSig.SDKAPPID, userModel.userId, userModel.userSig,
new TRTCChatSalonCallback.ActionCallback() {
@Override
public void onCallback(int code, String msg) {
if (code == 0) {
Log.d(TAG, "setSelfProfile success");
}
Log.d(TAG, "code: " + code + " msg:" + msg);
mTRTCChatSalon.setSelfProfile(userModel.userName, userModel.userAvatar,
new TRTCChatSalonCallback.ActionCallback() {
@Override
public void onCallback(int code, String msg) {
if (code == 0) {
Log.d(TAG, "setSelfProfile success");
}
}
});
}
});
}
});
}

private void createRoom() {
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 @@ -22,10 +24,10 @@ allprojects {
flatDir {
dirs project(':app').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 @@ -79,6 +79,56 @@ public class GenerateTestUserSig {
*/
private static final String SECRETKEY = "PLACEHOLDER";


/**
* Xmagic美颜证书url
* <p>
* 详细内容见https://cloud.tencent.com/document/product/616/65878
* </p>
*/
public static final String XMAGIC_LICENSE_URL = "PLACEHOLDER";

/**
* Xmagic美颜证书url
* <p>
* 详细内容见https://cloud.tencent.com/document/product/616/65878
* </p>
*/
public static final String XMAGIC_LICENSE_KEY = "PLACEHOLDER";


/**
* 腾讯云直播license管理页面(https://console.cloud.tencent.com/live/license)
* 当前应用的License LicenseUrl
* <p>
* License Management View (https://console.cloud.tencent.com/live/license)
* License URL of your application
*/
public static final String LICENSEURL = "请替换成您的licenseURL";

/**
* 腾讯云直播license管理页面(https://console.cloud.tencent.com/live/license)
* 当前应用的License Key
* <p>
* License Management View (https://console.cloud.tencent.com/live/license)
* License key of your application
*/
public static final String LICENSEURLKEY = "请替换成您的licenseKey";

/**
* 配置的后台服务域名,类似:https://service-3vscss6c-xxxxxxxxxxx.gz.apigw.tencentcs.com"
* <p>
* 小直播后台提供有登录、房间列表等服务,更多细节见文档:https://cloud.tencent.com/document/product/454/38625
*/
public static final String SERVERLESSURL = "PLACEHOLDER";

/**
* 配置的播放域名
* <p>
* 腾讯云域名管理页面:https://console.cloud.tencent.com/live/domainmanage
*/
public static final String PLAY_DOMAIN = "PLACEHOLDER";

/**
* Calculating UserSig
* <p>
Expand Down
4 changes: 2 additions & 2 deletions Android/tuichatsalon/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 'com.tencent.liteav.tuikit:tuicore:latest.release'
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
package com.tencent.liteav.basic;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Utils {

private static final String[] hexDigits = {"0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};

private static MessageDigest messageDigest = null;

static {
try {
messageDigest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}

public static String getFileMD5String(File file) {
String ret = "";
FileInputStream in = null;
FileChannel ch = null;
try {
in = new FileInputStream(file);
ch = in.getChannel();
ByteBuffer byteBuffer = ch.map(FileChannel.MapMode.READ_ONLY, 0,
file.length());
messageDigest.update(byteBuffer);
ret = bytesToHex(messageDigest.digest());
} catch (IOException e) {
e.printStackTrace();

} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (ch != null) {
try {
ch.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return ret;
}

public static String getFileMD5String(String fileName) {
return getFileMD5String(new File(fileName));
}

public static String getMD5String(String sourceStr) {
return getMD5String(sourceStr.getBytes());
}

public static String getMD5String(byte[] bytes) {
messageDigest.update(bytes);
return bytesToHex(messageDigest.digest());
}

public static boolean checkPassword(String pwd, String md5) {
return getMD5String(pwd).equalsIgnoreCase(md5);
}

public static boolean checkPassword(char[] pwd, String md5) {
return checkPassword(new String(pwd), md5);

}

public static boolean checkFileMD5(File file, String md5) {
return getFileMD5String(file).equalsIgnoreCase(md5);

}

public static boolean checkFileMD5(String fileName, String md5) {
return checkFileMD5(new File(fileName), md5);

}

public static String bytesToHex(byte[] bytes) {
return bytesToHex(bytes, 0, bytes.length);

}

public static String bytesToHex(byte[] bytes, int start, int end) {
StringBuilder sb = new StringBuilder();
for (int i = start; i < start + end; i++) {
sb.append(byteToHex(bytes[i]));
}
return sb.toString();

}

public static String byteToHex(byte bt) {
return hexDigits[(bt & 0xf0) >> 4] + "" + hexDigits[bt & 0xf];

}

public static String parseUrlToFileName(String urlStr)
throws UnsupportedEncodingException, NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] results = md.digest(urlStr.getBytes(StandardCharsets.UTF_8));
return byteArrayToHexString(results);
}

private static String byteArrayToHexString(byte[] b) {
StringBuffer resultSb = new StringBuffer();
for (int i = 0; i < b.length; i++) {
resultSb.append(byteToHexString(b[i]));
}
return resultSb.toString();
}

private static String byteToHexString(byte b) {
int n = b;
if (n < 0) {
n = 256 + n;
}
int d1 = n / 16;
int d2 = n % 16;
return hexDigits[d1] + hexDigits[d2];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private void loadUserModel() {
String json = SPUtils.getInstance(PER_DATA).getString(PER_USER_MODEL);
mUserModel = GsonUtils.fromJson(json, UserModel.class);
} catch (Exception e) {
Log.d(TAG, "loadUserModel failed:" + e.getMessage());
}
}

Expand All @@ -77,6 +78,7 @@ private void setUserPublishVideoDate(String date) {
try {
SPUtils.getInstance(PER_DATA).put(PER_USER_DATE, mUserPubishVideoDate);
} catch (Exception e) {
Log.d(TAG, "setUserPublishVideoDate failed:" + e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ChatSalonRoomManager {
private static final String TAG = "ChatSalonRoomManager";

private static ChatSalonRoomManager sInstance;
private RoomCallback mRoomCallback;
private RoomCallback mRoomCallback;

public static ChatSalonRoomManager getInstance() {
if (sInstance == null) {
Expand Down Expand Up @@ -49,11 +49,13 @@ public void destroyRoom(int roomId, ActionCallback callback) {

public interface RoomCallback {
void onRoomCreate(int roomId, ActionCallback callback);

void onRoomDestroy(int roomId, ActionCallback callback);
}

public interface ActionCallback {
void onSuccess();

void onError(int errorCode, String message);
}

Expand All @@ -64,7 +66,7 @@ public void getGroupInfo(final String roomId, final GetGroupInfoCallback callbac
V2TIMManager.getGroupManager().getGroupsInfo(roomIdList, new V2TIMValueCallback<List<V2TIMGroupInfoResult>>() {
@Override
public void onError(int i, String s) {
Log.e(TAG, "get group info list fail, code:" + i+ " msg: " + s);
Log.e(TAG, "get group info list fail, code:" + i + " msg: " + s);
callback.onFailed(-1, s);
}

Expand All @@ -83,6 +85,7 @@ public void onSuccess(List<V2TIMGroupInfoResult> resultList) {
// 通过房间号获取房间信息的回调
public interface GetGroupInfoCallback {
void onSuccess(V2TIMGroupInfoResult result);

void onFailed(int code, String msg);
}
}
Loading