2022-05-19 07:29:25 -06:00
|
|
|
struct VideoSource {
|
|
|
|
let type: String?
|
|
|
|
let uri: String?
|
|
|
|
let isNetwork: Bool
|
|
|
|
let isAsset: Bool
|
|
|
|
let shouldCache: Bool
|
2023-12-07 00:47:40 -07:00
|
|
|
let requestHeaders: [String: Any]?
|
2024-03-22 06:43:46 -06:00
|
|
|
let startPosition: Float64?
|
2023-11-24 04:52:46 -07:00
|
|
|
let cropStart: Int64?
|
|
|
|
let cropEnd: Int64?
|
2024-05-07 04:30:57 -06:00
|
|
|
let customMetadata: CustomMetadata?
|
2024-07-10 04:17:22 -06:00
|
|
|
/* DRM */
|
2024-09-20 09:46:10 -06:00
|
|
|
let drm: DRMParams
|
2024-09-13 02:50:33 -06:00
|
|
|
var textTracks: [TextTrack] = []
|
2023-12-07 00:47:40 -07:00
|
|
|
|
2022-05-19 07:29:25 -06:00
|
|
|
let json: NSDictionary?
|
2023-12-07 00:47:40 -07:00
|
|
|
|
2022-05-19 07:29:25 -06:00
|
|
|
init(_ json: NSDictionary!) {
|
|
|
|
guard json != nil else {
|
|
|
|
self.json = nil
|
|
|
|
self.type = nil
|
|
|
|
self.uri = nil
|
|
|
|
self.isNetwork = false
|
|
|
|
self.isAsset = false
|
|
|
|
self.shouldCache = false
|
|
|
|
self.requestHeaders = nil
|
2023-11-24 04:52:46 -07:00
|
|
|
self.startPosition = nil
|
|
|
|
self.cropStart = nil
|
|
|
|
self.cropEnd = nil
|
2024-05-07 04:30:57 -06:00
|
|
|
self.customMetadata = nil
|
2024-09-20 09:46:10 -06:00
|
|
|
self.drm = DRMParams(nil)
|
2022-05-19 07:29:25 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
self.json = json
|
|
|
|
self.type = json["type"] as? String
|
|
|
|
self.uri = json["uri"] as? String
|
|
|
|
self.isNetwork = json["isNetwork"] as? Bool ?? false
|
|
|
|
self.isAsset = json["isAsset"] as? Bool ?? false
|
|
|
|
self.shouldCache = json["shouldCache"] as? Bool ?? false
|
2024-03-07 03:35:17 -07:00
|
|
|
if let requestHeaders = json["requestHeaders"] as? [[String: Any]] {
|
|
|
|
var _requestHeaders: [String: Any] = [:]
|
|
|
|
for requestHeader in requestHeaders {
|
|
|
|
if let key = requestHeader["key"] as? String, let value = requestHeader["value"] {
|
|
|
|
_requestHeaders[key] = value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self.requestHeaders = _requestHeaders
|
|
|
|
} else {
|
|
|
|
self.requestHeaders = nil
|
|
|
|
}
|
2024-03-22 06:43:46 -06:00
|
|
|
self.startPosition = json["startPosition"] as? Float64
|
|
|
|
self.cropStart = (json["cropStart"] as? Float64).flatMap { Int64(round($0)) }
|
|
|
|
self.cropEnd = (json["cropEnd"] as? Float64).flatMap { Int64(round($0)) }
|
2024-05-07 04:30:57 -06:00
|
|
|
self.customMetadata = CustomMetadata(json["metadata"] as? NSDictionary)
|
2024-07-10 04:17:22 -06:00
|
|
|
self.drm = DRMParams(json["drm"] as? NSDictionary)
|
2024-09-13 02:50:33 -06:00
|
|
|
self.textTracks = (json["textTracks"] as? NSArray)?.map { trackDict in
|
|
|
|
return TextTrack(trackDict as? NSDictionary)
|
|
|
|
} ?? []
|
2022-05-19 07:29:25 -06:00
|
|
|
}
|
|
|
|
}
|