|
|
@@ -1,16 +1,19 @@
|
|
1
|
1
|
import Logger from '@jitsi/logger';
|
|
|
2
|
+import { merge } from 'lodash-es';
|
|
2
|
3
|
|
|
|
4
|
+import JitsiConference from './JitsiConference';
|
|
3
|
5
|
import * as JitsiConferenceErrors from './JitsiConferenceErrors';
|
|
4
|
6
|
import * as JitsiConferenceEvents from './JitsiConferenceEvents';
|
|
5
|
7
|
import JitsiConnection from './JitsiConnection';
|
|
6
|
8
|
import * as JitsiConnectionErrors from './JitsiConnectionErrors';
|
|
7
|
|
-import * as JitsiConnectionEvents from './JitsiConnectionEvents';
|
|
|
9
|
+import { JitsiConnectionEvents } from './JitsiConnectionEvents';
|
|
8
|
10
|
import JitsiMediaDevices from './JitsiMediaDevices';
|
|
9
|
11
|
import * as JitsiMediaDevicesEvents from './JitsiMediaDevicesEvents';
|
|
10
|
12
|
import JitsiTrackError from './JitsiTrackError';
|
|
11
|
13
|
import * as JitsiTrackErrors from './JitsiTrackErrors';
|
|
12
|
14
|
import * as JitsiTrackEvents from './JitsiTrackEvents';
|
|
13
|
15
|
import * as JitsiTranscriptionStatus from './JitsiTranscriptionStatus';
|
|
|
16
|
+import JitsiLocalTrack from './modules/RTC/JitsiLocalTrack';
|
|
14
|
17
|
import RTC from './modules/RTC/RTC';
|
|
15
|
18
|
import RTCStats from './modules/RTCStats/RTCStats';
|
|
16
|
19
|
import * as RTCStatsEvents from './modules/RTCStats/RTCStatsEvents';
|
|
|
@@ -27,6 +30,7 @@ import Settings from './modules/settings/Settings';
|
|
27
|
30
|
import LocalStatsCollector from './modules/statistics/LocalStatsCollector';
|
|
28
|
31
|
import runPreCallTest, { IIceServer, IPreCallResult } from './modules/statistics/PreCallTest';
|
|
29
|
32
|
import Statistics from './modules/statistics/statistics';
|
|
|
33
|
+import Deferred from './modules/util/Deferred';
|
|
30
|
34
|
import ScriptUtil from './modules/util/ScriptUtil';
|
|
31
|
35
|
import * as VideoSIPGWConstants from './modules/videosipgw/VideoSIPGWConstants';
|
|
32
|
36
|
import AudioMixer from './modules/webaudio/AudioMixer';
|
|
|
@@ -106,6 +110,16 @@ interface ICreateLocalTrackFromMediaStreamOptions {
|
|
106
|
110
|
videoType?: VideoType;
|
|
107
|
111
|
}
|
|
108
|
112
|
|
|
|
113
|
+export interface IJoinConferenceOptions {
|
|
|
114
|
+ conferenceOptions?: any;
|
|
|
115
|
+ connectionOptions?: any;
|
|
|
116
|
+ jaas?: {
|
|
|
117
|
+ release?: boolean;
|
|
|
118
|
+ useStaging?: boolean;
|
|
|
119
|
+ };
|
|
|
120
|
+ tracks?: JitsiLocalTrack[];
|
|
|
121
|
+}
|
|
|
122
|
+
|
|
109
|
123
|
/**
|
|
110
|
124
|
* The public API of the Jitsi Meet library (a.k.a. {@code JitsiMeetJS}).
|
|
111
|
125
|
*/
|
|
|
@@ -495,6 +509,95 @@ export default {
|
|
495
|
509
|
return Statistics.audioLevelsEnabled && LocalStatsCollector.isLocalStatsSupported();
|
|
496
|
510
|
},
|
|
497
|
511
|
|
|
|
512
|
+ /**
|
|
|
513
|
+ * Simple way to create a {JitsiConference}. All options are optional and sane defaults
|
|
|
514
|
+ * will be chosen for JaaS users.
|
|
|
515
|
+ *
|
|
|
516
|
+ * @param roomName - The name of the conference.
|
|
|
517
|
+ * @param appId - The application id (also known as tenant).
|
|
|
518
|
+ * @param token - The token (JWT) to use for authentication.
|
|
|
519
|
+ * @param options - The options to use for joining the conference.
|
|
|
520
|
+ */
|
|
|
521
|
+ async joinConference(
|
|
|
522
|
+ roomName: string,
|
|
|
523
|
+ appId: string = '',
|
|
|
524
|
+ token: string | null = null,
|
|
|
525
|
+ options: IJoinConferenceOptions = {}): Promise<JitsiConference> {
|
|
|
526
|
+ const d = new Deferred();
|
|
|
527
|
+ let connectionOptions = options.connectionOptions ?? {};
|
|
|
528
|
+
|
|
|
529
|
+ // Provide a solid default config in case of JaaS.
|
|
|
530
|
+ if (appId.startsWith('vpaas-magic-cookie')) {
|
|
|
531
|
+ // Initialize RTCStats logging.
|
|
|
532
|
+ Logger.addGlobalTransport(RTCStats.getDefaultLogCollector());
|
|
|
533
|
+
|
|
|
534
|
+ const useStage = options.jaas?.useStaging ?? false;
|
|
|
535
|
+ const jaasDomain = useStage ? 'staging.8x8.vc' : '8x8.vc';
|
|
|
536
|
+ const opts = {
|
|
|
537
|
+ hosts: {
|
|
|
538
|
+ domain: jaasDomain,
|
|
|
539
|
+ muc: `conference.${appId}.${jaasDomain}`
|
|
|
540
|
+ },
|
|
|
541
|
+ conferenceRequestUrl: `https://${jaasDomain}/${appId}/conference-request/v1?room=${roomName}`,
|
|
|
542
|
+ serviceUrl: `wss://${jaasDomain}/${appId}/xmpp-websocket?room=${roomName}`,
|
|
|
543
|
+ websocketKeepAliveUrl: `https://${jaasDomain}/${appId}/_unlock?room=${roomName}`,
|
|
|
544
|
+ analytics: {
|
|
|
545
|
+ rtcstatsEnabled: true,
|
|
|
546
|
+ rtcstatsEndpoint: `wss://rtcstats-server-${useStage ? 'pilot' : '8x8'}.jitsi.net/`,
|
|
|
547
|
+ rtcstatsSendSdp: true,
|
|
|
548
|
+ },
|
|
|
549
|
+ };
|
|
|
550
|
+
|
|
|
551
|
+ connectionOptions = merge(connectionOptions, opts);
|
|
|
552
|
+ }
|
|
|
553
|
+
|
|
|
554
|
+ const conn = new JitsiConnection(appId, token, connectionOptions);
|
|
|
555
|
+
|
|
|
556
|
+ function cleanupListeners() {
|
|
|
557
|
+ conn.removeEventListener(
|
|
|
558
|
+ JitsiConnectionEvents.CONNECTION_ESTABLISHED, onConnectionEstablished);
|
|
|
559
|
+ conn.removeEventListener(
|
|
|
560
|
+ JitsiConnectionEvents.CONNECTION_FAILED, onConnectionFailed);
|
|
|
561
|
+ }
|
|
|
562
|
+
|
|
|
563
|
+ function onConnectionEstablished() {
|
|
|
564
|
+ cleanupListeners();
|
|
|
565
|
+
|
|
|
566
|
+ const conf = conn.initJitsiConference(roomName, options.conferenceOptions ?? {});
|
|
|
567
|
+
|
|
|
568
|
+ d.resolve(conf);
|
|
|
569
|
+
|
|
|
570
|
+ // Make sure this runs after the promise was resolved so that local track events can be
|
|
|
571
|
+ // listened to.
|
|
|
572
|
+ queueMicrotask(() => {
|
|
|
573
|
+ for (const track of options.tracks || []) {
|
|
|
574
|
+ conf.addTrack(track);
|
|
|
575
|
+ }
|
|
|
576
|
+
|
|
|
577
|
+ conf.join();
|
|
|
578
|
+
|
|
|
579
|
+ // Default to receiving 720p for everyone.
|
|
|
580
|
+ conf.setReceiverConstraints({
|
|
|
581
|
+ lastN: -1,
|
|
|
582
|
+ defaultConstraints: { maxHeight: 720 },
|
|
|
583
|
+ });
|
|
|
584
|
+ });
|
|
|
585
|
+ }
|
|
|
586
|
+
|
|
|
587
|
+ function onConnectionFailed(error: string) {
|
|
|
588
|
+ cleanupListeners();
|
|
|
589
|
+ d.reject(error);
|
|
|
590
|
+ }
|
|
|
591
|
+
|
|
|
592
|
+ conn.addEventListener(
|
|
|
593
|
+ JitsiConnectionEvents.CONNECTION_ESTABLISHED, onConnectionEstablished);
|
|
|
594
|
+ conn.addEventListener(
|
|
|
595
|
+ JitsiConnectionEvents.CONNECTION_FAILED, onConnectionFailed);
|
|
|
596
|
+ conn.connect({ name: roomName });
|
|
|
597
|
+
|
|
|
598
|
+ return d as unknown as Promise<JitsiConference>;
|
|
|
599
|
+ },
|
|
|
600
|
+
|
|
498
|
601
|
/**
|
|
499
|
602
|
* Informs lib-jitsi-meet about the current network status.
|
|
500
|
603
|
*
|