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

in-band key rotation not working with Xbox One #4401

Closed
caridley opened this issue Aug 11, 2022 · 10 comments · Fixed by #4478 or #4424
Closed

in-band key rotation not working with Xbox One #4401

caridley opened this issue Aug 11, 2022 · 10 comments · Fixed by #4478 or #4424
Assignees
Labels
component: EME The issue involves the Encrypted Media Extensions web API component: PlayReady The issue involves the PlayReady DRM platform: Xbox Issues affecting Xbox priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@caridley
Copy link
Contributor

Have you read the FAQ and checked for duplicate open issues?
Yes

What version of Shaka Player are you using?
3.1.2 with customizations

Can you reproduce the issue with our latest release version?
Yes with 4.1.2

Can you reproduce the issue with the latest code from main?
Yes tested with main branch commit 25fd4f4 from 8/9/2022

Are you using the demo app or your own custom app?
Custom app

If custom app, can you reproduce the issue using our demo app?
I have not been able to get the demo app to run on the Xbox

What browser and OS are you using?
Xbox One

For embedded devices (smart TVs, etc.), what model and firmware version are you using?
Xbox One S - OS version 10.0.22000.4976

What are the manifest and license server URIs?
Will send via e-mail

What configuration are you using? What is the output of player.getConfiguration()?
see attached file configuration.txt

What did you do?
Playing stream with in-band key rotation signaled with a new KID in the moof/traf/sgpd box
Keys change every 10 minutes

What did you expect to happen?
Playback should continue through key changes uninterrupted, and we should see DRM license requests.

What actually happened?
When the key changes playback fails with an error like this

Shaka Error MEDIA.VIDEO_ERROR (5,8004b82b,)","code":3016,"category":3,"data":[5,"8004b82b",null]

The same stream works as expected with 2017 Samsung TV and Chrome on Mac

Debug log
RemconAvc_20220811_1130.log

Charles proxy capture of manifest, media-segment and license requests at stream start and point of failure

AvcInBandKeyRotation_20220811_1130_pruned.chls.zip

key change occurred on segment number 830119800

segment SpecNews_AVC-audio_105285_spa104800-830119799.m4s
has KID is eb36782fac245385b789bce12011a9e2

segment SpecNews_AVC-audio_105285_spa104800-830119800.m4s
has KID is 6624cf9f8a15598e91435cad17613e70

@caridley caridley added the type: bug Something isn't working correctly label Aug 11, 2022
@avelad avelad added component: EME The issue involves the Encrypted Media Extensions web API platform: Xbox Issues affecting Xbox component: PlayReady The issue involves the PlayReady DRM labels Aug 11, 2022
@github-actions github-actions bot added this to the v4.2 milestone Aug 11, 2022
@joeyparrish
Copy link
Member

The same stream works as expected with 2017 Samsung TV and Chrome on Mac

Chrome on Mac uses Widevine rather than PlayReady. On Samsung TV, which DRM are you using?

Looking through your log file, I see license requests sent at these times:

  • 11:31:34.733
  • 11:31:40.155

And the error at this time:

  • 11:40:08.545

The requests that are 6 seconds apart are for two different sessions, and both are of type license-request. The error is 8.5 minutes after the license request.

What is the key rotation period?

What is the structure of the keys and tracks? (For example, one set of keys for video, one for audio, or one set for SD video, one for HD, one for UHD, etc.)

Thanks!

@caridley
Copy link
Contributor Author

We use playready on Samsung TVs

Keys rotation occurs every 10 minutes, starting on the hour, then at 10 past etc...

Still trying to get a definitive answer on use of track specific keys

@caridley
Copy link
Contributor Author

I'm not sure why we are getting two license requests, at startup. It looks like the same KID is used in all init and media segments fetched prior to the second key request


In the init segments default_KID in moov.trak.mdia.minf.stbl.stsd.encv.sinf.schi.tenc is eb36782fac245385b789bce12011a9e2

In the media segments KID in moof.traf.sgpd is the same value eb36782fac245385b789bce12011a9e2


