Skip to content

Commit

Permalink
Merge pull request #6 from Disciple-Media/disabled-video-last-frame
Browse files Browse the repository at this point in the history
Track state of call to enableLocalVideo from remote users
  • Loading branch information
digitallysavvy authored Nov 26, 2024
2 parents 8adbd33 + 78360c8 commit 5552fe6
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Sources/SwiftUIRtc/AgoraManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ open class AgoraManager: NSObject, ObservableObject, AgoraRtcEngineDelegate {

/// 🧍‍♂️ The set of all users in the channel.
@Published public var allUsers: Set<UInt> = []

/// 📹 The set of all users in the channel that have camera enabled.
@Published public var enabledVideos: Set<UInt> = []

/// 🚀 Initializes and configures the Agora RTC Engine Kit.
///
Expand Down Expand Up @@ -140,4 +143,31 @@ open class AgoraManager: NSObject, ObservableObject, AgoraRtcEngineDelegate {
open func rtcEngine(_ engine: AgoraRtcEngineKit, didOfflineOfUid uid: UInt, reason: AgoraUserOfflineReason) {
self.allUsers.remove(uid)
}

/// 📹The remote video state has change.
///
/// - Parameters:
/// - engine: The Agora RTC enging kit object.
/// - uid: The ID of the user who left the channel.
/// - state: The reason of the remote video state change: #AgoraVideoRemoteReason.
/// - reason: The reason of the remote video state change: #AgoraVideoRemoteReason.
/// - elapsed: The time elapsed (ms) from the local user calling `joinChannel` until this callback is triggered.
///
/// This method adds or removes the remote user from `enabledVideos` set.
open func rtcEngine(_ engine: AgoraRtcEngineKit,
remoteVideoStateChangedOfUid uid: UInt,
state: AgoraVideoRemoteState,
reason: AgoraVideoRemoteReason,
elapsed: Int) {
switch state {
case .starting:
enabledVideos.insert(uid)

case .stopped:
enabledVideos.remove(uid)

default:
break
}
}
}

0 comments on commit 5552fe6

Please sign in to comment.