ソースを参照

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

dev1
hristoterezov 9年前
コミット
37e73e7ec5
10個のファイルの変更1512行の追加1379行の削除
  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 ファイルの表示

@@ -29,6 +29,13 @@ var LibJitsiMeet = {
29 29
     init: function (options) {
30 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 39
     setLogLevel: function (level) {
33 40
         Logger.setLogLevel(level);
34 41
     },

+ 12
- 3
doc/API.md ファイルの表示

@@ -37,7 +37,14 @@ You can access the following methods and objects trough ```JitsiMeetJS``` object
37 37
 *  ```JitsiMeetJS.init(options)``` - this method initialized Jitsi Meet API.
38 38
 The ```options``` parameter is JS object with the following properties:
39 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 49
 * ```JitsiMeetJS.JitsiConnection``` - the ```JitsiConnection``` constructor. You can use that to create new server connection.
43 50
 
@@ -48,7 +55,7 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
48 55
 
49 56
 * ```JitsiMeetJS.createLocalTracks(options)``` - Creates the media tracks and returns them trough ```Promise``` object.
50 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 59
         2. resolution - the prefered resolution for the local video.
53 60
         3. cameraDeviceId - the deviceID for the video device that is going to be used
54 61
         4. micDeviceId - the deviceID for the audio device that is going to be used
@@ -60,6 +67,8 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
60 67
 
61 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 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 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 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,7 +325,7 @@ room.on(JitsiMeetJS.events.conference.CONFERENCE_JOINED, onConferenceJoined);
316 325
 
317 326
 5. You also may want to get your local tracks from the camera and microphone:
318 327
 ```javascript
319
-room.createLocalTracks().then(onLocalTracks);
328
+JitsiMeetJS.createLocalTracks().then(onLocalTracks);
320 329
 ```
321 330
 
322 331
 NOTE: Adding listeners and creating local streams are not mandatory steps.

+ 24
- 0
doc/example/example.js ファイルの表示

@@ -157,6 +157,30 @@ function unload() {
157 157
     room.leave();
158 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 185
 $(window).bind('beforeunload', unload);
162 186
 $(window).bind('unload', unload);

+ 1
- 0
doc/example/index.html ファイルの表示

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

+ 1439
- 1370
lib-jitsi-meet.js
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 10
- 1
modules/RTC/JitsiTrack.js ファイルの表示

@@ -1,6 +1,7 @@
1 1
 var RTCBrowserType = require("./RTCBrowserType");
2 2
 var JitsiTrackEvents = require("../../JitsiTrackEvents");
3 3
 var EventEmitter = require("events");
4
+var RTC = require("./RTCUtils");
4 5
 
5 6
 /**
6 7
  * This implements 'onended' callback normally fired by WebRTC after the stream
@@ -191,13 +192,21 @@ JitsiTrack.prototype.isScreenSharing = function(){
191 192
  * Returns id of the track.
192 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 196
     var tracks = this.stream.getTracks();
196 197
     if(!tracks || tracks.length === 0)
197 198
         return null;
198 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 211
  * Checks whether the MediaStream is avtive/not ended.
203 212
  * When there is no check for active we don't have information and so

+ 8
- 0
modules/RTC/RTC.js ファイルの表示

@@ -195,6 +195,14 @@ RTC.stopMediaStream = function (mediaStream) {
195 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 206
 RTC.prototype.getVideoElementName = function () {
199 207
     return RTCBrowserType.isTemasysPluginUsed() ? 'object' : 'video';
200 208
 };

+ 8
- 1
modules/RTC/RTCUtils.js ファイルの表示

@@ -657,7 +657,7 @@ var RTCUtils = {
657 657
                 var deviceGUM = {
658 658
                     "audio": GUM.bind(self, ["audio"]),
659 659
                     "video": GUM.bind(self, ["video"]),
660
-                    "desktop": screenObtainer.obtainStream
660
+                    "desktop": screenObtainer.obtainStream.bind(screenObtainer)
661 661
                 };
662 662
                 // With FF/IE we can't split the stream into audio and video because FF
663 663
                 // doesn't support media stream constructors. So, we need to get the
@@ -763,6 +763,13 @@ var RTCUtils = {
763 763
         if (mediaStream.stop) {
764 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 ファイルの表示

@@ -328,7 +328,7 @@ ChatRoom.prototype.onPresence = function (pres) {
328 328
 
329 329
 ChatRoom.prototype.processNode = function (node, from) {
330 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 334
 ChatRoom.prototype.sendMessage = function (body, nickname) {

+ 2
- 3
modules/xmpp/SDP.js ファイルの表示

@@ -246,11 +246,11 @@ SDP.prototype.toJingle = function (elem, thecreator) {
246 246
                     var msid = null;
247 247
                     if(mline.media == "audio")
248 248
                     {
249
-                        msid = APP.RTC.localAudio.getId();
249
+                        msid = APP.RTC.localAudio._getId();
250 250
                     }
251 251
                     else
252 252
                     {
253
-                        msid = APP.RTC.localVideo.getId();
253
+                        msid = APP.RTC.localVideo._getId();
254 254
                     }
255 255
                     if(msid != null)
256 256
                     {
@@ -645,4 +645,3 @@ SDP.prototype.jingle2media = function (content) {
645 645
 
646 646
 
647 647
 module.exports = SDP;
648
-

読み込み中…
キャンセル
保存