add onInitReady callback to send initialization segment path

This commit is contained in:
Rui Rodrigues 2024-07-15 09:55:47 +01:00
parent a2ce4df663
commit 0a43d7a160
2 changed files with 6 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 onInitReady: RCTDirectEventBlock?
@objc var onVideoChunkReady: RCTDirectEventBlock?
@objc var onCodeScanned: RCTDirectEventBlock?
// zoom
@ -340,14 +341,15 @@ public final class CameraView: UIView, CameraSessionDelegate {
func onVideoChunkReady(chunk: ChunkedRecorder.Chunk) {
ReactLogger.log(level: .info, message: "Chunk ready: \(chunk)")
guard let onVideoChunkReady = onVideoChunkReady else {
guard let onVideoChunkReady, let onInitReady else {
return
}
switch chunk.type {
case .initialization:
// FIXME: send initialization segment
return
onInitReady([
"filepath": chunk.url.path,
])
case .data(index: let index):
onVideoChunkReady([
"filepath": chunk.url.path,

View File

@ -55,6 +55,7 @@ RCT_EXPORT_VIEW_PROPERTY(onInitialized, RCTDirectEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onStarted, RCTDirectEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onStopped, RCTDirectEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onViewReady, RCTDirectEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onInitReady, RCTDirectEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onVideoChunkReady, RCTDirectEventBlock);
// Code Scanner
RCT_EXPORT_VIEW_PROPERTY(codeScannerOptions, NSDictionary);