Skip to content

Commit 3456cfb

Browse files
authored
Merge branch 'main' into feature/ctedash
2 parents 44d15fa + 6c1db80 commit 3456cfb

22 files changed

Lines changed: 2172 additions & 29 deletions

CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ if(OPENMOQ_ENABLE_PICOQUIC AND EXISTS "${OPENMOQ_PICOQUIC_SOURCE_DIR}/CMakeLists
143143
endif()
144144

145145
add_library(openmoq_publisher_lib STATIC
146+
src/cat4moq.cpp
146147
src/cli_options.cpp
147148
src/cmaf_segmenter.cpp
148149
src/cmsf_packager.cpp
@@ -208,6 +209,12 @@ add_executable(openmoq-publisher-psychedelic-example
208209
)
209210
target_link_libraries(openmoq-publisher-psychedelic-example PRIVATE openmoq_publisher_lib)
210211

212+
add_executable(openmoq-publisher-auth-example
213+
examples/auth/AuthPublisher.cpp
214+
examples/auth/catapult_client.cpp
215+
)
216+
target_link_libraries(openmoq-publisher-auth-example PRIVATE openmoq_publisher_lib)
217+
211218
include(CTest)
212219

213220
if(OPENMOQ_BUILD_TESTS)
@@ -253,6 +260,18 @@ if(OPENMOQ_BUILD_TESTS)
253260
target_link_libraries(openmoq-publisher-api-tests PRIVATE openmoq_publisher_lib)
254261
add_test(NAME openmoq-publisher-api-tests COMMAND openmoq-publisher-api-tests)
255262

263+
add_executable(openmoq-publisher-cat4moq-api-tests
264+
tests/cat4moq_api_test.cpp
265+
)
266+
target_link_libraries(openmoq-publisher-cat4moq-api-tests PRIVATE openmoq_publisher_lib)
267+
add_test(NAME openmoq-publisher-cat4moq-api-tests COMMAND openmoq-publisher-cat4moq-api-tests)
268+
269+
add_executable(openmoq-publisher-cat4moq-transport-token-tests
270+
tests/cat4moq_transport_token_test.cpp
271+
)
272+
target_link_libraries(openmoq-publisher-cat4moq-transport-token-tests PRIVATE openmoq_publisher_lib)
273+
add_test(NAME openmoq-publisher-cat4moq-transport-token-tests COMMAND openmoq-publisher-cat4moq-transport-token-tests)
274+
256275
add_executable(openmoq-publisher-control-message-tests
257276
tests/moqt_control_messages_test.cpp
258277
)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ On Windows, replace `./build/openmoq-publisher` with `build\Release\openmoq-publ
201201
| FFmpeg input recipes | [docs/ffmpeg.md](docs/ffmpeg.md) |
202202
| Relay interoperability | [docs/relay-interop.md](docs/relay-interop.md) |
203203
| C++ Publisher API | [docs/publisher-api.md](docs/publisher-api.md) |
204+
| CAT4MOQ auth example | [examples/auth/README.md](examples/auth/README.md) |
204205
| Protocol mapping | [docs/protocol-mapping.md](docs/protocol-mapping.md) |
205206
| WebTransport compliance | [docs/webtransport-compliance.md](docs/webtransport-compliance.md) |
206207
| Transport plan | [docs/transport-plan.md](docs/transport-plan.md) |

docs/publisher-api.md

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Key types:
1313
- `openmoq::publisher::PublisherConfig`
1414
- `openmoq::publisher::Publisher`
1515
- `openmoq::publisher::PreparedPublish`
16+
- `openmoq::publisher::cat4moq::AuthorizationConfig`
1617

1718
## 2. Link the Library
1819

@@ -52,7 +53,36 @@ config.subscriber_timeout = std::chrono::seconds(30);
5253
openmoq::publisher::Publisher publisher(config);
5354
```
5455
55-
## 4. Prepare Media Once (Batch Mode)
56+
## 4. Optional CAT4MOQ Authorization
57+
58+
Applications that need CAT4MOQ or other MoQ authorization-token carriage configure tokens at the public API layer. Transport internals consume this config when encoding setup, namespace, and publish request messages.
59+
60+
```cpp
61+
#include "openmoq/publisher/cat4moq.h"
62+
#include "openmoq/publisher/publisher_api.h"
63+
64+
std::vector<std::uint8_t> setup_cwt = read_setup_token();
65+
std::vector<std::uint8_t> publish_cwt = read_publish_token();
66+
67+
openmoq::publisher::PublisherConfig config;
68+
config.authorization.setup_token =
69+
openmoq::publisher::cat4moq::wrap_cat_token(setup_cwt);
70+
config.authorization.action_token =
71+
openmoq::publisher::cat4moq::wrap_cat_token(publish_cwt);
72+
```
73+
74+
`setup_token` is carried on the session setup message. `action_token` is carried on publisher action requests such as namespace publish and track publish. Leave either field empty when that part of the relay policy does not require a token.
75+
76+
Helper wrappers:
77+
78+
- `wrap_cat_token(...)`: wraps raw Catapult/CAT CWT bytes as a CAT authorization-token value.
79+
- `wrap_out_of_band_token(...)`: wraps raw private token bytes with the out-of-band token type.
80+
- `AuthorizationToken`: stores the encoded authorization-token value sent on the wire.
81+
- `AuthorizationConfig`: groups setup-level and action-level tokens for `PublisherConfig`.
82+
83+
The runnable example in [examples/auth](../examples/auth/README.md) shows file-based tokens, Catapult command integration, and a deterministic `publish_live_objects(...)` flow against a moqx relay.
84+
85+
## 5. Prepare Media Once (Batch Mode)
5686

5787
For file or buffered stream workflows, prepare media first:
5888

@@ -78,7 +108,7 @@ This is useful for larger apps that want to:
78108
- store plan state
79109
- publish the same prepared asset to multiple endpoints
80110
81-
## 5. Optional: Inspect or Emit the Plan
111+
## 6. Optional: Inspect or Emit the Plan
82112
83113
Render the plan for logging/debug:
84114
@@ -92,7 +122,7 @@ Emit generated catalog and media objects to disk:
92122
publisher.emit_objects(prepared, "out");
93123
```
94124

95-
## 6. Configure Endpoint and TLS
125+
## 7. Configure Endpoint and TLS
96126

97127
Build `EndpointConfig` and optional `TlsConfig`.
98128

@@ -126,7 +156,7 @@ tls.insecure_skip_verify = false;
126156
// tls.private_key_path = "...";
127157
```
128158

129-
## 7. Publish Prepared Content
159+
## 8. Publish Prepared Content
130160

131161
Use prepared content plus endpoint:
132162

@@ -149,7 +179,7 @@ Convenience helpers:
149179
- `publish_file(path, endpoint, tls)`
150180
- `publish_stream(input, source_name, endpoint, tls)`
151181

152-
## 8. Live Input Publish (Incremental stdin/stream)
182+
## 9. Live Input Publish (Incremental stdin/stream)
153183

154184
The default live path expects fragmented MP4, which matches ffmpeg/CMAF
155185
pipelines:
@@ -168,7 +198,7 @@ if (!status.ok) {
168198

169199
`publish_live(...)` uses incremental parsing and live publish flow instead of buffering to EOF.
170200

171-
## 9. Arbitrary Live Object Publish
201+
## 10. Arbitrary Live Object Publish
172202

173203
Applications that already produce MoQ objects directly can bypass fragmented MP4
174204
ingest with `publish_live_objects(...)`.
@@ -200,7 +230,7 @@ Each `LiveObject` supplies the target track, group/object IDs, optional media
200230
timing, and the payload bytes to send. The fragmented MP4 `publish_live(...)`
201231
API remains the default live publishing path.
202232
203-
## 10. ALPN Override Behavior
233+
## 11. ALPN Override Behavior
204234
205235
By default, the API applies transport-appropriate ALPN:
206236
@@ -229,7 +259,7 @@ The same override flag exists on:
229259
- `publish_live(...)`
230260
- `publish_live_objects(...)`
231261

232-
## 11. Error Handling Pattern
262+
## 12. Error Handling Pattern
233263

234264
All API publish calls return `TransportStatus`:
235265

@@ -251,7 +281,7 @@ if (!status.ok) {
251281
}
252282
```
253283

254-
## 12. Integration Pattern for Larger Applications
284+
## 13. Integration Pattern for Larger Applications
255285

256286
For service-style integration:
257287

@@ -263,7 +293,7 @@ For service-style integration:
263293
6. For direct object producers, provide a `LiveObjectSource` and call `publish_live_objects(...)`.
264294
7. Use `TransportStatus` messages for metrics and retry decisions.
265295

266-
## 13. Publish Summary (`stats`)
296+
## 14. Publish Summary (`stats`)
267297

268298
The publisher API is blocking: `publish(...)`, `publish_file(...)`,
269299
`publish_stream(...)`, and `publish_live(...)` run the session on the calling
@@ -332,7 +362,7 @@ Example:
332362
}
333363
```
334364

335-
## 14. Complete Example
365+
## 15. Complete Example
336366

337367
```cpp
338368
#include "openmoq/publisher/publisher_api.h"
@@ -378,7 +408,7 @@ int main() {
378408
}
379409
```
380410

381-
## 15. Live Publish with Audio/Video Encoders on Other Threads
411+
## 16. Live Publish with Audio/Video Encoders on Other Threads
382412

383413
`publish_live(...)` consumes one MP4 byte stream.
384414
For multi-track live publishing, the common pattern is:

docs/quickstart.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,33 @@ When `--forward 0` is used, seeing a relay connection ID only confirms that the
169169

170170
The DASH ingest listener is currently supported on Unix-like platforms. Windows builds compile the CLI but report DASH ingest server startup as unsupported.
171171

172+
## CAT4MOQ Auth Example
173+
174+
Build the CAT4MOQ auth example when testing a relay that requires MoQ authorization tokens:
175+
176+
```bash
177+
cmake --build build --target openmoq-publisher-auth-example
178+
```
179+
180+
Run it with a token file:
181+
182+
```bash
183+
CAT4MOQ_TOKEN_FILE=/tmp/publish-token.cwt \
184+
CAT4MOQ_ENDPOINT='https://127.0.0.1:4433/moq-relay' \
185+
./examples/auth/run-cat4moq-auth-example.sh
186+
```
187+
188+
Or run it with moqx as the Catapult/CAT4MOQ issuer command:
189+
190+
```bash
191+
CATAPULT_CAT4MOQ_COMMAND='../moqx/build/moqx issue-cat-token --config /tmp/moqx-auth.yaml --auth-service live --auth-key-id cat-dev --auth-actions client_setup,publish_namespace,publish --auth-namespace {namespace} --auth-track {track}' \
192+
CAT4MOQ_ENDPOINT='https://127.0.0.1:4433/moq-relay' \
193+
./examples/auth/run-cat4moq-auth-example.sh
194+
```
195+
196+
See [examples/auth/README.md](../examples/auth/README.md) for the moqx auth
197+
config, token generation, relay connection, and focused-test workflow.
198+
172199
## Output Notes
173200

174201
- default output includes the `catalog` object plus media objects

docs/relay-interop.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,49 @@ OPENMOQ_PICOQUIC_TRACE=1 ./build/openmoq-publisher \
7171

7272
`moq-relay.red5.net:4433` currently accepts WebTransport on `/moq`; `/moq-relay` returns HTTP `404` during CONNECT. The moqx relay examples use a placeholder hostname because those relay hostnames are not public yet; moqx uses `/moq-relay`.
7373

74+
## CAT4MOQ Authorization with moqx
75+
76+
For moqx services with auth enabled, use the auth example instead of the generic CLI. It obtains CAT4MOQ token bytes from a file or Catapult command, configures `PublisherConfig::authorization`, and publishes a deterministic live-object track.
77+
78+
Build the example:
79+
80+
```bash
81+
cmake --build build --target openmoq-publisher-auth-example
82+
```
83+
84+
Run against an already-started relay:
85+
86+
```bash
87+
CAT4MOQ_TOKEN_FILE=/tmp/publish-token.cwt \
88+
CAT4MOQ_ENDPOINT='https://127.0.0.1:4433/moq-relay' \
89+
CAT4MOQ_NAMESPACE='cat4moq.example' \
90+
CAT4MOQ_TRACK='video' \
91+
./examples/auth/run-cat4moq-auth-example.sh
92+
```
93+
94+
Run with separate setup/action tokens:
95+
96+
```bash
97+
CAT4MOQ_SETUP_TOKEN_FILE=/tmp/setup.cwt \
98+
CAT4MOQ_ACTION_TOKEN_FILE=/tmp/publish.cwt \
99+
CAT4MOQ_ENDPOINT='https://127.0.0.1:4433/moq-relay' \
100+
./examples/auth/run-cat4moq-auth-example.sh
101+
```
102+
103+
Run with moqx as the Catapult/CAT4MOQ issuer command:
104+
105+
```bash
106+
CATAPULT_CAT4MOQ_COMMAND='../moqx/build/moqx issue-cat-token --config /tmp/moqx-auth.yaml --auth-service live --auth-key-id cat-dev --auth-actions client_setup,publish_namespace,publish --auth-namespace {namespace} --auth-track {track}' \
107+
CAT4MOQ_ENDPOINT='https://127.0.0.1:4433/moq-relay' \
108+
./examples/auth/run-cat4moq-auth-example.sh
109+
```
110+
111+
When using the default CAT wrapper, configure moqx service auth with
112+
`token_type: 16`, matching the token type wrapped by moqxr. If using
113+
`CAT4MOQ_TOKEN_WRAPPER=out-of-band`, configure `token_type: 0`. See
114+
[examples/auth/README.md](../examples/auth/README.md) for the local moqx auth
115+
config, token generation, token encoding, and focused-test workflow.
116+
74117
## Trace CSV
75118

76119
If you want a per-object CSV trace for pacing and enqueue correlation, set `OPENMOQ_PICOQUIC_TRACE_CSV` alongside `OPENMOQ_PICOQUIC_TRACE`:

0 commit comments

Comments
 (0)