瀏覽代碼

Adds a module for sending DTMF tones.

j8
Boris Grozev 10 年之前
父節點
當前提交
795ec24246
共有 3 個文件被更改,包括 46 次插入0 次删除
  1. 1
    0
      app.js
  2. 44
    0
      modules/DTMF/DTMF.js
  3. 1
    0
      modules/xmpp/xmpp.js

+ 1
- 0
app.js 查看文件

15
         this.keyboardshortcut = require("./modules/keyboardshortcut/keyboardshortcut");
15
         this.keyboardshortcut = require("./modules/keyboardshortcut/keyboardshortcut");
16
         this.translation = require("./modules/translation/translation");
16
         this.translation = require("./modules/translation/translation");
17
         this.settings = require("./modules/settings/Settings");
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 查看文件

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 查看文件

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

Loading…
取消
儲存