mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: refactor unnecessary isOffer param
parent
6d5bca0762
commit
17ea55ad07
|
@ -24,7 +24,6 @@ import io.openvidu.server.kurento.endpoint.KurentoFilter;
|
||||||
|
|
||||||
public class KurentoMediaOptions extends MediaOptions {
|
public class KurentoMediaOptions extends MediaOptions {
|
||||||
|
|
||||||
public boolean isOffer;
|
|
||||||
public String sdpOffer;
|
public String sdpOffer;
|
||||||
public boolean doLoopback;
|
public boolean doLoopback;
|
||||||
|
|
||||||
|
@ -34,21 +33,19 @@ public class KurentoMediaOptions extends MediaOptions {
|
||||||
public Boolean onlyPlayWithSubscribers;
|
public Boolean onlyPlayWithSubscribers;
|
||||||
public Integer networkCache;
|
public Integer networkCache;
|
||||||
|
|
||||||
public KurentoMediaOptions(boolean isOffer, String sdpOffer, Boolean hasAudio, Boolean hasVideo,
|
public KurentoMediaOptions(String sdpOffer, Boolean hasAudio, Boolean hasVideo, Boolean audioActive,
|
||||||
Boolean audioActive, Boolean videoActive, String typeOfVideo, Integer frameRate, String videoDimensions,
|
Boolean videoActive, String typeOfVideo, Integer frameRate, String videoDimensions, KurentoFilter filter,
|
||||||
KurentoFilter filter, boolean doLoopback) {
|
boolean doLoopback) {
|
||||||
super(hasAudio, hasVideo, audioActive, videoActive, typeOfVideo, frameRate, videoDimensions, filter);
|
super(hasAudio, hasVideo, audioActive, videoActive, typeOfVideo, frameRate, videoDimensions, filter);
|
||||||
this.isOffer = isOffer;
|
|
||||||
this.sdpOffer = sdpOffer;
|
this.sdpOffer = sdpOffer;
|
||||||
this.doLoopback = doLoopback;
|
this.doLoopback = doLoopback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KurentoMediaOptions(boolean isOffer, String sdpOffer, Boolean hasAudio, Boolean hasVideo,
|
public KurentoMediaOptions(String sdpOffer, Boolean hasAudio, Boolean hasVideo, Boolean audioActive,
|
||||||
Boolean audioActive, Boolean videoActive, String typeOfVideo, Integer frameRate, String videoDimensions,
|
Boolean videoActive, String typeOfVideo, Integer frameRate, String videoDimensions, KurentoFilter filter,
|
||||||
KurentoFilter filter, boolean doLoopback, String rtspUri, Boolean adaptativeBitrate,
|
boolean doLoopback, String rtspUri, Boolean adaptativeBitrate, Boolean onlyPlayWithSubscribers,
|
||||||
Boolean onlyPlayWithSubscribers, Integer networkCache) {
|
Integer networkCache) {
|
||||||
super(hasAudio, hasVideo, audioActive, videoActive, typeOfVideo, frameRate, videoDimensions, filter);
|
super(hasAudio, hasVideo, audioActive, videoActive, typeOfVideo, frameRate, videoDimensions, filter);
|
||||||
this.isOffer = isOffer;
|
|
||||||
this.sdpOffer = sdpOffer;
|
this.sdpOffer = sdpOffer;
|
||||||
this.doLoopback = doLoopback;
|
this.doLoopback = doLoopback;
|
||||||
this.rtspUri = rtspUri;
|
this.rtspUri = rtspUri;
|
||||||
|
@ -61,7 +58,6 @@ public class KurentoMediaOptions extends MediaOptions {
|
||||||
String typeOfVideo, Integer frameRate, String videoDimensions, KurentoFilter filter,
|
String typeOfVideo, Integer frameRate, String videoDimensions, KurentoFilter filter,
|
||||||
KurentoMediaOptions streamProperties) {
|
KurentoMediaOptions streamProperties) {
|
||||||
super(hasAudio, hasVideo, audioActive, videoActive, typeOfVideo, frameRate, videoDimensions, filter);
|
super(hasAudio, hasVideo, audioActive, videoActive, typeOfVideo, frameRate, videoDimensions, filter);
|
||||||
this.isOffer = streamProperties.isOffer;
|
|
||||||
this.sdpOffer = streamProperties.sdpOffer;
|
this.sdpOffer = streamProperties.sdpOffer;
|
||||||
this.doLoopback = streamProperties.doLoopback;
|
this.doLoopback = streamProperties.doLoopback;
|
||||||
this.rtspUri = streamProperties.rtspUri;
|
this.rtspUri = streamProperties.rtspUri;
|
||||||
|
|
|
@ -55,7 +55,6 @@ import io.openvidu.server.core.MediaOptions;
|
||||||
import io.openvidu.server.core.Participant;
|
import io.openvidu.server.core.Participant;
|
||||||
import io.openvidu.server.kurento.endpoint.MediaEndpoint;
|
import io.openvidu.server.kurento.endpoint.MediaEndpoint;
|
||||||
import io.openvidu.server.kurento.endpoint.PublisherEndpoint;
|
import io.openvidu.server.kurento.endpoint.PublisherEndpoint;
|
||||||
import io.openvidu.server.kurento.endpoint.SdpType;
|
|
||||||
import io.openvidu.server.kurento.endpoint.SubscriberEndpoint;
|
import io.openvidu.server.kurento.endpoint.SubscriberEndpoint;
|
||||||
import io.openvidu.server.recording.service.RecordingManager;
|
import io.openvidu.server.recording.service.RecordingManager;
|
||||||
|
|
||||||
|
@ -172,15 +171,15 @@ public class KurentoParticipant extends Participant {
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String publishToRoom(SdpType sdpType, String sdpString, boolean doLoopback, boolean silent) {
|
public String publishToRoom(String sdpOffer, boolean doLoopback, boolean silent) {
|
||||||
log.info("PARTICIPANT {}: Request to publish video in room {} (sdp type {})", this.getParticipantPublicId(),
|
log.info("PARTICIPANT {}: Request to publish video in room {})", this.getParticipantPublicId(),
|
||||||
this.session.getSessionId(), sdpType);
|
this.session.getSessionId());
|
||||||
log.trace("PARTICIPANT {}: Publishing Sdp ({}) is {}", this.getParticipantPublicId(), sdpType, sdpString);
|
log.trace("PARTICIPANT {}: Publishing SDPOffer is {}", this.getParticipantPublicId(), sdpOffer);
|
||||||
|
|
||||||
String sdpResponse = this.getPublisher().publish(sdpType, sdpString, doLoopback);
|
String sdpResponse = this.getPublisher().publish(sdpOffer, doLoopback);
|
||||||
this.streaming = true;
|
this.streaming = true;
|
||||||
|
|
||||||
log.trace("PARTICIPANT {}: Publishing Sdp ({}) is {}", this.getParticipantPublicId(), sdpType, sdpResponse);
|
log.trace("PARTICIPANT {}: Publishing Sdp is {}", this.getParticipantPublicId(), sdpResponse);
|
||||||
log.info("PARTICIPANT {}: Is now publishing video in room {}", this.getParticipantPublicId(),
|
log.info("PARTICIPANT {}: Is now publishing video in room {}", this.getParticipantPublicId(),
|
||||||
this.session.getSessionId());
|
this.session.getSessionId());
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,6 @@ import io.openvidu.server.core.SessionManager;
|
||||||
import io.openvidu.server.core.Token;
|
import io.openvidu.server.core.Token;
|
||||||
import io.openvidu.server.kurento.endpoint.KurentoFilter;
|
import io.openvidu.server.kurento.endpoint.KurentoFilter;
|
||||||
import io.openvidu.server.kurento.endpoint.PublisherEndpoint;
|
import io.openvidu.server.kurento.endpoint.PublisherEndpoint;
|
||||||
import io.openvidu.server.kurento.endpoint.SdpType;
|
|
||||||
import io.openvidu.server.kurento.kms.Kms;
|
import io.openvidu.server.kurento.kms.Kms;
|
||||||
import io.openvidu.server.kurento.kms.KmsManager;
|
import io.openvidu.server.kurento.kms.KmsManager;
|
||||||
import io.openvidu.server.rpc.RpcHandler;
|
import io.openvidu.server.rpc.RpcHandler;
|
||||||
|
@ -380,7 +379,6 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
KurentoMediaOptions kurentoOptions = (KurentoMediaOptions) mediaOptions;
|
KurentoMediaOptions kurentoOptions = (KurentoMediaOptions) mediaOptions;
|
||||||
KurentoParticipant kParticipant = (KurentoParticipant) participant;
|
KurentoParticipant kParticipant = (KurentoParticipant) participant;
|
||||||
KurentoSession kSession = kParticipant.getSession();
|
KurentoSession kSession = kParticipant.getSession();
|
||||||
SdpType sdpType = kurentoOptions.isOffer ? SdpType.OFFER : SdpType.ANSWER;
|
|
||||||
boolean isTranscodingAllowed = kSession.getSessionProperties().isTranscodingAllowed();
|
boolean isTranscodingAllowed = kSession.getSessionProperties().isTranscodingAllowed();
|
||||||
VideoCodec forcedVideoCodec = kSession.getSessionProperties().forcedVideoCodec();
|
VideoCodec forcedVideoCodec = kSession.getSessionProperties().forcedVideoCodec();
|
||||||
|
|
||||||
|
@ -391,15 +389,13 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
|
|
||||||
// Modify sdp if forced codec is defined
|
// Modify sdp if forced codec is defined
|
||||||
if (forcedVideoCodec != VideoCodec.NONE && !participant.isIpcam()) {
|
if (forcedVideoCodec != VideoCodec.NONE && !participant.isIpcam()) {
|
||||||
kurentoOptions.sdpOffer = sdpMunging.forceCodec(participant, kurentoOptions.sdpOffer,
|
kurentoOptions.sdpOffer = sdpMunging.forceCodec(participant, kurentoOptions.sdpOffer, kSession, true, false,
|
||||||
kurentoOptions.isOffer, kSession, true, false, isTranscodingAllowed, forcedVideoCodec);
|
isTranscodingAllowed, forcedVideoCodec);
|
||||||
CDR.log(new WebrtcDebugEvent(participant, streamId, WebrtcDebugEventIssuer.client,
|
CDR.log(new WebrtcDebugEvent(participant, streamId, WebrtcDebugEventIssuer.client,
|
||||||
WebrtcDebugEventOperation.publish, WebrtcDebugEventType.sdpOfferMunged, kurentoOptions.sdpOffer));
|
WebrtcDebugEventOperation.publish, WebrtcDebugEventType.sdpOfferMunged, kurentoOptions.sdpOffer));
|
||||||
}
|
}
|
||||||
log.debug(
|
log.debug("Request [PUBLISH_MEDIA] sdpOffer={} loopbackAltSrc={} lpbkConnType={} doLoopback={} rtspUri={} ({})",
|
||||||
"Request [PUBLISH_MEDIA] isOffer={} sdp={} "
|
kurentoOptions.sdpOffer, kurentoOptions.doLoopback, kurentoOptions.rtspUri,
|
||||||
+ "loopbackAltSrc={} lpbkConnType={} doLoopback={} rtspUri={} ({})",
|
|
||||||
kurentoOptions.isOffer, kurentoOptions.sdpOffer, kurentoOptions.doLoopback, kurentoOptions.rtspUri,
|
|
||||||
participant.getParticipantPublicId());
|
participant.getParticipantPublicId());
|
||||||
|
|
||||||
kParticipant.createPublishingEndpoint(mediaOptions, streamId);
|
kParticipant.createPublishingEndpoint(mediaOptions, streamId);
|
||||||
|
@ -426,7 +422,7 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sdpAnswer = kParticipant.publishToRoom(sdpType, kurentoOptions.sdpOffer, kurentoOptions.doLoopback, false);
|
sdpAnswer = kParticipant.publishToRoom(kurentoOptions.sdpOffer, kurentoOptions.doLoopback, false);
|
||||||
|
|
||||||
if (sdpAnswer == null) {
|
if (sdpAnswer == null) {
|
||||||
OpenViduException e = new OpenViduException(Code.MEDIA_SDP_ERROR_CODE,
|
OpenViduException e = new OpenViduException(Code.MEDIA_SDP_ERROR_CODE,
|
||||||
|
@ -580,8 +576,8 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
|
|
||||||
// Modify sdp if forced codec is defined
|
// Modify sdp if forced codec is defined
|
||||||
if (forcedVideoCodec != VideoCodec.NONE && !participant.isIpcam()) {
|
if (forcedVideoCodec != VideoCodec.NONE && !participant.isIpcam()) {
|
||||||
sdpOffer = sdpMunging.forceCodec(participant, sdpOffer, true, session, false, false,
|
sdpOffer = sdpMunging.forceCodec(participant, sdpOffer, session, false, false, isTranscodingAllowed,
|
||||||
isTranscodingAllowed, forcedVideoCodec);
|
forcedVideoCodec);
|
||||||
|
|
||||||
CDR.log(new WebrtcDebugEvent(participant, subscriberEndpointName, WebrtcDebugEventIssuer.client,
|
CDR.log(new WebrtcDebugEvent(participant, subscriberEndpointName, WebrtcDebugEventIssuer.client,
|
||||||
WebrtcDebugEventOperation.subscribe, WebrtcDebugEventType.sdpOfferMunged, sdpOffer));
|
WebrtcDebugEventOperation.subscribe, WebrtcDebugEventType.sdpOfferMunged, sdpOffer));
|
||||||
|
@ -788,8 +784,8 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
|
|
||||||
boolean doLoopback = RpcHandler.getBooleanParam(request, ProtocolElements.PUBLISHVIDEO_DOLOOPBACK_PARAM);
|
boolean doLoopback = RpcHandler.getBooleanParam(request, ProtocolElements.PUBLISHVIDEO_DOLOOPBACK_PARAM);
|
||||||
|
|
||||||
return new KurentoMediaOptions(true, sdpOffer, hasAudio, hasVideo, audioActive, videoActive, typeOfVideo,
|
return new KurentoMediaOptions(sdpOffer, hasAudio, hasVideo, audioActive, videoActive, typeOfVideo, frameRate,
|
||||||
frameRate, videoDimensions, kurentoFilter, doLoopback);
|
videoDimensions, kurentoFilter, doLoopback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1123,8 +1119,8 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
// Modify sdp if forced codec is defined
|
// Modify sdp if forced codec is defined
|
||||||
if (forcedVideoCodec != VideoCodec.NONE && !participant.isIpcam()) {
|
if (forcedVideoCodec != VideoCodec.NONE && !participant.isIpcam()) {
|
||||||
sdpOfferHasBeenMunged = true;
|
sdpOfferHasBeenMunged = true;
|
||||||
sdpOffer = sdpMunging.forceCodec(participant, sdpOffer, true, kSession, isPublisher, true,
|
sdpOffer = sdpMunging.forceCodec(participant, sdpOffer, kSession, isPublisher, true, isTranscodingAllowed,
|
||||||
isTranscodingAllowed, forcedVideoCodec);
|
forcedVideoCodec);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPublisher) {
|
if (isPublisher) {
|
||||||
|
@ -1151,8 +1147,7 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
// 3) Create a new PublisherEndpoint connecting it to the previous PassThrough
|
// 3) Create a new PublisherEndpoint connecting it to the previous PassThrough
|
||||||
kParticipant.resetPublisherEndpoint(kurentoOptions, passThru);
|
kParticipant.resetPublisherEndpoint(kurentoOptions, passThru);
|
||||||
kParticipant.createPublishingEndpoint(kurentoOptions, streamId);
|
kParticipant.createPublishingEndpoint(kurentoOptions, streamId);
|
||||||
SdpType sdpType = kurentoOptions.isOffer ? SdpType.OFFER : SdpType.ANSWER;
|
String sdpAnswer = kParticipant.publishToRoom(sdpOffer, kurentoOptions.doLoopback, true);
|
||||||
String sdpAnswer = kParticipant.publishToRoom(sdpType, sdpOffer, kurentoOptions.doLoopback, true);
|
|
||||||
log.debug("SDP Answer for publishing reconnection PARTICIPANT {}: {}", participant.getParticipantPublicId(),
|
log.debug("SDP Answer for publishing reconnection PARTICIPANT {}: {}", participant.getParticipantPublicId(),
|
||||||
sdpAnswer);
|
sdpAnswer);
|
||||||
|
|
||||||
|
|
|
@ -181,16 +181,14 @@ public class PublisherEndpoint extends MediaEndpoint {
|
||||||
* itself (after applying the intermediate media elements and the
|
* itself (after applying the intermediate media elements and the
|
||||||
* {@link PassThrough}) to allow loopback of the media stream.
|
* {@link PassThrough}) to allow loopback of the media stream.
|
||||||
*
|
*
|
||||||
* @param sdpType indicates the type of the sdpString (offer or
|
* @param sdpOffer offer from the remote peer
|
||||||
* answer)
|
|
||||||
* @param sdpString offer or answer from the remote peer
|
|
||||||
* @param doLoopback loopback flag
|
* @param doLoopback loopback flag
|
||||||
* @param loopbackAlternativeSrc alternative loopback source
|
* @param loopbackAlternativeSrc alternative loopback source
|
||||||
* @param loopbackConnectionType how to connect the loopback source
|
* @param loopbackConnectionType how to connect the loopback source
|
||||||
* @return the SDP response (the answer if processing an offer SDP, otherwise is
|
* @return the SDP response (the answer if processing an offer SDP, otherwise is
|
||||||
* the updated offer generated previously by this endpoint)
|
* the updated offer generated previously by this endpoint)
|
||||||
*/
|
*/
|
||||||
public synchronized String publish(SdpType sdpType, String sdpString, boolean doLoopback) {
|
public synchronized String publish(String sdpOffer, boolean doLoopback) {
|
||||||
registerOnIceCandidateEventListener(this.getOwner().getParticipantPublicId());
|
registerOnIceCandidateEventListener(this.getOwner().getParticipantPublicId());
|
||||||
if (doLoopback) {
|
if (doLoopback) {
|
||||||
connect(this.getEndpoint());
|
connect(this.getEndpoint());
|
||||||
|
@ -198,21 +196,7 @@ public class PublisherEndpoint extends MediaEndpoint {
|
||||||
innerConnect();
|
innerConnect();
|
||||||
}
|
}
|
||||||
this.createdAt = System.currentTimeMillis();
|
this.createdAt = System.currentTimeMillis();
|
||||||
String sdpResponse = null;
|
String sdpResponse = processOffer(sdpOffer);
|
||||||
switch (sdpType) {
|
|
||||||
case ANSWER:
|
|
||||||
|
|
||||||
/** THIS IS CURRENTLY NEVER CALLED **/
|
|
||||||
sdpResponse = processAnswer(sdpString);
|
|
||||||
/** THIS IS CURRENTLY NEVER CALLED **/
|
|
||||||
|
|
||||||
break;
|
|
||||||
case OFFER:
|
|
||||||
sdpResponse = processOffer(sdpString);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new OpenViduException(Code.MEDIA_SDP_ERROR_CODE, "Sdp type not supported: " + sdpType);
|
|
||||||
}
|
|
||||||
gatherCandidates();
|
gatherCandidates();
|
||||||
return sdpResponse;
|
return sdpResponse;
|
||||||
}
|
}
|
||||||
|
|
|
@ -686,8 +686,8 @@ public class SessionRestController {
|
||||||
String typeOfVideo = ConnectionType.IPCAM.name();
|
String typeOfVideo = ConnectionType.IPCAM.name();
|
||||||
Integer frameRate = null;
|
Integer frameRate = null;
|
||||||
String videoDimensions = null;
|
String videoDimensions = null;
|
||||||
KurentoMediaOptions mediaOptions = new KurentoMediaOptions(true, null, hasAudio, hasVideo, audioActive,
|
KurentoMediaOptions mediaOptions = new KurentoMediaOptions(null, hasAudio, hasVideo, audioActive, videoActive,
|
||||||
videoActive, typeOfVideo, frameRate, videoDimensions, null, false, connectionProperties.getRtspUri(),
|
typeOfVideo, frameRate, videoDimensions, null, false, connectionProperties.getRtspUri(),
|
||||||
connectionProperties.adaptativeBitrate(), connectionProperties.onlyPlayWithSubscribers(),
|
connectionProperties.adaptativeBitrate(), connectionProperties.onlyPlayWithSubscribers(),
|
||||||
connectionProperties.getNetworkCache());
|
connectionProperties.getNetworkCache());
|
||||||
|
|
||||||
|
|
|
@ -16,32 +16,34 @@
|
||||||
*/
|
*/
|
||||||
package io.openvidu.server.utils;
|
package io.openvidu.server.utils;
|
||||||
|
|
||||||
import io.openvidu.client.OpenViduException;
|
import java.util.ArrayList;
|
||||||
import io.openvidu.java.client.VideoCodec;
|
import java.util.Arrays;
|
||||||
import io.openvidu.client.OpenViduException.Code;
|
import java.util.HashSet;
|
||||||
import io.openvidu.server.core.Participant;
|
import java.util.List;
|
||||||
import io.openvidu.server.core.Session;
|
import java.util.Set;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.*;
|
import io.openvidu.client.OpenViduException;
|
||||||
import java.util.regex.Matcher;
|
import io.openvidu.client.OpenViduException.Code;
|
||||||
import java.util.regex.Pattern;
|
import io.openvidu.java.client.VideoCodec;
|
||||||
|
import io.openvidu.server.core.Participant;
|
||||||
|
import io.openvidu.server.core.Session;
|
||||||
|
|
||||||
public class SDPMunging {
|
public class SDPMunging {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SDPMunging.class);
|
private static final Logger log = LoggerFactory.getLogger(SDPMunging.class);
|
||||||
|
|
||||||
private Set<VideoCodec> supportedVideoCodecs = new HashSet<>(Arrays.asList(
|
private Set<VideoCodec> supportedVideoCodecs = new HashSet<>(Arrays.asList(VideoCodec.VP8, VideoCodec.H264));
|
||||||
VideoCodec.VP8,
|
|
||||||
VideoCodec.H264
|
|
||||||
));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `codec` is a uppercase SDP-style codec name: "VP8", "H264".
|
* `codec` is a uppercase SDP-style codec name: "VP8", "H264".
|
||||||
*
|
*
|
||||||
* This looks for all video m-sections (lines starting with "m=video"),
|
* This looks for all video m-sections (lines starting with "m=video"), then
|
||||||
* then searches all of its related PayloadTypes trying to find those which
|
* searches all of its related PayloadTypes trying to find those which
|
||||||
* correspond to the preferred codec. If any is found, they are moved to the
|
* correspond to the preferred codec. If any is found, they are moved to the
|
||||||
* front of the PayloadTypes list in the m= line, without removing the other
|
* front of the PayloadTypes list in the m= line, without removing the other
|
||||||
* codecs that might be present.
|
* codecs that might be present.
|
||||||
|
@ -52,10 +54,10 @@ public class SDPMunging {
|
||||||
* 6.1 "Unicast Streams" allows the answerer to list media formats in a
|
* 6.1 "Unicast Streams" allows the answerer to list media formats in a
|
||||||
* different order of preference from what it got in the offer:
|
* different order of preference from what it got in the offer:
|
||||||
*
|
*
|
||||||
* > Although the answerer MAY list the formats in their desired order of
|
* > Although the answerer MAY list the formats in their desired order of >
|
||||||
* > preference, it is RECOMMENDED that unless there is a specific reason,
|
* preference, it is RECOMMENDED that unless there is a specific reason, > the
|
||||||
* > the answerer list formats in the same relative order they were
|
* answerer list formats in the same relative order they were > present in the
|
||||||
* > present in the offer.
|
* offer.
|
||||||
*
|
*
|
||||||
* Here we have a specific reason, thus we use this allowance to change the
|
* Here we have a specific reason, thus we use this allowance to change the
|
||||||
* ordering of formats. Browsers (tested with Chrome 84) honor this change and
|
* ordering of formats. Browsers (tested with Chrome 84) honor this change and
|
||||||
|
@ -116,7 +118,8 @@ public class SDPMunging {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (codecPts.isEmpty()) {
|
if (codecPts.isEmpty()) {
|
||||||
throw new OpenViduException(Code.FORCED_CODEC_NOT_FOUND_IN_SDPOFFER, "The specified forced codec " + codecStr + " is not present in the SDP");
|
throw new OpenViduException(Code.FORCED_CODEC_NOT_FOUND_IN_SDPOFFER,
|
||||||
|
"The specified forced codec " + codecStr + " is not present in the SDP");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a new m= line where any PayloadTypes found have been moved
|
// Build a new m= line where any PayloadTypes found have been moved
|
||||||
|
@ -150,27 +153,31 @@ public class SDPMunging {
|
||||||
/**
|
/**
|
||||||
* Return a SDP modified to force a specific codec
|
* Return a SDP modified to force a specific codec
|
||||||
*/
|
*/
|
||||||
public String forceCodec(Participant participant, String sdp, boolean isOffer, Session session, boolean isPublisher,
|
public String forceCodec(Participant participant, String sdp, Session session, boolean isPublisher,
|
||||||
boolean isReconnecting, boolean isTranscodingAllowed, VideoCodec forcedVideoCodec) throws OpenViduException {
|
boolean isReconnecting, boolean isTranscodingAllowed, VideoCodec forcedVideoCodec)
|
||||||
|
throws OpenViduException {
|
||||||
try {
|
try {
|
||||||
if (supportedVideoCodecs.contains(forcedVideoCodec)) {
|
if (supportedVideoCodecs.contains(forcedVideoCodec)) {
|
||||||
String mungedSdpOffer;
|
String mungedSdpOffer;
|
||||||
|
|
||||||
log.debug("PARTICIPANT '{}' in Session '{}'. Is Publisher: '{}'. Is Subscriber: '{}'."
|
log.debug(
|
||||||
+ " Is Offer SDP: '{}'. Is Answer SDP: '{}'. Is Reconnecting '{}'."
|
"PARTICIPANT '{}' in Session '{}'. Is Publisher: '{}'. Is Subscriber: '{}'. Is Reconnecting '{}'."
|
||||||
+ " SDP before munging: \n {}", participant.getParticipantPublicId(),
|
+ " SDP before munging: \n {}",
|
||||||
session.getSessionId(), isPublisher, !isPublisher, isOffer, !isOffer, isReconnecting, sdp);
|
participant.getParticipantPublicId(), session.getSessionId(), isPublisher, !isPublisher,
|
||||||
|
isReconnecting, sdp);
|
||||||
|
|
||||||
mungedSdpOffer = this.setCodecPreference(forcedVideoCodec, sdp);
|
mungedSdpOffer = this.setCodecPreference(forcedVideoCodec, sdp);
|
||||||
|
|
||||||
log.debug("PARTICIPANT '{}' in Session '{}'. Is Publisher: '{}'. Is Subscriber: '{}'."
|
log.debug(
|
||||||
+ " Is Offer SDP: '{}'. Is Answer SDP: '{}'. Is Reconnecting '{}'."
|
"PARTICIPANT '{}' in Session '{}'. Is Publisher: '{}'. Is Subscriber: '{}'."
|
||||||
+ " SDP after munging: \n {}", participant.getParticipantPublicId(),
|
+ " Is Reconnecting '{}'." + " SDP after munging: \n {}",
|
||||||
session.getSessionId(), isPublisher, !isPublisher, isOffer, !isOffer, isReconnecting, mungedSdpOffer);
|
participant.getParticipantPublicId(), session.getSessionId(), isPublisher, !isPublisher,
|
||||||
|
isReconnecting, mungedSdpOffer);
|
||||||
|
|
||||||
return mungedSdpOffer;
|
return mungedSdpOffer;
|
||||||
} else {
|
} else {
|
||||||
throw new OpenViduException(Code.FORCED_CODEC_NOT_FOUND_IN_SDPOFFER, "Codec not supported by Media Server");
|
throw new OpenViduException(Code.FORCED_CODEC_NOT_FOUND_IN_SDPOFFER,
|
||||||
|
"Codec not supported by Media Server");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (OpenViduException e) {
|
} catch (OpenViduException e) {
|
||||||
|
@ -178,17 +185,17 @@ public class SDPMunging {
|
||||||
String errorMessage = "Error forcing codec: '" + forcedVideoCodec + "', for PARTICIPANT: '"
|
String errorMessage = "Error forcing codec: '" + forcedVideoCodec + "', for PARTICIPANT: '"
|
||||||
+ participant.getParticipantPublicId() + "' in Session: '" + session.getSessionId()
|
+ participant.getParticipantPublicId() + "' in Session: '" + session.getSessionId()
|
||||||
+ "'. Is publishing: '" + isPublisher + "'. Is Subscriber: '" + !isPublisher
|
+ "'. Is publishing: '" + isPublisher + "'. Is Subscriber: '" + !isPublisher
|
||||||
+ "'. Is Offer: '" + isOffer + "'. Is Answer: '" + !isOffer + "'. Is Reconnecting: '"
|
+ "'. Is Reconnecting: '" + isReconnecting + "'.\nException: " + e.getMessage() + "\nSDP:\n" + sdp;
|
||||||
+ isReconnecting + "'.\nException: " + e.getMessage() + "\nSDP:\n" + sdp;
|
|
||||||
|
|
||||||
if(!isTranscodingAllowed) {
|
if (!isTranscodingAllowed) {
|
||||||
throw new OpenViduException(Code.FORCED_CODEC_NOT_FOUND_IN_SDPOFFER, errorMessage);
|
throw new OpenViduException(Code.FORCED_CODEC_NOT_FOUND_IN_SDPOFFER, errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("Codec: '{}' is not supported for PARTICIPANT: '{}' in Session: '{}'. Is publishing: '{}'. "
|
log.info(
|
||||||
+ "Is Subscriber: '{}' Is Offer SDP: '{}'. Is Answer SDP: '{}'. Is Reconnecting: '{}'."
|
"Codec: '{}' is not supported for PARTICIPANT: '{}' in Session: '{}'. Is publishing: '{}'. "
|
||||||
+ " Transcoding will be allowed", forcedVideoCodec, participant.getParticipantPublicId(),
|
+ "Is Subscriber: '{}'. Is Reconnecting: '{}'." + " Transcoding will be allowed",
|
||||||
session.getSessionId(), isPublisher, !isPublisher, isOffer, !isOffer, isReconnecting);
|
forcedVideoCodec, participant.getParticipantPublicId(), session.getSessionId(), isPublisher,
|
||||||
|
!isPublisher, isReconnecting);
|
||||||
|
|
||||||
return sdp;
|
return sdp;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue