You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2018/10/13 04:41:22 UTC

[openmeetings] branch master updated: [OPENMEETINGS-1352] multi-stream somehow works

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

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/master by this push:
     new 4d16b79  [OPENMEETINGS-1352] multi-stream somehow works
4d16b79 is described below

commit 4d16b7947c5f6aaa9f7d49ca9434625753117d9b
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Sat Oct 13 11:41:10 2018 +0700

    [OPENMEETINGS-1352] multi-stream somehow works
---
 .../org/apache/openmeetings/core/remote/KRoom.java    |  3 +--
 .../org/apache/openmeetings/core/remote/KStream.java  | 19 +++++++++----------
 .../openmeetings/core/remote/KurentoHandler.java      |  6 +++---
 3 files changed, 13 insertions(+), 15 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 2ddb18d..4d56ad7 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
@@ -55,11 +55,10 @@ public class KRoom {
 		return pipeline.getId();
 	}
 
-	public KStream join(final KurentoHandler h, final StreamDesc sd) {
+	public KStream join(final StreamDesc sd) {
 		log.info("ROOM {}: join client {}, stream: {}", roomId, sd.getClient().getUser().getLogin(), sd.getUid());
 		final KStream stream = new KStream(sd, this.pipeline);
 		streams.put(stream.getUid(), stream);
-		h.streamsByUid.put(stream.getUid(), stream);
 		return stream;
 	}
 
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 e9fe1e6..9186c88 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
@@ -39,7 +39,6 @@ import org.kurento.client.IceCandidate;
 import org.kurento.client.IceCandidateFoundEvent;
 import org.kurento.client.MediaPipeline;
 import org.kurento.client.MediaType;
-import org.kurento.client.Transaction;
 import org.kurento.client.WebRtcEndpoint;
 import org.kurento.jsonrpc.JsonUtils;
 import org.slf4j.Logger;
@@ -77,6 +76,7 @@ public class KStream implements IKStream {
 			return this;
 		}
 		outgoingMedia = createEndpoint(h, sd.getSid(), sd.getUid());
+		h.streamsByUid.put(uid, this);
 		addListener(h, sd.getSid(), sd.getUid(), sdpOffer);
 		Client c = sd.getClient();
 		WebSocketHelper.sendRoom(new TextRoomMessage(c.getRoomId(), c, RoomMessage.Type.rightUpdated, c.getUid()));
@@ -140,7 +140,7 @@ public class KStream implements IKStream {
 		}
 
 		log.debug("PARTICIPANT {}: obtained endpoint for {}", uid, this.uid);
-		Client cur = h.getBySid(sid);
+		Client cur = h.getBySid(this.sid);
 		if (cur.hasActivity(Activity.broadcastA)) {
 			outgoingMedia.connect(listener, MediaType.AUDIO);
 		}
@@ -151,11 +151,9 @@ public class KStream implements IKStream {
 	}
 
 	private WebRtcEndpoint createEndpoint(final KurentoHandler h, String sid, String uid) {
-		Transaction t = h.beginTransaction();
-		WebRtcEndpoint endpoint = new WebRtcEndpoint.Builder(pipeline).build(t);
-		endpoint.addTag(t, "outUid", this.uid);
-		endpoint.addTag(t, "uid", uid);
-		t.commit();
+		WebRtcEndpoint endpoint = new WebRtcEndpoint.Builder(pipeline).build();
+		endpoint.addTag("outUid", this.uid);
+		endpoint.addTag("uid", uid);
 
 		endpoint.addIceCandidateFoundListener(new EventListener<IceCandidateFoundEvent>() {
 			@Override
@@ -217,9 +215,10 @@ public class KStream implements IKStream {
 		if (this.uid.equals(uid)) {
 			outgoingMedia.addIceCandidate(candidate);
 		} else {
-			WebRtcEndpoint webRtc = listeners.get(uid);
-			if (webRtc != null) {
-				webRtc.addIceCandidate(candidate);
+			WebRtcEndpoint endpoint = listeners.get(uid);
+			log.debug("Add candidate for {}, listener found ? {}", uid, endpoint != null);
+			if (endpoint != null) {
+				endpoint.addIceCandidate(candidate);
 			}
 		}
 	}
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 e980b7c..45eb7e4 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
@@ -212,7 +212,7 @@ public class KurentoHandler {
 					KStream stream = getByUid(uid);
 					if (stream == null) {
 						KRoom room = getRoom(c.getRoomId());
-						stream = room.join(this, sd);
+						stream = room.join(sd);
 					}
 					stream.startBroadcast(this, sd, msg.getString("sdpOffer"));
 				}
@@ -359,7 +359,7 @@ public class KurentoHandler {
 
 		if (room == null) {
 			log.debug("Room {} does not exist. Will create now!", roomId);
-			Transaction t = client.beginTransaction();
+			Transaction t = beginTransaction();
 			MediaPipeline pipe = client.createMediaPipeline(t);
 			pipe.addTag(t, TAG_KUID, kuid);
 			pipe.addTag(t, TAG_ROOM, String.valueOf(roomId));
@@ -531,7 +531,7 @@ public class KurentoHandler {
 					if (stream != null && stream.contains(tags.get("uid"))) {
 						return;
 					}
-					log.warn("Invalid Endpoint {} detected, will be dropped", point.getId());
+					log.warn("Invalid Endpoint {} detected, will be dropped, tags: {}", point.getId(), tags);
 					point.release();
 				}, checkTimeout, MILLISECONDS);
 			}