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

fix(camera_issue_detection): Adds timeout for reporting camera issues

dev1
hristoterezov 9 лет назад
Родитель
Сommit
2457cca193
1 измененных файлов: 38 добавлений и 12 удалений
  1. 38
    12
      modules/RTC/JitsiLocalTrack.js

+ 38
- 12
modules/RTC/JitsiLocalTrack.js Просмотреть файл

@@ -79,6 +79,13 @@ function JitsiLocalTrack(stream, track, mediaType, videoType, resolution,
79 79
      */
80 80
     this.stopStreamInProgress = false;
81 81
 
82
+    /**
83
+     * On mute event we are waiting for 3s to check if the stream is going to
84
+     * be still muted before firing the event for camera issue detected
85
+     * (NO_DATA_FROM_SOURCE).
86
+     */
87
+    this._noDataFromSourceTimout = null;
88
+
82 89
     this._onDeviceListChanged = function (devices) {
83 90
         self._setRealDeviceIdFromDeviceList(devices);
84 91
 
@@ -108,18 +115,7 @@ function JitsiLocalTrack(stream, track, mediaType, videoType, resolution,
108 115
     RTCUtils.addListener(RTCEvents.DEVICE_LIST_CHANGED,
109 116
         this._onDeviceListChanged);
110 117
 
111
-    // FIXME: Removed temporary until we verify that we don't fire the 
112
-    // the event when the camera is working.
113
-    // if(this.isVideoTrack() && this.videoType === VideoType.CAMERA) {
114
-    //     this._setHandler("track_mute", () => {
115
-    //         if(this._checkForCameraIssues())
116
-    //             this.eventEmitter.emit(JitsiTrackEvents.NO_DATA_FROM_SOURCE);
117
-    //     });
118
-    //     this._setHandler("track_ended", () => {
119
-    //         if(this._checkForCameraIssues())
120
-    //             this.eventEmitter.emit(JitsiTrackEvents.NO_DATA_FROM_SOURCE);
121
-    //     });
122
-    // }
118
+    this._initNoDataFromSourceHandlers();
123 119
 }
124 120
 
125 121
 JitsiLocalTrack.prototype = Object.create(JitsiTrack.prototype);
@@ -133,6 +129,36 @@ JitsiLocalTrack.prototype.isEnded = function () {
133 129
     return  this.getTrack().readyState === 'ended' || this._trackEnded;
134 130
 };
135 131
 
132
+/**
133
+ * Sets handlers to the MediaStreamTrack object that will detect camera issues.
134
+ */
135
+JitsiLocalTrack.prototype._initNoDataFromSourceHandlers = function () {
136
+    if(this.isVideoTrack() && this.videoType === VideoType.CAMERA) {
137
+        this._setHandler("track_mute", () => {
138
+            if(this._checkForCameraIssues()) {
139
+                this._noDataFromSourceTimout = setTimeout(() => {
140
+                    this._noDataFromSourceTimout = null;
141
+                    //unset the handler
142
+                    this._setHandler("track_unmute", undefined);
143
+                    if(this._checkForCameraIssues())
144
+                        this.eventEmitter.emit(
145
+                            JitsiTrackEvents.NO_DATA_FROM_SOURCE);
146
+                }, 3000);
147
+                this._setHandler("track_unmute", () => {
148
+                    if(this._noDataFromSourceTimout) {
149
+                        clearTimeout(this._noDataFromSourceTimout);
150
+                        this._noDataFromSourceTimout = null;
151
+                    }
152
+                });
153
+            }
154
+        });
155
+        this._setHandler("track_ended", () => {
156
+            if(this._checkForCameraIssues())
157
+                this.eventEmitter.emit(JitsiTrackEvents.NO_DATA_FROM_SOURCE);
158
+        });
159
+    }
160
+};
161
+
136 162
 /**
137 163
  * Sets real device ID by comparing track information with device information.
138 164
  * This is temporary solution until getConstraints() method will be implemented

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