|
|
@@ -3,9 +3,125 @@
|
|
3
|
3
|
* have different implementations depending on the underlying interface used
|
|
4
|
4
|
* (i.e. WebRTC and ORTC) and here we hold the code common to all of them.
|
|
5
|
5
|
*/
|
|
6
|
|
-function JingleSession() {
|
|
7
|
|
- // dripping is sending trickle candidates not one-by-one
|
|
|
6
|
+function JingleSession(me, sid, connection, service, eventEmitter) {
|
|
|
7
|
+ /**
|
|
|
8
|
+ * Our JID.
|
|
|
9
|
+ */
|
|
|
10
|
+ this.me = me;
|
|
|
11
|
+
|
|
|
12
|
+ /**
|
|
|
13
|
+ * The Jingle session identifier.
|
|
|
14
|
+ */
|
|
|
15
|
+ this.sid = sid;
|
|
|
16
|
+
|
|
|
17
|
+ /**
|
|
|
18
|
+ * The XMPP connection.
|
|
|
19
|
+ */
|
|
|
20
|
+ this.connection = connection;
|
|
|
21
|
+
|
|
|
22
|
+ /**
|
|
|
23
|
+ * The XMPP service.
|
|
|
24
|
+ */
|
|
|
25
|
+ this.service = service;
|
|
|
26
|
+
|
|
|
27
|
+ /**
|
|
|
28
|
+ * The event emitter.
|
|
|
29
|
+ */
|
|
|
30
|
+ this.eventEmitter = eventEmitter;
|
|
|
31
|
+
|
|
|
32
|
+ /**
|
|
|
33
|
+ * Whether to use dripping or not. Dripping is sending trickle candidates
|
|
|
34
|
+ * not one-by-one.
|
|
|
35
|
+ * Note: currently we do not support 'false'.
|
|
|
36
|
+ */
|
|
8
|
37
|
this.usedrip = true;
|
|
|
38
|
+
|
|
|
39
|
+ /**
|
|
|
40
|
+ * When dripping is used, stores ICE candidates which are to be sent.
|
|
|
41
|
+ */
|
|
|
42
|
+ this.drip_container = [];
|
|
|
43
|
+
|
|
|
44
|
+ // Media constraints. Is this WebRTC only?
|
|
|
45
|
+ this.media_constraints = null;
|
|
|
46
|
+
|
|
|
47
|
+ // ICE servers config (RTCConfiguration?).
|
|
|
48
|
+ this.ice_config = {};
|
|
9
|
49
|
}
|
|
10
|
50
|
|
|
|
51
|
+/**
|
|
|
52
|
+ * Prepares this object to initiate a session.
|
|
|
53
|
+ * @param peerjid the JID of the remote peer.
|
|
|
54
|
+ * @param isInitiator whether we will be the Jingle initiator.
|
|
|
55
|
+ * @param media_constraints
|
|
|
56
|
+ * @param ice_config
|
|
|
57
|
+ */
|
|
|
58
|
+JingleSession.prototype.initialize = function(peerjid, isInitiator,
|
|
|
59
|
+ media_constraints, ice_config) {
|
|
|
60
|
+ this.media_constraints = media_constraints;
|
|
|
61
|
+ this.ice_config = ice_config;
|
|
|
62
|
+
|
|
|
63
|
+ if (this.state !== null) {
|
|
|
64
|
+ console.error('attempt to initiate on session ' + this.sid +
|
|
|
65
|
+ 'in state ' + this.state);
|
|
|
66
|
+ return;
|
|
|
67
|
+ }
|
|
|
68
|
+ this.state = 'pending';
|
|
|
69
|
+ this.initiator = isInitiator ? this.me : peerjid;
|
|
|
70
|
+ this.responder = !isInitiator ? this.me : peerjid;
|
|
|
71
|
+ this.peerjid = peerjid;
|
|
|
72
|
+
|
|
|
73
|
+ this.doInitialize();
|
|
|
74
|
+};
|
|
|
75
|
+
|
|
|
76
|
+/**
|
|
|
77
|
+ * Finishes initialization.
|
|
|
78
|
+ */
|
|
|
79
|
+JingleSession.prototype.doInitialize = function() {};
|
|
|
80
|
+
|
|
|
81
|
+/**
|
|
|
82
|
+ * Adds the ICE candidates found in the 'contents' array as remote candidates?
|
|
|
83
|
+ * Note: currently only used on transport-info
|
|
|
84
|
+ */
|
|
|
85
|
+JingleSession.prototype.addIceCandidates = function(contents) {};
|
|
|
86
|
+
|
|
|
87
|
+/**
|
|
|
88
|
+ * Handles an 'add-source' event.
|
|
|
89
|
+ *
|
|
|
90
|
+ * @param contents an array of Jingle 'content' elements.
|
|
|
91
|
+ */
|
|
|
92
|
+JingleSession.prototype.addSources = function(contents) {};
|
|
|
93
|
+
|
|
|
94
|
+/**
|
|
|
95
|
+ * Handles a 'remove-source' event.
|
|
|
96
|
+ *
|
|
|
97
|
+ * @param contents an array of Jingle 'content' elements.
|
|
|
98
|
+ */
|
|
|
99
|
+JingleSession.prototype.removeSources = function(contents) {};
|
|
|
100
|
+
|
|
|
101
|
+/**
|
|
|
102
|
+ * Terminates this Jingle session (stops sending media and closes the streams?)
|
|
|
103
|
+ */
|
|
|
104
|
+JingleSession.prototype.terminate = function() {};
|
|
|
105
|
+
|
|
|
106
|
+/**
|
|
|
107
|
+ * Sends a Jingle session-terminate message to the peer and terminates the
|
|
|
108
|
+ * session.
|
|
|
109
|
+ * @param reason
|
|
|
110
|
+ * @param text
|
|
|
111
|
+ */
|
|
|
112
|
+JingleSession.prototype.sendTerminate = function(reason, text) {};
|
|
|
113
|
+
|
|
|
114
|
+/**
|
|
|
115
|
+ * Handles an offer from the remote peer (prepares to accept a session).
|
|
|
116
|
+ * @param jingle the 'jingle' XML element.
|
|
|
117
|
+ */
|
|
|
118
|
+JingleSession.prototype.setOffer = function(jingle) {};
|
|
|
119
|
+
|
|
|
120
|
+/**
|
|
|
121
|
+ * Handles an answer from the remote peer (prepares to accept a session).
|
|
|
122
|
+ * @param jingle the 'jingle' XML element.
|
|
|
123
|
+ */
|
|
|
124
|
+JingleSession.prototype.setAnswer = function(jingle) {};
|
|
|
125
|
+
|
|
|
126
|
+
|
|
11
|
127
|
module.exports = JingleSession;
|