mediasfu-shared 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +228 -0
- package/dist/index.cjs +7707 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7285 -0
- package/dist/index.js +7690 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -0
- package/src/ProducerClient/producerClientEmits/createDeviceClient.ts +68 -0
- package/src/consumers/addVideosGrid.ts +18 -0
- package/src/consumers/autoAdjust.ts +100 -0
- package/src/consumers/calculateRowsAndColumns.ts +51 -0
- package/src/consumers/changeVids.ts +753 -0
- package/src/consumers/checkGrid.ts +100 -0
- package/src/consumers/checkPermission.ts +89 -0
- package/src/consumers/checkScreenShare.ts +114 -0
- package/src/consumers/closeAndResize.ts +401 -0
- package/src/consumers/compareActiveNames.ts +122 -0
- package/src/consumers/compareScreenStates.ts +117 -0
- package/src/consumers/connectIps.ts +175 -0
- package/src/consumers/connectLocalIps.ts +103 -0
- package/src/consumers/connectRecvTransport.ts +158 -0
- package/src/consumers/connectSendTransport.ts +150 -0
- package/src/consumers/connectSendTransportAudio.ts +161 -0
- package/src/consumers/connectSendTransportScreen.ts +169 -0
- package/src/consumers/connectSendTransportVideo.ts +149 -0
- package/src/consumers/consumerResume.ts +25 -0
- package/src/consumers/controlMedia.ts +118 -0
- package/src/consumers/createSendTransport.ts +312 -0
- package/src/consumers/disconnectSendTransportAudio.ts +170 -0
- package/src/consumers/disconnectSendTransportScreen.ts +130 -0
- package/src/consumers/disconnectSendTransportVideo.ts +161 -0
- package/src/consumers/dispStreams.ts +694 -0
- package/src/consumers/generatePageContent.ts +118 -0
- package/src/consumers/getEstimate.ts +124 -0
- package/src/consumers/getPipedProducersAlt.ts +96 -0
- package/src/consumers/getProducersPiped.ts +89 -0
- package/src/consumers/getVideos.ts +107 -0
- package/src/consumers/mixStreams.ts +97 -0
- package/src/consumers/onScreenChanges.ts +106 -0
- package/src/consumers/prepopulateUserMedia.ts +18 -0
- package/src/consumers/processConsumerTransports.ts +157 -0
- package/src/consumers/processConsumerTransportsAudio.ts +121 -0
- package/src/consumers/rePort.ts +123 -0
- package/src/consumers/reUpdateInter.ts +289 -0
- package/src/consumers/readjust.ts +170 -0
- package/src/consumers/receiveAllPipedTransports.ts +77 -0
- package/src/consumers/receiveRoomMessages.ts +55 -0
- package/src/consumers/reorderStreams.ts +246 -0
- package/src/consumers/requestScreenShare.ts +103 -0
- package/src/consumers/resumePauseAudioStreams.ts +174 -0
- package/src/consumers/resumePauseStreams.ts +110 -0
- package/src/consumers/resumeSendTransportAudio.ts +143 -0
- package/src/consumers/signalNewConsumerTransport.ts +179 -0
- package/src/consumers/socketReceiveMethods/joinConsumeRoom.ts +130 -0
- package/src/consumers/socketReceiveMethods/newPipeProducer.ts +138 -0
- package/src/consumers/socketReceiveMethods/producerClosed.ts +102 -0
- package/src/consumers/startShareScreen.ts +124 -0
- package/src/consumers/stopShareScreen.ts +241 -0
- package/src/consumers/streamSuccessAudio.ts +297 -0
- package/src/consumers/streamSuccessAudioSwitch.ts +315 -0
- package/src/consumers/streamSuccessScreen.ts +255 -0
- package/src/consumers/streamSuccessVideo.ts +373 -0
- package/src/consumers/switchUserAudio.ts +140 -0
- package/src/consumers/switchUserVideo.ts +201 -0
- package/src/consumers/switchUserVideoAlt.ts +331 -0
- package/src/consumers/trigger.ts +250 -0
- package/src/consumers/updateMiniCardsGrid.ts +150 -0
- package/src/consumers/updateParticipantAudioDecibels.ts +56 -0
- package/src/index.ts +119 -0
- package/src/methods/background/launchBackground.ts +16 -0
- package/src/methods/breakoutRooms/breakoutRoomUpdated.ts +161 -0
- package/src/methods/breakoutRooms/handleStartBreakout.ts +96 -0
- package/src/methods/breakoutRooms/handleStopBreakout.ts +72 -0
- package/src/methods/breakoutRooms/index.ts +4 -0
- package/src/methods/breakoutRooms/launchBreakoutRooms.ts +31 -0
- package/src/methods/coHost/launchCoHost.ts +28 -0
- package/src/methods/coHostMethods/index.ts +2 -0
- package/src/methods/coHostMethods/modifyCoHostSettings.ts +94 -0
- package/src/methods/displaySettings/index.ts +1 -0
- package/src/methods/displaySettings/launchDisplaySettings.ts +31 -0
- package/src/methods/displaySettings/modifyDisplaySettings.ts +242 -0
- package/src/methods/exit/confirmExit.ts +60 -0
- package/src/methods/exit/index.ts +2 -0
- package/src/methods/exit/launchConfirmExit.ts +29 -0
- package/src/methods/index.ts +5 -0
- package/src/methods/mediaSettings/launchMediaSettings.ts +61 -0
- package/src/methods/menu/launchMenuModal.ts +28 -0
- package/src/methods/message/index.ts +1 -0
- package/src/methods/message/launchMessages.ts +27 -0
- package/src/methods/message/sendMessage.ts +175 -0
- package/src/methods/participants/index.ts +3 -0
- package/src/methods/participants/launchParticipants.ts +25 -0
- package/src/methods/participants/messageParticipants.ts +78 -0
- package/src/methods/participants/muteParticipants.ts +79 -0
- package/src/methods/participants/removeParticipants.ts +97 -0
- package/src/methods/polls/handleCreatePoll.ts +66 -0
- package/src/methods/polls/handleEndPoll.ts +64 -0
- package/src/methods/polls/handleVotePoll.ts +76 -0
- package/src/methods/polls/index.ts +3 -0
- package/src/methods/polls/launchPoll.ts +25 -0
- package/src/methods/prejoin/handleCreateRoom.ts +441 -0
- package/src/methods/prejoin/handleJoinRoom.ts +153 -0
- package/src/methods/prejoin/index.ts +14 -0
- package/src/methods/recording/checkPauseState.ts +57 -0
- package/src/methods/recording/checkResumeState.ts +42 -0
- package/src/methods/recording/confirmRecording.ts +241 -0
- package/src/methods/recording/launchRecording.ts +114 -0
- package/src/methods/recording/recordPauseTimer.ts +52 -0
- package/src/methods/recording/recordResumeTimer.ts +92 -0
- package/src/methods/recording/recordStartTimer.ts +106 -0
- package/src/methods/recording/recordUpdateTimer.ts +49 -0
- package/src/methods/recording/startRecording.ts +268 -0
- package/src/methods/recording/stopRecording.ts +124 -0
- package/src/methods/recording/updateRecording.ts +245 -0
- package/src/methods/requests/index.ts +1 -0
- package/src/methods/requests/launchRequests.ts +25 -0
- package/src/methods/requests/respondToRequests.ts +108 -0
- package/src/methods/settings/index.ts +2 -0
- package/src/methods/settings/launchSettings.ts +25 -0
- package/src/methods/settings/modifySettings.ts +99 -0
- package/src/methods/stream/clickVideo.ts +337 -0
- package/src/methods/stream/index.ts +3 -0
- package/src/methods/stream/switchAudio.ts +73 -0
- package/src/methods/stream/switchVideo.ts +148 -0
- package/src/methods/stream/switchVideoAlt.ts +152 -0
- package/src/methods/utils/checkLimitsAndMakeRequest.ts +103 -0
- package/src/methods/utils/validateAlphanumeric.ts +41 -0
- package/src/methods/waiting/index.ts +1 -0
- package/src/methods/waiting/launchWaiting.ts +26 -0
- package/src/methods/waiting/respondToWaiting.ts +82 -0
- package/src/methods/welcome/handleWelcomeRequest.ts +189 -0
- package/src/methods/welcome/index.ts +5 -0
- package/src/methods/whiteboard/handleStartWhiteboard.ts +65 -0
- package/src/methods/whiteboard/handleStopWhiteboard.ts +48 -0
- package/src/methods/whiteboard/index.ts +4 -0
- package/src/methods/whiteboard/launchConfigureWhiteboard.ts +29 -0
- package/src/producers/producerEmits/joinConRoom.ts +153 -0
- package/src/sockets/SocketManager.ts +232 -0
- package/src/types/shared-base-types.ts +752 -0
- package/src/types/types.ts +84 -0
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Stream, Participant, Transport, PrepopulateUserMediaParameters, PrepopulateUserMediaType, RePortParameters, RePortType,
|
|
3
|
+
ProcessConsumerTransportsParameters, ProcessConsumerTransportsType, ResumePauseStreamsParameters, ResumePauseStreamsType, ReadjustParameters, ReadjustType, AddVideosGridType, AddVideosGridParameters, GetEstimateType, CheckGridType, ResumePauseAudioStreamsParameters, ResumePauseAudioStreamsType, GetEstimateParameters,
|
|
4
|
+
EventType
|
|
5
|
+
} from "../types/types";
|
|
6
|
+
|
|
7
|
+
export interface DispStreamsParameters extends PrepopulateUserMediaParameters, RePortParameters, ProcessConsumerTransportsParameters, ResumePauseStreamsParameters, ReadjustParameters, ResumePauseAudioStreamsParameters, GetEstimateParameters, AddVideosGridParameters {
|
|
8
|
+
consumerTransports: Transport[];
|
|
9
|
+
streamNames: Stream[];
|
|
10
|
+
audStreamNames: Stream[];
|
|
11
|
+
participants: Participant[];
|
|
12
|
+
ref_participants: Participant[];
|
|
13
|
+
recordingDisplayType: 'video' | 'media' | 'all';
|
|
14
|
+
recordingVideoOptimized: boolean;
|
|
15
|
+
meetingDisplayType: string;
|
|
16
|
+
meetingVideoOptimized: boolean;
|
|
17
|
+
currentUserPage: number;
|
|
18
|
+
hostLabel: string;
|
|
19
|
+
mainHeightWidth: number;
|
|
20
|
+
prevMainHeightWidth: number;
|
|
21
|
+
prevDoPaginate: boolean;
|
|
22
|
+
doPaginate: boolean;
|
|
23
|
+
firstAll: boolean;
|
|
24
|
+
shared: boolean;
|
|
25
|
+
shareScreenStarted: boolean;
|
|
26
|
+
shareEnded: boolean;
|
|
27
|
+
oldAllStreams: (Stream | Participant)[];
|
|
28
|
+
updateMainWindow: boolean;
|
|
29
|
+
remoteProducerId?: string;
|
|
30
|
+
activeNames: string[];
|
|
31
|
+
dispActiveNames: string[];
|
|
32
|
+
p_dispActiveNames: string[];
|
|
33
|
+
nForReadjustRecord: number;
|
|
34
|
+
first_round: boolean;
|
|
35
|
+
lock_screen: boolean;
|
|
36
|
+
chatRefStreams: (Stream | Participant)[];
|
|
37
|
+
eventType: EventType;
|
|
38
|
+
islevel: string;
|
|
39
|
+
localStreamVideo: MediaStream | null;
|
|
40
|
+
|
|
41
|
+
breakOutRoomStarted: boolean;
|
|
42
|
+
breakOutRoomEnded: boolean;
|
|
43
|
+
keepBackground: boolean;
|
|
44
|
+
virtualStream: MediaStream | null;
|
|
45
|
+
|
|
46
|
+
updateActiveNames: (names: string[]) => void;
|
|
47
|
+
updateDispActiveNames: (names: string[]) => void;
|
|
48
|
+
updateLStreams: (streams: (Stream | Participant)[]) => void;
|
|
49
|
+
updateChatRefStreams: (streams: (Stream | Participant)[]) => void;
|
|
50
|
+
updateNForReadjustRecord: (n: number) => void;
|
|
51
|
+
updateUpdateMainWindow: (value: boolean) => void;
|
|
52
|
+
updateShowMiniView: (value: boolean) => void;
|
|
53
|
+
|
|
54
|
+
// mediasfu functions
|
|
55
|
+
prepopulateUserMedia: PrepopulateUserMediaType;
|
|
56
|
+
rePort: RePortType;
|
|
57
|
+
processConsumerTransports: ProcessConsumerTransportsType;
|
|
58
|
+
resumePauseStreams: ResumePauseStreamsType;
|
|
59
|
+
readjust: ReadjustType;
|
|
60
|
+
addVideosGrid: AddVideosGridType;
|
|
61
|
+
getEstimate: GetEstimateType;
|
|
62
|
+
checkGrid: CheckGridType;
|
|
63
|
+
resumePauseAudioStreams: ResumePauseAudioStreamsType;
|
|
64
|
+
|
|
65
|
+
getUpdatedAllParams: () => DispStreamsParameters;
|
|
66
|
+
[key: string]: any;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface DispStreamsOptions {
|
|
70
|
+
lStreams: (Stream | Participant)[];
|
|
71
|
+
ind: number;
|
|
72
|
+
auto?: boolean;
|
|
73
|
+
ChatSkip?: boolean;
|
|
74
|
+
forChatCard?: any;
|
|
75
|
+
forChatID?: any;
|
|
76
|
+
parameters: DispStreamsParameters;
|
|
77
|
+
breakRoom?: number;
|
|
78
|
+
inBreakRoom?: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Export the type definition for the function
|
|
82
|
+
export type DispStreamsType = (options: DispStreamsOptions) => Promise<void>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Function to display streams based on various parameters and conditions.
|
|
86
|
+
*
|
|
87
|
+
* @param {DispStreamsOptions} options - The options object.
|
|
88
|
+
* @param {Array} options.lStreams - List of streams to display.
|
|
89
|
+
* @param {number} options.ind - Index of the current stream.
|
|
90
|
+
* @param {boolean} [options.auto=false] - Flag to indicate if the function should run automatically.
|
|
91
|
+
* @param {boolean} [options.ChatSkip=false] - Flag to indicate if chat should be skipped.
|
|
92
|
+
* @param {string|null} [options.forChatID=null] - ID for chat reference.
|
|
93
|
+
* @param {DispStreamsParameters} options.parameters - Parameters object containing various settings and functions.
|
|
94
|
+
* @param {number} [options.breakRoom=-1] - Break room number.
|
|
95
|
+
* @param {boolean} [options.inBreakRoom=false] - Flag to indicate if in break room.
|
|
96
|
+
*
|
|
97
|
+
* @returns {Promise<void>} A promise that resolves when the function completes.
|
|
98
|
+
*
|
|
99
|
+
* @throws Will log an error if an issue occurs during the display of streams.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* const options = {
|
|
103
|
+
* lStreams: [stream1, stream2],
|
|
104
|
+
* ind: 0,
|
|
105
|
+
* auto: true,
|
|
106
|
+
* ChatSkip: false,
|
|
107
|
+
* forChatID: 'chat123',
|
|
108
|
+
* parameters: {
|
|
109
|
+
* consumerTransports: [],
|
|
110
|
+
* streamNames: [],
|
|
111
|
+
* audStreamNames: [],
|
|
112
|
+
* participants: [],
|
|
113
|
+
* ref_participants: [],
|
|
114
|
+
* recordingDisplayType: 'video',
|
|
115
|
+
* recordingVideoOptimized: false,
|
|
116
|
+
* meetingDisplayType: 'video',
|
|
117
|
+
* meetingVideoOptimized: false,
|
|
118
|
+
* currentUserPage: 1,
|
|
119
|
+
* hostLabel: 'Host',
|
|
120
|
+
* mainHeightWidth: 800,
|
|
121
|
+
* prevMainHeightWidth: 600,
|
|
122
|
+
* prevDoPaginate: false,
|
|
123
|
+
* doPaginate: true,
|
|
124
|
+
* firstAll: true,
|
|
125
|
+
* shared: false,
|
|
126
|
+
* shareScreenStarted: false,
|
|
127
|
+
* shareEnded: false,
|
|
128
|
+
* oldAllStreams: [],
|
|
129
|
+
* updateMainWindow: true,
|
|
130
|
+
* remoteProducerId: null,
|
|
131
|
+
* activeNames: [],
|
|
132
|
+
* dispActiveNames: [],
|
|
133
|
+
* p_dispActiveNames: [],
|
|
134
|
+
* nForReadjustRecord: 0,
|
|
135
|
+
* first_round: false,
|
|
136
|
+
* lock_screen: false,
|
|
137
|
+
* chatRefStreams: [],
|
|
138
|
+
* eventType: 'meeting',
|
|
139
|
+
* islevel: '1',
|
|
140
|
+
* localStreamVideo: null,
|
|
141
|
+
* breakOutRoomStarted: false,
|
|
142
|
+
* breakOutRoomEnded: false,
|
|
143
|
+
* keepBackground: false,
|
|
144
|
+
* virtualStream: null,
|
|
145
|
+
* updateActiveNames: (names) => console.log('Updated active names:', names),
|
|
146
|
+
* updateDispActiveNames: (names) => console.log('Updated displayed active names:', names),
|
|
147
|
+
* updateLStreams: (streams) => console.log('Updated limited streams:', streams),
|
|
148
|
+
* updateChatRefStreams: (streams) => console.log('Updated chat reference streams:', streams),
|
|
149
|
+
* updateNForReadjustRecord: (n) => console.log('Updated n for readjustment:', n),
|
|
150
|
+
* updateUpdateMainWindow: (state) => console.log('Main window updated:', state),
|
|
151
|
+
* updateShowMiniView: (value) => console.log('Mini view updated:', value),
|
|
152
|
+
* prepopulateUserMedia: async () => { console.log('your logic')},
|
|
153
|
+
* rePort: async () => { console.log('your logic')},
|
|
154
|
+
* processConsumerTransports: async () => { console.log('your logic')},
|
|
155
|
+
* resumePauseStreams: async () => { console.log('your logic')},
|
|
156
|
+
* readjust: async () => { console.log('your logic')},
|
|
157
|
+
* addVideosGrid: async () => { console.log('your logic')},
|
|
158
|
+
* getEstimate: async () => { console.log('your logic')},
|
|
159
|
+
* checkGrid: async () => { console.log('your logic')},
|
|
160
|
+
* resumePauseAudioStreams: async () => { console.log('your logic')},
|
|
161
|
+
* getUpdatedAllParams: () => { console.log('your logic')},
|
|
162
|
+
* },
|
|
163
|
+
* breakRoom: 1,
|
|
164
|
+
* inBreakRoom: false,
|
|
165
|
+
* };
|
|
166
|
+
*
|
|
167
|
+
* dispStreams(options)
|
|
168
|
+
* .then(() => {
|
|
169
|
+
* console.log('Streams displayed successfully');
|
|
170
|
+
* })
|
|
171
|
+
* .catch((error) => {
|
|
172
|
+
* console.error('Error displaying streams:', error);
|
|
173
|
+
* });
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
export async function dispStreams({
|
|
177
|
+
lStreams,
|
|
178
|
+
ind,
|
|
179
|
+
auto = false,
|
|
180
|
+
ChatSkip = false,
|
|
181
|
+
forChatID = null,
|
|
182
|
+
parameters,
|
|
183
|
+
breakRoom = -1,
|
|
184
|
+
inBreakRoom = false,
|
|
185
|
+
}: DispStreamsOptions): Promise<void> {
|
|
186
|
+
// Function to display streams
|
|
187
|
+
|
|
188
|
+
let { getUpdatedAllParams } = parameters;
|
|
189
|
+
parameters = getUpdatedAllParams();
|
|
190
|
+
|
|
191
|
+
let {
|
|
192
|
+
consumerTransports,
|
|
193
|
+
streamNames,
|
|
194
|
+
audStreamNames,
|
|
195
|
+
participants,
|
|
196
|
+
ref_participants,
|
|
197
|
+
recordingDisplayType,
|
|
198
|
+
recordingVideoOptimized,
|
|
199
|
+
meetingDisplayType,
|
|
200
|
+
meetingVideoOptimized,
|
|
201
|
+
currentUserPage,
|
|
202
|
+
hostLabel,
|
|
203
|
+
mainHeightWidth,
|
|
204
|
+
prevMainHeightWidth,
|
|
205
|
+
prevDoPaginate,
|
|
206
|
+
doPaginate,
|
|
207
|
+
firstAll,
|
|
208
|
+
shared,
|
|
209
|
+
shareScreenStarted,
|
|
210
|
+
shareEnded,
|
|
211
|
+
oldAllStreams,
|
|
212
|
+
updateMainWindow,
|
|
213
|
+
remoteProducerId,
|
|
214
|
+
activeNames,
|
|
215
|
+
dispActiveNames,
|
|
216
|
+
p_dispActiveNames,
|
|
217
|
+
nForReadjustRecord,
|
|
218
|
+
first_round,
|
|
219
|
+
lock_screen,
|
|
220
|
+
chatRefStreams,
|
|
221
|
+
eventType,
|
|
222
|
+
islevel,
|
|
223
|
+
localStreamVideo,
|
|
224
|
+
|
|
225
|
+
breakOutRoomStarted,
|
|
226
|
+
breakOutRoomEnded,
|
|
227
|
+
keepBackground,
|
|
228
|
+
virtualStream,
|
|
229
|
+
|
|
230
|
+
updateActiveNames,
|
|
231
|
+
updateDispActiveNames,
|
|
232
|
+
updateLStreams,
|
|
233
|
+
updateChatRefStreams,
|
|
234
|
+
updateNForReadjustRecord,
|
|
235
|
+
updateUpdateMainWindow,
|
|
236
|
+
updateShowMiniView,
|
|
237
|
+
|
|
238
|
+
prepopulateUserMedia,
|
|
239
|
+
rePort,
|
|
240
|
+
processConsumerTransports,
|
|
241
|
+
resumePauseStreams,
|
|
242
|
+
readjust,
|
|
243
|
+
addVideosGrid,
|
|
244
|
+
checkGrid,
|
|
245
|
+
getEstimate,
|
|
246
|
+
resumePauseAudioStreams,
|
|
247
|
+
} = parameters;
|
|
248
|
+
|
|
249
|
+
let proceed = true;
|
|
250
|
+
|
|
251
|
+
let lStreams_ = lStreams.filter((stream) => stream.producerId !== "youyou" && stream.producerId !== "youyouyou");
|
|
252
|
+
|
|
253
|
+
lStreams_ = lStreams_.filter((stream) => stream.id !== "youyou" && stream.id !== "youyouyou" && stream.name !== "youyou" && stream.name !== "youyouyou");
|
|
254
|
+
|
|
255
|
+
if (eventType === "chat") {
|
|
256
|
+
proceed = true;
|
|
257
|
+
} else if (ind === 0 || (islevel !== "2" && currentUserPage === ind)) {
|
|
258
|
+
proceed = false;
|
|
259
|
+
|
|
260
|
+
//get the name of every participant in lStreams if stream !null and assign it to activeNames
|
|
261
|
+
lStreams_.forEach((stream) => {
|
|
262
|
+
let checker = false;
|
|
263
|
+
let check_level = 0;
|
|
264
|
+
|
|
265
|
+
if (recordingDisplayType === "video") {
|
|
266
|
+
if (recordingVideoOptimized) {
|
|
267
|
+
if (Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
268
|
+
stream.producerId != null &&
|
|
269
|
+
stream.producerId !== "") {
|
|
270
|
+
checker = true;
|
|
271
|
+
check_level = 0;
|
|
272
|
+
}
|
|
273
|
+
} else {
|
|
274
|
+
if ((Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
275
|
+
stream.producerId != null &&
|
|
276
|
+
stream.producerId !== "") ||
|
|
277
|
+
(Object.prototype.hasOwnProperty.call(stream, "audioID") &&
|
|
278
|
+
stream.audioID != null &&
|
|
279
|
+
stream.audioID !== "")) {
|
|
280
|
+
checker = true;
|
|
281
|
+
check_level = 1;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
} else if (recordingDisplayType === "media") {
|
|
285
|
+
if ((Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
286
|
+
stream.producerId != null &&
|
|
287
|
+
stream.producerId !== "") ||
|
|
288
|
+
(Object.prototype.hasOwnProperty.call(stream, "audioID") &&
|
|
289
|
+
stream.audioID != null &&
|
|
290
|
+
stream.audioID !== "")) {
|
|
291
|
+
checker = true;
|
|
292
|
+
check_level = 1;
|
|
293
|
+
}
|
|
294
|
+
} else {
|
|
295
|
+
if ((Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
296
|
+
stream.producerId != null &&
|
|
297
|
+
stream.producerId !== "") ||
|
|
298
|
+
(Object.prototype.hasOwnProperty.call(stream, "audioID") &&
|
|
299
|
+
stream.audioID != null &&
|
|
300
|
+
stream.audioID !== "") ||
|
|
301
|
+
(Object.prototype.hasOwnProperty.call(stream, "name") &&
|
|
302
|
+
stream.name !== null &&
|
|
303
|
+
stream.name != "")) {
|
|
304
|
+
checker = true;
|
|
305
|
+
check_level = 2;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
let participant;
|
|
310
|
+
|
|
311
|
+
if (checker) {
|
|
312
|
+
// find the participant with the same videoID as the stream
|
|
313
|
+
if (check_level == 0) {
|
|
314
|
+
if (Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
315
|
+
stream.producerId != null &&
|
|
316
|
+
stream.producerId !== "") {
|
|
317
|
+
participant = streamNames.find(
|
|
318
|
+
(obj) => obj.producerId === stream.producerId
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
} else if (check_level == 1) {
|
|
322
|
+
// find for either producerId or name
|
|
323
|
+
if (Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
324
|
+
stream.producerId != null &&
|
|
325
|
+
stream.producerId !== "") {
|
|
326
|
+
participant = streamNames.find(
|
|
327
|
+
(obj) => obj.producerId === stream.producerId
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
if (!participant) {
|
|
331
|
+
if (Object.prototype.hasOwnProperty.call(stream, "audioID") &&
|
|
332
|
+
stream.audioID != null &&
|
|
333
|
+
stream.audioID !== "") {
|
|
334
|
+
participant = audStreamNames.find(
|
|
335
|
+
(obj) => obj.producerId === stream.audioID
|
|
336
|
+
);
|
|
337
|
+
if (!participant) {
|
|
338
|
+
participant = ref_participants.find(
|
|
339
|
+
(obj) => obj.audioID === stream.audioID
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
} else if (check_level == 2) {
|
|
345
|
+
if (Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
346
|
+
stream.producerId != null &&
|
|
347
|
+
stream.producerId !== "") {
|
|
348
|
+
participant = streamNames.find(
|
|
349
|
+
(obj) => obj.producerId === stream.producerId
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
if (!participant) {
|
|
353
|
+
if (Object.prototype.hasOwnProperty.call(stream, "audioID") &&
|
|
354
|
+
stream.audioID != null &&
|
|
355
|
+
stream.audioID !== "") {
|
|
356
|
+
participant = audStreamNames.find(
|
|
357
|
+
(obj) => obj.producerId === stream.audioID
|
|
358
|
+
);
|
|
359
|
+
if (!participant) {
|
|
360
|
+
participant = ref_participants.find(
|
|
361
|
+
(obj) => obj.audioID === stream.audioID
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (!participant) {
|
|
367
|
+
if (Object.prototype.hasOwnProperty.call(stream, "name") &&
|
|
368
|
+
stream.name !== null &&
|
|
369
|
+
stream.name != "") {
|
|
370
|
+
participant = ref_participants.find(
|
|
371
|
+
(obj) => obj.name === stream.name
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// push the name of the participant to activeNames
|
|
378
|
+
if (participant) {
|
|
379
|
+
// if activeNames does not include the name of the participant, push it
|
|
380
|
+
if (participant.name && !activeNames.includes(participant.name)) {
|
|
381
|
+
activeNames.push(participant.name);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
updateActiveNames(activeNames);
|
|
388
|
+
|
|
389
|
+
lStreams_.forEach((stream) => {
|
|
390
|
+
let disp_checker = false;
|
|
391
|
+
let disp_check_level = 0;
|
|
392
|
+
|
|
393
|
+
if (meetingDisplayType == "video") {
|
|
394
|
+
if (meetingVideoOptimized) {
|
|
395
|
+
if (Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
396
|
+
stream.producerId != null &&
|
|
397
|
+
stream.producerId !== "") {
|
|
398
|
+
disp_checker = true;
|
|
399
|
+
disp_check_level = 0;
|
|
400
|
+
}
|
|
401
|
+
} else {
|
|
402
|
+
if ((Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
403
|
+
stream.producerId != null &&
|
|
404
|
+
stream.producerId !== "") ||
|
|
405
|
+
(Object.prototype.hasOwnProperty.call(stream, "audioID") &&
|
|
406
|
+
stream.audioID != null &&
|
|
407
|
+
stream.audioID !== "")) {
|
|
408
|
+
disp_checker = true;
|
|
409
|
+
disp_check_level = 1;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
} else if (meetingDisplayType == "media") {
|
|
413
|
+
if ((Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
414
|
+
stream.producerId != null &&
|
|
415
|
+
stream.producerId !== "") ||
|
|
416
|
+
(Object.prototype.hasOwnProperty.call(stream, "audioID") &&
|
|
417
|
+
stream.audioID != null &&
|
|
418
|
+
stream.audioID !== "")) {
|
|
419
|
+
disp_checker = true;
|
|
420
|
+
disp_check_level = 1;
|
|
421
|
+
}
|
|
422
|
+
} else {
|
|
423
|
+
if ((Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
424
|
+
stream.producerId != null &&
|
|
425
|
+
stream.producerId !== "") ||
|
|
426
|
+
(Object.prototype.hasOwnProperty.call(stream, "audioID") &&
|
|
427
|
+
stream.audioID != null &&
|
|
428
|
+
stream.audioID !== "") ||
|
|
429
|
+
(Object.prototype.hasOwnProperty.call(stream, "name") &&
|
|
430
|
+
stream.name !== null &&
|
|
431
|
+
stream.name != "")) {
|
|
432
|
+
disp_checker = true;
|
|
433
|
+
disp_check_level = 2;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
let participant_;
|
|
438
|
+
|
|
439
|
+
if (disp_checker) {
|
|
440
|
+
if (disp_check_level == 0) {
|
|
441
|
+
if (Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
442
|
+
stream.producerId != null &&
|
|
443
|
+
stream.producerId !== "") {
|
|
444
|
+
participant_ = streamNames.find(
|
|
445
|
+
(obj) => obj.producerId === stream.producerId
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
} else if (disp_check_level == 1) {
|
|
449
|
+
// find for either producerId or name
|
|
450
|
+
if (Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
451
|
+
stream.producerId != null &&
|
|
452
|
+
stream.producerId !== "") {
|
|
453
|
+
participant_ = streamNames.find(
|
|
454
|
+
(obj) => obj.producerId === stream.producerId
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
if (!participant_) {
|
|
458
|
+
if (Object.prototype.hasOwnProperty.call(stream, "audioID") &&
|
|
459
|
+
stream.audioID != null &&
|
|
460
|
+
stream.audioID !== "") {
|
|
461
|
+
participant_ = audStreamNames.find(
|
|
462
|
+
(obj) => obj.producerId === stream.audioID
|
|
463
|
+
);
|
|
464
|
+
if (!participant_) {
|
|
465
|
+
participant_ = ref_participants.find(
|
|
466
|
+
(obj) => obj.audioID === stream.audioID
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
} else if (disp_check_level == 2) {
|
|
472
|
+
if (Object.prototype.hasOwnProperty.call(stream, "producerId") &&
|
|
473
|
+
stream.producerId != null &&
|
|
474
|
+
stream.producerId !== "") {
|
|
475
|
+
participant_ = streamNames.find(
|
|
476
|
+
(obj) => obj.producerId === stream.producerId
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
if (!participant_) {
|
|
480
|
+
if (Object.prototype.hasOwnProperty.call(stream, "audioID") &&
|
|
481
|
+
stream.audioID != null &&
|
|
482
|
+
stream.audioID !== "") {
|
|
483
|
+
participant_ = audStreamNames.find(
|
|
484
|
+
(obj) => obj.producerId === stream.audioID
|
|
485
|
+
);
|
|
486
|
+
if (!participant_) {
|
|
487
|
+
participant_ = ref_participants.find(
|
|
488
|
+
(obj) => obj.audioID === stream.audioID
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (!participant_) {
|
|
494
|
+
if (Object.prototype.hasOwnProperty.call(stream, "name") &&
|
|
495
|
+
stream.name !== null &&
|
|
496
|
+
stream.name != "") {
|
|
497
|
+
participant_ = ref_participants.find(
|
|
498
|
+
(obj) => obj.name === stream.name
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// push the name of the participant to activeNames
|
|
506
|
+
if (participant_) {
|
|
507
|
+
// if dispActiveNames does not include the name of the participant, push it
|
|
508
|
+
if (participant_.name && !dispActiveNames.includes(participant_.name)) {
|
|
509
|
+
dispActiveNames.push(participant_.name);
|
|
510
|
+
if (!p_dispActiveNames.includes(participant_.name)) {
|
|
511
|
+
proceed = true;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
updateDispActiveNames(dispActiveNames);
|
|
518
|
+
|
|
519
|
+
if (lStreams_.length < 1 && (shareScreenStarted || shared || !firstAll)) {
|
|
520
|
+
proceed = true;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (shareScreenStarted || shared) {
|
|
524
|
+
// Additional logic
|
|
525
|
+
} else {
|
|
526
|
+
if (prevMainHeightWidth !== mainHeightWidth) {
|
|
527
|
+
updateMainWindow = true;
|
|
528
|
+
updateUpdateMainWindow(updateMainWindow);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
nForReadjustRecord = activeNames.length;
|
|
533
|
+
updateNForReadjustRecord(nForReadjustRecord);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
if (!proceed && auto) {
|
|
537
|
+
if (updateMainWindow && !lock_screen && !shared) {
|
|
538
|
+
await prepopulateUserMedia({ name: hostLabel, parameters });
|
|
539
|
+
} else if (!first_round) {
|
|
540
|
+
await prepopulateUserMedia({ name: hostLabel, parameters });
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
if (ind === 0 && eventType !== "chat") {
|
|
544
|
+
await rePort({ parameters });
|
|
545
|
+
}
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if (eventType == "broadcast") {
|
|
550
|
+
lStreams = lStreams_;
|
|
551
|
+
updateLStreams(lStreams);
|
|
552
|
+
} else if (eventType == "chat") {
|
|
553
|
+
if (forChatID != null) {
|
|
554
|
+
lStreams = chatRefStreams;
|
|
555
|
+
updateLStreams(lStreams);
|
|
556
|
+
} else {
|
|
557
|
+
updateShowMiniView(false);
|
|
558
|
+
|
|
559
|
+
if (islevel != "2") {
|
|
560
|
+
let host = participants.find((obj) => {
|
|
561
|
+
return obj.islevel === "2";
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
if (host) {
|
|
565
|
+
let streame;
|
|
566
|
+
|
|
567
|
+
remoteProducerId = host.videoID as string;
|
|
568
|
+
// get the stream from allvideostream with the same id as remoteProducerId
|
|
569
|
+
|
|
570
|
+
if (islevel == "2") {
|
|
571
|
+
host.stream =
|
|
572
|
+
keepBackground && virtualStream
|
|
573
|
+
? virtualStream
|
|
574
|
+
: localStreamVideo;
|
|
575
|
+
} else {
|
|
576
|
+
streame = oldAllStreams.find(
|
|
577
|
+
(streame) => streame.producerId == remoteProducerId
|
|
578
|
+
);
|
|
579
|
+
// add streame to lStreams
|
|
580
|
+
if (streame) {
|
|
581
|
+
//remove any stream with name of host.name
|
|
582
|
+
lStreams = lStreams.filter((stream) => {
|
|
583
|
+
return stream.name != host.name;
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
lStreams.push(streame);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
//remove youyou and youyouyou from lStreams and then put it at the end
|
|
593
|
+
let youyou = lStreams.find((obj) => {
|
|
594
|
+
return obj.producerId === "youyou" || obj.producerId === "youyouyou";
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
lStreams = lStreams.filter((stream) => {
|
|
598
|
+
return (
|
|
599
|
+
stream.producerId != "youyou" && stream.producerId != "youyouyou"
|
|
600
|
+
);
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
if (youyou) {
|
|
604
|
+
lStreams.push(youyou);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
chatRefStreams = lStreams;
|
|
608
|
+
|
|
609
|
+
updateLStreams(lStreams);
|
|
610
|
+
updateChatRefStreams(chatRefStreams);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
let refLength = lStreams.length;
|
|
615
|
+
|
|
616
|
+
const [, rows, cols] = getEstimate({ n: refLength, parameters });
|
|
617
|
+
let result = await checkGrid({ rows, cols, actives: refLength }) || [false, 0, 0, 0, 0, 0, 0];
|
|
618
|
+
let [removeAltGrid, numtoaddd, numRows, numCols, , actualRows, lastrowcols] = result;
|
|
619
|
+
|
|
620
|
+
if (ChatSkip && eventType === "chat") {
|
|
621
|
+
numRows = 1;
|
|
622
|
+
numCols = 1;
|
|
623
|
+
actualRows = 1;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
await readjust({ n: lStreams.length, state: ind, parameters });
|
|
627
|
+
|
|
628
|
+
let mainGridStreams = lStreams.slice(0, numtoaddd);
|
|
629
|
+
let altGridStreams = lStreams.slice(numtoaddd);
|
|
630
|
+
|
|
631
|
+
if (doPaginate || prevDoPaginate !== doPaginate || shared || shareScreenStarted || shareEnded) {
|
|
632
|
+
let lStreams_alt = lStreams_;
|
|
633
|
+
await processConsumerTransports({ consumerTransports, lStreams_: lStreams_alt, parameters });
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
try {
|
|
637
|
+
if (breakOutRoomStarted && !breakOutRoomEnded) {
|
|
638
|
+
await resumePauseAudioStreams({ inBreakRoom, breakRoom, parameters });
|
|
639
|
+
} else {
|
|
640
|
+
await resumePauseStreams({ parameters });
|
|
641
|
+
}
|
|
642
|
+
} catch {
|
|
643
|
+
// console.log('Error in resumePauseAudioStreams:', error);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
try {
|
|
647
|
+
if (!breakOutRoomStarted || (breakOutRoomStarted && breakOutRoomEnded)) {
|
|
648
|
+
await resumePauseStreams({ parameters });
|
|
649
|
+
}
|
|
650
|
+
} catch {
|
|
651
|
+
// console.log('Error in resumePauseStreams:', error
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
if (shareEnded) {
|
|
655
|
+
shareEnded = false;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (ChatSkip && eventType === "chat") {
|
|
660
|
+
await addVideosGrid({
|
|
661
|
+
mainGridStreams,
|
|
662
|
+
altGridStreams,
|
|
663
|
+
numtoadd: numtoaddd - 1,
|
|
664
|
+
numRows,
|
|
665
|
+
numCols,
|
|
666
|
+
actualRows,
|
|
667
|
+
lastrowcols,
|
|
668
|
+
removeAltGrid,
|
|
669
|
+
parameters,
|
|
670
|
+
});
|
|
671
|
+
} else {
|
|
672
|
+
await addVideosGrid({
|
|
673
|
+
mainGridStreams,
|
|
674
|
+
altGridStreams,
|
|
675
|
+
numtoadd: numtoaddd,
|
|
676
|
+
numRows,
|
|
677
|
+
numCols,
|
|
678
|
+
actualRows,
|
|
679
|
+
lastrowcols,
|
|
680
|
+
removeAltGrid,
|
|
681
|
+
parameters,
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
if (updateMainWindow && !lock_screen && !shared) {
|
|
686
|
+
await prepopulateUserMedia({ name: hostLabel, parameters });
|
|
687
|
+
} else if (!first_round) {
|
|
688
|
+
await prepopulateUserMedia({ name: hostLabel, parameters });
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
if (ind === 0 && eventType !== "chat") {
|
|
692
|
+
await rePort({ parameters });
|
|
693
|
+
}
|
|
694
|
+
}
|