-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 v2.0.1 for Toshiba dTV #605
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
Hi Jozef, I see a lot of duplication here and I think we can find a better way to solve this. Let me start by clarifying some points. The platform implements EME v0.1b, but without the webkit prefix. Correct? The platform implements Thanks, |
hi Joey,
The way I worked is I copied PatchedMediaKeysWebkit into PatchedMediaKeys so if you compare these files you will see they are almost identical. |
Yes, the fact that they are almost identical makes me think there should be a solution that avoids all this code duplication. And based on the API, it looks like the very old EME v0.1b API, which is what we polyfill on top of in I think you should create separate polyfills for each of these things. For For EME, let's refactor the existing v0.1b polyfill so that it doesn't hard-code the prefix. If if (navigator.requestMediaKeySystemAccess &&
MediaKeySystemAccess.prototype.getConfiguration) {
shaka.log.info('Using native EME as-is.');
} else if (HTMLMediaElement.prototype.webkitGenerateKeyRequest) {
shaka.log.info('Using webkit-prefixed EME v0.1b');
shaka.polyfill.PatchedMediaKeysWebkit.install('webkit');
} else if (HTMLMediaElement.prototype.generateKeyRequest) {
shaka.log.info('Using unprefixed EME v0.1b');
shaka.polyfill.PatchedMediaKeysWebkit.install('');
} else if (window.MSMediaKeys) {
shaka.log.info('Using ms-prefixed EME v20140218');
shaka.polyfill.PatchedMediaKeysMs.install();
} else {
shaka.log.info('EME not available.');
shaka.polyfill.PatchedMediaKeysNop.install();
} Something in this direction would be acceptable, but I don't want to duplicate the entire file. That will lead to bugs in the long run. Since we do not have a Toshiba TV for development, would you be willing to work on this and revise your PR? |
@joey it makes sense to parametrize the existing PatchedMediaKeys. Do you also have any idea how to handle the FakeEvent problem for 'encrypted' event? I can also try to polyfill performance.now, last time there was some issue with that. |
@jozefchutka, I don't really know what the issue is what FakeEvent. Can you provide some details? What's the error? |
using FakeEvent it throws |
Ah, I see. In Let us know how it's going refactoring the polyfill, and if we can do anything else to help. |
@joeyparrish updated. see the latest PR and changes. There are some issues with polyfilling performance, it seems that it only lives for a thread or something, lets say if I do
it works in the next line, but it doesnt work after a second or so... |
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.
This looks really good overall. If polyfilling performance.now doesn't work on your platform, then it's really not a big deal. Falling back to Date.now() is good enough. I recommended a few small changes, but otherwise I like this very much. Thank you for contributing!
// Alias. | ||
var PatchedMediaKeysWebkit = shaka.polyfill.PatchedMediaKeysWebkit; | ||
PatchedMediaKeysWebkit.Prefix = prefix; |
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.
This should be declared somewhere. It should also be private to the class, which means it must end in an underscore. For example:
/** @Private {string} */
shaka.polyfill.PatchedMediaKeysWebkit.prefix_ = '';
* @param {string} api | ||
* @return {string} | ||
*/ | ||
shaka.polyfill.PatchedMediaKeysWebkit.prefixApi = function(api) { |
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.
This should also be private.
@@ -702,8 +727,11 @@ shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.generate_ = | |||
// GKR can throw an exception. If this occurs, wait 10 ms and try again at | |||
// most once. This situation should only occur when init data is available | |||
// ahead of the 'needkey' event. | |||
|
|||
var prefixApi = shaka.polyfill.PatchedMediaKeysWebkit.prefixApi; | |||
var prefixedApi = prefixApi('generateKeyRequest'); |
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.
Having an alias variable called "prefixApi" and another variable called "prefixedApi" is a little confusing and could easily lead to typos. Please rename this to "generateKeyRequestName", which will both avoid confusion, describe which API it references, and indicate that it is a string, not a function.
@@ -775,8 +803,10 @@ shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.update_ = | |||
keyId = null; | |||
} | |||
|
|||
var prefixApi = shaka.polyfill.PatchedMediaKeysWebkit.prefixApi; | |||
var prefixedApi = prefixApi('addKey'); |
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.
Please rename to "addKeyName". See above for rationale.
@@ -852,8 +882,10 @@ shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.close = | |||
// it to clean up resources in v0.1b. We still consider the session closed. | |||
// We can't let the exception propagate because MediaKeySession.close() | |||
// should not throw. | |||
var prefixApi = shaka.polyfill.PatchedMediaKeysWebkit.prefixApi; | |||
var prefixedApi = prefixApi('cancelKeyRequest'); |
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.
Please rename to "cancelKeyRequestName". See above for rationale.
hi Joey, I did these changes you requested, now it will take some time to test as I do not have access to the device right away, I will confirm its working here asap (today). |
Everything looks good now. I'll run it through the standard checks on our build bot and do some additional testing on Safari. |
Testing in progress... |
Oh, one thing is off, actually. This should be merged into |
Failure:
|
Those failures are unrelated to your change and have already been fixed. I'm overriding the build bot on this one. |
Test failures overridden. I've got no strings to hold me down, to make me smile, to make me frown! I've got no strings, as you can see. There are no strings on me! |
All tests are passing on Safari, which is the only browser still using this polyfill. I'm going to go ahead and merge it into |
Toshiba has EME v0.1b, but without the webkit prefix. This generalizes the WebKit MediaKeys polyfill to work with or without a prefix.
Oh, I forgot to wait for you to confirm that it's working well on the Toshiba TV! I got a little ahead of myself. I'm going to go ahead and close this, since I already merged it. Please let us know the results of your testing when you have a chance. If there is any more work needed to get Toshiba TVs working as expected, I would be happy to review another PR. I apologize if this is an inconvenience. |
Hi Joey, thanks for merging, latest master works with dTV. There will be one more PR sooner or later as we dont see adaptation switching for widevine video on dTV.... intestigating |
Toshiba has EME v0.1b, but without the webkit prefix. This generalizes the WebKit MediaKeys polyfill to work with or without a prefix.
Making shaka player working with Toshiba dTV
Mozilla/5.0 (Linux; U; Linux; ja-jp; DTV; TSBNetTV/T3A01C0.0203.0DD) AppleWebKit/536(KHTML, like Gecko) NX/3.0 (DTV; HTML; R1.0;) DTVNetBrowser/2.2 (000039;T3A01C0;0203;0DD) InettvBrowser/2.2 (000039;T3A01C0;0203;0DD) TOSHIBA dTV REGZA BROWSER 43Z700X
Toshiba has unprefixed HTMLMediaElement apis (generateKeyRequest etc.) and events (needkey etc.) while it has prefixed window.performance.webkitNow()