瀏覽代碼

Fixes start video muted and remote audio.

master
damencho 9 年之前
父節點
當前提交
e49bd553f8
共有 7 個文件被更改,包括 51 次插入23 次删除
  1. 5
    0
      JitsiConference.js
  2. 23
    9
      lib-jitsi-meet.js
  3. 5
    5
      lib-jitsi-meet.min.js
  4. 5
    2
      modules/RTC/JitsiRemoteTrack.js
  5. 7
    4
      modules/RTC/JitsiTrack.js
  6. 4
    2
      modules/RTC/RTC.js
  7. 2
    1
      service/RTC/RTCEvents.js

+ 5
- 0
JitsiConference.js 查看文件

772
             }
772
             }
773
         }
773
         }
774
     );
774
     );
775
+    conference.rtc.addListener(RTCEvents.FAKE_VIDEO_TRACK_CREATED,
776
+        function (track) {
777
+            conference.onTrackAdded(track);
778
+        }
779
+    );
775
 
780
 
776
     conference.room.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
781
     conference.room.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
777
         function (value) {
782
         function (value) {

+ 23
- 9
lib-jitsi-meet.js 查看文件

774
             }
774
             }
775
         }
775
         }
776
     );
776
     );
777
+    conference.rtc.addListener(RTCEvents.FAKE_VIDEO_TRACK_CREATED,
778
+        function (track) {
779
+            conference.onTrackAdded(track);
780
+        }
781
+    );
777
 
782
 
778
     conference.room.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
783
     conference.room.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
779
         function (value) {
784
         function (value) {
2045
     JitsiTrack.call(this, RTC, data.stream,
2050
     JitsiTrack.call(this, RTC, data.stream,
2046
         function () {
2051
         function () {
2047
             this.eventEmitter.emit(JitsiTrackEvents.TRACK_STOPPED);
2052
             this.eventEmitter.emit(JitsiTrackEvents.TRACK_STOPPED);
2048
-        }.bind(this), data.type);
2053
+        }.bind(this), data.jitsiTrackType);
2049
     this.rtc = RTC;
2054
     this.rtc = RTC;
2050
     this.sid = sid;
2055
     this.sid = sid;
2051
     this.stream = data.stream;
2056
     this.stream = data.stream;
2071
     if(this.muted === value)
2076
     if(this.muted === value)
2072
         return;
2077
         return;
2073
 
2078
 
2074
-    this.stream.muted = value;
2079
+    // we can have a fake video stream
2080
+    if(this.stream)
2081
+        this.stream.muted = value;
2082
+
2075
     this.muted = value;
2083
     this.muted = value;
2076
     this.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED);
2084
     this.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED);
2077
 };
2085
 };
2166
  * @param stream the stream
2174
  * @param stream the stream
2167
  * @param streamInactiveHandler the function that will handle
2175
  * @param streamInactiveHandler the function that will handle
2168
  *        onended/oninactive events of the stream.
2176
  *        onended/oninactive events of the stream.
2169
- * @param type optionally a type can be specified.
2177
+ * @param jitsiTrackType optionally a type can be specified.
2170
  *        This is the case where we are creating a dummy track with no stream
2178
  *        This is the case where we are creating a dummy track with no stream
2171
  *        Currently this happens when a remote side is starting with video muted
2179
  *        Currently this happens when a remote side is starting with video muted
2172
  */
2180
  */
