我们希望使用 WebRTC 使用 ReplayKit 发送 iOS devices\xe2\x80\x99 屏幕捕获。\nReplayKit 有一个 processSampleBuffer 回调,它提供 CMSampleBuffer。
\n\n但这就是我们陷入困境的地方,我们\xe2\x80\x99似乎无法将CMSampleBuffer发送到连接的对等点。\n我们尝试从sampleBuffer创建pixelBuffer,然后创建RTCVideoFrame。
\n\n我们还从 RTCPeerConnectionFactory 中提取了 RTCVideoSource,然后使用 RTCVideoCapturer 并将其流式传输到 localVideoSource。
\n\n知道我们做错了什么吗?
\n\nvar peerConnectionFactory: RTCPeerConnectionFactory?\n\noverride func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {\n switch sampleBufferType {\n case RPSampleBufferType.video:\n\n // create the CVPixelBuffer\n let pixelBuffer:CVPixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)!;\n\n // create the RTCVideoFrame\n var videoFrame:RTCVideoFrame?;\n let timestamp = NSDate().timeIntervalSince1970 * 1000\n videoFrame = RTCVideoFrame(pixelBuffer: pixelBuffer, rotation: RTCVideoRotation._0, timeStampNs: Int64(timestamp))\n\n // connect the video frames to the WebRTC\n let localVideoSource = …Run Code Online (Sandbox Code Playgroud)