forked from blackuy/react-native-twilio-video-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
180 lines (150 loc) · 5.27 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
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 type DataTrackEventCb = (t: DataTrackEventCbArgs) => 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 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;
onRoomDidDisconnect?: RoomErrorEventCb;
onRoomDidFailToConnect?: RoomErrorEventCb;
onRoomParticipantDidConnect?: ParticipantEventCb;
onRoomParticipantDidDisconnect?: ParticipantEventCb;
onNetworkQualityLevelsChanged?: NetworkLevelChangeEventCb;
onLocalParticipantSupportedCodecs?: LocalParticipantSupportedCodecsCb;
onStatsReceived?: (data: any) => void;
onDataTrackMessageReceived?: DataTrackEventCb;
// 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) => 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;
getStats: () => void;
publishLocalAudio: () => void;
unpublishLocalAudio: () => void;
publishLocalVideo: () => void;
unpublishLocalVideo: () => void;
sendString: (message: string) => void;
}
class TwilioVideoLocalView extends React.Component<
TwilioVideoLocalViewProps
> {}
class TwilioVideoParticipantView extends React.Component<
TwilioVideoParticipantViewProps
> {}
export { TwilioVideoLocalView, TwilioVideoParticipantView, TwilioVideo };
}