From d7f0d4bdf8b7e74f8c5715f93c7697506d6b2f2c Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Fri, 11 Sep 2020 12:01:46 +0200 Subject: [PATCH] openvidu-server: offerToReceiveAudio and offerToReceiveVideo on generateOffer --- .../openvidu/server/kurento/endpoint/MediaEndpoint.java | 7 ++++--- .../server/kurento/endpoint/SubscriberEndpoint.java | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) 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 d03f42e5..ff6dfe36 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 @@ -37,6 +37,7 @@ import org.kurento.client.IceCandidate; import org.kurento.client.ListenerSubscription; import org.kurento.client.MediaElement; import org.kurento.client.MediaPipeline; +import org.kurento.client.OfferOptions; import org.kurento.client.PlayerEndpoint; import org.kurento.client.RtpEndpoint; import org.kurento.client.SdpEndpoint; @@ -516,13 +517,13 @@ public abstract class MediaEndpoint { } } - protected String generateOffer() throws OpenViduException { + protected String generateOffer(OfferOptions options) throws OpenViduException { if (this.isWeb()) { if (webEndpoint == null) { throw new OpenViduException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE, "Can't generate offer when WebRtcEndpoint is null (ep: " + endpointName + ")"); } - return webEndpoint.generateOffer(); + return webEndpoint.generateOffer(options); } else if (this.isPlayerEndpoint()) { return ""; } else { @@ -530,7 +531,7 @@ public abstract class MediaEndpoint { throw new OpenViduException(Code.MEDIA_RTP_ENDPOINT_ERROR_CODE, "Can't generate offer when RtpEndpoint is null (ep: " + endpointName + ")"); } - return endpoint.generateOffer(); + return endpoint.generateOffer(options); } } 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 ba6eeaca..2862bfc6 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 @@ -20,6 +20,7 @@ package io.openvidu.server.kurento.endpoint; import java.util.Map.Entry; import org.kurento.client.MediaPipeline; +import org.kurento.client.OfferOptions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,7 +50,12 @@ public class SubscriberEndpoint extends MediaEndpoint { publisher.connect(this.getEndpoint(), true); this.createdAt = System.currentTimeMillis(); this.publisherStreamId = publisher.getStreamId(); - String sdpOffer = generateOffer(); + + OfferOptions offerOptions = new OfferOptions(); + offerOptions.setOfferToReceiveAudio(publisher.getMediaOptions().hasAudio()); + offerOptions.setOfferToReceiveVideo(publisher.getMediaOptions().hasVideo()); + String sdpOffer = generateOffer(offerOptions); + gatherCandidates(); return sdpOffer; }