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

fix: Missing AES-128 key of last HLS segment #4519

Merged
merged 2 commits into from
Oct 4, 2022

Conversation

devsunb
Copy link
Contributor

@devsunb devsunb commented Sep 27, 2022

Closes #4517

Problem

Fetching the last segment of HLS AES-128 stream fails with 3018 error

  • MediaSourceEngine attempts to transmux encrypted TS data
  • StreamingEngine does not decrypt TS data of the last segment
  • SegmentReference of the last segment has null for hlsAes128Key
  • hlsAes128Key is missing when adjusting the last SegmentReference in SegmentIndex.fit()

Test

Before

2022-09-28 02-09-34

After

2022-09-28 02-09-34

@avelad avelad added type: bug Something isn't working correctly component: HLS The issue involves Apple's HLS manifest format labels Sep 27, 2022
@avelad avelad added this to the v4.3 milestone Sep 27, 2022
@avelad
Copy link
Collaborator

avelad commented Sep 27, 2022

@theodab can you review it? You are the expert in AES-128

@github-actions
Copy link
Contributor

Incremental code coverage: 100.00%

@avelad avelad added the priority: P1 Big impact or workaround impractical; resolve before feature release label Sep 28, 2022
@@ -955,9 +955,11 @@ describe('SegmentIndex', /** @suppress {accessControls} */ () => {
* @param {number} startTime
* @param {number} endTime
* @param {!Array.<!shaka.media.SegmentReference>=} partialReferences
* @param {!shaka.extern.HlsAes128Key} hlsAes128Key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: If this is an optional parameter, the type should end with an equals sign to signify that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review. I fixed it!

* @return {shaka.media.SegmentReference}
*/
function makeReference(uri, startTime, endTime, partialReferences = []) {
function makeReference(uri, startTime, endTime, partialReferences = [],
hlsAes128Key = {method: 'AES-128', firstMediaSequenceNumber: 0}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to default that to non-null at all times in all tests?

Could you instead make a regression test for this particular bug, where you show that hlsAes128Key is preserved on the last segment after a fit() call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before

2022-10-03 01-10-03

After

2022-10-03 01-10-45

@joeyparrish
Copy link
Member

Thank you for finding and fixing this bug, and thank you for contributing!

@avelad
Copy link
Collaborator

avelad commented Sep 30, 2022

@devsunb can you rebase to resolve the issues in the tests? Thank you!

lib/media/segment_index.js Outdated Show resolved Hide resolved
avelad
avelad previously approved these changes Oct 2, 2022
daraqui
daraqui previously approved these changes Oct 3, 2022
@avelad
Copy link
Collaborator

avelad commented Oct 3, 2022

@devsunb please fix the linter errors, thanks!

@avelad avelad self-requested a review October 3, 2022 16:35
@devsunb
Copy link
Contributor Author

devsunb commented Oct 3, 2022

@devsunb please fix the linter errors, thanks!

I fixed it! Sorry for my oversight.

avelad
avelad previously approved these changes Oct 3, 2022
lib/media/segment_index.js Outdated Show resolved Hide resolved
@joeyparrish
Copy link
Member

Thanks for your contribution! I'll merge this after the new test run is complete.

@joeyparrish joeyparrish merged commit 3d0f752 into shaka-project:main Oct 4, 2022
JulianDomingo pushed a commit that referenced this pull request Oct 6, 2022
When fitting the segment references to the timeline, some properties
were lost, including the AES-128 key.  This fixes those missing properties.

Closes #4517
JulianDomingo pushed a commit that referenced this pull request 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 Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: HLS The issue involves Apple's HLS manifest format 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
4 participants