We have used the following steps of integrating PIP (Picture in Picture) for WebRTC Video Call:
We are enabling mode of Audio, Airplay, and Picture in Picture capability in our project.
We have added an Entitlement file with Accessing the Camera while multitasking, see Accessing the Camera While Multitasking.)
From the documentation link, we followed:
Provision Your App
After your account has permission to use the entitlement, you can create a new provisioning profile with it by following these steps:
Log in to your Apple Developer Account.
Go to Certificates, Identifiers & Profiles.
Generate a new provisioning profile for your app.
Select the Multitasking Camera Access entitlement from the additional entitlements for your account.
We have also integrated the following link, but how to add video render layer view in this
SampleBufferVideoCallViewwe don’t have any particular hint. https://developer.apple.com/documentation/avkit/adopting_picture_in_picture_for_video_calls?changes=__8Also,
RTCMTLVideoViewcreatesMTKViewisn’t supported, but we have usedWebRTCdefault video render view likeRTCEAGLVideoViewused toGLKViewfor a video rendering.
The PIP Integrate with WebRTC iOS Swift code:
class SampleBufferVideoCallView: UIView {
override class var layerClass: AnyClass {
get { return AVSampleBufferDisplayLayer.self }
}
var sampleBufferDisplayLayer: AVSampleBufferDisplayLayer {
return layer as! AVSampleBufferDisplayLayer
}
}
func startPIP() {
if #available(iOS 15.0, *) {
let sampleBufferVideoCallView = SampleBufferVideoCallView()
let pipVideoCallViewController = AVPictureInPictureVideoCallViewController()
pipVideoCallViewController.preferredContentSize = CGSize(width: 1080, height: 1920)
pipVideoCallViewController.view.addSubview(sampleBufferVideoCallView)
let remoteVideoRenderar = RTCEAGLVideoView()
remoteVideoRenderar.contentMode = .scaleAspectFill
remoteVideoRenderar.frame = viewUser.frame
viewUser.addSubview(remoteVideoRenderar)
let pipContentSource = AVPictureInPictureController.ContentSource(
activeVideoCallSourceView: self.viewUser,
contentViewController: pipVideoCallViewController)
let pipController = AVPictureInPictureController(contentSource: pipContentSource)
pipController.canStartPictureInPictureAutomaticallyFromInline = true
pipController.delegate = self
} else {
// Fallback on earlier versions
}
}
How to add a viewUser GLKView into pipContentSource and how to integrate remote video buffer view into SampleBufferVideoCallView?
Is it possible this way or any other way to video render buffer layer view in AVSampleBufferDisplayLayer?