|
| 1 | +# Picoquic Transport Plan |
| 2 | + |
| 3 | +This document turns the current picoquic integration idea into an implementation checklist for `moqxr`. |
| 4 | + |
| 5 | +## Goal |
| 6 | + |
| 7 | +Add a native QUIC transport layer using picoquic so the existing publisher pipeline can send MOQT control and media objects over a real connection without rewriting the packaging code. |
| 8 | + |
| 9 | +## Scope boundaries |
| 10 | + |
| 11 | +The current repository already handles: |
| 12 | + |
| 13 | +- MP4 parsing |
| 14 | +- fragmented MP4 fast-path packaging |
| 15 | +- progressive MP4 remux into synthetic fragments |
| 16 | +- draft-aware publish planning |
| 17 | + |
| 18 | +The picoquic work should add: |
| 19 | + |
| 20 | +- QUIC connection management |
| 21 | +- MOQT session setup and control streams |
| 22 | +- media object publication over QUIC streams |
| 23 | +- transport-level backpressure and error handling |
| 24 | + |
| 25 | +The picoquic work should not initially add: |
| 26 | + |
| 27 | +- HTTP/3 |
| 28 | +- WebTransport |
| 29 | +- broad muxing or repackaging logic |
| 30 | +- advanced QUIC features such as migration or multipath |
| 31 | + |
| 32 | +## Architecture target |
| 33 | + |
| 34 | +The intended layering is: |
| 35 | + |
| 36 | +1. Packaging layer |
| 37 | + Uses `ParsedMp4`, `SegmentedMp4`, and `PublishPlan`. |
| 38 | +2. Session layer |
| 39 | + Converts a `PublishPlan` into MOQT control and object publication actions. |
| 40 | +3. Transport layer |
| 41 | + Provides connection, stream, and write primitives. |
| 42 | +4. Picoquic adapter |
| 43 | + Implements the transport layer on top of picoquic callbacks and sockets. |
| 44 | + |
| 45 | +This separation is important because MOQT draft churn should be isolated to the session layer, while picoquic remains a byte transport. |
| 46 | + |
| 47 | +## Deliverables |
| 48 | + |
| 49 | +### Phase 1: transport seam |
| 50 | + |
| 51 | +- [x] Add a transport interface for connect, open stream, write, close |
| 52 | +- [x] Add a session façade that consumes `PublishPlan` |
| 53 | +- [x] Add a picoquic client stub that implements the transport interface |
| 54 | +- [x] Keep current CLI and packaging flow unchanged |
| 55 | + |
| 56 | +### Phase 2: connection establishment |
| 57 | + |
| 58 | +- [x] Add endpoint configuration: host, port, ALPN |
| 59 | +- [x] Add TLS configuration hooks: cert, key, CA, insecure-dev toggle |
| 60 | +- [x] Establish a client QUIC connection with picoquic |
| 61 | +- [x] Report handshake success and failures cleanly |
| 62 | + |
| 63 | +### Phase 3: MOQT control plane |
| 64 | + |
| 65 | +- [ ] Open a control stream after handshake |
| 66 | +- [ ] Implement setup and session negotiation |
| 67 | +- [ ] Implement namespace or publish announcement flow |
| 68 | +- [ ] Represent draft-14 and draft-16 control-plane differences behind one abstraction |
| 69 | + |
| 70 | +### Phase 4: object publication |
| 71 | + |
| 72 | +- [ ] Publish initialization object first |
| 73 | +- [ ] Publish media objects according to `PublishPlan` |
| 74 | +- [ ] Decide and document one stream mapping policy |
| 75 | +- [ ] Handle transport write backpressure |
| 76 | + |
| 77 | +### Phase 5: observability and testing |
| 78 | + |
| 79 | +- [ ] Add structured logs for handshake, stream lifecycle, and object publication |
| 80 | +- [ ] Add unit tests for session-to-transport mapping |
| 81 | +- [ ] Add loopback integration tests for transport |
| 82 | +- [ ] Add interoperability tests against an OpenMOQ-capable endpoint |
| 83 | + |
| 84 | +## Proposed stream mapping |
| 85 | + |
| 86 | +Initial recommendation: |
| 87 | + |
| 88 | +- one bidirectional control stream per session |
| 89 | +- one unidirectional stream per published object in the first implementation |
| 90 | + |
| 91 | +That policy is not necessarily optimal long-term, but it is easier to reason about and validate while the control-plane logic is still moving. |
| 92 | + |
| 93 | +## Interface responsibilities |
| 94 | + |
| 95 | +### `PublisherTransport` |
| 96 | + |
| 97 | +Owns: |
| 98 | + |
| 99 | +- connection establishment |
| 100 | +- stream creation |
| 101 | +- byte writes |
| 102 | +- close |
| 103 | +- connection state |
| 104 | + |
| 105 | +Does not own: |
| 106 | + |
| 107 | +- MOQT message structure |
| 108 | +- media packaging |
| 109 | +- object scheduling policy |
| 110 | + |
| 111 | +### `MoqtSession` |
| 112 | + |
| 113 | +Owns: |
| 114 | + |
| 115 | +- setup and control-plane sequencing |
| 116 | +- draft-specific control behavior |
| 117 | +- translation from `PublishPlan` to transport actions |
| 118 | + |
| 119 | +Does not own: |
| 120 | + |
| 121 | +- raw QUIC callbacks |
| 122 | +- MP4 parsing |
| 123 | +- object bytes |
| 124 | + |
| 125 | +### `PicoquicClient` |
| 126 | + |
| 127 | +Owns: |
| 128 | + |
| 129 | +- picoquic configuration and lifecycle |
| 130 | +- callback bridging |
| 131 | +- stream IDs and write execution |
| 132 | +- error translation into transport-level status objects |
| 133 | + |
| 134 | +## Suggested implementation order |
| 135 | + |
| 136 | +1. Land interface-only scaffolding |
| 137 | +2. Add endpoint and TLS config types |
| 138 | +3. Implement a connect-only picoquic client |
| 139 | +4. Add control stream bring-up |
| 140 | +5. Add init object publication |
| 141 | +6. Add full object publication from `PublishPlan` |
| 142 | +7. Add retry, backpressure, and metrics |
| 143 | + |
| 144 | +## Current repository status |
| 145 | + |
| 146 | +- The transport seam and session façade are implemented. |
| 147 | +- CLI flags for endpoint, ALPN, and TLS-related parameters are present. |
| 148 | +- The build can integrate local picoquic and picotls source checkouts directly. |
| 149 | +- The current workspace now compiles picoquic and picotls successfully. |
| 150 | +- A loopback smoke test was added for live handshake validation, but it is not enabled by default because the current handshake attempt still times out. |
| 151 | + |
| 152 | +## Key risks |
| 153 | + |
| 154 | +- draft-14 vs draft-16 control differences leaking into transport code |
| 155 | +- coupling picoquic callback state too tightly to publish scheduling |
| 156 | +- under-specifying how objects map to streams early on |
| 157 | + |
| 158 | +## Mitigations |
| 159 | + |
| 160 | +- keep draft-specific message encoding in session code |
| 161 | +- keep transport status and callbacks generic |
| 162 | +- start with a conservative one-object-per-stream policy |
| 163 | +- add integration tests before optimizing stream reuse or pacing |
0 commit comments