Make mp4.UUID an alias of the standard library uuid.UUID once Go 1.28 is released

Open
#716 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
18/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
go
Domain
api

Research direction

Start by reading the UUID type and UnpackKey/NewUUIDFromString in the mp4 package, then trace the KID and SystemID fields the issue lists: PsshBox.SystemID, KIDs, TencBox.DefaultKID, SeigSampleGroupEntry.KID, and the InitProtect parameter. Do not begin until Go 1.28 is released, since the issue requires go.mod to stay at 1.24 until then. Done means the alias compiles across these sites, the tests pass, and the CHANGELOG lists the breaking change.

Written by the indexing model from the issue text.

Description

enhancement

[!IMPORTANT]
Timing: do this once Go 1.28 is released (expected February 2027), not before.
The standard library uuid package arrived in Go 1.27. Once Go 1.28 is out, 1.27 is the oldest supported Go release, so requiring it then follows the Go release policy.
Until then, mp4ff keeps its current minimum (go 1.24 in go.mod, tested in CI).

Proposal

Make mp4.UUID an alias of the standard library type:

type UUID = uuid.UUID // [16]byte

Today mp4.UUID is a []byte. A 16-byte array is a better fit for KIDs and SystemIDs:

  • UUIDs compare with == and work as map keys, so UUID.Equal is no longer needed.
  • A UUID can no longer have the wrong length, so String() no longer needs its "bad uuid ..." case.
  • Decoding no longer allocates a slice for each KID or SystemID.
  • Callers can pass uuid.UUID values straight in, and String, MarshalText/UnmarshalText and Compare come from the standard library.

Use an alias rather than a defined type: a defined type such as type UUID uuid.UUID would lose the methods, including String().

What stays in mp4ff

  • UnpackKey and NewUUIDFromString. They also accept 24-character base64, which uuid.Parse does not, and UnpackKey decodes content keys, which are not UUIDs. They would return uuid.UUID for KIDs.
  • The PlayReady GUID byte-order conversion for KIDs.
  • The UUID* string constants. They are all in canonical form, so uuid.MustParse can parse them (UUIDMssSm was fixed in #715).

Breaking changes

This changes the type of exported fields and parameters, including PsshBox.SystemID and KIDs, TencBox.DefaultKID, SeigSampleGroupEntry.KID, the kid parameter of InitProtect, ProtectionSystemName, the PIFF tenc KID, and the KID fields of the decoded Widevine and PlayReady pssh data.

For callers:

  • mp4.UUID(b) with b []byte still compiles (slice-to-array conversion), but panics if len(b) < 16.
  • .Equal(...), comparisons with nil, and passing a UUID to bytes or hex functions without [:] no longer compile.
  • An unset KID is now the zero UUID instead of nil.
  • json.Marshal writes UUIDs as dashed strings instead of base64.

Raising the go directive to 1.27 also makes every module that depends on mp4ff require Go 1.27 or later. The CHANGELOG entry must list this as a breaking change.

Dominant language
Go
Stars
667
Forks
132
Avg merge
20h 4m
Merged PRs (30d)
54

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Eyevinn/mp4ff

All issues in Eyevinn/mp4ff

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.