Skip to content

Commit

Permalink
to consider stabilization delay.
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Nov 8, 2024
1 parent 7a737c2 commit 1986357
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/IO/IOVideoMixer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ final class IOVideoMixer<T: IOVideoMixerDelegate> {
private(set) var inputFormats: [UInt8: CMFormatDescription] = [:]
private var currentPixelBuffer: CVPixelBuffer?
private var videoTrackScreenObject = VideoTrackScreenObject()
private var hostTimeClock = CMClockGetHostTimeClock()

func append(_ track: UInt8, sampleBuffer: CMSampleBuffer) {
inputFormats[track] = sampleBuffer.formatDescription
Expand All @@ -41,6 +42,10 @@ final class IOVideoMixer<T: IOVideoMixerDelegate> {
for screen in screens where screen.track == track {
screen.enqueue(sampleBuffer)
}
if settings.mainTrack == track {
let diff = hostTimeClock.time - sampleBuffer.presentationTimeStamp
screen.delayTime = diff.seconds - (1.0 / 120.0)
}
case .passthrough:
if settings.mainTrack == track {
outputSampleBuffer(sampleBuffer)
Expand Down

0 comments on commit 1986357

Please sign in to comment.