Browse Source

Fixes minor Firefox issues. Adds methods for the desktop sharing.

dev1
hristoterezov 9 years ago
parent
commit
37e73e7ec5
10 changed files with 1512 additions and 1379 deletions
  1. 7
    0
      JitsiMeetJS.js
  2. 12
    3
      doc/API.md
  3. 24
    0
      doc/example/example.js
  4. 1
    0
      doc/example/index.html
  5. 1439
    1370
      lib-jitsi-meet.js
  6. 10
    1
      modules/RTC/JitsiTrack.js
  7. 8
    0
      modules/RTC/RTC.js
  8. 8
    1
      modules/RTC/RTCUtils.js
  9. 1
    1
      modules/xmpp/ChatRoom.js
  10. 2
    3
      modules/xmpp/SDP.js

+ 7
- 0
JitsiMeetJS.js View File

29
     init: function (options) {
29
     init: function (options) {
30
         return RTC.init(options || {});
30
         return RTC.init(options || {});
31
     },
31
     },
32
+    /**
33
+     * Returns whether the desktop sharing is enabled or not.
34
+     * @returns {boolean}
35
+     */
36
+    isDesktopSharingEnabled: function () {
37
+        return RTC.isDesktopSharingEnabled();
38
+    },
32
     setLogLevel: function (level) {
39
     setLogLevel: function (level) {
33
         Logger.setLogLevel(level);
40
         Logger.setLogLevel(level);
34
     },
41
     },

+ 12
- 3
doc/API.md View File

37
 *  ```JitsiMeetJS.init(options)``` - this method initialized Jitsi Meet API.
37
 *  ```JitsiMeetJS.init(options)``` - this method initialized Jitsi Meet API.
38
 The ```options``` parameter is JS object with the following properties:
38
 The ```options``` parameter is JS object with the following properties:
39
     1. useIPv6 - boolean property
39
     1. useIPv6 - boolean property
40
-
40
+    2. desktopSharingChromeMethod - Desktop sharing method. Can be set to 'ext', 'webrtc' or false to disable.
41
+    3. desktopSharingChromeExtId - The ID of the jidesha extension for Chrome or Firefox. Example: 'mbocklcggfhnbahlnepmldehdhpjfcjp'
42
+    desktopSharingChromeSources - Array of strings with the media sources to use when using screen sharing with the Chrome extension. Example: ['screen', 'window']
43
+    4. desktopSharingChromeMinExtVersion - Required version of Chrome extension. Example: '0.1'
44
+    5. desktopSharingFirefoxExtId - The ID of the jidesha extension for Firefox. If null, we assume that no extension is required.
45
+    6. desktopSharingFirefoxDisabled - Boolean. Whether desktop sharing should be disabled on Firefox. Example: false.
46
+    7. desktopSharingFirefoxMaxVersionExtRequired - The maximum version of Firefox which requires a jidesha extension. Example: if set to 41, we will require the extension for Firefox versions up to and including 41. On Firefox 42 and higher, we will run without the extension. If set to -1, an extension will be required for all versions of Firefox.
47
+    8. desktopSharingFirefoxExtensionURL - The URL to the Firefox extension for desktop sharing. "null" if no extension is required.
41
 
48
 
42
 * ```JitsiMeetJS.JitsiConnection``` - the ```JitsiConnection``` constructor. You can use that to create new server connection.
49
 * ```JitsiMeetJS.JitsiConnection``` - the ```JitsiConnection``` constructor. You can use that to create new server connection.
43
 
50
 
48
 
55
 
49
 * ```JitsiMeetJS.createLocalTracks(options)``` - Creates the media tracks and returns them trough ```Promise``` object.
56
 * ```JitsiMeetJS.createLocalTracks(options)``` - Creates the media tracks and returns them trough ```Promise``` object.
50
     - options - JS object with configuration options for the local media tracks. You can change the following properties there:
57
     - options - JS object with configuration options for the local media tracks. You can change the following properties there:
51
-        1. devices - array with the devices - "video" and "audio" that will be passed to GUM. If that property is not set GUM will try to get all available devices.
58
+        1. devices - array with the devices - "desktop", "video" and "audio" that will be passed to GUM. If that property is not set GUM will try to get all available devices.
52
         2. resolution - the prefered resolution for the local video.
59
         2. resolution - the prefered resolution for the local video.
53
         3. cameraDeviceId - the deviceID for the video device that is going to be used
60
         3. cameraDeviceId - the deviceID for the video device that is going to be used
54
         4. micDeviceId - the deviceID for the audio device that is going to be used
61
         4. micDeviceId - the deviceID for the audio device that is going to be used
60
 
67
 
61
 * ```JitsiMeetJS.isDeviceListAvailable()```- returns true if retrieving the device list is support and false - otherwise.
