小编Nir*_*iro的帖子

使用 WebRTC 通过 ReplayKit 发送 iOS 设备的屏幕截图

我们希望使用 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\n
var 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)

screensharing ios webrtc apprtc replaykit

7
推荐指数
1
解决办法
5299
查看次数

标签 统计

apprtc ×1

ios ×1

replaykit ×1

screensharing ×1

webrtc ×1