Repository navigation
Add single peer connection mode via /rtc/v1 #1066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a9f4cc7
Add SignalUrlBuilder for /rtc/v1 join request URLs
changt 30a20ef
Add SinglePeerConnectionTransport for /rtc/v1 single PC mode
changt 9d1e43f
Fall back to the legacy signal path when the server has no /rtc/v1
changt 4adedf6
Add changeset for single peer connection mode
changt 06e2d8f
Return plain URLs from SignalUrlBuilder
changt b1b013c
Drop the data channel hook from DuplexTransportObserver
changt b46205a
Show how to connect with a single peer connection
changt eec8639
Test a single peer connection join end to end
changt 63fac99
Redact the join request from the connection log
changt f8bb597
Attach tracks the server binds without a track callback
changt 1ae2b47
Negotiate on every media sections requirement
changt e2ba16a
Attach bound tracks once their publication arrives
changt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "client-sdk-android": minor | ||
| --- | ||
|
|
||
| Add `ConnectOptions.singlePeerConnection`, which joins through the `/rtc/v1` signal path and publishes and receives on one peer connection instead of a publisher and a subscriber. The client makes every offer; the server's media sections requirement adds receive-only transceivers, and the answer's mid-to-track mapping resolves received tracks. A server without `/rtc/v1` answers that handshake with 404, in which case the join retries on the legacy path with dual peer connections and later reconnects stay there. The option is off by default. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
livekit-android-sdk/src/main/java/io/livekit/android/room/DuplexTransportObserver.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * Copyright 2026 LiveKit, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.livekit.android.room | ||
|
|
||
| import io.livekit.android.util.LKLog | ||
| import io.livekit.android.webrtc.peerconnection.RTCThreadToken | ||
| import io.livekit.android.webrtc.peerconnection.executeOnRTCThread | ||
| import livekit.org.webrtc.MediaStream | ||
| import livekit.org.webrtc.MediaStreamTrack | ||
| import livekit.org.webrtc.RtpReceiver | ||
| import livekit.org.webrtc.RtpTransceiver | ||
|
|
||
| internal class DuplexTransportObserver(engine: RTCEngine, client: SignalClient, rtcThreadToken: RTCThreadToken) : | ||
| PublisherTransportObserver(engine, client, rtcThreadToken) { | ||
|
|
||
| override fun onTrack(transceiver: RtpTransceiver?) { | ||
| when (transceiver?.mediaType) { | ||
| MediaStreamTrack.MediaType.MEDIA_TYPE_AUDIO -> LKLog.v { "peerconn started receiving audio" } | ||
| MediaStreamTrack.MediaType.MEDIA_TYPE_VIDEO -> LKLog.v { "peerconn started receiving video" } | ||
| else -> LKLog.d { "peerconn started receiving unknown media type: ${transceiver?.mediaType}" } | ||
| } | ||
| } | ||
|
|
||
| override fun onAddTrack(receiver: RtpReceiver?, streams: Array<out MediaStream>?) { | ||
| executeOnRTCThread(rtcThreadToken) { | ||
| if (receiver != null && streams != null) { | ||
| val track = receiver.track() ?: return@executeOnRTCThread | ||
| LKLog.v { "onAddTrack: ${track.kind()}, ${track.id()}, ${streams.fold("") { sum, it -> "$sum, $it" }}" } | ||
| engine.listener?.onAddTrack(receiver, track, streams) | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.