Procházet zdrojové kódy

Extracts base class for ColibriFocus and JingleSession.

j8
paweldomas před 12 roky
rodič
revize
a5951df0d9

+ 0
- 2
app.js Zobrazit soubor

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

+ 1
- 0
index.html Zobrazit soubor

6
     <script src="libs/strophe/strophe.jingle.bundle.js?v=8"></script>
6
     <script src="libs/strophe/strophe.jingle.bundle.js?v=8"></script>
7
     <script src="libs/strophe/strophe.jingle.js?v=1"></script>
7
     <script src="libs/strophe/strophe.jingle.js?v=1"></script>
8
     <script src="libs/strophe/strophe.jingle.sdp.js?v=1"></script>
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
     <script src="libs/strophe/strophe.jingle.session.js?v=1"></script>
10
     <script src="libs/strophe/strophe.jingle.session.js?v=1"></script>
10
     <script src="libs/colibri/colibri.focus.js?v=8"></script><!-- colibri focus implementation -->
11
     <script src="libs/colibri/colibri.focus.js?v=8"></script><!-- colibri focus implementation -->
11
     <script src="libs/colibri/colibri.session.js?v=1"></script>
12
     <script src="libs/colibri/colibri.session.js?v=1"></script>

+ 5
- 24
libs/colibri/colibri.focus.js Zobrazit soubor

34
  THE SOFTWARE.
34
  THE SOFTWARE.
35
  */
35
  */
36
 /* jshint -W117 */
36
 /* jshint -W117 */
37
+
38
+ColibriFocus.prototype = Object.create(SessionBase.prototype);
37
 function ColibriFocus(connection, bridgejid) {
39
 function ColibriFocus(connection, bridgejid) {
38
-    this.connection = connection;
40
+
41
+    SessionBase.call(this, connection);
42
+
39
     this.bridgejid = bridgejid;
43
     this.bridgejid = bridgejid;
40
     this.peers = [];
44
     this.peers = [];
41
     this.confid = null;
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
     // media types of the conference
47
     // media types of the conference
49
     this.media = ['audio', 'video'];
48
     this.media = ['audio', 'video'];
50
 
49
 
623
 ColibriFocus.prototype.setRemoteDescription = function (session, elem, desctype) {
622
 ColibriFocus.prototype.setRemoteDescription = function (session, elem, desctype) {
624
     var participant = this.peers.indexOf(session.peerjid);
623
     var participant = this.peers.indexOf(session.peerjid);
625
     console.log('Colibri.setRemoteDescription from', session.peerjid, participant);
624
     console.log('Colibri.setRemoteDescription from', session.peerjid, participant);
626
-    var self = this;
627
     var remoteSDP = new SDP('');
625
     var remoteSDP = new SDP('');
628
-    var tmp;
629
     var channel;
626
     var channel;
630
     remoteSDP.fromJingle(elem);
627
     remoteSDP.fromJingle(elem);
631
 
628
 
800
     delete this.remotessrc[session.peerjid];
797
     delete this.remotessrc[session.peerjid];
801
     this.modifySources();
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 Zobrazit soubor

1
 /* jshint -W117 */
1
 /* jshint -W117 */
2
 // Jingle stuff
2
 // Jingle stuff
3
+JingleSession.prototype = Object.create(SessionBase.prototype);
3
 function JingleSession(me, sid, connection) {
4
 function JingleSession(me, sid, connection) {
5
+
6
+    SessionBase.call(this, connection);
7
+
4
     this.me = me;
8
     this.me = me;
5
     this.sid = sid;
9
     this.sid = sid;
6
-    this.connection = connection;
7
     this.initiator = null;
10
     this.initiator = null;
8
     this.responder = null;
11
     this.responder = null;
9
     this.isInitiator = null;
12
     this.isInitiator = null;
10
     this.peerjid = null;
13
     this.peerjid = null;
11
     this.state = null;
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
     this.localSDP = null;
15
     this.localSDP = null;
26
     this.remoteSDP = null;
16
     this.remoteSDP = null;
27
     this.localStreams = [];
17
     this.localStreams = [];
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
 JingleSession.prototype.sendMute = function (muted, content) {
626
 JingleSession.prototype.sendMute = function (muted, content) {
670
     var info = $iq({to: this.peerjid,
627
     var info = $iq({to: this.peerjid,
671
         type: 'set'})
628
         type: 'set'})

+ 46
- 0
libs/strophe/strophe.jingle.sessionbase.js Zobrazit soubor

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
+};

Načítá se…
Zrušit
Uložit