rtciv0.5.0

rtci-host 0.2.0, 0.1.0

From CHANGELOG.md of rtci-host at its release tag.

0.2.0

Tested with rtci 0.4 (was 0.3). A 0.x minor bump because rtci's types are in this crate's API (Peer::create_data_channel takes rtci's RTCDataChannelInit); no API of this crate is removed or changed, and JsEvent has no new variant.

Changed (rtci 0.4)

  • Built on rtci 0.4. Of its behaviour changes, these reach a connection of this crate, and are kept (each is what browsers do, or what W3C and the RFCs ask; none conflicts with what this crate promises a front end):
    • Each SSRC's packets stop carrying the MID, RtpStreamId and RepairedRtpStreamId header extensions once the peer's RTCP has reported on them (RFC 7941 4.2.3, RFC 9143 15; libwebrtc does the same, and browsers keep the SSRC they bound). A new SSRC, a changed value or a completed negotiation sends them again; RTX packets always carry them. The setting for the old form (with_sdes_header_extensions_on_every_packet) is left off: W3C promises nothing about which packets carry them. A readRtp() reader sees received packets without them after the first report.
    • The engine's pacer shares its queue among the waiting video streams by their encodings' priority (RFC 8835 4.1, the W3C priority weights) instead of releasing in the order written. This crate's FactorPacer keeps the pacer and its rate: what it counts as held (for the queue time limit's drain rate) is now kept per SSRC and removed by sequence number as each packet leaves, so interleaved streams, and padding the pacer makes, no longer skew it. The priority weights reach the engine pacer through it unchanged (an RTCP carrier).
    • RFC 8888 feedback leaves early once a stream has a report's share waiting (about 11,800 packets a second on one stream at the 50 ms interval), instead of waiting for the interval and splitting.
    • DTLS 1.2: a bad handshake message in a record that authenticates ends the association with a fatal alert (the DTLS transport, then the connection, goes failed), where three kinds were dropped silently.
    • SCTP drops a DATA chunk above the largest TSN while its advertised window is 0 (RFC 9260 6.2), rather than taking a probe into leftover space.
    • A received a=remote-candidates is parsed and ignored (RFC 9429 5.8): an answer names the pair this side's agent selected. Browsers never send it; two ICE-lite agents (ice_lite) are unchanged.
    • The other changes (FEC policy, RFC 7728 pause, H.264 / H.265 format parameters by direction, the XR blocks a peer asks for, RTX association by request) apply where the engine's defaults run them; this crate changes none of their settings.
  • removeTrack / replaceTrack(null) no longer say RTCP BYE in rtci 0.4, but only through the engine's own replace_track(None), which this crate never calls: a sender without a track is paused here (set_sender_paused) and its engine streams stay bound, as before. Nothing changes.
  • The abs-capture-time element this crate writes on a frame's first packet is left out in the last second of a month and the one after (RFC 7164 section 5), as rtci 0.4's write_rtp_with_capture_time does.
  • with_ice_failed_without_end_of_candidates(true) stays (see "End of candidates" in the README).

