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

fix(ios): split licenseUrl and loadedLicenseUrl #3578

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions docs/pages/component/drm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ Rather than setting the `licenseServer` url to get the license, you can manually
your `contentId` + the provided certificate via `objc [loadingRequest streamingContentKeyRequestDataForApp:certificateData
contentIdentifier:contentIdData options:nil error:&spcError]; `

Also, you will receive the `contentId` and a `licenseUrl` URL defined as `loadingRequest.request.URL.absoluteString ` or as the `licenseServer` prop if it's passed.
Also, you will receive following parameter of getLicense:
* `contentId` contentId if passed to `drm` object or loadingRequest.request.url?.host
* `loadedLicenseUrl` URL defined as `loadingRequest.request.URL.absoluteString`, this url starts with `skd://` or `clearkey://`
* `licenseServer` prop if prop is passed to `drm` object.
* `spcString` the SPC used to validate playback with drm server

You should return on this method a `CKC` in Base64, either by just returning it or returning a `Promise` that resolves with the `CKC`.

With this prop you can override the license acquisition flow, as an example:

```js
getLicense: (spcString, contentId, licenseUrl) => {
getLicense: (spcString, contentId, licenseUrl, loadedLicenseUrl) => {
const base64spc = Base64.encode(spcString);
const formData = new FormData();
formData.append('spc', base64spc);
Expand Down
8 changes: 4 additions & 4 deletions examples/basic/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ SPEC CHECKSUMS:
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
RCT-Folly: 045d6ecaa59d826c5736dfba0b2f4083ff8d79df
RCTDeprecation: 6cc9677aab2e9af79e75f2eeea9be22adbc657d9
RCTDeprecation: a6392cb4842ae80e6f13ea460517170be529c301
RCTRequired: 1c308285f5125d3e65fd864d1ffbd51c84f19be0
RCTTypeSafety: c66cf0ffe89d4c3a6f74c38a8b1396d9a06bd5f2
React: 525ec60174ace50c7cc60fe92982e580b0b26cfb
Expand Down Expand Up @@ -1397,9 +1397,9 @@ SPEC CHECKSUMS:
React-perflogger: bc4cdc9440a5ba3b462813447a5a6633010b1cc8
React-RCTActionSheet: 8b27811da488f196167ca1756453cc1feacbed8f
React-RCTAnimation: aba9dcc5c6c0213cd1e747076300261aa8d23845
React-RCTAppDelegate: bf765fc52328ba350794f1ca16d48e757278d2aa
React-RCTAppDelegate: f8d6afca137f95bac028b631c89c9648ae2e864d
React-RCTBlob: 843bb240adc3bc28cf8893a5fad4b4d41c0b89ad
React-RCTFabric: e79eaae738addada21b4b728fd77f95a3255c2af
React-RCTFabric: 176ba2d8c621a38090b7759eafc046e8f76d081f
React-RCTImage: 67ea59e43e222cde321675e49416e21b5adc52e6
React-RCTLinking: 73f14ccf9ce161d5f7b61c4d18eb01876897fe17
React-RCTNetwork: 157786ee39743278756977b8161631646bcf9770
Expand All @@ -1421,4 +1421,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: bbe1bd5f521b6b9366288dbaf8af1cec85c0a95a

COCOAPODS: 1.13.0
COCOAPODS: 1.12.0
126 changes: 66 additions & 60 deletions examples/basic/ios/videoplayer.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion ios/Video/Features/RCTResourceLoaderDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ class RCTResourceLoaderDelegate: NSObject, AVAssetResourceLoaderDelegate, URLSes
base64Certificate: _drm.base64Certificate
).then { spcData in
self._requestingCertificate = true
self._onGetLicense?(["licenseUrl": self._drm?.licenseServer ?? loadingRequest.request.url?.absoluteString ?? "",
self._onGetLicense?(["licenseUrl": self._drm?.licenseServer ?? "",
"loadedLicenseUrl": loadingRequest.request.url?.absoluteString ?? "",
"contentId": contentId ?? "",
"spcBase64": spcData.base64EncodedString(options: []),
"target": self._reactTag])
Expand Down
1 change: 1 addition & 0 deletions src/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
data.spcBase64,
data.contentId,
data.licenseUrl,
data.loadedLicenseUrl,
);
const getLicensePromise = Promise.resolve(getLicenseOverride); // Handles both scenarios, getLicenseOverride being a promise and not.
getLicensePromise
Expand Down
1 change: 1 addition & 0 deletions src/specs/VideoNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export type OnExternalPlaybackChangeData = Readonly<{

export type OnGetLicenseData = Readonly<{
licenseUrl: string;
loadedLicenseUrl: string;
contentId: string;
spcBase64: string;
}>;
Expand Down
1 change: 1 addition & 0 deletions src/types/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export type Drm = Readonly<{
/* eslint-disable @typescript-eslint/no-unused-vars */
getLicense?: (
licenseUrl: string,
loadedLicenseUrl: string,
contentId: string,
spcBase64: string,
) => void; // ios
Expand Down
Loading