0

ReplayKit用于获取视频流。callback 不断调用但rpSampleType返回其他内容。我只想要视频缓冲区。

这是我的代码

RPScreenRecorder.shared().startCapture(handler: { (cmSampleBuffer, rpSampleType, error) in
    if CMSampleBufferDataIsReady(cmSampleBuffer){

        switch rpSampleType {

        case RPSampleBufferType.video:
            // create the CVPixelBuffer
            let pixelBuffer = CMSampleBufferGetImageBuffer(cmSampleBuffer)!
            let rtcpixelBuffer = RTCCVPixelBuffer(pixelBuffer: pixelBuffer)
        default:
            print("sample has no matching type")
        }
    }
}) { (error) in
    print(error?.localizedDescription)
}
4

0 回答 0