Skip to content

Commit

Permalink
feat: support 3.0.+
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 committed Mar 26, 2021
1 parent b87cce2 commit ed3b61b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 126 deletions.
15 changes: 1 addition & 14 deletions BeanCovertor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,20 +305,7 @@ func mapToRtcEngineConfig(_ map: Dictionary<String, Any>) -> AgoraRtcEngineConfi
let config = AgoraRtcEngineConfig()
config.appId = map["appId"] as? String
if let areaCode = map["areaCode"] as? NSNumber {
config.areaCode = areaCode.uintValue
}
return config
}

func mapToEncryptionConfig(_ map: Dictionary<String, Any>) -> AgoraEncryptionConfig {
let config = AgoraEncryptionConfig()
if let encryptionMode = map["encryptionMode"] as? NSNumber {
if let encryptionMode = AgoraEncryptionMode(rawValue: encryptionMode.intValue) {
config.encryptionMode = encryptionMode
}
}
if let encryptionKey = map["encryptionKey"] as? String {
config.encryptionKey = encryptionKey
config.areaCode = areaCode.int32Value
}
return config
}
13 changes: 4 additions & 9 deletions Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ extension AgoraRtcLocalAudioStats {
return [
"numChannels": numChannels,
"sentSampleRate": sentSampleRate,
"sentBitrate": sentBitrate,
"txPacketLossRate": txPacketLossRate
"sentBitrate": sentBitrate
]
}
}
Expand Down Expand Up @@ -83,8 +82,7 @@ extension AgoraRtcRemoteAudioStats {
"receivedBitrate": receivedBitrate,
"totalFrozenTime": totalFrozenTime,
"frozenRate": frozenRate,
"totalActiveTime": totalActiveTime,
"publishDuration": publishDuration
"totalActiveTime": totalActiveTime
]
}
}
Expand All @@ -103,9 +101,7 @@ extension AgoraRtcLocalVideoStats {
"encodedFrameWidth": encodedFrameWidth,
"encodedFrameHeight": encodedFrameHeight,
"encodedFrameCount": encodedFrameCount,
"codecType": codecType.rawValue,
"txPacketLossRate": txPacketLossRate,
"captureFrameRate": captureFrameRate
"codecType": codecType.rawValue
]
}
}
Expand All @@ -124,8 +120,7 @@ extension AgoraRtcRemoteVideoStats {
"rxStreamType": rxStreamType.rawValue,
"totalFrozenTime": totalFrozenTime,
"frozenRate": frozenRate,
"totalActiveTime": totalActiveTime,
"publishDuration": publishDuration
"totalActiveTime": totalActiveTime
]
}
}
Expand Down
6 changes: 0 additions & 6 deletions RtcChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ protocol RtcChannelEncryptionInterface {
func setEncryptionSecret(_ params: NSDictionary, _ callback: Callback)

func setEncryptionMode(_ params: NSDictionary, _ callback: Callback)

func enableEncryption(_ params: NSDictionary, _ callback: Callback)
}

