From d92d8e8299af6c0ac2377d3e3916262adaf9f43b Mon Sep 17 00:00:00 2001 From: yanas Date: Mon, 3 Aug 2015 10:58:22 -0500 Subject: [PATCH] Some additional error handling. --- css/videolayout_default.css | 21 + index.html | 6 +- lang/main.json | 1 + libs/app.bundle.js | 1073 +++++++++++++------------ modules/UI/UI.js | 3 + modules/UI/videolayout/LargeVideo.js | 8 +- modules/UI/videolayout/VideoLayout.js | 13 + modules/xmpp/JingleSession.js | 9 + service/xmpp/XMPPEvents.js | 2 + 9 files changed, 618 insertions(+), 518 deletions(-) diff --git a/css/videolayout_default.css b/css/videolayout_default.css index 0d80ed21d..f7375007a 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 110e4812f..196aff39f 100644 --- a/index.html +++ b/index.html @@ -13,7 +13,7 @@ - + @@ -22,12 +22,12 @@ - + - + diff --git a/lang/main.json b/lang/main.json index 6548cd763..acab49f08 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 c52afc7b7..98dcc0be0 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() '' + '' + '' + - ''; + '' + + ''; html += ''; $(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,7 +28965,477 @@ exports.parse = function(sdp) { }; -},{"sdp-transform":95}],92:[function(require,module,exports){ +},{"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"] + } + ] +}; + +// 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"; + } + }); +}); + +},{}],93:[function(require,module,exports){ +var parser = require('./parser'); +var writer = require('./writer'); + +exports.write = writer; +exports.parse = parser.parse; +exports.parseFmtpConfig = parser.parseFmtpConfig; +exports.parsePayloads = parser.parsePayloads; +exports.parseRemoteCandidates = parser.parseRemoteCandidates; + +},{"./parser":94,"./writer":95}],94:[function(require,module,exports){ +var toIntIfInt = function (v) { + return String(Number(v)) === v ? Number(v) : v; +}; + +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 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 + + attachProperties(content.match(obj.reg), keyLocation, obj.names, obj.name); + + if (obj.push) { + location[obj.push].push(keyLocation); + } +}; + +var grammar = require('./grammar'); +var validLine = RegExp.prototype.test.bind(/^([a-z])=(.*)/); + +exports.parse = function (sdp) { + var session = {} + , media = [] + , location = session; // points at where properties go under (one of the above) + + // 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 + } + + 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); + } + } + }); + + session.media = media; // link it up + return session; +}; + +var fmtpReducer = function (acc, expr) { + var s = expr.split('='); + if (s.length === 2) { + acc[s[0]] = toIntIfInt(s[1]); + } + return acc; +}; + +exports.parseFmtpConfig = function (str) { + return str.split(';').reduce(fmtpReducer, {}); +}; + +exports.parsePayloads = function (str) { + return str.split(' ').map(Number); +}; + +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; +}; + +},{"./grammar":92}],95:[function(require,module,exports){ +var grammar = require('./grammar'); + +// 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 ''; + } + }); + // 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 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); +}; + +// 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']; + + +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 outerOrder = opts.outerOrder || defaultOuterOrder; + var innerOrder = opts.innerOrder || defaultInnerOrder; + var sdp = []; + + // 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)); + }); + } + }); + }); + + // 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 sdp.join('\r\n') + '\r\n'; +}; + +},{"./grammar":92}],96:[function(require,module,exports){ var transform = require('sdp-transform'); var transformUtils = require('./transform-utils'); var parseSsrcs = transformUtils.parseSsrcs; @@ -29338,7 +29837,7 @@ Simulcast.prototype.mungeLocalDescription = function (desc) { module.exports = Simulcast; -},{"./transform-utils":93,"sdp-transform":95}],93:[function(require,module,exports){ +},{"./transform-utils":97,"sdp-transform":99}],97:[function(require,module,exports){ exports.writeSsrcs = function(sources, order) { var ssrcs = []; @@ -29389,484 +29888,30 @@ exports.parseSsrcs = function (mLine) { }; -},{}],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"] - } - ] -}; - -// 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"; - } - }); -}); - -},{}],95:[function(require,module,exports){ -var parser = require('./parser'); -var writer = require('./writer'); - -exports.write = writer; -exports.parse = parser.parse; -exports.parseFmtpConfig = parser.parseFmtpConfig; -exports.parsePayloads = parser.parsePayloads; -exports.parseRemoteCandidates = parser.parseRemoteCandidates; - -},{"./parser":96,"./writer":97}],96:[function(require,module,exports){ -var toIntIfInt = function (v) { - return String(Number(v)) === v ? Number(v) : v; -}; - -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 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 - - attachProperties(content.match(obj.reg), keyLocation, obj.names, obj.name); - - if (obj.push) { - location[obj.push].push(keyLocation); - } -}; - -var grammar = require('./grammar'); -var validLine = RegExp.prototype.test.bind(/^([a-z])=(.*)/); - -exports.parse = function (sdp) { - var session = {} - , media = [] - , location = session; // points at where properties go under (one of the above) - - // 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 - } - - 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); - } - } - }); - - session.media = media; // link it up - return session; -}; - -var fmtpReducer = function (acc, expr) { - var s = expr.split('='); - if (s.length === 2) { - acc[s[0]] = toIntIfInt(s[1]); - } - return acc; -}; - -exports.parseFmtpConfig = function (str) { - return str.split(';').reduce(fmtpReducer, {}); -}; - -exports.parsePayloads = function (str) { - return str.split(' ').map(Number); -}; - -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; -}; - -},{"./grammar":94}],97:[function(require,module,exports){ -var grammar = require('./grammar'); - -// 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 ''; - } - }); - // 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 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); -}; - -// 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']; - - -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 outerOrder = opts.outerOrder || defaultOuterOrder; - var innerOrder = opts.innerOrder || defaultInnerOrder; - var sdp = []; - - // 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)); - }); - } - }); - }); - - // 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 sdp.join('\r\n') + '\r\n'; -}; - -},{"./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 fd0eae95f..280c9928e 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 c52d6f988..f96c534ca 100644 --- a/modules/UI/videolayout/LargeVideo.js +++ b/modules/UI/videolayout/LargeVideo.js @@ -288,7 +288,8 @@ function createLargeVideoHTML() '' + '' + '' + - ''; + '' + + ''; html += ''; $(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 3b6acc3c7..06b5527c6 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 7f68fe254..9a6abff2c 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 82fd3befe..350b952ca 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",