Socket
Socket
Sign inDemoInstall

p2p-media-loader-shaka

Package Overview
Dependencies
83
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

dist/browser-init-webpack.js

2

build/p2p-media-loader-shaka.min.js

@@ -18,2 +18,2 @@ require=function s(o,a,u){function c(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(l)return l(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[t]={exports:{}};o[t][0].call(i.exports,function(e){return c(o[t][1][e]||e)},i,i.exports,s,o,a,u)}return a[t].exports}for(var l="function"==typeof require&&require,e=0;e<u.length;e++)c(u[e]);return c}({1:[function(e,t,r){

*/
window.p2pml||(window.p2pml={}),window.p2pml.shaka=e("p2p-media-loader-shaka")},{"p2p-media-loader-shaka":"p2p-media-loader-shaka"}],2:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var s=e("events"),o=e("p2p-media-loader-core"),a=e("./segment-manager"),u=e("./integration"),c=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.loader=new o.HybridLoader(e.loader),n.segmentManager=new a.SegmentManager(n.loader,e.segments),Object.keys(o.Events).map(function(e){return o.Events[e]}).forEach(function(r){return n.loader.on(r,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.emit.apply(n,[r].concat(e))})}),n}return i(e,t),e.isSupported=function(){return o.HybridLoader.isSupported()},e.prototype.destroy=function(){this.loader.destroy(),this.segmentManager.destroy()},e.prototype.getSettings=function(){return{segments:this.segmentManager.getSettings(),loader:this.loader.getSettings()}},e.prototype.initShakaPlayer=function(e){u.initShakaPlayer(e,this.segmentManager)},e}(s.EventEmitter);r.Engine=c},{"./integration":3,"./segment-manager":6,events:10,"p2p-media-loader-core":void 0}],3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("debug"),s=e("./manifest-parser-proxy"),l=e("./utils"),f=n("p2pml:shaka:index");function o(e,t,r){if(!t.p2pml||r!==shaka.net.NetworkingEngine.RequestType.SEGMENT)return shaka.net.HttpXHRPlugin(e,t,r);var n=t.p2pml,i=n.player,s=n.segmentManager,o=i.getManifest();if(!o||!o.p2pml)return shaka.net.HttpXHRPlugin(e,t,r);var a=o.p2pml.parser.find(e,t.headers.Range);if(!a||"video"!==a.streamType)return shaka.net.HttpXHRPlugin(e,t,r);var u=null;f("request","load",a.identity);var c=new Promise(function(t,e){u=e,s.load(a,l.getSchemedUri(i.getManifestUri()),h(i)).then(function(e){return t({data:e})})});return new shaka.util.AbortableOperation(c,function(){return f("request","abort",a.identity),u(new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.OPERATION_ABORTED))})}function h(e){var t=0,r=e.getPlayheadTimeAsDate();return r&&(t=r.valueOf(),e.isLive()&&(t-=e.getPresentationStartTimeAsDate().valueOf()),t/=1e3),t}r.initShakaPlayer=function(r,n){f("register parser proxies"),shaka.media.ManifestParser.registerParserByExtension("mpd",s.ShakaDashManifestParserProxy),shaka.media.ManifestParser.registerParserByMime("application/dash+xml",s.ShakaDashManifestParserProxy),shaka.media.ManifestParser.registerParserByExtension("m3u8",s.ShakaHlsManifestParserProxy),shaka.media.ManifestParser.registerParserByMime("application/x-mpegurl",s.ShakaHlsManifestParserProxy),shaka.media.ManifestParser.registerParserByMime("application/vnd.apple.mpegurl",s.ShakaHlsManifestParserProxy),f("init networking engine"),shaka.net.NetworkingEngine.registerScheme("http",o),shaka.net.NetworkingEngine.registerScheme("https",o);var t=0,i=0;r.addEventListener("loading",function(){0<t&&(clearInterval(t),t=0),i=0;var e=r.getManifest();e&&e.p2pml&&e.p2pml.parser.reset(),n.destroy(),t=setInterval(function(){var e=h(r);(e!==i||r.isBuffering())&&(n.setPlayheadTime(e),i=e)},500)}),f("register request filter"),r.getNetworkingEngine().registerRequestFilter(function(e,t){t.p2pml={player:r,segmentManager:n}})}},{"./manifest-parser-proxy":4,"./utils":7,debug:8}],4:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var s=e("./parser-segment"),o=function(){function e(e){this.cache=new s.ParserSegmentCache(200),this.originalManifestParser=e}return e.prototype.isHls=function(){return this.originalManifestParser instanceof shaka.hls.HlsParser},e.prototype.isDash=function(){return this.originalManifestParser instanceof shaka.dash.DashParser},e.prototype.start=function(e,t){var a=this;return this.originalManifestParser.start(e,t).then(function(e){for(var t=0,r=(a.manifest=e).periods;t<r.length;t++)for(var n=[],i=0,s=r[t].variants;i<s.length;i++){var o=s[i];null!=o.video&&-1==n.indexOf(o.video)&&(a.hookGetSegmentReference(o.video),n.push(o.video)),null!=o.audio&&-1==n.indexOf(o.audio)&&(a.hookGetSegmentReference(o.audio),n.push(o.audio))}return e.p2pml={parser:a},e})},e.prototype.configure=function(e){return this.originalManifestParser.configure(e)},e.prototype.stop=function(){return this.originalManifestParser.stop()},e.prototype.update=function(){return this.originalManifestParser.update()},e.prototype.onExpirationUpdated=function(){return this.originalManifestParser.onExpirationUpdated()},e.prototype.find=function(e,t){return this.cache.find(e,t)},e.prototype.reset=function(){this.cache.clear()},e.prototype.hookGetSegmentReference=function(t){var r=this;t.getSegmentReferenceOriginal=t.getSegmentReference,t.getSegmentReference=function(e){return r.cache.add(t,e),t.getSegmentReferenceOriginal(e)},t.getPosition=function(){return r.isHls()&&"video"===t.type?r.manifest.periods[0].variants.reduce(function(e,t){return t.video&&t.video.id&&!e.includes(t.video.id)&&e.push(t.video.id),e},[]).indexOf(t.id):-1}},e}(),a=function(e){function t(){return e.call(this,new shaka.dash.DashParser)||this}return i(t,e),t}(r.ShakaManifestParserProxy=o);r.ShakaDashManifestParserProxy=a;var u=function(e){function t(){return e.call(this,new shaka.hls.HlsParser)||this}return i(t,e),t}(o);r.ShakaHlsManifestParserProxy=u},{"./parser-segment":5}],5:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var g=e("./utils"),n=function(){function d(e,t,r,n,i,s,o,a,u,c,l,f){this.streamId=e,this.streamType=t,this.streamPosition=r,this.streamIdentity=n,this.identity=i,this.position=s,this.start=o,this.end=a,this.uri=u,this.range=c,this.prev=l,this.next=f}return d.create=function(e,t){var r=e.getSegmentReferenceOriginal(t);if(r){var n=r.createUris();if(n&&0!==n.length){var i=r.getStartTime(),s=r.getEndTime(),o=r.getStartByte(),a=r.getEndByte(),u=o||a?"bytes="+(o||"")+"-"+(a||""):void 0,c=e.type.substring(0,1).toUpperCase(),l=e.getPosition(),f=0<=l,h=f?""+c+l:""+c+e.id,p=f?h+"+"+t:h+"+"+Number(i).toFixed(3);return new d(e.id,e.type,l,h,p,t,i,s,g.getSchemedUri(n[0]),u,function(){return d.create(e,t-1)},function(){return d.create(e,t+1)})}}},d}();r.ParserSegment=n;var i=function(){function e(e){this.segments=[],this.maxSegments=e}return e.prototype.find=function(t,r){return this.segments.find(function(e){return e.uri===t&&e.range===r})},e.prototype.add=function(e,t){var r=n.create(e,t);r&&!this.find(r.uri,r.range)&&(this.segments.push(r),this.segments.length>this.maxSegments&&this.segments.splice(0,.2*this.maxSegments))},e.prototype.clear=function(){this.segments.splice(0)},e}();r.ParserSegmentCache=i},{"./utils":7}],6:[function(e,t,r){"use strict";var n=this&&this.__awaiter||function(s,o,a,u){return new(a||(a=Promise))(function(e,t){function r(e){try{i(u.next(e))}catch(e){t(e)}}function n(e){try{i(u.throw(e))}catch(e){t(e)}}function i(t){t.done?e(t.value):new a(function(e){e(t.value)}).then(r,n)}i((u=u.apply(s,o||[])).next())})},a=this&&this.__generator||function(r,n){var i,s,o,e,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,s&&(o=2&t[0]?s.return:t[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,t[1])).done)return o;switch(s=0,o&&(t=[2&t[0],o.value]),t[0]){case 0:case 1:o=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,s=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(o=0<(o=a.trys).length&&o[o.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!o||t[1]>o[0]&&t[1]<o[3])){a.label=t[1];break}if(6===t[0]&&a.label<o[1]){a.label=o[1],o=t;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(t);break}o[2]&&a.ops.pop(),a.trys.pop();continue}t=n.call(r,a)}catch(e){t=[6,e],s=0}finally{i=o=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}};Object.defineProperty(r,"__esModule",{value:!0});var i=e("debug"),u=e("p2p-media-loader-core"),s={forwardSegmentCount:20,maxHistorySegments:50},o=function(){function e(e,t){void 0===t&&(t={});var r=this;this.debug=i("p2pml:shaka:sm"),this.requests=new Map,this.manifestUri="",this.playheadTime=0,this.segmentHistory=[],this.onSegmentLoaded=function(e){r.requests.has(e.id)&&(r.reportSuccess(r.requests.get(e.id),e),r.debug("request delete",e.id),r.requests.delete(e.id))},this.onSegmentError=function(e,t){r.requests.has(e.id)&&(r.reportError(r.requests.get(e.id),t),r.debug("request delete from error",e.id),r.requests.delete(e.id))},this.onSegmentAbort=function(e){r.requests.has(e.id)&&(r.reportError(r.requests.get(e.id),"Internal abort"),r.debug("request delete from abort",e.id),r.requests.delete(e.id))},this.settings=Object.assign(s,t),this.loader=e,this.loader.on(u.Events.SegmentLoaded,this.onSegmentLoaded),this.loader.on(u.Events.SegmentError,this.onSegmentError),this.loader.on(u.Events.SegmentAbort,this.onSegmentAbort)}return e.prototype.destroy=function(){0!==this.requests.size&&(console.error("Destroying segment manager with active request(s)!"),this.requests.clear()),this.playheadTime=0,this.segmentHistory.splice(0),this.loader.destroy()},e.prototype.getSettings=function(){return this.settings},e.prototype.load=function(t,r,o){return n(this,void 0,void 0,function(){var n,i,s=this;return a(this,function(e){return this.manifestUri=r,this.playheadTime=o,this.pushSegmentHistory(t),n=this.refreshLoad(),i=this.loader.getSegment(n.id),[2,new Promise(function(e,t){var r=new c(n.id,e,t);i?s.reportSuccess(r,i):(s.debug("request add",r.id),s.requests.set(r.id,r))})]})})},e.prototype.setPlayheadTime=function(e){this.playheadTime=e,0<this.segmentHistory.length&&this.refreshLoad()},e.prototype.refreshLoad=function(){var e=this.segmentHistory[this.segmentHistory.length-1],r=.1<this.playheadTime?this.playheadTime:e.start,t=this.segmentHistory.reduce(function(e,t){return t.start>=r&&e.push(t),e},[]);0===t.length&&t.push(e);var n=t.length-1;do{var i=t[t.length-1].next();if(!i)break;t.push(i)}while(t.length<this.settings.forwardSegmentCount);var s=this.manifestUri.split("?")[0],o=t.map(function(e,t){return new u.Segment(s+"+"+e.identity,e.uri,e.range,t)});return this.loader.load(o,s+"+"+e.streamIdentity),o[n]},e.prototype.pushSegmentHistory=function(e){this.segmentHistory.length>=this.settings.maxHistorySegments&&(this.debug("segment history auto shrink"),this.segmentHistory.splice(0,.2*this.settings.maxHistorySegments)),0<this.segmentHistory.length&&this.segmentHistory[this.segmentHistory.length-1].start>e.start&&(this.debug("segment history reset due to playhead seek back"),this.segmentHistory.splice(0)),this.segmentHistory.push(e)},e.prototype.reportSuccess=function(e,t){var r=this;if(e.resolve){var n=0;if(0<t.downloadSpeed&&t.data&&0<t.data.byteLength){var i=Math.trunc(t.data.byteLength/t.downloadSpeed);n=Date.now()-e.timeCreated+i}setTimeout(function(){r.debug("report success",e.id),e.resolve(t.data)},n)}},e.prototype.reportError=function(e,t){e.reject&&(this.debug("report error",e.id),e.reject(t))},e}();r.SegmentManager=o;var c=function(e,t,r){this.id=e,this.resolve=t,this.reject=r,this.timeCreated=Date.now()}},{debug:8,"p2p-media-loader-core":void 0}],7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getSchemedUri=function(e){return e.startsWith("//")?window.location.protocol+e:e}},{}],8:[function(r,n,s){(function(t){function e(){var e;try{e=s.storage.debug}catch(e){}return!e&&void 0!==t&&"env"in t&&(e=t.env.DEBUG),e}(s=n.exports=r("./debug")).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},s.formatArgs=function(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+s.humanize(this.diff),!t)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(n++,"%c"===e&&(i=n))}),e.splice(i,0,r)},s.save=function(e){try{null==e?s.storage.removeItem("debug"):s.storage.debug=e}catch(e){}},s.load=e,s.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},s.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),s.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],s.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},s.enable(e())}).call(this,r("_process"))},{"./debug":9,_process:12}],9:[function(e,t,u){function r(e){var n;function a(){if(a.enabled){var i=a,e=+new Date,t=e-(n||e);i.diff=t,i.prev=n,i.curr=e,n=e;for(var s=new Array(arguments.length),r=0;r<s.length;r++)s[r]=arguments[r];s[0]=u.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var o=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,function(e,t){if("%%"===e)return e;o++;var r=u.formatters[t];if("function"==typeof r){var n=s[o];e=r.call(i,n),s.splice(o,1),o--}return e}),u.formatArgs.call(i,s),(a.log||u.log||console.log.bind(console)).apply(i,s)}}return a.namespace=e,a.enabled=u.enabled(e),a.useColors=u.useColors(),a.color=function(e){var t,r=0;for(t in e)r=(r<<5)-r+e.charCodeAt(t),r|=0;return u.colors[Math.abs(r)%u.colors.length]}(e),a.destroy=i,"function"==typeof u.init&&u.init(a),u.instances.push(a),a}function i(){var e=u.instances.indexOf(this);return-1!==e&&(u.instances.splice(e,1),!0)}(u=t.exports=r.debug=r.default=r).coerce=function(e){return e instanceof Error?e.stack||e.message:e},u.disable=function(){u.enable("")},u.enable=function(e){var t;u.save(e),u.names=[],u.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),n=r.length;for(t=0;t<n;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?u.skips.push(new RegExp("^"+e.substr(1)+"$")):u.names.push(new RegExp("^"+e+"$")));for(t=0;t<u.instances.length;t++){var i=u.instances[t];i.enabled=u.enabled(i.namespace)}},u.enabled=function(e){if("*"===e[e.length-1])return!0;var t,r;for(t=0,r=u.skips.length;t<r;t++)if(u.skips[t].test(e))return!1;for(t=0,r=u.names.length;t<r;t++)if(u.names[t].test(e))return!0;return!1},u.humanize=e("ms"),u.instances=[],u.names=[],u.skips=[],u.formatters={}},{ms:11}],10:[function(e,t,r){var u=Object.create||function(e){var t=function(){};return t.prototype=e,new t},o=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return r},s=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};function n(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=u(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}((t.exports=n).EventEmitter=n).prototype._events=void 0,n.prototype._maxListeners=void 0;var i,a=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),i=0===c.x}catch(e){i=!1}function l(e){return void 0===e._maxListeners?n.defaultMaxListeners:e._maxListeners}function f(e,t,r,n){var i,s,o;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]):(s=e._events=u(null),e._eventsCount=0),o){if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(i=l(e))&&0<i&&o.length>i){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=o.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",a.name,a.message)}}else o=s[t]=r,++e._eventsCount;return e}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function p(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=s.call(h,n);return i.listener=r,n.wrapFn=i}function d(e,t,r){var n=e._events;if(!n)return[];var i=n[t];return i?"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):m(i,i.length):[]}function g(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function m(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}i?Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');a=e}}):n.defaultMaxListeners=a,n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},n.prototype.getMaxListeners=function(){return l(this)},n.prototype.emit=function(e){var t,r,n,i,s,o,a="error"===e;if(o=this._events)a=a&&null==o.error;else if(!a)return!1;if(a){if(1<arguments.length&&(t=arguments[1]),t instanceof Error)throw t;var u=new Error('Unhandled "error" event. ('+t+")");throw u.context=t,u}if(!(r=o[e]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=m(e,n),s=0;s<n;++s)i[s].call(r)}(r,c,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,s=m(e,i),o=0;o<i;++o)s[o].call(r,n)}(r,c,this,arguments[1]);break;case 3:!function(e,t,r,n,i){if(t)e.call(r,n,i);else for(var s=e.length,o=m(e,s),a=0;a<s;++a)o[a].call(r,n,i)}(r,c,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,i,s){if(t)e.call(r,n,i,s);else for(var o=e.length,a=m(e,o),u=0;u<o;++u)a[u].call(r,n,i,s)}(r,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),s=1;s<n;s++)i[s-1]=arguments[s];!function(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,s=m(e,i),o=0;o<i;++o)s[o].apply(r,n)}(r,c,this,i)}return!0},n.prototype.on=n.prototype.addListener=function(e,t){return f(this,e,t,!1)},n.prototype.prependListener=function(e,t){return f(this,e,t,!0)},n.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,p(this,e,t)),this},n.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,p(this,e,t)),this},n.prototype.removeListener=function(e,t){var r,n,i,s,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=u(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length-1;0<=s;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),n.removeListener&&this.emit("removeListener",e,o||t)}return this},n.prototype.removeAllListeners=function(e){var t,r,n;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=u(null),this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=u(null):delete r[e]),this;if(0===arguments.length){var i,s=o(r);for(n=0;n<s.length;++n)"removeListener"!==(i=s[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=u(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)for(n=t.length-1;0<=n;n--)this.removeListener(e,t[n]);return this},n.prototype.listeners=function(e){return d(this,e,!0)},n.prototype.rawListeners=function(e){return d(this,e,!1)},n.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},n.prototype.listenerCount=g,n.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]}},{}],11:[function(e,t,r){var i=36e5,s=864e5;function o(e,t,r){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}t.exports=function(e,t){t=t||{};var r,n=typeof e;if("string"===n&&0<e.length)return function(e){if(100<(e=String(e)).length)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*i;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*r;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?o(r=e,s,"day")||o(r,i,"hour")||o(r,6e4,"minute")||o(r,1e3,"second")||r+" ms":function(e){if(s<=e)return Math.round(e/s)+"d";if(i<=e)return Math.round(e/i)+"h";if(6e4<=e)return Math.round(e/6e4)+"m";if(1e3<=e)return Math.round(e/1e3)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],12:[function(e,t,r){var n,i,s=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(e){i=a}}();var c,l=[],f=!1,h=-1;function p(){f&&c&&(f=!1,c.length?l=c.concat(l):h=-1,l.length&&d())}function d(){if(!f){var e=u(p);f=!0;for(var t=l.length;t;){for(c=l,l=[];++h<t;)c&&c[h].run();h=-1,t=l.length}c=null,f=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(e)}}function g(e,t){this.fun=e,this.array=t}function m(){}s.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new g(e,t)),1!==l.length||f||u(d)},g.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(e){return[]},s.binding=function(e){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},{}],"p2p-media-loader-shaka":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./engine");r.Engine=n.Engine,r.version="0.1.0"},{"./engine":2}]},{},[1]);
window.p2pml||(window.p2pml={}),window.p2pml.shaka=e("p2p-media-loader-shaka")},{"p2p-media-loader-shaka":"p2p-media-loader-shaka"}],2:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var s=e("events"),o=e("p2p-media-loader-core"),a=e("./segment-manager"),u=e("./integration"),c=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.loader=new o.HybridLoader(e.loader),n.segmentManager=new a.SegmentManager(n.loader,e.segments),Object.keys(o.Events).map(function(e){return o.Events[e]}).forEach(function(r){return n.loader.on(r,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.emit.apply(n,[r].concat(e))})}),n}return i(e,t),e.isSupported=function(){return o.HybridLoader.isSupported()},e.prototype.destroy=function(){this.loader.destroy(),this.segmentManager.destroy()},e.prototype.getSettings=function(){return{segments:this.segmentManager.getSettings(),loader:this.loader.getSettings()}},e.prototype.initShakaPlayer=function(e){u.initShakaPlayer(e,this.segmentManager)},e}(s.EventEmitter);r.Engine=c},{"./integration":3,"./segment-manager":6,events:10,"p2p-media-loader-core":void 0}],3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("debug"),s=e("./manifest-parser-proxy"),l=e("./utils"),f=n("p2pml:shaka:index");function o(e,t,r){if(!t.p2pml||r!==shaka.net.NetworkingEngine.RequestType.SEGMENT)return shaka.net.HttpXHRPlugin(e,t,r);var n=t.p2pml,i=n.player,s=n.segmentManager,o=i.getManifest();if(!o||!o.p2pml)return shaka.net.HttpXHRPlugin(e,t,r);var a=o.p2pml.parser.find(e,t.headers.Range);if(!a||"video"!==a.streamType)return shaka.net.HttpXHRPlugin(e,t,r);var u=null;f("request","load",a.identity);var c=new Promise(function(t,e){u=e,s.load(a,l.getSchemedUri(i.getManifestUri()),h(i)).then(function(e){return t({data:e})})});return new shaka.util.AbortableOperation(c,function(){return f("request","abort",a.identity),u(new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.OPERATION_ABORTED))})}function h(e){var t=0,r=e.getPlayheadTimeAsDate();return r&&(t=r.valueOf(),e.isLive()&&(t-=e.getPresentationStartTimeAsDate().valueOf()),t/=1e3),t}r.initShakaPlayer=function(r,n){f("register parser proxies"),shaka.media.ManifestParser.registerParserByExtension("mpd",s.ShakaDashManifestParserProxy),shaka.media.ManifestParser.registerParserByMime("application/dash+xml",s.ShakaDashManifestParserProxy),shaka.media.ManifestParser.registerParserByExtension("m3u8",s.ShakaHlsManifestParserProxy),shaka.media.ManifestParser.registerParserByMime("application/x-mpegurl",s.ShakaHlsManifestParserProxy),shaka.media.ManifestParser.registerParserByMime("application/vnd.apple.mpegurl",s.ShakaHlsManifestParserProxy),f("init networking engine"),shaka.net.NetworkingEngine.registerScheme("http",o),shaka.net.NetworkingEngine.registerScheme("https",o);var t=0,i=0;r.addEventListener("loading",function(){0<t&&(clearInterval(t),t=0),i=0;var e=r.getManifest();e&&e.p2pml&&e.p2pml.parser.reset(),n.destroy(),t=setInterval(function(){var e=h(r);(e!==i||r.isBuffering())&&(n.setPlayheadTime(e),i=e)},500)}),f("register request filter"),r.getNetworkingEngine().registerRequestFilter(function(e,t){t.p2pml={player:r,segmentManager:n}})}},{"./manifest-parser-proxy":4,"./utils":7,debug:8}],4:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var s=e("./parser-segment"),o=function(){function e(e){this.cache=new s.ParserSegmentCache(200),this.originalManifestParser=e}return e.prototype.isHls=function(){return this.originalManifestParser instanceof shaka.hls.HlsParser},e.prototype.isDash=function(){return this.originalManifestParser instanceof shaka.dash.DashParser},e.prototype.start=function(e,t){var a=this;return this.originalManifestParser.start(e,t).then(function(e){for(var t=0,r=(a.manifest=e).periods;t<r.length;t++)for(var n=[],i=0,s=r[t].variants;i<s.length;i++){var o=s[i];null!=o.video&&-1==n.indexOf(o.video)&&(a.hookGetSegmentReference(o.video),n.push(o.video)),null!=o.audio&&-1==n.indexOf(o.audio)&&(a.hookGetSegmentReference(o.audio),n.push(o.audio))}return e.p2pml={parser:a},e})},e.prototype.configure=function(e){return this.originalManifestParser.configure(e)},e.prototype.stop=function(){return this.originalManifestParser.stop()},e.prototype.update=function(){return this.originalManifestParser.update()},e.prototype.onExpirationUpdated=function(){return this.originalManifestParser.onExpirationUpdated()},e.prototype.find=function(e,t){return this.cache.find(e,t)},e.prototype.reset=function(){this.cache.clear()},e.prototype.hookGetSegmentReference=function(t){var r=this;t.getSegmentReferenceOriginal=t.getSegmentReference,t.getSegmentReference=function(e){return r.cache.add(t,e),t.getSegmentReferenceOriginal(e)},t.getPosition=function(){return r.isHls()&&"video"===t.type?r.manifest.periods[0].variants.reduce(function(e,t){return t.video&&t.video.id&&!e.includes(t.video.id)&&e.push(t.video.id),e},[]).indexOf(t.id):-1}},e}(),a=function(e){function t(){return e.call(this,new shaka.dash.DashParser)||this}return i(t,e),t}(r.ShakaManifestParserProxy=o);r.ShakaDashManifestParserProxy=a;var u=function(e){function t(){return e.call(this,new shaka.hls.HlsParser)||this}return i(t,e),t}(o);r.ShakaHlsManifestParserProxy=u},{"./parser-segment":5}],5:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var g=e("./utils"),n=function(){function d(e,t,r,n,i,s,o,a,u,c,l,f){this.streamId=e,this.streamType=t,this.streamPosition=r,this.streamIdentity=n,this.identity=i,this.position=s,this.start=o,this.end=a,this.uri=u,this.range=c,this.prev=l,this.next=f}return d.create=function(e,t){var r=e.getSegmentReferenceOriginal(t);if(r){var n=r.createUris();if(n&&0!==n.length){var i=r.getStartTime(),s=r.getEndTime(),o=r.getStartByte(),a=r.getEndByte(),u=o||a?"bytes="+(o||"")+"-"+(a||""):void 0,c=e.type.substring(0,1).toUpperCase(),l=e.getPosition(),f=0<=l,h=f?""+c+l:""+c+e.id,p=f?h+"+"+t:h+"+"+Number(i).toFixed(3);return new d(e.id,e.type,l,h,p,t,i,s,g.getSchemedUri(n[0]),u,function(){return d.create(e,t-1)},function(){return d.create(e,t+1)})}}},d}();r.ParserSegment=n;var i=function(){function e(e){this.segments=[],this.maxSegments=e}return e.prototype.find=function(t,r){return this.segments.find(function(e){return e.uri===t&&e.range===r})},e.prototype.add=function(e,t){var r=n.create(e,t);r&&!this.find(r.uri,r.range)&&(this.segments.push(r),this.segments.length>this.maxSegments&&this.segments.splice(0,.2*this.maxSegments))},e.prototype.clear=function(){this.segments.splice(0)},e}();r.ParserSegmentCache=i},{"./utils":7}],6:[function(e,t,r){"use strict";var n=this&&this.__awaiter||function(s,o,a,u){return new(a||(a=Promise))(function(e,t){function r(e){try{i(u.next(e))}catch(e){t(e)}}function n(e){try{i(u.throw(e))}catch(e){t(e)}}function i(t){t.done?e(t.value):new a(function(e){e(t.value)}).then(r,n)}i((u=u.apply(s,o||[])).next())})},a=this&&this.__generator||function(r,n){var i,s,o,e,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,s&&(o=2&t[0]?s.return:t[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,t[1])).done)return o;switch(s=0,o&&(t=[2&t[0],o.value]),t[0]){case 0:case 1:o=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,s=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(o=0<(o=a.trys).length&&o[o.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!o||t[1]>o[0]&&t[1]<o[3])){a.label=t[1];break}if(6===t[0]&&a.label<o[1]){a.label=o[1],o=t;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(t);break}o[2]&&a.ops.pop(),a.trys.pop();continue}t=n.call(r,a)}catch(e){t=[6,e],s=0}finally{i=o=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}};Object.defineProperty(r,"__esModule",{value:!0});var i=e("debug"),u=e("p2p-media-loader-core"),s={forwardSegmentCount:20,maxHistorySegments:50,swarmId:void 0},o=function(){function e(e,t){void 0===t&&(t={});var r=this;this.debug=i("p2pml:shaka:sm"),this.requests=new Map,this.manifestUri="",this.playheadTime=0,this.segmentHistory=[],this.onSegmentLoaded=function(e){r.requests.has(e.id)&&(r.reportSuccess(r.requests.get(e.id),e),r.debug("request delete",e.id),r.requests.delete(e.id))},this.onSegmentError=function(e,t){r.requests.has(e.id)&&(r.reportError(r.requests.get(e.id),t),r.debug("request delete from error",e.id),r.requests.delete(e.id))},this.onSegmentAbort=function(e){r.requests.has(e.id)&&(r.reportError(r.requests.get(e.id),"Internal abort"),r.debug("request delete from abort",e.id),r.requests.delete(e.id))},this.settings=Object.assign(s,t),this.loader=e,this.loader.on(u.Events.SegmentLoaded,this.onSegmentLoaded),this.loader.on(u.Events.SegmentError,this.onSegmentError),this.loader.on(u.Events.SegmentAbort,this.onSegmentAbort)}return e.prototype.destroy=function(){0!==this.requests.size&&(console.error("Destroying segment manager with active request(s)!"),this.requests.clear()),this.playheadTime=0,this.segmentHistory.splice(0),this.loader.destroy()},e.prototype.getSettings=function(){return this.settings},e.prototype.load=function(t,r,o){return n(this,void 0,void 0,function(){var n,i,s=this;return a(this,function(e){return this.manifestUri=r,this.playheadTime=o,this.pushSegmentHistory(t),n=this.refreshLoad(),i=this.loader.getSegment(n.id),[2,new Promise(function(e,t){var r=new c(n.id,e,t);i?s.reportSuccess(r,i):(s.debug("request add",r.id),s.requests.set(r.id,r))})]})})},e.prototype.setPlayheadTime=function(e){this.playheadTime=e,0<this.segmentHistory.length&&this.refreshLoad()},e.prototype.refreshLoad=function(){var e=this.segmentHistory[this.segmentHistory.length-1],r=.1<this.playheadTime?this.playheadTime:e.start,t=this.segmentHistory.reduce(function(e,t){return t.start>=r&&e.push(t),e},[]);0===t.length&&t.push(e);var n=t.length-1;do{var i=t[t.length-1].next();if(!i)break;t.push(i)}while(t.length<this.settings.forwardSegmentCount);var s=this.settings.swarmId&&0!==this.settings.swarmId.length?this.settings.swarmId:this.manifestUri.split("?")[0],o=t.map(function(e,t){return new u.Segment(s+"+"+e.identity,e.uri,e.range,t)});return this.loader.load(o,s+"+"+e.streamIdentity),o[n]},e.prototype.pushSegmentHistory=function(e){this.segmentHistory.length>=this.settings.maxHistorySegments&&(this.debug("segment history auto shrink"),this.segmentHistory.splice(0,.2*this.settings.maxHistorySegments)),0<this.segmentHistory.length&&this.segmentHistory[this.segmentHistory.length-1].start>e.start&&(this.debug("segment history reset due to playhead seek back"),this.segmentHistory.splice(0)),this.segmentHistory.push(e)},e.prototype.reportSuccess=function(e,t){var r=this;if(e.resolve){var n=0;if(0<t.downloadSpeed&&t.data&&0<t.data.byteLength){var i=Math.trunc(t.data.byteLength/t.downloadSpeed);n=Date.now()-e.timeCreated+i}setTimeout(function(){r.debug("report success",e.id),e.resolve(t.data)},n)}},e.prototype.reportError=function(e,t){e.reject&&(this.debug("report error",e.id),e.reject(t))},e}();r.SegmentManager=o;var c=function(e,t,r){this.id=e,this.resolve=t,this.reject=r,this.timeCreated=Date.now()}},{debug:8,"p2p-media-loader-core":void 0}],7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getSchemedUri=function(e){return e.startsWith("//")?window.location.protocol+e:e}},{}],8:[function(r,n,s){(function(t){function e(){var e;try{e=s.storage.debug}catch(e){}return!e&&void 0!==t&&"env"in t&&(e=t.env.DEBUG),e}(s=n.exports=r("./debug")).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},s.formatArgs=function(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+s.humanize(this.diff),!t)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(n++,"%c"===e&&(i=n))}),e.splice(i,0,r)},s.save=function(e){try{null==e?s.storage.removeItem("debug"):s.storage.debug=e}catch(e){}},s.load=e,s.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},s.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),s.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],s.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},s.enable(e())}).call(this,r("_process"))},{"./debug":9,_process:12}],9:[function(e,t,u){function r(e){var n;function a(){if(a.enabled){var i=a,e=+new Date,t=e-(n||e);i.diff=t,i.prev=n,i.curr=e,n=e;for(var s=new Array(arguments.length),r=0;r<s.length;r++)s[r]=arguments[r];s[0]=u.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var o=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,function(e,t){if("%%"===e)return e;o++;var r=u.formatters[t];if("function"==typeof r){var n=s[o];e=r.call(i,n),s.splice(o,1),o--}return e}),u.formatArgs.call(i,s),(a.log||u.log||console.log.bind(console)).apply(i,s)}}return a.namespace=e,a.enabled=u.enabled(e),a.useColors=u.useColors(),a.color=function(e){var t,r=0;for(t in e)r=(r<<5)-r+e.charCodeAt(t),r|=0;return u.colors[Math.abs(r)%u.colors.length]}(e),a.destroy=i,"function"==typeof u.init&&u.init(a),u.instances.push(a),a}function i(){var e=u.instances.indexOf(this);return-1!==e&&(u.instances.splice(e,1),!0)}(u=t.exports=r.debug=r.default=r).coerce=function(e){return e instanceof Error?e.stack||e.message:e},u.disable=function(){u.enable("")},u.enable=function(e){var t;u.save(e),u.names=[],u.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),n=r.length;for(t=0;t<n;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?u.skips.push(new RegExp("^"+e.substr(1)+"$")):u.names.push(new RegExp("^"+e+"$")));for(t=0;t<u.instances.length;t++){var i=u.instances[t];i.enabled=u.enabled(i.namespace)}},u.enabled=function(e){if("*"===e[e.length-1])return!0;var t,r;for(t=0,r=u.skips.length;t<r;t++)if(u.skips[t].test(e))return!1;for(t=0,r=u.names.length;t<r;t++)if(u.names[t].test(e))return!0;return!1},u.humanize=e("ms"),u.instances=[],u.names=[],u.skips=[],u.formatters={}},{ms:11}],10:[function(e,t,r){var u=Object.create||function(e){var t=function(){};return t.prototype=e,new t},o=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return r},s=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};function n(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=u(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}((t.exports=n).EventEmitter=n).prototype._events=void 0,n.prototype._maxListeners=void 0;var i,a=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),i=0===c.x}catch(e){i=!1}function l(e){return void 0===e._maxListeners?n.defaultMaxListeners:e._maxListeners}function f(e,t,r,n){var i,s,o;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]):(s=e._events=u(null),e._eventsCount=0),o){if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(i=l(e))&&0<i&&o.length>i){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=o.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",a.name,a.message)}}else o=s[t]=r,++e._eventsCount;return e}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function p(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=s.call(h,n);return i.listener=r,n.wrapFn=i}function d(e,t,r){var n=e._events;if(!n)return[];var i=n[t];return i?"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):m(i,i.length):[]}function g(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function m(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}i?Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');a=e}}):n.defaultMaxListeners=a,n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},n.prototype.getMaxListeners=function(){return l(this)},n.prototype.emit=function(e){var t,r,n,i,s,o,a="error"===e;if(o=this._events)a=a&&null==o.error;else if(!a)return!1;if(a){if(1<arguments.length&&(t=arguments[1]),t instanceof Error)throw t;var u=new Error('Unhandled "error" event. ('+t+")");throw u.context=t,u}if(!(r=o[e]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=m(e,n),s=0;s<n;++s)i[s].call(r)}(r,c,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,s=m(e,i),o=0;o<i;++o)s[o].call(r,n)}(r,c,this,arguments[1]);break;case 3:!function(e,t,r,n,i){if(t)e.call(r,n,i);else for(var s=e.length,o=m(e,s),a=0;a<s;++a)o[a].call(r,n,i)}(r,c,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,i,s){if(t)e.call(r,n,i,s);else for(var o=e.length,a=m(e,o),u=0;u<o;++u)a[u].call(r,n,i,s)}(r,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),s=1;s<n;s++)i[s-1]=arguments[s];!function(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,s=m(e,i),o=0;o<i;++o)s[o].apply(r,n)}(r,c,this,i)}return!0},n.prototype.on=n.prototype.addListener=function(e,t){return f(this,e,t,!1)},n.prototype.prependListener=function(e,t){return f(this,e,t,!0)},n.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,p(this,e,t)),this},n.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,p(this,e,t)),this},n.prototype.removeListener=function(e,t){var r,n,i,s,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=u(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length-1;0<=s;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),n.removeListener&&this.emit("removeListener",e,o||t)}return this},n.prototype.removeAllListeners=function(e){var t,r,n;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=u(null),this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=u(null):delete r[e]),this;if(0===arguments.length){var i,s=o(r);for(n=0;n<s.length;++n)"removeListener"!==(i=s[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=u(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)for(n=t.length-1;0<=n;n--)this.removeListener(e,t[n]);return this},n.prototype.listeners=function(e){return d(this,e,!0)},n.prototype.rawListeners=function(e){return d(this,e,!1)},n.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},n.prototype.listenerCount=g,n.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]}},{}],11:[function(e,t,r){var i=36e5,s=864e5;function o(e,t,r){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}t.exports=function(e,t){t=t||{};var r,n=typeof e;if("string"===n&&0<e.length)return function(e){if(100<(e=String(e)).length)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*i;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*r;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?o(r=e,s,"day")||o(r,i,"hour")||o(r,6e4,"minute")||o(r,1e3,"second")||r+" ms":function(e){if(s<=e)return Math.round(e/s)+"d";if(i<=e)return Math.round(e/i)+"h";if(6e4<=e)return Math.round(e/6e4)+"m";if(1e3<=e)return Math.round(e/1e3)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],12:[function(e,t,r){var n,i,s=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(e){i=a}}();var c,l=[],f=!1,h=-1;function p(){f&&c&&(f=!1,c.length?l=c.concat(l):h=-1,l.length&&d())}function d(){if(!f){var e=u(p);f=!0;for(var t=l.length;t;){for(c=l,l=[];++h<t;)c&&c[h].run();h=-1,t=l.length}c=null,f=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(e)}}function g(e,t){this.fun=e,this.array=t}function m(){}s.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new g(e,t)),1!==l.length||f||u(d)},g.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(e){return[]},s.binding=function(e){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},{}],"p2p-media-loader-shaka":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./engine");r.Engine=n.Engine,r.version="0.2.0"},{"./engine":2}]},{},[1]);

@@ -18,5 +18,8 @@ "use strict";

var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -23,0 +26,0 @@ extendStatics(d, b);

@@ -18,5 +18,8 @@ "use strict";

var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -23,0 +26,0 @@ extendStatics(d, b);

@@ -48,3 +48,8 @@ /**

maxHistorySegments: number;
/**
* Override default swarm ID that is used to identify unique media stream with trackers (manifest URL without
* query parameters is used as the swarm ID if the parameter is not specified)
*/
swarmId: string | undefined;
}
export {};

@@ -57,3 +57,4 @@ "use strict";

forwardSegmentCount: 20,
maxHistorySegments: 50
maxHistorySegments: 50,
swarmId: undefined,
};

