From 1f3cff06b3c049becebe59cd67fd8d23034dc1c4 Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Wed, 5 Aug 2015 19:55:12 +0000 Subject: [PATCH] - add more information on the logs to track down webcam disconnections --- .../app/video/VideoStreamListener.java | 41 +++++++++++++++---- .../red5/client/UserClientMessageSender.java | 1 + .../modules/users/services/MessageReceiver.as | 14 +++++-- 3 files changed, 46 insertions(+), 10 deletions(-) mode change 100644 => 100755 bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as diff --git a/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoStreamListener.java b/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoStreamListener.java index 6a5135742f..9e5c5e7bb9 100755 --- a/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoStreamListener.java +++ b/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoStreamListener.java @@ -21,10 +21,7 @@ package org.bigbluebutton.app.video; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; - import org.apache.mina.core.buffer.IoBuffer; -import org.red5.server.api.IConnection; -import org.red5.server.api.Red5; import org.red5.server.api.scheduling.IScheduledJob; import org.red5.server.api.scheduling.ISchedulingService; import org.red5.server.api.scope.IScope; @@ -34,7 +31,6 @@ import org.red5.server.api.stream.IStreamPacket; import org.red5.server.net.rtmp.event.VideoData; import org.red5.server.scheduling.QuartzSchedulingService; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.red5.logging.Red5LoggerFactory; import com.google.gson.Gson; @@ -84,6 +80,8 @@ public class VideoStreamListener implements IStreamListener { private volatile boolean publishing = false; + private volatile boolean streamPaused = false; + private IScope scope; public VideoStreamListener(IScope scope, IBroadcastStream stream, Boolean record, String userId, int packetTimeout) { @@ -136,6 +134,27 @@ public class VideoStreamListener implements IStreamListener { recordingService.record(scope.getName(), event); } } + + + if (streamPaused) { + streamPaused = false; + long now = System.currentTimeMillis(); + long numSeconds = (now - lastVideoTime)/1000; + + Map logData = new HashMap(); + logData.put("meetingId", scope.getName()); + logData.put("userId", userId); + logData.put("stream", stream.getPublishedName()); + logData.put("packetCount", packetCount); + logData.put("publishing", publishing); + logData.put("pausedFor (sec)", numSeconds); + + Gson gson = new Gson(); + String logStr = gson.toJson(logData); + + log.warn("Video stream restarted. data={}", logStr ); + } + } } @@ -152,7 +171,8 @@ public class VideoStreamListener implements IStreamListener { public void execute(ISchedulingService service) { long now = System.currentTimeMillis(); - if ((now - lastVideoTime) > videoTimeout) { + if ((now - lastVideoTime) > videoTimeout && !streamPaused) { + streamPaused = true; long numSeconds = (now - lastVideoTime)/1000; Map logData = new HashMap(); @@ -168,6 +188,12 @@ public class VideoStreamListener implements IStreamListener { log.warn("Video packet timeout. data={}", logStr ); + if (!publishing) { + // remove the scheduled job + scheduler.removeScheduledJob(timeoutJobName); + } + +/* if (!streamStopped) { streamStopped = true; // remove the scheduled job @@ -175,9 +201,10 @@ public class VideoStreamListener implements IStreamListener { // stop / clean up if (publishing) { stream.stop(); - } - + } } +*/ + } } diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/red5/client/UserClientMessageSender.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/red5/client/UserClientMessageSender.java index 4cd3a662ad..e30833c325 100755 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/red5/client/UserClientMessageSender.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/red5/client/UserClientMessageSender.java @@ -381,6 +381,7 @@ public class UserClientMessageSender { Map args = new HashMap(); args.put("userId", msg.userId); args.put("webcamStream", msg.stream); + args.put("serverTimestamp", System.currentTimeMillis()); Map message = new HashMap(); Gson gson = new Gson(); diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as b/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as old mode 100644 new mode 100755 index 0a94d065a4..90ba953635 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as @@ -31,6 +31,7 @@ package org.bigbluebutton.modules.users.services import org.bigbluebutton.core.model.MeetingModel; import org.bigbluebutton.core.services.UsersService; import org.bigbluebutton.core.vo.LockSettingsVO; + import org.bigbluebutton.main.api.JSLog; import org.bigbluebutton.main.events.BBBEvent; import org.bigbluebutton.main.events.MadePresenterEvent; import org.bigbluebutton.main.events.PresenterStatusEvent; @@ -42,7 +43,7 @@ package org.bigbluebutton.modules.users.services import org.bigbluebutton.main.model.users.IMessageListener; import org.bigbluebutton.main.model.users.events.StreamStoppedEvent; import org.bigbluebutton.main.model.users.events.UsersConnectionEvent; - import org.bigbluebutton.modules.users.events.MeetingMutedEvent; + import org.bigbluebutton.modules.users.events.MeetingMutedEvent; public class MessageReceiver implements IMessageListener { @@ -521,8 +522,15 @@ package org.bigbluebutton.modules.users.services } private function handleUserUnsharedWebcam(msg: Object):void { - LOGGER.debug("*** handleUserUnsharedWebcam {0} **** \n", [msg.msg]); - var map:Object = JSON.parse(msg.msg); + LOGGER.debug("*** handleUserUnsharedWebcam {0} **** \n", [msg.msg]); + var map:Object = JSON.parse(msg.msg); + + var logData:Object = new Object(); + logData.user = UsersUtil.getUserData(); + logData.user.webcamStream = map.webcamStream; + logData.user.serverTimestamp = map.serverTimestamp; + JSLog.warn("UserUnsharedWebcam server message", logData); + UserManager.getInstance().getConference().unsharedWebcam(map.userId, map.webcamStream); sendStreamStoppedEvent(map.userId, map.webcamStream); }