diff --git a/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoParticipant.java b/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoParticipant.java index 2c256b02..ca3b3467 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoParticipant.java +++ b/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoParticipant.java @@ -376,6 +376,10 @@ public class KurentoParticipant extends Participant { } publisher.unregisterErrorListeners(); + if (publisher.kmsWebrtcStatsThread != null) { + publisher.kmsWebrtcStatsThread.cancel(true); + } + for (MediaElement el : publisher.getMediaElements()) { releaseElement(getParticipantPublicId(), el); } @@ -393,7 +397,12 @@ public class KurentoParticipant extends Participant { private void releaseSubscriberEndpoint(String senderName, SubscriberEndpoint subscriber, String reason) { if (subscriber != null) { + subscriber.unregisterErrorListeners(); + if (subscriber.kmsWebrtcStatsThread != null) { + subscriber.kmsWebrtcStatsThread.cancel(true); + } + releaseElement(senderName, subscriber.getEndpoint()); if (!ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(this.getParticipantPublicId())) { diff --git a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/MediaEndpoint.java b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/MediaEndpoint.java index 22dfb9f6..0d8bda09 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/MediaEndpoint.java +++ b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/MediaEndpoint.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Future; import org.kurento.client.Continuation; import org.kurento.client.ErrorEvent; @@ -87,6 +88,7 @@ public abstract class MediaEndpoint { public String selectedLocalIceCandidate; public String selectedRemoteIceCandidate; public Queue kmsEvents = new ConcurrentLinkedQueue<>(); + public Future kmsWebrtcStatsThread; /** * Constructor to set the owner, the endpoint's name and the media pipeline.