diff --git a/src/main/java/org/jitsi/videobridge/eventadmin/callstats/CallStatsConferenceStatsHandler.java b/src/main/java/org/jitsi/videobridge/eventadmin/callstats/CallStatsConferenceStatsHandler.java index b1128876e2..419ee476e5 100644 --- a/src/main/java/org/jitsi/videobridge/eventadmin/callstats/CallStatsConferenceStatsHandler.java +++ b/src/main/java/org/jitsi/videobridge/eventadmin/callstats/CallStatsConferenceStatsHandler.java @@ -47,7 +47,7 @@ class CallStatsConferenceStatsHandler private static final Logger logger = Logger.getLogger(CallStatsConferenceStatsHandler.class); - /* + /** * The {@link MediaType}s for which we will report to callstats. */ private static final MediaType[] MEDIA_TYPES @@ -107,7 +107,7 @@ void start(CallStats callStats, String bridgeId, this.interval = interval; this.conferenceIDPrefix = conferenceIDPrefix; - if(this.conferenceIDPrefix != null + if (this.conferenceIDPrefix != null && !this.conferenceIDPrefix.endsWith("/")) this.conferenceIDPrefix += "/"; } @@ -171,8 +171,8 @@ private void conferenceCreated(final Conference conference) cpr.start(); // register for periodic execution. - this.statisticsProcessors.put(conference, cpr); - this.statisticsExecutor.registerRecurringRunnable(cpr); + statisticsProcessors.put(conference, cpr); + statisticsExecutor.registerRecurringRunnable(cpr); } /** @@ -193,7 +193,9 @@ private void conferenceExpired(Conference conference) = statisticsProcessors.remove(conference); if (cpr == null) + { return; + } cpr.stop(); statisticsExecutor.deRegisterRecurringRunnable(cpr); @@ -246,18 +248,19 @@ public ConferencePeriodicRunnable( @Override protected void doRun() { - // if userInfo is missing the method conferenceSetupResponse - // is not called, means callstats still has not setup internally - // this conference, and no stats will be processed for it - if(userInfo == null) + if (userInfo == null) + { return; + } for (Endpoint e : o.getEndpoints()) { for (MediaType mediaType : MEDIA_TYPES) { for (RtpChannel rc : e.getChannels(mediaType)) + { processChannelStats(rc); + } } } } @@ -285,9 +288,12 @@ void start() */ void stop() { - callStats.sendCallStatsConferenceEvent( + if (userInfo != null) + { + callStats.sendCallStatsConferenceEvent( CallStatsConferenceEvents.CONFERENCE_TERMINATED, userInfo); + } } /** @@ -315,16 +321,27 @@ private void processChannelStats(RtpChannel channel) return; } + if (userInfo == null) + { + return; + } + if (channel.getReceiveSSRCs().length == 0) + { return; + } MediaStream stream = channel.getStream(); if (stream == null) + { return; + } MediaStreamStats2 stats = stream.getMediaStreamStats(); if (stats == null) + { return; + } Endpoint endpoint = channel.getEndpoint(); String endpointID = (endpoint == null) ? "" : endpoint.getID(); @@ -390,7 +407,7 @@ private static class CSStartConferenceListener { /** * Weak reference for the ConferencePeriodicRunnable, to make sure - * if this listener got leaked somwehere in callstats we will not keep + * if this listener got leaked somewhere in callstats we will not keep * reference to conferences and such. */ private final WeakReference processible; @@ -406,20 +423,30 @@ private static class CSStartConferenceListener this.processible = processible; } + /** + * TODO + * @param ucid TODO + */ @Override public void onResponse(String ucid) { ConferencePeriodicRunnable p = processible.get(); // maybe null cause it was garbage collected - if(p != null) + if (p != null) p.conferenceSetupResponse(ucid); } + /** + * TODO + * @param callStatsErrors TODO + * @param s TODO + */ @Override public void onError(CallStatsErrors callStatsErrors, String s) { - logger.error(s + "," + callStatsErrors); + logger.error("Failed to start a callstats conference (???): " + + s + ", " + callStatsErrors); } } }