-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
feat(iOS): rewrite DRM Module #4136
base: master
Are you sure you want to change the base?
feat(iOS): rewrite DRM Module #4136
Conversation
@freeboub should I add someone else to reviewers ? |
Maybe @paul-rinaldi or @paulrinaldi would like to test this version ? I can review but not test on my side ... |
ios/Video/Features/DRMManager+AVContentKeySessionDelegate.swift
Outdated
Show resolved
Hide resolved
I added some small comments, but it looks like good job 👍 |
I don't have a tv with iOS on it or vision OS. I have physical iPhones and physical iPads I could test with if you would like me to but it sounds like the PR creator already did that. Sorry I could not be more helpful. |
My proposal was linked to your message on discord in fact ! |
I have tested it and it works fine also it solved buffering issues in drm videos. |
3bd5834
to
6be407d
Compare
4cb8b05
to
516335d
Compare
Looks good to me. Please build a release after merging this PR :) |
Sure I will give this PR to tests for our client and after it will do it! Thanks! |
516335d
to
59ba0fd
Compare
Waiting for the merge |
59ba0fd
to
2dedcd2
Compare
346f441
to
e41a178
Compare
ios/Video/RCTVideo.swift
Outdated
if source.drm != nil || _localSourceEncryptionKeyScheme != nil { | ||
_resouceLoaderDelegate = RCTResourceLoaderDelegate( | ||
if source.drm?.type != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@freeboub source.drm
is never nil
is structure with nils
even if we don't pass anything are you okay with checking drm.type
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure to understand, you want to change
let drm: DRMParams?
by
let drm: DRMParams
And check only type ?
if that's the case, I agree !
Something like this patch:
diff --git a/ios/Video/DataStructures/VideoSource.swift b/ios/Video/DataStructures/VideoSource.swift
index e672929f..45e5b2d3 100644
--- a/ios/Video/DataStructures/VideoSource.swift
+++ b/ios/Video/DataStructures/VideoSource.swift
@@ -10,7 +10,7 @@ struct VideoSource {
let cropEnd: Int64?
let customMetadata: CustomMetadata?
/* DRM */
- let drm: DRMParams?
+ let drm: DRMParams
var textTracks: [TextTrack] = []
let json: NSDictionary?
@@ -28,7 +28,7 @@ struct VideoSource {
self.cropStart = nil
self.cropEnd = nil
self.customMetadata = nil
- self.drm = nil
+ self.drm = DRMParams(nil)
return
}
self.json = json
diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift
index 908e3eb8..64130675 100644
--- a/ios/Video/RCTVideo.swift
+++ b/ios/Video/RCTVideo.swift
@@ -421,7 +421,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
"type": _source?.type ?? NSNull(),
"isNetwork": NSNumber(value: _source?.isNetwork ?? false),
],
- "drm": source.drm?.json ?? NSNull(),
+ "drm": source.drm.json ?? NSNull(),
"target": reactTag as Any,
])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant:
in current impl source.drm is never null it will be always struct with some values (if drm is not setted but user all values will be just null). But now as I think I can aloso check if source.drm.json != nil
bcs if json is null it means that users notting passed to it
ead3023
to
85a027c
Compare
case .unsupportedDRMType: | ||
return NSLocalizedString("Verifiy that you are using fairplay (on Apple devices)", comment: "") | ||
case .simulatorDRMNotSuported: | ||
return NSLocalizedString("You need to test DRM conent on real device", comment: "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KrzysztofMoch there is a typo in "content"
Is this ready to be merged? |
@@ -1329,11 +1326,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH | |||
} | |||
|
|||
func setLicenseResult(_ license: String!, _ licenseUrl: String!) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KrzysztofMoch I am reviewing use of String! and it is a bad practice and can lead to some issues, see: #4181
It is just hide the warning, so no need to test the value ...
I think it would be better to change like I propose (not sure of the consequences inside _drmManager)
func setLicenseResult(_ license: String!, _ licenseUrl: String!) { | |
func setLicenseResult(_ license: String?, _ licenseUrl: String?) { |
@@ -1329,11 +1326,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH | |||
} | |||
|
|||
func setLicenseResult(_ license: String!, _ licenseUrl: String!) { | |||
_resouceLoaderDelegate?.setLicenseResult(license, licenseUrl) | |||
_drmManager?.setJSLicenseResult(license: license, licenseUrl: licenseUrl) | |||
} | |||
|
|||
func setLicenseResultError(_ error: String!, _ licenseUrl: String!) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here:
func setLicenseResultError(_ error: String!, _ licenseUrl: String!) { | |
func setLicenseResultError(_ error: String?, _ licenseUrl: String?) { |
case .offlineDRMNotSuported: | ||
return NSLocalizedString("You tried to use Offline DRM but it is not supported yet", comment: "") | ||
case .unsupportedDRMType: | ||
return NSLocalizedString("You tried to use unsupporeted DRM type", comment: "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KrzysztofMoch there is a typo in "unsupported"
Summary
I have re-implemented DRM module for Apple devices. New Implementation use
AVContentKeySession
instead of resource loader.fixes #4177 #3675 #3467
Motivation
Motivation is to fix issue with DRM Airplay and add visionOS support (in old implementation it was not possible)
Test plan
Tested on