connect onChunkReady from ChunkedRecorder to react native

This commit is contained in:
Rui Rodrigues
2024-07-15 09:50:39 +01:00
parent 89ecb35616
commit a2ce4df663
5 changed files with 36 additions and 3 deletions

View File

@@ -62,6 +62,7 @@ public final class CameraView: UIView, CameraSessionDelegate {
@objc var onStarted: RCTDirectEventBlock?
@objc var onStopped: RCTDirectEventBlock?
@objc var onViewReady: RCTDirectEventBlock?
@objc var onVideoChunkReady: RCTDirectEventBlock?
@objc var onCodeScanned: RCTDirectEventBlock?
// zoom
@objc var enableZoomGesture = false {
@@ -335,6 +336,25 @@ public final class CameraView: UIView, CameraSessionDelegate {
}
#endif
}
func onVideoChunkReady(chunk: ChunkedRecorder.Chunk) {
ReactLogger.log(level: .info, message: "Chunk ready: \(chunk)")
guard let onVideoChunkReady = onVideoChunkReady else {
return
}
switch chunk.type {
case .initialization:
// FIXME: send initialization segment
return
case .data(index: let index):
onVideoChunkReady([
"filepath": chunk.url.path,
"index": index,
])
}
}
func onCodeScanned(codes: [CameraSession.Code], scannerFrame: CameraSession.CodeScannerFrame) {
guard let onCodeScanned = onCodeScanned else {