2173
-function JitsiTrack(rtc, stream, streamInactiveHandler, type)
2181
+function JitsiTrack(rtc, stream, streamInactiveHandler, jitsiTrackType)
2174
 {
2182
 {
2175
     /**
2183
     /**
2176
      * Array with the HTML elements that are displaying the streams.
2184
      * Array with the HTML elements that are displaying the streams.
2181
     this.stream = stream;
2189
     this.stream = stream;
2182
     this.eventEmitter = new EventEmitter();
2190
     this.eventEmitter = new EventEmitter();
2183
     this.audioLevel = -1;
2191
     this.audioLevel = -1;
2184
-    this.type = type || (this.stream.getVideoTracks().length > 0)?
2192
+    this.type = jitsiTrackType || (this.stream.getVideoTracks().length > 0)?
2185
         JitsiTrack.VIDEO : JitsiTrack.AUDIO;
2193
         JitsiTrack.VIDEO : JitsiTrack.AUDIO;
2186
     if(this.type == JitsiTrack.AUDIO) {
2194
     if(this.type == JitsiTrack.AUDIO) {
2187
         this._getTracks = function () {
2195
         this._getTracks = function () {
2317
  * @returns {string} id of the track or null if this is fake track.
2325
  * @returns {string} id of the track or null if this is fake track.
2318
  */
2326
  */
2319
 JitsiTrack.prototype.getId = function () {
2327
 JitsiTrack.prototype.getId = function () {
2320
-    return RTC.getStreamID(this.stream);
2328
+    if(this.stream)
2329
+        return RTC.getStreamID(this.stream);
2330
+    else
2331
+        return null;
2321
 };
2332
 };
2322
 
2333
 
2323
 /**
2334
 /**
2416
             // we need to create a dummy track which we will mute, so we can
2427
             // we need to create a dummy track which we will mute, so we can
2417
             // notify interested about the muting
2428
             // notify interested about the muting
2418
             if(!self.remoteStreams[from][JitsiTrack.VIDEO]) {
2429
             if(!self.remoteStreams[from][JitsiTrack.VIDEO]) {
2419
-                self.createRemoteStream(
2430
+                var track = self.createRemoteStream(
2420
                     {peerjid:room.roomjid + "/" + from,
2431
                     {peerjid:room.roomjid + "/" + from,
2421
                      videoType:"camera",
2432
                      videoType:"camera",
2422
-                     type:JitsiTrack.VIDEO},
2433
+                     jitsiTrackType:JitsiTrack.VIDEO},
2423
                     null, null);
2434
                     null, null);
2435
+                self.eventEmitter
2436
+                    .emit(RTCEvents.FAKE_VIDEO_TRACK_CREATED, track);
2424
             }
2437
             }
2425
 
2438
 
2426
             self.remoteStreams[from][JitsiTrack.VIDEO]
2439
             self.remoteStreams[from][JitsiTrack.VIDEO]
31323
     LASTN_CHANGED: "rtc.lastn_changed",
31336
     LASTN_CHANGED: "rtc.lastn_changed",
31324
     DOMINANTSPEAKER_CHANGED: "rtc.dominantspeaker_changed",
31337
     DOMINANTSPEAKER_CHANGED: "rtc.dominantspeaker_changed",
31325
     LASTN_ENDPOINT_CHANGED: "rtc.lastn_endpoint_changed",
31338
     LASTN_ENDPOINT_CHANGED: "rtc.lastn_endpoint_changed",
31326
-    AVAILABLE_DEVICES_CHANGED: "rtc.available_devices_changed"
31339
+    AVAILABLE_DEVICES_CHANGED: "rtc.available_devices_changed",
31340
+    FAKE_VIDEO_TRACK_CREATED: "rtc.fake_video_track_created"
31327
 };
31341
 };
31328
 
31342
 
31329
 module.exports = RTCEvents;
31343
 module.exports = RTCEvents;

+ 5
- 5
lib-jitsi-meet.min.js
文件差異過大導致無法顯示
查看文件


+ 5
- 2
modules/RTC/JitsiRemoteTrack.js 查看文件

14
     JitsiTrack.call(this, RTC, data.stream,
14
     JitsiTrack.call(this, RTC, data.stream,
15
         function () {
15
         function () {
16
             this.eventEmitter.emit(JitsiTrackEvents.TRACK_STOPPED);
16
             this.eventEmitter.emit(JitsiTrackEvents.TRACK_STOPPED);
17
-        }.bind(this), data.type);
17
+        }.bind(this), data.jitsiTrackType);
18
     this.rtc = RTC;
18
     this.rtc = RTC;
19
     this.sid = sid;
19
     this.sid = sid;
20
     this.stream = data.stream;
20
     this.stream = data.stream;
40
     if(this.muted === value)
40
     if(this.muted === value)
41
         return;
41
         return;
42
 
42
 
43
-    this.stream.muted = value;
43
+    // we can have a fake video stream
44
+    if(this.stream)
45
+        this.stream.muted = value;
46
+
44
     this.muted = value;
47
     this.muted = value;
45
     this.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED);
48
     this.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED);
46
 };
49
 };

+ 7
- 4
modules/RTC/JitsiTrack.js 查看文件

60
  * @param stream the stream
60
  * @param stream the stream
61
  * @param streamInactiveHandler the function that will handle
61
  * @param streamInactiveHandler the function that will handle
62
  *        onended/oninactive events of the stream.
62
  *        onended/oninactive events of the stream.
63
- * @param type optionally a type can be specified.
63
+ * @param jitsiTrackType optionally a type can be specified.
64
  *        This is the case where we are creating a dummy track with no stream
64
  *        This is the case where we are creating a dummy track with no stream
65
  *        Currently this happens when a remote side is starting with video muted
65
  *        Currently this happens when a remote side is starting with video muted
66
  */
66
  */
67
-function JitsiTrack(rtc, stream, streamInactiveHandler, type)
67
+function JitsiTrack(rtc, stream, streamInactiveHandler, jitsiTrackType)
68
 {
68
 {
69
     /**
69
     /**
70
      * Array with the HTML elements that are displaying the streams.
70
      * Array with the HTML elements that are displaying the streams.
75
     this.stream = stream;
75
     this.stream = stream;
76
     this.eventEmitter = new EventEmitter();
76
     this.eventEmitter = new EventEmitter();
77
     this.audioLevel = -1;
77
     this.audioLevel = -1;
78
-    this.type = type || (this.stream.getVideoTracks().length > 0)?
78
+    this.type = jitsiTrackType || (this.stream.getVideoTracks().length > 0)?
79
         JitsiTrack.VIDEO : JitsiTrack.AUDIO;
79
         JitsiTrack.VIDEO : JitsiTrack.AUDIO;
80
     if(this.type == JitsiTrack.AUDIO) {
80
     if(this.type == JitsiTrack.AUDIO) {
81
         this._getTracks = function () {
81
         this._getTracks = function () {
211
  * @returns {string} id of the track or null if this is fake track.
211
  * @returns {string} id of the track or null if this is fake track.
212
  */
212
  */
213
 JitsiTrack.prototype.getId = function () {
213
 JitsiTrack.prototype.getId = function () {
214
-    return RTC.getStreamID(this.stream);
214
+    if(this.stream)
215
+        return RTC.getStreamID(this.stream);
216
+    else
217
+        return null;
215
 };
218
 };
216
 
219
 
217
 /**
220
 /**

+ 4
- 2
modules/RTC/RTC.js 查看文件

40
             // we need to create a dummy track which we will mute, so we can
40
             // we need to create a dummy track which we will mute, so we can
41
             // notify interested about the muting
41
             // notify interested about the muting
42
             if(!self.remoteStreams[from][JitsiTrack.VIDEO]) {
42
             if(!self.remoteStreams[from][JitsiTrack.VIDEO]) {
43
-                self.createRemoteStream(
43
+                var track = self.createRemoteStream(
44
                     {peerjid:room.roomjid + "/" + from,
44
                     {peerjid:room.roomjid + "/" + from,
45
                      videoType:"camera",
45
                      videoType:"camera",
46
-                     type:JitsiTrack.VIDEO},
46
+                     jitsiTrackType:JitsiTrack.VIDEO},
47
                     null, null);
47
                     null, null);
48
+                self.eventEmitter
49
+                    .emit(RTCEvents.FAKE_VIDEO_TRACK_CREATED, track);
48
             }
50
             }
49
 
51
 
50
             self.remoteStreams[from][JitsiTrack.VIDEO]
52
             self.remoteStreams[from][JitsiTrack.VIDEO]

+ 2
- 1
service/RTC/RTCEvents.js 查看文件

4
     LASTN_CHANGED: "rtc.lastn_changed",
4
     LASTN_CHANGED: "rtc.lastn_changed",
5
     DOMINANTSPEAKER_CHANGED: "rtc.dominantspeaker_changed",
5
     DOMINANTSPEAKER_CHANGED: "rtc.dominantspeaker_changed",
6
     LASTN_ENDPOINT_CHANGED: "rtc.lastn_endpoint_changed",
6
     LASTN_ENDPOINT_CHANGED: "rtc.lastn_endpoint_changed",
7
-    AVAILABLE_DEVICES_CHANGED: "rtc.available_devices_changed"
7
+    AVAILABLE_DEVICES_CHANGED: "rtc.available_devices_changed",
8
+    FAKE_VIDEO_TRACK_CREATED: "rtc.fake_video_track_created"
8
 };
9
 };
9
 
10
 
10
 module.exports = RTCEvents;
11
 module.exports = RTCEvents;

Loading…
取消
儲存