-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathEndpointAdapter.kt
More file actions
89 lines (81 loc) · 3.82 KB
/
Copy pathEndpointAdapter.kt
File metadata and controls
89 lines (81 loc) · 3.82 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.theoplayer.theolive
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.theoplayer.android.api.theolive.ContentProtectionConfiguration
import com.theoplayer.android.api.theolive.Endpoint
import com.theoplayer.android.api.theolive.EndpointMillicastSource
import com.theoplayer.android.api.theolive.FairPlayConfiguration
import com.theoplayer.android.api.theolive.KeySystemConfiguration
private const val PROP_MILLICAST_SRC = "millicastSrc"
private const val PROP_MILLICAST_NAME = "name"
private const val PROP_MILLICAST_ACCOUNTID = "accountId"
private const val PROP_MILLICAST_SUBSCRIBER_TOKEN ="subscriberToken"
private const val PROP_MILLICAST_DIRECTOR_URL = "directorUrl"
private const val PROP_HESP_SRC = "hespSrc"
private const val PROP_HLS_SRC = "hlsSrc"
private const val PROP_HLS_MPEG_TS_SRC = "hlsMpegTsSrc"
private const val PROP_AD_SRC = "adSrc"
private const val PROP_DAI_ASSET_KEY = "daiAssetKey"
private const val PROP_CDN = "cdn"
private const val PROP_TARGET_LATENCY = "targetLatency"
private const val PROP_WEIGHT = "weight"
private const val PROP_PRIORITY = "priority"
private const val PROP_CONTENT_PROTECTION = "contentProtection"
private const val PROP_INTEGRATION = "integration"
private const val PROP_WIDEVINE = "widevine"
private const val PROP_PLAYREADY = "playready"
private const val PROP_FAIRPLAY = "fairplay"
private const val PROP_LICENSE_URL = "licenseUrl"
private const val PROP_CERTIFICATE_URL = "certificateUrl"
object EndpointAdapter {
fun fromEndPointMillicastSource(millicastSource: EndpointMillicastSource): WritableMap {
return Arguments.createMap().apply {
putString(PROP_MILLICAST_NAME , millicastSource.name)
putString(PROP_MILLICAST_ACCOUNTID, millicastSource.accountId)
millicastSource.directorUrl?.let { putString(PROP_MILLICAST_DIRECTOR_URL, it) }
millicastSource.subscriberToken?.let { putString(PROP_MILLICAST_SUBSCRIBER_TOKEN, it) }
}
}
fun fromEndpoint(endPoint: Endpoint): WritableMap {
return Arguments.createMap().apply {
endPoint.millicastSrc?.let { putMap(PROP_MILLICAST_SRC, fromEndPointMillicastSource(it)) }
endPoint.hespSrc?.let { putString(PROP_HESP_SRC, it) }
endPoint.hlsSrc?.let { putString(PROP_HLS_SRC, it) }
endPoint.hlsMpegTsSrc?.let { putString(PROP_HLS_MPEG_TS_SRC, it) }
endPoint.adSrc?.let { putString(PROP_AD_SRC, it) }
endPoint.daiAssetKey?.let { putString(PROP_DAI_ASSET_KEY, it) }
endPoint.cdn?.let { putString(PROP_CDN, it) }
endPoint.targetLatency?.let { putDouble(PROP_TARGET_LATENCY, it) }
putInt(PROP_WEIGHT, endPoint.weight)
putInt(PROP_PRIORITY, endPoint.priority)
endPoint.contentProtection?.let {
putMap(PROP_CONTENT_PROTECTION, fromContentProtection(it))
}
}
}
fun fromContentProtection(contentProtection: ContentProtectionConfiguration): WritableMap {
return Arguments.createMap().apply {
putString(PROP_INTEGRATION, contentProtection.integration)
contentProtection.widevine?.let { config ->
putMap(PROP_WIDEVINE, fromKeySystemConfiguration(config))
}
contentProtection.playready?.let { config ->
putMap(PROP_PLAYREADY, fromKeySystemConfiguration(config))
}
contentProtection.fairplay?.let { config ->
putMap(PROP_FAIRPLAY, fromFairPlayConfiguration(config))
}
}
}
fun fromKeySystemConfiguration(config: KeySystemConfiguration): WritableMap {
return Arguments.createMap().apply {
config.licenseUrl?.let { url -> putString(PROP_LICENSE_URL, url) }
}
}
fun fromFairPlayConfiguration(config: FairPlayConfiguration): WritableMap {
return Arguments.createMap().apply {
config.licenseUrl?.let { url -> putString(PROP_LICENSE_URL, url) }
config.certificateUrl?.let { url -> putString(PROP_CERTIFICATE_URL, url) }
}
}
}