Skip to content

Feat: Add codec-signaling module (init_data builder + codec-string formatter) - #5

Open
ghbogarin wants to merge 2 commits into
openmoq:mainfrom
qualabs:feat/msf-codec-parser
Open

Feat: Add codec-signaling module (init_data builder + codec-string formatter)#5
ghbogarin wants to merge 2 commits into
openmoq:mainfrom
qualabs:feat/msf-codec-parser

Conversation

@ghbogarin

@ghbogarin ghbogarin commented Jul 30, 2026

Copy link
Copy Markdown

Summary

Adds a new media/codec_signaling module with two composable, pure helpers
that 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/HEVC
    Annex 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 that
    same 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 == NULL to learn the required length; no
partial output on failure).

Supported formats

  • AVC — Annex B SPS/PPS → avcC, or pass-through avcC
  • HEVC — Annex B VPS/SPS/PPS → hvcC, or pass-through hvcC
  • AV1 — OBUs → av1C, or pass-through av1C
  • AAC — AudioSpecificConfig (validate + copy)
  • Opus — OpusHead (RFC 7845) → dOps, or pass-through dOps

Assembled records are verified byte-for-byte against ffmpeg's muxers, with
documented exceptions (hvcC min_spatial_segmentation_idc emitted as 0;
av1C copies the sequence header verbatim as configOBUs). Unsupported inputs
return MOQ_ERR_UNSUPPORTED rather than producing incorrect output.

Changes

  • media/codec_signaling/include/moq/codec_signaling.h — public API
  • media/codec_signaling/src/codec_signaling.c — implementation
  • media/codec_signaling/tests/test_codec_signaling.c — test suite
  • media/codec_signaling/CMakeLists.txt — library + test target
  • CMakeLists.txt — new MOQ_BUILD_CODEC_SIGNALING option (ON) wiring the
    subdirectory in

Testing

test_codec_signaling covers 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 Reviewable

@ghbogarin ghbogarin changed the title Feat: Add codec-signaling module (init_data builder + codec-string formatter)- #1 Feat: Add codec-signaling module (init_data builder + codec-string formatter) Jul 30, 2026
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.

1 participant