Skip to content

Commit

Permalink
Merge branch 'master' into dev/3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 committed Dec 18, 2020
2 parents 561b3fd + a290e73 commit c8a08e5
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 113 deletions.
8 changes: 4 additions & 4 deletions BeanCovertor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ func mapToLiveTranscoding(_ map: Dictionary<String, Any>) -> AgoraLiveTranscodin
transcoding.transcodingExtraInfo = userConfigExtraInfo
}
if let transcodingUsers = map["transcodingUsers"] as? Array<Any> {
transcodingUsers.forEach { (item) in
if let item = item as? Dictionary<String, Any> {
transcodingUsers.forEach {
if let item = $0 as? Dictionary<String, Any> {
transcoding.add(mapToTranscodingUser(item))
}
}
Expand Down Expand Up @@ -208,8 +208,8 @@ func mapToChannelMediaRelayConfiguration(_ map: Dictionary<String, Any>) -> Agor
config.sourceInfo = mapToChannelMediaInfo(srcInfo)
}
if let destInfos = map["destInfos"] as? Array<Any> {
destInfos.forEach { (item) in
if let item = item as? Dictionary<String, Any> {
destInfos.forEach {
if let item = $0 as? Dictionary<String, Any> {
let info = mapToChannelMediaInfo(item)
config.setDestinationInfo(info, forChannelName: info.channelName ?? "")
}
Expand Down
4 changes: 2 additions & 2 deletions Callback.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ protocol Callback: class {
}

extension Callback {
func code(_ code: Int32?, _ runnable: ((Int32) -> Any?)? = nil) {
func code(_ code: Int32?, _ runnable: ((Int32?) -> Any?)? = nil) {
if code == nil || code! < 0 {
let newCode = abs(Int(code ?? Int32(AgoraErrorCode.notInitialized.rawValue)))
failure(String(newCode), AgoraRtcEngineKit.getErrorDescription(newCode) ?? "")
return
}

let res = runnable?(code!)
let res = runnable?(code)
if res is Void {
success(nil)
} else {
Expand Down
8 changes: 4 additions & 4 deletions Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ extension AgoraRtcAudioVolumeInfo {
extension Array where Element: AgoraRtcAudioVolumeInfo {
func toMapList() -> Array<Dictionary<String, Any?>> {
var list = [Dictionary<String, Any?>]()
self.forEach { (item) in
list.append(item.toMap())
self.forEach {
list.append($0.toMap())
}
return list
}
Expand Down Expand Up @@ -187,8 +187,8 @@ extension AgoraFacePositionInfo {
extension Array where Element: AgoraFacePositionInfo {
func toMapList() -> Array<Dictionary<String, Any?>> {
var list = [Dictionary<String, Any?>]()
self.forEach { (item) in
list.append(item.toMap())
self.forEach {
list.append($0.toMap())
}
return list
}
Expand Down
4 changes: 1 addition & 3 deletions MediaObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ extension MediaObserver: AgoraMediaMetadataDataSource {
extension MediaObserver: AgoraMediaMetadataDelegate {
func receiveMetadata(_ data: Data, fromUser uid: Int, atTimestamp timestamp: TimeInterval) {
emitter([
"buffer": String(data: data, encoding: .utf8),
"uid": uid,
"timeStampMs": timestamp
"data": [String(data: data, encoding: .utf8) ?? "", uid, timestamp]
])
}
}
34 changes: 17 additions & 17 deletions RtcChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ class RtcChannelManager: NSObject, RtcChannelInterface {
}

func Release() {
rtcChannelMap.forEach { key, value in
value.destroy()
rtcChannelMap.forEach {
$1.destroy()
}
rtcChannelMap.removeAll()
rtcChannelDelegateMap.removeAll()
Expand All @@ -149,10 +149,10 @@ class RtcChannelManager: NSObject, RtcChannelInterface {
}

@objc func create(_ params: NSDictionary, _ callback: Callback) {
callback.resolve(params["engine"] as? AgoraRtcEngineKit) { [weak self] it in
if let rtcChannel = it.createRtcChannel(params["channelId"] as! String) {
let delegate = RtcChannelEventHandler() { [weak self] methodName, data in
self?.emitter(methodName, data)
callback.resolve(params["engine"] as? AgoraRtcEngineKit) { [weak self] in
if let rtcChannel = $0.createRtcChannel(params["channelId"] as! String) {
let delegate = RtcChannelEventHandler() { [weak self] in
self?.emitter($0, $1)
}
rtcChannel.setRtcChannelDelegate(delegate)
self?.rtcChannelMap[rtcChannel.getId()!] = rtcChannel
Expand Down Expand Up @@ -196,8 +196,8 @@ class RtcChannelManager: NSObject, RtcChannelInterface {
}

@objc func getConnectionState(_ params: NSDictionary, _ callback: Callback) {
callback.resolve(self[params["channelId"] as! String]) { it in
it.getConnectionState().rawValue
callback.resolve(self[params["channelId"] as! String]) {
$0.getConnectionState().rawValue
}
}

Expand All @@ -210,8 +210,8 @@ class RtcChannelManager: NSObject, RtcChannelInterface {
}

@objc func getCallId(_ params: NSDictionary, _ callback: Callback) {
callback.resolve(self[params["channelId"] as! String]) { it in
it.getCallId()
callback.resolve(self[params["channelId"] as! String]) {
$0.getCallId()
}
}

Expand Down Expand Up @@ -286,8 +286,8 @@ class RtcChannelManager: NSObject, RtcChannelInterface {
@objc func registerMediaMetadataObserver(_ params: NSDictionary, _ callback: Callback) {
var code = -AgoraErrorCode.notInitialized.rawValue
if let it = self[params["channelId"] as! String] {
let mediaObserver = MediaObserver { [weak self] data in
self?.emitter(RtcEngineEvents.MetadataReceived, data)
let mediaObserver = MediaObserver { [weak self] in
self?.emitter(RtcEngineEvents.MetadataReceived, $0)
}
if it.setMediaMetadataDelegate(mediaObserver, with: .video) {
mediaObserverMap[it.getId()!] = mediaObserver
Expand All @@ -309,14 +309,14 @@ class RtcChannelManager: NSObject, RtcChannelInterface {
}

@objc func setMaxMetadataSize(_ params: NSDictionary, _ callback: Callback) {
callback.resolve(mediaObserverMap[params["channelId"] as! String]) { it in
it.setMaxMetadataSize(params["size"] as! Int)
callback.resolve(mediaObserverMap[params["channelId"] as! String]) {
$0.setMaxMetadataSize(params["size"] as! Int)
}
}

@objc func sendMetadata(_ params: NSDictionary, _ callback: Callback) {
callback.resolve(mediaObserverMap[params["channelId"] as! String]) { it in
it.addMetadata(params["metadata"] as! String)
callback.resolve(mediaObserverMap[params["channelId"] as! String]) {
$0.addMetadata(params["metadata"] as! String)
}
}

Expand Down Expand Up @@ -356,7 +356,7 @@ class RtcChannelManager: NSObject, RtcChannelInterface {
if let it = self[params["channelId"] as! String] {
code = it.createDataStream(&streamId, reliable: params["reliable"] as! Bool, ordered: params["ordered"] as! Bool)
}
callback.code(code) { it in
callback.code(code) { ignore in
streamId
}
}
Expand Down
10 changes: 5 additions & 5 deletions RtcChannelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,23 +220,23 @@ 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)
}
Expand Down
Loading

0 comments on commit c8a08e5

Please sign in to comment.