Use the new LinphoneVideoViewHolder to display call video & call preview
This commit is contained in:
@@ -9,33 +9,9 @@
|
||||
import SwiftUI
|
||||
import linphonesw
|
||||
|
||||
struct LinphoneVideoView: UIViewRepresentable {
|
||||
var core:Core
|
||||
private let _view = UIView()
|
||||
|
||||
func makeUIView(context: Context) -> UIView {
|
||||
core.nativeVideoWindowId = UnsafeMutableRawPointer(Unmanaged.passRetained(_view).toOpaque())
|
||||
return _view
|
||||
}
|
||||
|
||||
func updateUIView(_ uiView: UIView, context: Context) {}
|
||||
}
|
||||
|
||||
struct LinphoneVideoPreview: UIViewRepresentable {
|
||||
var core:Core
|
||||
private let _view = UIView()
|
||||
|
||||
func makeUIView(context: Context) -> UIView {
|
||||
core.nativePreviewWindowId = UnsafeMutableRawPointer(Unmanaged.passRetained(_view).toOpaque())
|
||||
return _view
|
||||
}
|
||||
|
||||
func updateUIView(_ uiView: UIView, context: Context) {}
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
|
||||
@ObservedObject var tutorialContext = VideoCallExample()
|
||||
@ObservedObject var tutorialContext : VideoCallExample
|
||||
|
||||
func getCallButtonText() -> String
|
||||
{
|
||||
@@ -120,7 +96,8 @@ struct ContentView: View {
|
||||
}
|
||||
})
|
||||
{
|
||||
Text(getCallButtonText())
|
||||
|
||||
Text(getCallButtonText())
|
||||
.font(.largeTitle)
|
||||
.foregroundColor(Color.white)
|
||||
.frame(width: 180.0, height: 42.0)
|
||||
@@ -142,11 +119,20 @@ struct ContentView: View {
|
||||
.padding(.top)
|
||||
}
|
||||
HStack {
|
||||
LinphoneVideoView(core: tutorialContext.mCore).frame(width: 150, height: 210).border(Color.gray).padding(.leading)
|
||||
LinphoneVideoViewHolder() { view in
|
||||
self.tutorialContext.mCore.nativeVideoWindowId = UnsafeMutableRawPointer(Unmanaged.passRetained(view).toOpaque())
|
||||
}
|
||||
.frame(width: 150, height: 210)
|
||||
.border(Color.gray)
|
||||
.padding(.leading)
|
||||
Spacer()
|
||||
LinphoneVideoPreview(core: tutorialContext.mCore).frame(width: 120, height: 160).border(Color.gray).padding(.horizontal)
|
||||
LinphoneVideoViewHolder() { view in
|
||||
self.tutorialContext.mCore.nativePreviewWindowId = UnsafeMutableRawPointer(Unmanaged.passRetained(view).toOpaque())
|
||||
}
|
||||
.frame(width: 90, height: 120)
|
||||
.border(Color.gray)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
Spacer()
|
||||
Group {
|
||||
Toggle(isOn: $tutorialContext.loggingUnit.logsEnabled.value) {
|
||||
Text("Logs collection")
|
||||
|
||||
@@ -19,7 +19,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
|
||||
let contentView = ContentView()
|
||||
let delegate = UIApplication.shared.delegate as! AppDelegate
|
||||
|
||||
let contentView = ContentView(tutorialContext: delegate.tutorialContext)
|
||||
|
||||
// Use a UIHostingController as window root view controller.
|
||||
if let windowScene = scene as? UIWindowScene {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
import linphonesw
|
||||
|
||||
|
||||
class VideoCallExample : ObservableObject
|
||||
{
|
||||
var mCore: Core! // We need a Core for... anything, basically
|
||||
@@ -25,7 +24,7 @@ class VideoCallExample : ObservableObject
|
||||
var mUsedVideoDeviceId : Int = 0
|
||||
var callAlreadyStopped = false;
|
||||
|
||||
@Published var videoEnabled : Bool = false
|
||||
@Published var videoEnabled : Bool = true
|
||||
@Published var callRunning : Bool = false
|
||||
@Published var isCallIncoming : Bool = false
|
||||
@Published var dest : String = "sip:arguillq@sip.linphone.org"
|
||||
@@ -52,6 +51,7 @@ class VideoCallExample : ObservableObject
|
||||
|
||||
mCore.addDelegate(delegate: mCallStateTracer)
|
||||
mCore.addDelegate(delegate: mRegistrationDelegate)
|
||||
|
||||
}
|
||||
|
||||
func registrationExample()
|
||||
|
||||
Reference in New Issue
Block a user