Sfoglia il codice sorgente

fix(presence) Fix backwards compat with endpoints that don't send sourceInfo in presence.

dev1
Jaya Allamsetty 2 anni fa
parent
commit
e6263e7cc4
1 ha cambiato i file con 52 aggiunte e 0 eliminazioni
  1. 52
    0
      modules/xmpp/ChatRoom.js

+ 52
- 0
modules/xmpp/ChatRoom.js Vedi File

4
 import { $iq, $msg, $pres, Strophe } from 'strophe.js';
4
 import { $iq, $msg, $pres, Strophe } from 'strophe.js';
5
 
5
 
6
 import * as JitsiTranscriptionStatus from '../../JitsiTranscriptionStatus';
6
 import * as JitsiTranscriptionStatus from '../../JitsiTranscriptionStatus';
7
+import { MediaType } from '../../service/RTC/MediaType';
8
+import { VideoType } from '../../service/RTC/VideoType';
7
 import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
9
 import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
8
 import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
10
 import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
9
 import Listenable from '../util/Listenable';
11
 import Listenable from '../util/Listenable';
1579
         return this.role === 'moderator';
1581
         return this.role === 'moderator';
1580
     }
1582
     }
1581
 
1583
 
1584
+    /**
1585
+     * Obtains the info about given media advertised (in legacy format) in the MUC presence of the participant
1586
+     * identified by the given endpoint JID. This is for mantining interop with endpoints that do not support
1587
+     * source-name signaling (Jigasi and very old mobile clients).
1588
+     *
1589
+     * @param {string} endpointId the endpoint ID mapped to the participant which corresponds to MUC nickname.
1590
+     * @param {MediaType} mediaType the type of the media for which presence info will be obtained.
1591
+     * @return {PeerMediaInfo} presenceInfo an object with media presence info or <tt>null</tt> either if there
1592
+     * is no presence available or if the media type given is invalid.
1593
+     */
1594
+    getMediaPresenceInfo(endpointId, mediaType) {
1595
+        // Will figure out current muted status by looking up owner's presence
1596
+        const pres = this.lastPresences[`${this.roomjid}/${endpointId}`];
1597
+
1598
+        if (!pres) {
1599
+            // No presence available
1600
+            return null;
1601
+        }
1602
+        const data = {
1603
+            muted: true, // muted by default
1604
+            videoType: mediaType === MediaType.VIDEO ? VideoType.CAMERA : undefined // 'camera' by default
1605
+        };
1606
+        let mutedNode = null;
1607
+
1608
+        if (mediaType === MediaType.AUDIO) {
1609
+            mutedNode = filterNodeFromPresenceJSON(pres, 'audiomuted');
1610
+        } else if (mediaType === MediaType.VIDEO) {
1611
+            mutedNode = filterNodeFromPresenceJSON(pres, 'videomuted');
1612
+            const codecTypeNode = filterNodeFromPresenceJSON(pres, 'jitsi_participant_codecType');
1613
+            const videoTypeNode = filterNodeFromPresenceJSON(pres, 'videoType');
1614
+
1615
+            if (videoTypeNode.length > 0) {
1616
+                data.videoType = videoTypeNode[0].value;
1617
+            }
1618
+            if (codecTypeNode.length > 0) {
1619
+                data.codecType = codecTypeNode[0].value;
1620
+            }
1621
+        } else {
1622
+            logger.error(`Unsupported media type: ${mediaType}`);
1623
+
1624
+            return null;
1625
+        }
1626
+
1627
+        if (mutedNode.length > 0) {
1628
+            data.muted = mutedNode[0].value === 'true';
1629
+        }
1630
+
1631
+        return data;
1632
+    }
1633
+
1582
     /**
1634
     /**
1583
      *
1635
      *
1584
      * @param peerJid
1636
      * @param peerJid

Loading…
Annulla
Salva