session-ios/Session/Calls/CallVC+Camera.swift

23 lines
1016 B
Swift
Raw Normal View History

2021-08-16 06:40:07 +02:00
import WebRTC
2021-08-18 00:56:11 +02:00
extension CallVC : CameraManagerDelegate {
2021-08-16 06:40:07 +02:00
func handleVideoOutputCaptured(sampleBuffer: CMSampleBuffer) {
guard let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }
let rtcPixelBuffer = RTCCVPixelBuffer(pixelBuffer: pixelBuffer)
let timestamp = CMTimeGetSeconds(CMSampleBufferGetPresentationTimeStamp(sampleBuffer))
let timestampNs = Int64(timestamp * 1000000000)
let rotation: RTCVideoRotation = {
switch UIDevice.current.orientation {
case .landscapeRight: return RTCVideoRotation._90
case .portraitUpsideDown: return RTCVideoRotation._180
case .landscapeLeft: return RTCVideoRotation._270
default: return RTCVideoRotation._0
}
}()
let frame = RTCVideoFrame(buffer: rtcPixelBuffer, rotation: rotation, timeStampNs: timestampNs)
2021-08-16 06:40:07 +02:00
frame.timeStamp = Int32(timestamp)
2021-11-03 05:31:50 +01:00
call.webRTCSession.handleLocalFrameCaptured(frame)
2021-08-16 06:40:07 +02:00
}
}