Преглед на файлове

Extracts base class for ColibriFocus and JingleSession.

j8
paweldomas преди 12 години
родител
ревизия
a5951df0d9
променени са 5 файла, в които са добавени 56 реда и са изтрити 73 реда
  1. 0
    2
      app.js
  2. 1
    0
      index.html
  3. 5
    24
      libs/colibri/colibri.focus.js
  4. 4
    47
      libs/strophe/strophe.jingle.session.js
  5. 46
    0
      libs/strophe/strophe.jingle.sessionbase.js

+ 0
- 2
app.js Целия файл

@@ -4,7 +4,6 @@ var connection = null;
4 4
 var focus = null;
5 5
 var activecall = null;
6 6
 var RTC = null;
7
-var RTCPeerConnection = null;
8 7
 var nickname = null;
9 8
 var sharedKey = '';
10 9
 var roomUrl = null;
@@ -23,7 +22,6 @@ function init() {
23 22
         window.location.href = 'chromeonly.html';
24 23
         return;
25 24
     }
26
-    RTCPeerconnection = TraceablePeerConnection;
27 25
 
28 26
     connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
29 27
 

+ 1
- 0
index.html Целия файл

@@ -6,6 +6,7 @@
6 6
     <script src="libs/strophe/strophe.jingle.bundle.js?v=8"></script>
7 7
     <script src="libs/strophe/strophe.jingle.js?v=1"></script>
8 8
     <script src="libs/strophe/strophe.jingle.sdp.js?v=1"></script>
9
+    <script src="libs/strophe/strophe.jingle.sessionbase.js?v=1"></script>
9 10
     <script src="libs/strophe/strophe.jingle.session.js?v=1"></script>
10 11
     <script src="libs/colibri/colibri.focus.js?v=8"></script><!-- colibri focus implementation -->
11 12
     <script src="libs/colibri/colibri.session.js?v=1"></script>

+ 5
- 24
libs/colibri/colibri.focus.js Целия файл

@@ -34,17 +34,16 @@
34 34
  THE SOFTWARE.
35 35
  */
36 36
 /* jshint -W117 */
