-
Notifications
You must be signed in to change notification settings - Fork 133
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
[WIP] Call generateRequest BEFORE pushing any segment with PlayReady #1486
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/compat/should_call_generate_request_before_buffering_media.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* (2024-07-23) We noticed issues with most devices relying on PlayReady when | ||
* playing some contents with a mix of encrypted and clear segments (not with | ||
* Canal+ own contents weirdly enough, yet with multiple others both encoded | ||
* and packaged differently). | ||
* The issue fixed itself when we called the | ||
* `MediaKeySession.prototype.generateRequest` EME API **BEFORE** any segment | ||
* was buffered. | ||
* | ||
* So this function returns `true` when calling `generateRequest` should | ||
* probably be performed before buffering any segment. | ||
* | ||
* @param {string} keySystem - The key system in use. | ||
* @returns {boolean} | ||
*/ | ||
export default function shouldCallGenerateRequestBeforeBufferingMedia( | ||
keySystem: string, | ||
): boolean { | ||
if (keySystem.indexOf("playready") !== -1) { | ||
return true; | ||
} | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main_thread/decrypt/utils/perform_fake_generate_request.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { closeSession } from "../../../compat/eme"; | ||
import type { ICustomMediaKeys } from "../../../compat/eme"; | ||
import { | ||
DUMMY_PLAY_READY_HEADER, | ||
generatePlayReadyInitData, | ||
} from "../../../compat/generate_init_data"; | ||
import log from "../../../log"; | ||
|
||
/** | ||
* The EME API is badly implemented on many devices, leading us toward the need | ||
* to perform some heavy work-arounds. | ||
* | ||
* A frequent one is to call the `MediaKeySession.prototype.generateRequest` API | ||
* at some point for dummy data an see if it fails (or not, sometimes just | ||
* calling it is important). | ||
* | ||
* This method does just that, resolving the returned Promise if the | ||
* `generateRequest` call could be performed and succeeded or rejecting in other | ||
* cases. | ||
* @param {MediaKeys} mediaKeys | ||
* @returns {Promise} | ||
*/ | ||
export default async function performFakeGenerateRequest( | ||
mediaKeys: MediaKeys | ICustomMediaKeys, | ||
): Promise<void> { | ||
const session = mediaKeys.createSession(); | ||
const initData = generatePlayReadyInitData(DUMMY_PLAY_READY_HEADER); | ||
await session.generateRequest("cenc", initData); | ||
closeSession(session).catch((err) => { | ||
const error = err instanceof Error ? err : new Error("Unknown Error"); | ||
log.warn("DRM: unable to close fake MediaKeySession", error); | ||
}); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note: maybe this does not need to be done if
MediaKeySessions
have already been created (and theirgenerateRequest
method called)?To check, it could save us some time when playing multiple contents