borogove

created pr with borogove/media-ufrag-look-everywhere.1 on 2026-12-01T21:54:25Z · by 9e834e0d
cmds
checkout latest patchset:
ssh pr.pico.sh pull borogove:media-ufrag-look-everywhere | git am -3
checkout specific patchset revision:
ssh pr.pico.sh pull borogove:media-ufrag-look-everywhere [rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh borogove:media-ufrag-look-everywhere
add comment to patch request:
ssh pr.pico.sh comment borogove:media-ufrag-look-everywhere "lgtm!"

Patchset borogove/media-ufrag-look-everywhere.1 on 2026-12-01T21:54:25Z · commit 1fdccd3

Find media and ufrag elsewhere if needed
Stephen Paul Weber 2026-12-01T21:53:34Z
Some clients ony set ufrag in the SDP or media by index and not id. This
allows us to still find it.
Diff stat
borogove/calls/Session.hx | 44 +++++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 5 deletions(-)
Semantic diff summary
0 added, 0 modified, 0 signature changed, 0 removed across 0 analyzed files (1 file skipped: unsupported file type)
+39 -5 borogove/calls/Session.hx #
......@@ -22,6 +22,13 @@ enum abstract CallStatus(Int) {
2222 var Failed;
2323 }
2424
25+typedef OutboundIceCandidate = {
26+ candidate: String,
27+ sdpMid: Null<String>,
28+ ?sdpMLineIndex: Null<Int>,
29+ ?usernameFragment: Null<String>
30+};
31+
2532 #if cpp
2633 @:build(HaxeCBridge.expose())
2734 @:build(HaxeSwiftBridge.expose())
......@@ -345,7 +352,7 @@ class InitiatedSession implements Session {
345352 private var pc: PeerConnection = null;
346353 private var peerDtlsSetup: String = "actpass";
347354 private final queuedInboundTransportInfo: Array<Stanza> = [];
348- private final queuedOutboundCandidate: Array<{ candidate: String, sdpMid: String, usernameFragment: String }> = [];
355+ private final queuedOutboundCandidate: Array<OutboundIceCandidate> = [];
349356 private var accepted: Bool = false;
350357 private var afterMedia: Null<()->Void> = null;
351358 private final initiator: Bool;
......@@ -563,7 +570,7 @@ class InitiatedSession implements Session {
563570 return transceiver.sender.dtmf;
564571 }
565572
566- private function sendIceCandidate(candidate: { candidate: String, sdpMid: String, usernameFragment: String }) {
573+ private function sendIceCandidate(candidate: Null<OutboundIceCandidate>) {
567574 if (candidate == null || candidate.candidate == "") { // All candidates received now
568575 if (candidatesDone != null) candidatesDone();
569576 return;
......@@ -573,8 +580,18 @@ class InitiatedSession implements Session {
573580 queuedOutboundCandidate.push(candidate);
574581 return;
575582 }
576- final media = localDescription.media.find((media) -> media.mid == candidate.sdpMid);
577- if (media == null) throw "Unknown media: " + candidate.sdpMid;
583+ final media = resolveCandidateMedia(candidate);
584+ if (media == null) return;
585+
586+ var ufrag = candidate.usernameFragment;
587+ if (ufrag == null || ufrag == "") {
588+ ufrag = media.attributes.find((attr) -> attr.key == "ice-ufrag")?.value;
589+ }
590+ if (ufrag == null || ufrag == "") {
591+ ufrag = localDescription.attributes.find((attr) -> attr.key == "ice-ufrag")?.value;
592+ }
593+ if (ufrag == null || ufrag == "") throw "No usernameFragment anywhere";
594+
578595 final transportInfo = new TransportInfo(
579596 new Media(
580597 media.mid,
......@@ -584,7 +601,7 @@ class InitiatedSession implements Session {
584601 media.protocol,
585602 [
586603 Attribute.parse(candidate.candidate),
587- new Attribute("ice-ufrag", candidate.usernameFragment),
604+ new Attribute("ice-ufrag", ufrag),
588605 media.attributes.find((attr) -> attr.key == "ice-pwd") ??
589606 localDescription.attributes.find((attr) -> attr.key == "ice-pwd")
590607 ],
......@@ -597,6 +614,23 @@ class InitiatedSession implements Session {
597614 client.sendStanza(transportInfo);
598615 }
599616
617+ private function resolveCandidateMedia(candidate: OutboundIceCandidate): Null<Media> {
618+ if (localDescription?.media == null) return null;
619+
620+ final byMid = localDescription.media.find((media) -> media.mid == candidate.sdpMid);
621+ if (byMid != null) return byMid;
622+
623+ final index = candidate.sdpMLineIndex;
624+ final media = if (index != null && index >= 0 && index < localDescription.media.length) {
625+ localDescription.media[index];
626+ } else if (localDescription.media.length == 1) {
627+ localDescription.media[0];
628+ } else {
629+ null;
630+ };
631+ return media;
632+ }
633+
600634 public function supplyMedia(streams: Array<MediaStream>): Void {
601635 setupPeerConnection(() -> {
602636 for (stream in streams) {
Back to top