From 374f3e987fe2f0c51f81865e9fb3f6812f6defbc Mon Sep 17 00:00:00 2001 From: HUI Date: Thu, 15 Oct 2020 20:21:19 +0800 Subject: [PATCH 1/2] feat: iOS raw data plugin --- RtcEngine.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/RtcEngine.swift b/RtcEngine.swift index ba0e3009b..1d40ca5ee 100644 --- a/RtcEngine.swift +++ b/RtcEngine.swift @@ -67,6 +67,8 @@ protocol RtcEngineInterface: func setLogFileSize(_ params: NSDictionary, _ callback: Callback) func setParameters(_ params: NSDictionary, _ callback: Callback) + + func getNativeHandle(_ callback: Callback) } protocol RtcEngineUserInfoInterface { @@ -433,6 +435,12 @@ class RtcEngineManager: NSObject, RtcEngineInterface { @objc func setLogFileSize(_ params: NSDictionary, _ callback: Callback) { callback.code(engine?.setLogFileSize((params["fileSizeInKBytes"] as! UInt))) } + + @objc func getNativeHandle(_ callback: Callback) { + callback.resolve(engine) { it in + Int(bitPattern: it.getNativeHandle()) + } + } @objc func setParameters(_ params: NSDictionary, _ callback: Callback) { callback.code(engine?.setParameters(params["parameters"] as! String)) From 12e25618ce8fabd5bf9b34e418792450518e219e Mon Sep 17 00:00:00 2001 From: HUI Date: Thu, 17 Dec 2020 14:07:21 +0800 Subject: [PATCH 2/2] fix: some rendering problems when change render widget order --- RtcSurfaceView.swift | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/RtcSurfaceView.swift b/RtcSurfaceView.swift index e5181ec90..cd69a26b7 100644 --- a/RtcSurfaceView.swift +++ b/RtcSurfaceView.swift @@ -11,15 +11,26 @@ import UIKit import AgoraRtcKit class RtcSurfaceView: UIView { - private lazy var canvas: AgoraRtcVideoCanvas = { - var canvas = AgoraRtcVideoCanvas() - canvas.view = self - return canvas - }() + private var surface: UIView + private var canvas: AgoraRtcVideoCanvas private weak var channel: AgoraRtcChannel? - - func destroy() { + + override init(frame: CGRect) { + surface = UIView(frame: frame) + canvas = AgoraRtcVideoCanvas() + canvas.view = surface + super.init(frame: frame) + addSubview(surface) + addObserver(self, forKeyPath: "frame", options: .new, context: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + deinit { canvas.view = nil + removeObserver(self, forKeyPath: "frame", context: nil) } func setData(_ engine: AgoraRtcEngineKit, _ channel: AgoraRtcChannel?, _ uid: Int) { @@ -45,6 +56,10 @@ class RtcSurfaceView: UIView { } private func setupVideoCanvas(_ engine: AgoraRtcEngineKit) { + subviews.forEach { $0.removeFromSuperview() } + surface = UIView(frame: self.frame) + addSubview(surface) + canvas.view = surface if canvas.uid == 0 { engine.setupLocalVideo(canvas) } else { @@ -73,4 +88,10 @@ class RtcSurfaceView: UIView { } } } + + override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { + if keyPath == "frame" { + surface.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height) + } + } }