Repository navigation
feat!: finishing an importer or the video producer returns a Finished handle - #8946
Conversation
Quest-Claim: 643c164d506d880b
… handle Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the full sweep that makes every remaining media producer's finish consume self and return a Finished handle, along with each caller.
- Codec importers: all ten
moq_mux::codecimporters'finish(self)now delegates tocontainer::Producer::finish. The five the TS importer keeps get a crate-privatefinish_in_place. A failedcutstill aborts the track with its cause throughend_with. import::Track/TrackStream: these returnimport::track::Finished, which exposesnameandabort. A failed flush of the last access unit now aborts the track inside moq-mux, so the duplicatedcause()helpers in moq-ffi and moq-c are gone.moq_video::encode::Producer:finish(self)returnsencode::Finished, which exposesdemandandabort. The splitter is released with the producer.- Callers: moq-c, moq-ffi, moq-cli, moq-gst, moq-rtsp, moq-webrtc, the bench, and the interop client keep the handle instead of the importer. moq-c's video
finalizenow forgets the child on a failed finish, asmedia_finishalready did. moq-webrtc'sBridge::finishconsumes the bridge, and that module is private, so theBox<dyn Send>alias stays internal. - Tests: there are two new
compile_faildoctests. A new test,a_failed_finish_aborts_the_track, covers the abort that moved into moq-mux.
claude-opus-5-5 | 𝕏
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed 9c3a152d89aeb85ee1702e8f2c39abd4709e9b47. No blocker found. The new handles retain the track and catalog rendition where callers linger (bindings, GStreamer, and WebRTC), without retaining the input splitter. The flush-error path now aborts at the importer, so callers no longer need the consumed producer to report the cause.
For the migration note, distinguish a caller that still serves completed media (keep the returned handle) from teardown (drop it deliberately). Also call out the old “abort after a failed finish” pattern: abort directly on a drain failure; once finish(self) is called, it owns reporting a finalize failure. Static review only; I did not rerun interop or doctests.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The only change since the prior review is a merge from origin/main. The PR's own code is unchanged.
- Merged
main: the merge brought in quest doc edits and a doc comment on an upstream test inrs/moq-mux/src/import/track.rs. It resolved cleanly against the consumingfinish(self)API.
claude-opus-5-5 | 𝕏
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The only change since the prior review is another merge from origin/main. Its conflict resolution keeps the consuming finish(self) API intact.
- Resolved the TS opus stream against typed TS errors: in
rs/moq-mux/src/container/ts/import.rs, the opus stream'sfinishnow returns main's TSResult<()>and calls this PR's crate-privatefinish_in_place. The?converts the error throughFrom<crate::Error>.cargo check -p moq-mux --testspasses on the merged head. - Updated the quest index:
quest/m2/README.mdno longer links the completedfinish-sweepquest. Thets-typed-outcomeslink was already removed upstream.
claude-opus-5-5 | 𝕏

