kevin преди 5 месеца
родител
ревизия
fb44c3febf

+ 2 - 1
ExampleCode/ExampleCode/ViewController.swift

@@ -24,7 +24,8 @@ class ViewController: UIViewController, ConnectDelegate {
     override func viewDidLoad() {
         super.viewDidLoad()
         
-        APIS.connect(appName: "ps29ios" ,apiKey: "31D080A9F46FBCAAE18F122B8C621CAC2994151978DD3D9BEBD01EB927EE840C", delegate: self, showButton: true)
+        APIS.connect(appName: "esApp" ,apiKey: "FE44324020F0F0196F29D86987B63047D58E546BA8CE5E349F0F5058041C40A7", delegate: self, showButton: true)
+//        "ps29ios" ,apiKey: "31D080A9F46FBCAAE18F122B8C621CAC2994151978DD3D9BEBD01EB927EE840C"
         //"OneApp","38747683290F62E9667A018F490396EAE47BC16ADECD85B7E865C733E6DBD6A2"
     }
     

+ 10 - 0
NexilisLite/NexilisLite/Source/CoreMessage_TMessageBank.swift

@@ -1282,6 +1282,16 @@ public class CoreMessage_TMessageBank {
         tmessage.mBodies[CoreMessage_TMessageKey.BROADCAST_ID] = blog_id
         return tmessage
     }
+    public static func inviteVCallConference(f_pin: String, blog_id:String) -> TMessage {
+        let me = User.getMyPin()!
+        let tmessage = TMessage()
+        tmessage.mCode = CoreMessage_TMessageCode.VC_ROOM_INVITE;
+        tmessage.mPIN = me
+        tmessage.mStatus = CoreMessage_TMessageUtil.getTID()
+        tmessage.mBodies[CoreMessage_TMessageKey.L_PIN] = f_pin
+        tmessage.mBodies[CoreMessage_TMessageKey.BLOG_ID] = blog_id
+        return tmessage
+    }
     public static func getVersionCheck() -> TMessage {
         let me = User.getMyPin()!
         let tmessage = TMessage()

+ 3 - 2
NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -2320,7 +2320,7 @@ extension Nexilis: CallDelegate {
                     isShowAlert = 0
                 }
             }
-            if (state == Nexilis.AUDIO_CALL_INCOMING && message.split(separator: ",")[1] != "joining Ac.room on channel 0") {
+            if (state == Nexilis.AUDIO_CALL_INCOMING && message.split(separator: ",")[1] != "joining Ac.room on channel 0" && message.split(separator: ",")[1] != "joining Vc.room on channel 0") {
                 if Nexilis.callAPNActivated || APIS.checkAppStateisBackground() {
                     return
                 }
@@ -2357,10 +2357,11 @@ extension Nexilis: CallDelegate {
                     UIApplication.shared.visibleViewController?.present(controller, animated: true, completion: nil)
                 }
 //                    API.receiveCCall(sParty: String(deviceId))
-            } else if state == Nexilis.VIDEO_CALL_INCOMING {
+            } else if (state == Nexilis.VIDEO_CALL_INCOMING && message.split(separator: ",")[1] != "joining Ac.room on channel 0" && message.split(separator: ",")[1] != "joining Vc.room on channel 0") {
                 if Nexilis.callAPNActivated || APIS.checkAppStateisBackground() {
                     return
                 }
+                print("DATA: \(message)")
                 let dataUser = User.getDataCanNil(pin: String(deviceId))
                 if dataUser == nil {
                     DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {

+ 37 - 15
NexilisLite/NexilisLite/Source/View/Call/VideoConferenceViewController.swift

@@ -24,6 +24,9 @@ class VideoConferenceViewController: UIViewController {
     var isPresent = false
     var callFCM = false
     var listRemoteViewFix: [UIImageView] = [
+        UIImageView(),
+        UIImageView(),
+        UIImageView(),
         UIImageView(),
         UIImageView(),
         UIImageView(),
@@ -31,6 +34,9 @@ class VideoConferenceViewController: UIViewController {
         UIImageView()
     ]
     var containerLabelName: [UIView] = [
+        UIView(),
+        UIView(),
+        UIView(),
         UIView(),
         UIView(),
         UIView(),
@@ -70,6 +76,7 @@ class VideoConferenceViewController: UIViewController {
     var roomId = ""
     var isCalled = false
     private var frontCamera = true
+    var timerCR : Timer?
     var users: [User] = []
     let poweredByView: UIStackView = {
         let stackView = UIStackView()
@@ -117,7 +124,7 @@ class VideoConferenceViewController: UIViewController {
         navigationController?.navigationBar.setBackgroundImage(nil, for: .default)
         navigationController?.navigationBar.shadowImage = nil
         navigationController?.navigationBar.isTranslucent = false
-//        navigationController?.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
+        navigationController?.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
         navigationController?.navigationBar.titleTextAttributes = textAttributes
         navigationController?.navigationBar.topItem?.backBarButtonItem = nil
@@ -130,7 +137,7 @@ class VideoConferenceViewController: UIViewController {
             navigationController?.navigationBar.setBackgroundImage(nil, for: .default)
             navigationController?.navigationBar.shadowImage = nil
             navigationController?.navigationBar.isTranslucent = false
-//            navigationController?.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
+            navigationController?.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
             navigationController?.navigationBar.titleTextAttributes = textAttributes
             navigationController?.navigationBar.topItem?.backBarButtonItem = nil
@@ -165,19 +172,13 @@ class VideoConferenceViewController: UIViewController {
         addListRemoteView()
         addTimerVC()
         didTapAcceptCallButton()
-        print("Room id: \(roomId)")
-        print("is initiatior \(isInisiator)")
-        print(listRemoteViewFix)
-        print(cameraView)
-        print(zoomView)
         do {
             if isInisiator && !isCalled {
-                API.initiateCR(sConfRoom: roomId, nCamIdx: 1, nResIdx: 2, nVQuality: 4, ivRemoteView: listRemoteViewFix, ivLocalView: cameraView, ivRemoteZ: zoomView)
-                Nexilis.write(message: CoreMessage_TMessageBank.startVCallConference(blog_id: roomId, time: "\(Date().currentTimeMillis())"))
+                
+                _ = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(initiateConfRoom), userInfo: nil, repeats: false)
             }
             else if !isCalled {
-                API.joinCR(sConfRoom: roomId, nCamIdx: 1, nResIdx: 2, nVQuality: 4, ivRemoteView: listRemoteViewFix, ivLocalView: cameraView, ivRemoteZ: zoomView)
-                Nexilis.write(message: CoreMessage_TMessageBank.joinVCallConference(blog_id: roomId))
+                _ = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(joinConfRoom), userInfo: nil, repeats: false)
             }
             isCalled = true
         } catch {
@@ -195,6 +196,16 @@ class VideoConferenceViewController: UIViewController {
         
     }
     
+    @objc func initiateConfRoom(){
+        API.initiateCR(sConfRoom: roomId, nCamIdx: 1, nResIdx: 0, nVQuality: 0, ivRemoteView: listRemoteViewFix, ivLocalView: cameraView, ivRemoteZ: zoomView)
+        Nexilis.write(message: CoreMessage_TMessageBank.startVCallConference(blog_id: roomId, time: "\(Date().currentTimeMillis())"))
+    }
+    
+    @objc func joinConfRoom(){
+        API.joinCR(sConfRoom: roomId, nCamIdx: 1, nResIdx: 0, nVQuality: 0, ivRemoteView: listRemoteViewFix, ivLocalView: cameraView, ivRemoteZ: zoomView)
+        Nexilis.write(message: CoreMessage_TMessageBank.joinVCallConference(blog_id: roomId))
+    }
+    
     func getDataProfile(fPin: String) {
         let query = "SELECT f_pin, first_name, last_name, official_account, image_id, device_id, offline_mode, user_type FROM BUDDY where f_pin = '\(fPin)'"
         Database.shared.database?.inTransaction({ (fmdb, rollback) in
@@ -282,7 +293,7 @@ class VideoConferenceViewController: UIViewController {
             zoomView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
             zoomView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
         ])
-        zoomView.backgroundColor = .black
+        zoomView.backgroundColor = .secondaryColor
         zoomView.isUserInteractionEnabled = true
         zoomView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(hideToolbar)))
     }
@@ -915,6 +926,7 @@ class VideoConferenceViewController: UIViewController {
 //            }
 //        }
         _ = Nexilis.write(message: CoreMessage_TMessageBank.endVCallConference(blog_id: roomId))
+        API.terminateCall(sParty: nil)
         cameraView.image = nil
         zoomView.image = nil
         listRemoteViewFix.removeAll()
@@ -957,7 +969,7 @@ class VideoConferenceViewController: UIViewController {
                 } else {
                     DispatchQueue.main.async {
                         self.dataPerson.append(data)
-                        API.initiateCCall(sParty: data["f_pin"]!, nCamIdx: 1, nResIdx: 2, nVQuality: 4, ivRemoteView: self.listRemoteViewFix, ivLocalView: self.cameraView, ivRemoteZ: self.zoomView)
+                        _ = Nexilis.write(message: CoreMessage_TMessageBank.inviteVCallConference(f_pin: data["f_pin"]!!, blog_id: self.roomId))
                     }
                 }
             }
@@ -967,10 +979,10 @@ class VideoConferenceViewController: UIViewController {
     
     @objc func camera(sender: Any?) {
         if frontCamera {
-            API.changeCameraParam(nCameraIdx: 0, nResolutionIndex: 2, nQuality: 4)
+            API.changeCameraParam(nCameraIdx: 0, nResolutionIndex: 0, nQuality: 0)
             frontCamera = false
         } else {
-            API.changeCameraParam(nCameraIdx: 1, nResolutionIndex: 2, nQuality: 4)
+            API.changeCameraParam(nCameraIdx: 1, nResolutionIndex: 0, nQuality: 0)
             frontCamera = true
         }
     }
@@ -1002,6 +1014,16 @@ class VideoConferenceViewController: UIViewController {
         var remoteChannel = [String:String]()
         let arrayMessage = message.split(separator: ",")
         print(state)
+        if (state == Nexilis.VIDEO_CALL_END) {
+            DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
+                self.endAllCall()
+                if self.isInisiator && !self.isPresent {
+                    self.navigationController?.popViewController(animated: true)
+                } else {
+                    self.dismiss(animated: true, completion: nil)
+                }
+            }
+        }
     }
     
     @objc func onStatusCall2(_ notification: NSNotification) {

+ 10 - 1
NexilisLite/NexilisLite/Source/View/Streaming/CreateSeminarViewController.swift

@@ -330,7 +330,16 @@ public class CreateSeminarViewController: UITableViewController {
             controller.roomId = data["blog"] as! String
         }
 //       TODO: navigationController?.show(controller, sender: nil)
-        navigationController?.show(controller, sender: nil)
+        if !controller.isInisiator {
+            var stack = navigationController?.viewControllers
+            stack!.remove(at: (stack!.count) - 1)
+            stack!.insert(controller, at: stack!.count)
+            navigationController?.setViewControllers(stack!, animated: true)
+        }
+        else {
+            navigationController?.show(controller, sender: nil)
+        }
+//        navigationController?.show(controller, sender: nil)
 //        navigationController?.dismiss(animated: true, completion: nil)
     }