/
URLUtils.java
75 lines (66 loc) · 2.24 KB
/
URLUtils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.tencent.liteav.showlive.ui.utils;
import com.tencent.liteav.debug.GenerateTestUserSig;
import com.tencent.qcloud.tuicore.TUILogin;
import java.io.File;
/**
* MLVB 移动直播地址生成
* 详情请参考:「https://cloud.tencent.com/document/product/454/7915」
* <p>
* <p>
* Generating Streaming URLs
* See [https://cloud.tencent.com/document/product/454/7915].
*/
public class URLUtils {
public static final String WEBRTC = "webrtc://";
public static final String RTMP = "rtmp://";
public static final String HTTP = "http://";
public static final String TRTC = "trtc://";
public static final String TRTC_DOMAIN = "cloud.tencent.com";
public static final String APP_NAME = "live";
/**
* 生成推流地址
* Generating Publishing URLs
*
* @param streamId
* @param type
* @return
*/
public static String generatePushUrl(String streamId, PushType type) {
String pushUrl = "";
if (type == PushType.RTC) {
pushUrl = TRTC + TRTC_DOMAIN + "/push/" + streamId + "?sdkappid=" + TUILogin.getSdkAppId() + "&userid="
+ TUILogin.getUserId() + "&usersig=" + TUILogin.getUserSig();
}
return pushUrl;
}
/**
* 生成拉流地址
* Generating Playback URLs
*
* @param streamId
* @param type
* @return
*/
public static String generatePlayUrl(String streamId, PlayType type) {
String playUrl = "";
if (type == PlayType.RTC) {
playUrl = "trtc://cloud.tencent.com/play/" + streamId + "?sdkappid=" + TUILogin.getSdkAppId() + "&userid="
+ TUILogin.getUserId() + "&usersig=" + TUILogin.getUserSig();
} else if (type == PlayType.RTMP) {
playUrl = HTTP + GenerateTestUserSig.PLAY_DOMAIN + File.separator + APP_NAME + File.separator + streamId
+ ".flv";
} else if (type == PlayType.WEBRTC) {
playUrl = WEBRTC + GenerateTestUserSig.PLAY_DOMAIN + File.separator + APP_NAME + File.separator + streamId;
}
return playUrl;
}
public enum PushType {
RTC,
RTMP
}
public enum PlayType {
RTC,
RTMP,
WEBRTC
}
}