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 5b044827..50b83921 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 @@ -109,7 +109,7 @@ public class KurentoParticipant extends Participant { String publisherStreamId = this.getParticipantPublicId() + "_" + (mediaOptions.hasVideo() ? mediaOptions.getTypeOfVideo() : "MICRO") + "_" + RandomStringUtils.random(5, true, false).toUpperCase(); - this.publisher.getEndpoint().addTag("name", publisherStreamId); + this.publisher.getEndpoint().setName(publisherStreamId); addEndpointListeners(this.publisher); // Remove streamId from publisher's map @@ -299,7 +299,7 @@ public class KurentoParticipant extends Participant { String subscriberStreamId = this.getParticipantPublicId() + "_" + kSender.getPublisherStreamId(); - subscriber.getEndpoint().addTag("name", subscriberStreamId); + subscriber.getEndpoint().setName(subscriberStreamId); addEndpointListeners(subscriber); @@ -383,8 +383,7 @@ public class KurentoParticipant extends Participant { * Returns a {@link SubscriberEndpoint} for the given participant public id. The * endpoint is created if not found. * - * @param remotePublicId - * id of another user + * @param remotePublicId id of another user * @return the endpoint instance */ public SubscriberEndpoint getNewOrExistingSubscriber(String senderPublicId) { @@ -486,7 +485,7 @@ public class KurentoParticipant extends Participant { /* * endpoint.getWebEndpoint().addElementConnectedListener((element) -> { String * msg = " Element connected (" + - * endpoint.getEndpoint().getTag("name") + ") -> " + "SINK: " + + * endpoint.getEndpoint().getName() + ") -> " + "SINK: " + * element.getSink().getName() + " | SOURCE: " + element.getSource().getName() + * " | MEDIATYPE: " + element.getMediaType(); System.out.println(msg); * this.infoHandler.sendInfo(msg); }); @@ -495,7 +494,7 @@ public class KurentoParticipant extends Participant { /* * endpoint.getWebEndpoint().addElementDisconnectedListener((event) -> { String * msg = " Element disconnected (" + - * endpoint.getEndpoint().getTag("name") + ") -> " + "SINK: " + + * endpoint.getEndpoint().getName() + ") -> " + "SINK: " + * event.getSinkMediaDescription() + " | SOURCE: " + * event.getSourceMediaDescription() + " | MEDIATYPE: " + event.getMediaType(); * System.out.println(msg); this.infoHandler.sendInfo(msg); }); @@ -510,7 +509,7 @@ public class KurentoParticipant extends Participant { * * endpoint.getWebEndpoint().addMediaFlowInStateChangeListener((event) -> { * String msg1 = " Media flow in state change (" + - * endpoint.getEndpoint().getTag("name") + ") -> " + "STATE: " + + * endpoint.getEndpoint().getName() + ") -> " + "STATE: " + * event.getState() + " | SOURCE: " + event.getSource().getName() + " | PAD: " + * event.getPadName() + " | MEDIATYPE: " + event.getMediaType() + * " | TIMESTAMP: " + System.currentTimeMillis(); @@ -522,10 +521,10 @@ public class KurentoParticipant extends Participant { * * if (endpoint.flowInMedia.values().size() != 2) { msg2 = * " THERE ARE LESS FLOW IN MEDIA'S THAN EXPECTED IN " + - * endpoint.getEndpoint().getTag("name") + " (" + + * endpoint.getEndpoint().getName() + " (" + * endpoint.flowInMedia.values().size() + ")"; } else { msg2 = * " NUMBER OF FLOW IN MEDIA'S IS NOW CORRECT IN " + - * endpoint.getEndpoint().getTag("name") + " (" + + * endpoint.getEndpoint().getName() + " (" + * endpoint.flowInMedia.values().size() + ")"; } * * log.debug(msg1); log.debug(msg2); this.infoHandler.sendInfo(msg1); @@ -533,7 +532,7 @@ public class KurentoParticipant extends Participant { * * endpoint.getWebEndpoint().addMediaFlowOutStateChangeListener((event) -> { * String msg1 = " Media flow out state change (" + - * endpoint.getEndpoint().getTag("name") + ") -> " + "STATE: " + + * endpoint.getEndpoint().getName() + ") -> " + "STATE: " + * event.getState() + " | SOURCE: " + event.getSource().getName() + " | PAD: " + * event.getPadName() + " | MEDIATYPE: " + event.getMediaType() + * " | TIMESTAMP: " + System.currentTimeMillis(); @@ -546,10 +545,10 @@ public class KurentoParticipant extends Participant { * * if (endpoint.flowOutMedia.values().size() != 2) { msg2 = * " THERE ARE LESS FLOW OUT MEDIA'S THAN EXPECTED IN " + - * endpoint.getEndpoint().getTag("name") + " (" + + * endpoint.getEndpoint().getName() + " (" + * endpoint.flowOutMedia.values().size() + ")"; } else { msg2 = * " NUMBER OF FLOW OUT MEDIA'S IS NOW CORRECT IN " + - * endpoint.getEndpoint().getTag("name") + " (" + + * endpoint.getEndpoint().getName() + " (" + * endpoint.flowOutMedia.values().size() + ")"; } * * log.debug(msg1); log.debug(msg2); this.infoHandler.sendInfo(msg1); @@ -557,51 +556,51 @@ public class KurentoParticipant extends Participant { * * endpoint.getWebEndpoint().addMediaSessionStartedListener((event) -> { String * msg = " Media session started (" + - * endpoint.getEndpoint().getTag("name") + ") | TIMESTAMP: " + + * endpoint.getEndpoint().getName() + ") | TIMESTAMP: " + * System.currentTimeMillis(); log.debug(msg); this.infoHandler.sendInfo(msg); * }); * * endpoint.getWebEndpoint().addMediaSessionTerminatedListener((event) -> { * String msg = " Media session terminated (" + - * endpoint.getEndpoint().getTag("name") + ") | TIMESTAMP: " + + * endpoint.getEndpoint().getName() + ") | TIMESTAMP: " + * System.currentTimeMillis(); log.debug(msg); this.infoHandler.sendInfo(msg); * }); * * endpoint.getWebEndpoint().addMediaStateChangedListener((event) -> { String * msg = " Media state changed (" + - * endpoint.getEndpoint().getTag("name") + ") from " + event.getOldState() + + * endpoint.getEndpoint().getName() + ") from " + event.getOldState() + * " to " + event.getNewState(); log.debug(msg); this.infoHandler.sendInfo(msg); * }); * * endpoint.getWebEndpoint().addConnectionStateChangedListener((event) -> { * String msg = " Connection state changed (" + - * endpoint.getEndpoint().getTag("name") + ") from " + event.getOldState() + + * endpoint.getEndpoint().getName() + ") from " + event.getOldState() + * " to " + event.getNewState() + " | TIMESTAMP: " + System.currentTimeMillis(); * log.debug(msg); this.infoHandler.sendInfo(msg); }); * * endpoint.getWebEndpoint().addIceCandidateFoundListener((event) -> { String * msg = " ICE CANDIDATE FOUND (" + - * endpoint.getEndpoint().getTag("name") + "): CANDIDATE: " + + * endpoint.getEndpoint().getName() + "): CANDIDATE: " + * event.getCandidate().getCandidate() + " | TIMESTAMP: " + * System.currentTimeMillis(); log.debug(msg); this.infoHandler.sendInfo(msg); * }); * * endpoint.getWebEndpoint().addIceComponentStateChangeListener((event) -> { * String msg = " ICE COMPONENT STATE CHANGE (" + - * endpoint.getEndpoint().getTag("name") + "): for component " + + * endpoint.getEndpoint().getName() + "): for component " + * event.getComponentId() + " - STATE: " + event.getState() + " | TIMESTAMP: " + * System.currentTimeMillis(); log.debug(msg); this.infoHandler.sendInfo(msg); * }); * * endpoint.getWebEndpoint().addIceGatheringDoneListener((event) -> { String msg * = " ICE GATHERING DONE! (" + - * endpoint.getEndpoint().getTag("name") + ")" + " | TIMESTAMP: " + + * endpoint.getEndpoint().getName() + ")" + " | TIMESTAMP: " + * System.currentTimeMillis(); log.debug(msg); this.infoHandler.sendInfo(msg); * }); */ endpoint.getWebEndpoint().addMediaFlowInStateChangeListener(event -> { - String msg1 = "Media flow in state change (" + endpoint.getEndpoint().getTag("name") + ") -> " + "STATE: " + String msg1 = "Media flow in state change (" + endpoint.getEndpoint().getName() + ") -> " + "STATE: " + event.getState() + " | SOURCE: " + event.getSource().getName() + " | PAD: " + event.getPadName() + " | MEDIATYPE: " + event.getMediaType() + " | TIMESTAMP: " + System.currentTimeMillis(); @@ -622,7 +621,7 @@ public class KurentoParticipant extends Participant { }); endpoint.getWebEndpoint().addMediaFlowOutStateChangeListener(event -> { - String msg1 = "Media flow out state change (" + endpoint.getEndpoint().getTag("name") + ") -> " + "STATE: " + String msg1 = "Media flow out state change (" + endpoint.getEndpoint().getName() + ") -> " + "STATE: " + event.getState() + " | SOURCE: " + event.getSource().getName() + " | PAD: " + event.getPadName() + " | MEDIATYPE: " + event.getMediaType() + " | TIMESTAMP: " + System.currentTimeMillis(); @@ -654,7 +653,7 @@ public class KurentoParticipant extends Participant { endpoint.selectedLocalIceCandidate = event.getCandidatePair().getLocalCandidate(); endpoint.selectedRemoteIceCandidate = event.getCandidatePair().getRemoteCandidate(); endpoint.kmsEvents.add(new KmsEvent(event, endpoint.createdAt())); - String msg = "ICE CANDIDATE SELECTED (" + endpoint.getEndpoint().getTag("name") + "): LOCAL CANDIDATE: " + String msg = "ICE CANDIDATE SELECTED (" + endpoint.getEndpoint().getName() + "): LOCAL CANDIDATE: " + endpoint.selectedLocalIceCandidate + " | REMOTE CANDIDATE: " + endpoint.selectedRemoteIceCandidate + " | TIMESTAMP: " + System.currentTimeMillis(); log.warn(msg); @@ -678,7 +677,7 @@ public class KurentoParticipant extends Participant { @Override public String getPublisherStreamId() { - return this.publisher.getEndpoint().getTag("name"); + return this.publisher.getEndpoint().getName(); } @Override diff --git a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/KmsEvent.java b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/KmsEvent.java index b59cd955..f86a6cc1 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/KmsEvent.java +++ b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/KmsEvent.java @@ -11,7 +11,7 @@ public class KmsEvent { public KmsEvent(MediaEvent event, long createdAt) { this.event = event; - this.endpoint = event.getSource().getTag("name"); + this.endpoint = event.getSource().getName(); this.event.setSource(null); this.timestamp = System.currentTimeMillis(); this.msSinceCreation = this.timestamp - createdAt; 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 005ebc99..482d64bf 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 @@ -31,14 +31,12 @@ import org.kurento.client.EventListener; import org.kurento.client.IceCandidate; import org.kurento.client.ListenerSubscription; import org.kurento.client.MediaElement; -import org.kurento.client.MediaEvent; import org.kurento.client.MediaPipeline; import org.kurento.client.MediaType; import org.kurento.client.OnIceCandidateEvent; import org.kurento.client.RtpEndpoint; import org.kurento.client.SdpEndpoint; import org.kurento.client.WebRtcEndpoint; -import org.kurento.client.internal.server.KurentoServerException; import org.kurento.jsonrpc.JsonUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -179,9 +177,8 @@ public abstract class MediaEndpoint { * actions are taken. It also registers an error listener for the endpoint and * for any additional media elements. * - * @param endpointLatch - * latch whose countdown is performed when the asynchronous call to - * build the {@link WebRtcEndpoint} returns + * @param endpointLatch latch whose countdown is performed when the asynchronous + * call to build the {@link WebRtcEndpoint} returns * * @return the existing endpoint, if any */ @@ -211,8 +208,7 @@ public abstract class MediaEndpoint { * Sets the {@link MediaPipeline} used to create the internal * {@link WebRtcEndpoint}. * - * @param pipeline - * the {@link MediaPipeline} + * @param pipeline the {@link MediaPipeline} */ public void setMediaPipeline(MediaPipeline pipeline) { this.pipeline = pipeline; @@ -228,8 +224,7 @@ public abstract class MediaEndpoint { /** * Sets the endpoint's name (as indicated by the browser). * - * @param endpointName - * the name + * @param endpointName the name */ public void setEndpointName(String endpointName) { this.endpointName = endpointName; @@ -299,8 +294,7 @@ public abstract class MediaEndpoint { * Add a new {@link IceCandidate} received gathered by the remote peer of this * {@link WebRtcEndpoint}. * - * @param candidate - * the remote candidate + * @param candidate the remote candidate */ public synchronized void addIceCandidate(IceCandidate candidate) throws OpenViduException { if (!this.isWeb()) { @@ -317,8 +311,7 @@ public abstract class MediaEndpoint { * Registers a listener for when the {@link MediaElement} triggers an * {@link ErrorEvent}. Notifies the owner with the error. * - * @param element - * the {@link MediaElement} + * @param element the {@link MediaElement} * @return {@link ListenerSubscription} that can be used to deregister the * listener */ @@ -335,10 +328,8 @@ public abstract class MediaEndpoint { * Unregisters the error listener from the media element using the provided * subscription. * - * @param element - * the {@link MediaElement} - * @param subscription - * the associated {@link ListenerSubscription} + * @param element the {@link MediaElement} + * @param subscription the associated {@link ListenerSubscription} */ protected void unregisterElementErrListener(MediaElement element, final ListenerSubscription subscription) { if (element == null || subscription == null) { @@ -352,8 +343,7 @@ public abstract class MediaEndpoint { * to process the offer String. * * @see SdpEndpoint#processOffer(String) - * @param offer - * String with the Sdp offer + * @param offer String with the Sdp offer * @return the Sdp answer */ protected String processOffer(String offer) throws OpenViduException { @@ -400,8 +390,7 @@ public abstract class MediaEndpoint { * to process the answer String. * * @see SdpEndpoint#processAnswer(String) - * @param answer - * String with the Sdp answer from remote + * @param answer String with the Sdp answer from remote * @return the updated Sdp offer, based on the received answer */ protected String processAnswer(String answer) throws OpenViduException { @@ -428,8 +417,7 @@ public abstract class MediaEndpoint { * * @see WebRtcEndpoint#addOnIceCandidateListener(org.kurento.client.EventListener) * @see Participant#sendIceCandidate(String, IceCandidate) - * @throws OpenViduException - * if thrown, unable to register the listener + * @throws OpenViduException if thrown, unable to register the listener */ protected void registerOnIceCandidateEventListener() throws OpenViduException { if (!this.isWeb()) { @@ -502,11 +490,9 @@ public abstract class MediaEndpoint { public JsonObject withStatsToJson() { JsonObject json = new JsonObject(); json.addProperty("createdAt", this.createdAt); - try { - json.addProperty("webrtcTagName", this.getEndpoint().getTag("name")); - } catch (KurentoServerException ex) { - json.addProperty("webrtcTagName", "NOT_FOUND"); - } + json.addProperty("webrtcEndpointName", this.getEndpoint().getName()); + json.addProperty("remoteSdp", this.getEndpoint().getRemoteSessionDescriptor()); + json.addProperty("localSdp", this.getEndpoint().getLocalSessionDescriptor()); json.add("receivedCandidates", new GsonBuilder().create().toJsonTree(this.receivedCandidateList)); json.addProperty("localCandidate", this.selectedLocalIceCandidate); json.addProperty("remoteCandidate", this.selectedRemoteIceCandidate); diff --git a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/PublisherEndpoint.java b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/PublisherEndpoint.java index ec1d935a..c45b011d 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/PublisherEndpoint.java +++ b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/PublisherEndpoint.java @@ -136,7 +136,7 @@ public class PublisherEndpoint extends MediaEndpoint { public boolean removeParticipantAsListenerOfFilterEvent(String eventType, String participantPublicId) { if (!this.subscribersToFilterEvents.containsKey(eventType)) { - String streamId = this.getEndpoint().getTag("name"); + String streamId = this.getEndpoint().getName(); log.error("Request to removeFilterEventListener to stream {} gone wrong: Filter {} has no listener added", streamId, eventType); throw new OpenViduException(Code.FILTER_EVENT_LISTENER_NOT_FOUND, @@ -565,7 +565,7 @@ public class PublisherEndpoint extends MediaEndpoint { @Override public JsonObject toJson() { JsonObject json = super.toJson(); - json.addProperty("streamId", this.getEndpoint().getTag("name")); + json.addProperty("streamId", this.getEndpoint().getName()); json.add("mediaOptions", this.mediaOptions.toJson()); return json; } diff --git a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/SubscriberEndpoint.java b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/SubscriberEndpoint.java index 0a5176cd..d5b07da3 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/SubscriberEndpoint.java +++ b/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/SubscriberEndpoint.java @@ -78,7 +78,7 @@ public class SubscriberEndpoint extends MediaEndpoint { public JsonObject toJson() { JsonObject json = super.toJson(); try { - json.addProperty("streamId", this.publisher.getEndpoint().getTag("name")); + json.addProperty("streamId", this.publisher.getEndpoint().getName()); } catch (NullPointerException ex) { json.addProperty("streamId", "NOT_FOUND"); }