peer_connection: public RtpTransceiver + getTransceivers/getReceivers (W3C)#42
Merged
Conversation
… (W3C) The transceiver was a private `_MediaTransceiver` with a stringly-typed direction, no mid/currentDirection/receiver, no stop, and addTransceiver returned void — so callers couldn't enumerate transceivers/receivers or inspect the negotiated media topology. - New public `RtpTransceiver` (in events.dart) with `kind`, `sender`, `receiver`, `mid`, `direction`, `currentDirection`, `setDirection()`, `stopped`, `stop()`; replaces `_MediaTransceiver`. - New `RtpTransceiverDirection` enum (sendrecv/sendonly/recvonly/inactive/ stopped) with SDP-token round-trip; the wire layer keeps using string tokens via `sdpToken` / `fromToken`. - `PeerConnection`: `addTransceiver` now returns the transceiver; `getTransceivers()` / `getReceivers()` added. - Negotiation records `mid` + `currentDirection` on each transceiver (one pass over the remote m-lines, covering recv-only too), and an arriving receiver is linked to its matching transceiver. Tests: unit coverage of the surface (direction enum round-trip, sender presence per direction, addTrack, setDirection, stop semantics, unmodifiable getters), plus negotiation assertions (mid + currentDirection + receiver linkage) on the existing media loopback. analyze clean; 660 unit + 22 e2e pass (the media e2e exercises the migrated SDP path). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The media-receiver helper offers recvonly audio/video and Chrome answers sendonly — the exact asymmetric case that exercises currentDirection. After processing Chrome's answer, assert every transceiver carries a negotiated mid and currentDirection=recvonly (negotiated(recvonly, sendonly)), failing the helper (exit 2) otherwise. Runs in Scenario 2 (audio + audio/video). Confirmed against Chrome: "audio mid=0 recvonly" and "audio mid=0 recvonly, video mid=1 recvonly" — validates PR #42's negotiated() against real SDP, which the loopback test (symmetric sendrecv) can't. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the public-RtpTransceiver part of the W3C §5 gap from the RFC/W3C divergence audit.
Problem
The transceiver was a private
_MediaTransceiverwith a stringly-typed direction, nomid/currentDirection/receiver, nostop(), andaddTransceiverreturnedvoid— so callers couldn't enumerate transceivers/receivers or inspect the negotiated media topology.Change
RtpTransceiver(events.dart) withkind,sender,receiver,mid,direction,currentDirection,setDirection(),stopped,stop()— replaces_MediaTransceiver.RtpTransceiverDirectionenum (sendrecv/sendonly/recvonly/inactive/stopped) with SDP-token round-trip (sdpToken/fromToken) and anegotiated(local, remote)intersection helper; the wire layer keeps using string tokens.PeerConnection:addTransceivernow returns the transceiver;getTransceivers()/getReceivers()added.midand a correctly-computedcurrentDirection(the local/remote direction intersection — right for asymmetric cases, not just the preferred direction), in one pass over the remote m-lines (recv-only included). An arriving receiver is linked to its matching transceiver.Notes (from /simplify)
currentDirectionis the real negotiated intersection viaRtpTransceiverDirection.negotiated, not the preferred direction.stoppedis derived fromdirection == stopped(no redundant flag);getSenders/getTransceivers/getReceiversall return unmodifiable views.Tests
Unit coverage of the surface (transceiver_test.dart): direction enum round-trip +
negotiated()intersection cases, sender presence per direction, addTrack, setDirection, stop semantics, unmodifiable getters. Plus negotiation assertions (mid + currentDirection + receiver linkage) on the existing media loopback.dart analyzeclean; 661 unit + 22 e2e pass (the media e2e exercises the migrated SDP path).🤖 Generated with Claude Code