Permalink
Browse files

feat(jitsi tracks): improve logging

Adds toString methods and improve log messages around local and remote
tracks.
  • Loading branch information...
paweldomas committed Feb 6, 2017
1 parent bf56a9c commit 3f5c8e40b534f1308e1aa0a8fefdaa740a5a8060
Showing with 68 additions and 36 deletions.
  1. +21 −10 modules/RTC/JitsiLocalTrack.js
  2. +8 −0 modules/RTC/JitsiRemoteTrack.js
  3. +39 −26 modules/RTC/TraceablePeerConnection.js
@@ -139,9 +139,7 @@ JitsiLocalTrack.prototype._addPeerConnection = function(tpc) {
this.peerConnections.push(tpc);
} else {
logger.error(
"PeerConnection[" + tpc.id
+ " is associated with the local track already["
+ this.rtcId + "]");
tpc + " has been associated with " + this + " already !");
}
};
@@ -150,10 +148,7 @@ JitsiLocalTrack.prototype._removePeerConnection = function (tpc) {
this.peerConnections.splice(
this.peerConnections.indexOf(tpc), 1);
} else {
logger.error(
"PeerConnection[" + tpc.id
+ " is not associated with this local track["
+ this.rtcId + "]");
logger.error(tpc + " is not associated with " + this);
}
};
@@ -267,8 +262,9 @@ JitsiLocalTrack.prototype._setStream = function (stream) {
// Store the MSID for video mute/unmute purposes
if (stream) {
this.storedMSID = this.getMSID();
logger.debug(
"Setting new MSID: " + this.storedMSID + " on: " + this.rtcId);
logger.debug("Setting new MSID: " + this.storedMSID + " on " + this);
} else {
logger.debug("Setting 'null' stream on " + this);
}
};
@@ -341,16 +337,21 @@ JitsiLocalTrack.prototype._setMute = function (mute) {
this.dontFireRemoveEvent = false;
// A function that will print info about muted status transition
const loggerMuteInfo = () => { logger.info("Mute " + this + ": " + mute); };
// FIXME FF does not support 'removeStream' method used to mute
if (this.isAudioTrack() ||
this.videoType === VideoType.DESKTOP ||
RTCBrowserType.isFirefox()) {
loggerMuteInfo();
if(this.track)
this.track.enabled = !mute;
} else {
if(mute) {
this.dontFireRemoveEvent = true;
promise = new Promise( (resolve, reject) => {
loggerMuteInfo();
this._removeStreamFromConferenceAsMute(() => {
//FIXME: Maybe here we should set the SRC for the containers
// to something
@@ -362,6 +363,7 @@ JitsiLocalTrack.prototype._setMute = function (mute) {
});
});
} else {
loggerMuteInfo();
// This path is only for camera.
var streamOptions = {
cameraDeviceId: this.getDeviceId(),
@@ -388,7 +390,7 @@ JitsiLocalTrack.prototype._setMute = function (mute) {
// unmute, but let's not crash here
if (self.videoType !== streamInfo.videoType) {
logger.warn(
"Video type has changed after unmute!",
this + ": video type has changed after unmute!",
self.videoType, streamInfo.videoType);
self.videoType = streamInfo.videoType;
}
@@ -583,6 +585,7 @@ JitsiLocalTrack.prototype._setByteSent = function (bytesSent) {
if(this._testByteSent && "connected" === iceConnectionState) {
setTimeout(function () {
if(this._bytesSent <= 0){
logger.warn(this + " 'bytes sent' <= 0: " + this._bytesSent);
//we are not receiving anything from the microphone
this._fireNoDataFromSourceEvent();
}
@@ -677,4 +680,12 @@ JitsiLocalTrack.prototype._isReceivingData = function () {
&& (!("muted" in track) || track.muted !== true)));
};
/**
* Creates a text representation of this local track instance.
* @return {string}
*/
JitsiLocalTrack.prototype.toString = function () {
return "LocalTrack[" + this.rtcId + "," + this.getType() + "]";
};
module.exports = JitsiLocalTrack;
@@ -186,4 +186,12 @@ JitsiRemoteTrack.prototype._attachTTFMTracker = function (container) {
}
};
/**
* Creates a text representation of this remote track instance.
* @return {string}
*/
JitsiRemoteTrack.prototype.toString = function () {
return "RemoteTrack[" + this.owner + ", " + this.getType() + "]";
};
module.exports = JitsiRemoteTrack;
@@ -225,6 +225,8 @@ function TraceablePeerConnection(rtc, id, signallingLayer, ice_config,
}, 1000);
}
logger.info("Create new " + this);
}
/**
@@ -248,7 +250,7 @@ TraceablePeerConnection.prototype._peerVideoTypeChanged
= function (endpointId, videoType) {
// Check if endpointId has a value to avoid action on random track
if (!endpointId) {
logger.error("No endpointID on peerVideoTypeChanged");
logger.error("No endpointID on peerVideoTypeChanged " + this);
return;
}
const videoTrack = this.getRemoteTracks(endpointId, MediaType.VIDEO);
@@ -329,9 +331,11 @@ TraceablePeerConnection.prototype.getLocalTracks = function(mediaType) {
*/
TraceablePeerConnection.prototype._remoteStreamAdded = function (stream) {
const self = this;
if (!RTC.isUserStream(stream)) {
const streamId = RTC.getStreamID(stream);
if (!RTC.isUserStreamById(streamId)) {
logger.info(
"Ignored remote 'stream added' event for non-user stream", stream);
this + " ignored remote 'stream added' event for non-user stream id: "
+ streamId);
return;
}
// Bind 'addtrack'/'removetrack' event handlers
@@ -367,7 +371,7 @@ TraceablePeerConnection.prototype._remoteTrackAdded = function (stream, track) {
const streamId = RTC.getStreamID(stream);
const mediaType = track.kind;
logger.info("Remote track added", streamId, mediaType);
logger.info(this + " remote track added:", streamId, mediaType);
// look up an associated JID for a stream id
if (!mediaType) {
@@ -425,14 +429,14 @@ TraceablePeerConnection.prototype._remoteTrackAdded = function (stream, track) {
return;
}
logger.log('associated ssrc', owner, trackSsrc);
logger.log(this + ' associated ssrc', owner, trackSsrc);
const peerMediaInfo
= this.signallingLayer.getPeerMediaInfo(owner, mediaType);
if (!peerMediaInfo) {
GlobalOnErrorHandler.callErrorHandler(
new Error("No peer media info available for: " + owner));
new Error(this + " no peer media info available for: " + owner));
// Abort
return;
}
@@ -466,7 +470,9 @@ TraceablePeerConnection.prototype._createRemoteTrack
= this.remoteTracks[owner] || (this.remoteTracks[owner] = { });
if (remoteTracks[mediaType]) {
logger.error("Overwriting remote track!", owner, mediaType);
logger.error(
this + " overwriting remote track! " + remoteTrack,
owner, mediaType);
}
remoteTracks[mediaType] = remoteTrack;
@@ -509,18 +515,18 @@ TraceablePeerConnection.prototype._remoteTrackRemoved
const streamId = RTC.getStreamID(stream);
const trackId = track && track.id;
logger.info("Remote track removed", streamId, trackId);
logger.info(this + " - remote track removed:", streamId, trackId);
if (!streamId) {
GlobalOnErrorHandler.callErrorHandler(
new Error("Remote track removal failed - no stream ID"));
new Error(this + " remote track removal failed - no stream ID"));
// Abort
return;
}
if (!trackId) {
GlobalOnErrorHandler.callErrorHandler(
new Error("Remote track removal failed - no track ID"));
new Error(this + " remote track removal failed - no track ID"));
// Abort
return;
}
@@ -537,7 +543,7 @@ TraceablePeerConnection.prototype._remoteTrackRemoved
// behave unexpectedly (the "user left" event would come before "track
// removed" events).
logger.warn(
"Removed track not found for msid: " + streamId
this + " Removed track not found for msid: " + streamId
+ "track id: " + trackId);
}
};
@@ -628,7 +634,7 @@ TraceablePeerConnection.prototype.removeRemoteTracks = function (owner) {
}
logger.debug(
"Removed remote tracks for " + owner
this + " removed remote tracks for " + owner
+ " count: " + removedTracks.length);
return removedTracks;
@@ -720,7 +726,7 @@ TraceablePeerConnection.prototype.removeRemoteTracks = function (owner) {
}
logger.debug(
"Removed remote tracks for " + owner
this + " removed remote tracks for " + owner
+ " count: " + removedTracks.length);
return removedTracks;
@@ -926,11 +932,10 @@ TraceablePeerConnection.prototype._getSSRC = function(rtcId) {
TraceablePeerConnection.prototype.addStream = function (stream) {
const rtcId = stream.rtcId;
this.trace('addLocalTrack', rtcId);
logger.info("add " + stream + " to: " + this);
if (this.localTracks[rtcId]) {
logger.error(
"Local track already in the PeerConnection: " + rtcId);
logger.error(stream + " is already in " + this);
return;
}
@@ -941,7 +946,7 @@ TraceablePeerConnection.prototype.addStream = function (stream) {
if (webrtcStream)
this.peerconnection.addStream(webrtcStream);
else
logger.warn("No WebRTC stream for: " + rtcId);
logger.warn(this + " no WebRTC stream for: " + stream);
// Muted video tracks do not have WebRTC stream
if (stream.isVideoTrack() && stream.isMuted()) {
@@ -996,8 +1001,7 @@ TraceablePeerConnection.prototype._assertTrackBelongs
const doesBelong = !!this.localTracks[localTrack.rtcId];
if (!doesBelong) {
logger.error(
methodName + ":local track[" + localTrack.rtcId
+ "] does not belong to this TPC[" + this.id + "]!");
methodName + ": " + localTrack + " does not belong to " + this);
}
return doesBelong;
};
@@ -1422,7 +1426,7 @@ TraceablePeerConnection.prototype._applyLocalSSRCMap = function (ssrcMap) {
if(ssrcMap[trackMSID]){
const newSSRC = ssrcMap[trackMSID];
if (!newSSRC) {
logger.error("No SSRC found for: " + trackMSID);
logger.error("No SSRC found for: " + trackMSID + " in " + this);
return;
}
const oldSSRC = this.localSSRCs[track.rtcId];
@@ -1431,20 +1435,20 @@ TraceablePeerConnection.prototype._applyLocalSSRCMap = function (ssrcMap) {
if (newSSRCNum != oldSSRCNum) {
if (oldSSRCNum !== null) {
logger.error(
"Overwriting SSRC for local track: "
+ trackMSID +" with: ", newSSRC);
"Overwriting SSRC for " + track + " "
+ trackMSID + " in " + this + " with: ", newSSRC);
} else {
logger.info(
"Setting new local SSRC for: " + track.rtcId, newSSRC);
"Setting new local SSRC for " + track + " in " + this, newSSRC);
}
this.localSSRCs[track.rtcId] = newSSRC;
} else {
logger.debug(
"Not updating local SSRC for: "
+ trackMSID +" to: " + newSSRCNum);
"Not updating local SSRC for " + track + " "
+ trackMSID +" to: " + newSSRCNum + " in " + this);
}
} else {
logger.warn("No local track matched with: " + trackMSID);
logger.warn("No local track matched with: " + trackMSID + " in " + this);
}
}.bind(this));
};
@@ -1526,4 +1530,13 @@ TraceablePeerConnection.prototype.generateNewStreamSSRCInfo = function (track) {
return ssrcInfo;
};
/**
* Creates a text representation of this <tt>TraceablePeerConnection</tt>
* instance.
* @return {string}
*/
TraceablePeerConnection.prototype.toString = function () {
return "TPC[" + this.id + "]";
};
module.exports = TraceablePeerConnection;

0 comments on commit 3f5c8e4

Please sign in to comment.