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

Adapt to mp4ff v0.46.0 #26

Merged
merged 5 commits into from
Oct 2, 2024
Merged

Adapt to mp4ff v0.46.0 #26

merged 5 commits into from
Oct 2, 2024

Conversation

hekmon
Copy link
Contributor

@hekmon hekmon commented Sep 9, 2024

Hello,

mp4ff had a massive rework on its functions set in its v0.40.0 release :

  • DecryptSampleCenc does not exist anymore
  • it has been replaced with CryptSampleCenc

But internaly a lot changed to hide the complexity and provide a cleaner high level access. So instead of just replacing the function and leaving the decrypt code that was inspired by the v0.39.0 decrypt utility, I started from scratch from the same utility but in v0.46.0, resulting on a much smaller code base to replicate.

The only change I made to the API, was to allow the slice of keys from the widevine license (and automatically select the content key from it) as input instead of the right key in bytes. The example in readme has been updated to reflect this change.

Tests for decrypts work fine for 3 of 4 samples. The audio sample does not pass the test but I am unable to know why. As you created those samples you might get why better than me.

@iyear
Copy link
Owner

iyear commented Sep 30, 2024

Thanks for your contribution, but the DecryptMP4 func sig has been modified, which will result in a breaking change. You can either keep the original function signature or create a new function.

@hekmon
Copy link
Contributor Author

hekmon commented Oct 1, 2024

You are right. I restored the original function signature to avoid the breaking change and added a wrapper on top of it for the new functionnality. Readme now refers to the wrapper.

@iyear
Copy link
Owner

iyear commented Oct 1, 2024

Please check the CI error: failed to decrypt segment: no senc box in traf

@hekmon
Copy link
Contributor Author

hekmon commented Oct 1, 2024

Tests for decrypts work fine for 3 of 4 samples. The audio sample does not pass the test but I am unable to know why. As you created those samples you might get why better than me.

This is what I was talking about. I have no clue, could you take a look ?

@iyear
Copy link
Owner

iyear commented Oct 1, 2024

my code:

hasSenc, isParsed := traf.ContainsSencBox()
if !hasSenc {
  // if not encrypted, do nothing
  continue
}

mp4ff code:

hasSenc, isParsed := traf.ContainsSencBox()
if !hasSenc {
    return fmt.Errorf("no senc box in traf")
}

I initially implemented a skip instead of returning an error for this because the Spotify sample I used is unencrypted for the first few seconds and encrypted afterward.

@hekmon
Copy link
Contributor Author

hekmon commented Oct 1, 2024

I knew you would have better insight than me on that audio sample :)

So to fix it there is to 2 ways :

  • Reimplementing the mp4ff code to introduce the continue again
    • I personnaly do not like reimplementing a portion of a code from a library we should rely on, it make stuffs messy and hard to maintain in the future
  • Checking/intercepting the error on the high level code to avoid replicating the mp4ff code
    • Unfortunatly the error is not a registered/wrapped error we could check with errors.Is() (which would be the cleanest way to do it).
    • This means we can only check its string representation (which is not a big deal as the error itself is an unwrapped fmt.Errorf): not really "golangish"

Even without the possibility of using Golang errors comparaison, I still prefer the second option. It keeps the duplicated code minimal. But in definitive it is your codebase and the choice should be yours.

I will push my working commit of the second option, tell me if this is ok for you.

@codecov-commenter
Copy link

codecov-commenter commented Oct 2, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 24.13793% with 22 lines in your changes missing coverage. Please review.

Project coverage is 68.19%. Comparing base (4f85b53) to head (f49c15e).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
decrypt.go 24.13% 16 Missing and 6 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #26      +/-   ##
==========================================
- Coverage   72.37%   68.19%   -4.18%     
==========================================
  Files           5        5              
  Lines         438      327     -111     
==========================================
- Hits          317      223      -94     
+ Misses         68       62       -6     
+ Partials       53       42      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@iyear iyear left a comment

Choose a reason for hiding this comment

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

LGTM

@iyear iyear merged commit 2ba3ad2 into iyear:master Oct 2, 2024
2 checks passed
@hekmon hekmon deleted the adapt branch October 2, 2024 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants