Skip to content

Commit

Permalink
Merge pull request #72 from AgoraIO-Community/swiftpm-multidep
Browse files Browse the repository at this point in the history
Multi Dependencies SwiftPM Fix

- Fix SwiftPM Caching Issue
  - AgoraUIKit includes both libraries, AgoraUIKitBasic doesn't have RTM
- Internally moved join success code to the callback delegate
- Fix UInt conversion issue for numbers too large
  • Loading branch information
maxxfrazer authored Apr 26, 2022
2 parents eb042c3 + 31e3f36 commit 39a6035
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 33 deletions.
2 changes: 1 addition & 1 deletion AgoraRtmControl_iOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Pod::Spec.new do |s|
s.name = 'AgoraRtmControl_iOS'
s.module_name = 'AgoraRtmControl'
s.version = ENV['LIB_VERSION'] || '1.8.1'
s.version = ENV['LIB_VERSION'] || '1.8.2'
s.summary = 'Agora Real-time Messaging Wrapper.'

s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion AgoraRtmControl_macOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Pod::Spec.new do |s|
s.name = 'AgoraRtmControl_macOS'
s.module_name = 'AgoraRtmControl'
s.version = ENV['LIB_VERSION'] || '1.8.1'
s.version = ENV['LIB_VERSION'] || '1.8.2'
s.summary = 'Agora Real-time Messaging Wrapper.'

s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion AgoraUIKit_iOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Pod::Spec.new do |s|
s.name = 'AgoraUIKit_iOS'
s.module_name = 'AgoraUIKit'
s.version = ENV['LIB_VERSION'] || '1.8.1'
s.version = ENV['LIB_VERSION'] || '1.8.2'
s.summary = 'Agora video session UIKit template.'

s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion AgoraUIKit_macOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Pod::Spec.new do |s|
s.name = 'AgoraUIKit_macOS'
s.module_name = 'AgoraUIKit'
s.version = ENV['LIB_VERSION'] || '1.8.1'
s.version = ENV['LIB_VERSION'] || '1.8.2'
s.summary = 'Agora video session AppKit template.'

s.description = <<-DESC
Expand Down
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ let package = Package(
name: "AgoraUIKit_iOS",
platforms: [.iOS(.v13)],
products: [
.library(name: "AgoraUIKit", targets: ["AgoraUIKit"]),
.library(name: "AgoraUIKit", targets: ["AgoraUIKit", "AgoraRtmControl"]),
.library(name: "AgoraUIKitBasic", targets: ["AgoraUIKit"]),
.library(name: "AgoraRtmControl", targets: ["AgoraRtmControl"])
],
dependencies: [
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<img src="https://github.com/AgoraIO-Community/iOS-UIKit/workflows/Pod%20Lint/badge.svg"/>
<img src="https://github.com/AgoraIO-Community/iOS-UIKit/workflows/swiftlint/badge.svg"/></br>
<img src="https://img.shields.io/badge/platform-iOS%20|%20macOS-lightgrey"/>
<img src="https://img.shields.io/github/v/release/AgoraIO-Community/iOS-UIKit?color=orange&label=SwiftPM&logo=swift"/>
<img src="https://img.shields.io/cocoapods/v/AgoraUIKit_iOS?label=CocoaPods"/>
<img src="https://img.shields.io/github/v/release/AgoraIO-Community/iOS-UIKit?color=orange&label=Stable%20Release&logo=swift"/>
<img src="https://img.shields.io/cocoapods/v/AgoraUIKit_iOS?label=Pre-release"/>
<a href="https://www.agora.io/en/join-slack/">
<img src="https://img.shields.io/badge/slack-@RTE%20Dev-blue.svg?logo=slack">
</a>
Expand All @@ -15,7 +15,8 @@ Instantly integrate Agora in your own application or prototype using iOS or macO
<p align="center">
<img src="https://github.com/AgoraIO-Community/iOS-UIKit/raw/main/media/agora-uikit-banner.png"/>
</p>
[More information available on this repo\'s Wiki](https://github.com/AgoraIO-Community/iOS-UIKit/wiki)

[More information available on this repo's Wiki](https://github.com/AgoraIO-Community/iOS-UIKit/wiki)

[Click here for full documentation](https://agoraio-community.github.io/iOS-UIKit/)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extension AgoraVideoViewer {
}
var iOSUInt: UInt? {
if let rtcId = rtcId {
return UInt(UInt32(bitPattern: Int32(rtcId)))
return AgoraUIKit.intToUInt(rtcId)
}
return nil
}
Expand Down Expand Up @@ -166,7 +166,7 @@ extension AgoraVideoViewer: RtmControllerDelegate {
self.sendPersonalData(to: member.userId)
}
public func personalData() -> some Codable {
let safeRtcId = Int32(self.rtcId ?? 0)
let safeRtcId = AgoraUIKit.uintToInt(self.rtcId ?? 0)
return UserData(
rtmId: self.rtmId,
rtcId: safeRtcId == 0 ? nil : Int(safeRtcId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extension AgoraVideoViewer {
self.isForceful = isForceful
}
var iOSUInt: UInt? {
return UInt(UInt32(bitPattern: Int32(rtcId)))
return AgoraUIKit.intToUInt(self.rtcId)
}
}

Expand Down Expand Up @@ -95,7 +95,7 @@ extension AgoraVideoViewer {
return
}
// This is to make sure the user ID is understood across platforms.
let safeRtcId = Int(Int32(bitPattern: UInt32(rtcId)))
let safeRtcId = AgoraUIKit.uintToInt(rtcId)
let muteReq = MuteRequest(rtcId: safeRtcId, mute: mute, device: device, isForceful: isForceful)
self.rtmController?.sendCodable(message: muteReq, user: rtcId) { sendStatus in
if sendStatus == .ok {
Expand Down
9 changes: 7 additions & 2 deletions Sources/Agora-UIKit/AgoraUIKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public struct AgoraUIKit: Codable {
/// Framework type of UIKit. "native", "flutter", "reactnative"
fileprivate(set) var framework: String
/// Version of UIKit being used
static let version = "1.8.1"
static let version = "1.8.2"
/// Framework type of UIKit. "native", "flutter", "reactnative"
static let framework = "native"
#if os(iOS)
Expand All @@ -47,5 +47,10 @@ public struct AgoraUIKit: Codable {
framework: \(framework)
"""
}

public static func uintToInt(_ uint: UInt) -> Int {
Int(Int32(bitPattern: UInt32(uint)))
}
public static func intToUInt(_ userInt: Int) -> UInt {
UInt(UInt32(bitPattern: Int32(userInt)))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import AgoraRtcKit

extension AgoraVideoViewer: AgoraRtcEngineDelegate {

/// Called when the user role successfully changes
/// - Parameters:
/// - engine: AgoraRtcEngine of this session.
Expand Down Expand Up @@ -165,6 +164,24 @@ extension AgoraVideoViewer: AgoraRtcEngineDelegate {
)
}

/**
Occurs when the local user successfully joins a specified channel.
- Parameters:
- engine: AgoraRtcEngineKit object
- channel: The channel name.
- uid: The user ID.
- elapsed: The time elapsed (ms) from the local user calling `joinChannelByToken` until this event occurs.
*/
open func rtcEngine(_ engine: AgoraRtcEngineKit, didJoinChannel channel: String, withUid uid: UInt, elapsed: Int) {
self.userID = uid
if self.userRole == .broadcaster { self.addLocalVideo() }
#if canImport(AgoraRtmControl)
self.setupRtmController(joining: channel)
#endif
self.delegate?.joinedChannel(channel: channel)
self.agoraSettings.rtcDelegate?.rtcEngine?(engine, didJoinChannel: channel, withUid: uid, elapsed: elapsed)
}

/**
Occurs when the local video stream state changes.
The SDK reports the current video state in this callback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,6 @@ extension AgoraVideoViewer {
self.agoraSettings.rtcDelegate?.rtcEngine?(engine, didApiCallExecute: error, api: api, result: result)
}

open func rtcEngine(_ engine: AgoraRtcEngineKit, didJoinChannel channel: String, withUid uid: UInt, elapsed: Int) {
self.agoraSettings.rtcDelegate?.rtcEngine?(engine, didJoinChannel: channel, withUid: uid, elapsed: elapsed)
}

open func rtcEngine(_ engine: AgoraRtcEngineKit, didRejoinChannel channel: String, withUid uid: UInt, elapsed: Int) {
self.agoraSettings.rtcDelegate?.rtcEngine?(engine, didRejoinChannel: channel, withUid: uid, elapsed: elapsed)
}
Expand Down Expand Up @@ -307,22 +303,22 @@ extension AgoraVideoViewer {
public func rtcEngine(_ engine: AgoraRtcEngineKit, didRequest info: AgoraRtcAudioFileInfo, error: AgoraAudioFileInfoError) {
self.agoraSettings.rtcDelegate?.rtcEngine?(engine, didRequest: info, error: error)
}
public func rtcEngine(_ engine: AgoraRtcEngineKit, wlAccStats currentStats: AgoraWlAccStats, averageStats: AgoraWlAccStats) {
open func rtcEngine(_ engine: AgoraRtcEngineKit, wlAccStats currentStats: AgoraWlAccStats, averageStats: AgoraWlAccStats) {
self.agoraSettings.rtcDelegate?.rtcEngine?(engine, wlAccStats: currentStats, averageStats: averageStats)
}
public func rtcEngine(_ engine: AgoraRtcEngineKit, wlAccMessage reason: AgoraWlAccReason, action: AgoraWlAccAction, wlAccMsg: String) {
open func rtcEngine(_ engine: AgoraRtcEngineKit, wlAccMessage reason: AgoraWlAccReason, action: AgoraWlAccAction, wlAccMsg: String) {
self.agoraSettings.rtcDelegate?.rtcEngine?(engine, wlAccMessage: reason, action: action, wlAccMsg: wlAccMsg)
}
public func rtcEngine(_ engine: AgoraRtcEngineKit, reportAudioDeviceTestVolume volumeType: AgoraAudioDeviceTestVolumeType, volume: Int) {
open func rtcEngine(_ engine: AgoraRtcEngineKit, reportAudioDeviceTestVolume volumeType: AgoraAudioDeviceTestVolumeType, volume: Int) {
self.agoraSettings.rtcDelegate?.rtcEngine?(engine, reportAudioDeviceTestVolume: volumeType, volume: volume)
}
public func rtcEngine(_ engine: AgoraRtcEngineKit, didClientRoleChangeFailed reason: AgoraClientRoleChangeFailedReason, currentRole: AgoraClientRole) {
open func rtcEngine(_ engine: AgoraRtcEngineKit, didClientRoleChangeFailed reason: AgoraClientRoleChangeFailedReason, currentRole: AgoraClientRole) {
self.agoraSettings.rtcDelegate?.rtcEngine?(engine, didClientRoleChangeFailed: reason, currentRole: currentRole)
}
public func rtcEngine(_ engine: AgoraRtcEngineKit, snapshotTaken channel: String, uid: UInt, filePath: String, width: Int, height: Int, errCode: Int) {
open func rtcEngine(_ engine: AgoraRtcEngineKit, snapshotTaken channel: String, uid: UInt, filePath: String, width: Int, height: Int, errCode: Int) {
self.agoraSettings.rtcDelegate?.rtcEngine?(engine, snapshotTaken: channel, uid: uid, filePath: filePath, width: width, height: height, errCode: errCode)
}
public func rtcEngine(_ engine: AgoraRtcEngineKit, didProxyConnected channel: String, withUid uid: UInt, proxyType: AgoraProxyType, localProxyIp: String, elapsed: Int) {
open func rtcEngine(_ engine: AgoraRtcEngineKit, didProxyConnected channel: String, withUid uid: UInt, proxyType: AgoraProxyType, localProxyIp: String, elapsed: Int) {
self.agoraSettings.rtcDelegate?.rtcEngine?(engine, didProxyConnected: channel, withUid: uid, proxyType: proxyType, localProxyIp: localProxyIp, elapsed: elapsed)
}
}
9 changes: 1 addition & 8 deletions Sources/Agora-UIKit/AgoraVideoViewer+VideoControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,7 @@ extension AgoraVideoViewer {
byToken: token,
channelId: channel,
info: nil, uid: self.userID
) { [weak self] _, uid, _ in
self?.userID = uid
if self?.userRole == .broadcaster { self?.addLocalVideo() }
self?.delegate?.joinedChannel(channel: channel)
#if canImport(AgoraRtmControl)
self?.setupRtmController(joining: channel)
#endif
}
)
}

#if canImport(AgoraRtmControl)
Expand Down

0 comments on commit 39a6035

Please sign in to comment.