我们使用了以下步骤将PIP (图片中的图片)集成到WebRTC视频呼叫中:
1. Log in to your Apple Developer Account.2. Go to Certificates, Identifiers & Profiles.3. Generate a new provisioning profile for your app.4. Select the Multitasking Camera Access entitlement from the additional entitlements for your account.SampleBufferVideoCallView中添加视频渲染层视图,我们没有任何特别的提示。8RTCMTLVideoView创建MTKView不受支持,但我们使用了WebRTC默认视频呈现视图,就像用于GLKView的RTCEAGLVideoView一样。PIP与WebRTC iOS Swift代码集成:
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
}
}如何将viewUser GLKView添加到pipContentSource以及如何将远程视频缓冲区视图集成到SampleBufferVideoCallView中
在AVSampleBufferDisplayLayer中是否有可能以这种方式或任何其他方式呈现缓冲层视图?
发布于 2022-06-02 05:13:18
在被问及这个问题时,苹果公司给出了以下建议:
为了提供建议,我们需要更多地了解您试图渲染视频的代码。 正如您所提到的文章中所讨论的,要提供PiP支持,您必须首先提供一个要在视频调用视图控制器中显示的源视图 --您需要向AVPictureInPictureVideoCallViewController添加一个UIView。系统支持显示来自AVPlayerLayer或AVSampleBufferDisplayLayer的内容,这取决于您的需要。不支持MTKView/GLKView。视频调用应用程序需要显示远程视图,所以使用AVSampleBufferDisplayLayer来实现。 为了在源视图中处理绘图,可以在缓冲区流转换为GLKView之前访问它,并将其提供给AVPictureInPictureViewController的内容。例如,您可以从视频提要帧创建CVPixelBuffers,然后根据这些框架创建CMSampleBuffers,一旦您拥有了CMSampleBuffers,就可以开始将这些内容提供给AVSampleBufferDisplayLayer以供显示。看看在那里定义的方法,看看是如何做到的。您可能会看到一些存档的ObjC示例代码AVGreenScreenPlayer,以帮助您开始使用AVSampleBufferDisplayLayer (注意:这是AVSampleBufferDisplayLayer代码,但AVSampleBufferDisplayLayer API在不同平台上是相同的)。 此外,为了实现PiP支持,您需要为AVPictureInPictureControllerDelegate和AVSampleBufferDisplayLayer AVPictureInPictureSampleBufferPlaybackDelegate提供委托方法。有关委托的更多信息,请参见最近的WWDC视频AVKit有什么新鲜事?,这是iOS 15中的新内容。
不过,不确定这是否能解决问题。
https://stackoverflow.com/questions/71419635
复制相似问题