Added

  • A send the socket refuses for its size (EMSGSIZE, Windows's WSAEMSGSIZE) is reported to the engine with rtci 0.4's RTCPeerConnection::handle_datagram_too_big (RFC 6347 4.1.1.1, RFC 9147 4.4): on a direct path from the send itself, and through a TURN relay by tracing the refused TURN message back to the relayed datagram it carried (the last 16 relayed datagrams' first 32 octets are kept for that). A DTLS datagram is quoted, so the engine validates the report and lowers SCTP's packet size too; SRTP and STUN go unquoted. The sockets read no ICMP errors.
  • The engine's OnPathMtuExceeded is taken: the RTP write_frame cuts is sized for the path from the next frame (the smallest datagram reported, less SRTP's largest tag). It is logged, not sent to JavaScript (no W3C event).
  • write_frame sizes its RTP payloads with rtci 0.4's RTCRtpSender::max_packet_expansion (RFC 7941 4.2.2): a packet with the header extensions the engine adds stays within 1200 octets, where it could reach about 1218. A frame takes a packet more now and then. When the expansion or the path changes, the packetizer is made again on the same sequence numbers and timestamps.

Fixed

  • A gathering phase under the relay-only ICE transport policy (the first one, or the ICE restart a setConfiguration({ iceTransportPolicy: "relay" }) causes) sends to and takes from the peer only through TURN relays (W3C webrtc-pc 4.2.2). The engine, which is not told the policy, keeps the previous generation's selected pair across an ICE restart until the new one selects a pair (RFC 8445 section 9), with its consent checks; after a switch to relay that host or server-reflexive pair carried the connection on, so neither side ever failed (0.1.0 too, with rtci 0.3; WPT RTCConfiguration-iceTransportPolicy timed out). That pair now loses consent: the side that restarted, with no candidate, fails at once, and the peer as its RFC 8863 PAC timer runs out.

0.1.0

First release, tested with rtci 0.3.

Added

  • The engine host extracted from the Denext-Deno fork's ext/webrtc (branch train/denext34): Peer, Network, IceTransport, the media layer, the fake capture devices, and their tests, with no deno_core, deno_permissions, deno_net, deno_net_route, deno_error or V8 dependency.
  • NetGate, the net permission gate (replacing the fork's NetGuard): Reach / ReachKind / Host / Proto / Direction describe each question, Verdict answers it, DenyAllGate refuses everything.
  • NetIo, the socket factory (UDP, mDNS, TCP listen and connect, DNS, route probes), with PlainNetIo on the operating system's sockets and the mdns_socket helper for routed implementations.
  • Error { kind: ErrorKind, message } in place of the fork's WebRtcError.
  • JsEvent<P> / FakeFrame<P> hold received bytes as Payload (Bytes); map_payload swaps in a front end's own buffer type.
  • The serde arguments and results the front ends share (ConfigArg, IceServerArg, CandidateArg, DataChannelArg, CreatedChannel, KeygenArg, CertificateInfo, FingerprintInfo), parse_ice_servers, check_ice_servers, needs_tls.
  • Certificate helpers: generate_certificate, certificate_fingerprints, certificate_to_pem, certificate_from_pem, expires_ms, CertificateStore.
  • The engine log-level helpers: set_engine_log_level, engine_log_level, is_engine_log_target.
  • Peer methods for every media call the front ends make (add_transceiver, write_frame, set_receiver_read_rtp, ...).
  • The asynchronous permission gate. When NetGate::decide (or interfaces) returns None, the engine calls ask once per question per connection and waits for it. Until the answer is an allow, no socket is bound, no name resolved and no datagram sent. Sends to an address still being asked are dropped and counted in packetsDiscardedOnSend; binds, ICE servers and remote candidates wait. Answers are cached per connection, keyed by the Reach without its kind, and questions in flight are deduped. A timeout (NetGate::ask_timeout, default DEFAULT_ASK_TIMEOUT, 10 s), a panicking gate and a dropped request are refusals. A gate that always decides synchronously behaves as before.
  • AskGate: an asynchronous gate whose questions queue as GateRequests (the gaterequest event: {"type":"gaterequest","ticket","kind","dir","proto","host","port","resolvedFrom"}) and are answered by ticket (AskGate::answer). It refuses everything until attach() (NO_GATE_REGISTERED) and remembers answers for every connection on it.
  • GateToken, which the engine mints from an allow. Every NetIo call that creates a socket or resolves a name takes one.
  • JsEvent::OpDone (the opdone event, {"type":"opdone","op","error"?}) and Serialize for Error ({"kind": ErrorKind::name(), "message"}).
  • Network::create: Network::new for a gate that answers later.
  • ICE-TCP active dials are asked as ReachKind::TcpDial.
  • The engine asks ReachKind::IceServer for each ICE server URL before resolving it, so a front end no longer has to (check_ice_servers stays, for front ends that want a refusal to fail the constructor).
  • Proto::as_str, Direction::as_str, ReachKind::as_str.
  • rtci_webrtc.js (js/): the W3C WebRTC API over rtci-ffi for a Deno runtime without built-in WebRTC, on the Denext-Deno fork's shared W3C factories (vendored): install({ replace, prompt }) / load(), the transport over Engine (waker, drain, ref/unref, two-phase operations), the permission gate over Deno.permissions (net-connect / net-listen probed, net otherwise), and a checksum and buildId() check before and after opening the library. Data channels only; media, encoded transforms and transfer throw NotSupportedError.

Changed (breaking for code written against the first extraction)

  • Peer::set_remote_description and Peer::add_ice_candidate return Result<u32>, an operation id, in place of Result<()>. They are two-phase: Err is only an argument error (a closed connection, an oversized description, an invalid type, a malformed candidate). The outcome, including a refused candidate (NotCapable) and the engine's own errors, is the opdone event for that id. With a synchronous gate it is queued before the call returns.
  • NetIo methods take a &GateToken first: bind_udp(token, addr, opts), bind_mdns(token, hosts), bind_tcp(token, addr), connect_tcp(token, bind, to, host), resolve(token, host, port). route_probe is unchanged.
  • IceTransport::gather gathers once the gate has answered for the binds (at once with a synchronous gate). Its candidates still arrive as events.
  • With an asynchronous gate that hasn't answered at construction, a connection resolves .local candidates once the gate allows mDNS, but does not publish its own host candidates under mDNS names (it reports why in an icecandidateerror).
  • DENO_WEBRTC_LOOPBACK_ONLY=1 asks for the 127.0.0.1 bind like any other bind (it used to skip the gate).
  • JsEvent has a new variant (OpDone), so an exhaustive match on it needs an arm.

Changed (rtci 0.3)

  • Built on rtci 0.3 (was 0.2). No API of this crate changes for it.
  • ICE is failed only once no candidate is to come (rtci 0.3, W3C webrtc-pc 5.6.4): local gathering complete, which this crate signals to the engine itself, and the peer's end-of-candidates (add_ice_candidate with an empty candidate, a=end-of-candidates, or a remote description without a=ice-options:trickle). Until then a lost or never found path is disconnected. A front end must pass the application's addIceCandidate() / addIceCandidate(null) / {candidate: ""} through as an empty candidate; an application that never relays the peer's end-of-candidates sees disconnected, not failed.
  • A connection with local candidates and none from the peer is no longer failed by this crate as soon as both sides end their candidates: the engine's RFC 8863 PAC timer (39.5 s with the defaults) waits for a check from the peer, which can still form a peer-reflexive pair. With no local candidate at all it still fails at once.
  • Answers list only the formats the offer has, in the offer's order: the engine's own answer now (rtci 0.3's default), so this crate no longer rewrites it (the payload-format filter of the Denext-Deno fork's DENEXT.md item 565 is gone). Answers say a=ice-options as the offer did (trickle alone to browsers).
  • After a remote answer, a sender's getParameters().codecs lists every format of the answer this side can send, one the answer added beyond the offer included (RFC 9429 section 5.11), in the answer's order.
  • A TURN username or credential that is not an RFC 8265 OpaqueString (a control or default-ignorable code point) is refused with InvalidAccessError when the servers are parsed (IceServerSpec::parse, so the constructor and setConfiguration), as W3C webrtc-pc 4.4.1.5 asks and rtci 0.3 does for its own configuration.
  • A remote answer with an a=rtcp-fb line its offer lacked is refused (OperationError), and a received rid-id with - or _ or over 255 characters is discarded (rtci 0.3 defaults).