Skip to content

Commit

Permalink
fix: expose missing ObjC methods on RemoteTrackPublication
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroshihorie committed Jan 12, 2024
1 parent 38b7527 commit 8e1043d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Sources/LiveKit/Core/SignalClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ extension SignalClient {

func sendUpdateSubscription(participantSid: Sid,
trackSid: String,
subscribed: Bool) async throws
isSubscribed: Bool) async throws
{
let p = Livekit_ParticipantTracks.with {
$0.participantSid = participantSid
Expand All @@ -482,7 +482,7 @@ extension SignalClient {
$0.subscription = Livekit_UpdateSubscription.with {
$0.trackSids = [trackSid] // Deprecated
$0.participantTracks = [p]
$0.subscribe = subscribed
$0.subscribe = isSubscribed
}
}

Expand Down
12 changes: 11 additions & 1 deletion Sources/LiveKit/TrackPublications/RemoteTrackPublication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ public enum SubscriptionState: Int, Codable {

@objc
public class RemoteTrackPublication: TrackPublication {
// MARK: - Public

@objc
public var isSubscriptionAllowed: Bool { _state.isSubscriptionAllowed }

@objc
public var isEnabled: Bool { _state.trackSettings.isEnabled }

override public var isMuted: Bool { track?.isMuted ?? _state.isMetadataMuted }

// MARK: - Private
Expand Down Expand Up @@ -64,12 +70,14 @@ public class RemoteTrackPublication: TrackPublication {
return _state.isSubscribePreferred != false && super.isSubscribed
}

@objc
public var subscriptionState: SubscriptionState {
if !isSubscriptionAllowed { return .notAllowed }
return isSubscribed ? .subscribed : .unsubscribed
}

/// Subscribe or unsubscribe from this track.
@objc
public func set(subscribed newValue: Bool) async throws {
guard _state.isSubscribePreferred != newValue else { return }

Expand All @@ -79,12 +87,13 @@ public class RemoteTrackPublication: TrackPublication {

try await participant.room.engine.signalClient.sendUpdateSubscription(participantSid: participant.sid,
trackSid: sid,
subscribed: newValue)
isSubscribed: newValue)
}

/// Enable or disable server from sending down data for this track.
///
/// This is useful when the participant is off screen, you may disable streaming down their video to reduce bandwidth requirements.
@objc
public func set(enabled newValue: Bool) async throws {
// No-op if already the desired value
let trackSettings = _state.trackSettings
Expand All @@ -98,6 +107,7 @@ public class RemoteTrackPublication: TrackPublication {
}

/// Set preferred video FPS for this track.
@objc
public func set(preferredFPS newValue: UInt) async throws {
// No-op if already the desired value
let trackSettings = _state.trackSettings
Expand Down
4 changes: 1 addition & 3 deletions Sources/LiveKit/TrackPublications/TrackPublication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

import Combine
import CoreGraphics
import Foundation

@objc
Expand Down Expand Up @@ -94,7 +92,7 @@ public class TrackPublication: NSObject, ObservableObject, Loggable {
var latestInfo: Livekit_TrackInfo?
}

var _state: StateSync<State>
let _state: StateSync<State>

init(info: Livekit_TrackInfo,
track: Track? = nil,
Expand Down

0 comments on commit 8e1043d

Please sign in to comment.