Przeglądaj źródła

first attempt to fix issue #41

j8
Philipp Hancke 12 lat temu
rodzic
commit
d432c130f9
1 zmienionych plików z 67 dodań i 1 usunięć
  1. 67
    1
      app.js

+ 67
- 1
app.js Wyświetl plik

@@ -265,6 +265,72 @@ function sendKeyframe(pc) {
265 265
     );
266 266
 }
267 267
 
268
+function demonstrateabug(pc) {
269
+    // funny way of doing mute. the subsequent offer contains things like rtcp-mux
270
+    // and triggers all new ice candidates (ice restart)
271
+    // this code is here to demonstrate a bug
272
+    pc.createOffer(
273
+        function (offer) {
274
+            console.log(offer);
275
+            var sdp = new SDP(offer.sdp);
276
+            if (sdp.media.length > 1) {
277
+                sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly');
278
+                sdp.raw = sdp.session + sdp.media.join('');
279
+                offer.sdp = sdp.raw;
280
+                pc.setLocalDescription(offer,
281
+                    function () {
282
+                        console.log('mute SLD ok');
283
+                    },
284
+                    function(error) {
285
+                        console.log('mute SLD error');
286
+                    }
287
+                );
288
+            }
289
+        },
290
+        function (error) {
291
+            console.warn(error);
292
+        },
293
+        {mandatory: {OfferToReceiveAudio: true, OfferToReceiveVideo: false}}
294
+    );
295
+}
296
+
297
+// really mute video, i.e. dont even send black frames
298
+function muteVideo(pc, unmute) {
299
+    // FIXME: this probably needs another of those lovely state safeguards...
300
+    // which checks for iceconn == connected and sigstate == stable
301
+    pc.setRemoteDescription(pc.remoteDescription,
302
+        function () {
303
+            pc.createAnswer(
304
+                function (answer) {
305
+                    var sdp = new SDP(answer.sdp);
306
+                    if (sdp.media.length > 1) {
307
+                        if (unmute)
308
+                            sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv');
309
+                        else
310
+                            sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly');
311
+                        sdp.raw = sdp.session + sdp.media.join('');
312
+                        answer.sdp = sdp.raw;
313
+                    }
314
+                    pc.setLocalDescription(answer,
315
+                        function () {
316
+                            console.log('mute SLD ok');
317
+                        },
318
+                        function(error) {
319
+                            console.log('mute SLD error');
320
+                        }
321
+                    );
322
+                },
323
+                function (error) {
324
+                    console.log(error);
325
+                }
326
+            );
327
+        },
328
+        function (error) {
329
+            console.log('muteVideo SRD error');
330
+        }
331
+    );
332
+}
333
+
268 334
 $(document).bind('callincoming.jingle', function (event, sid) {
269 335
     var sess = connection.jingle.sessions[sid];
270 336
     // TODO: check affiliation and/or role
@@ -1215,4 +1281,4 @@ function createEditDisplayNameButton() {
1215 1281
     editButton.innerHTML = '<i class="fa fa-pencil"></i>';
1216 1282
 
1217 1283
     return editButton;
1218
-}
1284
+}

Ładowanie…
Anuluj
Zapisz