Add video preview. Move all video display intelligence to the GUI part
This commit is contained in:
@@ -7,6 +7,31 @@
|
||||
//
|
||||
|
||||
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 {
|
||||
|
||||
@@ -117,9 +142,9 @@ struct ContentView: View {
|
||||
.padding(.top)
|
||||
}
|
||||
HStack {
|
||||
LinphoneVideoView(core: tutorialContext.mCore).frame(width: 150, height: 210).border(Color.gray).padding(.leading)
|
||||
Spacer()
|
||||
tutorialContext.videoView.frame(width : 150)
|
||||
Spacer()
|
||||
LinphoneVideoPreview(core: tutorialContext.mCore).frame(width: 120, height: 160).border(Color.gray).padding(.horizontal)
|
||||
}
|
||||
Spacer()
|
||||
Group {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
import linphonesw
|
||||
import SwiftUI
|
||||
|
||||
|
||||
class VideoCallExample : ObservableObject
|
||||
{
|
||||
@@ -34,20 +34,6 @@ class VideoCallExample : ObservableObject
|
||||
@Published var id : String = "sip:quentindev@sip.linphone.org"
|
||||
@Published var passwd : String = "dev"
|
||||
@Published var loggedIn: Bool = false
|
||||
|
||||
/*--- Wrapper to incorporate the video chat view into a SwiftUI gui ---*/
|
||||
struct VideoView: UIViewRepresentable {
|
||||
let videoAsUIView = UIView()
|
||||
|
||||
func makeUIView(context: Context) -> UIView {
|
||||
videoAsUIView.backgroundColor = .black
|
||||
return videoAsUIView
|
||||
}
|
||||
|
||||
func updateUIView(_ uiView: UIView, context: Context) {}
|
||||
}
|
||||
let videoView = VideoView()
|
||||
|
||||
|
||||
init()
|
||||
{
|
||||
@@ -60,8 +46,6 @@ class VideoCallExample : ObservableObject
|
||||
// main loop for receiving notifications and doing background linphonecore work:
|
||||
mCore.autoIterateEnabled = true
|
||||
|
||||
// Give the UIView in which the video will be rendered to the Linphone Core
|
||||
mCore.nativeVideoWindowId = UnsafeMutableRawPointer(Unmanaged.passRetained(videoView.videoAsUIView).toOpaque())
|
||||
try? mCore.start()
|
||||
|
||||
mVideoDevices = mCore.videoDevicesList
|
||||
|
||||
Reference in New Issue
Block a user