forked from bigbluebutton/bigbluebutton-api-php
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathCreateMeetingParameters.php
More file actions
444 lines (391 loc) · 17.3 KB
/
CreateMeetingParameters.php
File metadata and controls
444 lines (391 loc) · 17.3 KB
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
<?php
declare(strict_types=1);
/**
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
*
* Copyright (c) 2016-2018 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/
namespace BigBlueButton\Parameters;
use BigBlueButton\Enum\Feature;
use BigBlueButton\Enum\GuestPolicy;
use BigBlueButton\Enum\MeetingLayout;
/**
* @method string getName()
* @method $this setName(string $name)
* @method string getMeetingID()
* @method $this setMeetingID(string $id)
* @method string getWelcome()
* @method $this setWelcome(string $welcome)
* @method string getDialNumber()
* @method $this setDialNumber(string $dialNumber)
* @method string getVoiceBridge()
* @method $this setVoiceBridge(string $voiceBridge)
* @method string getWebVoice()
* @method $this setWebVoice(string $webVoice)
* @method int getMaxParticipants()
* @method $this setMaxParticipants(int $maxParticipants)
* @method string getLogoutURL()
* @method $this setLogoutURL(string $logoutURL)
* @method bool|null isRecord()
* @method $this setRecord(bool $isRecord)
* @method bool|null isNotifyRecordingIsOn()
* @method $this setNotifyRecordingIsOn(bool $isNotifyRecordingIsOn)
* @method bool|null isRemindRecordingIsOn()
* @method $this setRemindRecordingIsOn(bool $remindRecordingIsOn)
* @method bool|null isRecordFullDurationMedia()
* @method $this setRecordFullDurationMedia(bool $recordFullDurationMedia)
* @method int getDuration()
* @method $this setDuration(int $duration)
* @method string getParentMeetingID()
* @method $this setParentMeetingID(string $parentMeetingID)
* @method int getSequence()
* @method $this setSequence(int $sequence)
* @method bool|null isFreeJoin()
* @method $this setFreeJoin(bool $isFreeJoin)
* @method bool|null isBreakoutRoomsPrivateChatEnabled()
* @method $this setBreakoutRoomsPrivateChatEnabled(bool $isBreakoutRoomsPrivateChatEnabled)
* @method bool|null isBreakoutRoomsRecord()
* @method $this setBreakoutRoomsRecord(bool $isBreakoutRoomsRecord)
* @method string getModeratorOnlyMessage()
* @method $this setModeratorOnlyMessage(string $message)
* @method bool|null isAutoStartRecording()
* @method $this setAutoStartRecording(bool $isAutoStartRecording)
* @method bool|null isAllowStartStopRecording()
* @method $this setAllowStartStopRecording(bool $isAllow)
* @method bool|null isWebcamsOnlyForModerator()
* @method $this setWebcamsOnlyForModerator(bool $isWebcamsOnlyForModerator)
* @method string getLogo()
* @method $this setLogo(string $logo)
* @method string getBannerText()
* @method $this setBannerText(string $bannerText)
* @method string getBannerColor()
* @method $this setBannerColor(string $bannerColor)
* @method string getCopyright()
* @method $this setCopyright(string $copyright)
* @method bool|null isMuteOnStart()
* @method $this setMuteOnStart(bool $isMuteOnStart)
* @method bool|null isAllowModsToUnmuteUsers()
* @method $this setAllowModsToUnmuteUsers(bool $isAllowModsToUnmuteUsers)
* @method bool|null isLockSettingsDisableCam()
* @method $this setLockSettingsDisableCam(bool $isLockSettingsDisableCam)
* @method bool|null isLockSettingsDisableMic()
* @method $this setLockSettingsDisableMic(bool $isLockSettingsDisableMic)
* @method bool|null isLockSettingsDisablePrivateChat()
* @method $this setLockSettingsDisablePrivateChat(bool $isLockSettingsDisablePrivateChat)
* @method bool|null isLockSettingsDisablePublicChat()
* @method $this setLockSettingsDisablePublicChat(bool $isLockSettingsDisablePublicChat)
* @method bool|null isLockSettingsDisableNotes()
* @method $this setLockSettingsDisableNotes(bool $isLockSettingsDisableNotes)
* @method bool|null isLockSettingsLockedLayout()
* @method $this setLockSettingsLockedLayout(bool $isLockSettingsLockedLayout)
* @method bool|null isLockSettingsHideUserList()
* @method $this setLockSettingsHideUserList(bool $isLockSettingsHideUserList)
* @method bool|null isLockSettingsLockOnJoin()
* @method $this setLockSettingsLockOnJoin(bool $isLockSettingsLockOnJoin)
* @method bool|null isLockSettingsLockOnJoinConfigurable()
* @method $this setLockSettingsLockOnJoinConfigurable(bool $isLockSettingsLockOnJoinConfigurable)
* @method $this setLockSettingsHideViewersCursor(bool $isLockSettingsHideViewersCursor)
* @method bool|null isLockSettingsHideViewersCursor()
* @method string getGuestPolicy()
* @method $this setGuestPolicy(string $guestPolicy)
* @method bool|null isMeetingKeepEvents()
* @method $this setMeetingKeepEvents(bool $isMeetingKeepEvents)
* @method bool|null isEndWhenNoModerator()
* @method $this setEndWhenNoModerator(bool $isEndWhenNoModerator)
* @method int getEndWhenNoModeratorDelayInMinutes()
* @method $this setEndWhenNoModeratorDelayInMinutes(int $endWhenNoModeratorDelayInMinutes)
* @method int getMeetingExpireIfNoUserJoinedInMinutes()
* @method $this setMeetingExpireIfNoUserJoinedInMinutes(int $meetingExpireIfNoUserJoinedInMinutes)
* @method int getMeetingExpireWhenLastUserLeftInMinutes()
* @method $this setMeetingExpireWhenLastUserLeftInMinutes(int $meetingExpireWhenLastUserLeftInMinutes)
* @method string getMeetingLayout()
* @method $this setMeetingLayout(MeetingLayout $meetingLayout)
* @method string getMeetingEndedURL()
* @method $this setMeetingEndedURL(string $meetingEndedURL)
* @method int getLearningDashboardCleanupDelayInMinutes()
* @method $this setLearningDashboardCleanupDelayInMinutes(int $learningDashboardCleanupDelayInMinutes)
* @method bool|null isAllowModsToEjectCameras()
* @method $this setAllowModsToEjectCameras(bool $isAllowModsToEjectCameras)
* @method bool|null isAllowRequestsWithoutSession()
* @method $this setAllowRequestsWithoutSession(bool $isAllowRequestsWithoutSession)
* @method bool|null isAllowPromoteGuestToModerator()
* @method $this setAllowPromoteGuestToModerator(bool $isAllowPromoteGuestToModerator)
* @method int getUserCameraCap()
* @method $this setUserCameraCap(int $cap)
* @method int getMeetingCameraCap()
* @method $this setMeetingCameraCap(int $cap)
* @method array getDisabledFeatures()
* @method $this setDisabledFeatures(array $disabledFeatures)
* @method array getDisabledFeaturesExclude()
* @method $this setDisabledFeaturesExclude(array $disabledFeaturesExclude)
* @method bool|null isPreUploadedPresentationOverrideDefault()
* @method $this setPreUploadedPresentationOverrideDefault(bool $preUploadedPresentationOverrideDefault)
* @method string getPresentationUploadExternalUrl()
* @method $this setPresentationUploadExternalUrl(string $presentationUploadExternalUrl)
* @method string getPresentationUploadExternalDescription()
* @method $this setPresentationUploadExternalDescription(string $presentationUploadExternalDescription)
* @method string getPreUploadedPresentation()
* @method $this setPreUploadedPresentation(string $preUploadedPresentation)
* @method string getPreUploadedPresentationName()
* @method $this setPreUploadedPresentationName(string $preUploadedPresentationName)
*/
class CreateMeetingParameters extends MetaParameters
{
protected ?string $welcome = null;
protected ?string $dialNumber = null;
protected ?int $voiceBridge = null;
protected ?string $webVoice = null;
protected ?int $maxParticipants = null;
protected ?string $logoutURL = null;
protected ?bool $record = null;
protected ?int $duration = null;
protected ?bool $isBreakout = null;
protected ?string $parentMeetingID = null;
protected ?int $sequence = null;
protected ?bool $freeJoin = null;
protected ?bool $breakoutRoomsPrivateChatEnabled = null;
protected ?bool $breakoutRoomsRecord = null;
protected ?string $moderatorOnlyMessage = null;
protected ?bool $autoStartRecording = null;
protected ?bool $allowStartStopRecording = null;
protected ?bool $webcamsOnlyForModerator = null;
protected ?string $logo = null;
protected ?string $bannerText = null;
protected ?string $bannerColor = null;
protected ?string $copyright = null;
protected ?bool $muteOnStart = null;
protected ?bool $allowModsToUnmuteUsers = null;
protected ?bool $lockSettingsDisableCam = null;
protected ?bool $lockSettingsDisableMic = null;
protected ?bool $lockSettingsDisablePrivateChat = null;
protected ?bool $lockSettingsDisablePublicChat = null;
protected ?bool $lockSettingsDisableNotes = null;
protected ?bool $lockSettingsLockedLayout = null;
protected ?bool $lockSettingsHideUserList = null;
protected ?bool $lockSettingsLockOnJoin = null;
protected ?bool $lockSettingsLockOnJoinConfigurable = null;
protected ?bool $lockSettingsHideViewersCursor = null;
protected GuestPolicy $guestPolicy;
protected ?bool $meetingKeepEvents = null;
protected ?bool $endWhenNoModerator = null;
protected int $endWhenNoModeratorDelayInMinutes;
protected ?MeetingLayout $meetingLayout = null;
protected ?string $meetingEndedURL = null;
protected ?int $learningDashboardCleanupDelayInMinutes = null;
protected ?bool $allowModsToEjectCameras = null;
protected ?bool $allowRequestsWithoutSession = null;
protected ?bool $allowPromoteGuestToModerator = null;
protected ?int $userCameraCap = null;
/**
* @var array<array{id: string, name: string|null, roster: array<mixed>}>
*/
private array $breakoutRoomsGroups = [];
/**
* @var array<Feature>
*/
protected array $disabledFeatures = [];
/**
* @var array<Feature>
*/
protected array $disabledFeaturesExclude = [];
protected ?int $meetingCameraCap = null;
protected ?int $meetingExpireIfNoUserJoinedInMinutes = null;
protected ?int $meetingExpireWhenLastUserLeftInMinutes = null;
protected ?bool $preUploadedPresentationOverrideDefault = null;
protected ?string $preUploadedPresentation = null;
protected ?string $preUploadedPresentationName = null;
protected ?bool $notifyRecordingIsOn = null;
protected ?bool $remindRecordingIsOn = null;
protected ?bool $recordFullDurationMedia = null;
protected ?string $presentationUploadExternalUrl = null;
protected ?string $presentationUploadExternalDescription = null;
/**
* @var array<string,string>
*/
private array $presentations = [];
public function __construct(protected string $meetingID, protected string $name)
{
$this->guestPolicy = GuestPolicy::ALWAYS_ACCEPT;
$this->ignoreProperties = ['disabledFeatures', 'disabledFeaturesExclude'];
}
public function setEndCallbackUrl(string $endCallbackUrl): self
{
$this->addMeta('endCallbackUrl', $endCallbackUrl);
return $this;
}
public function setRecordingReadyCallbackUrl(string $recordingReadyCallbackUrl): self
{
$this->addMeta('bbb-recording-ready-url', $recordingReadyCallbackUrl);
return $this;
}
public function setBreakout(bool $isBreakout): self
{
$this->isBreakout = $isBreakout;
return $this;
}
public function isBreakout(): ?bool
{
return $this->isBreakout;
}
public function isUserCameraCapDisabled(): bool
{
return $this->userCameraCap === 0;
}
public function disableUserCameraCap(): self
{
$this->userCameraCap = 0;
return $this;
}
public function isGuestPolicyAlwaysDeny(): bool
{
return $this->guestPolicy === GuestPolicy::ALWAYS_DENY;
}
public function setGuestPolicyAlwaysDeny(): self
{
$this->guestPolicy = GuestPolicy::ALWAYS_DENY;
return $this;
}
public function isGuestPolicyAskModerator(): bool
{
return $this->guestPolicy === GuestPolicy::ASK_MODERATOR;
}
/**
* Ask moderator on join of non-moderators if user/guest is allowed to enter the meeting.
*/
public function setGuestPolicyAskModerator(): self
{
$this->guestPolicy = GuestPolicy::ASK_MODERATOR;
return $this;
}
public function isGuestPolicyAlwaysAcceptAuth(): bool
{
return $this->guestPolicy === GuestPolicy::ALWAYS_ACCEPT_AUTH;
}
/**
* Ask moderator on join of guests is allowed to enter the meeting, user are allowed to join directly.
*/
public function setGuestPolicyAlwaysAcceptAuth(): self
{
$this->guestPolicy = GuestPolicy::ALWAYS_ACCEPT_AUTH;
return $this;
}
public function isGuestPolicyAlwaysAccept(): bool
{
return $this->guestPolicy === GuestPolicy::ALWAYS_ACCEPT;
}
public function setGuestPolicyAlwaysAccept(): self
{
$this->guestPolicy = GuestPolicy::ALWAYS_ACCEPT;
return $this;
}
public function addPresentation(string $nameOrUrl, ?string $content = null, ?string $filename = null): self
{
if (!$filename) {
$this->presentations[$nameOrUrl] = !$content ?: base64_encode($content);
} else {
$this->presentations[$nameOrUrl] = $filename;
}
return $this;
}
/**
* @return array<array{id: string, name: string|null, roster: array<mixed>}>
*/
public function getBreakoutRoomsGroups(): array
{
return $this->breakoutRoomsGroups;
}
/**
* @param array<mixed> $roster
*
* @return $this
*/
public function addBreakoutRoomsGroup(string $id, ?string $name, array $roster): self
{
$this->breakoutRoomsGroups[] = ['id' => $id, 'name' => $name, 'roster' => $roster];
return $this;
}
/** @return array<string,string> */
public function getPresentations(): array
{
return $this->presentations;
}
public function getPresentationsAsXML(): string
{
$result = '';
if (!empty($this->presentations)) {
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><modules/>');
$module = $xml->addChild('module');
$module->addAttribute('name', 'presentation');
foreach ($this->presentations as $nameOrUrl => $content) {
if (str_starts_with($nameOrUrl, 'http')) {
$presentation = $module->addChild('document');
$presentation->addAttribute('url', $nameOrUrl);
if (\is_string($content)) {
$presentation->addAttribute('filename', $content);
}
} else {
$document = $module->addChild('document');
$document->addAttribute('name', $nameOrUrl);
/* @phpstan-ignore-next-line */
$document[0] = $content;
}
}
$result = $xml->asXML();
}
if (false === $result) {
throw new \LogicException('Could not generate XML.');
}
return $result;
}
public function getHTTPQuery(): string
{
$queries = $this->getHTTPQueryArray();
// Add disabled features if any are set
if (!empty($this->disabledFeatures)) {
$queries = array_merge($queries, [
'disabledFeatures' => implode(',', array_map(fn (Feature $disabledFeature): string => $disabledFeature->value, $this->disabledFeatures)),
]);
}
// Add disabled features exclude if any are set
if (!empty($this->disabledFeaturesExclude)) {
$queries = array_merge($queries, [
'disabledFeaturesExclude' => implode(',', array_map(fn (Feature $disabledFeatureExclude): string => $disabledFeatureExclude->value, $this->disabledFeaturesExclude)),
]);
}
// Pre-defined groups to automatically assign the students to a given breakout room
if (!empty($this->breakoutRoomsGroups)) {
$queries = array_merge($queries, [
'groups' => json_encode($this->breakoutRoomsGroups),
]);
}
if ($this->isBreakout()) {
if ($this->parentMeetingID === null || $this->sequence === null) {
throw new \RuntimeException('Breakout rooms require a parentMeetingID and sequence number.');
}
} else {
$queries = $this->filterBreakoutRelatedQueries($queries);
}
return http_build_query($queries, '', '&', \PHP_QUERY_RFC3986);
}
/**
* @param array<string> $queries
*
* @return array<string>
*/
private function filterBreakoutRelatedQueries(array $queries): array
{
return array_filter($queries, static fn ($query) => !\in_array($query, ['isBreakout', 'parentMeetingID', 'sequence', 'freeJoin']));
}
}