@3deye-toolkit/react-camera 0.0.1-alpha.7 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,548 @@
1
+ /// <reference types="react" />
2
+
3
+ import type { IReactionDisposer } from 'mobx';
4
+ import { Observable } from 'rxjs';
5
+ import { default as React_2 } from 'react';
6
+ import type { Ref } from 'react';
7
+ import { Subscription } from 'rxjs';
8
+
9
+ declare type ArchiveChunk = Chunk & {
10
+ isLive: false;
11
+ };
12
+
13
+ declare class ArchiveChunk_2 implements Chunk_2 {
14
+ json?: string;
15
+ startTime: Date;
16
+ endTime: Date;
17
+ streamUrl: string;
18
+ duration?: number;
19
+ isLive: false;
20
+ cameraId: number;
21
+ id: number;
22
+ constructor(raw: any);
23
+ }
24
+
25
+ declare interface ArchivesStore {
26
+ fetchPrevChunk: (params: {
27
+ cameraId: number;
28
+ time: Date;
29
+ }) => Observable<ArchiveChunk | undefined>;
30
+ fetchNextChunk: (params: {
31
+ cameraId: number;
32
+ time: Date;
33
+ }) => Observable<ArchiveChunk | undefined>;
34
+ getChunks: (query: ChunksQuery) => ArchiveChunk[];
35
+ }
36
+
37
+ declare type BehaviorFactory = (controller: PlayerController) => PlayerBehavior;
38
+
39
+ declare interface Box {
40
+ Top: number;
41
+ Left: number;
42
+ Bottom: number;
43
+ Right: number;
44
+ }
45
+
46
+ export declare const BoxSelector: (({ onSelect, onRequestCancel, onClose }: Props_2) => JSX.Element) & {
47
+ displayName: string;
48
+ };
49
+
50
+ export declare class Camera {
51
+ id: number;
52
+ name: string;
53
+ imageUrl: string;
54
+ streamUrl: string;
55
+ dashStreamUrl: string;
56
+ address: {
57
+ Lat: number;
58
+ Lng: number;
59
+ } | null;
60
+ archiveDuration: number;
61
+ dvrWindowLength: number;
62
+ stateUpdatedAt: Date;
63
+ raw: RawCamera;
64
+ enabled: boolean;
65
+ isMicEnabled: boolean;
66
+ state: string;
67
+ pin: string;
68
+ webRtcUrl: string;
69
+ isPtz: boolean;
70
+ permissions: number;
71
+ get isOnline(): boolean;
72
+ get supportsWebRTC(): boolean;
73
+ constructor(raw: RawCamera);
74
+ update: (raw: RawCamera) => void;
75
+ }
76
+
77
+ declare const Camera_2: React_2.MemoExoticComponent<React_2.ForwardRefExoticComponent<Pick<Props & React_2.RefAttributes<HTMLDivElement>, "key" | keyof Props> & React_2.RefAttributes<HTMLDivElement>>>;
78
+ export default Camera_2;
79
+
80
+ declare interface Camera_3 {
81
+ id: number;
82
+ name: string;
83
+ streamUrl: string;
84
+ dashStreamUrl: string;
85
+ webRtcUrl: string;
86
+ pin: string;
87
+ dvrWindowLength: number;
88
+ enabled: boolean;
89
+ isOnline: boolean;
90
+ isPtz: boolean;
91
+ isMicEnabled: boolean;
92
+ address?: {
93
+ Lat: number;
94
+ Lng: number;
95
+ } | null;
96
+ archiveDuration: number;
97
+ permissions: number;
98
+ raw: RawCamera;
99
+ }
100
+
101
+ declare interface CameraStatistics {
102
+ id: number;
103
+ month: number;
104
+ trafficOutMBytes: number;
105
+ archiveStorageMBytes: number;
106
+ clipStorageMBytes: number;
107
+ }
108
+
109
+ declare interface Chunk {
110
+ startTime: Date;
111
+ endTime: Date;
112
+ streamUrl: string;
113
+ duration?: number;
114
+ cameraId: number;
115
+ }
116
+
117
+ declare interface Chunk_2 {
118
+ json?: string;
119
+ startTime: Date;
120
+ endTime: Date;
121
+ streamUrl: string;
122
+ duration?: number;
123
+ }
124
+
125
+ declare interface ChunksQuery {
126
+ cameraId: number;
127
+ from: Date;
128
+ to: Date;
129
+ }
130
+
131
+ declare interface Clip {
132
+ id: number;
133
+ cameraId: number;
134
+ startTime: Date;
135
+ endTime: Date;
136
+ isTimelapse: boolean;
137
+ duration: number;
138
+ clipUrl?: string;
139
+ name: string;
140
+ }
141
+
142
+ declare class Clip_2 {
143
+ id: number;
144
+ cameraId: number;
145
+ name: string;
146
+ startTime: Date;
147
+ endTime: Date;
148
+ type: 'Archive' | 'Timelaps' | 'Timelaps to do';
149
+ createdAt: Date;
150
+ /**
151
+ * clip duration in seconds
152
+ */
153
+ duration: number;
154
+ chunks: ArchiveChunk_2[];
155
+ clipUrl?: string;
156
+ description: string;
157
+ version: string;
158
+ raw: RawClip;
159
+ isDownloading: boolean;
160
+ archives?: ArchiveChunk_2[];
161
+ constructor(raw: RawClip);
162
+ get isTimelapse(): boolean;
163
+ update(raw: any): void;
164
+ }
165
+
166
+ export declare const CloseControl: {
167
+ ({ onClick }: Props_4): JSX.Element | null;
168
+ displayName: string;
169
+ };
170
+
171
+ export declare const Control: React_2.FC<Props_5>;
172
+
173
+ export declare class Controls extends React_2.Component<Props_6> {
174
+ get player(): PlayerController;
175
+ static contextType: React_2.Context<PlayerController>;
176
+ static Spacer: React_2.FC;
177
+ containerRef: React_2.RefObject<HTMLDivElement>;
178
+ mutationObserver: MutationObserver;
179
+ resizeReactionDisposer: IReactionDisposer;
180
+ componentDidUpdate(): void;
181
+ componentDidMount(): void;
182
+ reflow: () => void;
183
+ componentWillUnmount(): void;
184
+ render(): JSX.Element;
185
+ }
186
+
187
+ export declare const DefaultControls: (({ onRequestClose, fullscreenControl }: Props_8) => JSX.Element) & {
188
+ displayName: string;
189
+ };
190
+
191
+ export declare const FullscreenControl: {
192
+ ({ toggle: toggle, active }: Props_7): JSX.Element;
193
+ displayName: string;
194
+ };
195
+
196
+ declare class LiveChunk {
197
+ cameraId: number;
198
+ streamUrl: string;
199
+ dashStreamUrl: string;
200
+ startTime: Date;
201
+ endTime: Date;
202
+ length: number;
203
+ isLive: boolean;
204
+ isDvr: boolean;
205
+ hasDvr: boolean;
206
+ rtmpStreamUrl: string;
207
+ managed: boolean;
208
+ constructor(data: {
209
+ cameraId: number;
210
+ endTime: Date;
211
+ startTime: Date;
212
+ streamUrl: string;
213
+ dashStreamUrl: string;
214
+ length: number;
215
+ });
216
+ setBounds: (range: [Date, Date]) => void;
217
+ }
218
+
219
+ export declare const PlaybackRateControl: (() => JSX.Element | null) & {
220
+ displayName: string;
221
+ };
222
+
223
+ export declare const Player: React_2.MemoExoticComponent<React_2.ForwardRefExoticComponent<Pick<Props_3 & React_2.RefAttributes<HTMLDivElement>, "key" | keyof Props_3> & React_2.RefAttributes<HTMLDivElement>>>;
224
+
225
+ declare interface PlayerBehavior {
226
+ state: PlayerState | null;
227
+ player: PlayerController;
228
+ loading: boolean;
229
+ error: any;
230
+ delay?: number;
231
+ live?: boolean;
232
+ seek?: (time: Date) => void;
233
+ goLive?: () => void;
234
+ getCurrentTime: () => Date | null;
235
+ getDateRange?: () => [Date, Date] | null;
236
+ dispose: () => Promise<void> | void;
237
+ }
238
+
239
+ export declare const PlayerContext: React_2.Context<PlayerController>;
240
+
241
+ export declare class PlayerController {
242
+ id: number;
243
+ disposables: (IReactionDisposer | Subscription)[];
244
+ liveChunk?: LiveChunk | null;
245
+ currentTime: Date | null;
246
+ targetTime: Date | null;
247
+ chunk: ArchiveChunk | LiveChunk | null;
248
+ paused: boolean;
249
+ error: any;
250
+ get loading(): boolean;
251
+ playbackRate: number;
252
+ volume: number;
253
+ muted: boolean;
254
+ videoResizeMode: VideoResizeMode;
255
+ camera: Camera_3;
256
+ stats: any;
257
+ mode: 'archive' | 'DVR' | 'WebRTC' | null;
258
+ behavior: PlayerBehavior | null;
259
+ transform: string | null;
260
+ width: number;
261
+ height: number;
262
+ chunkRequest: {
263
+ time: Date;
264
+ backward: boolean;
265
+ } | null;
266
+ loopRange: {
267
+ start: Date;
268
+ end: Date;
269
+ } | null;
270
+ loopRangeEnabled: boolean;
271
+ restoreFromDvrEnabled: boolean;
272
+ pendingBehavior: PlayerBehavior | null;
273
+ video: HTMLVideoElement;
274
+ clip?: Clip;
275
+ startTime: Date | null;
276
+ endTime: Date | null;
277
+ stream: MediaStream | null;
278
+ canSeek: boolean;
279
+ canSeek$: Observable<any>;
280
+ progress$: Observable<any>;
281
+ muted$: Observable<boolean>;
282
+ volume$: Observable<number>;
283
+ ended$: Observable<any>;
284
+ archivesStore: ArchivesStore;
285
+ behaviors: {
286
+ archive: BehaviorFactory;
287
+ DVR: BehaviorFactory;
288
+ WebRTC: BehaviorFactory | null;
289
+ };
290
+ seekTime?: Date | null;
291
+ constructor({ camera, startTime, endTime, clip, archivesStore, behaviors }: {
292
+ camera: Camera_3;
293
+ clip?: Clip;
294
+ startTime?: Date | null;
295
+ endTime?: Date | null;
296
+ archivesStore: ArchivesStore;
297
+ behaviors: {
298
+ archive: BehaviorFactory;
299
+ DVR: BehaviorFactory;
300
+ WebRTC: BehaviorFactory | null;
301
+ };
302
+ });
303
+ attach(video: HTMLVideoElement, { canSeek$, progress$, muted$, volume$, ended$ }: PlayerEventStreams): void;
304
+ private seek;
305
+ private seekAfterReady;
306
+ private stopLoadingOnError;
307
+ private replaceErrorMessageOnOffline;
308
+ changeMedia: ({ time, chunk, backward }: {
309
+ time: Date;
310
+ chunk?: LiveChunk | ArchiveChunk | undefined;
311
+ backward?: boolean | undefined;
312
+ }) => void;
313
+ private initCurrentTime;
314
+ private initPlayableRange;
315
+ /**
316
+ * If the chunk after chunk request is the same as the current chunk,
317
+ * then we can dismiss loading indicator and seek.
318
+ */
319
+ private initSameChunkRequestFix;
320
+ private initLiveChunkUpdate;
321
+ private initChunkRequest;
322
+ private setupLiveChunk;
323
+ /**
324
+ * Inits correct behavior for current player mode
325
+ */
326
+ private initPlayerBehavior;
327
+ /**
328
+ * Rewind by given amount of milliseconds
329
+ * @param value milliseconds
330
+ * @returns
331
+ */
332
+ seekBackward: (value: number) => void;
333
+ /**
334
+ * Seek forward by given amount of milliseconds
335
+ * @param value
336
+ * @returns
337
+ */
338
+ seekForward: (value: number) => void;
339
+ goLive: () => void;
340
+ setCamera: (camera: Camera_3) => void;
341
+ setCameraAndStartTime: (camera: Camera_3, startTime: Date | null) => void;
342
+ toggleResizeMode: () => void;
343
+ setVideoResizeMode: (mode: VideoResizeMode) => void;
344
+ toggleMute: () => void;
345
+ setStartTime: (time: Date | null) => void;
346
+ setVolume: (volume: number) => void;
347
+ setPlaybackRate: (rate: number) => void;
348
+ reactToVolumeChange(): void;
349
+ togglePlayback: () => void;
350
+ setTransform(transform: string | null): void;
351
+ play: () => void;
352
+ pause: () => void;
353
+ detach: () => void;
354
+ private initUpgradeToWebRtcWhenCameraIsBackOnline;
355
+ private initFallbackToDVR;
356
+ private initUpgradeToWebRtcAfterFallbackToDvr;
357
+ }
358
+
359
+ declare interface PlayerEventStreams {
360
+ canSeek$: Observable<any>;
361
+ progress$: Observable<any>;
362
+ ended$: Observable<any>;
363
+ volume$: Observable<number>;
364
+ muted$: Observable<boolean>;
365
+ }
366
+
367
+ declare enum PlayerState {
368
+ Initial = "initial",
369
+ Playing = "playing",
370
+ Paused = "paused",
371
+ Reconnecting = "reconnecting",
372
+ Stalled = "stalled",
373
+ Error = "error",
374
+ Failed = "failed"
375
+ }
376
+
377
+ export declare const PlayPauseControl: (() => JSX.Element) & {
378
+ displayName: string;
379
+ };
380
+
381
+ declare interface Props extends Omit<React_2.HTMLAttributes<HTMLDivElement>, 'onMouseDown'> {
382
+ cameraId: number;
383
+ startTime?: Date | null;
384
+ controls?: React_2.ReactNode;
385
+ onMouseDown?: (e: MouseEvent) => void;
386
+ onRequestClose?: () => void;
387
+ }
388
+
389
+ declare interface Props_2 {
390
+ onSelect: (box: Box) => void;
391
+ onClose: () => void;
392
+ onRequestCancel: () => void;
393
+ }
394
+
395
+ declare interface Props_3 extends Omit<React_2.HTMLAttributes<HTMLDivElement>, 'onMouseDown'> {
396
+ camera: Camera;
397
+ startTime?: Date | null;
398
+ endTime?: Date | null;
399
+ clip?: Clip_2;
400
+ controls: React_2.ReactNode;
401
+ onMouseDown?: (e: MouseEvent) => void;
402
+ hideCameraTitle?: boolean;
403
+ webRtcOptions?: {
404
+ enabled: boolean;
405
+ allowedIceCandidateProtocols?: ('udp' | 'tcp')[];
406
+ };
407
+ controllerRef?: Ref<PlayerController>;
408
+ videoRef?: Ref<HTMLVideoElement>;
409
+ archivesStore: ArchivesStore;
410
+ }
411
+
412
+ declare interface Props_4 {
413
+ onClick?: () => void;
414
+ }
415
+
416
+ declare type Props_5 = Omit<React_2.HTMLAttributes<HTMLButtonElement>, 'title'> & {
417
+ ref?: React_2.Ref<HTMLButtonElement>;
418
+ title?: React_2.ReactNode;
419
+ };
420
+
421
+ declare interface Props_6 {
422
+ children: React_2.ReactNode;
423
+ style?: React_2.CSSProperties;
424
+ }
425
+
426
+ declare interface Props_7 {
427
+ toggle: (() => void) | null;
428
+ active: boolean;
429
+ }
430
+
431
+ declare interface Props_8 {
432
+ onRequestClose?: () => void;
433
+ fullscreenControl?: React_2.ReactNode;
434
+ }
435
+
436
+ export declare const PtzControls: ((props: PtzControlsProps) => JSX.Element) & {
437
+ displayName: string;
438
+ };
439
+
440
+ declare interface PtzControlsProps {
441
+ cameraId: number;
442
+ style?: React_2.CSSProperties;
443
+ initialZoomSpeed?: number;
444
+ initialMovementSpeed?: number;
445
+ disabled?: boolean;
446
+ disallowHomePositionUpdate?: boolean;
447
+ disallowGoHome?: boolean;
448
+ }
449
+
450
+ declare interface RawCamera {
451
+ id: number;
452
+ customerId: number;
453
+ name: string;
454
+ description: string;
455
+ cameraBrand: string;
456
+ cameraModel: string;
457
+ enabled: boolean;
458
+ cameraUserName: string;
459
+ cameraPassword: null;
460
+ serialNum: string;
461
+ isOnvif: boolean;
462
+ isP2P: boolean;
463
+ p2pRegistrationCode: null;
464
+ planId: null;
465
+ p2pState: string;
466
+ cameraVideoFormat: string;
467
+ cameraState: string;
468
+ cameraStateChangedTime: string;
469
+ cameraError: null;
470
+ cameraAddress: string;
471
+ isMicEnabled: boolean;
472
+ imageQuality: number;
473
+ cameraSourceChannel: string;
474
+ pin: string;
475
+ streamUrl: string;
476
+ dashStreamUrl: string;
477
+ rtmpUrl: string;
478
+ webRtcStreamHost: string;
479
+ webRtcUrl: string;
480
+ cameraHttpSourceUrl: string;
481
+ cameraRtspSourceUrl: string;
482
+ supportedResolutions: string;
483
+ cameraType: string;
484
+ isCloud: boolean;
485
+ generateImageUrl: null;
486
+ imageUrl: string;
487
+ qualityProfile: string;
488
+ encodingProfile: null;
489
+ width: number;
490
+ height: number;
491
+ bitRate: number;
492
+ frameRate: number;
493
+ archiveDuration: number;
494
+ isArchiveByMotionEvent: boolean;
495
+ isAnalyticsEnabled: boolean;
496
+ isTimelapseAvailable: boolean;
497
+ motionEnabled: boolean;
498
+ isPTZ: boolean;
499
+ motionDuration: number;
500
+ dvrWindowLength: number;
501
+ jsonField: string;
502
+ dtUpdUtc: string;
503
+ version: string;
504
+ statistics: CameraStatistics;
505
+ }
506
+
507
+ declare interface RawClip {
508
+ id: number;
509
+ recordType: string;
510
+ isReady: boolean;
511
+ name: string;
512
+ description: string;
513
+ tagName: null;
514
+ cameraId: number;
515
+ clipUrl: string;
516
+ thumbnailUrl: string;
517
+ startTime: string;
518
+ endTime: string;
519
+ duration: number;
520
+ validTo: string;
521
+ timeCreated: string;
522
+ timeUpdated: string;
523
+ version: string;
524
+ }
525
+
526
+ export declare const ResizeModeControl: (() => JSX.Element) & {
527
+ displayName: string;
528
+ };
529
+
530
+ export declare const SnapshotControl: React_2.FC;
531
+
532
+ export declare function useFullscreen(): {
533
+ ref: (node: HTMLElement | null) => void;
534
+ toggle: () => undefined;
535
+ enabled: boolean;
536
+ active: boolean;
537
+ };
538
+
539
+ declare enum VideoResizeMode {
540
+ Fit = "contain",
541
+ Stretch = "fill"
542
+ }
543
+
544
+ export declare const VolumeControl: (() => JSX.Element) & {
545
+ displayName: string;
546
+ };
547
+
548
+ export { }