|
|
@@ -2,6 +2,7 @@ var JitsiTrack = require("./JitsiTrack");
|
|
2
|
2
|
var JitsiTrackEvents = require("../../JitsiTrackEvents");
|
|
3
|
3
|
var RTCBrowserType = require("./RTCBrowserType");
|
|
4
|
4
|
var Statistics = require("../statistics/statistics");
|
|
|
5
|
+var AdapterJS = require("./adapter.screenshare");
|
|
5
|
6
|
|
|
6
|
7
|
var ttfmTrackerAudioAttached = false;
|
|
7
|
8
|
var ttfmTrackerVideoAttached = false;
|
|
|
@@ -25,6 +26,10 @@ function JitsiRemoteTrack(conference, ownerJid, stream, track, mediaType, videoT
|
|
25
|
26
|
this.conference = conference;
|
|
26
|
27
|
this.peerjid = ownerJid;
|
|
27
|
28
|
this.muted = muted;
|
|
|
29
|
+ // we want to mark whether the track has been ever muted
|
|
|
30
|
+ // to detect ttfm events for startmuted conferences, as it can significantly
|
|
|
31
|
+ // increase ttfm values
|
|
|
32
|
+ this.hasBeenMuted = muted;
|
|
28
|
33
|
}
|
|
29
|
34
|
|
|
30
|
35
|
JitsiRemoteTrack.prototype = Object.create(JitsiTrack.prototype);
|
|
|
@@ -38,6 +43,9 @@ JitsiRemoteTrack.prototype.setMute = function (value) {
|
|
38
|
43
|
if(this.muted === value)
|
|
39
|
44
|
return;
|
|
40
|
45
|
|
|
|
46
|
+ if(value)
|
|
|
47
|
+ this.hasBeenMuted = true;
|
|
|
48
|
+
|
|
41
|
49
|
// we can have a fake video stream
|
|
42
|
50
|
if(this.stream)
|
|
43
|
51
|
this.stream.muted = value;
|
|
|
@@ -89,6 +97,26 @@ JitsiRemoteTrack.prototype._setVideoType = function (type) {
|
|
89
|
97
|
this.eventEmitter.emit(JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED, type);
|
|
90
|
98
|
};
|
|
91
|
99
|
|
|
|
100
|
+JitsiRemoteTrack.prototype._playCallback = function () {
|
|
|
101
|
+ var type = (this.isVideoTrack() ? 'video' : 'audio');
|
|
|
102
|
+
|
|
|
103
|
+ var now = window.performance.now();
|
|
|
104
|
+ console.log("(TIME) Render " + type + ":\t", now);
|
|
|
105
|
+ this.conference.getConnectionTimes()[type + ".render"] = now;
|
|
|
106
|
+
|
|
|
107
|
+ var ttfm = now
|
|
|
108
|
+ - (this.conference.getConnectionTimes()["session.initiate"]
|
|
|
109
|
+ - this.conference.getConnectionTimes()["muc.joined"])
|
|
|
110
|
+ - (window.connectionTimes["obtainPermissions.end"]
|
|
|
111
|
+ - window.connectionTimes["obtainPermissions.start"]);
|
|
|
112
|
+ this.conference.getConnectionTimes()[type + ".ttfm"] = ttfm;
|
|
|
113
|
+ console.log("(TIME) TTFM " + type + ":\t", ttfm);
|
|
|
114
|
+ var eventName = type +'.ttfm';
|
|
|
115
|
+ if(this.hasBeenMuted)
|
|
|
116
|
+ eventName += '.muted';
|
|
|
117
|
+ Statistics.analytics.sendEvent(eventName, ttfm);
|
|
|
118
|
+};
|
|
|
119
|
+
|
|
92
|
120
|
/**
|
|
93
|
121
|
* Attach time to first media tracker only if there is conference and only
|
|
94
|
122
|
* for the first element.
|
|
|
@@ -107,21 +135,13 @@ JitsiRemoteTrack.prototype._attachTTFMTracker = function (container) {
|
|
107
|
135
|
if (this.isVideoTrack())
|
|
108
|
136
|
ttfmTrackerVideoAttached = true;
|
|
109
|
137
|
|
|
110
|
|
- // FIXME: this is not working for temasys
|
|
111
|
|
- container.addEventListener("canplay", function () {
|
|
112
|
|
- var type = (this.isVideoTrack() ? 'video' : 'audio');
|
|
113
|
|
-
|
|
114
|
|
- var now = window.performance.now();
|
|
115
|
|
- console.log("(TIME) Render " + type + ":\t", now);
|
|
116
|
|
- this.conference.getConnectionTimes()[type + ".render"] = now;
|
|
117
|
|
-
|
|
118
|
|
- var ttfm = now
|
|
119
|
|
- - (this.conference.getConnectionTimes()["session.initiate"]
|
|
120
|
|
- - this.conference.getConnectionTimes()["muc.joined"]);
|
|
121
|
|
- this.conference.getConnectionTimes()[type + ".ttfm"] = ttfm;
|
|
122
|
|
- console.log("(TIME) TTFM " + type + ":\t", ttfm);
|
|
123
|
|
- Statistics.analytics.sendEvent(type +'.ttfm', ttfm);
|
|
124
|
|
- }.bind(this));
|
|
|
138
|
+ if (RTCBrowserType.isTemasysPluginUsed()) {
|
|
|
139
|
+ // FIXME: this is not working for IE11
|
|
|
140
|
+ AdapterJS.addEvent(container, 'play', this._playCallback.bind(this));
|
|
|
141
|
+ }
|
|
|
142
|
+ else {
|
|
|
143
|
+ container.addEventListener("canplay", this._playCallback.bind(this));
|
|
|
144
|
+ }
|
|
125
|
145
|
};
|
|
126
|
146
|
|
|
127
|
147
|
module.exports = JitsiRemoteTrack;
|