@@ -159,7 +160,8 @@ var SegmentManager = /** @class */ (function () {

} while (sequence.length < this.settings.forwardSegmentCount);
var manifestUriNoQuery = this.manifestUri.split("?")[0];
var masterSwarmId = (this.settings.swarmId && (this.settings.swarmId.length !== 0)) ?
this.settings.swarmId : this.manifestUri.split("?")[0];
var loaderSegments = sequence.map(function (s, i) {
return new p2p_media_loader_core_1.Segment(manifestUriNoQuery + "+" + s.identity, s.uri, s.range, i);
return new p2p_media_loader_core_1.Segment(masterSwarmId + "+" + s.identity, s.uri, s.range, i);
});
this.loader.load(loaderSegments, manifestUriNoQuery + "+" + lastRequestedSegment.streamIdentity);
this.loader.load(loaderSegments, masterSwarmId + "+" + lastRequestedSegment.streamIdentity);
return loaderSegments[lastRequestedSegmentIndex];

@@ -166,0 +168,0 @@ };

{
"name": "p2p-media-loader-shaka",
"description": "P2P Media Loader Shaka Player integration",
"version": "0.1.0",
"version": "0.2.0",
"license": "Apache-2.0",

@@ -25,7 +25,8 @@ "author": "Novage",

"scripts": {
"compile": "rimraf ./dist && tsc && copyfiles -f ./lib/*.js ./dist && rimraf ./build && mkdirp ./build",
"browserify": "browserify -r ./dist/index.js:p2p-media-loader-shaka ./dist/browser-init.js --exclude p2p-media-loader-core > ./build/p2p-media-loader-shaka.js",
"compile": "tsc && copyfiles -f ./lib/*.js ./dist",
"browserify": "mkdirp ./build && browserify -r ./dist/index.js:p2p-media-loader-shaka ./dist/browser-init.js --exclude p2p-media-loader-core > ./build/p2p-media-loader-shaka.js",
"minify": "uglifyjs ./build/p2p-media-loader-shaka.js -m -c --comments > ./build/p2p-media-loader-shaka.min.js",
"refresh-dependencies": "copyfiles -f ./node_modules/p2p-media-loader-core/build/p2p-media-loader-core*.js ./demo",
"build": "npm run compile && npm run browserify && npm run minify && npm run refresh-dependencies",
"build": "npm run compile && npm run browserify && npm run minify",
"webpack:build": "webpack --progress",
"webpack:watch": "webpack --watch --progress",
"lint": "tslint -c ./tslint.json -p ./tsconfig.test.json",

@@ -39,21 +40,23 @@ "test": "mocha -r ts-node/register test/*.test.ts"

"dependencies": {
"p2p-media-loader-core": "^0.1.0"
"p2p-media-loader-core": "^0.2.0"
},
"devDependencies": {
"@types/debug": "^0.0.30",
"@types/debug": "^0.0.31",
"@types/mocha": "^5.2.5",
"@types/node": "^10.5.4",
"@types/sinon": "^5.0.1",
"browserify": "^16.2.2",
"@types/node": "^10.12.9",
"@types/sinon": "^5.0.5",
"browserify": "^16.2.3",
"browserify-versionify": "^1.0.6",
"copyfiles": "^2.0.0",
"copyfiles": "^2.1.0",
"mkdirp": "^0.5.1",
"mocha": "^5.2.0",
"rimraf": "^2.6.1",
"sinon": "^6.1.4",
"ts-mockito": "^2.2.9",
"ts-node": "^7.0.0",
"tslint": "^5.5.0",
"typescript": "^2.7.1",
"uglify-js": "^3.3.9"
"sinon": "^7.1.1",
"ts-loader": "^5.3.0",
"ts-mockito": "^2.3.1",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"typescript": "^3.1.6",
"uglify-js": "^3.4.9",
"webpack": "^4.25.1",
"webpack-cli": "^3.1.2"
},

@@ -60,0 +63,0 @@ "browserify": {

# P2P Media Loader - Shaka Player integration
[![npm version](https://badge.fury.io/js/p2p-media-loader-shaka.svg)](https://npmjs.com/package/p2p-media-loader-shaka)
P2P sharing of segmented media streams (i.e. HLS, DASH) using WebRTC for [Shaka Player](https://github.com/google/shaka-player)

@@ -13,3 +15,3 @@

- [Hls.js integration](https://cdn.jsdelivr.net/npm/p2p-media-loader-hlsjs@latest/build/)
## Basic usage

@@ -33,3 +35,3 @@

<script src="https://github.com/videojs/mux.js/releases/download/v4.4.0/mux.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/2.4.2/shaka-player.compiled.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/2.4.4/shaka-player.compiled.js"></script>
</head>

@@ -83,4 +85,5 @@ <body>

+ `maxHistorySegments` - Maximum amount of requested segments manager should remember; used to build up sequence with correct priorities for P2P sharing. Default is 50;
+ `swarmId` - Override default swarm ID that is used to identify unique media stream with trackers (manifest URL without query parameters is used as the swarm ID if the parameter is not specified);
- `loader`
+ settings for `HybridLoader` (see _P2P Media Loader Core API_ for details);
+ settings for `HybridLoader` (see [P2P Media Loader Core API](../p2p-media-loader-core/README.md#loader--new-hybridloadersettings) for details);

@@ -87,0 +90,0 @@ ### `engine.getSettings()`

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc