You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by se...@apache.org on 2020/04/22 23:18:37 UTC

[openmeetings] branch feature/openmeetings-2278-start-recording-twice-in-one-session updated: OPENMEETINGS-2278 Add functionality to stop the sharing as part of recording stop as it will stop the MediaStream on stop of recording. This also clears the KStream that goes ghost and enables restarting the recording. Some further work required on the UI to prevent starting to screenshare while recording potentially required.

This is an automated email from the ASF dual-hosted git repository.

sebawagner pushed a commit to branch feature/openmeetings-2278-start-recording-twice-in-one-session
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/feature/openmeetings-2278-start-recording-twice-in-one-session by this push:
     new 7fdf3f0  OPENMEETINGS-2278 Add functionality to stop the sharing as part of recording stop as it will stop the MediaStream on stop of recording. This also clears the KStream that goes ghost and enables restarting the recording. Some further work required on the UI to prevent starting to screenshare while recording potentially required.
7fdf3f0 is described below

commit 7fdf3f00573785da6125bdd0636e21adbc7fcf6a
Author: Sebastian Wagner <se...@apache.org>
AuthorDate: Thu Apr 23 11:18:22 2020 +1200

    OPENMEETINGS-2278 Add functionality to stop the sharing as part of recording stop as it will stop the MediaStream on stop of recording. This also clears the KStream that goes ghost and enables restarting the recording. Some further work required on the UI to prevent starting to screenshare while recording potentially required.
---
 .../org/apache/openmeetings/core/remote/KRoom.java   |  2 +-
 .../org/apache/openmeetings/core/remote/KStream.java |  8 ++++++++
 .../openmeetings/core/remote/KurentoHandler.java     | 20 ++++++++++++++++----
 .../openmeetings/core/remote/StreamProcessor.java    |  6 ++++++
 4 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KRoom.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KRoom.java
index c33926d..e09c593 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KRoom.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KRoom.java
@@ -237,7 +237,7 @@ public class KRoom {
 			sd = c.addStream(StreamType.SCREEN, a);
 			sd.setWidth(msg.getInt("width")).setHeight(msg.getInt("height"));
 			cm.update(c);
-			log.debug("User {}: has started sharing", sd.getUid());
+			log.debug("User {}: has started sharing, with stream: {}", sd.getUid(), a);
 			h.sendClient(sd.getSid(), newKurentoMsg()
 					.put("id", "broadcast")
 					.put("stream", sd.toJson()
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KStream.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KStream.java
index e0e6193..344b5ca 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KStream.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KStream.java
@@ -359,4 +359,12 @@ public class KStream extends AbstractStream {
 	public boolean contains(String uid) {
 		return this.uid.equals(uid) || listeners.containsKey(uid);
 	}
+
+	@Override
+	public String toString() {
+		return "KStream [room=" + room + ", streamType=" + streamType + ", profile=" + profile + ", recorder="
+				+ recorder + ", outgoingMedia=" + outgoingMedia + ", listeners=" + listeners + ", flowoutFuture="
+				+ flowoutFuture + ", chunkId=" + chunkId + ", type=" + type + ", sid=" + sid + ", uid=" + uid + "]";
+	}
+	
 }
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java
index c7abd4c..b2f847a 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java
@@ -56,6 +56,7 @@ import org.kurento.client.KurentoConnectionListener;
 import org.kurento.client.MediaObject;
 import org.kurento.client.MediaPipeline;
 import org.kurento.client.ObjectCreatedEvent;
+import org.kurento.client.ObjectDestroyedEvent;
 import org.kurento.client.PlayerEndpoint;
 import org.kurento.client.RecorderEndpoint;
 import org.kurento.client.Tag;
@@ -120,7 +121,8 @@ public class KurentoHandler {
 			try {
 				kuid = randomUUID().toString();
 				client = KurentoClient.create(kurentoWsUrl, new KConnectionListener(kuid));
-				client.getServerManager().addObjectCreatedListener(new KWatchDog());
+				client.getServerManager().addObjectCreatedListener(new KWatchDogCreate());
+				client.getServerManager().addObjectDestroyedListener(new KWatchDogDestroy());
 			} catch (Exception e) {
 				log.warn("Fail to create Kurento client, will re-try in {} ms", checkTimeout);
 				kmsRecheckScheduler.schedule(check, checkTimeout, MILLISECONDS);
@@ -384,17 +386,26 @@ public class KurentoHandler {
 			notifyRooms();
 		}
 	}
+	
+	private class KWatchDogDestroy implements EventListener<ObjectDestroyedEvent> {
 
-	private class KWatchDog implements EventListener<ObjectCreatedEvent> {
+		@Override
+		public void onEvent(ObjectDestroyedEvent event) {
+			log.debug("Kurento::ObjectDestroyedEvent objectId {}, tags {}, source {}", event.getObjectId(), event.getTags(), event.getSource());
+		}
+		
+	}
+
+	private class KWatchDogCreate implements EventListener<ObjectCreatedEvent> {
 		private ScheduledExecutorService scheduler;
 
-		public KWatchDog() {
+		public KWatchDogCreate() {
 			scheduler = Executors.newScheduledThreadPool(watchThreadCount);
 		}
 
 		@Override
 		public void onEvent(ObjectCreatedEvent evt) {
-			log.debug("Kurento::ObjectCreated -> {}", evt.getObject());
+			log.debug("Kurento::ObjectCreated -> {}, source {}", evt.getObject(), evt.getSource());
 			if (evt.getObject() instanceof MediaPipeline) {
 				// room created
 				final String roid = evt.getObject().getId();
@@ -444,6 +455,7 @@ public class KurentoHandler {
 					}
 					Map<String, String> tags = tagsAsMap(point);
 					KStream stream = streamProcessor.getByUid(tags.get("outUid"));
+					log.debug("New Endpoint {} detected, tags: {}, kStream: {}", point.getId(), tags, stream);
 					if (stream != null && stream.contains(tags.get("uid"))) {
 						return;
 					}
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java
index 1032a8a..12a6beb 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java
@@ -373,6 +373,8 @@ public class StreamProcessor implements IStreamProcessor {
 		StreamDesc sd = doStopSharing(c.getSid(), uid);
 		if (sender != null && sd != null) {
 			sender.stopBroadcast(this);
+		} else {
+			log.warn("Could not stop broadcast - could be a KStream leak and lead to ghost KStream, client: {}, uid: {} ", c, uid);
 		}
 	}
 
@@ -431,6 +433,10 @@ public class StreamProcessor implements IStreamProcessor {
 			return;
 		}
 		kHandler.getRoom(c.getRoomId()).stopRecording(this, c);
+		Optional<StreamDesc> osd = c.getScreenStream();
+		if (osd.isPresent()) {
+			pauseSharing(c, osd.get().getUid()); 
+		}
 	}
 
 	void startConvertion(Recording rec) {