Преглед изворни кода

Adds start silent config, to disable send/receive audio.

dev1
damencho пре 6 година
родитељ
комит
0a5eaf3d36

+ 12
- 8
JitsiConferenceEventManager.js Прегледај датотеку

@@ -644,15 +644,19 @@ JitsiConferenceEventManager.prototype.setupStatisticsListeners = function() {
644 644
         conference.eventEmitter.emit(
645 645
             JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED);
646 646
     });
647
-    conference.statistics.addByteSentStatsListener((tpc, stats) => {
648
-        conference.getLocalTracks(MediaType.AUDIO).forEach(track => {
649
-            const ssrc = tpc.getLocalSSRC(track);
650 647
 
651
-            if (!ssrc || !stats.hasOwnProperty(ssrc)) {
652
-                return;
653
-            }
648
+    // if we are in startSilent mode we will not be sending/receiving so nothing to detect
649
+    if (!conference.options.config.startSilent) {
650
+        conference.statistics.addByteSentStatsListener((tpc, stats) => {
651
+            conference.getLocalTracks(MediaType.AUDIO).forEach(track => {
652
+                const ssrc = tpc.getLocalSSRC(track);
653
+
654
+                if (!ssrc || !stats.hasOwnProperty(ssrc)) {
655
+                    return;
656
+                }
654 657
 
655
-            track._onByteSentStatsReceived(tpc, stats[ssrc]);
658
+                track._onByteSentStatsReceived(tpc, stats[ssrc]);
659
+            });
656 660
         });
657
-    });
661
+    }
658 662
 };

+ 2
- 1
doc/API.md Прегледај датотеку

@@ -225,7 +225,8 @@ This objects represents the server connection. You can create new ```JitsiConnec
225 225
         6. enableTalkWhileMuted - boolean property. Enables/disables talk while muted detection, by default the value is false/disabled.
226 226
         7. ignoreStartMuted - ignores start muted events coming from jicofo.
227 227
         8. enableStatsID - enables sending callStatsUsername as stats-id in presence, jicofo and videobridge will use it as endpointID to report stats
228
-        9. enableDisplayNameInStats - enables sending the users display name, if set, to callstats as alias of the endpointID stats 
228
+        9. enableDisplayNameInStats - enables sending the users display name, if set, to callstats as alias of the endpointID stats
229
+        10. startSilent - enables silent mode, will mark audio as inactive will not send/receive audio
229 230
 
230 231
         **NOTE: if 4 and 5 are set the library is going to send events to callstats. Otherwise the callstats integration will be disabled.**
231 232
 

+ 1
- 0
modules/RTC/RTC.js Прегледај датотеку

@@ -494,6 +494,7 @@ export default class RTC extends Listenable {
494 494
      *      disabled by removing it from the SDP.
495 495
      * @param {boolean} options.preferH264 If set to 'true' H264 will be
496 496
      *      preferred over other video codecs.
497
+     * @param {boolean} options.startSilent If set to 'true' no audio will be sent or received.
497 498
      * @return {TraceablePeerConnection}
498 499
      */
499 500
     createPeerConnection(signaling, iceConfig, isP2P, options) {

+ 12
- 5
modules/RTC/TraceablePeerConnection.js Прегледај датотеку

@@ -52,6 +52,7 @@ const SIM_LAYER_RIDS = [ SIM_LAYER_1_RID, SIM_LAYER_2_RID, SIM_LAYER_3_RID ];
52 52
  * @param {boolean} options.enableLayerSuspension if set to 'true', we will
53 53
  * cap the video send bitrate when we are told we have not been selected by
54 54
  * any endpoints (and therefore the non-thumbnail streams are not in use).
55
+ * @param {boolean} options.startSilent If set to 'true' no audio will be sent or received.
55 56
  *
56 57
  * FIXME: initially the purpose of TraceablePeerConnection was to be able to
57 58
  * debug the peer connection. Since many other responsibilities have been added
@@ -77,7 +78,7 @@ export default function TraceablePeerConnection(
77 78
      * @type {boolean}
78 79
      * @private
79 80
      */
80
-    this.audioTransferActive = true;
81
+    this.audioTransferActive = !(options.startSilent === true);
81 82
 
82 83
     /**
83 84
      * Indicates whether or not this peer connection instance is actively
@@ -1166,8 +1167,9 @@ function replaceDefaultUnifiedPlanMsid(ssrcLines = []) {
1166 1167
 /**
1167 1168
  * Makes sure that both audio and video directions are configured as 'sendrecv'.
1168 1169
  * @param {Object} localDescription the SDP object as defined by WebRTC.
1170
+ * @param {object} options <tt>TracablePeerConnection</tt> config options.
1169 1171
  */
1170
-const enforceSendRecv = function(localDescription) {
1172
+const enforceSendRecv = function(localDescription, options) {
1171 1173
     if (!localDescription) {
1172 1174
         throw new Error('No local description passed in.');
1173 1175
     }
@@ -1177,7 +1179,12 @@ const enforceSendRecv = function(localDescription) {
1177 1179
     let changed = false;
1178 1180
 
1179 1181
     if (audioMedia && audioMedia.direction !== 'sendrecv') {
1180
-        audioMedia.direction = 'sendrecv';
1182
+        if (options.startSilent) {
1183
+            audioMedia.direction = 'inactive';
1184
+        } else {
1185
+            audioMedia.direction = 'sendrecv';
1186
+        }
1187
+
1181 1188
         changed = true;
1182 1189
     }
1183 1190
 
@@ -1298,7 +1305,7 @@ const getters = {
1298 1305
         // Note that the description we set in chrome does have the accurate
1299 1306
         // direction (e.g. 'recvonly'), since that is technically what is
1300 1307
         // happening (check setLocalDescription impl).
1301
-        desc = enforceSendRecv(desc);
1308
+        desc = enforceSendRecv(desc, this.options);
1302 1309
 
1303 1310
         // See the method's doc for more info about this transformation.
1304 1311
         desc = this.localSdpMunger.transformStreamIdentifiers(desc);
@@ -1810,7 +1817,7 @@ TraceablePeerConnection.prototype.setLocalDescription = function(description) {
1810 1817
  * disabled the SDP audio media direction in the local SDP will be adjusted to
1811 1818
  * 'inactive' which means that no data will be sent nor accepted, but
1812 1819
  * the connection should be kept alive.
1813
- * @param {boolean} active <tt>true</tt> to enable video media transmission or
1820
+ * @param {boolean} active <tt>true</tt> to enable audio media transmission or
1814 1821
  * <tt>false</tt> to disable. If the value is not a boolean the call will have
1815 1822
  * no effect.
1816 1823
  * @return {boolean} <tt>true</tt> if the value has changed and sRD/sLD cycle

+ 4
- 0
modules/xmpp/JingleSessionPC.js Прегледај датотеку

@@ -304,6 +304,10 @@ export default class JingleSessionPC extends JingleSession {
304 304
             pcOptions.enableLayerSuspension = options.enableLayerSuspension;
305 305
         }
306 306
 
307
+        if (options.startSilent) {
308
+            pcOptions.startSilent = true;
309
+        }
310
+
307 311
         this.peerconnection
308 312
             = this.rtc.createPeerConnection(
309 313
                     this.signalingLayer,

Loading…
Откажи
Сачувај