LiveKit Swift Client SDK Documentation

Class Local​Participant

@objc
public class LocalParticipant: Participant  
%107 LocalParticipant LocalParticipant Participant Participant LocalParticipant->Participant

Superclass

Participant

Properties

local​Audio​Tracks

@objc
    public var localAudioTracks: [LocalTrackPublication]  

local​Video​Tracks

@objc
    public var localVideoTracks: [LocalTrackPublication]  

Methods

set​Camera​Obj​C(enabled:​)

@objc(setCameraEnabled:)
    @discardableResult
    public func setCameraObjC(enabled: Bool) -> Promise<LocalTrackPublication?>.ObjCPromise<LocalTrackPublication>  

set​Microphone​Obj​C(enabled:​)

@objc(setMicrophoneEnabled:)
    @discardableResult
    public func setMicrophoneObjC(enabled: Bool) -> Promise<LocalTrackPublication?>.ObjCPromise<LocalTrackPublication>  

set​Screen​Share​Obj​C(enabled:​)

@objc(setScreenShareEnabled:)
    @discardableResult
    public func setScreenShareObjC(enabled: Bool) -> Promise<LocalTrackPublication?>.ObjCPromise<LocalTrackPublication>  

publish​Video​Track​Obj​C(track:​publish​Options:​)

@objc(publishVideoTrack:options:)
    @discardableResult
    public func publishVideoTrackObjC(track: LocalVideoTrack,
                                      publishOptions: VideoPublishOptions? = nil) -> Promise<LocalTrackPublication>.ObjCPromise<LocalTrackPublication>  

publish​Audio​Track​Obj​C(track:​publish​Options:​)

@objc(publishAudioTrack:options:)
    @discardableResult
    public func publishAudioTrackObjC(track: LocalAudioTrack,
                                      publishOptions: AudioPublishOptions? = nil) -> Promise<LocalTrackPublication>.ObjCPromise<LocalTrackPublication>  

unpublish​Obj​C(publication:​)

@objc(unpublishPublication:)
    @discardableResult
    public func unpublishObjC(publication: LocalTrackPublication) -> Promise<Void>.ObjCPromise<NSNull>  

publish​Data​Obj​C(data:​reliability:​destination:​)

@objc(publishData:reliability:destination:)
    @discardableResult
    public func publishDataObjC(data: Data,
                                reliability: Reliability = .reliable,
                                destination: [String] = []) -> Promise<Void>.ObjCPromise<NSNull>  

set​Track​Subscription​Permissions​Obj​C(all​Participants​Allowed:​track​Permissions:​)

@objc(setTrackSubscriptionPermissionsWithAllParticipantsAllowed:trackPermissions:)
    @discardableResult
    public func setTrackSubscriptionPermissionsObjC(allParticipantsAllowed: Bool,
                                                    trackPermissions: [ParticipantTrackPermission] = []) -> Promise<Void>.ObjCPromise<NSNull>  

publish​Audio​Track(track:​publish​Options:​)

public func publishAudioTrack(track: LocalAudioTrack,
                                  publishOptions: AudioPublishOptions? = nil) -> Promise<LocalTrackPublication>  

publish a new audio track to the Room

publish​Video​Track(track:​publish​Options:​)

public func publishVideoTrack(track: LocalVideoTrack,
                                  publishOptions: VideoPublishOptions? = nil) -> Promise<LocalTrackPublication>  

publish a new video track to the Room

unpublish​All(notify:​)

public override func unpublishAll(notify _notify: Bool = true) -> Promise<Void>  

unpublish(publication:​notify:​)

public func unpublish(publication: LocalTrackPublication, notify _notify: Bool = true) -> Promise<Void>  

unpublish an existing published track this will also stop the track

publish​Data(data:​reliability:​destination:​)

@discardableResult
    public func publishData(data: Data,
                            reliability: Reliability = .reliable,
                            destination: [String] = []) -> Promise<Void>  

publish data to the other participants in the room

Data is forwarded to each participant in the room. Each payload must not exceed 15k.

Parameters

data Data

Data to send

reliability Reliability

Toggle between sending relialble vs lossy delivery. For data that you need delivery guarantee (such as chat messages), use Reliable. For data that should arrive as quickly as possible, but you are ok with dropped packets, use Lossy.

destination [String]

SIDs of the participants who will receive the message. If empty, deliver to everyone

set​Track​Subscription​Permissions(all​Participants​Allowed:​track​Permissions:​)

@discardableResult
    public func setTrackSubscriptionPermissions(allParticipantsAllowed: Bool,
                                                trackPermissions: [ParticipantTrackPermission] = []) -> Promise<Void>  
  • Control who can subscribe to LocalParticipant's published tracks.
  • By default, all participants can subscribe. This allows fine-grained control over
  • who is able to subscribe at a participant and track level.
  • Note: if access is given at a track-level (i.e. both allParticipantsAllowed and
  • ParticipantTrackPermission/allTracksAllowed are false), any newer published tracks
  • will not grant permissions to any participants and will require a subsequent
  • permissions update to allow subscription.
    • Parameter allParticipantsAllowed Allows all participants to subscribe all tracks.
  • Takes precedence over participantTrackPermissions if set to true.
  • By default this is set to true.
    • Parameter participantTrackPermissions Full list of individual permissions per
  • participant/track. Any omitted participants will not receive any permissions.

set​Camera(enabled:​)

@discardableResult
    public func setCamera(enabled: Bool) -> Promise<LocalTrackPublication?>  

set​Microphone(enabled:​)

@discardableResult
    public func setMicrophone(enabled: Bool) -> Promise<LocalTrackPublication?>  

set​Screen​Share(enabled:​)

@discardableResult
    public func setScreenShare(enabled: Bool) -> Promise<LocalTrackPublication?>  

Enable or disable screen sharing. This has different behavior depending on the platform.

For iOS, this will use InAppScreenCapturer to capture in-app screen only due to Apple's limitation. If you would like to capture the screen when the app is in the background, you will need to create a "Broadcast Upload Extension".

For macOS, this will use MacOSScreenCapturer to capture the main screen. MacOSScreenCapturer has the ability to capture other screens and windows. See MacOSScreenCapturer for details.

For advanced usage, you can create a relevant LocalVideoTrack and call LocalParticipant/publishVideoTrack(track:publishOptions:).

set(source:​enabled:​)

public func set(source: Track.Source, enabled: Bool) -> Promise<LocalTrackPublication?>