Skip to content

feat: Implement live video per-segment manifest chain validation (spec 19.3)#3

Open
N1Knight wants to merge 10 commits into
mainfrom
feat/live-video-section-19-3
Open

feat: Implement live video per-segment manifest chain validation (spec 19.3)#3
N1Knight wants to merge 10 commits into
mainfrom
feat/live-video-section-19-3

Conversation

@N1Knight

Copy link
Copy Markdown

Summary

Implements C2PA Technical Specification sections 18.25 and 19.3 — the per-segment C2PA Manifest Box method for live video signing and validation.

Each CMAF/DASH media segment carries its own C2PA Manifest containing a c2pa.livevideo.segment assertion. The implementation covers both ends: a LiveVideoSigner that produces signed segments with a cryptographic continuity chain, and a LiveVideoValidator that verifies it.

Section 18.25 (c2pa.livevideo.segment assertion) is also included here as required groundwork.

Changes

  • c2pa.livevideo.segment assertionLiveVideoSegment CBOR assertion with sequenceNumber, streamId, continuityMethod, previousManifestId, and open-ended extension fields. Includes ContinuityMethod enum with lossless round-trip for unknown future methods.

  • LiveVideoSigner (SDK) — signs init and media segments one at a time, managing sequence numbers and previousManifestId automatically. Supports resuming the continuity chain across separate process invocations via resume_from_segment. Stream identity (streamId) is read from the manifest JSON; state fields (previousManifestId, nextSequenceNumber) can be persisted there too via updated_manifest_json.

  • LiveVideoValidator (SDK) — stateful validator for §19.3 streams. Validates init segments (§19.7.1) and media segments (§19.7.2): ordering, stream identity, manifest continuity, and previousManifestId linkage.

  • 5 new validation status codeslivevideo.init.invalid, livevideo.segment.invalid, livevideo.manifest.invalid, livevideo.assertion.invalid, livevideo.continuityMethod.invalid.

  • live-video-sign CLI subcommand — signs a stream from the command line. Reads streamId from the manifest JSON; --previous-segment resumes the chain across invocations; --init optionally signs the init segment.

  • live-video CLI subcommand — validates a signed stream from the command line.

  • BMFF styp support — extended the BMFF IO handler to accept styp (Segment Type Box) in addition to ftyp, enabling signing and reading of real DASH .m4s media segments.

Validation rules implemented

Rule Status code
Init segment contains mdat box livevideo.init.invalid
Segment has no C2PA Manifest Box livevideo.segment.invalid
sequenceNumber not strictly increasing livevideo.assertion.invalid
streamId changed between segments livevideo.assertion.invalid
continuityMethod missing livevideo.continuityMethod.invalid
continuityMethod == c2pa.manifestId without previousManifestId livevideo.continuityMethod.invalid
previousManifestId doesn't match preceding segment's manifest ID livevideo.segment.invalid
Unrecognized continuityMethod livevideo.continuityMethod.invalid

Test plan

Unit/integration tests:

cargo test --features="file_io" -p c2pa live_video
cargo test --features="file_io" -p c2pa live_video_segment
cargo test -p c2patool live_video
make clippy

Manual end-to-end (sign + verify):

Requires live_video_demo/ with input/init.mp4 + input/seg_*.m4s and a manifest.json with a c2pa.livevideo.segment assertion containing streamId.

  • Sign all segments in one shot
cargo run --bin c2patool -- live_video_demo/input live-video-sign \
  --segments_glob "seg_*.m4s" \
  --output live_video_demo/signed \
  --manifest live_video_demo/manifest.json \
  --init init.mp4
  • Or sign segments one at a time (e.g. simulating a live ingest pipeline)
cargo run --bin c2patool -- live_video_demo/input live-video-sign \
  --segments_glob "seg_001.m4s" \
  --output live_video_demo/signed \
  --manifest live_video_demo/manifest.json \
  --init init.mp4

cargo run --bin c2patool -- live_video_demo/input live-video-sign \
  --segments_glob "seg_002.m4s" \
  --output live_video_demo/signed \
  --manifest live_video_demo/manifest.json \
  --previous-segment live_video_demo/signed/seg_001.m4s
  • Verify
cargo run --bin c2patool -- live_video_demo/signed/init.mp4 live-video \
  --segments_glob "seg_*.m4s"

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