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

DRM: Refacto EME implementation selection mechanism #1261

Merged
merged 1 commit into from
Jul 18, 2023

Conversation

peaBerberian
Copy link
Collaborator

@peaBerberian peaBerberian commented Jul 7, 2023

While debugging a safari issue that in the end seemed link to both DRM and audio track selection of a directfile content, we experimented with the possibility for an application to choose between EME implementation.

For example, an application could decide on Safari to either rely on the latest EME recommendation or on the still-available webkit-vendored API, which are both incompatible to one another.

This was a feature we didn't really want, but what we thought we might have to implement because Safari had issues with both API that could lead to the impossibility to play the content. The RxPlayer couldn't determine which content would work best with which API, but the application could (as it depended on the packager used).

Thankfully, we ended up finding a better solution, relying only on timing audio track switches requests on the application-side instead.

Still, we had the feature ready and though this new API appears unnecessarily complex now that we don't need it anymore, some work on it still appear beneficial to the RxPlayer.
Consequently, this commit removes any notion of the new API but keeps:

  • EME polyfills (webkit-vendored and so on) are now only brought into your application when you rely on the "minimal build" if you actually import the EME feature (it makes sense, shouldn't break anything, and just remove some code from your bundle(s) if you don't need decryption)

  • The choice of the EME implementation to rely on is now isolated in its own getEmeApiImplementation function based on an implementation's "name", instead of just chosen once at evaluation time, which should make future debugging easier.

  • MediaKeys-related clean-up is now always performed with the EME API that was used for the corresponding content.

  • The webkit implementation now only rely on the webkitneedkey event for initialization data and not on the encrypted event anymore, as its format is different.

  • Switching EME implementation between contents is now a theoretical possibility (though no API exploit this), and we clean-up the previous implementation's side effect when we do so.

  • We remove the potentiality of a race condition between setMediaKeys EME API call by awaiting the returned promise when we're removing the previous MediaKeys instance.

  • Some minor ContentDecryptor improvements, brought initially when we wanted to attach MediaKeys to the HTMLMediaElement only AFTER the encrypted events - which is not needed now - but the modifications appeared to lead to a simpler architecture that what we had before.

  • Any key system whose name begins by com.apple.fps is now considered fairplay, instead of an incomplete enumerated list

While debugging a safari issue that in the end seemed link to both DRM
and audio track selection of a directfile contents, we experimented with
the possibility for an application to choose between EME implementation.

For example, an application could decide on Safari to either rely on the
latest EME recommendation or on the still-available webkit-vendored API,
which are both incompatible to one another.

This was a feature we didn't really want, but what we thought we might
have to implement because Safari had issues with both API that could
lead to the impossibility to play the content, but the RxPlayer couldn't
determine which content would work best with which API, but the
application could (as it depended on the packager used).

Thankfully, we ended up finding a better solution, relying only on timing
audio track switches requests on the application-side instead.

Still, we had the feature ready and though this new API appears
unnecessarily complex now that we don't need it anymore, some work on it
still appear beneficial to the RxPlayer.
Consequently, this commit removes any notion of the new API but keeps:

  - EME polyfills (webkit-vendored and so on) are now only brought into
    your application when you rely on the "minimal build" if you
    actually import the `EME` feature (it makes sense, shouldn't break
    anything, and just remove some code from your bundle(s) if you don't
    need decryption)

  - The choice of the EME implementation to rely on is now isolated in
    its own `getEmeApiImplementation` function based on an
    implementation's "name", instead of just chosen once at evaluation
    time, which should make future debugging easier.

  - MediaKeys-related clean-up is now always performed with the EME API
    that was used for the corresponding content.

  - The webkit implementation now only rely on the `webkitneedkey` event
    for initialization data and not on the `encrypted` event anymore, as
    its format is different.

  - Switching EME implementation between contents is now a possibility,
    and we clean-up the previous implementation's side effect when we do
    so.

  - We remove the potentiality of a race condition between
    `setMediaKeys` EME API call by awaiting the returned promise when
    we're removing the previous MediaKeys instance.

  - Some minor `ContentDecryptor` improvements, brought initially when
    we wanted to attach MediaKeys to the HTMLMediaElement only _AFTER_
    the encrypted events - which is not needed now - but the
    modifications appeared to lead to a simpler architecture that what
    we had before.
@peaBerberian peaBerberian added the DRM Relative to DRM (EncryptedMediaExtensions) label Jul 7, 2023
@peaBerberian peaBerberian added the Performance checks Performance tests are run on this issue / PR label Jul 18, 2023
@peaBerberian peaBerberian added this to the 3.31.1 milestone Jul 18, 2023
@peaBerberian peaBerberian merged commit 80540b6 into master Jul 18, 2023
5 checks passed
@peaBerberian peaBerberian deleted the misc/eme-cleanup branch August 13, 2023 09:32
@peaBerberian peaBerberian modified the milestones: 3.31.1, 3.32.0 Sep 12, 2023
@peaBerberian peaBerberian mentioned this pull request Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DRM Relative to DRM (EncryptedMediaExtensions) Performance checks Performance tests are run on this issue / PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant