fix: Fully synchronize buffers in RecordingSession to account for late-running frames (#2206)

* fix: Fully synchronize `RecordingSession` to account for late Frames

* Restructure Code

* Update RecordingSession.swift

* Fix last audio timestamp not being used

* fix: Remove `capture/aborted` error

* Update RecordingSession.swift

* Don't log for every Frame

* Format
This commit is contained in:
Marc Rousavy
2023-11-23 18:17:15 +01:00
committed by GitHub
parent 29e649937e
commit 1767e6e881
4 changed files with 171 additions and 81 deletions

View File

@@ -10,7 +10,10 @@ import AVFoundation
import Foundation
extension AVCaptureSession {
private var clock: CMClock {
/**
Returns the clock that is used by this AVCaptureSession.
*/
var clock: CMClock {
if #available(iOS 15.4, *), let synchronizationClock {
return synchronizationClock
}
@@ -24,7 +27,6 @@ extension AVCaptureSession {
func synchronizeBuffer(_ buffer: CMSampleBuffer, toSession to: AVCaptureSession) {
let timestamp = CMSampleBufferGetPresentationTimeStamp(buffer)
let synchronizedTimestamp = CMSyncConvertTime(timestamp, from: clock, to: to.clock)
ReactLogger.log(level: .info, message: "Synchronized Timestamp \(timestamp.seconds) -> \(synchronizedTimestamp.seconds)")
CMSampleBufferSetOutputPresentationTimeStamp(buffer, newValue: synchronizedTimestamp)
}
}