37
+
38
+ColibriFocus.prototype = Object.create(SessionBase.prototype);
37 39
 function ColibriFocus(connection, bridgejid) {
38
-    this.connection = connection;
40
+
41
+    SessionBase.call(this, connection);
42
+
39 43
     this.bridgejid = bridgejid;
40 44
     this.peers = [];
41 45
     this.confid = null;
42 46
 
43
-    this.peerconnection
44
-        = new TraceablePeerConnection(
45
-            this.connection.jingle.ice_config,
46
-            this.connection.jingle.pc_constraints);
47
-
48 47
     // media types of the conference
49 48
     this.media = ['audio', 'video'];
50 49
 
@@ -623,9 +622,7 @@ ColibriFocus.prototype.sendSSRCUpdate = function (sdp, jid, isadd) {
623 622
 ColibriFocus.prototype.setRemoteDescription = function (session, elem, desctype) {
624 623
     var participant = this.peers.indexOf(session.peerjid);
625 624
     console.log('Colibri.setRemoteDescription from', session.peerjid, participant);
626
-    var self = this;
627 625
     var remoteSDP = new SDP('');
628
-    var tmp;
629 626
     var channel;
630 627
     remoteSDP.fromJingle(elem);
631 628
 
@@ -800,19 +797,3 @@ ColibriFocus.prototype.terminate = function (session, reason) {
800 797
     delete this.remotessrc[session.peerjid];
801 798
     this.modifySources();
802 799
 };
803
-
804
-ColibriFocus.prototype.modifySources = function () {
805
-    var self = this;
806
-    this.peerconnection.modifySources(function(){
807
-        $(document).trigger('setLocalDescription.jingle', [self.sid]);
808
-    });
809
-};
810
-
811
-ColibriFocus.prototype.hardMuteVideo = function (muted) {
812
-
813
-    this.peerconnection.hardMuteVideo(muted);
814
-
815
-    this.connection.jingle.localVideo.getVideoTracks().forEach(function (track) {
816
-        track.enabled = !muted;
817
-    });
818
-};

+ 4
- 47
libs/strophe/strophe.jingle.session.js Целия файл

@@ -1,27 +1,17 @@
1 1
 /* jshint -W117 */
2 2
 // Jingle stuff
3
+JingleSession.prototype = Object.create(SessionBase.prototype);
3 4
 function JingleSession(me, sid, connection) {
5
+
6
+    SessionBase.call(this, connection);
7
+
4 8
     this.me = me;
5 9
     this.sid = sid;
6
-    this.connection = connection;
7 10
     this.initiator = null;
8 11
     this.responder = null;
9 12
     this.isInitiator = null;
10 13
     this.peerjid = null;
11 14
     this.state = null;
12
-    /**
13
-     * Peer connection instance.
14
-     * @type {TraceablePeerConnection}
15
-     */
16
-    this.peerconnection = null;
17
-    //console.log('create PeerConnection ' + JSON.stringify(this.ice_config));
18
-    try {
19
-        this.peerconnection = new RTCPeerconnection(this.ice_config, this.pc_constraints);
20
-    } catch (e) {
21
-        console.error('Failed to create PeerConnection, exception: ', e.message);
22
-        console.error(e);
23
-    }
24
-
25 15
     this.localSDP = null;
26 16
     this.remoteSDP = null;
27 17
     this.localStreams = [];
@@ -633,39 +623,6 @@ JingleSession.prototype.sendTerminate = function (reason, text) {
633 623
     }
634 624
 };
635 625
 
636
-
637
-JingleSession.prototype.addSource = function (elem) {
638
-
639
-    this.peerconnection.addSource(elem);
640
-
641
-    this.modifySources();
642
-};
643
-
644
-JingleSession.prototype.removeSource = function (elem) {
645
-
646
-    this.peerconnection.removeSource(elem);
647
-
648
-    this.modifySources();
649
-};
650
-
651
-JingleSession.prototype.modifySources = function() {
652
-    var self = this;
653
-    this.peerconnection.modifySources(function(){
654
-        $(document).trigger('setLocalDescription.jingle', [self.sid]);
655
-    });
656
-};
657
-
658
-// SDP-based mute by going recvonly/sendrecv
659
-// FIXME: should probably black out the screen as well
660
-JingleSession.prototype.hardMuteVideo = function (muted) {
661
-
662
-    this.peerconnection.hardMuteVideo(muted);
663
-
664
-    this.connection.jingle.localVideo.getVideoTracks().forEach(function (track) {
665
-        track.enabled = !muted;
666
-    });
667
-};
668
-
669 626
 JingleSession.prototype.sendMute = function (muted, content) {
670 627
     var info = $iq({to: this.peerjid,
671 628
         type: 'set'})

+ 46
- 0
libs/strophe/strophe.jingle.sessionbase.js Целия файл

@@ -0,0 +1,46 @@
1
+/**
2
+ * Base class for ColibriFocus and JingleSession.
3
+ * @param connection Strophe connection object
4
+ * @constructor
5
+ */
6
+function SessionBase(connection){
7
+
8
+    this.connection = connection;
9
+    this.peerconnection
10
+        = new TraceablePeerConnection(
11
+            connection.jingle.ice_config,
12
+            connection.jingle.pc_constraints);
13
+}
14
+
15
+
16
+SessionBase.prototype.modifySources = function() {
17
+    var self = this;
18
+    this.peerconnection.modifySources(function(){
19
+        $(document).trigger('setLocalDescription.jingle', [self.sid]);
20
+    });
21
+};
22
+
23
+SessionBase.prototype.addSource = function (elem) {
24
+
25
+    this.peerconnection.addSource(elem);
26
+
27
+    this.modifySources();
28
+};
29
+
30
+SessionBase.prototype.removeSource = function (elem) {
31
+
32
+    this.peerconnection.removeSource(elem);
33
+
34
+    this.modifySources();
35
+};
36
+
37
+// SDP-based mute by going recvonly/sendrecv
38
+// FIXME: should probably black out the screen as well
39
+SessionBase.prototype.hardMuteVideo = function (muted) {
40
+
41
+    this.peerconnection.hardMuteVideo(muted);
42
+
43
+    this.connection.jingle.localVideo.getVideoTracks().forEach(function (track) {
44
+        track.enabled = !muted;
45
+    });
46
+};

Loading…
Отказ
Запис