diff --git a/android/build.gradle b/android/build.gradle index 9505d8de7..b1691be3f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -50,7 +50,7 @@ android { } dependencies { - api 'com.github.agorabuilder:native-full-sdk:3.5.1' + api 'com.github.agorabuilder:native-full-sdk:3.5.2' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${safeExtGet('kotlin_version', '1.3.72')}" } diff --git a/android/src/main/java/io/agora/rtc/base/BeanCovertor.kt b/android/src/main/java/io/agora/rtc/base/BeanCovertor.kt index 425638174..97c15edff 100644 --- a/android/src/main/java/io/agora/rtc/base/BeanCovertor.kt +++ b/android/src/main/java/io/agora/rtc/base/BeanCovertor.kt @@ -12,6 +12,7 @@ import io.agora.rtc.live.LiveTranscoding.TranscodingUser import io.agora.rtc.models.ChannelMediaOptions import io.agora.rtc.models.ClientRoleOptions import io.agora.rtc.models.DataStreamConfig +import io.agora.rtc.models.EchoTestConfiguration import io.agora.rtc.video.* fun mapToVideoDimensions(map: Map<*, *>): VideoEncoderConfiguration.VideoDimensions { @@ -264,3 +265,12 @@ fun mapToVirtualBackgroundSource(map: Map<*, *>): VirtualBackgroundSource { (map["blur_degree"] as? Int)?.let { blur_degree = it } } } + +fun mapToEchoTestConfiguration(map: Map<*, *>): EchoTestConfiguration { + return EchoTestConfiguration().apply { + (map["enableAudio"] as? Boolean)?.let { enableAudio = it } + (map["enableVideo"] as? Boolean)?.let { enableVideo = it } + (map["token"] as? String)?.let { token = it } + (map["channelId"] as? String)?.let { channelId = it } + } +} diff --git a/android/src/main/java/io/agora/rtc/base/RtcEngine.kt b/android/src/main/java/io/agora/rtc/base/RtcEngine.kt index ff731616c..43a445780 100644 --- a/android/src/main/java/io/agora/rtc/base/RtcEngine.kt +++ b/android/src/main/java/io/agora/rtc/base/RtcEngine.kt @@ -68,6 +68,8 @@ class IRtcEngine { fun setLocalAccessPoint(params: Map, callback: Callback) fun enableVirtualBackground(params: Map, callback: Callback) + + fun takeSnapshot(params: Map, callback: Callback) } interface RtcUserInfoInterface { @@ -382,7 +384,10 @@ class IRtcEngine { } open class RtcEngineFactory { - open fun create(params: Map, rtcEngineEventHandler: RtcEngineEventHandler): RtcEngine? { + open fun create( + params: Map, + rtcEngineEventHandler: RtcEngineEventHandler + ): RtcEngine? { val engine = RtcEngineEx.create(mapToRtcEngineConfig(params["config"] as Map<*, *>).apply { mContext = params["context"] as Context mEventHandler = rtcEngineEventHandler @@ -401,8 +406,10 @@ open class RtcEngineManager( private var mediaObserver: MediaObserver? = null fun release() { - RtcEngine.destroy() - engine = null + if (engine != null) { + RtcEngine.destroy() + engine = null + } mediaObserver = null } @@ -578,6 +585,16 @@ open class RtcEngineManager( ) } + override fun takeSnapshot(params: Map, callback: Callback) { + callback.code( + engine?.takeSnapshot( + params["channel"] as String, + (params["uid"] as Number).toNativeUInt(), + params["filePath"] as String + ) + ) + } + override fun registerLocalUserAccount(params: Map, callback: Callback) { callback.code( engine?.registerLocalUserAccount( @@ -1139,7 +1156,15 @@ open class RtcEngineManager( } override fun startEchoTest(params: Map, callback: Callback) { - callback.code(engine?.startEchoTest((params["intervalInSeconds"] as Number).toInt())) + (params["intervalInSeconds"] as? Number)?.let { intervalInSeconds -> + callback.code(engine?.startEchoTest(intervalInSeconds.toInt())) + return@startEchoTest + } + (params["config"] as? Map<*, *>)?.let { config -> + callback.code(engine?.startEchoTest(mapToEchoTestConfiguration(config))) + return@startEchoTest + } + callback.code(engine?.startEchoTest()) } override fun stopEchoTest(callback: Callback) { diff --git a/android/src/main/java/io/agora/rtc/base/RtcEngineEvent.kt b/android/src/main/java/io/agora/rtc/base/RtcEngineEvent.kt index d06d10b75..15ac9c19d 100644 --- a/android/src/main/java/io/agora/rtc/base/RtcEngineEvent.kt +++ b/android/src/main/java/io/agora/rtc/base/RtcEngineEvent.kt @@ -88,6 +88,7 @@ class RtcEngineEvents { const val UserSuperResolutionEnabled = "UserSuperResolutionEnabled" const val UploadLogResult = "UploadLogResult" const val VirtualBackgroundSourceEnabled = "VirtualBackgroundSourceEnabled" + const val SnapshotTaken = "SnapshotTaken" fun toMap(): Map { return hashMapOf( @@ -171,7 +172,8 @@ class RtcEngineEvents { "RtmpStreamingEvent" to RtmpStreamingEvent, "UserSuperResolutionEnabled" to UserSuperResolutionEnabled, "UploadLogResult" to UploadLogResult, - "VirtualBackgroundSourceEnabled" to VirtualBackgroundSourceEnabled + "VirtualBackgroundSourceEnabled" to VirtualBackgroundSourceEnabled, + "SnapshotTaken" to SnapshotTaken ) } } @@ -694,4 +696,23 @@ class RtcEngineEventHandler( ) { callback(RtcEngineEvents.VirtualBackgroundSourceEnabled, enabled, reason) } + + override fun onSnapshotTaken( + channel: String?, + uid: Int, + filePath: String?, + width: Int, + height: Int, + errCode: Int + ) { + callback( + RtcEngineEvents.SnapshotTaken, + channel, + uid.toUInt().toLong(), + filePath, + width, + height, + errCode + ) + } } diff --git a/android/src/main/java/io/agora/rtc/base/RtcEnginePlugin.kt b/android/src/main/java/io/agora/rtc/base/RtcEnginePlugin.kt index a688286df..0c434437a 100644 --- a/android/src/main/java/io/agora/rtc/base/RtcEnginePlugin.kt +++ b/android/src/main/java/io/agora/rtc/base/RtcEnginePlugin.kt @@ -12,8 +12,8 @@ interface RtcEnginePlugin { * This callback will be called when the [RtcEngine] is created by * [RtcEngine.createWithContext](https://docs.agora.io/cn/Video/API%20Reference/flutter/agora_rtc_engine/RtcEngine/createWithContext.html) * function from flutter. - * - * NOTE that you should not call [RtcEngine.destroy], because it will also destroy the `RtcEngine` + * + * NOTE that you should not call [RtcEngine.destroy], because it will also destroy the `RtcEngine` * used by flutter side. * * @param rtcEngine The same [RtcEngine] used by flutter side diff --git a/example/android/app/src/test/kotlin/io/agora/agora_rtc_engine_example/FakeRtcEngine.kt b/example/android/app/src/test/kotlin/io/agora/agora_rtc_engine_example/FakeRtcEngine.kt index d3cc46a13..ca93c0134 100644 --- a/example/android/app/src/test/kotlin/io/agora/agora_rtc_engine_example/FakeRtcEngine.kt +++ b/example/android/app/src/test/kotlin/io/agora/agora_rtc_engine_example/FakeRtcEngine.kt @@ -9,10 +9,7 @@ import io.agora.rtc.live.LiveInjectStreamConfig import io.agora.rtc.live.LiveTranscoding import io.agora.rtc.mediaio.IVideoSink import io.agora.rtc.mediaio.IVideoSource -import io.agora.rtc.models.ChannelMediaOptions -import io.agora.rtc.models.ClientRoleOptions -import io.agora.rtc.models.DataStreamConfig -import io.agora.rtc.models.UserInfo +import io.agora.rtc.models.* import io.agora.rtc.video.* import java.util.* import javax.microedition.khronos.egl.EGLContext @@ -30,15 +27,32 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return 0 } - override fun sendCustomReportMessage(id: String?, category: String?, event: String?, label: String?, value: Int): Int { + override fun sendCustomReportMessage( + id: String?, + category: String?, + event: String?, + label: String?, + value: Int + ): Int { return 0 } - override fun joinChannel(token: String?, channelName: String?, optionalInfo: String?, optionalUid: Int): Int { + override fun joinChannel( + token: String?, + channelName: String?, + optionalInfo: String?, + optionalUid: Int + ): Int { return 0 } - override fun joinChannel(token: String?, channelName: String?, optionalInfo: String?, optionalUid: Int, options: ChannelMediaOptions?): Int { + override fun joinChannel( + token: String?, + channelName: String?, + optionalInfo: String?, + optionalUid: Int, + options: ChannelMediaOptions? + ): Int { return 0 } @@ -46,7 +60,11 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return 0 } - override fun switchChannel(token: String?, channelName: String?, options: ChannelMediaOptions?): Int { + override fun switchChannel( + token: String?, + channelName: String?, + options: ChannelMediaOptions? + ): Int { return 0 } @@ -62,11 +80,20 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return 0 } - override fun joinChannelWithUserAccount(token: String?, channelName: String?, userAccount: String?): Int { + override fun joinChannelWithUserAccount( + token: String?, + channelName: String?, + userAccount: String? + ): Int { return 0 } - override fun joinChannelWithUserAccount(token: String?, channelName: String?, userAccount: String?, options: ChannelMediaOptions?): Int { + override fun joinChannelWithUserAccount( + token: String?, + channelName: String?, + userAccount: String?, + options: ChannelMediaOptions? + ): Int { return 0 } @@ -114,7 +141,11 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return 0 } - override fun setHighQualityAudioParameters(fullband: Boolean, stereo: Boolean, fullBitrate: Boolean): Int { + override fun setHighQualityAudioParameters( + fullband: Boolean, + stereo: Boolean, + fullBitrate: Boolean + ): Int { return 0 } @@ -238,7 +269,10 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return 0 } - override fun enableVirtualBackground(enabled: Boolean, backgroundSource: VirtualBackgroundSource?): Int { + override fun enableVirtualBackground( + enabled: Boolean, + backgroundSource: VirtualBackgroundSource? + ): Int { return 0 } @@ -318,11 +352,22 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return 0 } - override fun startAudioMixing(filePath: String?, loopback: Boolean, replace: Boolean, cycle: Int): Int { + override fun startAudioMixing( + filePath: String?, + loopback: Boolean, + replace: Boolean, + cycle: Int + ): Int { return 0 } - override fun startAudioMixing(filePath: String?, loopback: Boolean, replace: Boolean, cycle: Int, startPos: Int): Int { + override fun startAudioMixing( + filePath: String?, + loopback: Boolean, + replace: Boolean, + cycle: Int, + startPos: Int + ): Int { return 0 } @@ -422,6 +467,10 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return 0 } + override fun startEchoTest(config: EchoTestConfiguration?): Int { + return 0 + } + override fun stopEchoTest(): Int { return 0 } @@ -470,7 +519,14 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return 0 } - override fun pushExternalAudioFrame(data: ByteArray?, timestamp: Long, sampleRate: Int, channels: Int, bytesPerSample: Int, sourcePos: Int): Int { + override fun pushExternalAudioFrame( + data: ByteArray?, + timestamp: Long, + sampleRate: Int, + channels: Int, + bytesPerSample: Int, + sourcePos: Int + ): Int { return 0 } @@ -501,11 +557,21 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return 0 } - override fun setRecordingAudioFrameParameters(sampleRate: Int, channel: Int, mode: Int, samplesPerCall: Int): Int { + override fun setRecordingAudioFrameParameters( + sampleRate: Int, + channel: Int, + mode: Int, + samplesPerCall: Int + ): Int { return 0 } - override fun setPlaybackAudioFrameParameters(sampleRate: Int, channel: Int, mode: Int, samplesPerCall: Int): Int { + override fun setPlaybackAudioFrameParameters( + sampleRate: Int, + channel: Int, + mode: Int, + samplesPerCall: Int + ): Int { return 0 } @@ -754,6 +820,14 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return 0 } + override fun takeSnapshot(channel: String?, uid: Int, filePath: String?): Int { + return 0 + } + + override fun enableContentInspect(enabled: Boolean, config: ContentInspectConfig?): Int { + return 0 + } + override fun setProfile(profile: String?, merge: Boolean): Int { return 0 } @@ -778,7 +852,12 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return "" } - override fun makeQualityReportUrl(channel: String?, listenerUid: Int, speakerUid: Int, format: Int): String { + override fun makeQualityReportUrl( + channel: String?, + listenerUid: Int, + speakerUid: Int, + format: Int + ): String { return "" } @@ -790,11 +869,23 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return 0 } - override fun setTextureId(id: Int, eglContext: EGLContext?, width: Int, height: Int, ts: Long): Int { + override fun setTextureId( + id: Int, + eglContext: EGLContext?, + width: Int, + height: Int, + ts: Long + ): Int { return 0 } - override fun setTextureId(id: Int, eglContext: android.opengl.EGLContext?, width: Int, height: Int, ts: Long): Int { + override fun setTextureId( + id: Int, + eglContext: android.opengl.EGLContext?, + width: Int, + height: Int, + ts: Long + ): Int { return 0 } @@ -818,15 +909,39 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return 0 } - override fun playEffect(soundId: Int, filePath: String?, loop: Int, pitch: Double, pan: Double, gain: Double): Int { + override fun playEffect( + soundId: Int, + filePath: String?, + loop: Int, + pitch: Double, + pan: Double, + gain: Double + ): Int { return 0 } - override fun playEffect(soundId: Int, filePath: String?, loopCount: Int, pitch: Double, pan: Double, gain: Double, publish: Boolean): Int { + override fun playEffect( + soundId: Int, + filePath: String?, + loopCount: Int, + pitch: Double, + pan: Double, + gain: Double, + publish: Boolean + ): Int { return 0 } - override fun playEffect(soundId: Int, filePath: String?, loopCount: Int, pitch: Double, pan: Double, gain: Double, publish: Boolean, startPos: Int): Int { + override fun playEffect( + soundId: Int, + filePath: String?, + loopCount: Int, + pitch: Double, + pan: Double, + gain: Double, + publish: Boolean, + startPos: Int + ): Int { return 0 } @@ -874,7 +989,11 @@ class FakeRtcEngine : RtcEngineEx(), IAudioEffectManager { return 0 } - override fun startRhythmPlayer(sound1: String?, sound2: String?, config: AgoraRhythmPlayerConfig?): Int { + override fun startRhythmPlayer( + sound1: String?, + sound2: String?, + config: AgoraRhythmPlayerConfig? + ): Int { return 0 } @@ -908,11 +1027,20 @@ class FakeRtcChannel : RtcChannel() { return 0 } - override fun joinChannel(token: String?, optionalInfo: String?, optionalUid: Int, options: ChannelMediaOptions?): Int { + override fun joinChannel( + token: String?, + optionalInfo: String?, + optionalUid: Int, + options: ChannelMediaOptions? + ): Int { return 0 } - override fun joinChannelWithUserAccount(token: String?, userAccount: String?, options: ChannelMediaOptions?): Int { + override fun joinChannelWithUserAccount( + token: String?, + userAccount: String?, + options: ChannelMediaOptions? + ): Int { return 0 } diff --git a/example/android/app/src/test/kotlin/io/agora/agora_rtc_engine_example/RtcEnginePluginTest.kt b/example/android/app/src/test/kotlin/io/agora/agora_rtc_engine_example/RtcEnginePluginTest.kt index 978cba237..d0c6408b2 100644 --- a/example/android/app/src/test/kotlin/io/agora/agora_rtc_engine_example/RtcEnginePluginTest.kt +++ b/example/android/app/src/test/kotlin/io/agora/agora_rtc_engine_example/RtcEnginePluginTest.kt @@ -8,7 +8,10 @@ import org.junit.Before import org.junit.Test class FakeRtcEngineFactory(private val engine: RtcEngine) : RtcEngineFactory() { - override fun create(params: Map, rtcEngineEventHandler: RtcEngineEventHandler): RtcEngine? { + override fun create( + params: Map, + rtcEngineEventHandler: RtcEngineEventHandler + ): RtcEngine? { return engine } } @@ -21,8 +24,9 @@ class RtcEnginePluginTest { fun setUp() { rtcEngine = FakeRtcEngine() rtcChannelManager = RtcEngineManager( - emit = {_: String, _: Map? -> }, - rtcEngineFactory = FakeRtcEngineFactory(rtcEngine)) + emit = { _: String, _: Map? -> }, + rtcEngineFactory = FakeRtcEngineFactory(rtcEngine) + ) } @Test diff --git a/ios/Classes/Base/BeanCovertor.swift b/ios/Classes/Base/BeanCovertor.swift index 2578b18a4..ae6c5240f 100644 --- a/ios/Classes/Base/BeanCovertor.swift +++ b/ios/Classes/Base/BeanCovertor.swift @@ -437,3 +437,20 @@ func mapToVirtualBackgroundSource(_ map: [String: Any]) -> AgoraVirtualBackgroun } return backgroundSource } + +func mapToEchoTestConfiguration(_ map: [String: Any]) -> AgoraEchoTestConfiguration { + let config = AgoraEchoTestConfiguration() + if let enableAudio = map["enableAudio"] as? NSNumber { + config.enableAudio = enableAudio.boolValue + } + if let enableVideo = map["enableVideo"] as? NSNumber { + config.enableVideo = enableVideo.boolValue + } + if let token = map["token"] as? String { + config.token = token + } + if let channelId = map["channelId"] as? String { + config.channelId = channelId + } + return config +} diff --git a/ios/Classes/Base/RtcChannelEvent.swift b/ios/Classes/Base/RtcChannelEvent.swift index 69fa31e6f..eca5b4da8 100644 --- a/ios/Classes/Base/RtcChannelEvent.swift +++ b/ios/Classes/Base/RtcChannelEvent.swift @@ -223,27 +223,27 @@ extension RtcChannelEventHandler: AgoraRtcChannelDelegate { callback(RtcChannelEvents.ChannelMediaRelayEvent, rtcChannel, event.rawValue) } - func rtcChannel(_ rtcChannel: AgoraRtcChannel, didAudioPublishStateChange oldState: AgoraStreamPublishState, newState: AgoraStreamPublishState, elapseSinceLastState: Int) { + public 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) { + public 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) { + public 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) { + public 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) { + public func rtcChannel(_ rtcChannel: AgoraRtcChannel, rtmpStreamingEventWithUrl url: String, eventCode: AgoraRtmpStreamingEvent) { callback(RtcChannelEvents.RtmpStreamingEvent, rtcChannel, url, eventCode.rawValue) } - func rtcChannel(_ rtcChannel: AgoraRtcChannel, superResolutionEnabledOfUid uid: UInt, enabled: Bool, reason: AgoraSuperResolutionStateReason) { + public func rtcChannel(_ rtcChannel: AgoraRtcChannel, superResolutionEnabledOfUid uid: UInt, enabled: Bool, reason: AgoraSuperResolutionStateReason) { callback(RtcChannelEvents.UserSuperResolutionEnabled, rtcChannel, uid, enabled, reason.rawValue) } } diff --git a/ios/Classes/Base/RtcEngine.swift b/ios/Classes/Base/RtcEngine.swift index 4b7f379e0..514ec50b9 100644 --- a/ios/Classes/Base/RtcEngine.swift +++ b/ios/Classes/Base/RtcEngine.swift @@ -86,6 +86,8 @@ protocol RtcEngineInterface: func setLocalAccessPoint(_ params: NSDictionary, _ callback: Callback) func enableVirtualBackground(_ params: NSDictionary, _ callback: Callback) + + func takeSnapshot(_ params: NSDictionary, _ callback: Callback) } protocol RtcEngineUserInfoInterface { @@ -423,8 +425,10 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } func Release() { - AgoraRtcEngineKit.destroy() - engine = nil + if (engine != nil) { + AgoraRtcEngineKit.destroy() + engine = nil + } delegate = nil mediaObserver = nil } @@ -955,7 +959,15 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func startEchoTest(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.startEchoTest(withInterval: (params["intervalInSeconds"] as! NSNumber).intValue)) + if let intervalInSeconds = (params["intervalInSeconds"] as? NSNumber) { + callback.code(engine?.startEchoTest(withInterval: intervalInSeconds.intValue)) + return + } + if let config = (params["config"] as? [String: Any]) { + callback.code(engine?.startEchoTest(withConfig: mapToEchoTestConfiguration(config))) + return + } + callback.code(engine?.startEchoTest()) } @objc func stopEchoTest(_ callback: Callback) { @@ -1210,4 +1222,12 @@ class RtcEngineManager: NSObject, RtcEngineInterface { @objc func enableVirtualBackground(_ params: NSDictionary, _ callback: Callback) { callback.code(engine?.enableVirtualBackground(params["enabled"] as! Bool, backData: mapToVirtualBackgroundSource(params["backgroundSource"] as! [String: Any]))) } + + @objc func takeSnapshot(_ params: NSDictionary, _ callback: Callback) { + var code: Int32? + if let ret = engine?.takeSnapshot(params["channel"] as! String, uid: (params["uid"] as! NSNumber).intValue, filePath: params["filePath"] as! String) { + code = Int32(ret); + } + callback.code(code) + } } diff --git a/ios/Classes/Base/RtcEngineEvent.swift b/ios/Classes/Base/RtcEngineEvent.swift index 61a9825fb..dd4f555ed 100644 --- a/ios/Classes/Base/RtcEngineEvent.swift +++ b/ios/Classes/Base/RtcEngineEvent.swift @@ -92,6 +92,7 @@ class RtcEngineEvents { static let UploadLogResult = "UploadLogResult" static let AirPlayIsConnected = "AirPlayIsConnected" static let VirtualBackgroundSourceEnabled = "VirtualBackgroundSourceEnabled" + static let SnapshotTaken = "SnapshotTaken" static func toMap() -> [String: String] { return [ @@ -177,6 +178,7 @@ class RtcEngineEvents { "UploadLogResult": UploadLogResult, "AirPlayIsConnected": AirPlayIsConnected, "VirtualBackgroundSourceEnabled": VirtualBackgroundSourceEnabled, + "SnapshotTaken": SnapshotTaken, ] } } @@ -299,8 +301,8 @@ extension RtcEngineEventHandler: AgoraRtcEngineDelegate { public func rtcEngine(_: AgoraRtcEngineKit, localAudioStateChange state: AgoraAudioLocalState, error: AgoraAudioLocalError) { callback(RtcEngineEvents.LocalAudioStateChanged, state.rawValue, error.rawValue) } - - func rtcEngine(_ engine: AgoraRtcEngineKit, didRequest info: AgoraRtcAudioFileInfo, error: AgoraAudioFileInfoError) { + + public func rtcEngine(_ engine: AgoraRtcEngineKit, didRequest info: AgoraRtcAudioFileInfo, error: AgoraAudioFileInfoError) { callback(RtcEngineEvents.RequestAudioFileInfo, info.toMap(), error.rawValue) } @@ -324,7 +326,7 @@ extension RtcEngineEventHandler: AgoraRtcEngineDelegate { callback(RtcEngineEvents.CameraExposureAreaChanged, rect.toMap()) } - func rtcEngine(_: AgoraRtcEngineKit, facePositionDidChangeWidth width: Int32, previewHeight height: Int32, faces: [AgoraFacePositionInfo]?) { + public func rtcEngine(_: AgoraRtcEngineKit, facePositionDidChangeWidth width: Int32, previewHeight height: Int32, faces: [AgoraFacePositionInfo]?) { callback(RtcEngineEvents.FacePositionChanged, width, height, faces?.toMapList()) } @@ -364,7 +366,7 @@ extension RtcEngineEventHandler: AgoraRtcEngineDelegate { callback(RtcEngineEvents.AudioMixingFinished) } - func rtcEngine(_: AgoraRtcEngineKit, localAudioMixingStateDidChanged state: AgoraAudioMixingStateCode, reason: AgoraAudioMixingReasonCode) { + public func rtcEngine(_: AgoraRtcEngineKit, localAudioMixingStateDidChanged state: AgoraAudioMixingStateCode, reason: AgoraAudioMixingReasonCode) { callback(RtcEngineEvents.AudioMixingStateChanged, state.rawValue, reason.rawValue) } @@ -484,47 +486,51 @@ extension RtcEngineEventHandler: AgoraRtcEngineDelegate { callback(RtcEngineEvents.VideoStopped) } - func rtcEngine(_: AgoraRtcEngineKit, firstLocalAudioFramePublished elapsed: Int) { + public func rtcEngine(_: AgoraRtcEngineKit, firstLocalAudioFramePublished elapsed: Int) { callback(RtcEngineEvents.FirstLocalAudioFramePublished, elapsed) } - func rtcEngine(_: AgoraRtcEngineKit, firstLocalVideoFramePublished elapsed: Int) { + public func rtcEngine(_: AgoraRtcEngineKit, firstLocalVideoFramePublished elapsed: Int) { callback(RtcEngineEvents.FirstLocalVideoFramePublished, elapsed) } - func rtcEngine(_: AgoraRtcEngineKit, didAudioPublishStateChange channel: String, oldState: AgoraStreamPublishState, newState: AgoraStreamPublishState, elapseSinceLastState: Int) { + public func rtcEngine(_: AgoraRtcEngineKit, didAudioPublishStateChange channel: String, oldState: AgoraStreamPublishState, newState: AgoraStreamPublishState, elapseSinceLastState: Int) { callback(RtcEngineEvents.AudioPublishStateChanged, channel, oldState.rawValue, newState.rawValue, elapseSinceLastState) } - func rtcEngine(_: AgoraRtcEngineKit, didVideoPublishStateChange channel: String, oldState: AgoraStreamPublishState, newState: AgoraStreamPublishState, elapseSinceLastState: Int) { + public func rtcEngine(_: AgoraRtcEngineKit, didVideoPublishStateChange channel: String, oldState: AgoraStreamPublishState, newState: AgoraStreamPublishState, elapseSinceLastState: Int) { callback(RtcEngineEvents.VideoPublishStateChanged, channel, oldState.rawValue, newState.rawValue, elapseSinceLastState) } - func rtcEngine(_: AgoraRtcEngineKit, didAudioSubscribeStateChange channel: String, withUid uid: UInt, oldState: AgoraStreamSubscribeState, newState: AgoraStreamSubscribeState, elapseSinceLastState: Int) { + public func rtcEngine(_: 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(_: AgoraRtcEngineKit, didVideoSubscribeStateChange channel: String, withUid uid: UInt, oldState: AgoraStreamSubscribeState, newState: AgoraStreamSubscribeState, elapseSinceLastState: Int) { + public func rtcEngine(_: 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(_: AgoraRtcEngineKit, rtmpStreamingEventWithUrl url: String, eventCode: AgoraRtmpStreamingEvent) { + public func rtcEngine(_: AgoraRtcEngineKit, rtmpStreamingEventWithUrl url: String, eventCode: AgoraRtmpStreamingEvent) { callback(RtcEngineEvents.RtmpStreamingEvent, url, eventCode.rawValue) } - func rtcEngine(_: AgoraRtcEngineKit, superResolutionEnabledOfUid uid: UInt, enabled: Bool, reason: AgoraSuperResolutionStateReason) { + public func rtcEngine(_: AgoraRtcEngineKit, superResolutionEnabledOfUid uid: UInt, enabled: Bool, reason: AgoraSuperResolutionStateReason) { callback(RtcEngineEvents.UserSuperResolutionEnabled, uid, enabled, reason.rawValue) } - func rtcEngine(_: AgoraRtcEngineKit, uploadLogResultRequestId requestId: String, success: Bool, reason: AgoraUploadErrorReason) { + public func rtcEngine(_: AgoraRtcEngineKit, uploadLogResultRequestId requestId: String, success: Bool, reason: AgoraUploadErrorReason) { callback(RtcEngineEvents.UploadLogResult, requestId, success, reason.rawValue) } - func rtcEngineAirPlayIsConnected(_ engine: AgoraRtcEngineKit) { + public func rtcEngineAirPlayIsConnected(_ engine: AgoraRtcEngineKit) { callback(RtcEngineEvents.AirPlayIsConnected) } - func rtcEngine(_ engine: AgoraRtcEngineKit, virtualBackgroundSourceEnabled enabled: Bool, reason: AgoraVirtualBackgroundSourceStateReason) { + public func rtcEngine(_ engine: AgoraRtcEngineKit, virtualBackgroundSourceEnabled enabled: Bool, reason: AgoraVirtualBackgroundSourceStateReason) { callback(RtcEngineEvents.VirtualBackgroundSourceEnabled, enabled, reason.rawValue) } + + public func rtcEngine(_ engine: AgoraRtcEngineKit, snapshotTaken channel: String, uid: UInt, filePath: String, width: Int, height: Int, errCode: Int) { + callback(RtcEngineEvents.SnapshotTaken, channel, uid, filePath, width, height, errCode) + } } diff --git a/ios/agora_rtc_engine.podspec b/ios/agora_rtc_engine.podspec index 759550c1c..ab9cdab23 100644 --- a/ios/agora_rtc_engine.podspec +++ b/ios/agora_rtc_engine.podspec @@ -17,7 +17,7 @@ Pod::Spec.new do |s| s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.dependency 'Flutter' - s.dependency 'AgoraRtcEngine_iOS', '3.5.1' + s.dependency 'AgoraRtcEngine_iOS', '3.5.2' s.platform = :ios, '8.0' # Flutter.framework does not contain a i386 slice. diff --git a/lib/src/classes.dart b/lib/src/classes.dart index 5c21970fd..6387d3a99 100644 --- a/lib/src/classes.dart +++ b/lib/src/classes.dart @@ -1662,12 +1662,6 @@ class VirtualBackgroundSource { /// The information of an audio file, which is reported in [RtcEngineEventHandler.requestAudioFileInfoCallback]. @JsonSerializable(explicitToJson: true) class AudioFileInfo { - /// Construct the [AudioFileInfo] - AudioFileInfo({ - required this.filePath, - required this.durationMs, - }); - /// The file path. @JsonKey() String filePath; @@ -1676,6 +1670,12 @@ class AudioFileInfo { @JsonKey() int durationMs; + /// Construct the [AudioFileInfo] + AudioFileInfo({ + required this.filePath, + required this.durationMs, + }); + /// @nodoc factory AudioFileInfo.fromJson(Map json) => _$AudioFileInfoFromJson(json); @@ -1683,3 +1683,50 @@ class AudioFileInfo { /// @nodoc Map toJson() => _$AudioFileInfoToJson(this); } + +/// The configuration of the audio and video call loop test. +/// +/// @since v3.5.2 +@JsonSerializable(explicitToJson: true) +class EchoTestConfiguration { + /// Whether to enable the audio device for the call loop test: + /// - true: (Default) Enables the audio device. To test the audio device, set this parameter as `true`. + /// - false: Disables the audio device. + @JsonKey(includeIfNull: false) + bool? enableAudio; + + /// Whether to enable the video device for the call loop test: + /// - true: (Default) Enables the video device. To test the video device, set this parameter as `true`. + /// - false: Disables the video device. + @JsonKey(includeIfNull: false) + bool? enableVideo; + + /// The token used to secure the audio and video call loop test. If you do not enable App Certificate in Agora + /// Console, you do not need to pass a value in this parameter; if you have enabled App Certificate in Agora Console, + /// you must pass a token in this parameter, the `uid` used when you generate the token must be 0xFFFFFFFF, and the + /// channel name used must be the channel name that identifies each audio and video call loop tested. For server-side + /// token generation, see [Authenticate Your Users with Tokens](https://docs.agora.io/en/Interactive%20Broadcast/token_server?platform=All%20Platforms). + @JsonKey(includeIfNull: false) + String? token; + + /// The channel name that identifies each audio and video call loop. To ensure proper loop test functionality, the + /// channel name passed in to identify each loop test cannot be the same when users of the same project (App ID) + /// perform audio and video call loop tests on different devices. + @JsonKey(includeIfNull: false) + String? channelId; + + /// Construct the [EchoTestConfiguration] + EchoTestConfiguration({ + this.enableAudio, + this.enableVideo, + this.token, + this.channelId, + }); + + /// @nodoc + factory EchoTestConfiguration.fromJson(Map json) => + _$EchoTestConfigurationFromJson(json); + + /// @nodoc + Map toJson() => _$EchoTestConfigurationToJson(this); +} diff --git a/lib/src/classes.g.dart b/lib/src/classes.g.dart index b92d01ee0..69a6f426f 100644 --- a/lib/src/classes.g.dart +++ b/lib/src/classes.g.dart @@ -6,24 +6,21 @@ part of 'classes.dart'; // JsonSerializableGenerator // ************************************************************************** -UserInfo _$UserInfoFromJson(Map json) { - return UserInfo( - json['uid'] as int, - json['userAccount'] as String, - ); -} +UserInfo _$UserInfoFromJson(Map json) => UserInfo( + json['uid'] as int, + json['userAccount'] as String, + ); Map _$UserInfoToJson(UserInfo instance) => { 'uid': instance.uid, 'userAccount': instance.userAccount, }; -VideoDimensions _$VideoDimensionsFromJson(Map json) { - return VideoDimensions( - width: json['width'] as int?, - height: json['height'] as int?, - ); -} +VideoDimensions _$VideoDimensionsFromJson(Map json) => + VideoDimensions( + width: json['width'] as int?, + height: json['height'] as int?, + ); Map _$VideoDimensionsToJson(VideoDimensions instance) { final val = {}; @@ -40,24 +37,25 @@ Map _$VideoDimensionsToJson(VideoDimensions instance) { } VideoEncoderConfiguration _$VideoEncoderConfigurationFromJson( - Map json) { - return VideoEncoderConfiguration( - dimensions: json['dimensions'] == null - ? null - : VideoDimensions.fromJson(json['dimensions'] as Map), - frameRate: _$enumDecodeNullable(_$VideoFrameRateEnumMap, json['frameRate']), - minFrameRate: - _$enumDecodeNullable(_$VideoFrameRateEnumMap, json['minFrameRate']), - bitrate: json['bitrate'] as int?, - minBitrate: json['minBitrate'] as int?, - orientationMode: _$enumDecodeNullable( - _$VideoOutputOrientationModeEnumMap, json['orientationMode']), - degradationPrefer: _$enumDecodeNullable( - _$DegradationPreferenceEnumMap, json['degradationPrefer']), - mirrorMode: - _$enumDecodeNullable(_$VideoMirrorModeEnumMap, json['mirrorMode']), - ); -} + Map json) => + VideoEncoderConfiguration( + dimensions: json['dimensions'] == null + ? null + : VideoDimensions.fromJson( + json['dimensions'] as Map), + frameRate: + $enumDecodeNullable(_$VideoFrameRateEnumMap, json['frameRate']), + minFrameRate: + $enumDecodeNullable(_$VideoFrameRateEnumMap, json['minFrameRate']), + bitrate: json['bitrate'] as int?, + minBitrate: json['minBitrate'] as int?, + orientationMode: $enumDecodeNullable( + _$VideoOutputOrientationModeEnumMap, json['orientationMode']), + degradationPrefer: $enumDecodeNullable( + _$DegradationPreferenceEnumMap, json['degradationPrefer']), + mirrorMode: + $enumDecodeNullable(_$VideoMirrorModeEnumMap, json['mirrorMode']), + ); Map _$VideoEncoderConfigurationToJson( VideoEncoderConfiguration instance) { @@ -82,43 +80,6 @@ Map _$VideoEncoderConfigurationToJson( return val; } -K _$enumDecode( - Map enumValues, - Object? source, { - K? unknownValue, -}) { - if (source == null) { - throw ArgumentError( - 'A value must be provided. Supported values: ' - '${enumValues.values.join(', ')}', - ); - } - - return enumValues.entries.singleWhere( - (e) => e.value == source, - orElse: () { - if (unknownValue == null) { - throw ArgumentError( - '`$source` is not one of the supported values: ' - '${enumValues.values.join(', ')}', - ); - } - return MapEntry(unknownValue, enumValues.values.first); - }, - ).key; -} - -K? _$enumDecodeNullable( - Map enumValues, - dynamic source, { - K? unknownValue, -}) { - if (source == null) { - return null; - } - return _$enumDecode(enumValues, source, unknownValue: unknownValue); -} - const _$VideoFrameRateEnumMap = { VideoFrameRate.Min: -1, VideoFrameRate.Fps1: 1, @@ -148,15 +109,14 @@ const _$VideoMirrorModeEnumMap = { VideoMirrorMode.Disabled: 2, }; -BeautyOptions _$BeautyOptionsFromJson(Map json) { - return BeautyOptions( - lighteningContrastLevel: _$enumDecodeNullable( - _$LighteningContrastLevelEnumMap, json['lighteningContrastLevel']), - lighteningLevel: (json['lighteningLevel'] as num?)?.toDouble(), - smoothnessLevel: (json['smoothnessLevel'] as num?)?.toDouble(), - rednessLevel: (json['rednessLevel'] as num?)?.toDouble(), - ); -} +BeautyOptions _$BeautyOptionsFromJson(Map json) => + BeautyOptions( + lighteningContrastLevel: $enumDecodeNullable( + _$LighteningContrastLevelEnumMap, json['lighteningContrastLevel']), + lighteningLevel: (json['lighteningLevel'] as num?)?.toDouble(), + smoothnessLevel: (json['smoothnessLevel'] as num?)?.toDouble(), + rednessLevel: (json['rednessLevel'] as num?)?.toDouble(), + ); Map _$BeautyOptionsToJson(BeautyOptions instance) { final val = {}; @@ -181,15 +141,13 @@ const _$LighteningContrastLevelEnumMap = { LighteningContrastLevel.High: 2, }; -AgoraImage _$AgoraImageFromJson(Map json) { - return AgoraImage( - json['url'] as String, - x: json['x'] as int?, - y: json['y'] as int?, - width: json['width'] as int?, - height: json['height'] as int?, - ); -} +AgoraImage _$AgoraImageFromJson(Map json) => AgoraImage( + json['url'] as String, + x: json['x'] as int?, + y: json['y'] as int?, + width: json['width'] as int?, + height: json['height'] as int?, + ); Map _$AgoraImageToJson(AgoraImage instance) { final val = { @@ -209,19 +167,18 @@ Map _$AgoraImageToJson(AgoraImage instance) { return val; } -TranscodingUser _$TranscodingUserFromJson(Map json) { - return TranscodingUser( - json['uid'] as int, - x: json['x'] as int?, - y: json['y'] as int?, - width: json['width'] as int?, - height: json['height'] as int?, - zOrder: json['zOrder'] as int?, - alpha: (json['alpha'] as num?)?.toDouble(), - audioChannel: - _$enumDecodeNullable(_$AudioChannelEnumMap, json['audioChannel']), - ); -} +TranscodingUser _$TranscodingUserFromJson(Map json) => + TranscodingUser( + json['uid'] as int, + x: json['x'] as int?, + y: json['y'] as int?, + width: json['width'] as int?, + height: json['height'] as int?, + zOrder: json['zOrder'] as int?, + alpha: (json['alpha'] as num?)?.toDouble(), + audioChannel: + $enumDecodeNullable(_$AudioChannelEnumMap, json['audioChannel']), + ); Map _$TranscodingUserToJson(TranscodingUser instance) { final val = { @@ -253,38 +210,38 @@ const _$AudioChannelEnumMap = { AudioChannel.Channel5: 5, }; -LiveTranscoding _$LiveTranscodingFromJson(Map json) { - return LiveTranscoding( - (json['transcodingUsers'] as List) - .map((e) => TranscodingUser.fromJson(e as Map)) - .toList(), - width: json['width'] as int?, - height: json['height'] as int?, - videoBitrate: json['videoBitrate'] as int?, - videoFramerate: - _$enumDecodeNullable(_$VideoFrameRateEnumMap, json['videoFramerate']), - lowLatency: json['lowLatency'] as bool?, - videoGop: json['videoGop'] as int?, - watermark: json['watermark'] == null - ? null - : AgoraImage.fromJson(json['watermark'] as Map), - backgroundImage: json['backgroundImage'] == null - ? null - : AgoraImage.fromJson(json['backgroundImage'] as Map), - audioSampleRate: _$enumDecodeNullable( - _$AudioSampleRateTypeEnumMap, json['audioSampleRate']), - audioBitrate: json['audioBitrate'] as int?, - audioChannels: - _$enumDecodeNullable(_$AudioChannelEnumMap, json['audioChannels']), - audioCodecProfile: _$enumDecodeNullable( - _$AudioCodecProfileTypeEnumMap, json['audioCodecProfile']), - videoCodecProfile: _$enumDecodeNullable( - _$VideoCodecProfileTypeEnumMap, json['videoCodecProfile']), - backgroundColor: - _$ColorFromJson(json['backgroundColor'] as Map), - userConfigExtraInfo: json['userConfigExtraInfo'] as String?, - ); -} +LiveTranscoding _$LiveTranscodingFromJson(Map json) => + LiveTranscoding( + (json['transcodingUsers'] as List) + .map((e) => TranscodingUser.fromJson(e as Map)) + .toList(), + width: json['width'] as int?, + height: json['height'] as int?, + videoBitrate: json['videoBitrate'] as int?, + videoFramerate: + $enumDecodeNullable(_$VideoFrameRateEnumMap, json['videoFramerate']), + lowLatency: json['lowLatency'] as bool?, + videoGop: json['videoGop'] as int?, + watermark: json['watermark'] == null + ? null + : AgoraImage.fromJson(json['watermark'] as Map), + backgroundImage: json['backgroundImage'] == null + ? null + : AgoraImage.fromJson( + json['backgroundImage'] as Map), + audioSampleRate: $enumDecodeNullable( + _$AudioSampleRateTypeEnumMap, json['audioSampleRate']), + audioBitrate: json['audioBitrate'] as int?, + audioChannels: + $enumDecodeNullable(_$AudioChannelEnumMap, json['audioChannels']), + audioCodecProfile: $enumDecodeNullable( + _$AudioCodecProfileTypeEnumMap, json['audioCodecProfile']), + videoCodecProfile: $enumDecodeNullable( + _$VideoCodecProfileTypeEnumMap, json['videoCodecProfile']), + backgroundColor: + _$ColorFromJson(json['backgroundColor'] as Map), + userConfigExtraInfo: json['userConfigExtraInfo'] as String?, + ); Map _$LiveTranscodingToJson(LiveTranscoding instance) { final val = {}; @@ -336,13 +293,12 @@ const _$VideoCodecProfileTypeEnumMap = { VideoCodecProfileType.High: 100, }; -ChannelMediaInfo _$ChannelMediaInfoFromJson(Map json) { - return ChannelMediaInfo( - json['channelName'] as String, - json['uid'] as int, - token: json['token'] as String?, - ); -} +ChannelMediaInfo _$ChannelMediaInfoFromJson(Map json) => + ChannelMediaInfo( + json['channelName'] as String, + json['uid'] as int, + token: json['token'] as String?, + ); Map _$ChannelMediaInfoToJson(ChannelMediaInfo instance) { final val = { @@ -361,14 +317,13 @@ Map _$ChannelMediaInfoToJson(ChannelMediaInfo instance) { } ChannelMediaRelayConfiguration _$ChannelMediaRelayConfigurationFromJson( - Map json) { - return ChannelMediaRelayConfiguration( - ChannelMediaInfo.fromJson(json['srcInfo'] as Map), - (json['destInfos'] as List) - .map((e) => ChannelMediaInfo.fromJson(e as Map)) - .toList(), - ); -} + Map json) => + ChannelMediaRelayConfiguration( + ChannelMediaInfo.fromJson(json['srcInfo'] as Map), + (json['destInfos'] as List) + .map((e) => ChannelMediaInfo.fromJson(e as Map)) + .toList(), + ); Map _$ChannelMediaRelayConfigurationToJson( ChannelMediaRelayConfiguration instance) => @@ -377,14 +332,13 @@ Map _$ChannelMediaRelayConfigurationToJson( 'destInfos': instance.destInfos.map((e) => e.toJson()).toList(), }; -LastmileProbeConfig _$LastmileProbeConfigFromJson(Map json) { - return LastmileProbeConfig( - json['probeUplink'] as bool, - json['probeDownlink'] as bool, - json['expectedUplinkBitrate'] as int, - json['expectedDownlinkBitrate'] as int, - ); -} +LastmileProbeConfig _$LastmileProbeConfigFromJson(Map json) => + LastmileProbeConfig( + json['probeUplink'] as bool, + json['probeDownlink'] as bool, + json['expectedUplinkBitrate'] as int, + json['expectedDownlinkBitrate'] as int, + ); Map _$LastmileProbeConfigToJson( LastmileProbeConfig instance) => @@ -395,14 +349,12 @@ Map _$LastmileProbeConfigToJson( 'expectedDownlinkBitrate': instance.expectedDownlinkBitrate, }; -Rectangle _$RectangleFromJson(Map json) { - return Rectangle( - x: json['x'] as int?, - y: json['y'] as int?, - width: json['width'] as int?, - height: json['height'] as int?, - ); -} +Rectangle _$RectangleFromJson(Map json) => Rectangle( + x: json['x'] as int?, + y: json['y'] as int?, + width: json['width'] as int?, + height: json['height'] as int?, + ); Map _$RectangleToJson(Rectangle instance) { final val = {}; @@ -420,19 +372,18 @@ Map _$RectangleToJson(Rectangle instance) { return val; } -WatermarkOptions _$WatermarkOptionsFromJson(Map json) { - return WatermarkOptions( - visibleInPreview: json['visibleInPreview'] as bool?, - positionInLandscapeMode: json['positionInLandscapeMode'] == null - ? null - : Rectangle.fromJson( - json['positionInLandscapeMode'] as Map), - positionInPortraitMode: json['positionInPortraitMode'] == null - ? null - : Rectangle.fromJson( - json['positionInPortraitMode'] as Map), - ); -} +WatermarkOptions _$WatermarkOptionsFromJson(Map json) => + WatermarkOptions( + visibleInPreview: json['visibleInPreview'] as bool?, + positionInLandscapeMode: json['positionInLandscapeMode'] == null + ? null + : Rectangle.fromJson( + json['positionInLandscapeMode'] as Map), + positionInPortraitMode: json['positionInPortraitMode'] == null + ? null + : Rectangle.fromJson( + json['positionInPortraitMode'] as Map), + ); Map _$WatermarkOptionsToJson(WatermarkOptions instance) { final val = {}; @@ -452,21 +403,20 @@ Map _$WatermarkOptionsToJson(WatermarkOptions instance) { } LiveInjectStreamConfig _$LiveInjectStreamConfigFromJson( - Map json) { - return LiveInjectStreamConfig( - width: json['width'] as int?, - height: json['height'] as int?, - videoGop: json['videoGop'] as int?, - videoFramerate: - _$enumDecodeNullable(_$VideoFrameRateEnumMap, json['videoFramerate']), - videoBitrate: json['videoBitrate'] as int?, - audioSampleRate: _$enumDecodeNullable( - _$AudioSampleRateTypeEnumMap, json['audioSampleRate']), - audioBitrate: json['audioBitrate'] as int?, - audioChannels: - _$enumDecodeNullable(_$AudioChannelEnumMap, json['audioChannels']), - ); -} + Map json) => + LiveInjectStreamConfig( + width: json['width'] as int?, + height: json['height'] as int?, + videoGop: json['videoGop'] as int?, + videoFramerate: + $enumDecodeNullable(_$VideoFrameRateEnumMap, json['videoFramerate']), + videoBitrate: json['videoBitrate'] as int?, + audioSampleRate: $enumDecodeNullable( + _$AudioSampleRateTypeEnumMap, json['audioSampleRate']), + audioBitrate: json['audioBitrate'] as int?, + audioChannels: + $enumDecodeNullable(_$AudioChannelEnumMap, json['audioChannels']), + ); Map _$LiveInjectStreamConfigToJson( LiveInjectStreamConfig instance) { @@ -492,16 +442,15 @@ Map _$LiveInjectStreamConfigToJson( } CameraCapturerConfiguration _$CameraCapturerConfigurationFromJson( - Map json) { - return CameraCapturerConfiguration( - preference: _$enumDecodeNullable( - _$CameraCaptureOutputPreferenceEnumMap, json['preference']), - captureWidth: json['captureWidth'] as int?, - captureHeight: json['captureHeight'] as int?, - cameraDirection: - _$enumDecodeNullable(_$CameraDirectionEnumMap, json['cameraDirection']), - ); -} + Map json) => + CameraCapturerConfiguration( + preference: $enumDecodeNullable( + _$CameraCaptureOutputPreferenceEnumMap, json['preference']), + captureWidth: json['captureWidth'] as int?, + captureHeight: json['captureHeight'] as int?, + cameraDirection: $enumDecodeNullable( + _$CameraDirectionEnumMap, json['cameraDirection']), + ); Map _$CameraCapturerConfigurationToJson( CameraCapturerConfiguration instance) { @@ -534,14 +483,13 @@ const _$CameraDirectionEnumMap = { CameraDirection.Front: 1, }; -ChannelMediaOptions _$ChannelMediaOptionsFromJson(Map json) { - return ChannelMediaOptions( - autoSubscribeAudio: json['autoSubscribeAudio'] as bool?, - autoSubscribeVideo: json['autoSubscribeVideo'] as bool?, - publishLocalAudio: json['publishLocalAudio'] as bool?, - publishLocalVideo: json['publishLocalVideo'] as bool?, - ); -} +ChannelMediaOptions _$ChannelMediaOptionsFromJson(Map json) => + ChannelMediaOptions( + autoSubscribeAudio: json['autoSubscribeAudio'] as bool?, + autoSubscribeVideo: json['autoSubscribeVideo'] as bool?, + publishLocalAudio: json['publishLocalAudio'] as bool?, + publishLocalVideo: json['publishLocalVideo'] as bool?, + ); Map _$ChannelMediaOptionsToJson(ChannelMediaOptions instance) { final val = {}; @@ -559,16 +507,15 @@ Map _$ChannelMediaOptionsToJson(ChannelMediaOptions instance) { return val; } -EncryptionConfig _$EncryptionConfigFromJson(Map json) { - return EncryptionConfig( - encryptionMode: - _$enumDecodeNullable(_$EncryptionModeEnumMap, json['encryptionMode']), - encryptionKey: json['encryptionKey'] as String?, - encryptionKdfSalt: (json['encryptionKdfSalt'] as List?) - ?.map((e) => e as int) - .toList(), - ); -} +EncryptionConfig _$EncryptionConfigFromJson(Map json) => + EncryptionConfig( + encryptionMode: + $enumDecodeNullable(_$EncryptionModeEnumMap, json['encryptionMode']), + encryptionKey: json['encryptionKey'] as String?, + encryptionKdfSalt: (json['encryptionKdfSalt'] as List?) + ?.map((e) => e as int) + .toList(), + ); Map _$EncryptionConfigToJson(EncryptionConfig instance) { final val = {}; @@ -598,33 +545,31 @@ const _$EncryptionModeEnumMap = { EncryptionMode.AES256GCM2: 8, }; -RtcStats _$RtcStatsFromJson(Map json) { - return RtcStats( - json['duration'] as int, - json['txBytes'] as int, - json['rxBytes'] as int, - json['txAudioBytes'] as int, - json['txVideoBytes'] as int, - json['rxAudioBytes'] as int, - json['rxVideoBytes'] as int, - json['txKBitRate'] as int, - json['rxKBitRate'] as int, - json['txAudioKBitRate'] as int, - json['rxAudioKBitRate'] as int, - json['txVideoKBitRate'] as int, - json['rxVideoKBitRate'] as int, - json['userCount'] as int, - json['lastmileDelay'] as int, - json['txPacketLossRate'] as int, - json['rxPacketLossRate'] as int, - (json['cpuTotalUsage'] as num).toDouble(), - (json['cpuAppUsage'] as num).toDouble(), - json['gatewayRtt'] as int, - (json['memoryAppUsageRatio'] as num).toDouble(), - (json['memoryTotalUsageRatio'] as num).toDouble(), - json['memoryAppUsageInKbytes'] as int, - ); -} +RtcStats _$RtcStatsFromJson(Map json) => RtcStats( + json['duration'] as int, + json['txBytes'] as int, + json['rxBytes'] as int, + json['txAudioBytes'] as int, + json['txVideoBytes'] as int, + json['rxAudioBytes'] as int, + json['rxVideoBytes'] as int, + json['txKBitRate'] as int, + json['rxKBitRate'] as int, + json['txAudioKBitRate'] as int, + json['rxAudioKBitRate'] as int, + json['txVideoKBitRate'] as int, + json['rxVideoKBitRate'] as int, + json['userCount'] as int, + json['lastmileDelay'] as int, + json['txPacketLossRate'] as int, + json['rxPacketLossRate'] as int, + (json['cpuTotalUsage'] as num).toDouble(), + (json['cpuAppUsage'] as num).toDouble(), + json['gatewayRtt'] as int, + (json['memoryAppUsageRatio'] as num).toDouble(), + (json['memoryTotalUsageRatio'] as num).toDouble(), + json['memoryAppUsageInKbytes'] as int, + ); Map _$RtcStatsToJson(RtcStats instance) => { 'duration': instance.duration, @@ -652,14 +597,13 @@ Map _$RtcStatsToJson(RtcStats instance) => { 'memoryAppUsageInKbytes': instance.memoryAppUsageInKbytes, }; -AudioVolumeInfo _$AudioVolumeInfoFromJson(Map json) { - return AudioVolumeInfo( - json['uid'] as int, - json['volume'] as int, - json['vad'] as int, - json['channelId'] as String, - ); -} +AudioVolumeInfo _$AudioVolumeInfoFromJson(Map json) => + AudioVolumeInfo( + json['uid'] as int, + json['volume'] as int, + json['vad'] as int, + json['channelId'] as String, + ); Map _$AudioVolumeInfoToJson(AudioVolumeInfo instance) => { @@ -669,14 +613,12 @@ Map _$AudioVolumeInfoToJson(AudioVolumeInfo instance) => 'channelId': instance.channelId, }; -Rect _$RectFromJson(Map json) { - return Rect( - left: json['left'] as int?, - top: json['top'] as int?, - right: json['right'] as int?, - bottom: json['bottom'] as int?, - ); -} +Rect _$RectFromJson(Map json) => Rect( + left: json['left'] as int?, + top: json['top'] as int?, + right: json['right'] as int?, + bottom: json['bottom'] as int?, + ); Map _$RectToJson(Rect instance) { final val = {}; @@ -695,13 +637,12 @@ Map _$RectToJson(Rect instance) { } LastmileProbeOneWayResult _$LastmileProbeOneWayResultFromJson( - Map json) { - return LastmileProbeOneWayResult( - json['packetLossRate'] as int, - json['jitter'] as int, - json['availableBandwidth'] as int, - ); -} + Map json) => + LastmileProbeOneWayResult( + json['packetLossRate'] as int, + json['jitter'] as int, + json['availableBandwidth'] as int, + ); Map _$LastmileProbeOneWayResultToJson( LastmileProbeOneWayResult instance) => @@ -711,16 +652,15 @@ Map _$LastmileProbeOneWayResultToJson( 'availableBandwidth': instance.availableBandwidth, }; -LastmileProbeResult _$LastmileProbeResultFromJson(Map json) { - return LastmileProbeResult( - _$enumDecode(_$LastmileProbeResultStateEnumMap, json['state']), - json['rtt'] as int, - LastmileProbeOneWayResult.fromJson( - json['uplinkReport'] as Map), - LastmileProbeOneWayResult.fromJson( - json['downlinkReport'] as Map), - ); -} +LastmileProbeResult _$LastmileProbeResultFromJson(Map json) => + LastmileProbeResult( + $enumDecode(_$LastmileProbeResultStateEnumMap, json['state']), + json['rtt'] as int, + LastmileProbeOneWayResult.fromJson( + json['uplinkReport'] as Map), + LastmileProbeOneWayResult.fromJson( + json['downlinkReport'] as Map), + ); Map _$LastmileProbeResultToJson( LastmileProbeResult instance) => @@ -737,14 +677,13 @@ const _$LastmileProbeResultStateEnumMap = { LastmileProbeResultState.Unavailable: 3, }; -LocalAudioStats _$LocalAudioStatsFromJson(Map json) { - return LocalAudioStats( - json['numChannels'] as int, - json['sentSampleRate'] as int, - json['sentBitrate'] as int, - json['txPacketLossRate'] as int, - ); -} +LocalAudioStats _$LocalAudioStatsFromJson(Map json) => + LocalAudioStats( + json['numChannels'] as int, + json['sentSampleRate'] as int, + json['sentBitrate'] as int, + json['txPacketLossRate'] as int, + ); Map _$LocalAudioStatsToJson(LocalAudioStats instance) => { @@ -754,27 +693,26 @@ Map _$LocalAudioStatsToJson(LocalAudioStats instance) => 'txPacketLossRate': instance.txPacketLossRate, }; -LocalVideoStats _$LocalVideoStatsFromJson(Map json) { - return LocalVideoStats( - json['sentBitrate'] as int, - json['sentFrameRate'] as int, - json['encoderOutputFrameRate'] as int, - json['rendererOutputFrameRate'] as int, - json['targetBitrate'] as int, - json['targetFrameRate'] as int, - _$enumDecode( - _$VideoQualityAdaptIndicationEnumMap, json['qualityAdaptIndication']), - json['encodedBitrate'] as int, - json['encodedFrameWidth'] as int, - json['encodedFrameHeight'] as int, - json['encodedFrameCount'] as int, - _$enumDecode(_$VideoCodecTypeEnumMap, json['codecType']), - json['txPacketLossRate'] as int, - json['captureFrameRate'] as int, - _$enumDecode( - _$CaptureBrightnessLevelTypeEnumMap, json['captureBrightnessLevel']), - ); -} +LocalVideoStats _$LocalVideoStatsFromJson(Map json) => + LocalVideoStats( + json['sentBitrate'] as int, + json['sentFrameRate'] as int, + json['encoderOutputFrameRate'] as int, + json['rendererOutputFrameRate'] as int, + json['targetBitrate'] as int, + json['targetFrameRate'] as int, + $enumDecode( + _$VideoQualityAdaptIndicationEnumMap, json['qualityAdaptIndication']), + json['encodedBitrate'] as int, + json['encodedFrameWidth'] as int, + json['encodedFrameHeight'] as int, + json['encodedFrameCount'] as int, + $enumDecode(_$VideoCodecTypeEnumMap, json['codecType']), + json['txPacketLossRate'] as int, + json['captureFrameRate'] as int, + $enumDecode( + _$CaptureBrightnessLevelTypeEnumMap, json['captureBrightnessLevel']), + ); Map _$LocalVideoStatsToJson(LocalVideoStats instance) => { @@ -817,25 +755,24 @@ const _$CaptureBrightnessLevelTypeEnumMap = { CaptureBrightnessLevelType.Dark: 2, }; -RemoteAudioStats _$RemoteAudioStatsFromJson(Map json) { - return RemoteAudioStats( - json['uid'] as int, - _$enumDecode(_$NetworkQualityEnumMap, json['quality']), - json['networkTransportDelay'] as int, - json['jitterBufferDelay'] as int, - json['audioLossRate'] as int, - json['numChannels'] as int, - json['receivedSampleRate'] as int, - json['receivedBitrate'] as int, - json['totalFrozenTime'] as int, - json['frozenRate'] as int, - json['totalActiveTime'] as int, - json['publishDuration'] as int, - _$enumDecode(_$ExperienceQualityTypeEnumMap, json['qoeQuality']), - _$enumDecode(_$ExperiencePoorReasonEnumMap, json['qualityChangedReason']), - json['mosValue'] as int, - ); -} +RemoteAudioStats _$RemoteAudioStatsFromJson(Map json) => + RemoteAudioStats( + json['uid'] as int, + $enumDecode(_$NetworkQualityEnumMap, json['quality']), + json['networkTransportDelay'] as int, + json['jitterBufferDelay'] as int, + json['audioLossRate'] as int, + json['numChannels'] as int, + json['receivedSampleRate'] as int, + json['receivedBitrate'] as int, + json['totalFrozenTime'] as int, + json['frozenRate'] as int, + json['totalActiveTime'] as int, + json['publishDuration'] as int, + $enumDecode(_$ExperienceQualityTypeEnumMap, json['qoeQuality']), + $enumDecode(_$ExperiencePoorReasonEnumMap, json['qualityChangedReason']), + json['mosValue'] as int, + ); Map _$RemoteAudioStatsToJson(RemoteAudioStats instance) => { @@ -882,23 +819,22 @@ const _$ExperiencePoorReasonEnumMap = { ExperiencePoorReason.WifiBluetoothCoexist: 8, }; -RemoteVideoStats _$RemoteVideoStatsFromJson(Map json) { - return RemoteVideoStats( - json['uid'] as int, - json['delay'] as int, - json['width'] as int, - json['height'] as int, - json['receivedBitrate'] as int, - json['decoderOutputFrameRate'] as int, - json['rendererOutputFrameRate'] as int, - json['packetLossRate'] as int, - _$enumDecode(_$VideoStreamTypeEnumMap, json['rxStreamType']), - json['totalFrozenTime'] as int, - json['frozenRate'] as int, - json['totalActiveTime'] as int, - json['publishDuration'] as int, - ); -} +RemoteVideoStats _$RemoteVideoStatsFromJson(Map json) => + RemoteVideoStats( + json['uid'] as int, + json['delay'] as int, + json['width'] as int, + json['height'] as int, + json['receivedBitrate'] as int, + json['decoderOutputFrameRate'] as int, + json['rendererOutputFrameRate'] as int, + json['packetLossRate'] as int, + $enumDecode(_$VideoStreamTypeEnumMap, json['rxStreamType']), + json['totalFrozenTime'] as int, + json['frozenRate'] as int, + json['totalActiveTime'] as int, + json['publishDuration'] as int, + ); Map _$RemoteVideoStatsToJson(RemoteVideoStats instance) => { @@ -922,15 +858,14 @@ const _$VideoStreamTypeEnumMap = { VideoStreamType.Low: 1, }; -FacePositionInfo _$FacePositionInfoFromJson(Map json) { - return FacePositionInfo( - json['x'] as int, - json['y'] as int, - json['width'] as int, - json['height'] as int, - json['distance'] as int, - ); -} +FacePositionInfo _$FacePositionInfoFromJson(Map json) => + FacePositionInfo( + json['x'] as int, + json['y'] as int, + json['width'] as int, + json['height'] as int, + json['distance'] as int, + ); Map _$FacePositionInfoToJson(FacePositionInfo instance) => { @@ -941,12 +876,11 @@ Map _$FacePositionInfoToJson(FacePositionInfo instance) => 'distance': instance.distance, }; -ClientRoleOptions _$ClientRoleOptionsFromJson(Map json) { - return ClientRoleOptions( - audienceLatencyLevel: _$enumDecodeNullable( - _$AudienceLatencyLevelTypeEnumMap, json['audienceLatencyLevel']), - ); -} +ClientRoleOptions _$ClientRoleOptionsFromJson(Map json) => + ClientRoleOptions( + audienceLatencyLevel: $enumDecodeNullable( + _$AudienceLatencyLevelTypeEnumMap, json['audienceLatencyLevel']), + ); Map _$ClientRoleOptionsToJson(ClientRoleOptions instance) { final val = {}; @@ -967,13 +901,11 @@ const _$AudienceLatencyLevelTypeEnumMap = { AudienceLatencyLevelType.UltraLowLatency: 2, }; -LogConfig _$LogConfigFromJson(Map json) { - return LogConfig( - filePath: json['filePath'] as String?, - fileSize: json['fileSize'] as int?, - level: _$enumDecodeNullable(_$LogLevelEnumMap, json['level']), - ); -} +LogConfig _$LogConfigFromJson(Map json) => LogConfig( + filePath: json['filePath'] as String?, + fileSize: json['fileSize'] as int?, + level: $enumDecodeNullable(_$LogLevelEnumMap, json['level']), + ); Map _$LogConfigToJson(LogConfig instance) { final val = {}; @@ -998,12 +930,11 @@ const _$LogLevelEnumMap = { LogLevel.Fatal: 8, }; -DataStreamConfig _$DataStreamConfigFromJson(Map json) { - return DataStreamConfig( - json['syncWithAudio'] as bool, - json['ordered'] as bool, - ); -} +DataStreamConfig _$DataStreamConfigFromJson(Map json) => + DataStreamConfig( + json['syncWithAudio'] as bool, + json['ordered'] as bool, + ); Map _$DataStreamConfigToJson(DataStreamConfig instance) => { @@ -1011,17 +942,16 @@ Map _$DataStreamConfigToJson(DataStreamConfig instance) => 'ordered': instance.ordered, }; -RtcEngineConfig _$RtcEngineConfigFromJson(Map json) { - return RtcEngineConfig( - json['appId'] as String, - areaCode: (json['areaCode'] as List?) - ?.map((e) => _$enumDecode(_$AreaCodeEnumMap, e)) - .toList(), - logConfig: json['logConfig'] == null - ? null - : LogConfig.fromJson(json['logConfig'] as Map), - ); -} +RtcEngineConfig _$RtcEngineConfigFromJson(Map json) => + RtcEngineConfig( + json['appId'] as String, + areaCode: (json['areaCode'] as List?) + ?.map((e) => $enumDecode(_$AreaCodeEnumMap, e)) + .toList(), + logConfig: json['logConfig'] == null + ? null + : LogConfig.fromJson(json['logConfig'] as Map), + ); Map _$RtcEngineConfigToJson(RtcEngineConfig instance) { final val = { @@ -1050,17 +980,16 @@ const _$AreaCodeEnumMap = { AreaCode.GLOB: -1, }; -RtcEngineContext _$RtcEngineContextFromJson(Map json) { - return RtcEngineContext( - json['appId'] as String, - areaCode: (json['areaCode'] as List?) - ?.map((e) => _$enumDecode(_$AreaCodeEnumMap, e)) - .toList(), - logConfig: json['logConfig'] == null - ? null - : LogConfig.fromJson(json['logConfig'] as Map), - ); -} +RtcEngineContext _$RtcEngineContextFromJson(Map json) => + RtcEngineContext( + json['appId'] as String, + areaCode: (json['areaCode'] as List?) + ?.map((e) => $enumDecode(_$AreaCodeEnumMap, e)) + .toList(), + logConfig: json['logConfig'] == null + ? null + : LogConfig.fromJson(json['logConfig'] as Map), + ); Map _$RtcEngineContextToJson(RtcEngineContext instance) { final val = { @@ -1079,13 +1008,12 @@ Map _$RtcEngineContextToJson(RtcEngineContext instance) { return val; } -RhythmPlayerConfig _$RhythmPlayerConfigFromJson(Map json) { - return RhythmPlayerConfig( - beatsPerMeasure: json['beatsPerMeasure'] as int?, - beatsPerMinute: json['beatsPerMinute'] as int?, - publish: json['publish'] as bool?, - ); -} +RhythmPlayerConfig _$RhythmPlayerConfigFromJson(Map json) => + RhythmPlayerConfig( + beatsPerMeasure: json['beatsPerMeasure'] as int?, + beatsPerMinute: json['beatsPerMinute'] as int?, + publish: json['publish'] as bool?, + ); Map _$RhythmPlayerConfigToJson(RhythmPlayerConfig instance) { final val = {}; @@ -1103,17 +1031,16 @@ Map _$RhythmPlayerConfigToJson(RhythmPlayerConfig instance) { } AudioRecordingConfiguration _$AudioRecordingConfigurationFromJson( - Map json) { - return AudioRecordingConfiguration( - json['filePath'] as String, - recordingQuality: _$enumDecodeNullable( - _$AudioRecordingQualityEnumMap, json['recordingQuality']), - recordingPosition: _$enumDecodeNullable( - _$AudioRecordingPositionEnumMap, json['recordingPosition']), - recordingSampleRate: _$enumDecodeNullable( - _$AudioSampleRateTypeEnumMap, json['recordingSampleRate']), - ); -} + Map json) => + AudioRecordingConfiguration( + json['filePath'] as String, + recordingQuality: $enumDecodeNullable( + _$AudioRecordingQualityEnumMap, json['recordingQuality']), + recordingPosition: $enumDecodeNullable( + _$AudioRecordingPositionEnumMap, json['recordingPosition']), + recordingSampleRate: $enumDecodeNullable( + _$AudioSampleRateTypeEnumMap, json['recordingSampleRate']), + ); Map _$AudioRecordingConfigurationToJson( AudioRecordingConfiguration instance) { @@ -1149,16 +1076,16 @@ const _$AudioRecordingPositionEnumMap = { }; VirtualBackgroundSource _$VirtualBackgroundSourceFromJson( - Map json) { - return VirtualBackgroundSource( - backgroundSourceType: _$enumDecodeNullable( - _$VirtualBackgroundSourceTypeEnumMap, json['backgroundSourceType']), - color: _$ColorFromJson(json['color'] as Map), - source: json['source'] as String?, - blurDegree: - _$enumDecode(_$VirtualBackgroundBlurDegreeEnumMap, json['blur_degree']), - ); -} + Map json) => + VirtualBackgroundSource( + backgroundSourceType: $enumDecodeNullable( + _$VirtualBackgroundSourceTypeEnumMap, json['backgroundSourceType']), + color: _$ColorFromJson(json['color'] as Map), + source: json['source'] as String?, + blurDegree: $enumDecodeNullable( + _$VirtualBackgroundBlurDegreeEnumMap, json['blur_degree']) ?? + VirtualBackgroundBlurDegree.High, + ); Map _$VirtualBackgroundSourceToJson( VirtualBackgroundSource instance) { @@ -1191,15 +1118,40 @@ const _$VirtualBackgroundBlurDegreeEnumMap = { VirtualBackgroundBlurDegree.High: 3, }; -AudioFileInfo _$AudioFileInfoFromJson(Map json) { - return AudioFileInfo( - filePath: json['filePath'] as String, - durationMs: json['durationMs'] as int, - ); -} +AudioFileInfo _$AudioFileInfoFromJson(Map json) => + AudioFileInfo( + filePath: json['filePath'] as String, + durationMs: json['durationMs'] as int, + ); Map _$AudioFileInfoToJson(AudioFileInfo instance) => { 'filePath': instance.filePath, 'durationMs': instance.durationMs, }; + +EchoTestConfiguration _$EchoTestConfigurationFromJson( + Map json) => + EchoTestConfiguration( + enableAudio: json['enableAudio'] as bool?, + enableVideo: json['enableVideo'] as bool?, + token: json['token'] as String?, + channelId: json['channelId'] as String?, + ); + +Map _$EchoTestConfigurationToJson( + EchoTestConfiguration instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('enableAudio', instance.enableAudio); + writeNotNull('enableVideo', instance.enableVideo); + writeNotNull('token', instance.token); + writeNotNull('channelId', instance.channelId); + return val; +} diff --git a/lib/src/enum_converter.dart b/lib/src/enum_converter.dart index 0aa047f27..3982dce3d 100644 --- a/lib/src/enum_converter.dart +++ b/lib/src/enum_converter.dart @@ -6,12 +6,12 @@ import 'enums.dart'; part 'enum_converter.g.dart'; -abstract class EnumConverter { +abstract class EnumConverter { E e; EnumConverter(this.e); - EnumConverter.fromValue(Map map, T t) : e = _$enumDecode(map, t); + EnumConverter.fromValue(Map map, T t) : e = $enumDecode(map, t); T toValue(Map map) { return map[e] as T; diff --git a/lib/src/enum_converter.g.dart b/lib/src/enum_converter.g.dart index 09f93c929..224162196 100644 --- a/lib/src/enum_converter.g.dart +++ b/lib/src/enum_converter.g.dart @@ -6,43 +6,16 @@ part of 'enum_converter.dart'; // JsonSerializableGenerator // ************************************************************************** -AreaCodeConverter _$AreaCodeConverterFromJson(Map json) { - return AreaCodeConverter( - _$enumDecode(_$AreaCodeEnumMap, json['e']), - ); -} +AreaCodeConverter _$AreaCodeConverterFromJson(Map json) => + AreaCodeConverter( + $enumDecode(_$AreaCodeEnumMap, json['e']), + ); Map _$AreaCodeConverterToJson(AreaCodeConverter instance) => { 'e': _$AreaCodeEnumMap[instance.e], }; -K _$enumDecode( - Map enumValues, - Object? source, { - K? unknownValue, -}) { - if (source == null) { - throw ArgumentError( - 'A value must be provided. Supported values: ' - '${enumValues.values.join(', ')}', - ); - } - - return enumValues.entries.singleWhere( - (e) => e.value == source, - orElse: () { - if (unknownValue == null) { - throw ArgumentError( - '`$source` is not one of the supported values: ' - '${enumValues.values.join(', ')}', - ); - } - return MapEntry(unknownValue, enumValues.values.first); - }, - ).key; -} - const _$AreaCodeEnumMap = { AreaCode.CN: 1, AreaCode.NA: 2, @@ -54,11 +27,10 @@ const _$AreaCodeEnumMap = { }; AudioCodecProfileTypeConverter _$AudioCodecProfileTypeConverterFromJson( - Map json) { - return AudioCodecProfileTypeConverter( - _$enumDecode(_$AudioCodecProfileTypeEnumMap, json['e']), - ); -} + Map json) => + AudioCodecProfileTypeConverter( + $enumDecode(_$AudioCodecProfileTypeEnumMap, json['e']), + ); Map _$AudioCodecProfileTypeConverterToJson( AudioCodecProfileTypeConverter instance) => @@ -73,11 +45,10 @@ const _$AudioCodecProfileTypeEnumMap = { AudioEqualizationBandFrequencyConverter _$AudioEqualizationBandFrequencyConverterFromJson( - Map json) { - return AudioEqualizationBandFrequencyConverter( - _$enumDecode(_$AudioEqualizationBandFrequencyEnumMap, json['e']), - ); -} + Map json) => + AudioEqualizationBandFrequencyConverter( + $enumDecode(_$AudioEqualizationBandFrequencyEnumMap, json['e']), + ); Map _$AudioEqualizationBandFrequencyConverterToJson( AudioEqualizationBandFrequencyConverter instance) => @@ -99,11 +70,10 @@ const _$AudioEqualizationBandFrequencyEnumMap = { }; AudioLocalErrorConverter _$AudioLocalErrorConverterFromJson( - Map json) { - return AudioLocalErrorConverter( - _$enumDecode(_$AudioLocalErrorEnumMap, json['e']), - ); -} + Map json) => + AudioLocalErrorConverter( + $enumDecode(_$AudioLocalErrorEnumMap, json['e']), + ); Map _$AudioLocalErrorConverterToJson( AudioLocalErrorConverter instance) => @@ -122,11 +92,10 @@ const _$AudioLocalErrorEnumMap = { }; AudioLocalStateConverter _$AudioLocalStateConverterFromJson( - Map json) { - return AudioLocalStateConverter( - _$enumDecode(_$AudioLocalStateEnumMap, json['e']), - ); -} + Map json) => + AudioLocalStateConverter( + $enumDecode(_$AudioLocalStateEnumMap, json['e']), + ); Map _$AudioLocalStateConverterToJson( AudioLocalStateConverter instance) => @@ -142,11 +111,10 @@ const _$AudioLocalStateEnumMap = { }; AudioFileInfoErrorConverter _$AudioFileInfoErrorConverterFromJson( - Map json) { - return AudioFileInfoErrorConverter( - _$enumDecode(_$AudioFileInfoErrorEnumMap, json['e']), - ); -} + Map json) => + AudioFileInfoErrorConverter( + $enumDecode(_$AudioFileInfoErrorEnumMap, json['e']), + ); Map _$AudioFileInfoErrorConverterToJson( AudioFileInfoErrorConverter instance) => @@ -160,11 +128,10 @@ const _$AudioFileInfoErrorEnumMap = { }; AudioMixingReasonConverter _$AudioMixingReasonConverterFromJson( - Map json) { - return AudioMixingReasonConverter( - _$enumDecode(_$AudioMixingReasonEnumMap, json['e']), - ); -} + Map json) => + AudioMixingReasonConverter( + $enumDecode(_$AudioMixingReasonEnumMap, json['e']), + ); Map _$AudioMixingReasonConverterToJson( AudioMixingReasonConverter instance) => @@ -187,11 +154,10 @@ const _$AudioMixingReasonEnumMap = { }; AudioMixingStateCodeConverter _$AudioMixingStateCodeConverterFromJson( - Map json) { - return AudioMixingStateCodeConverter( - _$enumDecode(_$AudioMixingStateCodeEnumMap, json['e']), - ); -} + Map json) => + AudioMixingStateCodeConverter( + $enumDecode(_$AudioMixingStateCodeEnumMap, json['e']), + ); Map _$AudioMixingStateCodeConverterToJson( AudioMixingStateCodeConverter instance) => @@ -208,11 +174,10 @@ const _$AudioMixingStateCodeEnumMap = { }; AudioMixingDualMonoModeConverter _$AudioMixingDualMonoModeConverterFromJson( - Map json) { - return AudioMixingDualMonoModeConverter( - _$enumDecode(_$AudioMixingDualMonoModeEnumMap, json['e']), - ); -} + Map json) => + AudioMixingDualMonoModeConverter( + $enumDecode(_$AudioMixingDualMonoModeEnumMap, json['e']), + ); Map _$AudioMixingDualMonoModeConverterToJson( AudioMixingDualMonoModeConverter instance) => @@ -228,11 +193,10 @@ const _$AudioMixingDualMonoModeEnumMap = { }; AudioOutputRoutingConverter _$AudioOutputRoutingConverterFromJson( - Map json) { - return AudioOutputRoutingConverter( - _$enumDecode(_$AudioOutputRoutingEnumMap, json['e']), - ); -} + Map json) => + AudioOutputRoutingConverter( + $enumDecode(_$AudioOutputRoutingEnumMap, json['e']), + ); Map _$AudioOutputRoutingConverterToJson( AudioOutputRoutingConverter instance) => @@ -251,11 +215,10 @@ const _$AudioOutputRoutingEnumMap = { }; AudioProfileConverter _$AudioProfileConverterFromJson( - Map json) { - return AudioProfileConverter( - _$enumDecode(_$AudioProfileEnumMap, json['e']), - ); -} + Map json) => + AudioProfileConverter( + $enumDecode(_$AudioProfileEnumMap, json['e']), + ); Map _$AudioProfileConverterToJson( AudioProfileConverter instance) => @@ -273,11 +236,10 @@ const _$AudioProfileEnumMap = { }; AudioRecordingQualityConverter _$AudioRecordingQualityConverterFromJson( - Map json) { - return AudioRecordingQualityConverter( - _$enumDecode(_$AudioRecordingQualityEnumMap, json['e']), - ); -} + Map json) => + AudioRecordingQualityConverter( + $enumDecode(_$AudioRecordingQualityEnumMap, json['e']), + ); Map _$AudioRecordingQualityConverterToJson( AudioRecordingQualityConverter instance) => @@ -292,11 +254,10 @@ const _$AudioRecordingQualityEnumMap = { }; AudioRecordingPositionConverter _$AudioRecordingPositionConverterFromJson( - Map json) { - return AudioRecordingPositionConverter( - _$enumDecode(_$AudioRecordingPositionEnumMap, json['e']), - ); -} + Map json) => + AudioRecordingPositionConverter( + $enumDecode(_$AudioRecordingPositionEnumMap, json['e']), + ); Map _$AudioRecordingPositionConverterToJson( AudioRecordingPositionConverter instance) => @@ -311,11 +272,10 @@ const _$AudioRecordingPositionEnumMap = { }; AudioRemoteStateConverter _$AudioRemoteStateConverterFromJson( - Map json) { - return AudioRemoteStateConverter( - _$enumDecode(_$AudioRemoteStateEnumMap, json['e']), - ); -} + Map json) => + AudioRemoteStateConverter( + $enumDecode(_$AudioRemoteStateEnumMap, json['e']), + ); Map _$AudioRemoteStateConverterToJson( AudioRemoteStateConverter instance) => @@ -332,11 +292,10 @@ const _$AudioRemoteStateEnumMap = { }; AudioRemoteStateReasonConverter _$AudioRemoteStateReasonConverterFromJson( - Map json) { - return AudioRemoteStateReasonConverter( - _$enumDecode(_$AudioRemoteStateReasonEnumMap, json['e']), - ); -} + Map json) => + AudioRemoteStateReasonConverter( + $enumDecode(_$AudioRemoteStateReasonEnumMap, json['e']), + ); Map _$AudioRemoteStateReasonConverterToJson( AudioRemoteStateReasonConverter instance) => @@ -356,11 +315,10 @@ const _$AudioRemoteStateReasonEnumMap = { }; AudioReverbPresetConverter _$AudioReverbPresetConverterFromJson( - Map json) { - return AudioReverbPresetConverter( - _$enumDecode(_$AudioReverbPresetEnumMap, json['e']), - ); -} + Map json) => + AudioReverbPresetConverter( + $enumDecode(_$AudioReverbPresetEnumMap, json['e']), + ); Map _$AudioReverbPresetConverterToJson( AudioReverbPresetConverter instance) => @@ -389,11 +347,10 @@ const _$AudioReverbPresetEnumMap = { }; AudioReverbTypeConverter _$AudioReverbTypeConverterFromJson( - Map json) { - return AudioReverbTypeConverter( - _$enumDecode(_$AudioReverbTypeEnumMap, json['e']), - ); -} + Map json) => + AudioReverbTypeConverter( + $enumDecode(_$AudioReverbTypeEnumMap, json['e']), + ); Map _$AudioReverbTypeConverterToJson( AudioReverbTypeConverter instance) => @@ -410,11 +367,10 @@ const _$AudioReverbTypeEnumMap = { }; AudioSampleRateTypeConverter _$AudioSampleRateTypeConverterFromJson( - Map json) { - return AudioSampleRateTypeConverter( - _$enumDecode(_$AudioSampleRateTypeEnumMap, json['e']), - ); -} + Map json) => + AudioSampleRateTypeConverter( + $enumDecode(_$AudioSampleRateTypeEnumMap, json['e']), + ); Map _$AudioSampleRateTypeConverterToJson( AudioSampleRateTypeConverter instance) => @@ -429,11 +385,10 @@ const _$AudioSampleRateTypeEnumMap = { }; AudioScenarioConverter _$AudioScenarioConverterFromJson( - Map json) { - return AudioScenarioConverter( - _$enumDecode(_$AudioScenarioEnumMap, json['e']), - ); -} + Map json) => + AudioScenarioConverter( + $enumDecode(_$AudioScenarioEnumMap, json['e']), + ); Map _$AudioScenarioConverterToJson( AudioScenarioConverter instance) => @@ -453,11 +408,10 @@ const _$AudioScenarioEnumMap = { }; AudioVoiceChangerConverter _$AudioVoiceChangerConverterFromJson( - Map json) { - return AudioVoiceChangerConverter( - _$enumDecode(_$AudioVoiceChangerEnumMap, json['e']), - ); -} + Map json) => + AudioVoiceChangerConverter( + $enumDecode(_$AudioVoiceChangerEnumMap, json['e']), + ); Map _$AudioVoiceChangerConverterToJson( AudioVoiceChangerConverter instance) => @@ -489,11 +443,10 @@ const _$AudioVoiceChangerEnumMap = { CameraCaptureOutputPreferenceConverter _$CameraCaptureOutputPreferenceConverterFromJson( - Map json) { - return CameraCaptureOutputPreferenceConverter( - _$enumDecode(_$CameraCaptureOutputPreferenceEnumMap, json['e']), - ); -} + Map json) => + CameraCaptureOutputPreferenceConverter( + $enumDecode(_$CameraCaptureOutputPreferenceEnumMap, json['e']), + ); Map _$CameraCaptureOutputPreferenceConverterToJson( CameraCaptureOutputPreferenceConverter instance) => @@ -509,11 +462,10 @@ const _$CameraCaptureOutputPreferenceEnumMap = { }; CameraDirectionConverter _$CameraDirectionConverterFromJson( - Map json) { - return CameraDirectionConverter( - _$enumDecode(_$CameraDirectionEnumMap, json['e']), - ); -} + Map json) => + CameraDirectionConverter( + $enumDecode(_$CameraDirectionEnumMap, json['e']), + ); Map _$CameraDirectionConverterToJson( CameraDirectionConverter instance) => @@ -527,11 +479,10 @@ const _$CameraDirectionEnumMap = { }; ChannelMediaRelayErrorConverter _$ChannelMediaRelayErrorConverterFromJson( - Map json) { - return ChannelMediaRelayErrorConverter( - _$enumDecode(_$ChannelMediaRelayErrorEnumMap, json['e']), - ); -} + Map json) => + ChannelMediaRelayErrorConverter( + $enumDecode(_$ChannelMediaRelayErrorEnumMap, json['e']), + ); Map _$ChannelMediaRelayErrorConverterToJson( ChannelMediaRelayErrorConverter instance) => @@ -555,11 +506,10 @@ const _$ChannelMediaRelayErrorEnumMap = { }; ChannelMediaRelayEventConverter _$ChannelMediaRelayEventConverterFromJson( - Map json) { - return ChannelMediaRelayEventConverter( - _$enumDecode(_$ChannelMediaRelayEventEnumMap, json['e']), - ); -} + Map json) => + ChannelMediaRelayEventConverter( + $enumDecode(_$ChannelMediaRelayEventEnumMap, json['e']), + ); Map _$ChannelMediaRelayEventConverterToJson( ChannelMediaRelayEventConverter instance) => @@ -587,11 +537,10 @@ const _$ChannelMediaRelayEventEnumMap = { }; ChannelMediaRelayStateConverter _$ChannelMediaRelayStateConverterFromJson( - Map json) { - return ChannelMediaRelayStateConverter( - _$enumDecode(_$ChannelMediaRelayStateEnumMap, json['e']), - ); -} + Map json) => + ChannelMediaRelayStateConverter( + $enumDecode(_$ChannelMediaRelayStateEnumMap, json['e']), + ); Map _$ChannelMediaRelayStateConverterToJson( ChannelMediaRelayStateConverter instance) => @@ -607,11 +556,10 @@ const _$ChannelMediaRelayStateEnumMap = { }; ChannelProfileConverter _$ChannelProfileConverterFromJson( - Map json) { - return ChannelProfileConverter( - _$enumDecode(_$ChannelProfileEnumMap, json['e']), - ); -} + Map json) => + ChannelProfileConverter( + $enumDecode(_$ChannelProfileEnumMap, json['e']), + ); Map _$ChannelProfileConverterToJson( ChannelProfileConverter instance) => @@ -625,11 +573,10 @@ const _$ChannelProfileEnumMap = { ChannelProfile.Game: 2, }; -ClientRoleConverter _$ClientRoleConverterFromJson(Map json) { - return ClientRoleConverter( - _$enumDecode(_$ClientRoleEnumMap, json['e']), - ); -} +ClientRoleConverter _$ClientRoleConverterFromJson(Map json) => + ClientRoleConverter( + $enumDecode(_$ClientRoleEnumMap, json['e']), + ); Map _$ClientRoleConverterToJson( ClientRoleConverter instance) => @@ -643,11 +590,10 @@ const _$ClientRoleEnumMap = { }; ConnectionChangedReasonConverter _$ConnectionChangedReasonConverterFromJson( - Map json) { - return ConnectionChangedReasonConverter( - _$enumDecode(_$ConnectionChangedReasonEnumMap, json['e']), - ); -} + Map json) => + ConnectionChangedReasonConverter( + $enumDecode(_$ConnectionChangedReasonEnumMap, json['e']), + ); Map _$ConnectionChangedReasonConverterToJson( ConnectionChangedReasonConverter instance) => @@ -675,11 +621,10 @@ const _$ConnectionChangedReasonEnumMap = { }; ConnectionStateTypeConverter _$ConnectionStateTypeConverterFromJson( - Map json) { - return ConnectionStateTypeConverter( - _$enumDecode(_$ConnectionStateTypeEnumMap, json['e']), - ); -} + Map json) => + ConnectionStateTypeConverter( + $enumDecode(_$ConnectionStateTypeEnumMap, json['e']), + ); Map _$ConnectionStateTypeConverterToJson( ConnectionStateTypeConverter instance) => @@ -696,11 +641,10 @@ const _$ConnectionStateTypeEnumMap = { }; DegradationPreferenceConverter _$DegradationPreferenceConverterFromJson( - Map json) { - return DegradationPreferenceConverter( - _$enumDecode(_$DegradationPreferenceEnumMap, json['e']), - ); -} + Map json) => + DegradationPreferenceConverter( + $enumDecode(_$DegradationPreferenceEnumMap, json['e']), + ); Map _$DegradationPreferenceConverterToJson( DegradationPreferenceConverter instance) => @@ -715,11 +659,10 @@ const _$DegradationPreferenceEnumMap = { }; EncryptionModeConverter _$EncryptionModeConverterFromJson( - Map json) { - return EncryptionModeConverter( - _$enumDecode(_$EncryptionModeEnumMap, json['e']), - ); -} + Map json) => + EncryptionModeConverter( + $enumDecode(_$EncryptionModeEnumMap, json['e']), + ); Map _$EncryptionModeConverterToJson( EncryptionModeConverter instance) => @@ -739,11 +682,10 @@ const _$EncryptionModeEnumMap = { EncryptionMode.AES256GCM2: 8, }; -ErrorCodeConverter _$ErrorCodeConverterFromJson(Map json) { - return ErrorCodeConverter( - _$enumDecode(_$ErrorCodeEnumMap, json['e']), - ); -} +ErrorCodeConverter _$ErrorCodeConverterFromJson(Map json) => + ErrorCodeConverter( + $enumDecode(_$ErrorCodeEnumMap, json['e']), + ); Map _$ErrorCodeConverterToJson(ErrorCodeConverter instance) => { @@ -833,11 +775,10 @@ const _$ErrorCodeEnumMap = { }; InjectStreamStatusConverter _$InjectStreamStatusConverterFromJson( - Map json) { - return InjectStreamStatusConverter( - _$enumDecode(_$InjectStreamStatusEnumMap, json['e']), - ); -} + Map json) => + InjectStreamStatusConverter( + $enumDecode(_$InjectStreamStatusEnumMap, json['e']), + ); Map _$InjectStreamStatusConverterToJson( InjectStreamStatusConverter instance) => @@ -860,11 +801,10 @@ const _$InjectStreamStatusEnumMap = { }; LastmileProbeResultStateConverter _$LastmileProbeResultStateConverterFromJson( - Map json) { - return LastmileProbeResultStateConverter( - _$enumDecode(_$LastmileProbeResultStateEnumMap, json['e']), - ); -} + Map json) => + LastmileProbeResultStateConverter( + $enumDecode(_$LastmileProbeResultStateEnumMap, json['e']), + ); Map _$LastmileProbeResultStateConverterToJson( LastmileProbeResultStateConverter instance) => @@ -879,11 +819,10 @@ const _$LastmileProbeResultStateEnumMap = { }; LighteningContrastLevelConverter _$LighteningContrastLevelConverterFromJson( - Map json) { - return LighteningContrastLevelConverter( - _$enumDecode(_$LighteningContrastLevelEnumMap, json['e']), - ); -} + Map json) => + LighteningContrastLevelConverter( + $enumDecode(_$LighteningContrastLevelEnumMap, json['e']), + ); Map _$LighteningContrastLevelConverterToJson( LighteningContrastLevelConverter instance) => @@ -898,11 +837,10 @@ const _$LighteningContrastLevelEnumMap = { }; LocalVideoStreamErrorConverter _$LocalVideoStreamErrorConverterFromJson( - Map json) { - return LocalVideoStreamErrorConverter( - _$enumDecode(_$LocalVideoStreamErrorEnumMap, json['e']), - ); -} + Map json) => + LocalVideoStreamErrorConverter( + $enumDecode(_$LocalVideoStreamErrorEnumMap, json['e']), + ); Map _$LocalVideoStreamErrorConverterToJson( LocalVideoStreamErrorConverter instance) => @@ -923,11 +861,10 @@ const _$LocalVideoStreamErrorEnumMap = { }; LocalVideoStreamStateConverter _$LocalVideoStreamStateConverterFromJson( - Map json) { - return LocalVideoStreamStateConverter( - _$enumDecode(_$LocalVideoStreamStateEnumMap, json['e']), - ); -} + Map json) => + LocalVideoStreamStateConverter( + $enumDecode(_$LocalVideoStreamStateEnumMap, json['e']), + ); Map _$LocalVideoStreamStateConverterToJson( LocalVideoStreamStateConverter instance) => @@ -942,11 +879,10 @@ const _$LocalVideoStreamStateEnumMap = { LocalVideoStreamState.Failed: 3, }; -LogFilterConverter _$LogFilterConverterFromJson(Map json) { - return LogFilterConverter( - _$enumDecode(_$LogFilterEnumMap, json['e']), - ); -} +LogFilterConverter _$LogFilterConverterFromJson(Map json) => + LogFilterConverter( + $enumDecode(_$LogFilterEnumMap, json['e']), + ); Map _$LogFilterConverterToJson(LogFilterConverter instance) => { @@ -963,11 +899,10 @@ const _$LogFilterEnumMap = { }; NetworkQualityConverter _$NetworkQualityConverterFromJson( - Map json) { - return NetworkQualityConverter( - _$enumDecode(_$NetworkQualityEnumMap, json['e']), - ); -} + Map json) => + NetworkQualityConverter( + $enumDecode(_$NetworkQualityEnumMap, json['e']), + ); Map _$NetworkQualityConverterToJson( NetworkQualityConverter instance) => @@ -987,11 +922,11 @@ const _$NetworkQualityEnumMap = { NetworkQuality.Detecting: 8, }; -NetworkTypeConverter _$NetworkTypeConverterFromJson(Map json) { - return NetworkTypeConverter( - _$enumDecode(_$NetworkTypeEnumMap, json['e']), - ); -} +NetworkTypeConverter _$NetworkTypeConverterFromJson( + Map json) => + NetworkTypeConverter( + $enumDecode(_$NetworkTypeEnumMap, json['e']), + ); Map _$NetworkTypeConverterToJson( NetworkTypeConverter instance) => @@ -1011,11 +946,10 @@ const _$NetworkTypeEnumMap = { }; RtmpStreamingErrorCodeConverter _$RtmpStreamingErrorCodeConverterFromJson( - Map json) { - return RtmpStreamingErrorCodeConverter( - _$enumDecode(_$RtmpStreamingErrorCodeEnumMap, json['e']), - ); -} + Map json) => + RtmpStreamingErrorCodeConverter( + $enumDecode(_$RtmpStreamingErrorCodeEnumMap, json['e']), + ); Map _$RtmpStreamingErrorCodeConverterToJson( RtmpStreamingErrorCodeConverter instance) => @@ -1039,11 +973,10 @@ const _$RtmpStreamingErrorCodeEnumMap = { }; RtmpStreamingStateConverter _$RtmpStreamingStateConverterFromJson( - Map json) { - return RtmpStreamingStateConverter( - _$enumDecode(_$RtmpStreamingStateEnumMap, json['e']), - ); -} + Map json) => + RtmpStreamingStateConverter( + $enumDecode(_$RtmpStreamingStateEnumMap, json['e']), + ); Map _$RtmpStreamingStateConverterToJson( RtmpStreamingStateConverter instance) => @@ -1060,11 +993,10 @@ const _$RtmpStreamingStateEnumMap = { }; StreamFallbackOptionsConverter _$StreamFallbackOptionsConverterFromJson( - Map json) { - return StreamFallbackOptionsConverter( - _$enumDecode(_$StreamFallbackOptionsEnumMap, json['e']), - ); -} + Map json) => + StreamFallbackOptionsConverter( + $enumDecode(_$StreamFallbackOptionsEnumMap, json['e']), + ); Map _$StreamFallbackOptionsConverterToJson( StreamFallbackOptionsConverter instance) => @@ -1079,11 +1011,10 @@ const _$StreamFallbackOptionsEnumMap = { }; UserOfflineReasonConverter _$UserOfflineReasonConverterFromJson( - Map json) { - return UserOfflineReasonConverter( - _$enumDecode(_$UserOfflineReasonEnumMap, json['e']), - ); -} + Map json) => + UserOfflineReasonConverter( + $enumDecode(_$UserOfflineReasonEnumMap, json['e']), + ); Map _$UserOfflineReasonConverterToJson( UserOfflineReasonConverter instance) => @@ -1098,11 +1029,10 @@ const _$UserOfflineReasonEnumMap = { }; UserPriorityConverter _$UserPriorityConverterFromJson( - Map json) { - return UserPriorityConverter( - _$enumDecode(_$UserPriorityEnumMap, json['e']), - ); -} + Map json) => + UserPriorityConverter( + $enumDecode(_$UserPriorityEnumMap, json['e']), + ); Map _$UserPriorityConverterToJson( UserPriorityConverter instance) => @@ -1116,11 +1046,10 @@ const _$UserPriorityEnumMap = { }; VideoCodecProfileTypeConverter _$VideoCodecProfileTypeConverterFromJson( - Map json) { - return VideoCodecProfileTypeConverter( - _$enumDecode(_$VideoCodecProfileTypeEnumMap, json['e']), - ); -} + Map json) => + VideoCodecProfileTypeConverter( + $enumDecode(_$VideoCodecProfileTypeEnumMap, json['e']), + ); Map _$VideoCodecProfileTypeConverterToJson( VideoCodecProfileTypeConverter instance) => @@ -1135,11 +1064,10 @@ const _$VideoCodecProfileTypeEnumMap = { }; VideoFrameRateConverter _$VideoFrameRateConverterFromJson( - Map json) { - return VideoFrameRateConverter( - _$enumDecode(_$VideoFrameRateEnumMap, json['e']), - ); -} + Map json) => + VideoFrameRateConverter( + $enumDecode(_$VideoFrameRateEnumMap, json['e']), + ); Map _$VideoFrameRateConverterToJson( VideoFrameRateConverter instance) => @@ -1158,11 +1086,10 @@ const _$VideoFrameRateEnumMap = { VideoFrameRate.Fps60: 60, }; -BitRateConverter _$BitRateConverterFromJson(Map json) { - return BitRateConverter( - _$enumDecode(_$BitRateEnumMap, json['e']), - ); -} +BitRateConverter _$BitRateConverterFromJson(Map json) => + BitRateConverter( + $enumDecode(_$BitRateEnumMap, json['e']), + ); Map _$BitRateConverterToJson(BitRateConverter instance) => { @@ -1175,11 +1102,10 @@ const _$BitRateEnumMap = { }; VideoMirrorModeConverter _$VideoMirrorModeConverterFromJson( - Map json) { - return VideoMirrorModeConverter( - _$enumDecode(_$VideoMirrorModeEnumMap, json['e']), - ); -} + Map json) => + VideoMirrorModeConverter( + $enumDecode(_$VideoMirrorModeEnumMap, json['e']), + ); Map _$VideoMirrorModeConverterToJson( VideoMirrorModeConverter instance) => @@ -1194,11 +1120,10 @@ const _$VideoMirrorModeEnumMap = { }; VideoOutputOrientationModeConverter - _$VideoOutputOrientationModeConverterFromJson(Map json) { - return VideoOutputOrientationModeConverter( - _$enumDecode(_$VideoOutputOrientationModeEnumMap, json['e']), - ); -} + _$VideoOutputOrientationModeConverterFromJson(Map json) => + VideoOutputOrientationModeConverter( + $enumDecode(_$VideoOutputOrientationModeEnumMap, json['e']), + ); Map _$VideoOutputOrientationModeConverterToJson( VideoOutputOrientationModeConverter instance) => @@ -1213,11 +1138,10 @@ const _$VideoOutputOrientationModeEnumMap = { }; VideoQualityAdaptIndicationConverter - _$VideoQualityAdaptIndicationConverterFromJson(Map json) { - return VideoQualityAdaptIndicationConverter( - _$enumDecode(_$VideoQualityAdaptIndicationEnumMap, json['e']), - ); -} + _$VideoQualityAdaptIndicationConverterFromJson(Map json) => + VideoQualityAdaptIndicationConverter( + $enumDecode(_$VideoQualityAdaptIndicationEnumMap, json['e']), + ); Map _$VideoQualityAdaptIndicationConverterToJson( VideoQualityAdaptIndicationConverter instance) => @@ -1232,11 +1156,10 @@ const _$VideoQualityAdaptIndicationEnumMap = { }; VideoRemoteStateConverter _$VideoRemoteStateConverterFromJson( - Map json) { - return VideoRemoteStateConverter( - _$enumDecode(_$VideoRemoteStateEnumMap, json['e']), - ); -} + Map json) => + VideoRemoteStateConverter( + $enumDecode(_$VideoRemoteStateEnumMap, json['e']), + ); Map _$VideoRemoteStateConverterToJson( VideoRemoteStateConverter instance) => @@ -1253,11 +1176,10 @@ const _$VideoRemoteStateEnumMap = { }; VideoRemoteStateReasonConverter _$VideoRemoteStateReasonConverterFromJson( - Map json) { - return VideoRemoteStateReasonConverter( - _$enumDecode(_$VideoRemoteStateReasonEnumMap, json['e']), - ); -} + Map json) => + VideoRemoteStateReasonConverter( + $enumDecode(_$VideoRemoteStateReasonEnumMap, json['e']), + ); Map _$VideoRemoteStateReasonConverterToJson( VideoRemoteStateReasonConverter instance) => @@ -1279,11 +1201,10 @@ const _$VideoRemoteStateReasonEnumMap = { }; VideoRenderModeConverter _$VideoRenderModeConverterFromJson( - Map json) { - return VideoRenderModeConverter( - _$enumDecode(_$VideoRenderModeEnumMap, json['e']), - ); -} + Map json) => + VideoRenderModeConverter( + $enumDecode(_$VideoRenderModeEnumMap, json['e']), + ); Map _$VideoRenderModeConverterToJson( VideoRenderModeConverter instance) => @@ -1299,11 +1220,10 @@ const _$VideoRenderModeEnumMap = { }; VideoStreamTypeConverter _$VideoStreamTypeConverterFromJson( - Map json) { - return VideoStreamTypeConverter( - _$enumDecode(_$VideoStreamTypeEnumMap, json['e']), - ); -} + Map json) => + VideoStreamTypeConverter( + $enumDecode(_$VideoStreamTypeEnumMap, json['e']), + ); Map _$VideoStreamTypeConverterToJson( VideoStreamTypeConverter instance) => @@ -1316,11 +1236,11 @@ const _$VideoStreamTypeEnumMap = { VideoStreamType.Low: 1, }; -WarningCodeConverter _$WarningCodeConverterFromJson(Map json) { - return WarningCodeConverter( - _$enumDecode(_$WarningCodeEnumMap, json['e']), - ); -} +WarningCodeConverter _$WarningCodeConverterFromJson( + Map json) => + WarningCodeConverter( + $enumDecode(_$WarningCodeEnumMap, json['e']), + ); Map _$WarningCodeConverterToJson( WarningCodeConverter instance) => @@ -1364,11 +1284,10 @@ const _$WarningCodeEnumMap = { }; AudioChannelConverter _$AudioChannelConverterFromJson( - Map json) { - return AudioChannelConverter( - _$enumDecode(_$AudioChannelEnumMap, json['e']), - ); -} + Map json) => + AudioChannelConverter( + $enumDecode(_$AudioChannelEnumMap, json['e']), + ); Map _$AudioChannelConverterToJson( AudioChannelConverter instance) => @@ -1386,11 +1305,10 @@ const _$AudioChannelEnumMap = { }; VideoCodecTypeConverter _$VideoCodecTypeConverterFromJson( - Map json) { - return VideoCodecTypeConverter( - _$enumDecode(_$VideoCodecTypeEnumMap, json['e']), - ); -} + Map json) => + VideoCodecTypeConverter( + $enumDecode(_$VideoCodecTypeEnumMap, json['e']), + ); Map _$VideoCodecTypeConverterToJson( VideoCodecTypeConverter instance) => @@ -1406,11 +1324,10 @@ const _$VideoCodecTypeEnumMap = { }; StreamPublishStateConverter _$StreamPublishStateConverterFromJson( - Map json) { - return StreamPublishStateConverter( - _$enumDecode(_$StreamPublishStateEnumMap, json['e']), - ); -} + Map json) => + StreamPublishStateConverter( + $enumDecode(_$StreamPublishStateEnumMap, json['e']), + ); Map _$StreamPublishStateConverterToJson( StreamPublishStateConverter instance) => @@ -1426,11 +1343,10 @@ const _$StreamPublishStateEnumMap = { }; StreamSubscribeStateConverter _$StreamSubscribeStateConverterFromJson( - Map json) { - return StreamSubscribeStateConverter( - _$enumDecode(_$StreamSubscribeStateEnumMap, json['e']), - ); -} + Map json) => + StreamSubscribeStateConverter( + $enumDecode(_$StreamSubscribeStateEnumMap, json['e']), + ); Map _$StreamSubscribeStateConverterToJson( StreamSubscribeStateConverter instance) => @@ -1446,11 +1362,10 @@ const _$StreamSubscribeStateEnumMap = { }; RtmpStreamingEventConverter _$RtmpStreamingEventConverterFromJson( - Map json) { - return RtmpStreamingEventConverter( - _$enumDecode(_$RtmpStreamingEventEnumMap, json['e']), - ); -} + Map json) => + RtmpStreamingEventConverter( + $enumDecode(_$RtmpStreamingEventEnumMap, json['e']), + ); Map _$RtmpStreamingEventConverterToJson( RtmpStreamingEventConverter instance) => @@ -1465,11 +1380,10 @@ const _$RtmpStreamingEventEnumMap = { AudioSessionOperationRestrictionConverter _$AudioSessionOperationRestrictionConverterFromJson( - Map json) { - return AudioSessionOperationRestrictionConverter( - _$enumDecode(_$AudioSessionOperationRestrictionEnumMap, json['e']), - ); -} + Map json) => + AudioSessionOperationRestrictionConverter( + $enumDecode(_$AudioSessionOperationRestrictionEnumMap, json['e']), + ); Map _$AudioSessionOperationRestrictionConverterToJson( AudioSessionOperationRestrictionConverter instance) => @@ -1486,11 +1400,10 @@ const _$AudioSessionOperationRestrictionEnumMap = { }; AudioEffectPresetConverter _$AudioEffectPresetConverterFromJson( - Map json) { - return AudioEffectPresetConverter( - _$enumDecode(_$AudioEffectPresetEnumMap, json['e']), - ); -} + Map json) => + AudioEffectPresetConverter( + $enumDecode(_$AudioEffectPresetEnumMap, json['e']), + ); Map _$AudioEffectPresetConverterToJson( AudioEffectPresetConverter instance) => @@ -1521,11 +1434,10 @@ const _$AudioEffectPresetEnumMap = { }; VoiceBeautifierPresetConverter _$VoiceBeautifierPresetConverterFromJson( - Map json) { - return VoiceBeautifierPresetConverter( - _$enumDecode(_$VoiceBeautifierPresetEnumMap, json['e']), - ); -} + Map json) => + VoiceBeautifierPresetConverter( + $enumDecode(_$VoiceBeautifierPresetEnumMap, json['e']), + ); Map _$VoiceBeautifierPresetConverterToJson( VoiceBeautifierPresetConverter instance) => @@ -1550,11 +1462,10 @@ const _$VoiceBeautifierPresetEnumMap = { }; AudienceLatencyLevelTypeConverter _$AudienceLatencyLevelTypeConverterFromJson( - Map json) { - return AudienceLatencyLevelTypeConverter( - _$enumDecode(_$AudienceLatencyLevelTypeEnumMap, json['e']), - ); -} + Map json) => + AudienceLatencyLevelTypeConverter( + $enumDecode(_$AudienceLatencyLevelTypeEnumMap, json['e']), + ); Map _$AudienceLatencyLevelTypeConverterToJson( AudienceLatencyLevelTypeConverter instance) => @@ -1567,11 +1478,10 @@ const _$AudienceLatencyLevelTypeEnumMap = { AudienceLatencyLevelType.UltraLowLatency: 2, }; -LogLevelConverter _$LogLevelConverterFromJson(Map json) { - return LogLevelConverter( - _$enumDecode(_$LogLevelEnumMap, json['e']), - ); -} +LogLevelConverter _$LogLevelConverterFromJson(Map json) => + LogLevelConverter( + $enumDecode(_$LogLevelEnumMap, json['e']), + ); Map _$LogLevelConverterToJson(LogLevelConverter instance) => { @@ -1587,11 +1497,10 @@ const _$LogLevelEnumMap = { }; CaptureBrightnessLevelTypeConverter - _$CaptureBrightnessLevelTypeConverterFromJson(Map json) { - return CaptureBrightnessLevelTypeConverter( - _$enumDecode(_$CaptureBrightnessLevelTypeEnumMap, json['e']), - ); -} + _$CaptureBrightnessLevelTypeConverterFromJson(Map json) => + CaptureBrightnessLevelTypeConverter( + $enumDecode(_$CaptureBrightnessLevelTypeEnumMap, json['e']), + ); Map _$CaptureBrightnessLevelTypeConverterToJson( CaptureBrightnessLevelTypeConverter instance) => @@ -1607,11 +1516,10 @@ const _$CaptureBrightnessLevelTypeEnumMap = { }; SuperResolutionStateReasonConverter - _$SuperResolutionStateReasonConverterFromJson(Map json) { - return SuperResolutionStateReasonConverter( - _$enumDecode(_$SuperResolutionStateReasonEnumMap, json['e']), - ); -} + _$SuperResolutionStateReasonConverterFromJson(Map json) => + SuperResolutionStateReasonConverter( + $enumDecode(_$SuperResolutionStateReasonEnumMap, json['e']), + ); Map _$SuperResolutionStateReasonConverterToJson( SuperResolutionStateReasonConverter instance) => @@ -1627,11 +1535,10 @@ const _$SuperResolutionStateReasonEnumMap = { }; UploadErrorReasonConverter _$UploadErrorReasonConverterFromJson( - Map json) { - return UploadErrorReasonConverter( - _$enumDecode(_$UploadErrorReasonEnumMap, json['e']), - ); -} + Map json) => + UploadErrorReasonConverter( + $enumDecode(_$UploadErrorReasonEnumMap, json['e']), + ); Map _$UploadErrorReasonConverterToJson( UploadErrorReasonConverter instance) => @@ -1646,11 +1553,10 @@ const _$UploadErrorReasonEnumMap = { }; CloudProxyTypeConverter _$CloudProxyTypeConverterFromJson( - Map json) { - return CloudProxyTypeConverter( - _$enumDecode(_$CloudProxyTypeEnumMap, json['e']), - ); -} + Map json) => + CloudProxyTypeConverter( + $enumDecode(_$CloudProxyTypeEnumMap, json['e']), + ); Map _$CloudProxyTypeConverterToJson( CloudProxyTypeConverter instance) => @@ -1665,11 +1571,10 @@ const _$CloudProxyTypeEnumMap = { }; ExperienceQualityTypeConverter _$ExperienceQualityTypeConverterFromJson( - Map json) { - return ExperienceQualityTypeConverter( - _$enumDecode(_$ExperienceQualityTypeEnumMap, json['e']), - ); -} + Map json) => + ExperienceQualityTypeConverter( + $enumDecode(_$ExperienceQualityTypeEnumMap, json['e']), + ); Map _$ExperienceQualityTypeConverterToJson( ExperienceQualityTypeConverter instance) => @@ -1683,11 +1588,10 @@ const _$ExperienceQualityTypeEnumMap = { }; ExperiencePoorReasonConverter _$ExperiencePoorReasonConverterFromJson( - Map json) { - return ExperiencePoorReasonConverter( - _$enumDecode(_$ExperiencePoorReasonEnumMap, json['e']), - ); -} + Map json) => + ExperiencePoorReasonConverter( + $enumDecode(_$ExperiencePoorReasonEnumMap, json['e']), + ); Map _$ExperiencePoorReasonConverterToJson( ExperiencePoorReasonConverter instance) => @@ -1704,11 +1608,10 @@ const _$ExperiencePoorReasonEnumMap = { }; VoiceConversionPresetConverter _$VoiceConversionPresetConverterFromJson( - Map json) { - return VoiceConversionPresetConverter( - _$enumDecode(_$VoiceConversionPresetEnumMap, json['e']), - ); -} + Map json) => + VoiceConversionPresetConverter( + $enumDecode(_$VoiceConversionPresetEnumMap, json['e']), + ); Map _$VoiceConversionPresetConverterToJson( VoiceConversionPresetConverter instance) => @@ -1725,11 +1628,10 @@ const _$VoiceConversionPresetEnumMap = { }; VirtualBackgroundSourceTypeConverter - _$VirtualBackgroundSourceTypeConverterFromJson(Map json) { - return VirtualBackgroundSourceTypeConverter( - _$enumDecode(_$VirtualBackgroundSourceTypeEnumMap, json['e']), - ); -} + _$VirtualBackgroundSourceTypeConverterFromJson(Map json) => + VirtualBackgroundSourceTypeConverter( + $enumDecode(_$VirtualBackgroundSourceTypeEnumMap, json['e']), + ); Map _$VirtualBackgroundSourceTypeConverterToJson( VirtualBackgroundSourceTypeConverter instance) => @@ -1744,11 +1646,10 @@ const _$VirtualBackgroundSourceTypeEnumMap = { }; VirtualBackgroundBlurDegreeConverter - _$VirtualBackgroundBlurDegreeConverterFromJson(Map json) { - return VirtualBackgroundBlurDegreeConverter( - _$enumDecode(_$VirtualBackgroundBlurDegreeEnumMap, json['e']), - ); -} + _$VirtualBackgroundBlurDegreeConverterFromJson(Map json) => + VirtualBackgroundBlurDegreeConverter( + $enumDecode(_$VirtualBackgroundBlurDegreeEnumMap, json['e']), + ); Map _$VirtualBackgroundBlurDegreeConverterToJson( VirtualBackgroundBlurDegreeConverter instance) => @@ -1764,11 +1665,10 @@ const _$VirtualBackgroundBlurDegreeEnumMap = { VirtualBackgroundSourceStateReasonConverter _$VirtualBackgroundSourceStateReasonConverterFromJson( - Map json) { - return VirtualBackgroundSourceStateReasonConverter( - _$enumDecode(_$VirtualBackgroundSourceStateReasonEnumMap, json['e']), - ); -} + Map json) => + VirtualBackgroundSourceStateReasonConverter( + $enumDecode(_$VirtualBackgroundSourceStateReasonEnumMap, json['e']), + ); Map _$VirtualBackgroundSourceStateReasonConverterToJson( VirtualBackgroundSourceStateReasonConverter instance) => diff --git a/lib/src/enums.dart b/lib/src/enums.dart index b155f4fb3..a8eebe093 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -137,7 +137,6 @@ enum AudioLocalState { /// The information acquisition state enum AudioFileInfoError { - /// Successfully get the information of an audio file. @JsonValue(0) Ok, @@ -232,20 +231,20 @@ enum AudioMixingDualMonoMode { @JsonValue(0) Auto, - /// 1: Left channel mode. This mode replaces the audio of the right channel - /// with the audio of the left channel, which means the user can only hear the + /// 1: Left channel mode. This mode replaces the audio of the right channel + /// with the audio of the left channel, which means the user can only hear the /// audio of the left channel. @JsonValue(1) L, - /// 2: Right channel mode. This mode replaces the audio of the left channel - /// with the audio of the right channel, which means the user can only hear the + /// 2: Right channel mode. This mode replaces the audio of the left channel + /// with the audio of the right channel, which means the user can only hear the /// audio of the right channel. @JsonValue(2) R, - /// 3: Mixed channel mode. This mode mixes the audio of the left channel and the - /// right channel, which means the user can hear the audio of the left channel + /// 3: Mixed channel mode. This mode mixes the audio of the left channel and the + /// right channel, which means the user can hear the audio of the left channel /// and the right channel at the same time. @JsonValue(3) MIX, @@ -2617,17 +2616,17 @@ enum VirtualBackgroundSourceType { /// The degree of blurring applied to the custom background image enum VirtualBackgroundBlurDegree { - /// The degree of blurring applied to the custom background image is low. The + /// The degree of blurring applied to the custom background image is low. The /// user can almost see the background clearly. @JsonValue(1) Low, - /// The degree of blurring applied to the custom background image is medium. + /// The degree of blurring applied to the custom background image is medium. /// It is difficult for the user to recognize details in the background. @JsonValue(2) Medium, - /// (Default) The degree of blurring applied to the custom background image is + /// (Default) The degree of blurring applied to the custom background image is /// high. The user can barely see any distinguishing features in the background. @JsonValue(3) High, diff --git a/lib/src/events.dart b/lib/src/events.dart index 682cc81ae..3a584360d 100644 --- a/lib/src/events.dart +++ b/lib/src/events.dart @@ -166,6 +166,9 @@ typedef UploadLogResultCallback = void Function( // ignore: public_member_api_docs typedef VirtualBackgroundSourceEnabledCallback = void Function( bool enabled, VirtualBackgroundSourceStateReason reason); +// ignore: public_member_api_docs +typedef SnapshotTakenCallback = void Function(String channel, int uid, + String filePath, int width, int height, int errCode); /// The SDK uses the [RtcEngineEventHandler] class to send callbacks to the application, and the application inherits the methods of this class to retrieve these callbacks. /// @@ -1048,6 +1051,29 @@ class RtcEngineEventHandler { /// - [VirtualBackgroundSourceStateReason] `reason`: The reason why the virtual background is not successfully enabled or the message that confirms success. See [VirtualBackgroundSourceStateReason]. VirtualBackgroundSourceEnabledCallback? virtualBackgroundSourceEnabled; + /// Reports the result of taking a video snapshot. + /// + /// Since + /// v3.5.2 + /// After a successful takeSnapshot method call, the SDK triggers this callback + /// to report whether the snapshot is successfully taken as well as the details + /// for the snapshot taken. + /// + /// Parameters + /// - channel The channel name. + /// - uid The user ID of the user. A uid of 0 indicates the local user. + /// - filePath The local path of the snapshot. + /// - width The width (px) of the snapshot. + /// - height The height (px) of the snapshot. + /// - errCode The message that confirms success or the reason why the snapshot + /// is not successfully taken: + /// - 0: Success. + /// - < 0: Failure. + /// - -1: The SDK fails to write data to a file or encode a JPEG image. + /// - -2: The SDK does not find the video stream of the specified user within + /// one second after the takeSnapshot method call succeeds. + SnapshotTakenCallback? snapshotTaken; + /// Constructs a [RtcEngineEventHandler] RtcEngineEventHandler({ this.warning, @@ -1132,6 +1158,7 @@ class RtcEngineEventHandler { this.uploadLogResult, this.airPlayIsConnected, this.virtualBackgroundSourceEnabled, + this.snapshotTaken, }); // ignore: public_member_api_docs @@ -1461,6 +1488,10 @@ class RtcEngineEventHandler { virtualBackgroundSourceEnabled?.call(data[0], VirtualBackgroundSourceStateReasonConverter.fromValue(data[1]).e); break; + case 'SnapshotTaken': + snapshotTaken?.call( + data[0], data[1], data[2], data[3], data[4], data[5]); + break; } } } diff --git a/lib/src/rtc_engine.dart b/lib/src/rtc_engine.dart index c07a58a05..2190f0d6d 100644 --- a/lib/src/rtc_engine.dart +++ b/lib/src/rtc_engine.dart @@ -1051,9 +1051,13 @@ class RtcEngine with RtcEngineInterface { } @override - Future startEchoTest(int intervalInSeconds) { + Future startEchoTest( + {int? intervalInSeconds, EchoTestConfiguration? config}) { + assert(intervalInSeconds == null || config == null, + 'Only need one of the params'); return _invokeMethod('startEchoTest', { 'intervalInSeconds': intervalInSeconds, + 'config': config?.toJson(), }); } @@ -1296,6 +1300,15 @@ class RtcEngine with RtcEngineInterface { 'backgroundSource': backgroundSource.toJson(), }); } + + @override + Future takeSnapshot(String channel, int uid, String filePath) { + return _invokeMethod('takeSnapshot', { + 'channel': channel, + 'uid': uid, + 'filePath': filePath, + }); + } } /// @nodoc @@ -1634,6 +1647,29 @@ mixin RtcEngineInterface /// - Kirin 900 series 980 and later Future enableVirtualBackground( bool enabled, VirtualBackgroundSource backgroundSource); + + /// Takes a snapshot of a video stream. + /// + /// Since + /// v3.5.2 + /// + /// This method takes a snapshot of a video stream from the specified user, generates a JPG image, and saves it to the specified path. + /// + /// The method is asynchronous, and the SDK has not taken the snapshot when the method call returns. After a successful method call, the SDK triggers the onSnapshotTaken callback to report whether the snapshot is successfully taken as well as the details of the snapshot taken. + /// + /// Note + /// - Call this method after joining a channel. + /// - If the video of the specified user is pre-processed, for example, added with watermarks or image enhancement effects, the generated snapshot also includes the pre-processing effects. + /// + /// Parameters + /// - channel The channel name. + /// - uid The user ID of the user. Set uid as 0 if you want to take a snapshot of the local user's video. + /// - filePath The local path (including the filename extensions) for the snapshot. For example, /storage/emulated/0/Android/data//files/example.jpg. Ensure that the path you specify exists and is writable. + /// + /// Returns + /// - 0: Success. + /// - < 0: Failure. + Future takeSnapshot(String channel, int uid, String filePath); } /// @nodoc @@ -2976,7 +3012,10 @@ mixin RtcTestInterface { /// - In the [ChannelProfile.LiveBroadcasting] profile, only a host can call this method. /// /// **Parameter** [intervalInSeconds] The time interval (s) between when you speak and when the recording plays back. - Future startEchoTest(int intervalInSeconds); + /// + /// **Parameter** [config] The configuration of the audio and video call loop test. See [EchoTestConfiguration]. + Future startEchoTest( + {int? intervalInSeconds, EchoTestConfiguration? config}); /// Stops the audio call test. Future stopEchoTest(); diff --git a/pubspec.yaml b/pubspec.yaml index 067c47a9a..cac24e014 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - json_annotation: ^4.0.0 + json_annotation: ^4.4.0 dev_dependencies: integration_test: sdk: flutter @@ -23,7 +23,7 @@ dev_dependencies: sdk: flutter pedantic: ^1.11.0 build_runner: ^1.11.5 - json_serializable: ^4.0.2 + json_serializable: ^6.1.1 flutter: plugin: platforms: