From 1c2d735b3d62e519b3be094b9ad0149e544d0505 Mon Sep 17 00:00:00 2001 From: Nathan Oehlman Date: Mon, 29 Feb 2016 15:44:53 +1000 Subject: [PATCH] Uses the Jitsi sdp-interop module for interop. Requires the changes in https://github.com/jitsi/sdp-interop/compare/issue-13 --- index.js | 21 +++++++++++++++++---- package.json | 3 ++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 6312e64..d09cc48 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ var detect = require('rtc-core/detect'); var findPlugin = require('rtc-core/plugin'); var PriorityQueue = require('priorityqueuejs'); var Promise = require('es6-promise').Promise; +var Interop = require('sdp-interop').Interop; var pluck = require('whisk/pluck'); var pluckSessionDesc = pluck('sdp', 'type'); @@ -89,6 +90,8 @@ module.exports = function(pc, opts) { var RTCIceCandidate = (opts || {}).RTCIceCandidate || detect('RTCIceCandidate'); + var interop = navigator.mozGetUserMedia && new Interop(); + // Determine plugin overridable methods var createIceCandidate = pluggable(plugin && plugin.createIceCandidate, function(data) { return new RTCIceCandidate(data); @@ -199,6 +202,16 @@ module.exports = function(pc, opts) { return desc; } + function prepareDescription(desc) { + if (!interop || !desc || !desc.sdp) return desc; + return interop.toUnifiedPlan(desc); + } + + function setLocalDescription(desc) { + if (interop) desc = interop.toPlanB(desc); + tq.setLocalDescription(desc); + } + function completeConnection() { // Clean any cached media types now that we have potentially new remote description if (pc.__mediaIDs || pc.__mediaTypes) { @@ -445,22 +458,22 @@ module.exports = function(pc, opts) { }); tq.setLocalDescription = enqueue('setLocalDescription', execMethod, { - processArgs: cleansdp, + processArgs: cleansdp, prepareDescription, pass: emitSdp }); tq.setRemoteDescription = enqueue('setRemoteDescription', execMethod, { - processArgs: createSessionDescription, + processArgs: createSessionDescription, prepareDescription, pass: completeConnection }); tq.createOffer = enqueue('createOffer', execMethod, { checks: [ isNotNegotiating ], - pass: tq.setLocalDescription + pass: setLocalDescription }); tq.createAnswer = enqueue('createAnswer', execMethod, { - pass: tq.setLocalDescription + pass: setLocalDescription }); return tq; diff --git a/package.json b/package.json index 61192e6..55ee941 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "rtc-sdp": "^1.2.0", "rtc-sdpclean": "^1.0.0", "rtc-validator": "^1.0.0", + "sdp-interop": "^0.1.11", "whisk": "^1.1.0" }, "devDependencies": { @@ -51,4 +52,4 @@ "testling": { "files": "test/all.js" } -} \ No newline at end of file +}