Force coding working in all browsers

pull/600/head
cruizba 2020-09-11 17:49:41 +02:00
parent d7f0d4bdf8
commit 2f26431afe
3 changed files with 11 additions and 10 deletions

View File

@ -380,7 +380,7 @@ public class KurentoSessionManager extends SessionManager {
if (forcedVideoCodec != VideoCodec.NONE && !participant.isIpcam()) {
String sdpOffer = kurentoOptions.sdpOffer;
try {
kurentoOptions.sdpOffer = this.sdpMunging.setCodecPreference(forcedVideoCodec, sdpOffer);
kurentoOptions.sdpOffer = this.sdpMunging.setCodecPreference(forcedVideoCodec, sdpOffer, true);
log.debug("PARTICIPANT '{}' in Session '{}' publishing SDP Offer after munging: \n {}",
participant.getParticipantPublicId(), kSession.getSessionId(), kurentoOptions.sdpOffer);
} catch (OpenViduException e) {
@ -571,7 +571,7 @@ public class KurentoSessionManager extends SessionManager {
try {
log.debug("PARTICIPANT '{}' in Session '{}' SDP Offer before munging: \n {}",
participant.getParticipantPublicId(), session.getSessionId(), sdpOffer);
sdpOffer = this.sdpMunging.setCodecPreference(forcedVideoCodec, sdpOffer);
sdpOffer = this.sdpMunging.setCodecPreference(forcedVideoCodec, sdpOffer, false);
if (forcedVideoCodec == VideoCodec.H264) {
sdpOffer = this.sdpMunging.setfmtpH264(sdpOffer);
}
@ -622,7 +622,7 @@ public class KurentoSessionManager extends SessionManager {
// Modify sdp if forced codec is defined
if (forcedVideoCodec != VideoCodec.NONE) {
try {
sdpAnswer = this.sdpMunging.setCodecPreference(forcedVideoCodec, sdpAnswer);
sdpAnswer = this.sdpMunging.setCodecPreference(forcedVideoCodec, sdpAnswer, true);
log.debug("PARTICIPANT '{}' subscribing in Session '{}' SDP Answer after munging: \n {}",
participant.getParticipantPublicId(), session.getSessionId(), sdpAnswer);
} catch (OpenViduException e) {
@ -1178,7 +1178,7 @@ public class KurentoSessionManager extends SessionManager {
// Modify sdp if forced codec is defined
if (forcedVideoCodec != VideoCodec.NONE) {
try {
sdpString = sdpMunging.setCodecPreference(forcedVideoCodec, sdpString);
sdpString = sdpMunging.setCodecPreference(forcedVideoCodec, sdpString, true);
log.debug("PARTICIPANT '{}' in Session '{}' reconnecting SDP after munging: \n {}",
participant.getParticipantPublicId(), kSession.getSessionId(), sdpString);
} catch (OpenViduException e) {

View File

@ -42,7 +42,7 @@ public class SDPMunging {
* ordering of formats. Browsers (tested with Chrome 84) honor this change and
* use the first codec provided in the answer, so this operation actually works.
*/
public String setCodecPreference(VideoCodec codec, String sdp) throws OpenViduException {
public String setCodecPreference(VideoCodec codec, String sdp, boolean removeCodecs) throws OpenViduException {
String codecStr = codec.name();
log.info("[setCodecPreference] codec: {}", codecStr);
@ -121,11 +121,12 @@ public class SDPMunging {
newLine.append(pt + " ");
}
// Add the rest of PayloadTypes.
newLine.append(String.join(" ", lineParts));
// Replace the original m= line with the one we just built.
lines[sl] = newLine.toString();
if (!removeCodecs) {
// Add the rest of PayloadTypes.
newLine.append(String.join(" ", lineParts));
}
lines[sl] = newLine.toString().trim();
}
return String.join("\r\n", lines) + "\r\n";

View File

@ -149,7 +149,7 @@ public class SDPMungingTest {
private void initTestsSetCodecPrevalence(VideoCodec codec, String sdpNameFile) throws IOException {
this.oldSdp = getSdpFile(sdpNameFile);
this.newSdp = this.sdpMungin.setCodecPreference(codec, oldSdp);
this.newSdp = this.sdpMungin.setCodecPreference(codec, oldSdp, true);
this.forceCodecPayloads = new ArrayList<>();
// Get all Payload-Type for video Codec