Просмотр исходного кода

Creates multiple (Jitsi-Meet) MediaStreams if the RTCMediaStream object

contains both audio and video tracks.
j8
Boris Grozev 10 лет назад
Родитель
Сommit
cd1e761699
2 измененных файлов: 26 добавлений и 12 удалений
  1. 6
    3
      modules/RTC/MediaStream.js
  2. 20
    9
      modules/RTC/RTC.js

+ 6
- 3
modules/RTC/MediaStream.js Просмотреть файл

@@ -11,7 +11,7 @@ var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
11 11
  *
12 12
  * @constructor
13 13
  */
14
-function MediaStream(data, ssrc, browser, eventEmitter, muted) {
14
+function MediaStream(data, ssrc, browser, eventEmitter, muted, type) {
15 15
 
16 16
     // XXX(gp) to minimize headaches in the future, we should build our
17 17
     // abstractions around tracks and not streams. ORTC is track based API.
@@ -23,12 +23,15 @@ function MediaStream(data, ssrc, browser, eventEmitter, muted) {
23 23
     // Also, we should be able to associate multiple SSRCs with a MediaTrack as
24 24
     // a track might have an associated RTX and FEC sources.
25 25
 
26
+    if (!type) {
27
+        console.log("Errrm...some code needs an update...");
28
+    }
29
+
26 30
     this.stream = data.stream;
27 31
     this.peerjid = data.peerjid;
28 32
     this.videoType = data.videoType;
29 33
     this.ssrc = ssrc;
30
-    this.type = (this.stream.getVideoTracks().length > 0)?
31
-        MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
34
+    this.type = type;
32 35
     this.muted = muted;
33 36
     this.eventEmitter = eventEmitter;
34 37
 }

+ 20
- 9
modules/RTC/RTC.js Просмотреть файл

@@ -111,16 +111,27 @@ var RTC = {
111 111
             muted = pres.videoMuted;
112 112
         }
113 113
 
114
-        var remoteStream = new MediaStream(data, ssrc,
115
-            RTCBrowserType.getBrowserType(), eventEmitter, muted);
114
+        var self = this;
115
+        [MediaStreamType.AUDIO_TYPE, MediaStreamType.VIDEO_TYPE].forEach(
116
+            function(type) {
117
+            var tracks =
118
+                type == MediaStreamType.AUDIO_TYPE
119
+                ? data.stream.getAudioTracks : data.stream.getVideoTracks();
120
+            if (!tracks || !Array.isArray(tracks) || !tracks.length) {
121
+                console.log("Not creating a(n) "+type+" stream: no tracks");
122
+                return;
123
+            }
116 124
 
117
-        if(!this.remoteStreams[jid]) {
118
-            this.remoteStreams[jid] = {};
119
-        }
120
-        this.remoteStreams[jid][remoteStream.type]= remoteStream;
121
-        eventEmitter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED,
122
-                          remoteStream);
123
-        return remoteStream;
125
+            var remoteStream = new MediaStream(data, ssrc,
126
+                RTCBrowserType.getBrowserType(), eventEmitter, muted, type);
127
+
128
+            if (!self.remoteStreams[jid]) {
129
+                self.remoteStreams[jid] = {};
130
+            }
131
+            self.remoteStreams[jid][type] = remoteStream;
132
+            eventEmitter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED,
133
+                remoteStream);
134
+        });
124 135
     },
125 136
     getPCConstraints: function () {
126 137
         return this.rtcUtils.pc_constraints;

Загрузка…
Отмена
Сохранить