forked from blackuy/react-native-twilio-video-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
224 lines (190 loc) · 6.97 KB
/
index.d.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
declare module 'react-native-twilio-video-webrtc' {
import { ViewProps } from 'react-native';
import React from 'react';
export interface TrackIdentifier {
participantSid: string;
videoTrackSid: string;
}
type scaleType = 'fit' | 'fill';
type cameraType = 'front' | 'back';
interface TwilioVideoParticipantViewProps extends ViewProps {
trackIdentifier: TrackIdentifier;
ref?: React.Ref<any>;
scaleType?: scaleType;
}
interface TwilioVideoLocalViewProps extends ViewProps {
enabled: boolean;
ref?: React.Ref<any>;
scaleType?: scaleType;
}
interface Participant {
sid: string;
identity: string;
}
interface Track {
enabled: boolean;
trackName: string;
trackSid: string;
}
export interface TrackEventCbArgs {
participant: Participant;
track: Track;
}
export type TrackEventCb = (t: TrackEventCbArgs) => void;
export interface DataTrackEventCbArgs {
message: string;
trackSid: string;
}
export interface DataTrackBinaryEventCbArgs {
message: Uint8Array;
trackSid: string;
}
export type DataTrackEventCb = (t: DataTrackEventCbArgs) => void;
export type DataTrackBinaryEventCb = (t: DataTrackBinaryEventCbArgs) => void;
interface RoomEventCommonArgs {
roomName: string;
roomSid: string;
}
export type RoomErrorEventArgs = RoomEventCommonArgs & {
error: any;
};
type RoomEventArgs = RoomEventCommonArgs & {
participants: Participant[];
localParticipant: Participant;
};
type ParticipantEventArgs = RoomEventCommonArgs & {
participant: Participant;
};
type NetworkLevelChangeEventArgs = {
participant: Participant;
isLocalUser: boolean;
quality: number;
};
export type RoomEventCb = (p: RoomEventArgs) => void;
export type RoomErrorEventCb = (t: RoomErrorEventArgs) => void;
export type ParticipantEventCb = (p: ParticipantEventArgs) => void;
export type NetworkLevelChangeEventCb = (
p: NetworkLevelChangeEventArgs,
) => void;
export type FlashlightStatusChangedEventArgs = { status: string };
export type FlashlightStatusChangedEventCb = (
p: FlashlightStatusChangedEventArgs
) => void;
export type DominantSpeakerChangedEventArgs = RoomEventCommonArgs & {
participant: Participant;
};
export type DominantSpeakerChangedCb = (
d: DominantSpeakerChangedEventArgs,
) => void;
export type LocalParticipantSupportedCodecsCbEventArgs = {
supportedCodecs: Array<string>;
};
export type LocalParticipantSupportedCodecsCb = (
d: LocalParticipantSupportedCodecsCbEventArgs,
) => void;
export type TwilioVideoProps = ViewProps & {
onCameraDidStart?: () => void;
onCameraDidStopRunning?: (err: any) => void;
onCameraWasInterrupted?: () => void;
onDominantSpeakerDidChange?: DominantSpeakerChangedCb;
onParticipantAddedAudioTrack?: TrackEventCb;
onParticipantAddedVideoTrack?: TrackEventCb;
onParticipantDisabledVideoTrack?: TrackEventCb;
onParticipantDisabledAudioTrack?: TrackEventCb;
onParticipantEnabledVideoTrack?: TrackEventCb;
onParticipantEnabledAudioTrack?: TrackEventCb;
onParticipantRemovedAudioTrack?: TrackEventCb;
onParticipantRemovedVideoTrack?: TrackEventCb;
onParticipantAddedDataTrack?: TrackEventCb;
onParticipantRemovedDataTrack?: TrackEventCb;
onRoomDidConnect?: RoomEventCb;
onFlashlightStatusChanged?: FlashlightStatusChangedEventCb;
onRoomDidDisconnect?: RoomErrorEventCb;
onRoomDidFailToConnect?: RoomErrorEventCb;
onRoomParticipantDidConnect?: ParticipantEventCb;
onRoomParticipantDidDisconnect?: ParticipantEventCb;
onNetworkQualityLevelsChanged?: NetworkLevelChangeEventCb;
onLocalParticipantSupportedCodecs?: LocalParticipantSupportedCodecsCb;
onStatsReceived?: (data: any) => void;
onDataTrackMessageReceived?: DataTrackEventCb;
onDataTrackBinaryMessageReceived?: DataTrackBinaryEventCb;
localVideoTrackName?: string;
// iOS only
autoInitializeCamera?: boolean;
ref?: React.Ref<any>;
};
type iOSConnectParams = {
roomName?: string;
accessToken: string;
cameraType?: cameraType;
dominantSpeakerEnabled?: boolean;
enableAudio?: boolean;
enableVideo?: boolean;
encodingParameters?: {
enableH264Codec?: boolean;
// if audioBitrate OR videoBitrate is provided, you must provide both
audioBitrate?: number;
videoBitrate?: number;
};
enableNetworkQualityReporting?: boolean;
};
type androidConnectParams = {
roomName?: string;
accessToken: string;
cameraType?: cameraType;
dominantSpeakerEnabled?: boolean;
enableAudio?: boolean;
enableVideo?: boolean;
enableRemoteAudio?: boolean;
encodingParameters?: {
enableH264Codec?: boolean;
};
enableNetworkQualityReporting?: boolean;
maintainVideoTrackInBackground?: boolean;
};
class TwilioVideo extends React.Component<TwilioVideoProps> {
setLocalVideoEnabled: (
enabled: boolean,
cameraType?: cameraType,
) => Promise<boolean>;
setLocalAudioEnabled: (enabled: boolean) => Promise<boolean>;
setRemoteAudioEnabled: (enabled: boolean) => Promise<boolean>;
setBluetoothHeadsetConnected: (enabled: boolean) => Promise<boolean>;
connect: (options: iOSConnectParams | androidConnectParams) => void;
disconnect: () => void;
flipCamera: () => void;
toggleSoundSetup: (speaker: boolean) => void;
setFlashlightStatus: (enabled: boolean) => void;
getStats: () => void;
publishLocalAudio: () => void;
unpublishLocalAudio: () => void;
publishLocalVideo: () => void;
unpublishLocalVideo: () => void;
sendString: (message: string) => void;
/**
* Prepares the local video track so that it can receive a new name. The local
* video should be unpublished and disabled before calling this method, and you
* will need to enable and publish the video track for it to take effect.
*
* @param {string} localVideoTrackName - The new name for the local video track,
* which should match the prop of the same name. This is needed here to deal with
* platform oddities around when the prop gets sent to the native side... :-/
*/
prepareToRebuildLocalVideoTrack: (localVideoTrackName: string) => void;
/**
* Send a capture frame request to the native `TwilioVideoLocalView`.
*
* The native view then captures the frame and saves it to the apps document directory as a `.jpeg` file.
*
* An event is emitted to JS when the captured frame is saved.
*
* Listen to JS event via `DeviceEventEmitter.addListener('onFrameCaptured', ({filename}) => { // code here })`.
*
* `import { DeviceEventEmitter } from 'react-native';`
*/
captureFrame: (filename: string) => void;
}
class TwilioVideoLocalView extends React.Component<TwilioVideoLocalViewProps> {}
class TwilioVideoParticipantView extends React.Component<TwilioVideoParticipantViewProps> {}
export { TwilioVideoLocalView, TwilioVideoParticipantView, TwilioVideo };
}