68
 * ```JitsiMeetJS.isDeviceListAvailable()```- returns true if retrieving the device list is support and false - otherwise.
62
 
69
 
70
+* ```JitsiMeetJS.isDesktopSharingEnabled()``` - returns true if desktop sharing is supported and false otherwise. NOTE: that method can be used after ```JitsiMeetJS.init(options)``` is completed otherwise the result will be always null.
71
+
63
 * ```JitsiMeetJS.events``` - JS object that contains all events used by the API. You will need that JS object when you try to subscribe for connection or conference events.
72
 * ```JitsiMeetJS.events``` - JS object that contains all events used by the API. You will need that JS object when you try to subscribe for connection or conference events.
64
     We have two event types - connection and conference. You can access the events with the following code ```JitsiMeetJS.events.<event_type>.<event_name>```.
73
     We have two event types - connection and conference. You can access the events with the following code ```JitsiMeetJS.events.<event_type>.<event_name>```.
65
     For example if you want to use the conference event that is fired when somebody leave conference you can use the following code - ```JitsiMeetJS.events.conference.USER_LEFT```.
74
     For example if you want to use the conference event that is fired when somebody leave conference you can use the following code - ```JitsiMeetJS.events.conference.USER_LEFT```.
316
 
325
 
317
 5. You also may want to get your local tracks from the camera and microphone:
326
 5. You also may want to get your local tracks from the camera and microphone:
318
 ```javascript
327
 ```javascript
319
-room.createLocalTracks().then(onLocalTracks);
328
+JitsiMeetJS.createLocalTracks().then(onLocalTracks);
320
 ```
329
 ```
321
 
330
 
322
 NOTE: Adding listeners and creating local streams are not mandatory steps.
331
 NOTE: Adding listeners and creating local streams are not mandatory steps.

+ 24
- 0
doc/example/example.js View File

157
     room.leave();
157
     room.leave();
158
     connection.disconnect();
158
     connection.disconnect();
159
 }
159
 }
160
+var isVideo = true;
161
+function switchVideo() {
162
+    isVideo = !isVideo;
163
+    if(localTracks[1]) {
164
+        localTracks[1].stop();
165
+        localTracks.pop();
166
+    }
167
+    JitsiMeetJS.createLocalTracks({devices: isVideo? ["video"] : ["desktop"]}).
168
+        then(function (tracks) {
169
+            localTracks.push(tracks[0]);
170
+            localTracks[1].addEventListener(JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
171
+                function () {
172
+                    console.log("local track muted");
173
+                });
174
+            localTracks[1].addEventListener(JitsiMeetJS.events.track.TRACK_STOPPED,
175
+                function () {
176
+                    console.log("local track stoped");
177
+                });
178
+            localTracks[1].attach($("#localVideo1"));
179
+            room.addTrack(localTracks[1]);
180
+        }).catch(function (error) {
181
+            console.log(error);
182
+        });
183
+}
160
 
184
 
161
 $(window).bind('beforeunload', unload);
185
 $(window).bind('beforeunload', unload);
162
 $(window).bind('unload', unload);
186
 $(window).bind('unload', unload);

+ 1
- 0
doc/example/index.html View File

12
 </head>
12
 </head>
13
 <body>
13
 <body>
14
     <a href="#" onclick="unload()">Unload</a>
14
     <a href="#" onclick="unload()">Unload</a>
15
+    <a href="#" onclick="switchVideo()">switchVideo</a>
15
     <!-- <video id="localVideo" autoplay="true"></video> -->
16
     <!-- <video id="localVideo" autoplay="true"></video> -->
16
     <!--<audio id="localAudio" autoplay="true" muted="true"></audio>-->
17
     <!--<audio id="localAudio" autoplay="true" muted="true"></audio>-->
17
 </body>
18
 </body>

+ 1439
- 1370
lib-jitsi-meet.js
File diff suppressed because it is too large
View File


+ 10
- 1
modules/RTC/JitsiTrack.js View File

1
 var RTCBrowserType = require("./RTCBrowserType");
1
 var RTCBrowserType = require("./RTCBrowserType");
2
 var JitsiTrackEvents = require("../../JitsiTrackEvents");
2
 var JitsiTrackEvents = require("../../JitsiTrackEvents");
3
 var EventEmitter = require("events");
3
 var EventEmitter = require("events");
4
+var RTC = require("./RTCUtils");
4
 
5
 
5
 /**
6
 /**
6
  * This implements 'onended' callback normally fired by WebRTC after the stream
7
  * This implements 'onended' callback normally fired by WebRTC after the stream
191
  * Returns id of the track.
192
  * Returns id of the track.
192
  * @returns {string} id of the track or null if this is fake track.
193
  * @returns {string} id of the track or null if this is fake track.
193
  */
