2023-12-07 00:47:40 -07:00
|
|
|
// MARK: - RCTVideoError
|
|
|
|
|
|
|
|
enum RCTVideoError: Int {
|
2022-05-19 07:29:25 -06:00
|
|
|
case fromJSPart
|
|
|
|
case noLicenseServerURL
|
|
|
|
case licenseRequestNotOk
|
|
|
|
case noDataFromLicenseRequest
|
|
|
|
case noSPC
|
|
|
|
case noDataRequest
|
|
|
|
case noCertificateData
|
|
|
|
case noCertificateURL
|
|
|
|
case noFairplayDRM
|
|
|
|
case noDRMData
|
|
|
|
case invalidContentId
|
|
|
|
}
|
|
|
|
|
2023-12-07 00:47:40 -07:00
|
|
|
// MARK: - RCTVideoErrorHandler
|
|
|
|
|
2022-05-19 07:29:25 -06:00
|
|
|
enum RCTVideoErrorHandler {
|
|
|
|
static let noDRMData = NSError(
|
|
|
|
domain: "RCTVideo",
|
|
|
|
code: RCTVideoError.noDRMData.rawValue,
|
|
|
|
userInfo: [
|
|
|
|
NSLocalizedDescriptionKey: "Error obtaining DRM license.",
|
|
|
|
NSLocalizedFailureReasonErrorKey: "No drm object found.",
|
2023-12-07 00:47:40 -07:00
|
|
|
NSLocalizedRecoverySuggestionErrorKey: "Have you specified the 'drm' prop?",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2022-05-19 07:29:25 -06:00
|
|
|
static let noCertificateURL = NSError(
|
|
|
|
domain: "RCTVideo",
|
|
|
|
code: RCTVideoError.noCertificateURL.rawValue,
|
|
|
|
userInfo: [
|
|
|
|
NSLocalizedDescriptionKey: "Error obtaining DRM License.",
|
|
|
|
NSLocalizedFailureReasonErrorKey: "No certificate URL has been found.",
|
2023-12-07 00:47:40 -07:00
|
|
|
NSLocalizedRecoverySuggestionErrorKey: "Did you specified the prop certificateUrl?",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2022-05-19 07:29:25 -06:00
|
|
|
static let noCertificateData = NSError(
|
|
|
|
domain: "RCTVideo",
|
|
|
|
code: RCTVideoError.noCertificateData.rawValue,
|
|
|
|
userInfo: [
|
|
|
|
NSLocalizedDescriptionKey: "Error obtaining DRM license.",
|
|
|
|
NSLocalizedFailureReasonErrorKey: "No certificate data obtained from the specificied url.",
|
2023-12-07 00:47:40 -07:00
|
|
|
NSLocalizedRecoverySuggestionErrorKey: "Have you specified a valid 'certificateUrl'?",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2022-05-19 07:29:25 -06:00
|
|
|
static let noSPC = NSError(
|
|
|
|
domain: "RCTVideo",
|
|
|
|
code: RCTVideoError.noSPC.rawValue,
|
|
|
|
userInfo: [
|
|
|
|
NSLocalizedDescriptionKey: "Error obtaining license.",
|
|
|
|
NSLocalizedFailureReasonErrorKey: "No spc received.",
|
2023-12-07 00:47:40 -07:00
|
|
|
NSLocalizedRecoverySuggestionErrorKey: "Check your DRM config.",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2022-05-19 07:29:25 -06:00
|
|
|
static let noLicenseServerURL = NSError(
|
|
|
|
domain: "RCTVideo",
|
|
|
|
code: RCTVideoError.noLicenseServerURL.rawValue,
|
|
|
|
userInfo: [
|
|
|
|
NSLocalizedDescriptionKey: "Error obtaining DRM License.",
|
|
|
|
NSLocalizedFailureReasonErrorKey: "No license server URL has been found.",
|
2023-12-07 00:47:40 -07:00
|
|
|
NSLocalizedRecoverySuggestionErrorKey: "Did you specified the prop licenseServer?",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2022-05-19 07:29:25 -06:00
|
|
|
static let noDataFromLicenseRequest = NSError(
|
|
|
|
domain: "RCTVideo",
|
|
|
|
code: RCTVideoError.noDataFromLicenseRequest.rawValue,
|
|
|
|
userInfo: [
|
|
|
|
NSLocalizedDescriptionKey: "Error obtaining DRM license.",
|
|
|
|
NSLocalizedFailureReasonErrorKey: "No data received from the license server.",
|
2023-12-07 00:47:40 -07:00
|
|
|
NSLocalizedRecoverySuggestionErrorKey: "Is the licenseServer ok?",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2022-05-19 07:29:25 -06:00
|
|
|
static func licenseRequestNotOk(_ statusCode: Int) -> NSError {
|
|
|
|
return NSError(
|
|
|
|
domain: "RCTVideo",
|
|
|
|
code: RCTVideoError.licenseRequestNotOk.rawValue,
|
|
|
|
userInfo: [
|
|
|
|
NSLocalizedDescriptionKey: "Error obtaining license.",
|
|
|
|
NSLocalizedFailureReasonErrorKey: String(
|
2023-12-07 00:47:40 -07:00
|
|
|
format: "License server responded with status code %li",
|
|
|
|
statusCode
|
2022-05-19 07:29:25 -06:00
|
|
|
),
|
2023-12-07 00:47:40 -07:00
|
|
|
NSLocalizedRecoverySuggestionErrorKey: "Did you send the correct data to the license Server? Is the server ok?",
|
|
|
|
]
|
|
|
|
)
|
2022-05-19 07:29:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static func fromJSPart(_ error: String) -> NSError {
|
|
|
|
return NSError(domain: "RCTVideo",
|
2023-12-07 00:47:40 -07:00
|
|
|
code: RCTVideoError.fromJSPart.rawValue,
|
|
|
|
userInfo: [
|
|
|
|
NSLocalizedDescriptionKey: error,
|
|
|
|
NSLocalizedFailureReasonErrorKey: error,
|
|
|
|
NSLocalizedRecoverySuggestionErrorKey: error,
|
|
|
|
])
|
2022-05-19 07:29:25 -06:00
|
|
|
}
|
2023-12-07 00:47:40 -07:00
|
|
|
|
2022-05-19 07:29:25 -06:00
|
|
|
static let invalidContentId = NSError(
|
|
|
|
domain: "RCTVideo",
|
|
|
|
code: RCTVideoError.invalidContentId.rawValue,
|
|
|
|
userInfo: [
|
|
|
|
NSLocalizedDescriptionKey: "Error obtaining DRM license.",
|
|
|
|
NSLocalizedFailureReasonErrorKey: "No valide content Id received",
|
2023-12-07 00:47:40 -07:00
|
|
|
NSLocalizedRecoverySuggestionErrorKey: "Is the contentId and url ok?",
|
|
|
|
]
|
|
|
|
)
|
2022-05-19 07:29:25 -06:00
|
|
|
}
|