浏览代码

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,6 +772,11 @@ function setupListeners(conference) {
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 781
     conference.room.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
777 782
         function (value) {

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

@@ -774,6 +774,11 @@ function setupListeners(conference) {
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 783
     conference.room.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
779 784
         function (value) {
@@ -2045,7 +2050,7 @@ function JitsiRemoteTrack(RTC, data, sid, ssrc) {
2045 2050
     JitsiTrack.call(this, RTC, data.stream,
2046 2051
         function () {
2047 2052
             this.eventEmitter.emit(JitsiTrackEvents.TRACK_STOPPED);
2048
-        }.bind(this), data.type);
2053
+        }.bind(this), data.jitsiTrackType);
2049 2054
     this.rtc = RTC;
2050 2055
     this.sid = sid;
2051 2056
     this.stream = data.stream;
@@ -2071,7 +2076,10 @@ JitsiRemoteTrack.prototype.setMute = function (value) {
2071 2076
     if(this.muted === value)
2072 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 2083
     this.muted = value;
2076 2084
     this.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED);
2077 2085
 };
@@ -2166,11 +2174,11 @@ function addMediaStreamInactiveHandler(mediaStream, handler) {
2166 2174
  * @param stream the stream
2167 2175
  * @param streamInactiveHandler the function that will handle
2168 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 2178
  *        This is the case where we are creating a dummy track with no stream
2171 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 2184
      * Array with the HTML elements that are displaying the streams.
@@ -2181,7 +2189,7 @@ function JitsiTrack(rtc, stream, streamInactiveHandler, type)
2181 2189
     this.stream = stream;
2182 2190
     this.eventEmitter = new EventEmitter();
2183 2191
     this.audioLevel = -1;
2184
-    this.type = type || (this.stream.getVideoTracks().length > 0)?
2192
+    this.type = jitsiTrackType || (this.stream.getVideoTracks().length > 0)?
2185 2193
         JitsiTrack.VIDEO : JitsiTrack.AUDIO;
2186 2194
     if(this.type == JitsiTrack.AUDIO) {
2187 2195
         this._getTracks = function () {
@@ -2317,7 +2325,10 @@ JitsiTrack.prototype._getId = function () {
2317 2325
  * @returns {string} id of the track or null if this is fake track.
2318 2326
  */
2319 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,11 +2427,13 @@ function RTC(room, options) {
2416 2427
             // we need to create a dummy track which we will mute, so we can
2417 2428
             // notify interested about the muting
2418 2429
             if(!self.remoteStreams[from][JitsiTrack.VIDEO]) {
2419
-                self.createRemoteStream(
2430
+                var track = self.createRemoteStream(
2420 2431
                     {peerjid:room.roomjid + "/" + from,
2421 2432
                      videoType:"camera",
2422
-                     type:JitsiTrack.VIDEO},
2433
+                     jitsiTrackType:JitsiTrack.VIDEO},
2423 2434
                     null, null);
2435
+                self.eventEmitter
2436
+                    .emit(RTCEvents.FAKE_VIDEO_TRACK_CREATED, track);
2424 2437
             }
2425 2438
 
2426 2439
             self.remoteStreams[from][JitsiTrack.VIDEO]
@@ -31323,7 +31336,8 @@ var RTCEvents = {
31323 31336
     LASTN_CHANGED: "rtc.lastn_changed",
31324 31337
     DOMINANTSPEAKER_CHANGED: "rtc.dominantspeaker_changed",
31325 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 31343
 module.exports = RTCEvents;

+ 5
- 5
lib-jitsi-meet.min.js
文件差异内容过多而无法显示
查看文件


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

@@ -14,7 +14,7 @@ function JitsiRemoteTrack(RTC, data, sid, ssrc) {
14 14
     JitsiTrack.call(this, RTC, data.stream,
15 15
         function () {
16 16
             this.eventEmitter.emit(JitsiTrackEvents.TRACK_STOPPED);
17
-        }.bind(this), data.type);
17
+        }.bind(this), data.jitsiTrackType);
18 18
     this.rtc = RTC;
19 19
     this.sid = sid;
20 20
     this.stream = data.stream;
@@ -40,7 +40,10 @@ JitsiRemoteTrack.prototype.setMute = function (value) {
40 40
     if(this.muted === value)
41 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 47
     this.muted = value;
45 48
     this.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED);
46 49
 };

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

@@ -60,11 +60,11 @@ function addMediaStreamInactiveHandler(mediaStream, handler) {
60 60
  * @param stream the stream
61 61
  * @param streamInactiveHandler the function that will handle
62 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 64
  *        This is the case where we are creating a dummy track with no stream
65 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 70
      * Array with the HTML elements that are displaying the streams.
@@ -75,7 +75,7 @@ function JitsiTrack(rtc, stream, streamInactiveHandler, type)
75 75
     this.stream = stream;
76 76
     this.eventEmitter = new EventEmitter();
77 77
     this.audioLevel = -1;
78
-    this.type = type || (this.stream.getVideoTracks().length > 0)?
78
+    this.type = jitsiTrackType || (this.stream.getVideoTracks().length > 0)?
79 79
         JitsiTrack.VIDEO : JitsiTrack.AUDIO;
80 80
     if(this.type == JitsiTrack.AUDIO) {
81 81
         this._getTracks = function () {
@@ -211,7 +211,10 @@ JitsiTrack.prototype._getId = function () {
211 211
  * @returns {string} id of the track or null if this is fake track.
212 212
  */
213 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,11 +40,13 @@ function RTC(room, options) {
40 40
             // we need to create a dummy track which we will mute, so we can
41 41
             // notify interested about the muting
42 42
             if(!self.remoteStreams[from][JitsiTrack.VIDEO]) {
43
-                self.createRemoteStream(
43
+                var track = self.createRemoteStream(
44 44
                     {peerjid:room.roomjid + "/" + from,
45 45
                      videoType:"camera",
46
-                     type:JitsiTrack.VIDEO},
46
+                     jitsiTrackType:JitsiTrack.VIDEO},
47 47
                     null, null);
48
+                self.eventEmitter
49
+                    .emit(RTCEvents.FAKE_VIDEO_TRACK_CREATED, track);
48 50
             }
49 51
 
50 52
             self.remoteStreams[from][JitsiTrack.VIDEO]

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

@@ -4,7 +4,8 @@ var RTCEvents = {
4 4
     LASTN_CHANGED: "rtc.lastn_changed",
5 5
     DOMINANTSPEAKER_CHANGED: "rtc.dominantspeaker_changed",
6 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 11
 module.exports = RTCEvents;

正在加载...
取消
保存