Skip to content

Commit

Permalink
Fix Firefox SDP negotiation and Simulcast (#1589)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcague committed May 27, 2020
1 parent 9dc4525 commit 5d57b23
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
13 changes: 7 additions & 6 deletions erizo_controller/erizoClient/src/webrtc-stacks/BaseStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ const BaseStack = (specInput) => {
const numberOfRemoteMedias = that.remoteSdp.getStreams().size;
const numberOfLocalMedias = localSdp.getStreams().size;

let direction = Direction.reverse('sendrecv');
let direction = Direction.SENDRECV;
if (numberOfRemoteMedias > 0 && numberOfLocalMedias > 0) {
direction = Direction.reverse('sendrecv');
direction = Direction.SENDRECV;
} else if (numberOfRemoteMedias > 0 && numberOfLocalMedias === 0) {
direction = Direction.reverse('recvonly');
direction = Direction.RECVONLY;
} else if (numberOfRemoteMedias === 0 && numberOfLocalMedias > 0) {
direction = Direction.reverse('sendonly');
direction = Direction.SENDONLY;
} else {
direction = Direction.reverse('inactive');
direction = Direction.INACTIVE;
}
localSdp.getMedias().forEach((media) => {
media.setDirection(direction);
Expand Down Expand Up @@ -301,7 +301,8 @@ const BaseStack = (specInput) => {
negotiationQueue.startEnqueuing();
logSDP('Creating offer', that.mediaConstraints);
const rejectMessages = [];
return that.peerConnection.createOffer(that.mediaConstraints)
return that.prepareCreateOffer(isSubscribe)
.then(() => that.peerConnection.createOffer(that.mediaConstraints))
.then(setLocalDescForOffer.bind(null, isSubscribe))
.catch((error) => {
rejectMessages.push(`in protectedCreateOffer-createOffer, error: ${error}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ const ChromeStableStack = (specInput) => {
});
};

that.prepareCreateOffer = () => Promise.resolve();

that.setSimulcastLayersBitrate = () => {
Logger.debug('Maybe set simulcast Layers bitrate', that.simulcast);
if (that.simulcast && that.simulcast.spatialLayerBitrates) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,12 @@ const FirefoxStack = (specInput) => {

that.enableSimulcast = sdp => sdp;

const baseCreateOffer = that.createOffer;

that.createOffer = (isSubscribe, forceOfferToReceive = false, streamId = '') => {
that.prepareCreateOffer = (isSubscribe = false) => {
let promises = [];
if (isSubscribe !== true) {
promises = enableSimulcast();
}
Promise.all(promises).then(() => {
baseCreateOffer(isSubscribe, forceOfferToReceive, streamId);
});
return Promise.all(promises);
};

return that;
Expand Down
2 changes: 1 addition & 1 deletion erizo_controller/erizoJS/models/SessionDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function getMediaInfoFromDescription(info, sdp, mediaType) {
});

if (isSimulcast) {
simulcast.setSimulcastPlainString(`${ridDirection} rid=${ridsData.join(';')}`);
simulcast.setSimulcastPlainString(`${ridDirection} ${ridsData.join(';')}`);
media.simulcast_03 = simulcast;
}
if (info.getXGoogleFlag() && info.getXGoogleFlag() !== '') {
Expand Down
4 changes: 1 addition & 3 deletions extras/basic_example/public/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ const startBasicExample = () => {
video: !audioOnly,
data: true,
screen,
attributes: {},
videoSize: [640, 480, 640, 480],
videoFrameRate: [10, 20] };
attributes: {} };
// If we want screen sharing we have to put our Chrome extension id.
// The default one only works in our Lynckia test servers.
// If we are not using chrome, the creation of the stream will fail regardless.
Expand Down

0 comments on commit 5d57b23

Please sign in to comment.