Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass spcBase64 to getLicense #9

Open
wants to merge 1 commit into
base: feature/ios-drm-support
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions DRM.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ Platforms: iOS
With this prop you can override the license acquisition flow, as an example:

```js
getLicense: (spcString) => {
const base64spc = Base64.encode(spcString);
getLicense: ({ spcString, spcBase64 }, props) => {
const formData = new FormData();
formData.append('spc', base64spc);
formData.append('spc', spcBase64);
return fetch(`https://license.pallycon.com/ri/licenseManager.do`, {
method: 'POST',
headers: {
Expand Down Expand Up @@ -108,8 +107,7 @@ drm: {
```js
drm: {
type: DRMType.FAIRPLAY,
getLicense: (spcString) => {
const base64spc = Base64.encode(spcString);
getLicense: ({ spcString, spcBase64 }, props) => {
return fetch('YOUR LICENSE SERVER HERE', {
method: 'POST',
headers: {
Expand All @@ -119,7 +117,7 @@ drm: {
body: JSON.stringify({
getFairplayLicense: {
foo: 'bar',
spcMessage: base64spc,
spcMessage: spcBase64,
}
})
})
Expand Down
4 changes: 2 additions & 2 deletions Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ export default class Video extends Component {
_onGetLicense = (event) => {
if (this.props.drm && this.props.drm.getLicense instanceof Function) {
const data = event.nativeEvent;
if (data && data.spc) {
const getLicenseOverride = this.props.drm.getLicense(data.spc, this.props);
if (data && data.spcBase64) {
const getLicenseOverride = this.props.drm.getLicense(data, this.props);
const getLicensePromise = Promise.resolve(getLicenseOverride); // Handles both scenarios, getLicenseOverride being a promise and not.
getLicensePromise.then((result => {
if (result !== undefined) {
Expand Down
3 changes: 2 additions & 1 deletion ios/Video/RCTVideo.m
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,8 @@ - (BOOL)loadingRequestHandling:(AVAssetResourceLoadingRequest *)loadingRequest {
if(self.onGetLicense) {
NSString *spcStr = [[NSString alloc] initWithData:spcData encoding:NSASCIIStringEncoding];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe related:

but spcStr is not empty in xcode debugger.

self->_requestingCertificate = YES;
self.onGetLicense(@{@"spc": spcStr,
self.onGetLicense(@{@"spcString": spcStr,
@"spcBase64": [spcData base64EncodedStringWithOptions:0],
@"target": self.reactTag});
} else if(licenseServer != nil) {
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
Expand Down