Skip to content

Commit

Permalink
Merge branch 'release/1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos committed Dec 4, 2018
2 parents 0b74b7e + b3a0163 commit 19ff301
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ - (BOOL)shouldProcessResourceLoadingRequest:(AVAssetResourceLoadingRequest *)loa
}
NSError *friendlyError = [NSError errorWithDomain:SRGContentProtectionErrorDomain code:SRGContentProtectionErrorUnauthorized userInfo:[userInfo copy]];
[loadingRequest finishLoadingWithError:friendlyError];
return;
}
else {
[loadingRequest.dataRequest respondWithData:data];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ - (BOOL)shouldProcessResourceLoadingRequest:(AVAssetResourceLoadingRequest *)loa
[diagnosticInformation startTimeMeasurementForKey:@"duration"];

self.request = [[SRGNetworkRequest alloc] initWithURLRequest:[NSURLRequest requestWithURL:self.certificateURL] session:self.session options:0 completionBlock:^(NSData * _Nullable certificateData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
NSHTTPURLResponse *HTTPResponse = [response isKindOfClass:[NSHTTPURLResponse class]] ? (NSHTTPURLResponse *)response : nil;

// Resource loader methods must be called on the main thread
if (error) {
[self finishLoadingRequest:loadingRequest withContentKeyContextData:nil error:error];
[self finishLoadingRequest:loadingRequest withContentKeyContextData:nil HTTPResponse:HTTPResponse error:error];
return;
}

Expand All @@ -109,13 +111,14 @@ - (BOOL)shouldProcessResourceLoadingRequest:(AVAssetResourceLoadingRequest *)loa
options:nil
error:&keyError];
if (keyError) {
[self finishLoadingRequest:loadingRequest withContentKeyContextData:nil error:keyError];
[self finishLoadingRequest:loadingRequest withContentKeyContextData:nil HTTPResponse:HTTPResponse error:keyError];
return;
}

NSURLRequest *contentKeyContextRequest = SRGFairPlayContentKeyContextRequest(URL, keyRequestData);
self.request = [[SRGNetworkRequest alloc] initWithURLRequest:contentKeyContextRequest session:self.session options:0 completionBlock:^(NSData * _Nullable contentKeyContextData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
[self finishLoadingRequest:loadingRequest withContentKeyContextData:contentKeyContextData error:error];
NSHTTPURLResponse *HTTPResponse = [response isKindOfClass:[NSHTTPURLResponse class]] ? (NSHTTPURLResponse *)response : nil;
[self finishLoadingRequest:loadingRequest withContentKeyContextData:contentKeyContextData HTTPResponse:HTTPResponse error:error];
}];
[self.request resume];
}];
Expand All @@ -130,7 +133,7 @@ - (void)didCancelResourceLoadingRequest:(AVAssetResourceLoadingRequest *)loading

#pragma mark Helpers

- (void)finishLoadingRequest:(AVAssetResourceLoadingRequest *)loadingRequest withContentKeyContextData:(NSData *)contentKeyContextData error:(NSError *)error
- (void)finishLoadingRequest:(AVAssetResourceLoadingRequest *)loadingRequest withContentKeyContextData:(NSData *)contentKeyContextData HTTPResponse:(NSHTTPURLResponse *)HTTPResponse error:(NSError *)error
{
if (contentKeyContextData) {
[loadingRequest.dataRequest respondWithData:contentKeyContextData];
Expand All @@ -146,10 +149,11 @@ - (void)finishLoadingRequest:(AVAssetResourceLoadingRequest *)loadingRequest wit
}

SRGDiagnosticInformation *diagnosticInformation = [self diagnosticInformation];
[diagnosticInformation setURL:loadingRequest.request.URL forKey:@"url"];
if (HTTPResponse) {
[diagnosticInformation setURL:HTTPResponse.URL forKey:@"url"];
[diagnosticInformation setInteger:HTTPResponse.statusCode forKey:@"httpStatusCode"];
}

NSHTTPURLResponse *HTTPResponse = [loadingRequest.response isKindOfClass:NSHTTPURLResponse.class] ? (NSHTTPURLResponse *)loadingRequest.response : nil;
[diagnosticInformation setInteger:HTTPResponse.statusCode forKey:@"httpStatusCode"];
[diagnosticInformation setString:error.localizedDescription forKey:@"message"];
[diagnosticInformation stopTimeMeasurementForKey:@"duration"];
}
Expand Down
8 changes: 4 additions & 4 deletions SRGContentProtection.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.1.1;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -791,7 +791,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.1.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -980,7 +980,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.1.1;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1038,7 +1038,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.1.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down

0 comments on commit 19ff301

Please sign in to comment.