-
Notifications
You must be signed in to change notification settings - Fork 31
/
URLUtils.swift
54 lines (48 loc) · 1.9 KB
/
URLUtils.swift
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
//
// URLUtils.swift
// TUIPusherApp
//
// Created by gg on 2021/10/21.
// Copyright © 2022 Tencent. All rights reserved.
import Foundation
import ImSDK_Plus
import TUICore
public class URLUtils: NSObject {
static let WEBRTC : String = "webrtc://"
static let RTMP : String = "rtmp://"
static let HTTP : String = "http://"
static let TRTC : String = "trtc://"
static let TRTC_DOMAIN: String = "cloud.tencent.com"
static let APP_NAME : String = "live"
enum AddressType: Int {
case RTC = 0
case RTMP = 1
case WEBRTC = 2
}
static func generatePushUrl(_ streamId: String, type: AddressType) -> String {
guard V2TIMManager.sharedInstance().getLoginStatus() == .STATUS_LOGINED else { return "" }
guard let userId = TUILogin.getUserID() else { return "" }
guard let userSig = TUILogin.getUserSig() else { return "" }
let sdkAppId = TUILogin.getSdkAppID()
switch type {
case .RTC:
return "\(TRTC)\(TRTC_DOMAIN)/push/\(streamId)?sdkappid=\(sdkAppId)&userid=\(userId)&usersig=\(userSig)"
default :
return ""
}
}
static func generatePlayUrl(_ streamId: String, type: AddressType) -> String {
guard V2TIMManager.sharedInstance().getLoginStatus() == .STATUS_LOGINED else { return "" }
guard let userId = TUILogin.getUserID() else { return "" }
guard let userSig = TUILogin.getUserSig() else { return "" }
let sdkAppId = TUILogin.getSdkAppID()
switch type {
case .RTC:
return "trtc://cloud.tencent.com/play/\(streamId)?sdkappid=\(sdkAppId)&userid=\(userId)&usersig=\(userSig)"
case .RTMP:
return "\(HTTP)\(PLAY_DOMAIN)/\(APP_NAME)/\(streamId).flv"
case .WEBRTC:
return "\(WEBRTC)\(PLAY_DOMAIN)/\(APP_NAME)/\(streamId)"
}
}
}