This repository has been archived on 2022-06-28. You can view files and clone it, but cannot push or open issues or pull requests.
Yotter/app/static/videojs-http-streaming.min.js

8 lines
264 KiB
JavaScript
Raw Normal View History

2020-10-06 21:04:38 +05:30
/*! @name @videojs/http-streaming @version 2.2.1 @license Apache-2.0 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("global/document"),require("global/window"),require("video.js"),require("xmldom")):"function"==typeof define&&define.amd?define(["exports","global/document","global/window","video.js","xmldom"],t):t((e=e||self).httpStreaming={},e.document,e.window,e.videojs,e.window)}(this,(function(e,t,i,n,r){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,i=i&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i,n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;var a=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},s=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function u(e,t){return e(t={exports:{}},t.exports),t.exports}function d(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var l,c=d(u((function(e,t){!function(t){var i=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,n=/^([^\/?#]*)(.*)$/,r=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,s={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var r=s.parseURL(e);if(!r)throw new Error("Error trying to parse base URL.");return r.path=s.normalizePath(r.path),s.buildURLFromParts(r)}var a=s.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return i.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):t;var o=s.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var u=n.exec(o.path);o.netLoc=u[1],o.path=u[2]}o.netLoc&&!o.path&&(o.path="/");var d={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(d.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var l=o.path,c=l.substring(0,l.lastIndexOf("/")+1)+a.path;d.path=s.normalizePath(c)}else d.path=o.path,a.params||(d.params=o.params,a.query||(d.query=o.query));return null===d.path&&(d.path=i.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(d)},parseURL:function(e){var t=i.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(r,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=s}()}))),h=d(i),m=function(e,t){return/^[a-z]+:/i.test(t)?t:(/\/\//i.test(e)||(e=c.buildAbsoluteURL(h.location&&h.location.href||"",e)),c.buildAbsoluteURL(e,t))},f=m,p=function(e,t,i){return e&&i&&i.responseURL&&t!==i.responseURL?i.responseURL:t},g=function(){function e(){this.listeners={}}var t=e.prototype;return t.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},t.off=function(e,t){if(!this.listeners[e])return!1;var i=this.listeners[e].indexOf(t);return this.listeners[e]=this.listeners[e].slice(0),this.listeners[e].splice(i,1),i>-1},t.trigger=function(e){var t=this.listeners[e];if(t)if(2===arguments.length)for(var i=t.length,n=0;n<i;++n)t[n].call(this,arguments[1]);else for(var r=Array.prototype.slice.call(arguments,1),a=t.length,s=0;s<a;++s)t[s].apply(this,r)},t.dispose=function(){this.listeners={}},t.pipe=function(e){this.on("data",(function(t){e.push(t)}))},e}(),y=u((function(e){function t(){return e.exports=t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},t.apply(this,arguments)}e.exports=t})),v=(l=i)&&"object"==typeof l&&"default"in l?l.default:l,_=function(e){for(var t,i=(t=e,v.atob?v.atob(t):Buffer.from(t,"base64").toString("binary")),n=new Uint8Array(i.length),r=0;r<i.length;r++)n[r]=i.charCodeAt(r);re
/*! @name @videojs/http-streaming @version 2.2.1 @license Apache-2.0 */!function(){var e=function(){this.init=function(){var e={};this.on=function(t,i){e[t]||(e[t]=[]),e[t]=e[t].concat(i)},this.off=function(t,i){var n;return!!e[t]&&(n=e[t].indexOf(i),e[t]=e[t].slice(),e[t].splice(n,1),n>-1)},this.trigger=function(t){var i,n,r,a;if(i=e[t])if(2===arguments.length)for(r=i.length,n=0;n<r;++n)i[n].call(this,arguments[1]);else{for(a=[],n=arguments.length,n=1;n<arguments.length;++n)a.push(arguments[n]);for(r=i.length,n=0;n<r;++n)i[n].apply(this,a)}},this.dispose=function(){e={}}}};e.prototype.pipe=function(e){return this.on("data",(function(t){e.push(t)})),this.on("done",(function(t){e.flush(t)})),this.on("partialdone",(function(t){e.partialFlush(t)})),this.on("endedtimeline",(function(t){e.endTimeline(t)})),this.on("reset",(function(t){e.reset(t)})),e},e.prototype.push=function(e){this.trigger("data",e)},e.prototype.flush=function(e){this.trigger("done",e)},e.prototype.partialFlush=function(e){this.trigger("partialdone",e)},e.prototype.endTimeline=function(e){this.trigger("endedtimeline",e)},e.prototype.reset=function(e){this.trigger("reset",e)};var t,n,r,a,s,o,u,d,l,c,h,m,f,p,g,y,v,_,b,T,S,I,L,A,k,E,w,O,U,C,P,D,x,R,M,F,B,N,q,V,H=e,j=Math.pow(2,32)-1;!function(){var e;if(I={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},"undefined"!=typeof Uint8Array){for(e in I)I.hasOwnProperty(e)&&(I[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);L=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),k=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),A=new Uint8Array([0,0,0,1]),E=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),w=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),O={video:E,audio:w},P=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),C=new Uint8Array([0,0,0,0,0,0,0,0]),D=new Uint8Array([0,0,0,0,0,0,0,0]),x=D,R=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),M=D,U=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}}(),t=function(e){var t,i,n=[],r=0;for(t=1;t<arguments.length;t++)n.push(arguments[t]);for(t=n.length;t--;)r+=n[t].byteLength;for(i=new Uint8Array(r+8),new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,i.byteLength),i.set(e,4),t=0,r=8;t<n.length;t++)i.set(n[t],r),r+=n[t].byteLength;return i},n=function(){return t(I.dinf,t(I.dref,P))},r=function(e){return t(I.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,e.audioobjecttype<<3|e.samplingfrequencyindex>>>1,e.samplingfrequencyindex<<7|e.channelcount<<3,6,1,2]))},g=function(e){return t(I.hdlr,O[e])},p=function(e){var i=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,e.duration>>>24&255,e.duration>>>16&255,e.duration>>>8&255,255&e.duration,85,196,0,0]);return e.samplerate&&(i[12]=e.samplerate>>>24&255,i[13]=e.samplerate>>>16&255,i[14]=e.samplerate>>>8&255,i[15]=255&e.samplerate),t(I.mdhd,i)},f=function(e){return t(I.mdia,p(e),g(e.type),o(e))},s=function(e){return t(I.mfhd,new Uint8Array([0,0,0,0,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e]))},o=function(e){return t(I.minf,"video"===e.type?t(I.vmhd,U):t(I.smhd,C),n(),v(e))},u=function(e,i){for(var n=[],r=i.length;r--;)n[r]=b(i[r]);return t.apply(null,[I.moof,s(e)].concat(n))},d=function(e){for(var i=e.length,n=[];i--;)n[i]=h(e[i]);return t.apply(null,[I.moov,c(4294967295)].concat(n).concat(l(e)))},l=function(e){for(var i=e.length,n=[];i--;)n[i]=T(e[i]);return t.apply(null,[I.mvex].concat(n))},c=function(e){var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
/*! @name @videojs/http-streaming @version 2.2.1 @license Apache-2.0 */!function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var t=function(){function e(){this.listeners={}}var t=e.prototype;return t.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},t.off=function(e,t){if(!this.listeners[e])return!1;var i=this.listeners[e].indexOf(t);return this.listeners[e]=this.listeners[e].slice(0),this.listeners[e].splice(i,1),i>-1},t.trigger=function(e){var t=this.listeners[e];if(t)if(2===arguments.length)for(var i=t.length,n=0;n<i;++n)t[n].call(this,arguments[1]);else for(var r=Array.prototype.slice.call(arguments,1),a=t.length,s=0;s<a;++s)t[s].apply(this,r)},t.dispose=function(){this.listeners={}},t.pipe=function(e){this.on("data",(function(t){e.push(t)}))},e}(),n=null,r=function(){function e(e){var t,i,r;n||(n=function(){var e,t,i,n,r,a,s,o,u=[[[],[],[],[],[]],[[],[],[],[],[]]],d=u[0],l=u[1],c=d[4],h=l[4],m=[],f=[];for(e=0;e<256;e++)f[(m[e]=e<<1^283*(e>>7))^e]=e;for(t=i=0;!c[t];t^=n||1,i=f[i]||1)for(a=(a=i^i<<1^i<<2^i<<3^i<<4)>>8^255&a^99,c[t]=a,h[a]=t,o=16843009*m[r=m[n=m[t]]]^65537*r^257*n^16843008*t,s=257*m[a]^16843008*a,e=0;e<4;e++)d[e][t]=s=s<<24^s>>>8,l[e][a]=o=o<<24^o>>>8;for(e=0;e<5;e++)d[e]=d[e].slice(0),l[e]=l[e].slice(0);return u}()),this._tables=[[n[0][0].slice(),n[0][1].slice(),n[0][2].slice(),n[0][3].slice(),n[0][4].slice()],[n[1][0].slice(),n[1][1].slice(),n[1][2].slice(),n[1][3].slice(),n[1][4].slice()]];var a=this._tables[0][4],s=this._tables[1],o=e.length,u=1;if(4!==o&&6!==o&&8!==o)throw new Error("Invalid aes key size");var d=e.slice(0),l=[];for(this._key=[d,l],t=o;t<4*o+28;t++)r=d[t-1],(t%o==0||8===o&&t%o==4)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],t%o==0&&(r=r<<8^r>>>24^u<<24,u=u<<1^283*(u>>7))),d[t]=d[t-o]^r;for(i=0;t;i++,t--)r=d[3&i?t:t-4],l[i]=t<=4||i<4?r:s[0][a[r>>>24]]^s[1][a[r>>16&255]]^s[2][a[r>>8&255]]^s[3][a[255&r]]}return e.prototype.decrypt=function(e,t,i,n,r,a){var s,o,u,d,l=this._key[1],c=e^l[0],h=n^l[1],m=i^l[2],f=t^l[3],p=l.length/4-2,g=4,y=this._tables[1],v=y[0],_=y[1],b=y[2],T=y[3],S=y[4];for(d=0;d<p;d++)s=v[c>>>24]^_[h>>16&255]^b[m>>8&255]^T[255&f]^l[g],o=v[h>>>24]^_[m>>16&255]^b[f>>8&255]^T[255&c]^l[g+1],u=v[m>>>24]^_[f>>16&255]^b[c>>8&255]^T[255&h]^l[g+2],f=v[f>>>24]^_[c>>16&255]^b[h>>8&255]^T[255&m]^l[g+3],g+=4,c=s,h=o,m=u;for(d=0;d<4;d++)r[(3&-d)+a]=S[c>>>24]<<24^S[h>>16&255]<<16^S[m>>8&255]<<8^S[255&f]^l[g++],s=c,c=h,h=m,m=f,f=s},e}(),a=function(e){function i(){var i;return(i=e.call(this,t)||this).jobs=[],i.delay=1,i.timeout_=null,i}var n,r;r=e,(n=i).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r;var a=i.prototype;return a.processJob_=function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null},a.push=function(e){this.jobs.push(e),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))},i}(t),s=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},o=function(){function t(e,i,n,r){var o=t.STEP,u=new Int32Array(e.buffer),d=new Uint8Array(e.byteLength),l=0;for(this.asyncStream_=new a,this.asyncStream_.push(this.decryptChunk_(u.subarray(l,l+o),i,n,d)),l=o;l<u.length;l+=o)n=new Uint32Array([s(u[l-4]),s(u[l-3]),s(u[l-2]),s(u[l-1])]),this.asyncStream_.push(this.decryptChunk_(u.subarray(l,l+o),i,n,d));this.asyncStream_.push((function(){
/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */
var e;
/*! @name aes-decrypter @version 3.0.2 @license Apache-2.0 */r(null,(e=d).subarray(0,e.byteLength-e[e.byteLength-1]))}))}return t.prototype.decryptChunk_=function(e,t,i,n){return function(){var a=function(e,t,i){var n,a,o,u,d,l,c,h,m,f=new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),p=new r(Array.prototype.slice.call(t)),g=new Uint8Array(e.byteLength),y=new Int32Array(g.buffer);for(n=i[0],a=i[1],o=i[2],u=i[3],m=0;m<f.length;m+=4)d=s(f[m]),l=s(f[m+1]),c=s(f[m+2]),h=s(f[m+3]),p.decrypt(d,l,c,h,y,m),y[m]=s(y[m]^n),y[m+1]=s(y[m+1]^a),y[m+2]=s(y[m+2]^o),y[m+3]=s(y[m+3]^u),n=d,a=l,o=c,u=h;return g}(e,t,i);n.set(a,e.byteOffset)}},i=t,o=[{key:"STEP",get:function(){return 32e3}}],(n=null)&&e(i.prototype,n),o&&e(i,o),t;var i,n,o}();new function(e){e.onmessage=function(t){var i=t.data,n=new Uint8Array(i.encrypted.bytes,i.encrypted.byteOffset,i.encrypted.byteLength),r=new Uint32Array(i.key.bytes,i.key.byteOffset,i.key.byteLength/4),a=new Uint32Array(i.iv.bytes,i.iv.byteOffset,i.iv.byteLength/4);new o(n,r,a,(function(t,n){var r,a;e.postMessage((r={source:i.source,decrypted:n},a={},Object.keys(r).forEach((function(e){var t=r[e];ArrayBuffer.isView(t)?a[e]={bytes:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength}:a[e]=t})),a),[n.buffer])}))}}(i)}()})),un=function(e){var t=e.default?"main":"alternative";return e.characteristics&&e.characteristics.indexOf("public.accessibility.describes-video")>=0&&(t="main-desc"),t},dn=function(e,t){e.abort(),e.pause(),t&&t.activePlaylistLoader&&(t.activePlaylistLoader.pause(),t.activePlaylistLoader=null)},ln=function(e,t){t.activePlaylistLoader=e,e.load()},cn={AUDIO:function(e,t){return function(){var i=t.segmentLoaders[e],r=t.mediaTypes[e],a=t.blacklistCurrentPlaylist;dn(i,r);var s=r.activeTrack(),o=r.activeGroup(),u=(o.filter((function(e){return e.default}))[0]||o[0]).id,d=r.tracks[u];if(s!==d){for(var l in n.log.warn("Problem encountered loading the alternate audio track.Switching back to default."),r.tracks)r.tracks[l].enabled=r.tracks[l]===d;r.onTrackChanged()}else a({message:"Problem encountered loading the default audio track."})}},SUBTITLES:function(e,t){return function(){var i=t.segmentLoaders[e],r=t.mediaTypes[e];n.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),dn(i,r);var a=r.activeTrack();a&&(a.mode="disabled"),r.onTrackChanged()}}},hn={AUDIO:function(e,t,i){if(t){var n=i.tech,r=i.requestOptions,a=i.segmentLoaders[e];t.on("loadedmetadata",(function(){var e=t.media();a.playlist(e,r),(!n.paused()||e.endList&&"none"!==n.preload())&&a.load()})),t.on("loadedplaylist",(function(){a.playlist(t.media(),r),n.paused()||a.load()})),t.on("error",cn[e](e,i))}},SUBTITLES:function(e,t,i){var n=i.tech,r=i.requestOptions,a=i.segmentLoaders[e],s=i.mediaTypes[e];t.on("loadedmetadata",(function(){var e=t.media();a.playlist(e,r),a.track(s.activeTrack()),(!n.paused()||e.endList&&"none"!==n.preload())&&a.load()})),t.on("loadedplaylist",(function(){a.playlist(t.media(),r),n.paused()||a.load()})),t.on("error",cn[e](e,i))}},mn={AUDIO:function(e,t){var i=t.vhs,r=t.sourceType,a=t.segmentLoaders[e],s=t.requestOptions,o=t.master,u=o.mediaGroups,d=o.playlists,l=t.mediaTypes[e],c=l.groups,h=l.tracks,m=t.masterPlaylistLoader;u[e]&&0!==Object.keys(u[e]).length||(u[e]={main:{default:{default:!0}}});var f=function(a){c[a]||(c[a]=[]);var o=d.filter((function(t){return t.attributes[e]===a})),l=function(d){var l=u[e][a][d];o.filter((function(e){return e.resolvedUri===l.resolvedUri})).length&&delete l.resolvedUri;var f;if(f="vhs-json"===r&&l.playlists?new R(l.playlists[0],i,s):l.resolvedUri?new R(l.resolvedUri,i,s):l.playlists&&"dash"===r?new ut(l.playlists[0],i,s,m):null,l=n.mergeOptions({id:d,playlistLoader:f},l),hn[e](e,l.playlistLoader,t),c[a].push(l),void 0===h[d]){var p=new n.AudioTrack({id:d,kind:un(l),enabled:!1,language:l.language,default:l.default,label:d});h[d]=p}};for(var f in u[e][a])l(f)};for(var p in u[e])f(p);a.on("error",cn[e](e,t))},SUBTITLES:function(e,t){var i=t.tech,r=t.vhs,a=t.sourceType,s=t.segmentLoaders[e],o=t.requestOptions,u=t.master.mediaGroups,d=t.med