unified-video-framework
Version:
Cross-platform video player framework supporting iOS, Android, Web, Smart TVs (Samsung/LG), Roku, and more
46 lines • 1.75 kB
JavaScript
import { BaseDRM } from './BaseDRM.js';
import { KEY_SYSTEMS, DRMErrorCode } from '../types/DRMTypes.js';
import { DRMErrorHandler } from '../utils/DRMErrorHandler.js';
import { CertificateManager } from '../utils/CertificateManager.js';
export class FairPlayDRM extends BaseDRM {
constructor() {
super(...arguments);
this.certManager = new CertificateManager();
}
getKeySystem() { return KEY_SYSTEMS.FAIRPLAY; }
async initialize() {
try {
if (!this.config.certificateUrl) {
return {
success: false,
error: DRMErrorHandler.createError(DRMErrorCode.CERTIFICATE_FETCH_FAILED, 'FairPlay requires certificateUrl'),
};
}
const cert = await this.certManager.fetchCertificate(this.config.certificateUrl, this.config.headers);
this.log('FairPlay certificate fetched, size:', cert.byteLength);
return { success: true, drmType: 'fairplay', keySystem: KEY_SYSTEMS.FAIRPLAY };
}
catch (error) {
return {
success: false,
error: DRMErrorHandler.createError(DRMErrorCode.INITIALIZATION_FAILED, `FairPlay init failed: ${error.message}`, error),
};
}
}
getHLSConfig() {
return {
emeEnabled: true,
drmSystems: {
'com.apple.fps.1_0': {
licenseUrl: this.config.licenseUrl,
serverCertificateUrl: this.config.certificateUrl,
},
},
};
}
async destroy() {
this.certManager.clear();
this.log('FairPlay DRM destroyed');
}
}
//# sourceMappingURL=FairPlayDRM.js.map