Skip to content

Commit

Permalink
consistent bool property naming
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroshihorie committed Dec 18, 2023
1 parent 81a5ff4 commit 30cf935
Show file tree
Hide file tree
Showing 18 changed files with 88 additions and 88 deletions.
2 changes: 1 addition & 1 deletion Sources/LiveKit/Core/Engine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ extension Engine {
let autoSubscribe = _state.connectOptions.autoSubscribe
let trackSids = room._state.remoteParticipants.values.flatMap { participant in
participant._state.trackPublications.values
.filter { $0.subscribed != autoSubscribe }
.filter { $0.isSubscribed != autoSubscribe }
.map(\.sid)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Core/Room+SignalClientDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ extension Room: SignalClientDelegate {
}

func signalClient(_: SignalClient, didUpdateRemoteMute trackSid: String, muted: Bool) {
log("trackSid: \(trackSid) muted: \(muted)")
log("trackSid: \(trackSid) isMuted: \(muted)")

guard let publication = localParticipant._state.trackPublications[trackSid] as? LocalTrackPublication else {
// publication was not found but the delegate was handled
Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Core/SignalClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ extension SignalClient {
let r = Livekit_SignalRequest.with {
$0.trackSetting = Livekit_UpdateTrackSettings.with {
$0.trackSids = [sid]
$0.disabled = !settings.enabled
$0.disabled = !settings.isEnabled
$0.width = UInt32(settings.dimensions.width)
$0.height = UInt32(settings.dimensions.height)
$0.quality = settings.videoQuality.toPBType()
Expand Down
4 changes: 2 additions & 2 deletions Sources/LiveKit/Extensions/CustomStringConvertible.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Foundation

extension TrackSettings: CustomStringConvertible {
public var description: String {
"TrackSettings(enabled: \(enabled), dimensions: \(dimensions), videoQuality: \(videoQuality))"
"TrackSettings(enabled: \(isEnabled), dimensions: \(dimensions), videoQuality: \(videoQuality))"
}
}

Expand Down Expand Up @@ -50,7 +50,7 @@ extension Livekit_TrackInfo: CustomStringConvertible {
"source: \(source), " +
"width: \(width), " +
"height: \(height), " +
"muted: \(muted), " +
"isMuted: \(muted), " +
"simulcast: \(simulcast), " +
"codecs: \(codecs.map { String(describing: $0) }), " +
"layers: \(layers.map { String(describing: $0) }))"
Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Participant/LocalParticipant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ extension LocalParticipant {

for mediaTrack in mediaTracks {
// Don't re-publish muted tracks
if mediaTrack.muted { continue }
if mediaTrack.isMuted { continue }
try await publish(track: mediaTrack, publishOptions: mediaTrack.publishOptions)
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/LiveKit/Participant/Participant+Convenience.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ public extension Participant {
}

var firstCameraVideoTrack: VideoTrack? {
guard let pub = firstCameraPublication, !pub.muted, pub.subscribed,
guard let pub = firstCameraPublication, !pub.isMuted, pub.isSubscribed,
let track = pub.track else { return nil }
return track as? VideoTrack
}

var firstScreenShareVideoTrack: VideoTrack? {
guard let pub = firstScreenSharePublication, !pub.muted, pub.subscribed,
guard let pub = firstScreenSharePublication, !pub.isMuted, pub.isSubscribed,
let track = pub.track else { return nil }
return track as? VideoTrack
}

var firstAudioTrack: AudioTrack? {
guard let pub = firstAudioPublication, !pub.muted,
guard let pub = firstAudioPublication, !pub.isMuted,
let track = pub.track else { return nil }
return track as? AudioTrack
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/LiveKit/Participant/Participant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ public class Participant: NSObject, ObservableObject, Loggable {

public extension Participant {
func isCameraEnabled() -> Bool {
!(getTrackPublication(source: .camera)?.muted ?? true)
!(getTrackPublication(source: .camera)?.isMuted ?? true)
}

func isMicrophoneEnabled() -> Bool {
!(getTrackPublication(source: .microphone)?.muted ?? true)
!(getTrackPublication(source: .microphone)?.isMuted ?? true)
}

func isScreenShareEnabled() -> Bool {
!(getTrackPublication(source: .screenShareVideo)?.muted ?? true)
!(getTrackPublication(source: .screenShareVideo)?.isMuted ?? true)
}

internal func getTrackPublication(name: String) -> TrackPublication? {
Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Protocols/ParticipantDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public protocol ParticipantDelegate: AnyObject {
@objc(participant:publication:didUpdateStreamState:) optional
func participant(_ participant: RemoteParticipant, didUpdatePublication publication: RemoteTrackPublication, streamState: StreamState)

/// ``RemoteTrackPublication/subscriptionAllowed`` has updated for the ``RemoteTrackPublication``.
/// ``RemoteTrackPublication/isSubscriptionAllowed`` has updated for the ``RemoteTrackPublication``.
@objc(participant:publication:didUpdateCanSubscribe:) optional
func participant(_ participant: RemoteParticipant, didUpdatePublication publication: RemoteTrackPublication, isSubscriptionAllowed: Bool)

Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Protocols/TrackDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public protocol TrackDelegate: AnyObject {
@objc optional
func track(_ track: VideoTrack, didDetach videoView: VideoView)

/// ``Track/muted`` has updated.
/// ``Track/isMuted`` has updated.
@objc(track:didUpdateMuted:shouldSendSignal:) optional
func track(_ track: Track, didUpdate muted: Bool, shouldSendSignal: Bool)

Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Protocols/VideoRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public protocol VideoRenderer {
/// Whether this ``VideoRenderer`` should be considered visible or not for AdaptiveStream.
/// This will be invoked on the .main thread.
@objc
var adaptiveStreamIsEnabled: Bool { get }
var isAdaptiveStreamEnabled: Bool { get }
/// The size used for AdaptiveStream computation. Return .zero if size is unknown yet.
/// This will be invoked on the .main thread.
@objc
Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/SwiftUI/SwiftUIVideoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public struct SwiftUIVideoView: NativeViewRepresentable {
videoView.layoutMode = layoutMode
videoView.mirrorMode = mirrorMode
videoView.renderMode = renderMode
videoView.debugMode = debugMode
videoView.isDebugMode = debugMode

// update
Task.detached { @MainActor in
Expand Down
16 changes: 8 additions & 8 deletions Sources/LiveKit/Track/AudioManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ public class AudioManager: Loggable {
public static func == (lhs: AudioManager.State, rhs: AudioManager.State) -> Bool {
lhs.localTracksCount == rhs.localTracksCount &&
lhs.remoteTracksCount == rhs.remoteTracksCount &&
lhs.preferSpeakerOutput == rhs.preferSpeakerOutput
lhs.isSpeakerOutputPreferred == rhs.isSpeakerOutputPreferred
}

// Keep this var within State so it's protected by UnfairLock
var customConfigureFunc: ConfigureAudioSessionFunc?

public var localTracksCount: Int = 0
public var remoteTracksCount: Int = 0
public var preferSpeakerOutput: Bool = true
public var isSpeakerOutputPreferred: Bool = true

public var trackState: TrackState {
if localTracksCount > 0, remoteTracksCount == 0 {
Expand All @@ -139,9 +139,9 @@ public class AudioManager: Loggable {

/// Set this to false if you prefer using the device's receiver instead of speaker. Defaults to true.
/// This only works when the audio output is set to the built-in speaker / receiver.
public var preferSpeakerOutput: Bool {
get { _state.preferSpeakerOutput }
set { _state.mutate { $0.preferSpeakerOutput = newValue } }
public var isSpeakerOutputPreferred: Bool {
get { _state.isSpeakerOutputPreferred }
set { _state.mutate { $0.isSpeakerOutputPreferred = newValue } }
}

// MARK: - AudioProcessingModule
Expand Down Expand Up @@ -264,7 +264,7 @@ public class AudioManager: Loggable {
// prepare config
let configuration = LKRTCAudioSessionConfiguration.webRTC()

if newState.trackState == .remoteOnly && newState.preferSpeakerOutput {
if newState.trackState == .remoteOnly && newState.isSpeakerOutputPreferred {
/* .playback */
configuration.category = AVAudioSession.Category.playback.rawValue
configuration.mode = AVAudioSession.Mode.spokenAudio.rawValue
Expand All @@ -273,12 +273,12 @@ public class AudioManager: Loggable {
]

} else if [.localOnly, .localAndRemote].contains(newState.trackState) ||
(newState.trackState == .remoteOnly && !newState.preferSpeakerOutput)
(newState.trackState == .remoteOnly && !newState.isSpeakerOutputPreferred)
{
/* .playAndRecord */
configuration.category = AVAudioSession.Category.playAndRecord.rawValue

if newState.preferSpeakerOutput {
if newState.isSpeakerOutputPreferred {
// use .videoChat if speakerOutput is preferred
configuration.mode = AVAudioSession.Mode.videoChat.rawValue
} else {
Expand Down
12 changes: 6 additions & 6 deletions Sources/LiveKit/Track/Track.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class Track: NSObject, Loggable {
public var sid: Sid? { _state.sid }

@objc
public var muted: Bool { _state.muted }
public var isMuted: Bool { _state.isMuted }

@objc
public var statistics: TrackStatistics? { _state.statistics }
Expand Down Expand Up @@ -129,7 +129,7 @@ public class Track: NSObject, Loggable {
var dimensions: Dimensions?
var videoFrame: VideoFrame?
var trackState: TrackState = .stopped
var muted: Bool = false
var isMuted: Bool = false
var statistics: TrackStatistics?
var simulcastStatistics: [VideoCodec: TrackStatistics] = [:]
var reportStatistics: Bool = false
Expand Down Expand Up @@ -271,8 +271,8 @@ public class Track: NSObject, Loggable {
notify _notify: Bool = true,
shouldSendSignal: Bool = false)
{
guard _state.muted != newValue else { return }
_state.mutate { $0.muted = newValue }
guard _state.isMuted != newValue else { return }
_state.mutate { $0.isMuted = newValue }

if newValue {
// clear video frame cache if muted
Expand Down Expand Up @@ -341,15 +341,15 @@ extension Track {
//
func _mute() async throws {
// LocalTrack only, already muted
guard self is LocalTrack, !muted else { return }
guard self is LocalTrack, !isMuted else { return }
try await disable()
try await stop()
set(muted: true, shouldSendSignal: true)
}

func _unmute() async throws {
// LocalTrack only, already un-muted
guard self is LocalTrack, muted else { return }
guard self is LocalTrack, isMuted else { return }
try await enable()
try await start()
set(muted: false, shouldSendSignal: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class LocalTrackPublication: TrackPublication {
extension LocalTrackPublication {
func suspend() async throws {
// Do nothing if already muted
guard !muted else { return }
guard !isMuted else { return }
try await mute()
_suspended = true
}
Expand Down
Loading

0 comments on commit 30cf935

Please sign in to comment.