From bf0c72ec336b0bf9c711802e263dcffe71d90ccc Mon Sep 17 00:00:00 2001 From: EnricoSchw Date: Thu, 2 Oct 2025 11:59:53 +0200 Subject: [PATCH 1/2] fix: the first transceiver must be treated specially in old and new web api --- wasm/src/avs_pc.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wasm/src/avs_pc.ts b/wasm/src/avs_pc.ts index 7ca4096f3..f352463a8 100644 --- a/wasm/src/avs_pc.ts +++ b/wasm/src/avs_pc.ts @@ -1016,6 +1016,9 @@ function update_tracks(pc: PeerConnection, stream: MediaStream): Promise { } const videoSenderUpdates: Promise[] = [] + // We have to check old API, because in old API the transceiver with mid==1 is a receiver and in the new API it is + // a sender. We have to avoid adding tracks if transceiver is receiver. + const isOldAPI = rtc.getTransceivers().some(t => t.mid === "video"); tracks.forEach(track => { if (track.kind === 'video') { pc.sending_video = true; @@ -1027,7 +1030,7 @@ function update_tracks(pc: PeerConnection, stream: MediaStream): Promise { if (track.kind === 'video' && pc.conv_type !== CONV_TYPE_ONEONONE) { const transceivers = rtc.getTransceivers(); for (const trans of transceivers) { - if (trans.mid === 'video' || trans.mid === '1') { + if ((trans.mid === 'video' && isOldAPI) || (trans.mid === '1' && !isOldAPI)) { pc_log(LOG_LEVEL_INFO, `update_tracks: adjust`) const {params, layerFound} = getEncodingParameter(trans.sender, pc.vstate === PC_VIDEO_STATE_SCREENSHARE) From f480d1c7575c7c30e52c8e4bd54c339c03f0f9a5 Mon Sep 17 00:00:00 2001 From: EnricoSchw Date: Thu, 2 Oct 2025 12:00:44 +0200 Subject: [PATCH 2/2] fix: the first transceiver must be treated specially in old and new cpp api --- src/peerflow/peerflow.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/peerflow/peerflow.cpp b/src/peerflow/peerflow.cpp index 7c564f129..f440b4cc4 100644 --- a/src/peerflow/peerflow.cpp +++ b/src/peerflow/peerflow.cpp @@ -1686,7 +1686,10 @@ class SdpRemoteObserver return; auto trxs = pf_->peerConn->GetTransceivers(); - info("pf(%p): %d trxs\n", pf_, (int)trxs.size()); + bool is_old_api = std::any_of(trxs.begin(), trxs.end(),[](const auto& t) { return t->mid() == "video"; }); + + info("pf(%p): %d trxs, oldApi: %d\n", pf_, (int)trxs.size(), is_old_api); + for(rtc::scoped_refptr txrx: trxs) { std::string mid = txrx->mid().value_or("-"); @@ -1694,7 +1697,7 @@ class SdpRemoteObserver webrtc::RtpParameters params = sender->GetParameters(); if (txrx->media_type() != cricket::MEDIA_TYPE_VIDEO - || (mid != "video" && mid != "1")) + || (mid != "video" && (mid != "1" && !is_old_api))) continue; if (pf_->call_type == ICALL_CALL_TYPE_VIDEO ||