You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/manifest/writing/ingredients.md
+64Lines changed: 64 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,4 +70,68 @@ When ingredients are added, the SDK validates their Content Credentials (if any)
70
70
Ingredient certificates are validated when they are added to the manifest store, NOT during validation of the composed asset.
71
71
:::
72
72
73
+
## Linking actions and ingredients
74
+
75
+
To link an action and an ingredient, reuse the ingredient ID in the action's `ingredientsId` array when building the manifest. The examples given here are for Python, but the same technique works in any language.
76
+
77
+
This example and others are in the Python library:
78
+
79
+
-[An ingredient with a `c2pa.opened` action](https://github.com/contentauth/c2pa-python/blob/main/tests/test_unit_tests.py#L2927).
80
+
-[An ingredient with one `c2pa.opened` and one `c2pa.placed` action](https://github.com/contentauth/c2pa-python/blob/main/tests/test_unit_tests.py#L3011).
81
+
-[Multiple ingredients with `c2pa.placed` action](https://github.com/contentauth/c2pa-python/blob/main/tests/test_unit_tests.py#L3117).
82
+
83
+
First, get an ID for the ingredient; [for example](https://github.com/contentauth/c2pa-python/blob/main/tests/test_unit_tests.py#L2934):
Use that ID when the manifest gets defined in an `ingredientsId` array; [for example](https://github.com/contentauth/c2pa-python/blob/main/tests/test_unit_tests.py#L2958):
90
+
91
+
```json
92
+
...
93
+
"assertions": [
94
+
{
95
+
"label": "c2pa.actions.v2",
96
+
"data": {
97
+
"actions": [
98
+
{
99
+
"action": "c2pa.opened",
100
+
"softwareAgent": {
101
+
"name": "Opened asset",
102
+
},
103
+
"parameters": {
104
+
"ingredientIds": [
105
+
parent_ingredient_id
106
+
]
107
+
},
108
+
...
109
+
```
110
+
111
+
Then the SDK then links the ingrdient with the action.
112
+
113
+
This also works with an ingredient JSON with the "add ingredient" function; [for example](https://github.com/contentauth/c2pa-python/blob/main/tests/test_unit_tests.py#L2971-L2985):
114
+
115
+
```python
116
+
ingredient_json = {
117
+
"relationship": "parentOf",
118
+
"instance_id": parent_ingredient_id
119
+
}
120
+
# An opened ingredient is always a parent--exactly one parent ingredient is allowed.
0 commit comments