Skip to content

Commit

Permalink
chore: kickoff release
Browse files Browse the repository at this point in the history
  • Loading branch information
phantumcode authored Dec 5, 2023
2 parents 6230ae6 + 09473a5 commit d738e32
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
10 changes: 4 additions & 6 deletions Sources/FaceLiveness/AV/VideoChunker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ final class VideoChunker {
}

guard state == .writing else { return }
let timestamp = CMSampleBufferGetPresentationTimeStamp(buffer).seconds

if startTimeSeconds == nil { startTimeSeconds = timestamp }
guard let startTimeSeconds else {
return
}

if assetWriterInput.isReadyForMoreMediaData {
let timestamp = CMSampleBufferGetPresentationTimeStamp(buffer).seconds
if startTimeSeconds == nil { startTimeSeconds = timestamp }
guard let startTimeSeconds else {
return
}
let presentationTime = CMTime(seconds: timestamp - startTimeSeconds, preferredTimescale: 600)
guard let imageBuffer = buffer.imageBuffer else { return }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ extension FaceLivenessDetectionViewModel: VideoSegmentProcessor {
sendVideoEvent(data: chunk, videoEventTime: .zero)
if !hasSentFinalVideoEvent,
case .completedDisplayingFreshness = livenessState.state {
sendFinalVideoChunk(data: chunk, videoEventTime: .zero)
DispatchQueue.global(qos: .default).asyncAfter(deadline: .now() + 0.9) {
self.sendFinalVideoEvent()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -289,27 +289,7 @@ class FaceLivenessDetectionViewModel: ObservableObject {
}
}

func sendVideoEvent(data: Data, videoEventTime: UInt64, n: UInt8 = 1) {
guard !hasSentFinalVideoEvent else { return }
let eventDate = Date()
let timestamp = eventDate.timestampMilliseconds

let videoEvent = VideoEvent.init(chunk: data, timestamp: timestamp)

do {
try livenessService?.send(
.video(event: videoEvent),
eventDate: { eventDate }
)
} catch {
DispatchQueue.main.async {
self.livenessState.unrecoverableStateEncountered(.unknown)
}
}
}

func sendFinalVideoChunk(data: Data, videoEventTime: UInt64) {
sendVideoEvent(data: data, videoEventTime: videoEventTime)
func sendFinalVideoEvent() {
sendFinalEvent(
targetFaceRect: faceGuideRect,
viewSize: videoSize,
Expand Down

0 comments on commit d738e32

Please sign in to comment.