Repository navigation
Expose selected ICE candidate pair changes through Room eventsFeat/selected ice candidate pair event - #1065
Conversation
🦋 Changeset detectedLatest commit: 1d9bf55 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Devin Review found 2 potential issues.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| val address: String?, | ||
| val port: Int?, | ||
| val foundation: String?, | ||
| /** 1 for RTP, 2 for RTCP. Always 1 when rtcp-mux is in use. */ | ||
| val component: Int?, | ||
| val priority: Long?, |
There was a problem hiding this comment.
🟡 Public candidate fields lack KDoc
The public IceCandidateInfo fields address, port, foundation, component, and priority lack required KDoc. Several SelectedIceCandidatePair fields also lack it, leaving the new API's field-level reference incomplete.
Learn more
The repository requires KDoc for every public API. IceCandidateInfo leaves address, port, foundation, component, priority, relatedPort, sdpMid, and sdpMLineIndex undocumented. SelectedIceCandidatePair also lacks field-level KDoc for target, local, and remote.
Example: A consumer browsing the generated reference for IceCandidateInfo.component sees its Kotlin type but not what 1 and 2 mean.
Recommended fix: Add concise KDoc to each undocumented public property on both types, including units or nullable meanings where applicable.
Was this helpful? React with 👍 or 👎 to provide feedback.
| /** | ||
| * @suppress | ||
| */ | ||
| override fun onSelectedIceCandidatePairChanged(pair: SelectedIceCandidatePair) { | ||
| // Posted synchronously so that ordering between consecutive changes is preserved. | ||
| eventBus.tryPostEvent(RoomEvent.SelectedIceCandidatePairChanged(this, pair)) |
There was a problem hiding this comment.
🟡 Room event lacks entry-point example
The new RoomEvent.SelectedIceCandidatePairChanged API has no usage example on Room. Its example exists only in a separate guide, contrary to the entry-point documentation rule.
Learn more
The repository requires short examples for new APIs at their entry point. Room.events is where apps consume this event, but its entry-point property has no example, and the new callback only has @suppress.
Example: An app author browsing Room discovers events but cannot see how to filter for selected ICE candidate pair changes without finding the separate guide.
Recommended fix: Add a short KDoc snippet to the Room entry point showing collection of RoomEvent.SelectedIceCandidatePairChanged from room.events.
Was this helpful? React with 👍 or 👎 to provide feedback.
Add KDoc to SelectedIceCandidatePairChanged.pair, PeerConnectionType, and the RFC 5245 priority decomposition properties; add a guide for logging and consuming the event. Co-Authored-By: Claude Code <noreply@anthropic.com>
Add KDoc to the undocumented public properties of IceCandidateInfo (address, port, foundation, priority, relatedPort, sdpMid, sdpMLineIndex) and SelectedIceCandidatePair (target, local, remote), and merge the duplicated KDoc above typePreference. Add a usage example to Room.events showing how to collect RoomEvent.SelectedIceCandidatePairChanged, per the entry-point documentation rule. Co-Authored-By: Claude Code <noreply@anthropic.com>
76bc078 to
1d9bf55
Compare
Fixes #1033
Summary
Exposes libwebrtc's
onSelectedCandidatePairChangedcallback through the public SDK as a newRoomEvent.SelectedIceCandidatePairChangedevent, so applications can observe every ICE candidate pair switch — the initial selection, Wi-Fi↔cellular handovers,anges, and re-selections after reconnection — without pollinggetPublisherRTCStats/getSubscriberRTCStatsand diffingselectedCandidatePairIdbetween samples.As noted in the issue, both transport observlectedCandidatePairChanged` in v2.29.0 withempty bodies; this wires those callbacks through.
What's included
RoomEvent.SelectedIceCandidatePairChanged(room, pair)— emitted fromroom.eventsfor both the publisher and subscriber peer connections.SelectedIceCandidatePair— the newly selected pair:target:IceTarget.PUBLISHERor `IceT connections run independent ICE sessions andmay pick different paths)local/remote:IceCandidateInfo—RFC 5245 §15.1) parsed intotype,protocol,address,port,foundation,component,priority(plus its RFC 5245 decomposition:typePreference,localPreference,componddress/relatedPort,tcpType, remainingextension attributes,sdpMid,sdpMLineIndex,serverUrl,adapterType, and the raw SDP linereason,lastDataReceivedMs, `estimatbwebrtc's change reason and disconnectionestimateisRelayed— true when media goes throu sidesummary()/describe()— single-line and full-dump formatting for loggingtryPostEvent(synchronous), so ordering between consecutive changes is preserved. Callbacksare dispatched on the RTC thread, consistentsport observers.
nullinstead of throwing, so logging never breaks on anunexpected candidate line.
Usage
room.events .filterIsInstance<RoomEvent.SelectedIceCandidatePairChanged>() .onEach { event -> val pair = event.pair Log.i("Ice", "pair changed: ${pair.s if (pair.isRelayed) { Log.w("Ice", "media now relayed get}") } } .launchIn(lifecycleScope)Testing
SelectedIceCandidatePairTest— parses srates with/without thea=prefix, malformedcandidate lines don't throw, change-event conversion,isRelayeddetection.RoomSelectedIceCandidatePairMockE2ETestublisher and subscriber, null native eventignored, emission works after a full reconnect.MockIceCandidatestest fixtures.