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 onStarted: RCTDirectEventBlock?
@objc var onStopped: RCTDirectEventBlock? @objc var onStopped: RCTDirectEventBlock?
@objc var onViewReady: RCTDirectEventBlock? @objc var onViewReady: RCTDirectEventBlock?
@objc var onInitReady: RCTDirectEventBlock?
@objc var onVideoChunkReady: RCTDirectEventBlock? @objc var onVideoChunkReady: RCTDirectEventBlock?
@objc var onCodeScanned: RCTDirectEventBlock? @objc var onCodeScanned: RCTDirectEventBlock?
// zoom // zoom
@ -340,14 +341,15 @@ public final class CameraView: UIView, CameraSessionDelegate {
func onVideoChunkReady(chunk: ChunkedRecorder.Chunk) { func onVideoChunkReady(chunk: ChunkedRecorder.Chunk) {
ReactLogger.log(level: .info, message: "Chunk ready: \(chunk)") ReactLogger.log(level: .info, message: "Chunk ready: \(chunk)")
guard let onVideoChunkReady = onVideoChunkReady else { guard let onVideoChunkReady, let onInitReady else {
return return
} }
switch chunk.type { switch chunk.type {
case .initialization: case .initialization:
// FIXME: send initialization segment onInitReady([
return "filepath": chunk.url.path,
])
case .data(index: let index): case .data(index: let index):
onVideoChunkReady([ onVideoChunkReady([
"filepath": chunk.url.path, "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(onStarted, RCTDirectEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onStopped, RCTDirectEventBlock); RCT_EXPORT_VIEW_PROPERTY(onStopped, RCTDirectEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onViewReady, RCTDirectEventBlock); RCT_EXPORT_VIEW_PROPERTY(onViewReady, RCTDirectEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onInitReady, RCTDirectEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onVideoChunkReady, RCTDirectEventBlock); RCT_EXPORT_VIEW_PROPERTY(onVideoChunkReady, RCTDirectEventBlock);
// Code Scanner // Code Scanner
RCT_EXPORT_VIEW_PROPERTY(codeScannerOptions, NSDictionary); RCT_EXPORT_VIEW_PROPERTY(codeScannerOptions, NSDictionary);