<commit_before>//
//  WidevineClassicHandler.swift
//  Pods
//
//  Created by <NAME> on 19/02/2017.
//
//

import Foundation

typealias LocalAssetRegistrationBlock = (Error?) -> Void
typealias LocalAssetStatusBlock = (Error?, TimeInterval, TimeInterval) -> Void

#if WIDEVINE_ENABLED
    import PlayKitWV
    
    /************************************************************/
    // MARK: - WidevineClassicError
    /************************************************************/
    
    enum WidevineClassicError: PKError { 
        
        case invalidDRMData
        case missingWidevineFile
        
        static let Domain = "com.kaltura.playkit.error.drm.widevine"
        
        var code: Int {
            switch self {
            case .invalidDRMData: return PKErrorCode.invalidDRMData
            case .missingWidevineFile: return PKErrorCode.missingWidevineFile
            }
        }
        
        var errorDescription: String {
            switch self {
            case.invalidDRMData: return "Couldn't extract license uri, invalid DRM data"
            case .missingWidevineFile: return "Couldn't register asset, Widevine file not found"
            }
        }
        
        var userInfo: [String : Any] {
            switch self {
            case .invalidDRMData: return [:]
            case .missingWidevineFile: return [:]
            }
        }
    }
    
    extension PKErrorDomain {
        @objc public static let Widevine = WidevineClassicError.Domain
    }
    
    extension PKErrorCode {
        @objc(InvalidDRMData) public static let invalidDRMData = 6200
        @objc(MissingWidevineFile) public static let missingWidevineFile = 6201
    }
    
    /************************************************************/
    // MARK: - Widevine Classic
    /************************************************************/
    
    class WidevineClassicHelper {
        static func registerLocalAsset(_ assetUri: String!, mediaSource: MediaSource!, refresh: Bool, callback: @escaping LocalAssetRegistrationBlock) {
            PKLog.info("registerLocalAsset")
            
            WidevineClassicCDM.setEventBlock({ (event: KCDMEventType, data: [AnyHashable : Any]?) in
                switch event {
                case KCDMEvent_LicenseAcquired:
                    callback(nil)
                    break
                case KCDMEvent_FileNotFound:
                    callback(WidevineClassicError.missingWidevineFile.asNSError)
                    PKLog.error("Widevine file not found")
                    break
                default:
                    PKLog.debug("event::", event)
                }
            }, forAsset: assetUri)
            
            let (lu, e) = WidevineClassicHelper.extractLicenseUri(mediaSource: mediaSource)
            guard let licenseUri = lu else {<commit_msg>replace Domain with domain (#114)<commit_after>//
//  WidevineClassicHandler.swift
//  Pods
//
//  Created by <NAME> on 19/02/2017.
//
//

import Foundation

typealias LocalAssetRegistrationBlock = (Error?) -> Void
typealias LocalAssetStatusBlock = (Error?, TimeInterval, TimeInterval) -> Void

#if WIDEVINE_ENABLED
    import PlayKitWV
    
    /************************************************************/
    // MARK: - WidevineClassicError
    /************************************************************/
    
    enum WidevineClassicError: PKError {
        
        case invalidDRMData
        case missingWidevineFile
        
        static let domain = "com.kaltura.playkit.error.drm.widevine"
        
        var code: Int {
            switch self {
            case .invalidDRMData: return PKErrorCode.invalidDRMData
            case .missingWidevineFile: return PKErrorCode.missingWidevineFile
            }
        }
        
        var errorDescription: String {
            switch self {
            case.invalidDRMData: return "Couldn't extract license uri, invalid DRM data"
            case .missingWidevineFile: return "Couldn't register asset, Widevine file not found"
            }
        }
        
        var userInfo: [String : Any] {
            switch self {
            case .invalidDRMData: return [:]
            case .missingWidevineFile: return [:]
            }
        }
    }
    
    extension PKErrorDomain {
        @objc public static let Widevine = WidevineClassicError.domain
    }
    
    extension PKErrorCode {
        @objc(InvalidDRMData) public static let invalidDRMData = 6200
        @objc(MissingWidevineFile) public static let missingWidevineFile = 6201
    }
    
    /************************************************************/
    // MARK: - Widevine Classic
    /************************************************************/
    
    class WidevineClassicHelper {
        static func registerLocalAsset(_ assetUri: String!, mediaSource: MediaSource!, refresh: Bool, callback: @escaping LocalAssetRegistrationBlock) {
            PKLog.info("registerLocalAsset")
            
            WidevineClassicCDM.setEventBlock({ (event: KCDMEventType, data: [AnyHashable : Any]?) in
                switch event {
                case KCDMEvent_LicenseAcquired:
                    callback(nil)
                    break
                case KCDMEvent_FileNotFound:
                    callback(WidevineClassicError.missingWidevineFile.asNSError)
                    PKLog.error("Widevine file not found")
                    break
                default:
                    PKLog.debug("event::", event)
                }
            }, forAsset: assetUri)
            
            let (lu, e) = WidevineClassicHelper.extractLicenseUri(mediaSource: mediaSource)
            guard let licenseUri = lu else {
{'fraction_non_alphanumeric': 0.15270246632849396, 'fraction_numerical': 0.006122092006297009, 'mean_word_length': 2.035031847133758, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2345555', 'n_tokens_mistral': 1563, 'n_tokens_neox': 1417, 'n_words': 328}