Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Some additional error handling.

yanasd92d8e8299af
diff --git a/css/videolayout_default.css b/css/videolayout_default.css
index 0d80ed21dc..f7375007a8 100644
--- a/css/videolayout_default.css
+++ b/css/videolayout_default.css
@@ -446,3 +446,24 @@
background-position: center;
}
+.videoProblemFilter {
+ -webkit-filter: blur(10px) grayscale(.5) opacity(0.8);
+ filter: blur(10px) grayscale(.5) opacity(0.8);
+}
+
+#videoConnectionMessage {
+ display: none;
+ position: absolute;
+ width: 100%;
+ top:50%;
+ z-index: 10000;
+ font-weight: 600;
+ font-size: 14px;
+ text-align: center;
+ color: #FFF;
+ opacity: .80;
+ text-shadow: 0px 0px 1px rgba(0,0,0,0.3),
+ 0px 1px 1px rgba(0,0,0,0.3),
+ 1px 0px 1px rgba(0,0,0,0.3),
+ 0px 0px 1px rgba(0,0,0,0.3);
+}
\ No newline at end of file
diff --git a/index.html b/index.html
index 110e4812f2..196aff39fd 100644
--- a/index.html
+++ b/index.html
@@ -13,7 +13,7 @@
<script src="libs/jquery-2.1.1.min.js"></script>
<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsSHA/1.5.0/sha.js"></script>
- <script src="config.js?v=11"></script><!-- adapt to your needs, i.e. set hosts and bosh path -->
+ <script src="config.js?v=12"></script><!-- adapt to your needs, i.e. set hosts and bosh path -->
<script src="libs/strophe/strophe.min.js?v=2"></script>
<script src="libs/strophe/strophe.disco.min.js?v=1"></script>
<script src="libs/strophe/strophe.caps.jsonly.min.js?v=1"></script>
@@ -22,12 +22,12 @@
<script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
<script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
<script src="interface_config.js?v=5"></script>
- <script src="libs/app.bundle.js?v=116"></script>
+ <script src="libs/app.bundle.js?v=117"></script>
<script src="analytics.js?v=1"></script><!-- google analytics plugin -->
<link rel="stylesheet" href="css/font.css?v=7"/>
<link rel="stylesheet" href="css/toastr.css?v=1">
<link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=30"/>
- <link rel="stylesheet" type="text/css" media="screen" href="css/videolayout_default.css?v=18" id="videolayout_default"/>
+ <link rel="stylesheet" type="text/css" media="screen" href="css/videolayout_default.css?v=19" id="videolayout_default"/>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-impromptu.css?v=4">
<link rel="stylesheet" href="css/modaldialog.css?v=3">
diff --git a/lang/main.json b/lang/main.json
index 6548cd7634..acab49f08e 100644
--- a/lang/main.json
+++ b/lang/main.json
@@ -229,6 +229,7 @@
{
"ERROR": "Error",
"CONNECTING": "Connecting",
+ "RECONNECTING": "A network problem occurred. Reconnecting...",
"CONNFAIL": "Connection failed",
"AUTHENTICATING": "Authenticating",
"AUTHFAIL": "Authentication failed",
diff --git a/libs/app.bundle.js b/libs/app.bundle.js
index c52afc7b7a..98dcc0be0a 100644
--- a/libs/app.bundle.js
+++ b/libs/app.bundle.js
@@ -275,7 +275,7 @@ var API = {
};
module.exports = API;
-},{"../../service/xmpp/XMPPEvents":108}],3:[function(require,module,exports){
+},{"../../service/xmpp/XMPPEvents":116}],3:[function(require,module,exports){
/* global APP */
/**
@@ -517,7 +517,7 @@ function onPinnedEndpointChanged(userResource) {
module.exports = DataChannels;
-},{"../../service/RTC/RTCEvents":99}],5:[function(require,module,exports){
+},{"../../service/RTC/RTCEvents":107}],5:[function(require,module,exports){
/* global APP */
var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
var RTCEvents = require("../../service/RTC/RTCEvents");
@@ -620,7 +620,7 @@ LocalStream.prototype.getId = function () {
module.exports = LocalStream;
-},{"../../service/RTC/RTCEvents":99,"../../service/RTC/StreamEventTypes.js":101}],6:[function(require,module,exports){
+},{"../../service/RTC/RTCEvents":107,"../../service/RTC/StreamEventTypes.js":109}],6:[function(require,module,exports){
var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
/**
@@ -669,7 +669,7 @@ MediaStream.prototype.setMute = function (value) {
module.exports = MediaStream;
-},{"../../service/RTC/MediaStreamTypes":98}],7:[function(require,module,exports){
+},{"../../service/RTC/MediaStreamTypes":106}],7:[function(require,module,exports){
/* global APP */
var EventEmitter = require("events");
var RTCBrowserType = require("./RTCBrowserType");
@@ -972,7 +972,7 @@ var RTC = {
module.exports = RTC;
-},{"../../service/RTC/MediaStreamTypes":98,"../../service/RTC/RTCEvents.js":99,"../../service/RTC/StreamEventTypes.js":101,"../../service/UI/UIEvents":102,"../../service/desktopsharing/DesktopSharingEventTypes":105,"../../service/xmpp/XMPPEvents":108,"./DataChannels":4,"./LocalStream.js":5,"./MediaStream.js":6,"./RTCBrowserType":8,"./RTCUtils.js":9,"events":109}],8:[function(require,module,exports){
+},{"../../service/RTC/MediaStreamTypes":106,"../../service/RTC/RTCEvents.js":107,"../../service/RTC/StreamEventTypes.js":109,"../../service/UI/UIEvents":110,"../../service/desktopsharing/DesktopSharingEventTypes":113,"../../service/xmpp/XMPPEvents":116,"./DataChannels":4,"./LocalStream.js":5,"./MediaStream.js":6,"./RTCBrowserType":8,"./RTCUtils.js":9,"events":117}],8:[function(require,module,exports){
var currentBrowser;
@@ -1704,7 +1704,7 @@ RTCUtils.prototype.createStream = function(stream, isVideo) {
module.exports = RTCUtils;
-},{"../../service/RTC/Resolutions":100,"../xmpp/SDPUtil":56,"./RTCBrowserType":8,"./adapter.screenshare":10}],10:[function(require,module,exports){
+},{"../../service/RTC/Resolutions":108,"../xmpp/SDPUtil":56,"./RTCBrowserType":8,"./adapter.screenshare":10}],10:[function(require,module,exports){
/*! adapterjs - v0.11.0 - 2015-06-08 */
// Adapter's interface.
@@ -3351,6 +3351,9 @@ function registerListeners() {
UI.addListener(UIEvents.LARGEVIDEO_INIT, function () {
AudioLevels.init();
});
+
+ APP.xmpp.addListener(XMPPEvents.CONNECTION_INTERRUPTED, VideoLayout.onVideoInterrupted);
+ APP.xmpp.addListener(XMPPEvents.CONNECTION_RESTORED, VideoLayout.onVideoRestored);
}
@@ -3877,7 +3880,7 @@ UI.setVideoMute = setVideoMute;
module.exports = UI;
-},{"../../service/RTC/RTCEvents":99,"../../service/RTC/StreamEventTypes":101,"../../service/UI/UIEvents":102,"../../service/connectionquality/CQEvents":104,"../../service/desktopsharing/DesktopSharingEventTypes":105,"../../service/members/Events":106,"../../service/xmpp/XMPPEvents":108,"../RTC/RTCBrowserType":8,"./../settings/Settings":47,"./audio_levels/AudioLevels.js":12,"./authentication/Authentication":14,"./avatar/Avatar":16,"./etherpad/Etherpad.js":17,"./prezi/Prezi.js":18,"./side_pannels/SidePanelToggler":20,"./side_pannels/chat/Chat.js":21,"./side_pannels/contactlist/ContactList":25,"./side_pannels/settings/SettingsMenu":26,"./toolbars/BottomToolbar":27,"./toolbars/Toolbar":28,"./toolbars/ToolbarToggler":29,"./util/MessageHandler":31,"./util/NicknameHandler":32,"./util/UIUtil":33,"./videolayout/VideoLayout.js":39,"./welcome_page/RoomnameGenerator":40,"./welcome_page/WelcomePage":41,"events":109}],12:[function(require,module,exports){
+},{"../../service/RTC/RTCEvents":107,"../../service/RTC/StreamEventTypes":109,"../../service/UI/UIEvents":110,"../../service/connectionquality/CQEvents":112,"../../service/desktopsharing/DesktopSharingEventTypes":113,"../../service/members/Events":114,"../../service/xmpp/XMPPEvents":116,"../RTC/RTCBrowserType":8,"./../settings/Settings":47,"./audio_levels/AudioLevels.js":12,"./authentication/Authentication":14,"./avatar/Avatar":16,"./etherpad/Etherpad.js":17,"./prezi/Prezi.js":18,"./side_pannels/SidePanelToggler":20,"./side_pannels/chat/Chat.js":21,"./side_pannels/contactlist/ContactList":25,"./side_pannels/settings/SettingsMenu":26,"./toolbars/BottomToolbar":27,"./toolbars/Toolbar":28,"./toolbars/ToolbarToggler":29,"./util/MessageHandler":31,"./util/NicknameHandler":32,"./util/UIUtil":33,"./videolayout/VideoLayout.js":39,"./welcome_page/RoomnameGenerator":40,"./welcome_page/WelcomePage":41,"events":117}],12:[function(require,module,exports){
/* global APP, interfaceConfig, $, Strophe */
var CanvasUtil = require("./CanvasUtils");
@@ -5976,7 +5979,7 @@ var Chat = (function (my) {
return my;
}(Chat || {}));
module.exports = Chat;
-},{"../../../../service/UI/UIEvents":102,"../../toolbars/ToolbarToggler":29,"../../util/NicknameHandler":32,"../../util/UIUtil":33,"../SidePanelToggler":20,"./Commands":22,"./Replacement":23,"./smileys.json":24}],22:[function(require,module,exports){
+},{"../../../../service/UI/UIEvents":110,"../../toolbars/ToolbarToggler":29,"../../util/NicknameHandler":32,"../../util/UIUtil":33,"../SidePanelToggler":20,"./Commands":22,"./Replacement":23,"./smileys.json":24}],22:[function(require,module,exports){
/* global APP, require */
var UIUtil = require("../../util/UIUtil");
@@ -6481,7 +6484,7 @@ var SettingsMenu = {
module.exports = SettingsMenu;
-},{"../../../../service/translation/languages":107,"../../avatar/Avatar":16,"../../util/UIUtil":33,"./../../../settings/Settings":47}],27:[function(require,module,exports){
+},{"../../../../service/translation/languages":115,"../../avatar/Avatar":16,"../../util/UIUtil":33,"./../../../settings/Settings":47}],27:[function(require,module,exports){
/* global $ */
var PanelToggler = require("../side_pannels/SidePanelToggler");
@@ -7163,7 +7166,7 @@ var Toolbar = (function (my) {
}(Toolbar || {}));
module.exports = Toolbar;
-},{"../../../service/authentication/AuthenticationEvents":103,"../authentication/Authentication":14,"../etherpad/Etherpad":17,"../prezi/Prezi":18,"../side_pannels/SidePanelToggler":20,"../util/MessageHandler":31,"../util/UIUtil":33,"./BottomToolbar":27}],29:[function(require,module,exports){
+},{"../../../service/authentication/AuthenticationEvents":111,"../authentication/Authentication":14,"../etherpad/Etherpad":17,"../prezi/Prezi":18,"../side_pannels/SidePanelToggler":20,"../util/MessageHandler":31,"../util/UIUtil":33,"./BottomToolbar":27}],29:[function(require,module,exports){
/* global APP, config, $, interfaceConfig, Moderator,
DesktopStreaming.showDesktopSharingButton */
@@ -7639,7 +7642,7 @@ var NicknameHandler = {
};
module.exports = NicknameHandler;
-},{"../../../service/UI/UIEvents":102}],33:[function(require,module,exports){
+},{"../../../service/UI/UIEvents":110}],33:[function(require,module,exports){
/* global $ */
/**
* Created by hristo on 12/22/14.
@@ -8396,7 +8399,8 @@ function createLargeVideoHTML()
'<img id="activeSpeakerAvatar" src=""/>' +
'<canvas id="activeSpeakerAudioLevel"></canvas>' +
'</div>' +
- '<video id="largeVideo" autoplay oncontextmenu="return false;"></video>';
+ '<video id="largeVideo" autoplay oncontextmenu="return false;"></video>' +
+ '<span id="videoConnectionMessage"></span>';
html += '</div>';
$(html).prependTo("#videospace");
@@ -8768,12 +8772,15 @@ var LargeVideo = {
setHover: function(inHandler, outHandler)
{
$('#largeVideoContainer').hover(inHandler, outHandler);
+ },
+
+ enableVideoProblemFilter: function (enable) {
+ $("#largeVideo").toggleClass("videoProblemFilter", enable);
}
};
-
module.exports = LargeVideo;
-},{"../../../service/UI/UIEvents":102,"../../RTC/RTCBrowserType":8,"../../xmpp/xmpp":66,"../avatar/Avatar":16,"../toolbars/ToolbarToggler":29,"../util/UIUtil":33}],36:[function(require,module,exports){
+},{"../../../service/UI/UIEvents":110,"../../RTC/RTCBrowserType":8,"../../xmpp/xmpp":66,"../avatar/Avatar":16,"../toolbars/ToolbarToggler":29,"../util/UIUtil":33}],36:[function(require,module,exports){
/* global $, interfaceConfig, APP */
var SmallVideo = require("./SmallVideo");
var ConnectionIndicator = require("./ConnectionIndicator");
@@ -10670,11 +10677,24 @@ var VideoLayout = (function (my) {
LargeVideo.setHover(inHandler, outHandler);
};
+ my.onVideoInterrupted = function () {
+ LargeVideo.enableVideoProblemFilter(true);
+ var reconnectingKey = "connection.RECONNECTING";
+ $('#videoConnectionMessage').attr("data-i18n", reconnectingKey);
+ $('#videoConnectionMessage').text(APP.translation.translateString(reconnectingKey));
+ $('#videoConnectionMessage').css({display: "block"});
+ };
+
+ my.onVideoRestored = function () {
+ LargeVideo.enableVideoProblemFilter(false);
+ $('#videoConnectionMessage').css({display: "none"});
+ };
+
return my;
}(VideoLayout || {}));
module.exports = VideoLayout;
-},{"../../../service/RTC/MediaStreamTypes":98,"../../../service/UI/UIEvents":102,"../../RTC/RTC":7,"../../RTC/RTCBrowserType":8,"../audio_levels/AudioLevels":12,"../prezi/Prezi":18,"../side_pannels/contactlist/ContactList":25,"./LargeVideo":35,"./LocalVideo":36,"./RemoteVideo":37}],40:[function(require,module,exports){
+},{"../../../service/RTC/MediaStreamTypes":106,"../../../service/UI/UIEvents":110,"../../RTC/RTC":7,"../../RTC/RTCBrowserType":8,"../audio_levels/AudioLevels":12,"../prezi/Prezi":18,"../side_pannels/contactlist/ContactList":25,"./LargeVideo":35,"./LocalVideo":36,"./RemoteVideo":37}],40:[function(require,module,exports){
//var nouns = [
//];
var pluralNouns = [
@@ -11129,7 +11149,7 @@ var ConnectionQuality = {
};
module.exports = ConnectionQuality;
-},{"../../service/connectionquality/CQEvents":104,"../../service/xmpp/XMPPEvents":108,"events":109}],44:[function(require,module,exports){
+},{"../../service/connectionquality/CQEvents":112,"../../service/xmpp/XMPPEvents":116,"events":117}],44:[function(require,module,exports){
/* global $, alert, APP, changeLocalVideo, chrome, config, getConferenceHandler,
getUserMediaWithConstraints */
/**
@@ -11518,7 +11538,7 @@ module.exports = {
};
-},{"../../service/RTC/RTCEvents":99,"../../service/desktopsharing/DesktopSharingEventTypes":105,"../RTC/RTCBrowserType":8,"../RTC/adapter.screenshare":10,"events":109}],45:[function(require,module,exports){
+},{"../../service/RTC/RTCEvents":107,"../../service/desktopsharing/DesktopSharingEventTypes":113,"../RTC/RTCBrowserType":8,"../RTC/adapter.screenshare":10,"events":117}],45:[function(require,module,exports){
/* global APP, $ */
//maps keycode to character, id of popover for given function and function
var shortcuts = {};
@@ -11746,7 +11766,7 @@ var Members = {
module.exports = Members;
-},{"../../service/members/Events":106,"../../service/xmpp/XMPPEvents":108,"events":109}],47:[function(require,module,exports){
+},{"../../service/members/Events":114,"../../service/xmpp/XMPPEvents":116,"events":117}],47:[function(require,module,exports){
var email = '';
var displayName = '';
var userId;
@@ -12894,7 +12914,7 @@ var statistics = {
module.exports = statistics;
-},{"../../service/RTC/RTCEvents":99,"../../service/RTC/StreamEventTypes.js":101,"../../service/xmpp/XMPPEvents":108,"./CallStats":48,"./LocalStatsCollector.js":49,"./RTPStatsCollector.js":50,"events":109}],52:[function(require,module,exports){
+},{"../../service/RTC/RTCEvents":107,"../../service/RTC/StreamEventTypes.js":109,"../../service/xmpp/XMPPEvents":116,"./CallStats":48,"./LocalStatsCollector.js":49,"./RTPStatsCollector.js":50,"events":117}],52:[function(require,module,exports){
/* global $, require, config, interfaceConfig */
var i18n = require("i18next-client");
var languages = require("../../service/translation/languages");
@@ -13032,7 +13052,7 @@ module.exports = {
}
};
-},{"../../service/translation/languages":107,"../settings/Settings":47,"i18next-client":68}],53:[function(require,module,exports){
+},{"../../service/translation/languages":115,"../settings/Settings":47,"i18next-client":68}],53:[function(require,module,exports){
/* jshint -W117 */
var TraceablePeerConnection = require("./TraceablePeerConnection");
var SDPDiffer = require("./SDPDiffer");
@@ -13125,6 +13145,7 @@ JingleSession.prototype.initiate = function (peerjid, isInitiator) {
this.hadstuncandidate = false;
this.hadturncandidate = false;
this.lasticecandidate = false;
+ this.isreconnect = false;
this.peerconnection
= new TraceablePeerConnection(
@@ -13162,9 +13183,17 @@ JingleSession.prototype.initiate = function (peerjid, isInitiator) {
switch (self.peerconnection.iceConnectionState) {
case 'connected':
this.startTime = new Date();
+
+ if (this.peerconnection.signalingState === 'stable' && this.isreconnect)
+ self.eventEmitter.emit(XMPPEvents.CONNECTION_RESTORED);
+ this.isreconnect = false;
+
break;
case 'disconnected':
+ this.isreconnect = true;
this.stopTime = new Date();
+ if (this.peerconnection.signalingState === 'stable')
+ self.eventEmitter.emit(XMPPEvents.CONNECTION_INTERRUPTED);
break;
case 'failed':
self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
@@ -14461,7 +14490,7 @@ JingleSession.prototype.remoteStreamAdded = function (data, times) {
module.exports = JingleSession;
-},{"../../service/xmpp/XMPPEvents":108,"../RTC/RTCBrowserType":8,"./SDP":54,"./SDPDiffer":55,"./SDPUtil":56,"./TraceablePeerConnection":57,"async":67,"sdp-transform":95}],54:[function(require,module,exports){
+},{"../../service/xmpp/XMPPEvents":116,"../RTC/RTCBrowserType":8,"./SDP":54,"./SDPDiffer":55,"./SDPUtil":56,"./TraceablePeerConnection":57,"async":67,"sdp-transform":103}],54:[function(require,module,exports){
/* jshint -W117 */
var SDPUtil = require("./SDPUtil");
@@ -16073,7 +16102,7 @@ TraceablePeerConnection.prototype.getStats = function(callback, errback) {
module.exports = TraceablePeerConnection;
-},{"../../service/xmpp/XMPPEvents":108,"../RTC/RTC":7,"../RTC/RTCBrowserType.js":8,"sdp-interop":89,"sdp-simulcast":92,"sdp-transform":95}],58:[function(require,module,exports){
+},{"../../service/xmpp/XMPPEvents":116,"../RTC/RTC":7,"../RTC/RTCBrowserType.js":8,"sdp-interop":89,"sdp-simulcast":96,"sdp-transform":103}],58:[function(require,module,exports){
/* global $, $iq, APP, config, messageHandler,
roomName, sessionTerminated, Strophe, Util */
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
@@ -16506,7 +16535,7 @@ module.exports = Moderator;
-},{"../../service/authentication/AuthenticationEvents":103,"../../service/xmpp/XMPPEvents":108,"../settings/Settings":47}],59:[function(require,module,exports){
+},{"../../service/authentication/AuthenticationEvents":111,"../../service/xmpp/XMPPEvents":116,"../settings/Settings":47}],59:[function(require,module,exports){
/* global $, $iq, config, connection, focusMucJid, messageHandler,
Toolbar, Util */
var Moderator = require("./moderator");
@@ -17281,7 +17310,7 @@ module.exports = function(XMPP, eventEmitter) {
};
-},{"../../service/xmpp/XMPPEvents":108,"./moderator":58}],61:[function(require,module,exports){
+},{"../../service/xmpp/XMPPEvents":116,"./moderator":58}],61:[function(require,module,exports){
/* jshint -W117 */
var JingleSession = require("./JingleSession");
@@ -17633,7 +17662,7 @@ module.exports = function(XMPP, eventEmitter) {
};
-},{"../../service/xmpp/XMPPEvents":108,"../RTC/RTCBrowserType":8,"./JingleSession":53}],62:[function(require,module,exports){
+},{"../../service/xmpp/XMPPEvents":116,"../RTC/RTCBrowserType":8,"./JingleSession":53}],62:[function(require,module,exports){
/* global Strophe */
module.exports = function () {
@@ -17715,7 +17744,7 @@ module.exports = function (XMPP, eventEmitter) {
}
});
}
-},{"../../service/xmpp/XMPPEvents":108}],64:[function(require,module,exports){
+},{"../../service/xmpp/XMPPEvents":116}],64:[function(require,module,exports){
/* jshint -W117 */
module.exports = function() {
Strophe.addConnectionPlugin('rayo',
@@ -18404,7 +18433,7 @@ var XMPP = {
module.exports = XMPP;
-},{"../../service/RTC/RTCEvents":99,"../../service/RTC/StreamEventTypes":101,"../../service/xmpp/XMPPEvents":108,"../settings/Settings":47,"./SDP":54,"./moderator":58,"./recording":59,"./strophe.emuc":60,"./strophe.jingle":61,"./strophe.logger":62,"./strophe.moderate":63,"./strophe.rayo":64,"./strophe.util":65,"events":109,"pako":69,"retry":85}],67:[function(require,module,exports){
+},{"../../service/RTC/RTCEvents":107,"../../service/RTC/StreamEventTypes":109,"../../service/xmpp/XMPPEvents":116,"../settings/Settings":47,"./SDP":54,"./moderator":58,"./recording":59,"./strophe.emuc":60,"./strophe.jingle":61,"./strophe.logger":62,"./strophe.moderate":63,"./strophe.rayo":64,"./strophe.util":65,"events":117,"pako":69,"retry":85}],67:[function(require,module,exports){
(function (process){
/*!
* async
@@ -19531,7 +19560,7 @@ module.exports = XMPP;
}());
}).call(this,require('_process'))
-},{"_process":110}],68:[function(require,module,exports){
+},{"_process":118}],68:[function(require,module,exports){
// i18next, v1.7.7
// Copyright (c)2014 Jan Mühlemann (jamuhl).
// Distributed under MIT license
@@ -28936,937 +28965,953 @@ exports.parse = function(sdp) {
};
-},{"sdp-transform":95}],92:[function(require,module,exports){
-var transform = require('sdp-transform');
-var transformUtils = require('./transform-utils');
-var parseSsrcs = transformUtils.parseSsrcs;
-var writeSsrcs = transformUtils.writeSsrcs;
-
-//region Constants
-
-var DEFAULT_NUM_OF_LAYERS = 3;
-
-//endregion
-
-//region Ctor
-
-function Simulcast(options) {
-
- this.options = options ? options : {};
-
- if (!this.options.numOfLayers) {
- this.options.numOfLayers = DEFAULT_NUM_OF_LAYERS;
- }
-
- this.layers = [];
-}
-
-//endregion
-
-//region Stateless private utility functions
-
-/**
- * Returns a random integer between min (included) and max (excluded)
- * Using Math.round() gives a non-uniform distribution!
- * @returns {number}
- */
-function generateSSRC() {
- var min = 0, max = 0xffffffff;
- return Math.floor(Math.random() * (max - min)) + min;
-};
-
-function processVideo(session, action) {
- if (session == null || !Array.isArray(session.media)) {
- return;
- }
-
- session.media.forEach(function (mLine) {
- if (mLine.type === 'video') {
- action(mLine);
- }
- });
-}
-
-function validateDescription(desc)
-{
- return desc && desc != null
- && desc.type && desc.type != ''
- && desc.sdp && desc.sdp != '';
-}
-
-function explodeRemoteSimulcast(mLine) {
-
- if (!mLine || !Array.isArray(mLine.ssrcGroups)) {
- return;
- }
-
- var sources = parseSsrcs(mLine);
- var order = [];
-
- // Find the SIM group and explode its sources.
- var j = mLine.ssrcGroups.length;
- while (j--) {
-
- if (mLine.ssrcGroups[j].semantics !== 'SIM') {
- continue;
+},{"sdp-transform":93}],92:[function(require,module,exports){
+var grammar = module.exports = {
+ v: [{
+ name: 'version',
+ reg: /^(\d*)$/
+ }],
+ o: [{ //o=- 20518 0 IN IP4 203.0.113.1
+ // NB: sessionId will be a String in most cases because it is huge
+ name: 'origin',
+ reg: /^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,
+ names: ['username', 'sessionId', 'sessionVersion', 'netType', 'ipVer', 'address'],
+ format: "%s %s %d %s IP%d %s"
+ }],
+ // default parsing of these only (though some of these feel outdated)
+ s: [{ name: 'name' }],
+ i: [{ name: 'description' }],
+ u: [{ name: 'uri' }],
+ e: [{ name: 'email' }],
+ p: [{ name: 'phone' }],
+ z: [{ name: 'timezones' }], // TODO: this one can actually be parsed properly..
+ r: [{ name: 'repeats' }], // TODO: this one can also be parsed properly
+ //k: [{}], // outdated thing ignored
+ t: [{ //t=0 0
+ name: 'timing',
+ reg: /^(\d*) (\d*)/,
+ names: ['start', 'stop'],
+ format: "%d %d"
+ }],
+ c: [{ //c=IN IP4 10.47.197.26
+ name: 'connection',
+ reg: /^IN IP(\d) (\S*)/,
+ names: ['version', 'ip'],
+ format: "IN IP%d %s"
+ }],
+ b: [{ //b=AS:4000
+ push: 'bandwidth',
+ reg: /^(TIAS|AS|CT|RR|RS):(\d*)/,
+ names: ['type', 'limit'],
+ format: "%s:%s"
+ }],
+ m: [{ //m=video 51744 RTP/AVP 126 97 98 34 31
+ // NB: special - pushes to session
+ // TODO: rtp/fmtp should be filtered by the payloads found here?
+ reg: /^(\w*) (\d*) ([\w\/]*)(?: (.*))?/,
+ names: ['type', 'port', 'protocol', 'payloads'],
+ format: "%s %d %s %s"
+ }],
+ a: [
+ { //a=rtpmap:110 opus/48000/2
+ push: 'rtp',
+ reg: /^rtpmap:(\d*) ([\w\-]*)\/(\d*)(?:\s*\/(\S*))?/,
+ names: ['payload', 'codec', 'rate', 'encoding'],
+ format: function (o) {
+ return (o.encoding) ?
+ "rtpmap:%d %s/%s/%s":
+ "rtpmap:%d %s/%s";
+ }
+ },
+ { //a=fmtp:108 profile-level-id=24;object=23;bitrate=64000
+ push: 'fmtp',
+ reg: /^fmtp:(\d*) (\S*)/,
+ names: ['payload', 'config'],
+ format: "fmtp:%d %s"
+ },
+ { //a=control:streamid=0
+ name: 'control',
+ reg: /^control:(.*)/,
+ format: "control:%s"
+ },
+ { //a=rtcp:65179 IN IP4 193.84.77.194
+ name: 'rtcp',
+ reg: /^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,
+ names: ['port', 'netType', 'ipVer', 'address'],
+ format: function (o) {
+ return (o.address != null) ?
+ "rtcp:%d %s IP%d %s":
+ "rtcp:%d";
+ }
+ },
+ { //a=rtcp-fb:98 trr-int 100
+ push: 'rtcpFbTrrInt',
+ reg: /^rtcp-fb:(\*|\d*) trr-int (\d*)/,
+ names: ['payload', 'value'],
+ format: "rtcp-fb:%d trr-int %d"
+ },
+ { //a=rtcp-fb:98 nack rpsi
+ push: 'rtcpFb',
+ reg: /^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,
+ names: ['payload', 'type', 'subtype'],
+ format: function (o) {
+ return (o.subtype != null) ?
+ "rtcp-fb:%s %s %s":
+ "rtcp-fb:%s %s";
+ }
+ },
+ { //a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
+ //a=extmap:1/recvonly URI-gps-string
+ push: 'ext',
+ reg: /^extmap:([\w_\/]*) (\S*)(?: (\S*))?/,
+ names: ['value', 'uri', 'config'], // value may include "/direction" suffix
+ format: function (o) {
+ return (o.config != null) ?
+ "extmap:%s %s %s":
+ "extmap:%s %s";
+ }
+ },
+ {
+ //a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR|2^20|1:32
+ push: 'crypto',
+ reg: /^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,
+ names: ['id', 'suite', 'config', 'sessionConfig'],
+ format: function (o) {
+ return (o.sessionConfig != null) ?
+ "crypto:%d %s %s %s":
+ "crypto:%d %s %s";
+ }
+ },
+ { //a=setup:actpass
+ name: 'setup',
+ reg: /^setup:(\w*)/,
+ format: "setup:%s"
+ },
+ { //a=mid:1
+ name: 'mid',
+ reg: /^mid:([^\s]*)/,
+ format: "mid:%s"
+ },
+ { //a=msid:0c8b064d-d807-43b4-b434-f92a889d8587 98178685-d409-46e0-8e16-7ef0db0db64a
+ name: 'msid',
+ reg: /^msid:(.*)/,
+ format: "msid:%s"
+ },
+ { //a=ptime:20
+ name: 'ptime',
+ reg: /^ptime:(\d*)/,
+ format: "ptime:%d"
+ },
+ { //a=maxptime:60
+ name: 'maxptime',
+ reg: /^maxptime:(\d*)/,
+ format: "maxptime:%d"
+ },
+ { //a=sendrecv
+ name: 'direction',
+ reg: /^(sendrecv|recvonly|sendonly|inactive)/
+ },
+ { //a=ice-lite
+ name: 'icelite',
+ reg: /^(ice-lite)/
+ },
+ { //a=ice-ufrag:F7gI
+ name: 'iceUfrag',
+ reg: /^ice-ufrag:(\S*)/,
+ format: "ice-ufrag:%s"
+ },
+ { //a=ice-pwd:x9cml/YzichV2+XlhiMu8g
+ name: 'icePwd',
+ reg: /^ice-pwd:(\S*)/,
+ format: "ice-pwd:%s"
+ },
+ { //a=fingerprint:SHA-1 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33
+ name: 'fingerprint',
+ reg: /^fingerprint:(\S*) (\S*)/,
+ names: ['type', 'hash'],
+ format: "fingerprint:%s %s"
+ },
+ {
+ //a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host
+ //a=candidate:1162875081 1 udp 2113937151 192.168.34.75 60017 typ host generation 0
+ //a=candidate:3289912957 2 udp 1845501695 193.84.77.194 60017 typ srflx raddr 192.168.34.75 rport 60017 generation 0
+ push:'candidates',
+ reg: /^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: generation (\d*))?/,
+ names: ['foundation', 'component', 'transport', 'priority', 'ip', 'port', 'type', 'raddr', 'rport', 'generation'],
+ format: function (o) {
+ var str = "candidate:%s %d %s %d %s %d typ %s";
+ // NB: candidate has two optional chunks, so %void middle one if it's missing
+ str += (o.raddr != null) ? " raddr %s rport %d" : "%v%v";
+ if (o.generation != null) {
+ str += " generation %d";
}
+ return str;
+ }
+ },
+ { //a=end-of-candidates (keep after the candidates line for readability)
+ name: 'endOfCandidates',
+ reg: /^(end-of-candidates)/
+ },
+ { //a=remote-candidates:1 203.0.113.1 54400 2 203.0.113.1 54401 ...
+ name: 'remoteCandidates',
+ reg: /^remote-candidates:(.*)/,
+ format: "remote-candidates:%s"
+ },
+ { //a=ice-options:google-ice
+ name: 'iceOptions',
+ reg: /^ice-options:(\S*)/,
+ format: "ice-options:%s"
+ },
+ { //a=ssrc:2566107569 cname:t9YU8M1UxTF8Y1A1
+ push: "ssrcs",
+ reg: /^ssrc:(\d*) ([\w_]*):(.*)/,
+ names: ['id', 'attribute', 'value'],
+ format: "ssrc:%d %s:%s"
+ },
+ { //a=ssrc-group:FEC 1 2
+ push: "ssrcGroups",
+ reg: /^ssrc-group:(\w*) (.*)/,
+ names: ['semantics', 'ssrcs'],
+ format: "ssrc-group:%s %s"
+ },
+ { //a=msid-semantic: WMS Jvlam5X3SX1OP6pn20zWogvaKJz5Hjf9OnlV
+ name: "msidSemantic",
+ reg: /^msid-semantic:\s?(\w*) (\S*)/,
+ names: ['semantic', 'token'],
+ format: "msid-semantic: %s %s" // space after ":" is not accidental
+ },
+ { //a=group:BUNDLE audio video
+ push: 'groups',
+ reg: /^group:(\w*) (.*)/,
+ names: ['type', 'mids'],
+ format: "group:%s %s"
+ },
+ { //a=rtcp-mux
+ name: 'rtcpMux',
+ reg: /^(rtcp-mux)/
+ },
+ { //a=rtcp-rsize
+ name: 'rtcpRsize',
+ reg: /^(rtcp-rsize)/
+ },
+ { // any a= that we don't understand is kepts verbatim on media.invalid
+ push: 'invalid',
+ names: ["value"]
+ }
+ ]
+};
- var simulcastSsrcs = mLine.ssrcGroups[j].ssrcs.split(' ');
+// set sensible defaults to avoid polluting the grammar with boring details
+Object.keys(grammar).forEach(function (key) {
+ var objs = grammar[key];
+ objs.forEach(function (obj) {
+ if (!obj.reg) {
+ obj.reg = /(.*)/;
+ }
+ if (!obj.format) {
+ obj.format = "%s";
+ }
+ });
+});
- for (var i = 0; i < simulcastSsrcs.length; i++) {
+},{}],93:[function(require,module,exports){
+var parser = require('./parser');
+var writer = require('./writer');
- var ssrc = simulcastSsrcs[i];
- order.push(ssrc);
+exports.write = writer;
+exports.parse = parser.parse;
+exports.parseFmtpConfig = parser.parseFmtpConfig;
+exports.parsePayloads = parser.parsePayloads;
+exports.parseRemoteCandidates = parser.parseRemoteCandidates;
- var parts = sources[ssrc].msid.split(' ');
- sources[ssrc].msid = [parts[0], '/', i, ' ', parts[1], '/', i].join('');
- sources[ssrc].cname = [sources[ssrc].cname, '/', i].join('');
+},{"./parser":94,"./writer":95}],94:[function(require,module,exports){
+var toIntIfInt = function (v) {
+ return String(Number(v)) === v ? Number(v) : v;
+};
- // Remove all the groups that this SSRC participates in.
- mLine.ssrcGroups.forEach(function (relatedGroup) {
- if (relatedGroup.semantics === 'SIM') {
- return;
- }
+var attachProperties = function (match, location, names, rawName) {
+ if (rawName && !names) {
+ location[rawName] = toIntIfInt(match[1]);
+ }
+ else {
+ for (var i = 0; i < names.length; i += 1) {
+ if (match[i+1] != null) {
+ location[names[i]] = toIntIfInt(match[i+1]);
+ }
+ }
+ }
+};
- var relatedSsrcs = relatedGroup.ssrcs.split(' ');
- if (relatedSsrcs.indexOf(ssrc) === -1) {
- return;
- }
+var parseReg = function (obj, location, content) {
+ var needsBlank = obj.name && obj.names;
+ if (obj.push && !location[obj.push]) {
+ location[obj.push] = [];
+ }
+ else if (needsBlank && !location[obj.name]) {
+ location[obj.name] = {};
+ }
+ var keyLocation = obj.push ?
+ {} : // blank object that will be pushed
+ needsBlank ? location[obj.name] : location; // otherwise, named location or root
- // Nuke all the related SSRCs.
- relatedSsrcs.forEach(function (relatedSSRC) {
- sources[relatedSSRC].msid = sources[ssrc].msid;
- sources[relatedSSRC].cname = sources[ssrc].cname;
- if (relatedSSRC !== ssrc) {
- order.push(relatedSSRC);
- }
- });
+ attachProperties(content.match(obj.reg), keyLocation, obj.names, obj.name);
- // Schedule the related group for nuking.
- })
- }
+ if (obj.push) {
+ location[obj.push].push(keyLocation);
+ }
+};
- mLine.ssrcs = writeSsrcs(sources, order);
- mLine.ssrcGroups.splice(j, 1);
- };
-}
+var grammar = require('./grammar');
+var validLine = RegExp.prototype.test.bind(/^([a-z])=(.*)/);
-function squeezeRemoteSimulcast(mLine) {
+exports.parse = function (sdp) {
+ var session = {}
+ , media = []
+ , location = session; // points at where properties go under (one of the above)
- if (!mLine || !Array.isArray(mLine.ssrcGroups)) {
- return;
+ // parse lines we understand
+ sdp.split(/(\r\n|\r|\n)/).filter(validLine).forEach(function (l) {
+ var type = l[0];
+ var content = l.slice(2);
+ if (type === 'm') {
+ media.push({rtp: [], fmtp: []});
+ location = media[media.length-1]; // point at latest media line
}
- var sources = parseSsrcs(mLine);
-
- // Find the SIM group and nuke it.
- mLine.ssrcGroups.some(function (simulcastGroup) {
- if (simulcastGroup.semantics !== 'SIM') {
- return false;
- }
-
- // Schedule the SIM group for nuking.
- simulcastGroup.nuke = true;
-
- var simulcastSsrcs = simulcastGroup.ssrcs.split(' ');
-
- // Nuke all the higher layer SSRCs.
- for (var i = 1; i < simulcastSsrcs.length; i++) {
-
- var ssrc = simulcastSsrcs[i];
- delete sources[ssrc];
+ for (var j = 0; j < (grammar[type] || []).length; j += 1) {
+ var obj = grammar[type][j];
+ if (obj.reg.test(content)) {
+ return parseReg(obj, location, content);
+ }
+ }
+ });
- // Remove all the groups that this SSRC participates in.
- mLine.ssrcGroups.forEach(function (relatedGroup) {
- if (relatedGroup.semantics === 'SIM') {
- return;
- }
+ session.media = media; // link it up
+ return session;
+};
- var relatedSsrcs = relatedGroup.ssrcs.split(' ');
- if (relatedSsrcs.indexOf(ssrc) === -1) {
- return;
- }
+var fmtpReducer = function (acc, expr) {
+ var s = expr.split('=');
+ if (s.length === 2) {
+ acc[s[0]] = toIntIfInt(s[1]);
+ }
+ return acc;
+};
- // Nuke all the related SSRCs.
- relatedSsrcs.forEach(function (relatedSSRC) {
- delete sources[relatedSSRC];
- });
+exports.parseFmtpConfig = function (str) {
+ return str.split(';').reduce(fmtpReducer, {});
+};
- // Schedule the related group for nuking.
- relatedGroup.nuke = true;
- })
- }
+exports.parsePayloads = function (str) {
+ return str.split(' ').map(Number);
+};
- return true;
+exports.parseRemoteCandidates = function (str) {
+ var candidates = [];
+ var parts = str.split(' ').map(toIntIfInt);
+ for (var i = 0; i < parts.length; i += 3) {
+ candidates.push({
+ component: parts[i],
+ ip: parts[i + 1],
+ port: parts[i + 2]
});
+ }
+ return candidates;
+};
- mLine.ssrcs = writeSsrcs(sources);
-
- // Nuke all the scheduled groups.
- var i = mLine.ssrcGroups.length;
- while (i--) {
- if (mLine.ssrcGroups[i].nuke) {
- mLine.ssrcGroups.splice(i, 1);
- }
- }
-}
-
-function removeGoogConference(mLine) {
- if (!mLine || !Array.isArray(mLine.invalid)) {
- return;
- }
+},{"./grammar":92}],95:[function(require,module,exports){
+var grammar = require('./grammar');
- var i = mLine.invalid.length;
- while (i--) {
- if (mLine.invalid[i].value == 'x-google-flag:conference') {
- mLine.invalid.splice(i, 1);
- }
+// customized util.format - discards excess arguments and can void middle ones
+var formatRegExp = /%[sdv%]/g;
+var format = function (formatStr) {
+ var i = 1;
+ var args = arguments;
+ var len = args.length;
+ return formatStr.replace(formatRegExp, function (x) {
+ if (i >= len) {
+ return x; // missing argument
}
-}
-
-function assertGoogConference(mLine) {
- if (!mLine) {
- return;
+ var arg = args[i];
+ i += 1;
+ switch (x) {
+ case '%%':
+ return '%';
+ case '%s':
+ return String(arg);
+ case '%d':
+ return Number(arg);
+ case '%v':
+ return '';
}
+ });
+ // NB: we discard excess arguments - they are typically undefined from makeLine
+};
- if (!Array.isArray(mLine.invalid)) {
- mLine.invalid = [];
- }
+var makeLine = function (type, obj, location) {
+ var str = obj.format instanceof Function ?
+ (obj.format(obj.push ? location : location[obj.name])) :
+ obj.format;
- if (!mLine.invalid.some(
- function (i) { return i.value === 'x-google-flag:conference' })) {
- mLine.invalid.push({'value': 'x-google-flag:conference'});
+ var args = [type + '=' + str];
+ if (obj.names) {
+ for (var i = 0; i < obj.names.length; i += 1) {
+ var n = obj.names[i];
+ if (obj.name) {
+ args.push(location[obj.name][n]);
+ }
+ else { // for mLine and push attributes
+ args.push(location[obj.names[i]]);
+ }
}
-}
-
-//endregion
+ }
+ else {
+ args.push(location[obj.name]);
+ }
+ return format.apply(null, args);
+};
-//region "Private" functions
+// RFC specified order
+// TODO: extend this with all the rest
+var defaultOuterOrder = [
+ 'v', 'o', 's', 'i',
+ 'u', 'e', 'p', 'c',
+ 'b', 't', 'r', 'z', 'a'
+];
+var defaultInnerOrder = ['i', 'c', 'b', 'a'];
-/**
- *
- * @param mLine
- * @private
- */
-Simulcast.prototype._maybeInitializeLayers = function(mLine) {
- if (!mLine || mLine.type !== 'video') {
- return;
+module.exports = function (session, opts) {
+ opts = opts || {};
+ // ensure certain properties exist
+ if (session.version == null) {
+ session.version = 0; // "v=0" must be there (only defined version atm)
+ }
+ if (session.name == null) {
+ session.name = " "; // "s= " must be there if no meaningful name set
+ }
+ session.media.forEach(function (mLine) {
+ if (mLine.payloads == null) {
+ mLine.payloads = "";
}
+ });
- var sources = parseSsrcs(mLine);
+ var outerOrder = opts.outerOrder || defaultOuterOrder;
+ var innerOrder = opts.innerOrder || defaultInnerOrder;
+ var sdp = [];
- if (Object.keys(sources).length === 0) {
+ // loop through outerOrder for matching properties on session
+ outerOrder.forEach(function (type) {
+ grammar[type].forEach(function (obj) {
+ if (obj.name in session && session[obj.name] != null) {
+ sdp.push(makeLine(type, obj, session));
+ }
+ else if (obj.push in session && session[obj.push] != null) {
+ session[obj.push].forEach(function (el) {
+ sdp.push(makeLine(type, obj, el));
+ });
+ }
+ });
+ });
- // no sources, disable simulcast.
- if (this.layers.length !== 0) {
- this.layers = [];
+ // then for each media line, follow the innerOrder
+ session.media.forEach(function (mLine) {
+ sdp.push(makeLine('m', grammar.m[0], mLine));
+
+ innerOrder.forEach(function (type) {
+ grammar[type].forEach(function (obj) {
+ if (obj.name in mLine && mLine[obj.name] != null) {
+ sdp.push(makeLine(type, obj, mLine));
+ }
+ else if (obj.push in mLine && mLine[obj.push] != null) {
+ mLine[obj.push].forEach(function (el) {
+ sdp.push(makeLine(type, obj, el));
+ });
}
+ });
+ });
+ });
- return;
- }
+ return sdp.join('\r\n') + '\r\n';
+};
- // find the base layer (we'll reuse its msid and cname).
- var baseLayerSSRC = Object.keys(sources)[0];
- var baseLayer = sources[baseLayerSSRC];
+},{"./grammar":92}],96:[function(require,module,exports){
+var transform = require('sdp-transform');
+var transformUtils = require('./transform-utils');
+var parseSsrcs = transformUtils.parseSsrcs;
+var writeSsrcs = transformUtils.writeSsrcs;
- // todo(gp) handle screen sharing.
+//region Constants
- // check if base CNAME has changed and reinitialise layers.
- if (this.layers.length > 0
- && sources[baseLayerSSRC].cname !== this.layers[0].cname) {
- this.layers = [];
- }
+var DEFAULT_NUM_OF_LAYERS = 3;
- // (re)initialise layers
- if (this.layers.length < 1) {
+//endregion
- // first push the base layer.
- this.layers.push({
- ssrc: baseLayerSSRC,
- msid: baseLayer.msid,
- cname: baseLayer.cname
- });
+//region Ctor
- var rtx = false; // RFC 4588
- if (Array.isArray(mLine.rtp)) {
- rtx = mLine.rtp.some(
- function (rtpmap) { return rtpmap.codec === 'rtx'; });
- }
+function Simulcast(options) {
- if (rtx) {
- this.layers[0].rtx = generateSSRC();
- }
+ this.options = options ? options : {};
- // now push additional layers.
- for (var i = 1; i < Math.max(1, this.options.numOfLayers); i++) {
+ if (!this.options.numOfLayers) {
+ this.options.numOfLayers = DEFAULT_NUM_OF_LAYERS;
+ }
- var layer = { ssrc: generateSSRC() };
- if (rtx) {
- layer.rtx = generateSSRC();
- }
+ this.layers = [];
+}
- this.layers.push(layer);
- }
- }
-};
+//endregion
+
+//region Stateless private utility functions
/**
- *
- * @param mLine
- * @private
+ * Returns a random integer between min (included) and max (excluded)
+ * Using Math.round() gives a non-uniform distribution!
+ * @returns {number}
*/
-Simulcast.prototype._restoreSimulcastView = function(mLine) {
- if (mLine && mLine.type === 'video' && this.layers.length !== 0) {
+function generateSSRC() {
+ var min = 0, max = 0xffffffff;
+ return Math.floor(Math.random() * (max - min)) + min;
+};
- var sources = {};
+function processVideo(session, action) {
+ if (session == null || !Array.isArray(session.media)) {
+ return;
+ }
- var msid = this.layers[0].msid;
- var cname = this.layers[0].cname;
- var simulcastSsrcs = [];
- var ssrcGroups = [];
+ session.media.forEach(function (mLine) {
+ if (mLine.type === 'video') {
+ action(mLine);
+ }
+ });
+}
- for (var i = 0; i < this.layers.length; i++) {
- var layer = this.layers[i];
+function validateDescription(desc)
+{
+ return desc && desc != null
+ && desc.type && desc.type != ''
+ && desc.sdp && desc.sdp != '';
+}
- sources[layer.ssrc] = { msid: msid, cname: cname };
- simulcastSsrcs.push(layer.ssrc);
+function explodeRemoteSimulcast(mLine) {
- if (layer.rtx) {
+ if (!mLine || !Array.isArray(mLine.ssrcGroups)) {
+ return;
+ }
- sources[layer.rtx] = {
- msid: msid,
- cname: cname
- }
+ var sources = parseSsrcs(mLine);
+ var order = [];
- ssrcGroups.push({
- semantics: 'FID',
- ssrcs: [layer.ssrc, layer.rtx].join(' ')
- });
- }
+ // Find the SIM group and explode its sources.
+ var j = mLine.ssrcGroups.length;
+ while (j--) {
+
+ if (mLine.ssrcGroups[j].semantics !== 'SIM') {
+ continue;
}
- ssrcGroups.push({
- semantics: 'SIM',
- ssrcs: simulcastSsrcs.join(' ')
- });
+ var simulcastSsrcs = mLine.ssrcGroups[j].ssrcs.split(' ');
- mLine.ssrcGroups = ssrcGroups;
- mLine.ssrcs = writeSsrcs(sources);
- }
-}
+ for (var i = 0; i < simulcastSsrcs.length; i++) {
-//endregion
+ var ssrc = simulcastSsrcs[i];
+ order.push(ssrc);
-//region "Public" functions
+ var parts = sources[ssrc].msid.split(' ');
+ sources[ssrc].msid = [parts[0], '/', i, ' ', parts[1], '/', i].join('');
+ sources[ssrc].cname = [sources[ssrc].cname, '/', i].join('');
-Simulcast.prototype.isSupported = function () {
- return window.chrome;
+ // Remove all the groups that this SSRC participates in.
+ mLine.ssrcGroups.forEach(function (relatedGroup) {
+ if (relatedGroup.semantics === 'SIM') {
+ return;
+ }
- // TODO this needs improvements. For example I doubt that Chrome in Android
- // has simulcast support. Also, only recent versions of Chromium have native
- // simulcast support.
+ var relatedSsrcs = relatedGroup.ssrcs.split(' ');
+ if (relatedSsrcs.indexOf(ssrc) === -1) {
+ return;
+ }
+
+ // Nuke all the related SSRCs.
+ relatedSsrcs.forEach(function (relatedSSRC) {
+ sources[relatedSSRC].msid = sources[ssrc].msid;
+ sources[relatedSSRC].cname = sources[ssrc].cname;
+ if (relatedSSRC !== ssrc) {
+ order.push(relatedSSRC);
+ }
+ });
+
+ // Schedule the related group for nuking.
+ })
+ }
+
+ mLine.ssrcs = writeSsrcs(sources, order);
+ mLine.ssrcGroups.splice(j, 1);
+ };
}
-/**
- *
- * @param desc
- * @returns {RTCSessionDescription}
- */
-Simulcast.prototype.mungeRemoteDescription = function (desc) {
+function squeezeRemoteSimulcast(mLine) {
- if (!validateDescription(desc)) {
- return desc;
+ if (!mLine || !Array.isArray(mLine.ssrcGroups)) {
+ return;
}
- var session = transform.parse(desc.sdp);
-
- var self = this;
- processVideo(session, function (mLine) {
+ var sources = parseSsrcs(mLine);
- // Handle simulcast reception.
- if (self.options.explodeRemoteSimulcast) {
- explodeRemoteSimulcast(mLine);
- } else {
- squeezeRemoteSimulcast(mLine);
+ // Find the SIM group and nuke it.
+ mLine.ssrcGroups.some(function (simulcastGroup) {
+ if (simulcastGroup.semantics !== 'SIM') {
+ return false;
}
- // If native simulcast is enabled, we must append the x-goog-conference
- // attribute to the SDP.
- if (self.layers.length < 1) {
- removeGoogConference(mLine);
- } else {
- assertGoogConference(mLine);
+ // Schedule the SIM group for nuking.
+ simulcastGroup.nuke = true;
+
+ var simulcastSsrcs = simulcastGroup.ssrcs.split(' ');
+
+ // Nuke all the higher layer SSRCs.
+ for (var i = 1; i < simulcastSsrcs.length; i++) {
+
+ var ssrc = simulcastSsrcs[i];
+ delete sources[ssrc];
+
+ // Remove all the groups that this SSRC participates in.
+ mLine.ssrcGroups.forEach(function (relatedGroup) {
+ if (relatedGroup.semantics === 'SIM') {
+ return;
+ }
+
+ var relatedSsrcs = relatedGroup.ssrcs.split(' ');
+ if (relatedSsrcs.indexOf(ssrc) === -1) {
+ return;
+ }
+
+ // Nuke all the related SSRCs.
+ relatedSsrcs.forEach(function (relatedSSRC) {
+ delete sources[relatedSSRC];
+ });
+
+ // Schedule the related group for nuking.
+ relatedGroup.nuke = true;
+ })
}
- });
- return new RTCSessionDescription({
- type: desc.type,
- sdp: transform.write(session)
+ return true;
});
-};
+
+ mLine.ssrcs = writeSsrcs(sources);
+
+ // Nuke all the scheduled groups.
+ var i = mLine.ssrcGroups.length;
+ while (i--) {
+ if (mLine.ssrcGroups[i].nuke) {
+ mLine.ssrcGroups.splice(i, 1);
+ }
+ }
+}
+
+function removeGoogConference(mLine) {
+ if (!mLine || !Array.isArray(mLine.invalid)) {
+ return;
+ }
+
+ var i = mLine.invalid.length;
+ while (i--) {
+ if (mLine.invalid[i].value == 'x-google-flag:conference') {
+ mLine.invalid.splice(i, 1);
+ }
+ }
+}
+
+function assertGoogConference(mLine) {
+ if (!mLine) {
+ return;
+ }
+
+ if (!Array.isArray(mLine.invalid)) {
+ mLine.invalid = [];
+ }
+
+ if (!mLine.invalid.some(
+ function (i) { return i.value === 'x-google-flag:conference' })) {
+ mLine.invalid.push({'value': 'x-google-flag:conference'});
+ }
+}
+
+//endregion
+
+//region "Private" functions
/**
*
- * @param desc
- * @returns {RTCSessionDescription}
+ * @param mLine
+ * @private
*/
-Simulcast.prototype.mungeLocalDescription = function (desc) {
+Simulcast.prototype._maybeInitializeLayers = function(mLine) {
- if (!validateDescription(desc) || !this.isSupported()) {
- return desc;
+ if (!mLine || mLine.type !== 'video') {
+ return;
}
- var session = transform.parse(desc.sdp);
+ var sources = parseSsrcs(mLine);
- var self = this;
- processVideo(session, function (mLine) {
- // Initialize native simulcast layers, if not already done.
- self._maybeInitializeLayers(mLine);
+ if (Object.keys(sources).length === 0) {
- // Update the SDP with the simulcast layers.
- self._restoreSimulcastView(mLine);
- });
+ // no sources, disable simulcast.
+ if (this.layers.length !== 0) {
+ this.layers = [];
+ }
- return new RTCSessionDescription({
- type: desc.type,
- sdp: transform.write(session)
- });
-};
+ return;
+ }
-//endregion
+ // find the base layer (we'll reuse its msid and cname).
+ var baseLayerSSRC = Object.keys(sources)[0];
+ var baseLayer = sources[baseLayerSSRC];
-module.exports = Simulcast;
+ // todo(gp) handle screen sharing.
-},{"./transform-utils":93,"sdp-transform":95}],93:[function(require,module,exports){
-exports.writeSsrcs = function(sources, order) {
- var ssrcs = [];
+ // check if base CNAME has changed and reinitialise layers.
+ if (this.layers.length > 0
+ && sources[baseLayerSSRC].cname !== this.layers[0].cname) {
+ this.layers = [];
+ }
- // expand sources to ssrcs
- if (typeof sources !== 'undefined' &&
- Object.keys(sources).length !== 0) {
+ // (re)initialise layers
+ if (this.layers.length < 1) {
- if (Array.isArray(order)) {
- for (var i = 0; i < order.length; i++) {
- var ssrc = order[i];
- var source = sources[ssrc];
- Object.keys(source).forEach(function (attribute) {
- ssrcs.push({
- id: ssrc,
- attribute: attribute,
- value: source[attribute]
- });
- });
- }
- } else {
- Object.keys(sources).forEach(function (ssrc) {
- var source = sources[ssrc];
- Object.keys(source).forEach(function (attribute) {
- ssrcs.push({
- id: ssrc,
- attribute: attribute,
- value: source[attribute]
- });
+ // first push the base layer.
+ this.layers.push({
+ ssrc: baseLayerSSRC,
+ msid: baseLayer.msid,
+ cname: baseLayer.cname
});
- });
- }
- }
- return ssrcs;
-};
+ var rtx = false; // RFC 4588
+ if (Array.isArray(mLine.rtp)) {
+ rtx = mLine.rtp.some(
+ function (rtpmap) { return rtpmap.codec === 'rtx'; });
+ }
-exports.parseSsrcs = function (mLine) {
- var sources = {};
- // group sources attributes by ssrc.
- if (typeof mLine.ssrcs !== 'undefined' && Array.isArray(mLine.ssrcs)) {
- mLine.ssrcs.forEach(function (ssrc) {
- if (!sources[ssrc.id])
- sources[ssrc.id] = {};
- sources[ssrc.id][ssrc.attribute] = ssrc.value;
- });
- }
- return sources;
+ if (rtx) {
+ this.layers[0].rtx = generateSSRC();
+ }
+
+ // now push additional layers.
+ for (var i = 1; i < Math.max(1, this.options.numOfLayers); i++) {
+
+ var layer = { ssrc: generateSSRC() };
+ if (rtx) {
+ layer.rtx = generateSSRC();
+ }
+
+ this.layers.push(layer);
+ }
+ }
};
+/**
+ *
+ * @param mLine
+ * @private
+ */
+Simulcast.prototype._restoreSimulcastView = function(mLine) {
+ if (mLine && mLine.type === 'video' && this.layers.length !== 0) {
-},{}],94:[function(require,module,exports){
-var grammar = module.exports = {
- v: [{
- name: 'version',
- reg: /^(\d*)$/
- }],
- o: [{ //o=- 20518 0 IN IP4 203.0.113.1
- // NB: sessionId will be a String in most cases because it is huge
- name: 'origin',
- reg: /^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,
- names: ['username', 'sessionId', 'sessionVersion', 'netType', 'ipVer', 'address'],
- format: "%s %s %d %s IP%d %s"
- }],
- // default parsing of these only (though some of these feel outdated)
- s: [{ name: 'name' }],
- i: [{ name: 'description' }],
- u: [{ name: 'uri' }],
- e: [{ name: 'email' }],
- p: [{ name: 'phone' }],
- z: [{ name: 'timezones' }], // TODO: this one can actually be parsed properly..
- r: [{ name: 'repeats' }], // TODO: this one can also be parsed properly
- //k: [{}], // outdated thing ignored
- t: [{ //t=0 0
- name: 'timing',
- reg: /^(\d*) (\d*)/,
- names: ['start', 'stop'],
- format: "%d %d"
- }],
- c: [{ //c=IN IP4 10.47.197.26
- name: 'connection',
- reg: /^IN IP(\d) (\S*)/,
- names: ['version', 'ip'],
- format: "IN IP%d %s"
- }],
- b: [{ //b=AS:4000
- push: 'bandwidth',
- reg: /^(TIAS|AS|CT|RR|RS):(\d*)/,
- names: ['type', 'limit'],
- format: "%s:%s"
- }],
- m: [{ //m=video 51744 RTP/AVP 126 97 98 34 31
- // NB: special - pushes to session
- // TODO: rtp/fmtp should be filtered by the payloads found here?
- reg: /^(\w*) (\d*) ([\w\/]*)(?: (.*))?/,
- names: ['type', 'port', 'protocol', 'payloads'],
- format: "%s %d %s %s"
- }],
- a: [
- { //a=rtpmap:110 opus/48000/2
- push: 'rtp',
- reg: /^rtpmap:(\d*) ([\w\-]*)\/(\d*)(?:\s*\/(\S*))?/,
- names: ['payload', 'codec', 'rate', 'encoding'],
- format: function (o) {
- return (o.encoding) ?
- "rtpmap:%d %s/%s/%s":
- "rtpmap:%d %s/%s";
- }
- },
- { //a=fmtp:108 profile-level-id=24;object=23;bitrate=64000
- push: 'fmtp',
- reg: /^fmtp:(\d*) (\S*)/,
- names: ['payload', 'config'],
- format: "fmtp:%d %s"
- },
- { //a=control:streamid=0
- name: 'control',
- reg: /^control:(.*)/,
- format: "control:%s"
- },
- { //a=rtcp:65179 IN IP4 193.84.77.194
- name: 'rtcp',
- reg: /^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,
- names: ['port', 'netType', 'ipVer', 'address'],
- format: function (o) {
- return (o.address != null) ?
- "rtcp:%d %s IP%d %s":
- "rtcp:%d";
- }
- },
- { //a=rtcp-fb:98 trr-int 100
- push: 'rtcpFbTrrInt',
- reg: /^rtcp-fb:(\*|\d*) trr-int (\d*)/,
- names: ['payload', 'value'],
- format: "rtcp-fb:%d trr-int %d"
- },
- { //a=rtcp-fb:98 nack rpsi
- push: 'rtcpFb',
- reg: /^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,
- names: ['payload', 'type', 'subtype'],
- format: function (o) {
- return (o.subtype != null) ?
- "rtcp-fb:%s %s %s":
- "rtcp-fb:%s %s";
- }
- },
- { //a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
- //a=extmap:1/recvonly URI-gps-string
- push: 'ext',
- reg: /^extmap:([\w_\/]*) (\S*)(?: (\S*))?/,
- names: ['value', 'uri', 'config'], // value may include "/direction" suffix
- format: function (o) {
- return (o.config != null) ?
- "extmap:%s %s %s":
- "extmap:%s %s";
- }
- },
- {
- //a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR|2^20|1:32
- push: 'crypto',
- reg: /^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,
- names: ['id', 'suite', 'config', 'sessionConfig'],
- format: function (o) {
- return (o.sessionConfig != null) ?
- "crypto:%d %s %s %s":
- "crypto:%d %s %s";
- }
- },
- { //a=setup:actpass
- name: 'setup',
- reg: /^setup:(\w*)/,
- format: "setup:%s"
- },
- { //a=mid:1
- name: 'mid',
- reg: /^mid:([^\s]*)/,
- format: "mid:%s"
- },
- { //a=msid:0c8b064d-d807-43b4-b434-f92a889d8587 98178685-d409-46e0-8e16-7ef0db0db64a
- name: 'msid',
- reg: /^msid:(.*)/,
- format: "msid:%s"
- },
- { //a=ptime:20
- name: 'ptime',
- reg: /^ptime:(\d*)/,
- format: "ptime:%d"
- },
- { //a=maxptime:60
- name: 'maxptime',
- reg: /^maxptime:(\d*)/,
- format: "maxptime:%d"
- },
- { //a=sendrecv
- name: 'direction',
- reg: /^(sendrecv|recvonly|sendonly|inactive)/
- },
- { //a=ice-lite
- name: 'icelite',
- reg: /^(ice-lite)/
- },
- { //a=ice-ufrag:F7gI
- name: 'iceUfrag',
- reg: /^ice-ufrag:(\S*)/,
- format: "ice-ufrag:%s"
- },
- { //a=ice-pwd:x9cml/YzichV2+XlhiMu8g
- name: 'icePwd',
- reg: /^ice-pwd:(\S*)/,
- format: "ice-pwd:%s"
- },
- { //a=fingerprint:SHA-1 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33
- name: 'fingerprint',
- reg: /^fingerprint:(\S*) (\S*)/,
- names: ['type', 'hash'],
- format: "fingerprint:%s %s"
- },
- {
- //a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host
- //a=candidate:1162875081 1 udp 2113937151 192.168.34.75 60017 typ host generation 0
- //a=candidate:3289912957 2 udp 1845501695 193.84.77.194 60017 typ srflx raddr 192.168.34.75 rport 60017 generation 0
- push:'candidates',
- reg: /^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: generation (\d*))?/,
- names: ['foundation', 'component', 'transport', 'priority', 'ip', 'port', 'type', 'raddr', 'rport', 'generation'],
- format: function (o) {
- var str = "candidate:%s %d %s %d %s %d typ %s";
- // NB: candidate has two optional chunks, so %void middle one if it's missing
- str += (o.raddr != null) ? " raddr %s rport %d" : "%v%v";
- if (o.generation != null) {
- str += " generation %d";
- }
- return str;
- }
- },
- { //a=end-of-candidates (keep after the candidates line for readability)
- name: 'endOfCandidates',
- reg: /^(end-of-candidates)/
- },
- { //a=remote-candidates:1 203.0.113.1 54400 2 203.0.113.1 54401 ...
- name: 'remoteCandidates',
- reg: /^remote-candidates:(.*)/,
- format: "remote-candidates:%s"
- },
- { //a=ice-options:google-ice
- name: 'iceOptions',
- reg: /^ice-options:(\S*)/,
- format: "ice-options:%s"
- },
- { //a=ssrc:2566107569 cname:t9YU8M1UxTF8Y1A1
- push: "ssrcs",
- reg: /^ssrc:(\d*) ([\w_]*):(.*)/,
- names: ['id', 'attribute', 'value'],
- format: "ssrc:%d %s:%s"
- },
- { //a=ssrc-group:FEC 1 2
- push: "ssrcGroups",
- reg: /^ssrc-group:(\w*) (.*)/,
- names: ['semantics', 'ssrcs'],
- format: "ssrc-group:%s %s"
- },
- { //a=msid-semantic: WMS Jvlam5X3SX1OP6pn20zWogvaKJz5Hjf9OnlV
- name: "msidSemantic",
- reg: /^msid-semantic:\s?(\w*) (\S*)/,
- names: ['semantic', 'token'],
- format: "msid-semantic: %s %s" // space after ":" is not accidental
- },
- { //a=group:BUNDLE audio video
- push: 'groups',
- reg: /^group:(\w*) (.*)/,
- names: ['type', 'mids'],
- format: "group:%s %s"
- },
- { //a=rtcp-mux
- name: 'rtcpMux',
- reg: /^(rtcp-mux)/
- },
- { //a=rtcp-rsize
- name: 'rtcpRsize',
- reg: /^(rtcp-rsize)/
- },
- { // any a= that we don't understand is kepts verbatim on media.invalid
- push: 'invalid',
- names: ["value"]
- }
- ]
-};
+ var sources = {};
-// set sensible defaults to avoid polluting the grammar with boring details
-Object.keys(grammar).forEach(function (key) {
- var objs = grammar[key];
- objs.forEach(function (obj) {
- if (!obj.reg) {
- obj.reg = /(.*)/;
- }
- if (!obj.format) {
- obj.format = "%s";
- }
- });
-});
+ var msid = this.layers[0].msid;
+ var cname = this.layers[0].cname;
+ var simulcastSsrcs = [];
+ var ssrcGroups = [];
-},{}],95:[function(require,module,exports){
-var parser = require('./parser');
-var writer = require('./writer');
+ for (var i = 0; i < this.layers.length; i++) {
+ var layer = this.layers[i];
-exports.write = writer;
-exports.parse = parser.parse;
-exports.parseFmtpConfig = parser.parseFmtpConfig;
-exports.parsePayloads = parser.parsePayloads;
-exports.parseRemoteCandidates = parser.parseRemoteCandidates;
+ sources[layer.ssrc] = { msid: msid, cname: cname };
+ simulcastSsrcs.push(layer.ssrc);
-},{"./parser":96,"./writer":97}],96:[function(require,module,exports){
-var toIntIfInt = function (v) {
- return String(Number(v)) === v ? Number(v) : v;
-};
+ if (layer.rtx) {
-var attachProperties = function (match, location, names, rawName) {
- if (rawName && !names) {
- location[rawName] = toIntIfInt(match[1]);
- }
- else {
- for (var i = 0; i < names.length; i += 1) {
- if (match[i+1] != null) {
- location[names[i]] = toIntIfInt(match[i+1]);
- }
- }
- }
-};
+ sources[layer.rtx] = {
+ msid: msid,
+ cname: cname
+ }
-var parseReg = function (obj, location, content) {
- var needsBlank = obj.name && obj.names;
- if (obj.push && !location[obj.push]) {
- location[obj.push] = [];
- }
- else if (needsBlank && !location[obj.name]) {
- location[obj.name] = {};
- }
- var keyLocation = obj.push ?
- {} : // blank object that will be pushed
- needsBlank ? location[obj.name] : location; // otherwise, named location or root
+ ssrcGroups.push({
+ semantics: 'FID',
+ ssrcs: [layer.ssrc, layer.rtx].join(' ')
+ });
+ }
+ }
- attachProperties(content.match(obj.reg), keyLocation, obj.names, obj.name);
+ ssrcGroups.push({
+ semantics: 'SIM',
+ ssrcs: simulcastSsrcs.join(' ')
+ });
+
+ mLine.ssrcGroups = ssrcGroups;
+ mLine.ssrcs = writeSsrcs(sources);
+ }
+}
+
+//endregion
- if (obj.push) {
- location[obj.push].push(keyLocation);
- }
-};
+//region "Public" functions
-var grammar = require('./grammar');
-var validLine = RegExp.prototype.test.bind(/^([a-z])=(.*)/);
+Simulcast.prototype.isSupported = function () {
+ return window.chrome;
-exports.parse = function (sdp) {
- var session = {}
- , media = []
- , location = session; // points at where properties go under (one of the above)
+ // TODO this needs improvements. For example I doubt that Chrome in Android
+ // has simulcast support. Also, only recent versions of Chromium have native
+ // simulcast support.
+}
- // parse lines we understand
- sdp.split(/(\r\n|\r|\n)/).filter(validLine).forEach(function (l) {
- var type = l[0];
- var content = l.slice(2);
- if (type === 'm') {
- media.push({rtp: [], fmtp: []});
- location = media[media.length-1]; // point at latest media line
- }
+/**
+ *
+ * @param desc
+ * @returns {RTCSessionDescription}
+ */
+Simulcast.prototype.mungeRemoteDescription = function (desc) {
- for (var j = 0; j < (grammar[type] || []).length; j += 1) {
- var obj = grammar[type][j];
- if (obj.reg.test(content)) {
- return parseReg(obj, location, content);
- }
+ if (!validateDescription(desc)) {
+ return desc;
}
- });
- session.media = media; // link it up
- return session;
-};
+ var session = transform.parse(desc.sdp);
-var fmtpReducer = function (acc, expr) {
- var s = expr.split('=');
- if (s.length === 2) {
- acc[s[0]] = toIntIfInt(s[1]);
- }
- return acc;
-};
+ var self = this;
+ processVideo(session, function (mLine) {
-exports.parseFmtpConfig = function (str) {
- return str.split(';').reduce(fmtpReducer, {});
-};
+ // Handle simulcast reception.
+ if (self.options.explodeRemoteSimulcast) {
+ explodeRemoteSimulcast(mLine);
+ } else {
+ squeezeRemoteSimulcast(mLine);
+ }
-exports.parsePayloads = function (str) {
- return str.split(' ').map(Number);
-};
+ // If native simulcast is enabled, we must append the x-goog-conference
+ // attribute to the SDP.
+ if (self.layers.length < 1) {
+ removeGoogConference(mLine);
+ } else {
+ assertGoogConference(mLine);
+ }
+ });
-exports.parseRemoteCandidates = function (str) {
- var candidates = [];
- var parts = str.split(' ').map(toIntIfInt);
- for (var i = 0; i < parts.length; i += 3) {
- candidates.push({
- component: parts[i],
- ip: parts[i + 1],
- port: parts[i + 2]
+ return new RTCSessionDescription({
+ type: desc.type,
+ sdp: transform.write(session)
});
- }
- return candidates;
};
-},{"./grammar":94}],97:[function(require,module,exports){
-var grammar = require('./grammar');
+/**
+ *
+ * @param desc
+ * @returns {RTCSessionDescription}
+ */
+Simulcast.prototype.mungeLocalDescription = function (desc) {
-// customized util.format - discards excess arguments and can void middle ones
-var formatRegExp = /%[sdv%]/g;
-var format = function (formatStr) {
- var i = 1;
- var args = arguments;
- var len = args.length;
- return formatStr.replace(formatRegExp, function (x) {
- if (i >= len) {
- return x; // missing argument
- }
- var arg = args[i];
- i += 1;
- switch (x) {
- case '%%':
- return '%';
- case '%s':
- return String(arg);
- case '%d':
- return Number(arg);
- case '%v':
- return '';
+ if (!validateDescription(desc) || !this.isSupported()) {
+ return desc;
}
- });
- // NB: we discard excess arguments - they are typically undefined from makeLine
-};
-var makeLine = function (type, obj, location) {
- var str = obj.format instanceof Function ?
- (obj.format(obj.push ? location : location[obj.name])) :
- obj.format;
+ var session = transform.parse(desc.sdp);
- var args = [type + '=' + str];
- if (obj.names) {
- for (var i = 0; i < obj.names.length; i += 1) {
- var n = obj.names[i];
- if (obj.name) {
- args.push(location[obj.name][n]);
- }
- else { // for mLine and push attributes
- args.push(location[obj.names[i]]);
- }
- }
- }
- else {
- args.push(location[obj.name]);
- }
- return format.apply(null, args);
+ var self = this;
+ processVideo(session, function (mLine) {
+ // Initialize native simulcast layers, if not already done.
+ self._maybeInitializeLayers(mLine);
+
+ // Update the SDP with the simulcast layers.
+ self._restoreSimulcastView(mLine);
+ });
+
+ return new RTCSessionDescription({
+ type: desc.type,
+ sdp: transform.write(session)
+ });
};
-// RFC specified order
-// TODO: extend this with all the rest
-var defaultOuterOrder = [
- 'v', 'o', 's', 'i',
- 'u', 'e', 'p', 'c',
- 'b', 't', 'r', 'z', 'a'
-];
-var defaultInnerOrder = ['i', 'c', 'b', 'a'];
+//endregion
+module.exports = Simulcast;
-module.exports = function (session, opts) {
- opts = opts || {};
- // ensure certain properties exist
- if (session.version == null) {
- session.version = 0; // "v=0" must be there (only defined version atm)
- }
- if (session.name == null) {
- session.name = " "; // "s= " must be there if no meaningful name set
- }
- session.media.forEach(function (mLine) {
- if (mLine.payloads == null) {
- mLine.payloads = "";
- }
- });
+},{"./transform-utils":97,"sdp-transform":99}],97:[function(require,module,exports){
+exports.writeSsrcs = function(sources, order) {
+ var ssrcs = [];
- var outerOrder = opts.outerOrder || defaultOuterOrder;
- var innerOrder = opts.innerOrder || defaultInnerOrder;
- var sdp = [];
+ // expand sources to ssrcs
+ if (typeof sources !== 'undefined' &&
+ Object.keys(sources).length !== 0) {
- // loop through outerOrder for matching properties on session
- outerOrder.forEach(function (type) {
- grammar[type].forEach(function (obj) {
- if (obj.name in session && session[obj.name] != null) {
- sdp.push(makeLine(type, obj, session));
- }
- else if (obj.push in session && session[obj.push] != null) {
- session[obj.push].forEach(function (el) {
- sdp.push(makeLine(type, obj, el));
+ if (Array.isArray(order)) {
+ for (var i = 0; i < order.length; i++) {
+ var ssrc = order[i];
+ var source = sources[ssrc];
+ Object.keys(source).forEach(function (attribute) {
+ ssrcs.push({
+ id: ssrc,
+ attribute: attribute,
+ value: source[attribute]
+ });
});
}
- });
- });
-
- // then for each media line, follow the innerOrder
- session.media.forEach(function (mLine) {
- sdp.push(makeLine('m', grammar.m[0], mLine));
-
- innerOrder.forEach(function (type) {
- grammar[type].forEach(function (obj) {
- if (obj.name in mLine && mLine[obj.name] != null) {
- sdp.push(makeLine(type, obj, mLine));
- }
- else if (obj.push in mLine && mLine[obj.push] != null) {
- mLine[obj.push].forEach(function (el) {
- sdp.push(makeLine(type, obj, el));
+ } else {
+ Object.keys(sources).forEach(function (ssrc) {
+ var source = sources[ssrc];
+ Object.keys(source).forEach(function (attribute) {
+ ssrcs.push({
+ id: ssrc,
+ attribute: attribute,
+ value: source[attribute]
});
- }
+ });
});
- });
- });
+ }
+ }
- return sdp.join('\r\n') + '\r\n';
+ return ssrcs;
+};
+
+exports.parseSsrcs = function (mLine) {
+ var sources = {};
+ // group sources attributes by ssrc.
+ if (typeof mLine.ssrcs !== 'undefined' && Array.isArray(mLine.ssrcs)) {
+ mLine.ssrcs.forEach(function (ssrc) {
+ if (!sources[ssrc.id])
+ sources[ssrc.id] = {};
+ sources[ssrc.id][ssrc.attribute] = ssrc.value;
+ });
+ }
+ return sources;
};
-},{"./grammar":94}],98:[function(require,module,exports){
+
+},{}],98:[function(require,module,exports){
+arguments[4][92][0].apply(exports,arguments)
+},{"dup":92}],99:[function(require,module,exports){
+arguments[4][93][0].apply(exports,arguments)
+},{"./parser":100,"./writer":101,"dup":93}],100:[function(require,module,exports){
+arguments[4][94][0].apply(exports,arguments)
+},{"./grammar":98,"dup":94}],101:[function(require,module,exports){
+arguments[4][95][0].apply(exports,arguments)
+},{"./grammar":98,"dup":95}],102:[function(require,module,exports){
+arguments[4][92][0].apply(exports,arguments)
+},{"dup":92}],103:[function(require,module,exports){
+arguments[4][93][0].apply(exports,arguments)
+},{"./parser":104,"./writer":105,"dup":93}],104:[function(require,module,exports){
+arguments[4][94][0].apply(exports,arguments)
+},{"./grammar":102,"dup":94}],105:[function(require,module,exports){
+arguments[4][95][0].apply(exports,arguments)
+},{"./grammar":102,"dup":95}],106:[function(require,module,exports){
var MediaStreamType = {
VIDEO_TYPE: "Video",
AUDIO_TYPE: "Audio"
};
module.exports = MediaStreamType;
-},{}],99:[function(require,module,exports){
+},{}],107:[function(require,module,exports){
var RTCEvents = {
RTC_READY: "rtc.ready",
DATA_CHANNEL_OPEN: "rtc.data_channel_open",
@@ -29879,7 +29924,7 @@ var RTCEvents = {
};
module.exports = RTCEvents;
-},{}],100:[function(require,module,exports){
+},{}],108:[function(require,module,exports){
var Resolutions = {
"1080": {
width: 1920,
@@ -29933,7 +29978,7 @@ var Resolutions = {
}
};
module.exports = Resolutions;
-},{}],101:[function(require,module,exports){
+},{}],109:[function(require,module,exports){
var StreamEventTypes = {
EVENT_TYPE_LOCAL_CREATED: "stream.local_created",
@@ -29949,7 +29994,7 @@ var StreamEventTypes = {
};
module.exports = StreamEventTypes;
-},{}],102:[function(require,module,exports){
+},{}],110:[function(require,module,exports){
var UIEvents = {
NICKNAME_CHANGED: "UI.nickname_changed",
SELECTED_ENDPOINT: "UI.selected_endpoint",
@@ -29957,7 +30002,7 @@ var UIEvents = {
LARGEVIDEO_INIT: "UI.largevideo_init"
};
module.exports = UIEvents;
-},{}],103:[function(require,module,exports){
+},{}],111:[function(require,module,exports){
var AuthenticationEvents = {
/**
* Event callback arguments:
@@ -29971,7 +30016,7 @@ var AuthenticationEvents = {
};
module.exports = AuthenticationEvents;
-},{}],104:[function(require,module,exports){
+},{}],112:[function(require,module,exports){
var CQEvents = {
LOCALSTATS_UPDATED: "cq.localstats_updated",
REMOTESTATS_UPDATED: "cq.remotestats_updated",
@@ -29979,7 +30024,7 @@ var CQEvents = {
};
module.exports = CQEvents;
-},{}],105:[function(require,module,exports){
+},{}],113:[function(require,module,exports){
var DesktopSharingEventTypes = {
INIT: "ds.init",
@@ -29989,14 +30034,14 @@ var DesktopSharingEventTypes = {
};
module.exports = DesktopSharingEventTypes;
-},{}],106:[function(require,module,exports){
+},{}],114:[function(require,module,exports){
var Events = {
DTMF_SUPPORT_CHANGED: "members.dtmf_support_changed"
};
module.exports = Events;
-},{}],107:[function(require,module,exports){
+},{}],115:[function(require,module,exports){
module.exports = {
getLanguages : function () {
var languages = [];
@@ -30013,9 +30058,11 @@ module.exports = {
TR: "tr",
FR: "fr"
}
-},{}],108:[function(require,module,exports){
+},{}],116:[function(require,module,exports){
var XMPPEvents = {
CONNECTION_FAILED: "xmpp.connection.failed",
+ CONNECTION_INTERRUPTED: "xmpp.connection.interrupted",
+ CONNECTION_RESTORED: "xmpp.connection.restored",
CONFERENCE_CREATED: "xmpp.conferenceCreated.jingle",
CALL_INCOMING: "xmpp.callincoming.jingle",
DISPOSE_CONFERENCE: "xmpp.dispose_conference",
@@ -30063,7 +30110,7 @@ var XMPPEvents = {
READY_TO_JOIN: 'xmpp.ready_to_join'
};
module.exports = XMPPEvents;
-},{}],109:[function(require,module,exports){
+},{}],117:[function(require,module,exports){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -30366,7 +30413,7 @@ function isUndefined(arg) {
return arg === void 0;
}
-},{}],110:[function(require,module,exports){
+},{}],118:[function(require,module,exports){
// shim for using process in browser
var process = module.exports = {};
diff --git a/modules/UI/UI.js b/modules/UI/UI.js
index fd0eae95fb..280c9928e9 100644
--- a/modules/UI/UI.js
+++ b/modules/UI/UI.js
@@ -333,6 +333,9 @@ function registerListeners() {
UI.addListener(UIEvents.LARGEVIDEO_INIT, function () {
AudioLevels.init();
});
+
+ APP.xmpp.addListener(XMPPEvents.CONNECTION_INTERRUPTED, VideoLayout.onVideoInterrupted);
+ APP.xmpp.addListener(XMPPEvents.CONNECTION_RESTORED, VideoLayout.onVideoRestored);
}
diff --git a/modules/UI/videolayout/LargeVideo.js b/modules/UI/videolayout/LargeVideo.js
index c52d6f9883..f96c534ca8 100644
--- a/modules/UI/videolayout/LargeVideo.js
+++ b/modules/UI/videolayout/LargeVideo.js
@@ -288,7 +288,8 @@ function createLargeVideoHTML()
'<img id="activeSpeakerAvatar" src=""/>' +
'<canvas id="activeSpeakerAudioLevel"></canvas>' +
'</div>' +
- '<video id="largeVideo" autoplay oncontextmenu="return false;"></video>';
+ '<video id="largeVideo" autoplay oncontextmenu="return false;"></video>' +
+ '<span id="videoConnectionMessage"></span>';
html += '</div>';
$(html).prependTo("#videospace");
@@ -660,8 +661,11 @@ var LargeVideo = {
setHover: function(inHandler, outHandler)
{
$('#largeVideoContainer').hover(inHandler, outHandler);
+ },
+
+ enableVideoProblemFilter: function (enable) {
+ $("#largeVideo").toggleClass("videoProblemFilter", enable);
}
};
-
module.exports = LargeVideo;
\ No newline at end of file
diff --git a/modules/UI/videolayout/VideoLayout.js b/modules/UI/videolayout/VideoLayout.js
index 3b6acc3c72..06b5527c60 100644
--- a/modules/UI/videolayout/VideoLayout.js
+++ b/modules/UI/videolayout/VideoLayout.js
@@ -891,6 +891,19 @@ var VideoLayout = (function (my) {
LargeVideo.setHover(inHandler, outHandler);
};
+ my.onVideoInterrupted = function () {
+ LargeVideo.enableVideoProblemFilter(true);
+ var reconnectingKey = "connection.RECONNECTING";
+ $('#videoConnectionMessage').attr("data-i18n", reconnectingKey);
+ $('#videoConnectionMessage').text(APP.translation.translateString(reconnectingKey));
+ $('#videoConnectionMessage').css({display: "block"});
+ };
+
+ my.onVideoRestored = function () {
+ LargeVideo.enableVideoProblemFilter(false);
+ $('#videoConnectionMessage').css({display: "none"});
+ };
+
return my;
}(VideoLayout || {}));
diff --git a/modules/xmpp/JingleSession.js b/modules/xmpp/JingleSession.js
index 7f68fe2545..9a6abff2c6 100644
--- a/modules/xmpp/JingleSession.js
+++ b/modules/xmpp/JingleSession.js
@@ -90,6 +90,7 @@ JingleSession.prototype.initiate = function (peerjid, isInitiator) {
this.hadstuncandidate = false;
this.hadturncandidate = false;
this.lasticecandidate = false;
+ this.isreconnect = false;
this.peerconnection
= new TraceablePeerConnection(
@@ -127,9 +128,17 @@ JingleSession.prototype.initiate = function (peerjid, isInitiator) {
switch (self.peerconnection.iceConnectionState) {
case 'connected':
this.startTime = new Date();
+
+ if (this.peerconnection.signalingState === 'stable' && this.isreconnect)
+ self.eventEmitter.emit(XMPPEvents.CONNECTION_RESTORED);
+ this.isreconnect = false;
+
break;
case 'disconnected':
+ this.isreconnect = true;
this.stopTime = new Date();
+ if (this.peerconnection.signalingState === 'stable')
+ self.eventEmitter.emit(XMPPEvents.CONNECTION_INTERRUPTED);
break;
case 'failed':
self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
diff --git a/service/xmpp/XMPPEvents.js b/service/xmpp/XMPPEvents.js
index 82fd3befec..350b952ca5 100644
--- a/service/xmpp/XMPPEvents.js
+++ b/service/xmpp/XMPPEvents.js
@@ -1,5 +1,7 @@
var XMPPEvents = {
CONNECTION_FAILED: "xmpp.connection.failed",
+ CONNECTION_INTERRUPTED: "xmpp.connection.interrupted",
+ CONNECTION_RESTORED: "xmpp.connection.restored",
CONFERENCE_CREATED: "xmpp.conferenceCreated.jingle",
CALL_INCOMING: "xmpp.callincoming.jingle",
DISPOSE_CONFERENCE: "xmpp.dispose_conference",