Я пытаюсь интегрировать Fairplay в приложение Apple TV. Пока что я запрашивал сертификат, но когда я пытаюсь получить SP C, он терпит неудачу, он возвращает ошибку: «Операция не может быть завершена». Что я могу сделать, чтобы отладить это, или у вас есть URL-адреса потоковой передачи Fairplay для тестирования?
- (void)requestApplicationCertificateWithCompletion:(AppCertificateRequestCompletion)completion {
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
NSURL *url = [NSURL URLWithString:self.certificateUrl];
NSURLSessionDataTask *requestTask = [session dataTaskWithURL:url completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
completion(data);
}];
[requestTask resume];
}
- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForRenewalOfRequestedResource:(AVAssetResourceRenewalRequest *)renewalRequest {
return [self resourceLoader:resourceLoader shouldWaitForLoadingOfRequestedResource:renewalRequest];
}
- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForLoadingOfRequestedResource:(AVAssetResourceLoadingRequest *)loadingRequest {
NSURL *url = loadingRequest.request.URL;
AVAssetResourceLoadingDataRequest *dataRequest = loadingRequest.dataRequest;
[self requestApplicationCertificateWithCompletion:^(NSData *certificate) {
NSString *assetStr = [url.absoluteString stringByReplacingOccurrencesOfString:@"skd://" withString:@""];
NSData *assetId = [NSData dataWithBytes: [assetStr cStringUsingEncoding:NSUTF8StringEncoding] length:[assetStr lengthOfBytesUsingEncoding:NSUTF8StringEncoding]];
// To obtain the license request (Server Playback Context or SPC in Apple's terms), we call
// AVAssetResourceLoadingRequest.streamingContentKeyRequestData(forApp:contentIdentifier:options:)
// using the information we obtained earlier.
NSError *error = nil;
NSData *requestBytes = [loadingRequest streamingContentKeyRequestDataForApp:certificate
contentIdentifier:assetId
options:nil
error:&error];
NSLog(@"%@", error);
NSLog(@"%@", requestBytes);
}];
}
'requestBytes' имеет значение null.
Спасибо, Клаудиу