diff --git a/pkg/media/validate.go b/pkg/media/validate.go index 5a404c9e3..223b86df5 100644 --- a/pkg/media/validate.go +++ b/pkg/media/validate.go @@ -174,12 +174,13 @@ func (mm *MediaManager) ValidateMP4(ctx context.Context, input io.Reader, local DeleteAfter: deleteAfter, Published: meta.Published, } - // The bytes archived above are the bare canonical .m4s, but the live - // distribution pipelines (HLS transmux, WebRTC, transcode, thumbnail) and - // the replication forwarders still consume a presentation MP4. Synthesize - // a flat MP4 over the canonical segments for the notification; the segment - // bytes (and their signatures) pass through verbatim in the mdat envelope, - // so a receiving node re-validates it unchanged. + // The bytes archived above are the bare canonical .m4s. The local + // distribution pipelines (HLS transmux, WebRTC, transcode, thumbnail) still + // consume a presentation MP4, so synthesize a flat MP4 over the canonical + // segments for the notification's Data field; the segment bytes (and their + // signatures) pass through verbatim in the mdat envelope. Replication + // forwarders instead ship the bare canonical Muxl bytes (see the iroh and + // websocket senders), which a receiving node re-validates unchanged. var playable bytes.Buffer if err := muxl.RunMuxlWrap(ctx, bytes.NewReader(buf), "flat", &playable); err != nil { return fmt.Errorf("wrap segment for distribution: %w", err) diff --git a/pkg/replication/iroh_replicator/kv.go b/pkg/replication/iroh_replicator/kv.go index 15ca1b9a0..8ef853c7a 100644 --- a/pkg/replication/iroh_replicator/kv.go +++ b/pkg/replication/iroh_replicator/kv.go @@ -445,7 +445,10 @@ func (swarm *IrohSwarm) SendSegment(ctx context.Context, not *media.NewSegmentNo go func() { spmetrics.SendSegmentCalls.Inc() defer spmetrics.SendSegmentCalls.Dec() - err = swarm.Node.SendSegment(not.Segment.RepoDID, not.Data) + // Ship the bare canonical MUXL segment (blindly concatenatable, no + // presentation header) — smaller than the flat MP4 and the canonical + // form. The receiving node re-validates it verbatim via ValidateMP4. + err = swarm.Node.SendSegment(not.Segment.RepoDID, not.Muxl) if err != nil { log.Error(ctx, "could not send segment to swarm", "error", err) } diff --git a/pkg/spxrpc/place_stream_live.go b/pkg/spxrpc/place_stream_live.go index 8c703052a..27f50b49a 100644 --- a/pkg/spxrpc/place_stream_live.go +++ b/pkg/spxrpc/place_stream_live.go @@ -239,7 +239,9 @@ func (s *Server) handlePlaceStreamLiveSubscribeSegments(c echo.Context) error { continue } log.Debug(ctx, "got segment", "file", file.Filepath) - err := ws.WriteMessage(websocket.BinaryMessage, file.Data) + // Ship the bare canonical MUXL segment; the receiver + // re-validates it via ValidateMP4 (which accepts bare .m4s). + err := ws.WriteMessage(websocket.BinaryMessage, file.Muxl) if err != nil { log.Error(ctx, "could not write message", "error", err) cancel()