Version 2 of the LiveKit SDKs include a small number of breaking changes, focused on:
- Streamlining APIs to reduce confusion and improve naming consistency.
- Updated APIs to accept a participant's identity instead of their SID, offering a more intuitive experience as identities are application-provided.
- Enabling the coexistence of multiple libraries dependent on libwebrtc with LiveKit native SDKs.
Breaking changes across SDKs
This section outlines changes applicable to all frontend/client SDKs.
room.participants
-> room.remoteParticipants
In v2, we've updated the participants map on the room object, with key changes to note:
- Clarification:
localParticipant
has always been excluded from this map, so the termparticipants
was previously misleading. - Map key change: Instead of using the participant's
SID
as the map key, we now use theiridentity
.
// legacy v1: in v1 participants were stored in a map with keys representing their SID. This led to unnecessary complications e.g. when trying to filter for a list of identitiesval alice = room.remoteParticipants['PA_8sMkEu4vhz4v'];// new in v2: you can now use a participant's identity (encoded in the token) to directly access it from the remoteParticipants mapval alice = room.remoteParticipants[Participant.Identity('alice')];
track
-> trackPublication
In version 1, our SDKs used the term track
ambiguously, referring to both TrackPublication
and Track
. In version 2, we've simplified this terminology: now, all API references to publications explicitly use trackPublications
. For instance,
participant.tracks
->participant.trackPublications
participant.getTrack
->participant.getTrackPublication
participant.videoTracks
->participant.videoTrackPublications
// v1val trackPublications = room.localParticipant.tracks// v2val trackPublications = room.localParticipant.trackPublications
Updated publishData API
We've streamlined the publishData
API in v2, reducing its arguments to:
- The payload (data being sent)
- A
DataPublishOptions
object for advanced features
DataPublishOptions
now allows you to:
- specify a list of recipient participants using their identities
- set a topic
- choose if the data should be delivered reliably (slower, with retries) or not (faster)
In our effort to remove server identities from user facing APIs, we've removed the need to specify participant SIDs for recipients. In v2, simply use participant identities, which are stable across reconnects.
// v1room.localParticipant.publishData(data = msg,destination = listOf(participantSid))// v2room.localParticipant.publishData(data = msg,identities = listOf(Participant.Identity(identity)))
Async room SID
In order to speed up the initial connection, the room SID may not be immediately available upon connection. It's instead received later (typically within 300ms). To handle this, getting the room SID is done asynchronously in v2.
// v1val roomSid = room.sid// v2coroutineScope {// room.getSid() is a suspend functionval roomSid = room.getSid()}
Removed VideoQuality.OFF
from VideoQuality enum
In v2 we've removed the OFF
option on the VideoQuality enum. Previously, setting OFF via the setQuality APIs had no effect and was confusing to users.
// v1import livekit.LivekitModels.VideoQuality// v2 the enum has moved to a different package, with OFF option removedimport io.livekit.android.room.track.VideoQuality
Platform specific changes
Android
Removal of previously deprecated APIs
LiveKit.connect
- Please useLiveKit.create
andRoom.connect
instead.Room.listener
- Please useRoom.events
instead.Participant.listener
- Please useParticipant.events
instead.
Renaming of org.webrtc package to livekit.org.webrtc
We've renamed our internal org.webrtc
package to livekit.org.webrtc
to prevent conflicts with other WebRTC implementations. If your code references this package, update your import as follows:
// v1import org.webrtc.*// v2import livekit.org.webrtc.*
Moved composables into a separate package
Composables, including VideoRenderer
have been moved into a separate package, components-android
. Previously the SDK depended on Jetpack Compose, causing View-based apps to depend on an unnecessary package. By moving these components to a separate package, only Compose-based apps will need to depend on it.
To migrate, add in your build.gradle
:
dependencies {implementation "io.livekit:livekit-android-compose-components:1.0.0"}
The VideoRenderer
composable has also been renamed to VideoTrackView
to maintain parity with other platforms.
Participant.Sid and Identity inline value classes
To avoid confusion between participant sid
and identity
which shared the String
type, we've added the Participant.Sid
and Participant.Identity
inline value classes. This will prevent inadvertantly using one in place of the other.
Flutter
Removal of previously deprecated APIs
LiveKitClient.connect
- Please usevar room = Room(...)
androom.connect
instead.track
inTrackMutedEvent/TrackUnmutedEvent
- Usepublication
insteadTrackStreamStateUpdatedEvent.trackPublication
- UseTrackStreamStateUpdatedEvent.publication
insteadRemotePublication.videoQuality
- UseRemotePublication.setVideoQuality(quality)
insteadRemotePublication.subscribed
- UseRemotePublication.subscribe()
orunsubscribe()
insteadRemotePublication.enabled
- UseRemotePublication.enable()
ordisable()
insteadParticipant.unpublishTrack
- UseParticipant.removePublishedTrack
instead- Removed
AudioPublishOptions.stopMicTrackOnMute
Javascript/Typescript
webAudioMix
is no longer experimental
For this release, we're removing the experimental
notion of the expWebAudioMix
room option.
When using web audio mixing, setting volume directly on the HTMLAudioElements would no longer have any effects. Instead, you can use setVolume
methods that exist on both RemoteParticipant
and RemoteAudioTrack
to control the output volume.
Removal of previously deprecated APIs
RoomConnectOptions.publishOnly
- The publishOnly mode has been deprecated even before v1.0, finally removing those bits in the codeRoomState
- UseConnectionState
insteadRoomEvent.StateChanged
- UseRoomEvent.ConnectionStateChanged
insteadTrackPublishOptions.audioBitrate
- UseTrackPublishOptions.audioPreset
insteadroom.getActiveAudioOutputDevice()
- Useroom.getActiveDevice('audiooutput')
instead
Swift
Swift concurrency support
Swift SDK v2 has migrated to Swift Concurrency(async/await) from Google Promises.
Renamed APIs
- WebRTC types such as
RTCVideoFrame
are now not exported by the SDK, use new types defined by the SDK(VideoFrame
etc) instead. LocalParticipant.publish(track:publishOptions:)
has been renamed toLocalParticipant.publish(track:options:)
.RoomDelegate
andParticipantDelegate
signatures have been renamed. Xcode compiler will fail and suggest a rename if any of the previous delegates are used.- Legacy statistics (
TrackStats
) has been repalced withTrackStatistics
.
Go
CreateRoom -> NewRoom
The CreateRoom
function has been renamed to NewRoom
to disambiguate it from the RoomService.CreateRoom
API in the server SDK.