I am engaged on a Swift-based VoIP utility utilizing PJ-SIP and dealing with a difficulty with displaying the video stream in a UIView. I’ve arrange PJSIPManager to deal with SIP functionalities, and I am making an attempt to embed the video stream inside a UIView in my UIViewController. Nevertheless, the video just isn’t being displayed as anticipated.
Code Setup:
In my PJSIPManager, I’ve the next configuration:
struct PJSIPManager {
personal init() {
var cfg = pjsua_config()
pjsua_config_default(&cfg)
cfg.cb.on_call_media_state = on_call_media_state
}
var vid_win: UIView? = nil
personal func on_call_media_state(pjsipID: pjsua_call_id) {
// ... [media state handling code] ...
if (media[Int(mi)].kind == PJMEDIA_TYPE_VIDEO) {
PJSIPManager.occasion?.isVideoCall = true
let wid = media[Int(mi)].stream.vid.win_in;
var wi = pjsua_vid_win_info();
if (pjsua_vid_win_get_info(wid, &wi) == PJ_SUCCESS.rawValue) {
PJSIPManager.occasion?.vid_win = Unmanaged<UIView>.fromOpaque(wi.hwnd.information.ios.window).takeUnretainedValue();
}
}
}
}
In my UIViewController, I am doing the next:
override func viewDidLoad() {
tremendous.viewDidLoad()
DispatchQueue.principal.async {
if let isVideoCall = PJSIPManager.getInstance()?.isVideoCall, isVideoCall {
if let videoWindow = PJSIPManager.getInstance()?.vid_win {
self.view.addSubview(videoWindow)
videoWindow.backgroundColor = .crimson
self.videoView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
self.videoView.centerXAnchor.constraint(equalTo:self.view.centerXAnchor),
self.videoView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
self.videoView.widthAnchor.constraint(equalToConstant: 100),
self.videoView.heightAnchor.constraint(equalToConstant: 100)
])
}
}
}
}
With this setup, I am not in a position to see the video stream.
Situation:
Once I use the vid_win instantly from PJSIPManager, the video would not present up.however If I substitute vid_win with a newly created UIView occasion (self.videoView = UIView()), I can see the crimson view, indicating that the view is added to the view hierarchy, but it surely’s not rendering the video stream.
How can I be certain that vid_win is accurately receiving and displaying the video stream?
Are there any particular issues in PJ-SIP for embedding video in a UIView?
I made positive that isVideoCall is true and that PJSIPManager.getInstance()?.vid_win just isn’t nil