Skip to content

feat: Add embeddable api support#170

Merged
gpeacock merged 3 commits into
mainfrom
gpeacock/embeddable_api
Mar 5, 2026
Merged

feat: Add embeddable api support#170
gpeacock merged 3 commits into
mainfrom
gpeacock/embeddable_api

Conversation

@gpeacock

@gpeacock gpeacock commented Mar 5, 2026

Copy link
Copy Markdown
Member

New APIs — six new Builder methods for the embeddable workflow where the signer lives on the context: needs_placeholder(format) — check if a placeholder embed step is required
placeholder(format) — generate the placeholder bytes to embed in the asset
set_data_hash_exclusions(exclusions) — register where the placeholder was embedded
update_hash_from_stream(format, stream) — hash the asset, skipping exclusion ranges
sign_embeddable(format) — sign and return manifest bytes, zero-padded to placeholder size
set_bmff_mdat_hashes(...) — supply pre-computed mdat chunk hashes for BMFF Merkle workflows

Plus Context::ContextBuilder::with_signer(Signer&&) — attach a signer to a context programmatically.
New test — FullWorkflowWithAJpgContextSigner demonstrating the end-to-end embeddable workflow for a JPEG using a context-attached signer.

New APIs — six new Builder methods for the embeddable workflow where the signer lives on the context:
needs_placeholder(format) — check if a placeholder embed step is required
placeholder(format) — generate the placeholder bytes to embed in the asset
set_data_hash_exclusions(exclusions) — register where the placeholder was embedded
update_hash_from_stream(format, stream) — hash the asset, skipping exclusion ranges
sign_embeddable(format) — sign and return manifest bytes, zero-padded to placeholder size
set_bmff_mdat_hashes(...) — supply pre-computed mdat chunk hashes for BMFF Merkle workflows
Plus Context::ContextBuilder::with_signer(Signer&&) — attach a signer to a context programmatically.
New test — FullWorkflowWithAJpgContextSigner demonstrating the end-to-end embeddable workflow for a JPEG using a context-attached signer.

@tmathern tmathern left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The existing APIs in the header file should stay (especially since the implementation are still here).

The main reason is that they enable to programatically set a Signer on a Context (and not "just" through Settings). It is also used in one of the embeddable tests.
I know embeddable APIs can work just with the Context and expect a Signer on it. So being able to set it programatically makes the API more flexible.

All this to ask to revert the removals from c2pa.hpp.

ps: I am not sure why, sometimes you need the safe to test label to run the tests, sometimes not. Here it didn't run them, but I expect build failrues due to the header change (with_signer is used).

Comment thread tests/embeddable.test.cpp
Comment thread tests/embeddable.test.cpp Outdated
Comment thread tests/embeddable.test.cpp

@tmathern tmathern left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Such a clean API for a complicated topic! LGTM!

@tmathern

tmathern commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

Suggestion: Bump the version in https://github.com/contentauth/c2pa-c/blob/main/CMakeLists.txt#L17 before merging, so one of us can tag this later!

There's no breaking change but I think new apis warrant a minor version bump
@gpeacock gpeacock merged commit f22ec1d into main Mar 5, 2026
9 checks passed
@tmathern tmathern deleted the gpeacock/embeddable_api branch March 7, 2026 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants