Add CallVC

pull/560/head
Niels Andriesse 3 years ago
parent 4fd720cbc9
commit 32426f9005

@ -250,6 +250,7 @@
B8B558EF26C4B56C00693325 /* VideoCallVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8B558EE26C4B56C00693325 /* VideoCallVC.swift */; };
B8B558F126C4BB0600693325 /* CameraManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8B558F026C4BB0600693325 /* CameraManager.swift */; };
B8B558F326C4CA4600693325 /* MockCallConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8B558F226C4CA4600693325 /* MockCallConfig.swift */; };
B8B558F926C4CE6800693325 /* CallVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8B558F826C4CE6800693325 /* CallVC.swift */; };
B8BB82A5238F627000BA5194 /* HomeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8BB82A4238F627000BA5194 /* HomeVC.swift */; };
B8BC00C0257D90E30032E807 /* General.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8BC00BF257D90E30032E807 /* General.swift */; };
B8C2B2C82563685C00551B4D /* CircleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8C2B2C72563685C00551B4D /* CircleView.swift */; };
@ -1221,6 +1222,7 @@
B8B558EE26C4B56C00693325 /* VideoCallVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoCallVC.swift; sourceTree = "<group>"; };
B8B558F026C4BB0600693325 /* CameraManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraManager.swift; sourceTree = "<group>"; };
B8B558F226C4CA4600693325 /* MockCallConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockCallConfig.swift; sourceTree = "<group>"; };
B8B558F826C4CE6800693325 /* CallVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallVC.swift; sourceTree = "<group>"; };
B8B5BCEB2394D869003823C9 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = "<group>"; };
B8BAC75B2695645400EA1759 /* hr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hr; path = hr.lproj/Localizable.strings; sourceTree = "<group>"; };
B8BAC75C2695648500EA1759 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = "<group>"; };
@ -2321,6 +2323,7 @@
B8B558ED26C4B55F00693325 /* Calls */ = {
isa = PBXGroup;
children = (
B8B558F826C4CE6800693325 /* CallVC.swift */,
B8B558EE26C4B56C00693325 /* VideoCallVC.swift */,
B8B558F026C4BB0600693325 /* CameraManager.swift */,
);
@ -4858,6 +4861,7 @@
B80A579F23DFF1F300876683 /* NewClosedGroupVC.swift in Sources */,
D221A09A169C9E5E00537ABF /* main.m in Sources */,
3496957221A301A100DCFE74 /* OWSBackup.m in Sources */,
B8B558F926C4CE6800693325 /* CallVC.swift in Sources */,
B835247925C38D880089A44F /* MessageCell.swift in Sources */,
B86BD08623399CEF000F5AE3 /* SeedModal.swift in Sources */,
34E3E5681EC4B19400495BAC /* AudioProgressView.swift in Sources */,

@ -0,0 +1,73 @@
import UIKit
import AVFoundation
import WebRTC
final class MainChatRoomViewController : UIViewController, CameraCaptureDelegate, CallManagerDelegate {
// MARK: UI Components
private lazy var previewView: UIImageView = {
return UIImageView()
}()
private lazy var containerView: UIView = {
return UIView()
}()
private lazy var joinButton: UIButton = {
let result = UIButton()
result.setTitle("Join", for: UIControl.State.normal)
return result
}()
private lazy var roomNumberTextField: UITextField = {
return UITextField()
}()
private lazy var infoTextView: UITextView = {
return UITextView()
}()
// MARK: Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
setUpCamera()
}
private func setUpCamera() {
CameraManager.shared.delegate = self
CameraManager.shared.prepare()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
CameraManager.shared.start()
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
CameraManager.shared.stop()
}
// MARK: Streaming
func callManager(_ callManager: CallManager, sendData data: Data) {
// TODO: Implement
}
// MARK: Camera
func captureVideoOutput(sampleBuffer: CMSampleBuffer) {
guard let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }
let ciImage = CIImage(cvImageBuffer: pixelBuffer)
let image = UIImage(ciImage: ciImage)
DispatchQueue.main.async { [weak self] in
self?.previewView.image = image
}
}
// MARK: Logging
private func log(string: String) {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
self.infoTextView.text = self.infoTextView.text + "\n" + string
}
}
}

@ -2,7 +2,7 @@ import UIKit
import AVFoundation
import WebRTC
class VideoCallVC : UIViewController {
final class VideoCallVC : UIViewController {
private var localVideoView: UIView!
private var remoteVideoView: UIView!

@ -1,8 +1,14 @@
import PromiseKit
import WebRTC
public protocol CallManagerDelegate : AnyObject {
func callManager(_ callManager: CallManager, sendData data: Data)
}
/// See https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription for more information.
public final class CallManager : NSObject, RTCPeerConnectionDelegate {
public weak var delegate: CallManagerDelegate?
internal lazy var factory: RTCPeerConnectionFactory = {
RTCInitializeSSL()

Loading…
Cancel
Save