Socket
Socket
Sign inDemoInstall

p2p-media-loader-shaka

Package Overview
Dependencies
51
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.0 to 0.5.0

4

build/p2p-media-loader-shaka.js

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

};
this.settings = Object.assign(defaultSettings, settings);
this.settings = Object.assign({}, defaultSettings, settings);
this.loader = loader;

@@ -586,4 +586,4 @@ this.loader.on(p2p_media_loader_core_1.Events.SegmentLoaded, this.onSegmentLoaded);

exports.Engine = engine_1.Engine;
exports.version = typeof (__P2PML_VERSION__) === "undefined" ? "0.4.0" : __P2PML_VERSION__;
exports.version = typeof (__P2PML_VERSION__) === "undefined" ? "0.5.0" : __P2PML_VERSION__;
},{"./engine":2}]},{},[1]);

@@ -1,1 +0,1 @@

require=function(){return function e(t,s,r){function i(a,o){if(!s[a]){if(!t[a]){var h="function"==typeof require&&require;if(!o&&h)return h(a,!0);if(n)return n(a,!0);var d=new Error("Cannot find module '"+a+"'");throw d.code="MODULE_NOT_FOUND",d}var g=s[a]={exports:{}};t[a][0].call(g.exports,function(e){return i(t[a][1][e]||e)},g,g.exports,e,t,s,r)}return s[a].exports}for(var n="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}}()({1:[function(e,t,s){window.p2pml||(window.p2pml={}),window.p2pml.shaka=e("p2p-media-loader-shaka")},{"p2p-media-loader-shaka":"p2p-media-loader-shaka"}],2:[function(e,t,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=e("events"),i=e("p2p-media-loader-core"),n=e("./segment-manager"),a=e("./integration");s.Engine=class extends r.EventEmitter{static isSupported(){return i.HybridLoader.isSupported()}constructor(e={}){super(),this.loader=new i.HybridLoader(e.loader),this.segmentManager=new n.SegmentManager(this.loader,e.segments),Object.keys(i.Events).map(e=>i.Events[e]).forEach(e=>this.loader.on(e,(...t)=>this.emit(e,...t)))}destroy(){this.loader.destroy(),this.segmentManager.destroy()}getSettings(){return{segments:this.segmentManager.getSettings(),loader:this.loader.getSettings()}}getDetails(){return{loader:this.loader.getDetails()}}initShakaPlayer(e){a.initShakaPlayer(e,this.segmentManager)}}},{"./integration":3,"./segment-manager":6,events:"events","p2p-media-loader-core":"p2p-media-loader-core"}],3:[function(e,t,s){"use strict";var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))(function(i,n){function a(e){try{h(r.next(e))}catch(e){n(e)}}function o(e){try{h(r.throw(e))}catch(e){n(e)}}function h(e){e.done?i(e.value):new s(function(t){t(e.value)}).then(a,o)}h((r=r.apply(e,t||[])).next())})};Object.defineProperty(s,"__esModule",{value:!0});const i=e("debug"),n=e("./manifest-parser-proxy"),a=e("./utils"),o=i("p2pml:shaka:index");function h(e,t,s){if(!t.p2pml||s!==shaka.net.NetworkingEngine.RequestType.SEGMENT)return shaka.net.HttpXHRPlugin(e,t,s);const{player:i,segmentManager:n}=t.p2pml,h=i.getManifest();if(!h||!h.p2pml)return shaka.net.HttpXHRPlugin(e,t,s);const g=h.p2pml.parser.find(e,t.headers.Range);if(!g||"video"!==g.streamType)return shaka.net.HttpXHRPlugin(e,t,s);o("request","load",g.identity);const u=n.load(g,a.getSchemedUri(i.getManifestUri()),d(i));return new shaka.util.AbortableOperation(u,()=>r(this,void 0,void 0,function*(){o("request","abort",g.identity)}))}function d(e){let t=0;const s=e.getPlayheadTimeAsDate();return s&&(t=s.valueOf(),e.isLive()&&(t-=e.getPresentationStartTimeAsDate().valueOf()),t/=1e3),t}s.initShakaPlayer=function(e,t){o("register parser proxies"),shaka.media.ManifestParser.registerParserByExtension("mpd",n.ShakaDashManifestParserProxy),shaka.media.ManifestParser.registerParserByMime("application/dash+xml",n.ShakaDashManifestParserProxy),shaka.media.ManifestParser.registerParserByExtension("m3u8",n.ShakaHlsManifestParserProxy),shaka.media.ManifestParser.registerParserByMime("application/x-mpegurl",n.ShakaHlsManifestParserProxy),shaka.media.ManifestParser.registerParserByMime("application/vnd.apple.mpegurl",n.ShakaHlsManifestParserProxy),o("init networking engine"),shaka.net.NetworkingEngine.registerScheme("http",h),shaka.net.NetworkingEngine.registerScheme("https",h);let s=0,r=0;e.addEventListener("loading",()=>{s>0&&(clearInterval(s),s=0),r=0;const i=e.getManifest();i&&i.p2pml&&i.p2pml.parser.reset(),t.destroy(),s=setInterval(()=>{const s=d(e);(s!==r||e.isBuffering())&&(t.setPlayheadTime(s),r=s)},500)}),o("register request filter"),e.getNetworkingEngine().registerRequestFilter((s,r)=>{r.p2pml={player:e,segmentManager:t}})}},{"./manifest-parser-proxy":4,"./utils":7,debug:"debug"}],4:[function(e,t,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=e("./parser-segment");class i{constructor(e){this.cache=new r.ParserSegmentCache(200),this.originalManifestParser=e}isHls(){return this.originalManifestParser instanceof shaka.hls.HlsParser}isDash(){return this.originalManifestParser instanceof shaka.dash.DashParser}start(e,t){return this.originalManifestParser.start(e,t).then(e=>{this.manifest=e;for(const t of e.periods){const e=[];for(const s of t.variants)null!=s.video&&-1==e.indexOf(s.video)&&(this.hookGetSegmentReference(s.video),e.push(s.video)),null!=s.audio&&-1==e.indexOf(s.audio)&&(this.hookGetSegmentReference(s.audio),e.push(s.audio))}return e.p2pml={parser:this},e})}configure(e){return this.originalManifestParser.configure(e)}stop(){return this.originalManifestParser.stop()}update(){return this.originalManifestParser.update()}onExpirationUpdated(){return this.originalManifestParser.onExpirationUpdated()}find(e,t){return this.cache.find(e,t)}reset(){this.cache.clear()}hookGetSegmentReference(e){e.getSegmentReferenceOriginal=e.getSegmentReference,e.getSegmentReference=(t=>(this.cache.add(e,t),e.getSegmentReferenceOriginal(t))),e.getPosition=(()=>this.isHls()&&"video"===e.type?this.manifest.periods[0].variants.reduce((e,t)=>(t.video&&t.video.id&&!e.includes(t.video.id)&&e.push(t.video.id),e),[]).indexOf(e.id):-1)}}s.ShakaManifestParserProxy=i;s.ShakaDashManifestParserProxy=class extends i{constructor(){super(new shaka.dash.DashParser)}};s.ShakaHlsManifestParserProxy=class extends i{constructor(){super(new shaka.hls.HlsParser)}}},{"./parser-segment":5}],5:[function(e,t,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=e("./utils");class i{constructor(e,t,s,r,i,n,a,o,h,d,g,u){this.streamId=e,this.streamType=t,this.streamPosition=s,this.streamIdentity=r,this.identity=i,this.position=n,this.start=a,this.end=o,this.uri=h,this.range=d,this.prev=g,this.next=u}static create(e,t){const s=e.getSegmentReferenceOriginal(t);if(!s)return;const n=s.createUris();if(!n||0===n.length)return;const a=s.getStartTime(),o=s.getEndTime(),h=s.getStartByte(),d=s.getEndByte(),g=h||d?`bytes=${h||""}-${d||""}`:void 0,u=e.type.substring(0,1).toUpperCase(),l=e.getPosition(),c=l>=0,m=c?`${u}${l}`:`${u}${e.id}`,p=c?`${m}+${t}`:`${m}+${Number(a).toFixed(3)}`;return new i(e.id,e.type,l,m,p,t,a,o,r.getSchemedUri(n[0]),g,()=>i.create(e,t-1),()=>i.create(e,t+1))}}s.ParserSegment=i;s.ParserSegmentCache=class{constructor(e){this.segments=[],this.maxSegments=e}find(e,t){return this.segments.find(s=>s.uri===e&&s.range===t)}add(e,t){const s=i.create(e,t);s&&!this.find(s.uri,s.range)&&(this.segments.push(s),this.segments.length>this.maxSegments&&this.segments.splice(0,.2*this.maxSegments))}clear(){this.segments.splice(0)}}},{"./utils":7}],6:[function(e,t,s){"use strict";var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))(function(i,n){function a(e){try{h(r.next(e))}catch(e){n(e)}}function o(e){try{h(r.throw(e))}catch(e){n(e)}}function h(e){e.done?i(e.value):new s(function(t){t(e.value)}).then(a,o)}h((r=r.apply(e,t||[])).next())})};Object.defineProperty(s,"__esModule",{value:!0});const i=e("debug"),n=e("p2p-media-loader-core"),a={forwardSegmentCount:20,maxHistorySegments:50,swarmId:void 0};s.SegmentManager=class{constructor(e,t={}){this.debug=i("p2pml:shaka:sm"),this.requests=new Map,this.manifestUri="",this.playheadTime=0,this.segmentHistory=[],this.onSegmentLoaded=(e=>{this.requests.has(e.id)&&(this.reportSuccess(this.requests.get(e.id),e),this.debug("request delete",e.id),this.requests.delete(e.id))}),this.onSegmentError=((e,t)=>{this.requests.has(e.id)&&(this.reportError(this.requests.get(e.id),t),this.debug("request delete from error",e.id),this.requests.delete(e.id))}),this.onSegmentAbort=(e=>{this.requests.has(e.id)&&(this.reportError(this.requests.get(e.id),"Internal abort"),this.debug("request delete from abort",e.id),this.requests.delete(e.id))}),this.settings=Object.assign(a,t),this.loader=e,this.loader.on(n.Events.SegmentLoaded,this.onSegmentLoaded),this.loader.on(n.Events.SegmentError,this.onSegmentError),this.loader.on(n.Events.SegmentAbort,this.onSegmentAbort)}destroy(){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()}getSettings(){return this.settings}load(e,t,s){return r(this,void 0,void 0,function*(){this.manifestUri=t,this.playheadTime=s,this.pushSegmentHistory(e);const r=this.refreshLoad(),i=this.loader.getSegment(r.id);return new Promise((e,t)=>{const s=new o(r.id,e,t);i?this.reportSuccess(s,i):(this.debug("request add",s.id),this.requests.set(s.id,s))})})}setPlayheadTime(e){this.playheadTime=e,this.segmentHistory.length>0&&this.refreshLoad()}refreshLoad(){const e=this.segmentHistory[this.segmentHistory.length-1],t=this.playheadTime>.1?this.playheadTime:e.start,s=this.segmentHistory.reduce((e,s)=>(s.start>=t&&e.push(s),e),[]);0===s.length&&s.push(e);const r=s.length-1;do{const e=s[s.length-1].next();if(!e)break;s.push(e)}while(s.length<this.settings.forwardSegmentCount);const i=this.settings.swarmId&&0!==this.settings.swarmId.length?this.settings.swarmId:this.manifestUri.split("?")[0],a=s.map((e,t)=>new n.Segment(`${i}+${e.identity}`,e.uri,e.range,t));return this.loader.load(a,`${i}+${e.streamIdentity}`),a[r]}pushSegmentHistory(e){this.segmentHistory.length>=this.settings.maxHistorySegments&&(this.debug("segment history auto shrink"),this.segmentHistory.splice(0,.2*this.settings.maxHistorySegments)),this.segmentHistory.length>0&&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)}reportSuccess(e,t){let s=void 0;t.downloadSpeed>0&&t.data&&t.data.byteLength>0&&(s=Math.trunc(t.data.byteLength/t.downloadSpeed)),this.debug("report success",e.id),e.resolve({data:t.data,timeMs:s})}reportError(e,t){e.reject&&(this.debug("report error",e.id),e.reject(t))}};class o{constructor(e,t,s){this.id=e,this.resolve=t,this.reject=s}}},{debug:"debug","p2p-media-loader-core":"p2p-media-loader-core"}],7:[function(e,t,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0}),s.getSchemedUri=function(e){return e.startsWith("//")?window.location.protocol+e:e}},{}],"p2p-media-loader-shaka":[function(e,t,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var r=e("./engine");s.Engine=r.Engine,s.version="undefined"==typeof __P2PML_VERSION__?"0.4.0":__P2PML_VERSION__},{"./engine":2}]},{},[1]);
require=function(){return function e(t,s,r){function i(a,o){if(!s[a]){if(!t[a]){var h="function"==typeof require&&require;if(!o&&h)return h(a,!0);if(n)return n(a,!0);var d=new Error("Cannot find module '"+a+"'");throw d.code="MODULE_NOT_FOUND",d}var g=s[a]={exports:{}};t[a][0].call(g.exports,function(e){return i(t[a][1][e]||e)},g,g.exports,e,t,s,r)}return s[a].exports}for(var n="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}}()({1:[function(e,t,s){window.p2pml||(window.p2pml={}),window.p2pml.shaka=e("p2p-media-loader-shaka")},{"p2p-media-loader-shaka":"p2p-media-loader-shaka"}],2:[function(e,t,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=e("events"),i=e("p2p-media-loader-core"),n=e("./segment-manager"),a=e("./integration");s.Engine=class extends r.EventEmitter{static isSupported(){return i.HybridLoader.isSupported()}constructor(e={}){super(),this.loader=new i.HybridLoader(e.loader),this.segmentManager=new n.SegmentManager(this.loader,e.segments),Object.keys(i.Events).map(e=>i.Events[e]).forEach(e=>this.loader.on(e,(...t)=>this.emit(e,...t)))}destroy(){this.loader.destroy(),this.segmentManager.destroy()}getSettings(){return{segments:this.segmentManager.getSettings(),loader:this.loader.getSettings()}}getDetails(){return{loader:this.loader.getDetails()}}initShakaPlayer(e){a.initShakaPlayer(e,this.segmentManager)}}},{"./integration":3,"./segment-manager":6,events:"events","p2p-media-loader-core":"p2p-media-loader-core"}],3:[function(e,t,s){"use strict";var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))(function(i,n){function a(e){try{h(r.next(e))}catch(e){n(e)}}function o(e){try{h(r.throw(e))}catch(e){n(e)}}function h(e){e.done?i(e.value):new s(function(t){t(e.value)}).then(a,o)}h((r=r.apply(e,t||[])).next())})};Object.defineProperty(s,"__esModule",{value:!0});const i=e("debug"),n=e("./manifest-parser-proxy"),a=e("./utils"),o=i("p2pml:shaka:index");function h(e,t,s){if(!t.p2pml||s!==shaka.net.NetworkingEngine.RequestType.SEGMENT)return shaka.net.HttpXHRPlugin(e,t,s);const{player:i,segmentManager:n}=t.p2pml,h=i.getManifest();if(!h||!h.p2pml)return shaka.net.HttpXHRPlugin(e,t,s);const g=h.p2pml.parser.find(e,t.headers.Range);if(!g||"video"!==g.streamType)return shaka.net.HttpXHRPlugin(e,t,s);o("request","load",g.identity);const u=n.load(g,a.getSchemedUri(i.getManifestUri()),d(i));return new shaka.util.AbortableOperation(u,()=>r(this,void 0,void 0,function*(){o("request","abort",g.identity)}))}function d(e){let t=0;const s=e.getPlayheadTimeAsDate();return s&&(t=s.valueOf(),e.isLive()&&(t-=e.getPresentationStartTimeAsDate().valueOf()),t/=1e3),t}s.initShakaPlayer=function(e,t){o("register parser proxies"),shaka.media.ManifestParser.registerParserByExtension("mpd",n.ShakaDashManifestParserProxy),shaka.media.ManifestParser.registerParserByMime("application/dash+xml",n.ShakaDashManifestParserProxy),shaka.media.ManifestParser.registerParserByExtension("m3u8",n.ShakaHlsManifestParserProxy),shaka.media.ManifestParser.registerParserByMime("application/x-mpegurl",n.ShakaHlsManifestParserProxy),shaka.media.ManifestParser.registerParserByMime("application/vnd.apple.mpegurl",n.ShakaHlsManifestParserProxy),o("init networking engine"),shaka.net.NetworkingEngine.registerScheme("http",h),shaka.net.NetworkingEngine.registerScheme("https",h);let s=0,r=0;e.addEventListener("loading",()=>{s>0&&(clearInterval(s),s=0),r=0;const i=e.getManifest();i&&i.p2pml&&i.p2pml.parser.reset(),t.destroy(),s=setInterval(()=>{const s=d(e);(s!==r||e.isBuffering())&&(t.setPlayheadTime(s),r=s)},500)}),o("register request filter"),e.getNetworkingEngine().registerRequestFilter((s,r)=>{r.p2pml={player:e,segmentManager:t}})}},{"./manifest-parser-proxy":4,"./utils":7,debug:"debug"}],4:[function(e,t,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=e("./parser-segment");class i{constructor(e){this.cache=new r.ParserSegmentCache(200),this.originalManifestParser=e}isHls(){return this.originalManifestParser instanceof shaka.hls.HlsParser}isDash(){return this.originalManifestParser instanceof shaka.dash.DashParser}start(e,t){return this.originalManifestParser.start(e,t).then(e=>{this.manifest=e;for(const t of e.periods){const e=[];for(const s of t.variants)null!=s.video&&-1==e.indexOf(s.video)&&(this.hookGetSegmentReference(s.video),e.push(s.video)),null!=s.audio&&-1==e.indexOf(s.audio)&&(this.hookGetSegmentReference(s.audio),e.push(s.audio))}return e.p2pml={parser:this},e})}configure(e){return this.originalManifestParser.configure(e)}stop(){return this.originalManifestParser.stop()}update(){return this.originalManifestParser.update()}onExpirationUpdated(){return this.originalManifestParser.onExpirationUpdated()}find(e,t){return this.cache.find(e,t)}reset(){this.cache.clear()}hookGetSegmentReference(e){e.getSegmentReferenceOriginal=e.getSegmentReference,e.getSegmentReference=(t=>(this.cache.add(e,t),e.getSegmentReferenceOriginal(t))),e.getPosition=(()=>this.isHls()&&"video"===e.type?this.manifest.periods[0].variants.reduce((e,t)=>(t.video&&t.video.id&&!e.includes(t.video.id)&&e.push(t.video.id),e),[]).indexOf(e.id):-1)}}s.ShakaManifestParserProxy=i;s.ShakaDashManifestParserProxy=class extends i{constructor(){super(new shaka.dash.DashParser)}};s.ShakaHlsManifestParserProxy=class extends i{constructor(){super(new shaka.hls.HlsParser)}}},{"./parser-segment":5}],5:[function(e,t,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=e("./utils");class i{constructor(e,t,s,r,i,n,a,o,h,d,g,u){this.streamId=e,this.streamType=t,this.streamPosition=s,this.streamIdentity=r,this.identity=i,this.position=n,this.start=a,this.end=o,this.uri=h,this.range=d,this.prev=g,this.next=u}static create(e,t){const s=e.getSegmentReferenceOriginal(t);if(!s)return;const n=s.createUris();if(!n||0===n.length)return;const a=s.getStartTime(),o=s.getEndTime(),h=s.getStartByte(),d=s.getEndByte(),g=h||d?`bytes=${h||""}-${d||""}`:void 0,u=e.type.substring(0,1).toUpperCase(),l=e.getPosition(),c=l>=0,m=c?`${u}${l}`:`${u}${e.id}`,p=c?`${m}+${t}`:`${m}+${Number(a).toFixed(3)}`;return new i(e.id,e.type,l,m,p,t,a,o,r.getSchemedUri(n[0]),g,()=>i.create(e,t-1),()=>i.create(e,t+1))}}s.ParserSegment=i;s.ParserSegmentCache=class{constructor(e){this.segments=[],this.maxSegments=e}find(e,t){return this.segments.find(s=>s.uri===e&&s.range===t)}add(e,t){const s=i.create(e,t);s&&!this.find(s.uri,s.range)&&(this.segments.push(s),this.segments.length>this.maxSegments&&this.segments.splice(0,.2*this.maxSegments))}clear(){this.segments.splice(0)}}},{"./utils":7}],6:[function(e,t,s){"use strict";var r=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))(function(i,n){function a(e){try{h(r.next(e))}catch(e){n(e)}}function o(e){try{h(r.throw(e))}catch(e){n(e)}}function h(e){e.done?i(e.value):new s(function(t){t(e.value)}).then(a,o)}h((r=r.apply(e,t||[])).next())})};Object.defineProperty(s,"__esModule",{value:!0});const i=e("debug"),n=e("p2p-media-loader-core"),a={forwardSegmentCount:20,maxHistorySegments:50,swarmId:void 0};s.SegmentManager=class{constructor(e,t={}){this.debug=i("p2pml:shaka:sm"),this.requests=new Map,this.manifestUri="",this.playheadTime=0,this.segmentHistory=[],this.onSegmentLoaded=(e=>{this.requests.has(e.id)&&(this.reportSuccess(this.requests.get(e.id),e),this.debug("request delete",e.id),this.requests.delete(e.id))}),this.onSegmentError=((e,t)=>{this.requests.has(e.id)&&(this.reportError(this.requests.get(e.id),t),this.debug("request delete from error",e.id),this.requests.delete(e.id))}),this.onSegmentAbort=(e=>{this.requests.has(e.id)&&(this.reportError(this.requests.get(e.id),"Internal abort"),this.debug("request delete from abort",e.id),this.requests.delete(e.id))}),this.settings=Object.assign({},a,t),this.loader=e,this.loader.on(n.Events.SegmentLoaded,this.onSegmentLoaded),this.loader.on(n.Events.SegmentError,this.onSegmentError),this.loader.on(n.Events.SegmentAbort,this.onSegmentAbort)}destroy(){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()}getSettings(){return this.settings}load(e,t,s){return r(this,void 0,void 0,function*(){this.manifestUri=t,this.playheadTime=s,this.pushSegmentHistory(e);const r=this.refreshLoad(),i=this.loader.getSegment(r.id);return new Promise((e,t)=>{const s=new o(r.id,e,t);i?this.reportSuccess(s,i):(this.debug("request add",s.id),this.requests.set(s.id,s))})})}setPlayheadTime(e){this.playheadTime=e,this.segmentHistory.length>0&&this.refreshLoad()}refreshLoad(){const e=this.segmentHistory[this.segmentHistory.length-1],t=this.playheadTime>.1?this.playheadTime:e.start,s=this.segmentHistory.reduce((e,s)=>(s.start>=t&&e.push(s),e),[]);0===s.length&&s.push(e);const r=s.length-1;do{const e=s[s.length-1].next();if(!e)break;s.push(e)}while(s.length<this.settings.forwardSegmentCount);const i=this.settings.swarmId&&0!==this.settings.swarmId.length?this.settings.swarmId:this.manifestUri.split("?")[0],a=s.map((e,t)=>new n.Segment(`${i}+${e.identity}`,e.uri,e.range,t));return this.loader.load(a,`${i}+${e.streamIdentity}`),a[r]}pushSegmentHistory(e){this.segmentHistory.length>=this.settings.maxHistorySegments&&(this.debug("segment history auto shrink"),this.segmentHistory.splice(0,.2*this.settings.maxHistorySegments)),this.segmentHistory.length>0&&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)}reportSuccess(e,t){let s=void 0;t.downloadSpeed>0&&t.data&&t.data.byteLength>0&&(s=Math.trunc(t.data.byteLength/t.downloadSpeed)),this.debug("report success",e.id),e.resolve({data:t.data,timeMs:s})}reportError(e,t){e.reject&&(this.debug("report error",e.id),e.reject(t))}};class o{constructor(e,t,s){this.id=e,this.resolve=t,this.reject=s}}},{debug:"debug","p2p-media-loader-core":"p2p-media-loader-core"}],7:[function(e,t,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0}),s.getSchemedUri=function(e){return e.startsWith("//")?window.location.protocol+e:e}},{}],"p2p-media-loader-shaka":[function(e,t,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var r=e("./engine");s.Engine=r.Engine,s.version="undefined"==typeof __P2PML_VERSION__?"0.5.0":__P2PML_VERSION__},{"./engine":2}]},{},[1]);

@@ -61,3 +61,3 @@ "use strict";

};
this.settings = Object.assign(defaultSettings, settings);
this.settings = Object.assign({}, defaultSettings, settings);
this.loader = loader;

@@ -64,0 +64,0 @@ this.loader.on(p2p_media_loader_core_1.Events.SegmentLoaded, this.onSegmentLoaded);

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

@@ -40,6 +40,6 @@ "author": "Novage",

"events": "^3.0.0",
"p2p-media-loader-core": "^0.4.0"
"p2p-media-loader-core": "^0.5.0"
},
"devDependencies": {
"@types/debug": "^0.0.31",
"@types/debug": "^4.1.2",
"@types/events": "^3.0.0",

@@ -50,8 +50,8 @@ "browserify": "^16.2.3",

"mkdirp": "^0.5.1",
"terser": "^3.14.1",
"terser": "^3.17.0",
"ts-loader": "^5.3.3",
"tslint": "^5.12.1",
"typescript": "^3.2.4",
"webpack": "^4.29.0",
"webpack-cli": "^3.2.1"
"tslint": "^5.14.0",
"typescript": "^3.3.4000",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0"
},

@@ -58,0 +58,0 @@ "browserify": {

@@ -9,2 +9,3 @@ # P2P Media Loader - Shaka Player integration

- [Demo](http://novage.com.ua/p2p-media-loader/demo.html)
- [FAQ](https://github.com/Novage/p2p-media-loader/blob/master/FAQ.md)
- [Overview](http://novage.com.ua/p2p-media-loader/overview.html)

@@ -11,0 +12,0 @@ - [Technical overview](http://novage.com.ua/p2p-media-loader/technical-overview.html)

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