@joeyparrish
Copy link
Member

Based on the timing of the error, the key rotation period, and the fact that the license requests were grouped early in the session, I would guess that we're not fetching the next key for the next key rotation period.

This should be done through encrypted events, which are triggered whenever a media segment is appended which contains one or more pssh boxes. We only listen to the encrypted event if there is no PSSH in the manifest, or if the configuration manifest.dash.ignoreDrmInfo is set to true.

So either we're not listening to the event, or it didn't happen. I see that your config has ignoreDrmInfo set to false. If your manifest has PSSH info in the XML, please set this config to true.

If that doesn't work, please check that in your content, either:

  1. there is a new init segment at key rotation period boundaries, and each init segment contains a PSSH box
  2. or the media segments are self-initializing, and new PSSH boxes appear in new key rotation periods
  3. or the media segments in new key rotation periods contain new PSSH boxes independent of other init segment data (not sure if this is a thing, but I think it might work with the logic of the browser's encrypted events)

Does this help?

@joeyparrish joeyparrish added the status: waiting on response Waiting on a response from the reporter(s) of the issue label Aug 12, 2022
@caridley
Copy link
Contributor Author

The manifest does not contain PSSH

I think this approach is used -

  1. or the media segments in new key rotation periods contain new PSSH boxes independent of other init segment data (not sure if this is a thing, but I think it might work with the logic of the browser's encrypted events)

Note that this stream does work as expected on 2017 Samsung TV and Chrome on Mac OS

I have attached a Charles Proxy capture containing the manifest and media segments in the vicinity of the key change at segment number 830119800

@github-actions github-actions bot removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label Aug 16, 2022
@caridley
Copy link
Contributor Author

My guess is that the Xbox is not emitting the encrypted event in this situation. Is it feasible to detect the key change by parsing the PSSH in the media segments in shaka player?

@joeyparrish
Copy link
Member

Yes, it's entirely possible that Xbox is not generating encrypted events. EME on Xbox seems pretty broken.

We could "polyfill" that by parsing for PSSH ourselves. We already have the parser. I would be more than willing to review a PR to add something like that.

I haven't thought through where that would best be added, but segment data doesn't pass through DrmEngine today. So it would need to touch DrmEngine as well as either StreamingEngine or MediaSourceEngine.

I think it could be made generic, with a config to decide whether to use browser encrypted events or local parsing. That config could be made to default to true for Xbox.

@avelad avelad modified the milestones: v4.2, v4.3 Aug 17, 2022
@caridley caridley reopened this Aug 17, 2022
@joeyparrish joeyparrish added the priority: P1 Big impact or workaround impractical; resolve before feature release label Aug 18, 2022
@joeyparrish
Copy link
Member

@caridley, would you be willing to work on a PR for this?

@caridley
Copy link
Contributor Author

Yes.. I should be able to start on this next week.

@joeyparrish
Copy link
Member

Thanks!

joeyparrish pushed a commit that referenced this issue Oct 4, 2022
In-band key rotation, in which new keys are signaled by a change in the
pssh in the media segments, is not working on the Xbox one, but is
working for other browsers and devices. It appear that the Xbox does not
continue watching for pssh changes after the initial DRM session has
been setup.

The problem is fixed by parsing the pssh from media segments prior to
appending to the source buffer. This behavior is controlled with the new
boolean config field drm.parseInbandPsshEnabled.

Fixes #4401
JulianDomingo pushed a commit that referenced this issue Oct 6, 2022
In-band key rotation, in which new keys are signaled by a change in the
pssh in the media segments, is not working on the Xbox one, but is
working for other browsers and devices. It appear that the Xbox does not
continue watching for pssh changes after the initial DRM session has
been setup.

The problem is fixed by parsing the pssh from media segments prior to
appending to the source buffer. This behavior is controlled with the new
boolean config field drm.parseInbandPsshEnabled.

Fixes #4401
JulianDomingo pushed a commit that referenced this issue Oct 6, 2022
In-band key rotation, in which new keys are signaled by a change in the
pssh in the media segments, is not working on the Xbox one, but is
working for other browsers and devices. It appear that the Xbox does not
continue watching for pssh changes after the initial DRM session has
been setup.

The problem is fixed by parsing the pssh from media segments prior to
appending to the source buffer. This behavior is controlled with the new
boolean config field drm.parseInbandPsshEnabled.

Fixes #4401
JulianDomingo pushed a commit that referenced this issue Oct 7, 2022
🤖 I have created a release *beep* *boop*
---


##
[4.1.5](v4.1.4...v4.1.5)
(2022-10-07)


### Bug Fixes

* allow build without text
([#4506](#4506))
([1db6265](1db6265))
* allow the playback on platforms when low latency APIs are not
supported
([#4485](#4485))
([55d1390](55d1390))
* check for negative rows before moving
([#4510](#4510))
([31abae3](31abae3)),
closes
[#4508](#4508)
* Filter unsupported H.264 streams in Xbox
([#4493](#4493))
([1ecede6](1ecede6))
* Fix choppy HLS startup
([#4553](#4553))
([1675bff](1675bff)),
closes
[#4516](#4516)
* Fix errors with TS segments on Chromecast
([#4543](#4543))
([15a1c60](15a1c60))
* Fix hang when seeking to the last segment
([#4537](#4537))
([72a119d](72a119d))
* Fix HLS dynamic to static transition
([932d37c](932d37c))
* Fix HLS dynamic to static transition
([#4483](#4483))
([932d37c](932d37c)),
closes
[#4431](#4431)
* Fix in-band key rotation on Xbox One
([#4478](#4478))
([5a8f09c](5a8f09c)),
closes
[#4401](#4401)
* Respect existing app usage of Cast SDK
([#4523](#4523))
([9c3a494](9c3a494)),
closes
[#4521](#4521)
* **ttml:** Default TTML background color to transparent if unspecified
([#4496](#4496))
([16da1e7](16da1e7)),
closes
[#4468](#4468)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
JulianDomingo pushed a commit that referenced this issue Oct 7, 2022
🤖 I have created a release *beep* *boop*
---


##
[4.2.2](v4.2.1...v4.2.2)
(2022-10-07)


### Bug Fixes

* allow build without text
([#4506](#4506))
([7e93720](7e93720))
* allow the playback on platforms when low latency APIs are not
supported
([#4485](#4485))
([cf8c857](cf8c857))
* check for negative rows before moving
([#4510](#4510))
([23f39d7](23f39d7)),
closes
[#4508](#4508)
* Filter unsupported H.264 streams in Xbox
([#4493](#4493))
([914a08a](914a08a))
* Fix choppy HLS startup
([#4553](#4553))
([950ce69](950ce69)),
closes
[#4516](#4516)
* Fix errors with TS segments on Chromecast
([#4543](#4543))
([8204db6](8204db6))
* Fix hang when seeking to the last segment
([#4537](#4537))
([3d6c768](3d6c768))
* Fix HLS dynamic to static transition
([d9ecbf3](d9ecbf3))
* Fix HLS dynamic to static transition
([#4483](#4483))
([d9ecbf3](d9ecbf3)),
closes
[#4431](#4431)
* Fix in-band key rotation on Xbox One
([#4478](#4478))
([bc0a588](bc0a588)),
closes
[#4401](#4401)
* Missing AES-128 key of last HLS segment
([#4519](#4519))
([2c2677f](2c2677f)),
closes
[#4517](#4517)
* Respect existing app usage of Cast SDK
([#4523](#4523))
([3db2568](3db2568)),
closes
[#4521](#4521)
* **ttml:** Default TTML background color to transparent if unspecified
([#4496](#4496))
([0b5c985](0b5c985)),
closes
[#4468](#4468)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Dec 3, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: EME The issue involves the Encrypted Media Extensions web API component: PlayReady The issue involves the PlayReady DRM platform: Xbox Issues affecting Xbox priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
3 participants