11 lines
190 KiB
JavaScript
11 lines
190 KiB
JavaScript
|
(function(nt){if(typeof exports=="object"&&typeof module!="undefined")module.exports=nt();else if(typeof define=="function"&&define.amd)define([],nt);else{var I;I=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:this,I.videojsContribHls=nt()}})(function(){var nt;return function I(j,C,k){function E(S,m){if(!C[S]){if(!j[S]){var v=typeof require=="function"&&require;if(!m&&v)return v(S,!0);if(P)return P(S,!0);var c=new Error("Cannot find module '"+S+"'");throw c.code="MODULE_NOT_FOUND",c}var a=C[S]={exports:{}};j[S][0].call(a.exports,function(s){var l=j[S][1][s];return E(l||s)},a,a.exports,I,j,C,k)}return C[S].exports}for(var P=typeof require=="function"&&require,O=0;O<k.length;O++)E(k[O]);return E}({1:[function(I,j,C){"use strict";function k(v){return v&&v.__esModule?v:{default:v}}Object.defineProperty(C,"__esModule",{value:!0});var E=function(){function v(c,a){var s=[],l=!0,r=!1,h=void 0;try{for(var d,t=c[Symbol.iterator]();!(l=(d=t.next()).done)&&(s.push(d.value),!a||s.length!==a);l=!0);}catch(i){r=!0,h=i}finally{try{!l&&t.return&&t.return()}finally{if(r)throw h}}return s}return function(c,a){if(Array.isArray(c))return c;if(Symbol.iterator in Object(c))return v(c,a);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),P=I("global/window"),O=k(P),S=function(v,c){for(var a=v.cues,s=0;s<a.length;s++){var l=a[s];if(c>=l.adStartTime&&c<=l.adEndTime)return l}return null},m=function(v,c){var a=arguments.length<=2||arguments[2]===void 0?0:arguments[2];if(v.segments)for(var s=a,l=void 0,r=0;r<v.segments.length;r++){var h=v.segments[r];if(l||(l=S(c,s+h.duration/2)),l){if("cueIn"in h){l.endTime=s,l.adEndTime=s,s+=h.duration,l=null;continue}if(s<l.endTime){s+=h.duration;continue}l.endTime+=h.duration}else if("cueOut"in h&&(l=new O.default.VTTCue(s,s+h.duration,h.cueOut),l.adStartTime=s,l.adEndTime=s+parseFloat(h.cueOut),c.addCue(l)),"cueOutCont"in h){var d=void 0,t=void 0,i=h.cueOutCont.split("/").map(parseFloat),o=E(i,2);d=o[0],t=o[1],l=new O.default.VTTCue(s,s+h.duration,""),l.adStartTime=s-d,l.adEndTime=l.adStartTime+t,c.addCue(l)}s+=h.duration}};C.default={updateAdCues:m,findAdCue:S},j.exports=C.default},{"global/window":28}],2:[function(I,j,C){"use strict";Object.defineProperty(C,"__esModule",{value:!0});var k=function(m,v){return m.start(v)+"-"+m.end(v)},E=function(m,v){var c=m.toString(16);return"00".substring(0,2-c.length)+c+(v%2?" ":"")},P=function(m){return m>=32&&m<126?String.fromCharCode(m):"."},O=function(m){var v={};return Object.keys(m).forEach(function(c){var a=m[c];ArrayBuffer.isView(a)?v[c]={bytes:a.buffer,byteOffset:a.byteOffset,byteLength:a.byteLength}:v[c]=a}),v},S={hexDump:function(m){for(var v=Array.prototype.slice.call(m),c=16,a="",s=void 0,l=void 0,r=0;r<v.length/c;r++)s=v.slice(r*c,r*c+c).map(E).join(""),l=v.slice(r*c,r*c+c).map(P).join(""),a+=s+" "+l+`
|
||
|
`;return a},tagDump:function(m){return S.hexDump(m.bytes)},textRanges:function(m){var v="",c=void 0;for(c=0;c<m.length;c++)v+=k(m,c)+" ";return v},createTransferableMessage:O};C.default=S,j.exports=C.default},{}],3:[function(I,j,C){"use strict";Object.defineProperty(C,"__esModule",{value:!0}),C.default={GOAL_BUFFER_LENGTH:30},j.exports=C.default},{}],4:[function(I,j,C){"use strict";function k(v){return v&&v.__esModule?v:{default:v}}Object.defineProperty(C,"__esModule",{value:!0});var E=I("global/window"),P=k(E),O=I("aes-decrypter"),S=I("./bin-utils"),m=function(v){v.onmessage=function(c){var a=c.data,s=new Uint8Array(a.encrypted.bytes,a.encrypted.byteOffset,a.encrypted.byteLength),l=new Uint32Array(a.key.bytes,a.key.byteOffset,a.key.byteLength/4),r=new Uint32Array(a.iv.bytes,a.iv.byteOffset,a.iv.byteLength/4);new O.Decrypter(s,l,r,function(h,d){P.default.postMessage((0,S.createTransferableMessage)({source:a.source,decrypted:d}),[d.buffer])})}};C.default=function(v){return new m(v)},j.exports=C.default},{"./bin-utils":2,"aes-decrypter":21,"global/window":28}],5:[function(I,j,C){(function(k){"use strict";function E(L){return L&&L.__esModule?L:{default:L}}function P(L,D){if(!(L instanceof D))throw new TypeError("Cannot call a class as a function")}function O(L,D){if(typeof D!="function"&&D!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof D);L.prototype=Object.create(D&&D.prototype,{constructor:{value:L,enumerable:!1,writable:!0,configurable:!0}}),D&&(Object.setPrototypeOf?Object.setPrototypeOf(L,D):L.__proto__=D)}Object.defineProperty(C,"__esModule",{value:!0});var S=function(){function L(D,x){for(var M=0;M<x.length;M++){var N=x[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(D,N.key,N)}}return function(D,x,M){return x&&L(D.prototype,x),M&&L(D,M),D}}(),m=function(L,D,x){for(var M=!0;M;){var N=L,G=D,W=x;M=!1,N===null&&(N=Function.prototype);var B=Object.getOwnPropertyDescriptor(N,G);if(B!==void 0){if("value"in B)return B.value;var F=B.get;return F===void 0?void 0:F.call(W)}var H=Object.getPrototypeOf(N);if(H===null)return;L=H,D=G,x=W,M=!0,B=H=void 0}},v=I("./playlist-loader"),c=E(v),a=I("./segment-loader"),s=E(a),l=I("./ranges"),r=E(l),h=typeof window!="undefined"?window.videojs:typeof k!="undefined"?k.videojs:null,d=E(h),t=I("./ad-cue-tags"),i=E(t),o=I("./sync-controller"),p=E(o),u=I("videojs-contrib-media-sources/es5/codec-utils"),g=I("webworkify"),f=E(g),n=I("./decrypter-worker"),e=E(n),_=3e5,b=void 0,A=function(L,D){if(typeof L!=typeof D||Object.keys(L).length!==Object.keys(D).length)return!0;for(var x in L)if(L[x]!==D[x])return!0;return!1},w=function(L){var D={codecCount:0,videoCodec:null,videoObjectTypeIndicator:null,audioProfile:null},x=void 0;return D.codecCount=L.split(",").length,D.codecCount=D.codecCount||2,x=/(^|\s|,)+(avc1)([^ ,]*)/i.exec(L),x&&(D.videoCodec=x[2],D.videoObjectTypeIndicator=x[3]),D.audioProfile=/(^|\s|,)+mp4a.[0-9A-Fa-f]+\.([0-9A-Fa-f]+)/i.exec(L),D.audioProfile=D.audioProfile&&D.audioProfile[2],D},y=function(L){return L.replace(/avc1\.(\d+)\.(\d+)/i,function(D){return(0,u.translateLegacyCodecs)([D])[0]})};C.mapLegacyAvcCodecs_=y;var T=function(L,D){var x="mp2t",M={videoCodec:"avc1",videoObjectTypeIndicator:".4d400d",audioProfile:"2"},N=[],G=void 0,W=null;if(!D)return[];D.segments&&D.segments.length&&D.segments[0].map&&(x="mp4"),G=D.attributes||{},G.CODECS&&function(){var F=w(G.CODECS);Object.keys(F).forEach(function(H){M[H]=F[H]||M[H]})}(),L.mediaGroups.AUDIO&&(N=L.mediaGroups.AUDIO[G.AUDIO]);for(var B in N){if(W&&!!N[B].uri!=!!W.uri)return["video/"+x+'; codecs="'+M.videoCodec+M.videoObjectTypeIndicator+", mp4a.40."+M.audioProfile+'"',"audio/"+x+'; codecs="mp4a.40.'+M.audioProfile+'"'];W=N[B]}return W&&W.uri?["video/"+x+'; codecs="'+M.videoCodec+M.videoObjectTypeIndicator+'"',"audio/"+x+'; codecs="mp4a.40.'+M.audioProfile+'"']:["video/"+x+'; codecs="'+M.videoCodec+M.videoObjectTypeIndicator+", mp4a.40."+M.audioProfile+'"']};C.mimeTypesForPlaylist_=T;var U=function(L){function D(x){var M=this;P(this
|
||
|
|
||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1247138
|
||
|
|
||
|
`,N=this.activeAudioGroup().map(function(B){return B.enabled}).indexOf(!0),G=this.activeAudioGroup()[N],W=this.activeAudioGroup().filter(function(B){return B.properties_&&B.properties_.default})[0];this.audioPlaylistLoader_?(M="The audio track '"+G.label+"' that we tried to "+("switch to "+M+" Unfortunately this means we will have to ")+("return you to the main track '"+W.label+"'. Sorry!"),W.enabled=!0,this.activeAudioGroup().splice(N,1),this.trigger("audioupdate")):(M="The rendition that we tried to switch to "+M+"Unfortunately that means we will have to blacklist the current playlist and switch to another. Sorry!",this.blacklistCurrentPlaylist()),d.default.log.warn(M),this.setupAudio()}},{key:"mediaRequests_",value:function(){return this.audioSegmentLoader_.mediaRequests+this.mainSegmentLoader_.mediaRequests}},{key:"mediaTransferDuration_",value:function(){return this.audioSegmentLoader_.mediaTransferDuration+this.mainSegmentLoader_.mediaTransferDuration}},{key:"mediaBytesTransferred_",value:function(){return this.audioSegmentLoader_.mediaBytesTransferred+this.mainSegmentLoader_.mediaBytesTransferred}},{key:"mediaSecondsLoaded_",value:function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}},{key:"fillAudioTracks_",value:function(){var x=this.master(),M=x.mediaGroups||{};M&&M.AUDIO&&Object.keys(M.AUDIO).length!==0&&this.mode_==="html5"||(M.AUDIO={main:{default:{default:!0}}});for(var N in M.AUDIO){this.audioGroups_[N]||(this.audioGroups_[N]=[]);for(var G in M.AUDIO[N]){var W=M.AUDIO[N][G],B=new d.default.AudioTrack({id:G,kind:W.default?"main":"alternative",enabled:!1,language:W.language,label:G});B.properties_=W,this.audioGroups_[N].push(B)}}(this.activeAudioGroup().filter(function(F){return F.properties_.default})[0]||this.activeAudioGroup()[0]).enabled=!0}},{key:"load",value:function(){this.mainSegmentLoader_.load(),this.audioPlaylistLoader_&&this.audioSegmentLoader_.load()}},{key:"activeAudioGroup",value:function(){var x=this.masterPlaylistLoader_.media(),M=void 0;return x.attributes&&x.attributes.AUDIO&&(M=this.audioGroups_[x.attributes.AUDIO]),M||this.audioGroups_.main}},{key:"setupAudio",value:function(){var x=this,M=this.activeAudioGroup(),N=M.filter(function(G){return G.enabled})[0];return N||(N=M.filter(function(G){return G.properties_.default})[0]||M[0],N.enabled=!0),this.audioPlaylistLoader_&&(this.audioPlaylistLoader_.dispose(),this.audioPlaylistLoader_=null),this.audioSegmentLoader_.pause(),N.properties_.resolvedUri?(this.audioSegmentLoader_.resetEverything(),this.audioPlaylistLoader_=new c.default(N.properties_.resolvedUri,this.hls_,this.withCredentials),this.audioPlaylistLoader_.start(),this.audioPlaylistLoader_.on("loadedmetadata",function(){var G=x.audioPlaylistLoader_.media();x.audioSegmentLoader_.playlist(G,x.requestOptions_),(!x.tech_.paused()||G.endList&&x.tech_.preload()!=="none")&&x.audioSegmentLoader_.load(),G.endList||x.audioPlaylistLoader_.trigger("firstplay")}),this.audioPlaylistLoader_.on("loadedplaylist",function(){var G=void 0;return x.audioPlaylistLoader_&&(G=x.audioPlaylistLoader_.media()),G?void x.audioSegmentLoader_.playlist(G,x.requestOptions_):void x.audioPlaylistLoader_.media(x.audioPlaylistLoader_.playlists.master.playlists[0])}),void this.audioPlaylistLoader_.on("error",function(){d.default.log.warn("Problem encountered loading the alternate audio track. Switching back to default."),x.audioSegmentLoader_.abort(),x.setupAudio()})):void this.mainSegmentLoader_.resetEverything()}},{key:"fastQualityChange_",value:function(){var x=this.selectPlaylist();x!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(x),this.mainSegmentLoader_.resetLoader(),this.audiosegmentloader_&&this.audioSegmentLoader_.resetLoader())}},{key:"play",value:function(){if(!this.setupFirstPlay())return this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_()&&this.load(),this.tech_.duration()===1/0&&this.tech_.currentTime()<this.tech_.seekable().start(0)?this.tech_.setCurrentTime(this.tech_.seekable().start(0)):void 0}},{key:
|
||
|
`);r>-1;r=this.buffer.indexOf(`
|
||
|
`))this.trigger("data",this.buffer.substring(0,r)),this.buffer=this.buffer.substring(r+1)}}]),s}(v.default);C.default=c},{"./stream":33}],31:[function(I,j,C){"use strict";function k(r){return r&&r.__esModule?r:{default:r}}function E(r,h){if(!(r instanceof h))throw new TypeError("Cannot call a class as a function")}function P(r,h){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!h||typeof h!="object"&&typeof h!="function"?r:h}function O(r,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof h);r.prototype=Object.create(h&&h.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h&&(Object.setPrototypeOf?Object.setPrototypeOf(r,h):r.__proto__=h)}Object.defineProperty(C,"__esModule",{value:!0});var S=function(){function r(h,d){var t=[],i=!0,o=!1,p=void 0;try{for(var u,g=h[Symbol.iterator]();!(i=(u=g.next()).done)&&(t.push(u.value),!d||t.length!==d);i=!0);}catch(f){o=!0,p=f}finally{try{!i&&g.return&&g.return()}finally{if(o)throw p}}return t}return function(h,d){if(Array.isArray(h))return h;if(Symbol.iterator in Object(h))return r(h,d);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),m=function(){function r(h,d){for(var t=0;t<d.length;t++){var i=d[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(h,i.key,i)}}return function(h,d,t){return d&&r(h.prototype,d),t&&r(h,t),h}}(),v=I("./stream"),c=k(v),a=function(){var r="[^=]*",h='"[^"]*"|[^,]*',d="(?:"+r+")=(?:"+h+")";return new RegExp("(?:^|,)("+d+")")},s=function(r){for(var h=r.split(a()),d={},t=h.length,i=void 0;t--;)h[t]!==""&&(i=/([^=]*)=(.*)/.exec(h[t]).slice(1),i[0]=i[0].replace(/^\s+|\s+$/g,""),i[1]=i[1].replace(/^\s+|\s+$/g,""),i[1]=i[1].replace(/^['"](.*)['"]$/g,"$1"),d[i[0]]=i[1]);return d},l=function(r){function h(){return E(this,h),P(this,(h.__proto__||Object.getPrototypeOf(h)).call(this))}return O(h,r),m(h,[{key:"push",value:function(d){var t=void 0,i=void 0;if(d=d.replace(/^[\u0000\s]+|[\u0000\s]+$/g,""),d.length!==0){if(d[0]!=="#")return void this.trigger("data",{type:"uri",uri:d});if(d.indexOf("#EXT")!==0)return void this.trigger("data",{type:"comment",text:d.slice(1)});if(d=d.replace("\r",""),t=/^#EXTM3U/.exec(d))return void this.trigger("data",{type:"tag",tagType:"m3u"});if(t=/^#EXTINF:?([0-9\.]*)?,?(.*)?$/.exec(d))return i={type:"tag",tagType:"inf"},t[1]&&(i.duration=parseFloat(t[1])),t[2]&&(i.title=t[2]),void this.trigger("data",i);if(t=/^#EXT-X-TARGETDURATION:?([0-9.]*)?/.exec(d))return i={type:"tag",tagType:"targetduration"},t[1]&&(i.duration=parseInt(t[1],10)),void this.trigger("data",i);if(t=/^#ZEN-TOTAL-DURATION:?([0-9.]*)?/.exec(d))return i={type:"tag",tagType:"totalduration"},t[1]&&(i.duration=parseInt(t[1],10)),void this.trigger("data",i);if(t=/^#EXT-X-VERSION:?([0-9.]*)?/.exec(d))return i={type:"tag",tagType:"version"},t[1]&&(i.version=parseInt(t[1],10)),void this.trigger("data",i);if(t=/^#EXT-X-MEDIA-SEQUENCE:?(\-?[0-9.]*)?/.exec(d))return i={type:"tag",tagType:"media-sequence"},t[1]&&(i.number=parseInt(t[1],10)),void this.trigger("data",i);if(t=/^#EXT-X-DISCONTINUITY-SEQUENCE:?(\-?[0-9.]*)?/.exec(d))return i={type:"tag",tagType:"discontinuity-sequence"},t[1]&&(i.number=parseInt(t[1],10)),void this.trigger("data",i);if(t=/^#EXT-X-PLAYLIST-TYPE:?(.*)?$/.exec(d))return i={type:"tag",tagType:"playlist-type"},t[1]&&(i.playlistType=t[1]),void this.trigger("data",i);if(t=/^#EXT-X-BYTERANGE:?([0-9.]*)?@?([0-9.]*)?/.exec(d))return i={type:"tag",tagType:"byterange"},t[1]&&(i.length=parseInt(t[1],10)),t[2]&&(i.offset=parseInt(t[2],10)),void this.trigger("data",i);if(t=/^#EXT-X-ALLOW-CACHE:?(YES|NO)?/.exec(d))return i={type:"tag",tagType:"allow-cache"},t[1]&&(i.allowed=!/NO/.test(t[1])),void this.trigger("data",i);if(t=/^#EXT-X-MAP:?(.*)$/.exec(d)){if(i={type:"tag",tagType:"map"},t[1]){var o=s(t[1]);if(o.URI&&(i.uri=o.URI),o.BYTERANGE){var p=o.BYTERANGE.split("@"),u=S(p,2),g=u[0],f=u[1];i.byterange={},g&&(i.byterange.length=parseInt(g,10))
|
||
|
`)}}]),t}(c.default);C.default=h},{"./line-stream":30,"./parse-stream":31,"./stream":33}],33:[function(I,j,C){"use strict";function k(O,S){if(!(O instanceof S))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(C,"__esModule",{value:!0});var E=function(){function O(S,m){for(var v=0;v<m.length;v++){var c=m[v];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(S,c.key,c)}}return function(S,m,v){return m&&O(S.prototype,m),v&&O(S,v),S}}(),P=function(){function O(){k(this,O),this.listeners={}}return E(O,[{key:"on",value:function(S,m){this.listeners[S]||(this.listeners[S]=[]),this.listeners[S].push(m)}},{key:"off",value:function(S,m){if(!this.listeners[S])return!1;var v=this.listeners[S].indexOf(m);return this.listeners[S].splice(v,1),v>-1}},{key:"trigger",value:function(S){var m=this.listeners[S],v=void 0,c=void 0,a=void 0;if(m)if(arguments.length===2)for(c=m.length,v=0;v<c;++v)m[v].call(this,arguments[1]);else for(a=Array.prototype.slice.call(arguments,1),c=m.length,v=0;v<c;++v)m[v].apply(this,a)}},{key:"dispose",value:function(){this.listeners={}}},{key:"pipe",value:function(S){this.on("data",function(m){S.push(m)})}}]),O}();C.default=P},{}],34:[function(I,j,C){"use strict";var k=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],E=function(s){return s[0]<<21|s[1]<<14|s[2]<<7|s[3]},P=function(s,l,r){var h,d="";for(h=l;h<r;h++)d+="%"+("00"+s[h].toString(16)).slice(-2);return d},O=function(s,l,r){return unescape(P(s,l,r))},S=function(s,l){var r=s[l+6]<<21|s[l+7]<<14|s[l+8]<<7|s[l+9],h=s[l+5],d=(16&h)>>4;return d?r+20:r+10},m=function(s,l){var r=(224&s[l+5])>>5,h=s[l+4]<<3,d=6144&s[l+3];return d|h|r},v=function(s,l){return s[l]==="I".charCodeAt(0)&&s[l+1]==="D".charCodeAt(0)&&s[l+2]==="3".charCodeAt(0)?"timed-metadata":s[l]&!0&&(240&s[l+1])==240?"audio":null},c=function(s){for(var l=0;l+5<s.length;){if(s[l]===255&&(246&s[l+1])==240)return k[(60&s[l+2])>>>2];l++}return null},a=function(s){var l,r,h,d;l=10,64&s[5]&&(l+=4,l+=E(s.subarray(10,14)));do{if(r=E(s.subarray(l+4,l+8)),r<1)return null;if(d=String.fromCharCode(s[l],s[l+1],s[l+2],s[l+3]),d==="PRIV"){h=s.subarray(l+10,l+r+10);for(var t=0;t<h.byteLength;t++)if(h[t]===0){var i=O(h,0,t);if(i==="com.apple.streaming.transportStreamTimestamp"){var o=h.subarray(t+1),p=(1&o[3])<<30|o[4]<<22|o[5]<<14|o[6]<<6|o[7]>>>2;return p*=4,p+=3&o[7]}break}}l+=10,l+=r}while(l<s.byteLength);return null};j.exports={parseId3TagSize:S,parseAdtsSize:m,parseType:v,parseSampleRate:c,parseAacTimestamp:a}},{}],35:[function(I,j,C){"use strict";var k=I("./stream-types.js"),E=function(r){var h=31&r[1];return h<<=8,h|=r[2]},P=function(r){return!!(64&r[1])},O=function(r){var h=0;return(48&r[3])>>>4>1&&(h+=r[4]+1),h},S=function(r,h){var d=E(r);return d===0?"pat":d===h?"pmt":h?"pes":null},m=function(r){var h=P(r),d=4+O(r);return h&&(d+=r[d]+1),(31&r[d+10])<<8|r[d+11]},v=function(r){var h={},d=P(r),t=4+O(r);if(d&&(t+=r[t]+1),1&r[t+5]){var i,o,p;i=(15&r[t+1])<<8|r[t+2],o=3+i-4,p=(15&r[t+10])<<8|r[t+11];for(var u=12+p;u<o;){var g=t+u;h[(31&r[g+1])<<8|r[g+2]]=r[g],u+=((15&r[g+3])<<8|r[g+4])+5}return h}},c=function(r,h){var d=E(r),t=h[d];switch(t){case k.H264_STREAM_TYPE:return"video";case k.ADTS_STREAM_TYPE:return"audio";case k.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}},a=function(r){var h=P(r);if(!h)return null;var d,t=4+O(r),i={};return d=r[t+7],192&d&&(i.pts=(14&r[t+9])<<27|(255&r[t+10])<<20|(254&r[t+11])<<12|(255&r[t+12])<<5|(254&r[t+13])>>>3,i.pts*=4,i.pts+=(6&r[t+13])>>>1,i.dts=i.pts,64&d&&(i.dts=(14&r[t+14])<<27|(255&r[t+15])<<20|(254&r[t+16])<<12|(255&r[t+17])<<5|(254&r[t+18])>>>3,i.dts*=4,i.dts+=(6&r[t+18])>>>1)),i},s=function(r){switch(r){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},l=function(r){for(var h,d=4+O(r),t=r.subarray(d),i=0,o=0,p=!1;o<t.byteLength-3;o++)if(t[o+2]===1){i=o+5;break}for(;i<t.byteLength;)swit
|
||
|
`);_.length&&this.trigger("data",{startPts:this.startPts_,endPts:e,text:_})},n.prototype.popOn=function(e,_,b){var A=this.nonDisplayed_[g];A+=a(_),A+=a(b),this.nonDisplayed_[g]=A},n.prototype.rollUp=function(e,_,b){var A=this.displayed_[g];A===""&&(this.flushDisplayed(e),this.startPts_=e),A+=a(_),A+=a(b),this.displayed_[g]=A},n.prototype.shiftRowsUp_=function(){var e;for(e=0;e<this.topRow_;e++)this.displayed_[e]="";for(e=this.topRow_;e<g;e++)this.displayed_[e]=this.displayed_[e+1];this.displayed_[g]=""},j.exports={CaptionStream:v,Cea608Stream:n}},{"../utils/stream":75}],66:[function(I,j,C){"use strict";var k,E,P,O=I("../utils/stream.js"),S=I("./caption-stream"),m=I("./stream-types"),v=I("./timestamp-rollover-stream").TimestampRolloverStream,c=I("./stream-types.js"),a=188,s=71;k=function(){var h=new Uint8Array(a),d=0;k.prototype.init.call(this),this.push=function(t){var i,o=0,p=a;for(d?(i=new Uint8Array(t.byteLength+d),i.set(h.subarray(0,d)),i.set(t,d),d=0):i=t;p<i.byteLength;)i[o]!==s||i[p]!==s?(o++,p++):(this.trigger("data",i.subarray(o,p)),o+=a,p+=a);o<i.byteLength&&(h.set(i.subarray(o),0),d=i.byteLength-o)},this.flush=function(){d===a&&h[0]===s&&(this.trigger("data",h),d=0),this.trigger("done")}},k.prototype=new O,E=function(){var h,d,t,i;E.prototype.init.call(this),i=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,h=function(o,p){var u=0;p.payloadUnitStartIndicator&&(u+=o[u]+1),p.type==="pat"?d(o.subarray(u),p):t(o.subarray(u),p)},d=function(o,p){p.section_number=o[7],p.last_section_number=o[8],i.pmtPid=(31&o[10])<<8|o[11],p.pmtPid=i.pmtPid},t=function(o,p){var u,g,f,n;if(1&o[5]){for(i.programMapTable={},u=(15&o[1])<<8|o[2],g=3+u-4,f=(15&o[10])<<8|o[11],n=12+f;n<g;)i.programMapTable[(31&o[n+1])<<8|o[n+2]]=o[n],n+=((15&o[n+3])<<8|o[n+4])+5;for(p.programMapTable=i.programMapTable;i.packetsWaitingForPmt.length;)i.processPes_.apply(i,i.packetsWaitingForPmt.shift())}},this.push=function(o){var p={},u=4;p.payloadUnitStartIndicator=!!(64&o[1]),p.pid=31&o[1],p.pid<<=8,p.pid|=o[2],(48&o[3])>>>4>1&&(u+=o[u]+1),p.pid===0?(p.type="pat",h(o.subarray(u),p),this.trigger("data",p)):p.pid===this.pmtPid?(p.type="pmt",h(o.subarray(u),p),this.trigger("data",p)):this.programMapTable===void 0?this.packetsWaitingForPmt.push([o,u,p]):this.processPes_(o,u,p)},this.processPes_=function(o,p,u){u.streamType=this.programMapTable[u.pid],u.type="pes",u.data=o.subarray(p),this.trigger("data",u)}},E.prototype=new O,E.STREAM_TYPES={h264:27,adts:15},P=function(){var h=this,d={data:[],size:0},t={data:[],size:0},i={data:[],size:0},o=function(u,g){var f;g.dataAlignmentIndicator=(4&u[6])!=0,f=u[7],192&f&&(g.pts=(14&u[9])<<27|(255&u[10])<<20|(254&u[11])<<12|(255&u[12])<<5|(254&u[13])>>>3,g.pts*=4,g.pts+=(6&u[13])>>>1,g.dts=g.pts,64&f&&(g.dts=(14&u[14])<<27|(255&u[15])<<20|(254&u[16])<<12|(255&u[17])<<5|(254&u[18])>>>3,g.dts*=4,g.dts+=(6&u[18])>>>1)),g.data=u.subarray(9+u[8])},p=function(u,g){var f,n=new Uint8Array(u.size),e={type:g},_=0;if(u.data.length){for(e.trackId=u.data[0].pid;u.data.length;)f=u.data.shift(),n.set(f.data,_),_+=f.data.byteLength;o(n,e),u.size=0,h.trigger("data",e)}};P.prototype.init.call(this),this.push=function(u){({pat:function(){},pes:function(){var g,f;switch(u.streamType){case m.H264_STREAM_TYPE:case c.H264_STREAM_TYPE:g=d,f="video";break;case m.ADTS_STREAM_TYPE:g=t,f="audio";break;case m.METADATA_STREAM_TYPE:g=i,f="timed-metadata";break;default:return}u.payloadUnitStartIndicator&&p(g,f),g.data.push(u),g.size+=u.data.byteLength},pmt:function(){var g,f,n={type:"metadata",tracks:[]},e=u.programMapTable;for(g in e)e.hasOwnProperty(g)&&(f={timelineStartInfo:{baseMediaDecodeTime:0}},f.id=+g,e[g]===c.H264_STREAM_TYPE?(f.codec="avc",f.type="video"):e[g]===c.ADTS_STREAM_TYPE&&(f.codec="adts",f.type="audio"),n.tracks.push(f));h.trigger("data",n)}})[u.type]()},this.flush=function(){p(d,"video"),p(t,"audio"),p(i,"timed-metadata"),this.trigger("done")}},P.prototype=new O;var l={PAT_PID:0,MP2T_PACKET_LENGTH:a,TransportPacketStream:k,TransportParseStream:E,ElementaryStream:P,TimestampRolloverStream:v,CaptionStream:S.CaptionStream
|