Feat: Add codec-signaling module (init_data builder + codec-string formatter) - #5
Open
ghbogarin wants to merge 2 commits into
Open
Feat: Add codec-signaling module (init_data builder + codec-string formatter)#5ghbogarin wants to merge 2 commits into
ghbogarin wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
media/codec_signalingmodule with two composable, pure helpersthat produce the artifacts a catalog needs to signal a media track's codec:
moq_codec_init_data_build()— builds the decoder configuration record(
init_data). Elementary streams are assembled into a record (AVC/HEVCAnnex B → avcC/hvcC, AV1 OBUs → av1C, OpusHead → dOps); already-formed
records (avcC, hvcC, av1C, dOps) and AudioSpecificConfig are validated and
copied through unchanged.
moq_codec_string_format()— formats the codec string(e.g.
avc1.64001f,mp4a.40.2,hvc1...,av01...,opus) from thatsame record.
Both are allocation-free, thread-safe, and take the byte format explicitly
(no sniffing). Output goes to a caller-provided buffer using the two-call
size protocol (call with
buf == NULLto learn the required length; nopartial output on failure).
Supported formats
Assembled records are verified byte-for-byte against ffmpeg's muxers, with
documented exceptions (hvcC
min_spatial_segmentation_idcemitted as 0;av1C copies the sequence header verbatim as configOBUs). Unsupported inputs
return
MOQ_ERR_UNSUPPORTEDrather than producing incorrect output.Changes
media/codec_signaling/include/moq/codec_signaling.h— public APImedia/codec_signaling/src/codec_signaling.c— implementationmedia/codec_signaling/tests/test_codec_signaling.c— test suitemedia/codec_signaling/CMakeLists.txt— library + test targetCMakeLists.txt— newMOQ_BUILD_CODEC_SIGNALINGoption (ON) wiring thesubdirectory in
Testing
test_codec_signalingcovers both helpers across all supported formats:happy-path expected-bytes checks, round-trips (build → format), buffer-size
protocol, and error paths (NULL args, malformed/incoherent inputs,
unsupported streams). Registered with CTest as
codec_signaling.This change is