Skip to content

Commit

Permalink
add sampleWritingSessionStartedHandler to MultitrackMovieRecorder
Browse files Browse the repository at this point in the history
  • Loading branch information
YuAo committed Mar 6, 2021
1 parent d2df1b6 commit 28018e4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Sources/VideoIO/MultitrackMovieRecorder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,18 @@ public final class MultitrackMovieRecorder {
self.queue.sync { _duration }
}

public var durationChangedHandler: ((CMTime) -> Void)?
public var sampleWritingSessionStartTime: CMTime? {
self.queue.sync {
if recordingStartSampleTime == .invalid {
return nil
} else {
return recordingStartSampleTime
}
}
}

public var sampleWritingSessionStartedHandler: ((_ sampleWritingSessionStartTime: CMTime) -> Void)?
public var durationChangedHandler: ((_ duration: CMTime) -> Void)?

private var lastVideoSampleTime: CMTime = .invalid
private var recordingStartSampleTime: CMTime = .invalid
Expand Down Expand Up @@ -189,6 +200,9 @@ public final class MultitrackMovieRecorder {
self.assetWriter.startSession(atSourceTime: presentationTime)
self.recordingStartSampleTime = presentationTime
self.lastVideoSampleTime = presentationTime
DispatchQueue.main.async {
self.sampleWritingSessionStartedHandler?(presentationTime)
}
}

if self.assetWriter.status == .writing {
Expand Down

0 comments on commit 28018e4

Please sign in to comment.