194
  */
194
-JitsiTrack.prototype.getId = function () {
195
+JitsiTrack.prototype._getId = function () {
195
     var tracks = this.stream.getTracks();
196
     var tracks = this.stream.getTracks();
196
     if(!tracks || tracks.length === 0)
197
     if(!tracks || tracks.length === 0)
197
         return null;
198
         return null;
198
     return tracks[0].id;
199
     return tracks[0].id;
199
 };
200
 };
200
 
201
 
202
+/**
203
+ * Returns id of the track.
204
+ * @returns {string} id of the track or null if this is fake track.
205
+ */
206
+JitsiTrack.prototype.getId = function () {
207
+    return RTC.getStreamID(this.stream);
208
+};
209
+
201
 /**
210
 /**
202
  * Checks whether the MediaStream is avtive/not ended.
211
  * Checks whether the MediaStream is avtive/not ended.
203
  * When there is no check for active we don't have information and so
212
  * When there is no check for active we don't have information and so

+ 8
- 0
modules/RTC/RTC.js View File

195
     RTCUtils.stopMediaStream(mediaStream);
195
     RTCUtils.stopMediaStream(mediaStream);
196
 };
196
 };
197
 
197
 
198
+/**
199
+ * Returns whether the desktop sharing is enabled or not.
200
+ * @returns {boolean}
201
+ */
202
+RTC.isDesktopSharingEnabled = function () {
203
+    return RTCUtils.isDesktopSharingEnabled();
204
+}
205
+
198
 RTC.prototype.getVideoElementName = function () {
206
 RTC.prototype.getVideoElementName = function () {
199
     return RTCBrowserType.isTemasysPluginUsed() ? 'object' : 'video';
207
     return RTCBrowserType.isTemasysPluginUsed() ? 'object' : 'video';
200
 };
208
 };

+ 8
- 1
modules/RTC/RTCUtils.js View File

657
                 var deviceGUM = {
657
                 var deviceGUM = {
658
                     "audio": GUM.bind(self, ["audio"]),
658
                     "audio": GUM.bind(self, ["audio"]),
659
                     "video": GUM.bind(self, ["video"]),
659
                     "video": GUM.bind(self, ["video"]),
660
-                    "desktop": screenObtainer.obtainStream
660
+                    "desktop": screenObtainer.obtainStream.bind(screenObtainer)
661
                 };
661
                 };
662
                 // With FF/IE we can't split the stream into audio and video because FF
662
                 // With FF/IE we can't split the stream into audio and video because FF
663
                 // doesn't support media stream constructors. So, we need to get the
663
                 // doesn't support media stream constructors. So, we need to get the
763
         if (mediaStream.stop) {
763
         if (mediaStream.stop) {
764
             mediaStream.stop();
764
             mediaStream.stop();
765
         }
765
         }
766
+    },
767
+    /**
768
+     * Returns whether the desktop sharing is enabled or not.
769
+     * @returns {boolean}
770
+     */
771
+    isDesktopSharingEnabled: function () {
772
+        return screenObtainer.isSupported();
766
     }
773
     }
767
 
774
 
768
 };
775
 };

+ 1
- 1
modules/xmpp/ChatRoom.js View File

328
 
328
 
329
 ChatRoom.prototype.processNode = function (node, from) {
329
 ChatRoom.prototype.processNode = function (node, from) {
330
     if(this.presHandlers[node.tagName])
330
     if(this.presHandlers[node.tagName])
331
-        this.presHandlers[node.tagName](node, from);
331
+        this.presHandlers[node.tagName](node, Strophe.getResourceFromJid(from));
332
 };
332
 };
333
 
333
 
334
 ChatRoom.prototype.sendMessage = function (body, nickname) {
334
 ChatRoom.prototype.sendMessage = function (body, nickname) {

+ 2
- 3
modules/xmpp/SDP.js View File

246
                     var msid = null;
246
                     var msid = null;
247
                     if(mline.media == "audio")
247
                     if(mline.media == "audio")
248
                     {
248
                     {
249
-                        msid = APP.RTC.localAudio.getId();
249
+                        msid = APP.RTC.localAudio._getId();
250
                     }
250
                     }
251
                     else
251
                     else
252
                     {
252
                     {
253
-                        msid = APP.RTC.localVideo.getId();
253
+                        msid = APP.RTC.localVideo._getId();
254
                     }
254
                     }
255
                     if(msid != null)
255
                     if(msid != null)
256
                     {
256
                     {
645
 
645
 
646
 
646
 
647
 module.exports = SDP;
647
 module.exports = SDP;
648
-

Loading…
Cancel
Save