Skip to content

peer_connection: public RtpTransceiver + getTransceivers/getReceivers (W3C)#42

Merged
nus merged 2 commits into
mainfrom
public-rtp-transceiver
Jun 8, 2026
Merged

peer_connection: public RtpTransceiver + getTransceivers/getReceivers (W3C)#42
nus merged 2 commits into
mainfrom
public-rtp-transceiver

Conversation

@nus

@nus nus commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Addresses the public-RtpTransceiver part of the W3C §5 gap from the RFC/W3C divergence audit.

Problem

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.

Change

  • Public RtpTransceiver (events.dart) with kind, sender, receiver, mid, direction, currentDirection, setDirection(), stopped, stop() — replaces _MediaTransceiver.
  • RtpTransceiverDirection enum (sendrecv/sendonly/recvonly/inactive/stopped) with SDP-token round-trip (sdpToken/fromToken) and a negotiated(local, remote) intersection helper; the wire layer keeps using string tokens.
  • PeerConnection: addTransceiver now returns the transceiver; getTransceivers() / getReceivers() added.
  • Negotiation records each transceiver's mid and a correctly-computed currentDirection (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)

  • currentDirection is the real negotiated intersection via RtpTransceiverDirection.negotiated, not the preferred direction.
  • stopped is derived from direction == stopped (no redundant flag); getSenders/getTransceivers/getReceivers all 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 analyze clean; 661 unit + 22 e2e pass (the media e2e exercises the migrated SDP path).

🤖 Generated with Claude Code

nus and others added 2 commits June 8, 2026 19:00
… (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>
@nus nus merged commit 5c8404a into main Jun 8, 2026
15 checks passed
@nus nus deleted the public-rtp-transceiver branch June 8, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant