Pārlūkot izejas kodu

Adds a module for sending DTMF tones.

j8
Boris Grozev 10 gadus atpakaļ
vecāks
revīzija
795ec24246
3 mainītis faili ar 46 papildinājumiem un 0 dzēšanām
  1. 1
    0
      app.js
  2. 44
    0
      modules/DTMF/DTMF.js
  3. 1
    0
      modules/xmpp/xmpp.js

+ 1
- 0
app.js Parādīt failu

@@ -15,6 +15,7 @@ var APP =
15 15
         this.keyboardshortcut = require("./modules/keyboardshortcut/keyboardshortcut");
16 16
         this.translation = require("./modules/translation/translation");
17 17
         this.settings = require("./modules/settings/Settings");
18
+        this.DTMF = require("./modules/DTMF/DTMF");
18 19
     }
19 20
 };
20 21
 

+ 44
- 0
modules/DTMF/DTMF.js Parādīt failu

@@ -0,0 +1,44 @@
1
+/* global APP */
2
+
3
+/**
4
+ * A module for sending DTMF tones.
5
+ */
6
+var DTMFSender;
7
+var initDtmfSender = function() {
8
+    // TODO: This needs to reset this if the peerconnection changes
9
+    // (e.g. the call is re-made)
10
+    if (DTMFSender)
11
+        return;
12
+
13
+    var localAudio = APP.RTC.localAudio;
14
+    if (localAudio && localAudio.getTracks().length > 0)
15
+    {
16
+        var peerconnection =
17
+            APP.xmpp.getConnection().jingle.activecall.peerconnection.peerconnection;
18
+        if (peerconnection) {
19
+            DTMFSender =
20
+                peerconnection.createDTMFSender(localAudio.getTracks()[0]);
21
+            console.log("Initialized DTMFSender");
22
+        }
23
+        else {
24
+            console.log("Failed to initialize DTMFSender: no PeerConnection.");
25
+        }
26
+    }
27
+    else {
28
+        console.log("Failed to initialize DTMFSender: no audio track.");
29
+    }
30
+};
31
+
32
+var DTMF = {
33
+    sendTones: function (tones) {
34
+        if (!DTMFSender)
35
+            initDtmfSender();
36
+
37
+        if (DTMFSender){
38
+            DTMFSender.insertDTMF(tones);
39
+        }
40
+    }
41
+};
42
+
43
+module.exports = DTMF;
44
+

+ 1
- 0
modules/xmpp/xmpp.js Parādīt failu

@@ -142,6 +142,7 @@ function setupEvents() {
142 142
 }
143 143
 
144 144
 var XMPP = {
145
+    getConnection: function(){ return connection; },
145 146
     sessionTerminated: false,
146 147
 
147 148
     /**

Notiek ielāde…
Atcelt
Saglabāt