Skip to content

Commit

Permalink
fix: MetadataReceived event parameters bug
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 committed Dec 18, 2020
1 parent dbeb8ef commit bda6ec0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion android/src/main/java/io/agora/rtc/base/Callback.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import io.agora.rtc.RtcEngine
import kotlin.math.abs

abstract class Callback {
fun code(code: Int?, runnable: ((Int) -> Any?)? = null) {
fun code(code: Int?, runnable: ((Int?) -> Any?)? = null) {
if (code == null || code < 0) {
val newCode = abs(code ?: Constants.ERR_NOT_INITIALIZED)
failure(newCode.toString(), RtcEngine.getErrorDescription(newCode))
Expand Down
4 changes: 1 addition & 3 deletions android/src/main/java/io/agora/rtc/base/MediaObserver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class MediaObserver(

override fun onMetadataReceived(buffer: ByteArray, uid: Int, timeStampMs: Long) {
emit(hashMapOf(
"buffer" to String(buffer),
"uid" to uid,
"timeStampMs" to timeStampMs
"data" to arrayListOf(String(buffer), uid, timeStampMs)
))
}
}
4 changes: 2 additions & 2 deletions ios/RCTAgora/Base/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
4 changes: 1 addition & 3 deletions ios/RCTAgora/Base/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]
])
}
}

0 comments on commit bda6ec0

Please sign in to comment.