|
@@ -147,6 +147,10 @@ export default class JitsiLocalTrack extends JitsiTrack {
|
147
|
147
|
*/
|
148
|
148
|
this._noDataFromSourceTimeout = null;
|
149
|
149
|
|
|
150
|
+ this._onTrackMuted = this._onTrackMuted.bind(this);
|
|
151
|
+
|
|
152
|
+ this._trackMutedTS = 0;
|
|
153
|
+
|
150
|
154
|
this._onDeviceListWillChange = devices => {
|
151
|
155
|
const oldRealDeviceId = this._realDeviceId;
|
152
|
156
|
|
|
@@ -207,69 +211,59 @@ export default class JitsiLocalTrack extends JitsiTrack {
|
207
|
211
|
* issues.
|
208
|
212
|
*/
|
209
|
213
|
_initNoDataFromSourceHandlers() {
|
|
214
|
+ if (!this._isNoDataFromSourceEventsEnabled()) {
|
|
215
|
+ return;
|
|
216
|
+ }
|
|
217
|
+
|
|
218
|
+ this._setHandler('track_mute', () => {
|
|
219
|
+ this._trackMutedTS = window.performance.now();
|
|
220
|
+ this._fireNoDataFromSourceEvent();
|
|
221
|
+ });
|
|
222
|
+
|
|
223
|
+ this._setHandler('track_unmute', () => {
|
|
224
|
+ this._fireNoDataFromSourceEvent();
|
|
225
|
+ Statistics.sendAnalyticsAndLog(
|
|
226
|
+ TRACK_UNMUTED,
|
|
227
|
+ {
|
|
228
|
+ 'media_type': this.getType(),
|
|
229
|
+ 'track_type': 'local',
|
|
230
|
+ value: window.performance.now() - this._trackMutedTS
|
|
231
|
+ });
|
|
232
|
+ });
|
|
233
|
+
|
210
|
234
|
if (this.isVideoTrack() && this.videoType === VideoType.CAMERA) {
|
211
|
|
- const _onNoDataFromSourceError
|
212
|
|
- = this._onNoDataFromSourceError.bind(this);
|
213
|
|
-
|
214
|
|
- this._setHandler('track_mute', () => {
|
215
|
|
- if (this._checkForCameraIssues()) {
|
216
|
|
- const now = window.performance.now();
|
217
|
|
-
|
218
|
|
- this._noDataFromSourceTimeout
|
219
|
|
- = setTimeout(_onNoDataFromSourceError, 5000);
|
220
|
|
- this._setHandler('track_unmute', () => {
|
221
|
|
- this._clearNoDataFromSourceMuteResources();
|
222
|
|
- Statistics.sendAnalyticsAndLog(
|
223
|
|
- TRACK_UNMUTED,
|
224
|
|
- {
|
225
|
|
- 'media_type': this.getType(),
|
226
|
|
- 'track_type': 'local',
|
227
|
|
- value: window.performance.now() - now
|
228
|
|
- });
|
229
|
|
- });
|
|
235
|
+ this._setHandler('track_ended', () => {
|
|
236
|
+ if (!this.isReceivingData()) {
|
|
237
|
+ this._fireNoDataFromSourceEvent();
|
230
|
238
|
}
|
231
|
239
|
});
|
232
|
|
- this._setHandler('track_ended', _onNoDataFromSourceError);
|
233
|
|
- }
|
234
|
|
- }
|
235
|
|
-
|
236
|
|
- /**
|
237
|
|
- * Clears all timeouts and handlers set on MediaStreamTrack mute event.
|
238
|
|
- * FIXME: Change the name of the method with better one.
|
239
|
|
- */
|
240
|
|
- _clearNoDataFromSourceMuteResources() {
|
241
|
|
- if (this._noDataFromSourceTimeout) {
|
242
|
|
- clearTimeout(this._noDataFromSourceTimeout);
|
243
|
|
- this._noDataFromSourceTimeout = null;
|
244
|
240
|
}
|
245
|
|
- this._setHandler('track_unmute', undefined);
|
246
|
241
|
}
|
247
|
242
|
|
248
|
243
|
/**
|
249
|
|
- * Called when potential camera issue is detected. Clears the handlers and
|
250
|
|
- * timeouts set on MediaStreamTrack muted event. Verifies that the camera
|
251
|
|
- * issue persists and fires NO_DATA_FROM_SOURCE event.
|
|
244
|
+ * Returns true if no data from source events are enabled for this JitsiLocalTrack and false otherwise.
|
|
245
|
+ *
|
|
246
|
+ * @returns {boolean} - True if no data from source events are enabled for this JitsiLocalTrack and false otherwise.
|
252
|
247
|
*/
|
253
|
|
- _onNoDataFromSourceError() {
|
254
|
|
- this._clearNoDataFromSourceMuteResources();
|
255
|
|
- if (this._checkForCameraIssues()) {
|
256
|
|
- this._fireNoDataFromSourceEvent();
|
257
|
|
- }
|
|
248
|
+ _isNoDataFromSourceEventsEnabled() {
|
|
249
|
+ // Disable the events for screen sharing.
|
|
250
|
+ return !this.isVideoTrack() || this.videoType !== VideoType.DESKTOP;
|
258
|
251
|
}
|
259
|
252
|
|
260
|
253
|
/**
|
261
|
254
|
* Fires NO_DATA_FROM_SOURCE event and logs it to analytics and callstats.
|
262
|
255
|
*/
|
263
|
256
|
_fireNoDataFromSourceEvent() {
|
264
|
|
- this.emit(NO_DATA_FROM_SOURCE);
|
|
257
|
+ const value = !this.isReceivingData();
|
265
|
258
|
|
266
|
|
- Statistics.sendAnalytics(createNoDataFromSourceEvent(this.getType()));
|
267
|
|
- const log = { name: NO_DATA_FROM_SOURCE };
|
|
259
|
+ this.emit(NO_DATA_FROM_SOURCE, value);
|
268
|
260
|
|
269
|
|
- if (this.isAudioTrack()) {
|
270
|
|
- log.isReceivingData = this._isReceivingData();
|
271
|
|
- }
|
272
|
|
- Statistics.sendLog(JSON.stringify(log));
|
|
261
|
+ // FIXME: Should we report all of those events
|
|
262
|
+ Statistics.sendAnalytics(createNoDataFromSourceEvent(this.getType(), value));
|
|
263
|
+ Statistics.sendLog(JSON.stringify({
|
|
264
|
+ name: NO_DATA_FROM_SOURCE,
|
|
265
|
+ log: value
|
|
266
|
+ }));
|
273
|
267
|
}
|
274
|
268
|
|
275
|
269
|
/**
|
|
@@ -738,22 +732,6 @@ export default class JitsiLocalTrack extends JitsiTrack {
|
738
|
732
|
}
|
739
|
733
|
}
|
740
|
734
|
|
741
|
|
- /**
|
742
|
|
- * Detects camera issues, i.e. returns true if we expect this track to be
|
743
|
|
- * receiving data from its source, but it isn't receiving data.
|
744
|
|
- *
|
745
|
|
- * @returns {boolean} true if an issue is detected and false otherwise
|
746
|
|
- */
|
747
|
|
- _checkForCameraIssues() {
|
748
|
|
- if (!this.isVideoTrack()
|
749
|
|
- || this._stopStreamInProgress
|
750
|
|
- || this.videoType === VideoType.DESKTOP) {
|
751
|
|
- return false;
|
752
|
|
- }
|
753
|
|
-
|
754
|
|
- return !this._isReceivingData();
|
755
|
|
- }
|
756
|
|
-
|
757
|
735
|
/**
|
758
|
736
|
* Checks whether the attached MediaStream is receiving data from source or
|
759
|
737
|
* not. If the stream property is null(because of mute or another reason)
|
|
@@ -765,7 +743,12 @@ export default class JitsiLocalTrack extends JitsiTrack {
|
765
|
743
|
* @returns {boolean} true if the stream is receiving data and false
|
766
|
744
|
* this otherwise.
|
767
|
745
|
*/
|
768
|
|
- _isReceivingData() {
|
|
746
|
+ isReceivingData() {
|
|
747
|
+ if (this.isVideoTrack()
|
|
748
|
+ && (this.isMuted() || this._stopStreamInProgress || this.videoType === VideoType.DESKTOP)) {
|
|
749
|
+ return true;
|
|
750
|
+ }
|
|
751
|
+
|
769
|
752
|
if (!this.stream) {
|
770
|
753
|
return false;
|
771
|
754
|
}
|