-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathNativeApiVideoLiveStreamView.ts
80 lines (68 loc) · 2.13 KB
/
NativeApiVideoLiveStreamView.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type { HostComponent, ViewProps } from 'react-native';
import type {
DirectEventHandler,
Float,
Int32,
WithDefault,
} from 'react-native/Libraries/Types/CodegenTypes';
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
export type Camera = 'front' | 'back';
export type Resolution = Readonly<{
width: Int32;
height: Int32;
}>;
export type OnConnectionFailedEvent = Readonly<{
code: string;
}>;
export type OnPermissionsDeniedEvent = Readonly<{
permissions: string[];
}>;
export type OnStartStreamingEvent = Readonly<{
requestId: Int32;
result: boolean;
error: string;
}>;
export interface NativeLiveStreamProps extends ViewProps {
camera?: WithDefault<Camera, 'back'>;
video: {
bitrate: Int32;
fps: Int32;
resolution?: Resolution;
gopDuration: Float;
};
isMuted: boolean;
audio: {
bitrate: Int32;
sampleRate?: WithDefault<5500 | 11025 | 22050 | 44100, 44100>;
isStereo: boolean;
};
zoomRatio: Float;
enablePinchedZoom: boolean;
onConnectionSuccess?: DirectEventHandler<null>;
onConnectionFailed?: DirectEventHandler<OnConnectionFailedEvent>;
onDisconnect?: DirectEventHandler<null>;
onPermissionsDenied?: DirectEventHandler<OnPermissionsDeniedEvent>;
// Internal use only
onStartStreaming?: DirectEventHandler<OnStartStreamingEvent>;
}
export type NativeLiveStreamViewType = HostComponent<NativeLiveStreamProps>;
interface NativeCommands {
startStreaming: (
viewRef: React.ElementRef<NativeLiveStreamViewType>,
requestId: Int32,
streamKey: string,
url?: string,
) => void;
stopStreaming: (viewRef: React.ElementRef<NativeLiveStreamViewType>) => void;
setZoomRatioCommand: (
viewRef: React.ElementRef<NativeLiveStreamViewType>,
zoomRatio: Float
) => void;
}
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
supportedCommands: ['startStreaming', 'stopStreaming', 'setZoomRatioCommand'],
});
export default codegenNativeComponent<NativeLiveStreamProps>(
'ApiVideoLiveStreamView'
);