Problem
moq-dev/moq#8395 made finishing a media producer return a
Finishedhandle, but the sweep stopped short. The tenmoq_mux::codecimporters,moq_mux::import::{Track, TrackStream}, andmoq_video::encode::Producerstill tookfinish(&mut self). Afterfinisha caller could still publish, and the bindings kept the whole importer (its splitter included) alive just to keep the track published. This finishes quest/m2/finish-sweep.md.Approach
finish(self)returns thecontainer::Finishedof the producer each one wraps:Finished<hang::Container, VideoConfig>for video,AudioConfigfor audio. All ten have the same shape, with no per-codec handle. The TS importer keeps its codec importers inside its ownts::Finished, so it ends them through a crate-privatefinish_in_place, the same pattern ascontainer::Producer::end_with.import::Track/TrackStream:finish(self)returnsimport::track::Finished, one type over the video or audio track. It exposesnameandabort.import::trackis now a public module, likeimport::container. A failed flush of the last access unit now aborts the track with its cause inside the library. moq-ffi and moq-c used to do that themselves, so theircausehelpers are gone.moq_video::encode::Producer:finish(self) -> Result<Finished, Error>. The newencode::Finishedhasdemandandabort, matching the audio producer. The splitter is released with the producer.media.rs,video.rs) and moq-c (publish.rs,video.rs) now keep theFinishedinstead of the importer. moq-cli, moq-gst, moq-rtsp, moq-webrtc, the Rust interop client, and the moq-mux bench follow. moq-webrtc's internalBridge::finishnow consumes the bridge and hands back what keeps the track served. The bindings' own API is unchanged.compile_faildoctests, onimport::track::Finishedandmoq_video::encode::Finished, check that writing after finish does not compile. The codec importers returncontainer::Finished, which already has one.finalizenow forgets the child when its finish fails, asmedia_finishalready did.Impact
moq_mux::codec::{aac, av1, flac, h264, h265, mp3, opus, vp8, vp9}::Import::finishandmoq_mux::codec::legacy::Import::finish(breaking): these now takeselfand returnResult<container::Finished<catalog::hang::Container, hang::catalog::{VideoConfig | AudioConfig}>>. To migrate, hold the returned handle for as long as the track should stay published (dropping it releases the track and its rendition), and callaborton it instead of on the importer.moq_mux::import::{Track, TrackStream}::finish(breaking): these now takeselfand returnResult<moq_mux::import::track::Finished>. Migrate the same way. A failed finish now ends the track with its cause, so callers no longer abort the importer after an error.moq_mux::import::track(new public module) holdsFinished.Track,TrackStream,AudioInit, andVideoInitare still exported atmoq_mux::import.moq_video::encode::Producer::finish(breaking): nowfinish(self) -> Result<encode::Finished, Error>. Callaborton the returnedFinishedinstead of on the producer.moq_video::encode::Finished(new).Decisions
The maintainer confirmed these decisions on 2026-11-16 (
/quest-run). A review can still undo any of them:container::Finisheddirectly, not a handle of their own. It already carriesname,demand,info,consume,estimate, andabort.import::track::Finishedis one type for bothTrackandTrackStream, with onlynameandabort. It has no publicFromimpls, so the only way to get one is from a finish.finish_in_placeon the five codec importers it holds (h264, h265, aac, opus, legacy). The alternative was restructuringts::Importto store finished handles, which would mean much more churn for no behavior change.Finishedhasdemandandabortbut no name accessor, because the videoProducerhas none.Alternatives
Finishedper codec importer, wrapping the container one. Rejected: the quest asks for one shape, and the container type already says everything.finish(&mut self)on the importers that only the TS importer calls in place. Rejected: the public API would be split between borrowing and consuming finishes.Validation
just check: every module passed except py'stest_socket.py::test_abort_and_endpoint_close_are_errors(anunroutablevsclosedrace on endpoint close). That is the flake moq-dev/moq#8900 fixes; it is unrelated to finish.just test interop --all: all 210 lanes pass. These includefinish rust -> {rust, python, go, cpp, js, js-native-node}, which drives the Rust client throughTrackStream::finishand the linger, and everyrust -> *lane, which runsmoq import avc3(the CLI'sFinishedDecoder::Avc3) through the relay.moq-muxtestimport::track::tests::a_failed_finish_aborts_the_track. I mutation-checked it: with the in-library abort removed, it fails.finished_track_releases_its_splitter,finished_track_stream_releases_its_splitter, and moq-video'sfinished_producer_releases_its_splittermeasure that a keptFinishedno longer holds splitter storage. They pass against the new handles. moq-ffi'sa_failed_finish_ends_the_track_with_its_causestill passes now that the abort lives in moq-mux.just rs test -p moq-video --features openh264,capture encode::producer: 22 passed, includingabort_after_finish(finish then abort through the handle) and the capture fixtures.just rs doctest -p moq-mux -p moq-video: passes, including both newcompile_faildoctests.Follow-ups
None.
Models
Size: M
Implementer: Claude Code, claude-opus-5-5, medium effort (arm A)
🤖 Generated with Claude Code
(Written by Claude Opus 5.5 with medium)
Review
Rewritten by
quest reviewafter each round.Head: 288e6e4
Base: origin/main at 0051c3d
Risk: high,
Consuming finish APIs change public ownership requirements and can break downstream callers, which must update their code or revert the dependency upgrade.Classified: medium by default
Reviewer: Codex, gpt-6.1-sol, high effort
Session:
01a1e8e6-f238-7a90-b7a2-cff55dfb5989, round 2Score: 9/10,
No actionable regressions were found in the incremental changes; the merged finish paths remain consistent, but builds and tests were not run as instructed.Raised the risk to high:
Consuming finish APIs change public ownership requirements and can break downstream callers, which must update their code or revert the dependency upgrade.Rounds: 3; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none