protocol RtcChannelInjectStreamInterface {
Expand Down Expand Up @@ -331,10 +329,6 @@ class RtcChannelManager: NSObject, RtcChannelInterface {
callback.code(self[params["channelId"] as! String]?.setEncryptionMode(encryptionMode))
}

@objc func enableEncryption(_ params: NSDictionary, _ callback: Callback) {
callback.code(self[params["channelId"] as! String]?.enableEncryption(params["enabled"] as! Bool, encryptionConfig: mapToEncryptionConfig(params["config"] as! Dictionary)))
}

@objc func addInjectStreamUrl(_ params: NSDictionary, _ callback: Callback) {
callback.code(self[params["channelId"] as! String]?.addInjectStreamUrl(params["url"] as! String, config: mapToLiveInjectStreamConfig(params["config"] as! Dictionary)))
}
Expand Down
34 changes: 2 additions & 32 deletions RtcChannelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ class RtcChannelEvents {
static let ChannelMediaRelayStateChanged = "ChannelMediaRelayStateChanged"
static let ChannelMediaRelayEvent = "ChannelMediaRelayEvent"
static let MetadataReceived = "MetadataReceived"
static let AudioPublishStateChanged = "AudioPublishStateChanged"
static let VideoPublishStateChanged = "VideoPublishStateChanged"
static let AudioSubscribeStateChanged = "AudioSubscribeStateChanged"
static let VideoSubscribeStateChanged = "VideoSubscribeStateChanged"
static let RtmpStreamingEvent = "RtmpStreamingEvent"

static func toMap() -> Dictionary<String, String> {
return [
Expand Down Expand Up @@ -78,11 +73,6 @@ class RtcChannelEvents {
"ChannelMediaRelayStateChanged": ChannelMediaRelayStateChanged,
"ChannelMediaRelayEvent": ChannelMediaRelayEvent,
"MetadataReceived": MetadataReceived,
"AudioPublishStateChanged": AudioPublishStateChanged,
"VideoPublishStateChanged": VideoPublishStateChanged,
"AudioSubscribeStateChanged": AudioSubscribeStateChanged,
"VideoSubscribeStateChanged": VideoSubscribeStateChanged,
"RtmpStreamingEvent": RtmpStreamingEvent,
]
}
}
Expand Down Expand Up @@ -114,11 +104,11 @@ extension RtcChannelEventHandler: AgoraRtcChannelDelegate {
}

public func rtcChannelDidJoin(_ rtcChannel: AgoraRtcChannel, withUid uid: UInt, elapsed: Int) {
callback(RtcChannelEvents.JoinChannelSuccess, rtcChannel, rtcChannel.getId(), uid, elapsed)
callback(RtcChannelEvents.JoinChannelSuccess, rtcChannel, uid, elapsed)
}

public func rtcChannelDidRejoin(_ rtcChannel: AgoraRtcChannel, withUid uid: UInt, elapsed: Int) {
callback(RtcChannelEvents.RejoinChannelSuccess, rtcChannel, rtcChannel.getId(), uid, elapsed)
callback(RtcChannelEvents.RejoinChannelSuccess, rtcChannel, uid, elapsed)
}

public func rtcChannelDidLeave(_ rtcChannel: AgoraRtcChannel, with stats: AgoraChannelStats) {
Expand Down Expand Up @@ -220,24 +210,4 @@ extension RtcChannelEventHandler: AgoraRtcChannelDelegate {
public func rtcChannel(_ rtcChannel: AgoraRtcChannel, didReceive event: AgoraChannelMediaRelayEvent) {
callback(RtcChannelEvents.ChannelMediaRelayEvent, rtcChannel, event.rawValue)
}

func rtcChannel(_ rtcChannel: AgoraRtcChannel, didAudioPublishStateChange oldState: AgoraStreamPublishState, newState: AgoraStreamPublishState, elapseSinceLastState: Int) {
callback(RtcChannelEvents.AudioPublishStateChanged, rtcChannel, rtcChannel.getId(), oldState.rawValue, newState.rawValue, elapseSinceLastState)
}

func rtcChannel(_ rtcChannel: AgoraRtcChannel, didVideoPublishStateChange oldState: AgoraStreamPublishState, newState: AgoraStreamPublishState, elapseSinceLastState: Int) {
callback(RtcChannelEvents.VideoPublishStateChanged, rtcChannel, rtcChannel.getId(), oldState.rawValue, newState.rawValue, elapseSinceLastState)
}

func rtcChannel(_ rtcChannel: AgoraRtcChannel, didAudioSubscribeStateChange uid: UInt, oldState: AgoraStreamSubscribeState, newState: AgoraStreamSubscribeState, elapseSinceLastState: Int) {
callback(RtcChannelEvents.AudioSubscribeStateChanged, rtcChannel, rtcChannel.getId(), uid, oldState.rawValue, newState.rawValue, elapseSinceLastState)
}

func rtcChannel(_ rtcChannel: AgoraRtcChannel, didVideoSubscribeStateChange uid: UInt, oldState: AgoraStreamSubscribeState, newState: AgoraStreamSubscribeState, elapseSinceLastState: Int) {
callback(RtcChannelEvents.VideoSubscribeStateChanged, rtcChannel, rtcChannel.getId(), uid, oldState.rawValue, newState.rawValue, elapseSinceLastState)
}

func rtcChannel(_ rtcChannel: AgoraRtcChannel, rtmpStreamingEventWithUrl url: String, eventCode: AgoraRtmpStreamingEvent) {
callback(RtcChannelEvents.RtmpStreamingEvent, rtcChannel, url, eventCode.rawValue)
}
}
24 changes: 1 addition & 23 deletions RtcEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ protocol RtcEngineInterface:

func getConnectionState(_ callback: Callback)

func sendCustomReportMessage(_ params: NSDictionary, _ callback: Callback)

func getCallId(_ callback: Callback)

func rate(_ params: NSDictionary, _ callback: Callback)
Expand Down Expand Up @@ -285,8 +283,6 @@ protocol RtcEngineEncryptionInterface {
func setEncryptionSecret(_ params: NSDictionary, _ callback: Callback)

func setEncryptionMode(_ params: NSDictionary, _ callback: Callback)

func enableEncryption(_ params: NSDictionary, _ callback: Callback)
}

protocol RtcEngineAudioRecorderInterface {
Expand Down Expand Up @@ -410,10 +406,6 @@ class RtcEngineManager: NSObject, RtcEngineInterface {
}
}

@objc func sendCustomReportMessage(_ params: NSDictionary, _ callback: Callback) {
callback.code(engine?.sendCustomReportMessage(params["id"] as! String, category: params["category"] as! String, event: params["event"] as! String, label: params["label"] as! String, value: (params["value"] as! NSNumber).intValue))
}

@objc func getCallId(_ callback: Callback) {
callback.resolve(engine) {
$0.getCallId()
Expand Down Expand Up @@ -849,21 +841,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface {
}

@objc func setEncryptionMode(_ params: NSDictionary, _ callback: Callback) {
var encryptionMode = ""
switch (params["encryptionMode"] as! NSNumber).intValue {
case AgoraEncryptionMode.AES128XTS.rawValue:
encryptionMode = "aes-128-xts"
case AgoraEncryptionMode.AES128ECB.rawValue:
encryptionMode = "aes-128-ecb"
case AgoraEncryptionMode.AES256XTS.rawValue:
encryptionMode = "aes-256-xts"
default: encryptionMode = ""
}
callback.code(engine?.setEncryptionMode(encryptionMode))
}

@objc func enableEncryption(_ params: NSDictionary, _ callback: Callback) {
callback.code(engine?.enableEncryption(params["enabled"] as! Bool, encryptionConfig: mapToEncryptionConfig(params["config"] as! Dictionary)))
callback.code(engine?.setEncryptionMode(params["encryptionMode"] as? String))
}

@objc func startAudioRecording(_ params: NSDictionary, _ callback: Callback) {
Expand Down
42 changes: 0 additions & 42 deletions RtcEngineEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ class RtcEngineEvents {
static let CameraReady = "CameraReady"
static let VideoStopped = "VideoStopped"
static let MetadataReceived = "MetadataReceived"
static let FirstLocalAudioFramePublished = "FirstLocalAudioFramePublished"
static let FirstLocalVideoFramePublished = "FirstLocalVideoFramePublished"
static let AudioPublishStateChanged = "AudioPublishStateChanged"
static let VideoPublishStateChanged = "VideoPublishStateChanged"
static let AudioSubscribeStateChanged = "AudioSubscribeStateChanged"
static let VideoSubscribeStateChanged = "VideoSubscribeStateChanged"
static let RtmpStreamingEvent = "RtmpStreamingEvent"

static func toMap() -> Dictionary<String, String> {
return [
Expand Down Expand Up @@ -160,13 +153,6 @@ class RtcEngineEvents {
"CameraReady": CameraReady,
"VideoStopped": VideoStopped,
"MetadataReceived": MetadataReceived,
"FirstLocalAudioFramePublished": FirstLocalAudioFramePublished,
"FirstLocalVideoFramePublished": FirstLocalVideoFramePublished,
"AudioPublishStateChanged": AudioPublishStateChanged,
"VideoPublishStateChanged": VideoPublishStateChanged,
"AudioSubscribeStateChanged": AudioSubscribeStateChanged,
"VideoSubscribeStateChanged": VideoSubscribeStateChanged,
"RtmpStreamingEvent": RtmpStreamingEvent,
]
}
}
Expand Down Expand Up @@ -469,32 +455,4 @@ extension RtcEngineEventHandler: AgoraRtcEngineDelegate {
public func rtcEngineVideoDidStop(_ engine: AgoraRtcEngineKit) {
callback(RtcEngineEvents.VideoStopped)
}

func rtcEngine(_ engine: AgoraRtcEngineKit, firstLocalAudioFramePublished elapsed: Int) {
callback(RtcEngineEvents.FirstLocalAudioFramePublished, elapsed)
}

func rtcEngine(_ engine: AgoraRtcEngineKit, firstLocalVideoFramePublished elapsed: Int) {
callback(RtcEngineEvents.FirstLocalVideoFramePublished, elapsed)
}

func rtcEngine(_ engine: AgoraRtcEngineKit, didAudioPublishStateChange channel: String, oldState: AgoraStreamPublishState, newState: AgoraStreamPublishState, elapseSinceLastState: Int) {
callback(RtcEngineEvents.AudioPublishStateChanged, channel, oldState.rawValue, newState.rawValue, elapseSinceLastState)
}

func rtcEngine(_ engine: AgoraRtcEngineKit, didVideoPublishStateChange channel: String, oldState: AgoraStreamPublishState, newState: AgoraStreamPublishState, elapseSinceLastState: Int) {
callback(RtcEngineEvents.VideoPublishStateChanged, channel, oldState.rawValue, newState.rawValue, elapseSinceLastState)
}

func rtcEngine(_ engine: AgoraRtcEngineKit, didAudioSubscribeStateChange channel: String, withUid uid: UInt, oldState: AgoraStreamSubscribeState, newState: AgoraStreamSubscribeState, elapseSinceLastState: Int) {
callback(RtcEngineEvents.AudioSubscribeStateChanged, channel, uid, oldState.rawValue, newState.rawValue, elapseSinceLastState)
}

func rtcEngine(_ engine: AgoraRtcEngineKit, didVideoSubscribeStateChange channel: String, withUid uid: UInt, oldState: AgoraStreamSubscribeState, newState: AgoraStreamSubscribeState, elapseSinceLastState: Int) {
callback(RtcEngineEvents.VideoSubscribeStateChanged, channel, uid, oldState.rawValue, newState.rawValue, elapseSinceLastState)
}

func rtcEngine(_ engine: AgoraRtcEngineKit, rtmpStreamingEventWithUrl url: String, eventCode: AgoraRtmpStreamingEvent) {
callback(RtcEngineEvents.RtmpStreamingEvent, url, eventCode.rawValue)
}
}

0 comments on commit ed3b61b

Please sign in to comment.