I am using Replay Kit 2 (Broadcast Upload Extension) for screen sharing in my application.
It works fine on iPhone but error comes after few seconds as it crosses memory limit 50 MB when i run it on iPAD.
The issue is because of resolution which is high for iPAD. Also i have to use vp8 due to server side limitation so can't use H264.
I have tried minimizing resolution for CMSampleBuffer before sending it to server but memory still increases with same pace and stops.
func didCapture(_ sampleBuffer: CMSampleBuffer){
if CMSampleBufferGetNumSamples(sampleBuffer) != 1 ||
!CMSampleBufferIsValid(sampleBuffer) ||
!CMSampleBufferDataIsReady(sampleBuffer) {
return
}
let rtcPixelBuffer = RTCCVPixelBuffer(pixelBuffer: pixelBuffer)
rtcPixelBuffer.toI420()
// let value = rtcPixelBuffer.cropAndScale(to: CVPixelBuffer, withTempBuffer: <#T##UnsafeMutablePointer<UInt8>#>)
let timeStampNs = Int64(CMTimeGetSeconds(CMSampleBufferGetPresentationTimeStamp(sampleBuffer)) * Double(NSEC_PER_SEC))
let videoFrame = RTCVideoFrame(buffer: rtcPixelBuffer , rotation: ._0, timeStampNs: timeStampNs)
delegate?.capturer(self, didCapture: videoFrame)
}