{"version":3,"sources":["webpack://mpegts/webpack/universalModuleDefinition","webpack://mpegts/webpack/bootstrap","webpack://mpegts/./src/utils/logger.js","webpack://mpegts/./src/core/transmuxing-events.js","webpack://mpegts/./src/io/loader.js","webpack://mpegts/./src/utils/exception.js","webpack://mpegts/./src/utils/browser.js","webpack://mpegts/./src/demux/demux-errors.js","webpack://mpegts/./node_modules/events/events.js","webpack://mpegts/./src/core/media-segment-info.js","webpack://mpegts/./src/core/media-info.js","webpack://mpegts/./src/utils/logging-control.js","webpack://mpegts/./src/utils/utf8-conv.js","webpack://mpegts/./src/demux/amf-parser.js","webpack://mpegts/./src/demux/exp-golomb.js","webpack://mpegts/./src/demux/sps-parser.js","webpack://mpegts/./src/demux/h265-parser.js","webpack://mpegts/./src/utils/typedarray-equality.ts","webpack://mpegts/./src/demux/flv-demuxer.js","webpack://mpegts/./src/demux/pat-pmt-pes.ts","webpack://mpegts/./src/demux/base-demuxer.ts","webpack://mpegts/./src/demux/h264.ts","webpack://mpegts/./src/demux/mpeg4-audio.ts","webpack://mpegts/./src/demux/scte35.ts","webpack://mpegts/./src/demux/aac.ts","webpack://mpegts/./src/demux/pes-private-data.ts","webpack://mpegts/./src/demux/h265.ts","webpack://mpegts/./src/demux/smpte2038.ts","webpack://mpegts/./src/demux/mp3.ts","webpack://mpegts/./src/demux/ac3.ts","webpack://mpegts/./src/demux/ts-demuxer.ts","webpack://mpegts/./src/remux/mp4-generator.js","webpack://mpegts/./src/remux/aac-silent.js","webpack://mpegts/./src/remux/mp4-remuxer.js","webpack://mpegts/./src/core/transmuxing-controller.js","webpack://mpegts/./src/io/speed-sampler.js","webpack://mpegts/./src/io/fetch-stream-loader.js","webpack://mpegts/./src/io/xhr-moz-chunked-loader.js","webpack://mpegts/./src/io/xhr-range-loader.js","webpack://mpegts/./src/io/websocket-loader.js","webpack://mpegts/./src/io/range-seek-handler.js","webpack://mpegts/./src/io/param-seek-handler.js","webpack://mpegts/./src/io/io-controller.js","webpack://mpegts/./src/utils/polyfill.js","webpack://mpegts/./node_modules/webworkify-webpack/index.js","webpack://mpegts/./src/index.js","webpack://mpegts/./node_modules/es6-promise/dist/es6-promise.js","webpack://mpegts/./node_modules/process/browser.js","webpack://mpegts/(webpack)/buildin/global.js","webpack://mpegts/./src/core/transmuxing-worker.js","webpack://mpegts/./src/config.js","webpack://mpegts/./src/core/features.js","webpack://mpegts/./src/player/player-events.js","webpack://mpegts/./src/core/transmuxer.js","webpack://mpegts/./src/core/mse-events.js","webpack://mpegts/./src/core/mse-controller.js","webpack://mpegts/./src/player/player-errors.js","webpack://mpegts/./src/player/mse-player.js","webpack://mpegts/./src/player/native-player.js","webpack://mpegts/./src/mpegts.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","e","tag","msg","Log","FORCE_GLOBAL_TAG","GLOBAL_TAG","str","ENABLE_CALLBACK","emitter","emit","ENABLE_ERROR","console","error","warn","log","ENABLE_INFO","info","w","ENABLE_WARN","ENABLE_DEBUG","debug","v","ENABLE_VERBOSE","IO_ERROR","DEMUX_ERROR","INIT_SEGMENT","MEDIA_SEGMENT","LOADING_COMPLETE","RECOVERED_EARLY_EOF","MEDIA_INFO","METADATA_ARRIVED","SCRIPTDATA_ARRIVED","TIMED_ID3_METADATA_ARRIVED","SMPTE2038_METADATA_ARRIVED","SCTE35_METADATA_ARRIVED","PES_PRIVATE_DATA_DESCRIPTOR","PES_PRIVATE_DATA_ARRIVED","STATISTICS_INFO","RECOMMEND_SEEKPOINT","LoaderStatus","kIdle","kConnecting","kBuffering","kError","kComplete","LoaderErrors","OK","EXCEPTION","HTTP_STATUS_CODE_INVALID","CONNECTING_TIMEOUT","EARLY_EOF","UNRECOVERABLE_EARLY_EOF","typeName","this","_type","_status","_needStash","_onContentLengthKnown","_onURLRedirect","_onDataArrival","_onError","_onComplete","destroy","isWorking","callback","open","dataSource","range","abort","message","_message","toString","RuntimeException","Browser","ua","self","navigator","userAgent","toLowerCase","match","exec","indexOf","platform_match","matched","browser","version","majorVersion","platform","versionArray","split","major","parseInt","string","length","minor","build","chrome","opr","safari","webkit","rv","iemobile","edge","android","assign","detect","FORMAT_ERROR","FORMAT_UNSUPPORTED","CODEC_UNSUPPORTED","ReflectOwnKeys","R","Reflect","ReflectApply","apply","target","receiver","args","Function","ownKeys","getOwnPropertySymbols","getOwnPropertyNames","concat","NumberIsNaN","Number","isNaN","EventEmitter","init","once","Promise","resolve","reject","errorListener","err","removeListener","resolver","slice","arguments","eventTargetAgnosticAddListener","handler","flags","on","addErrorHandlerIfEventEmitter","_events","undefined","_eventsCount","_maxListeners","defaultMaxListeners","checkListener","listener","TypeError","_getMaxListeners","that","_addListener","type","prepend","events","existing","warning","newListener","unshift","push","warned","Error","String","count","onceWrapper","fired","wrapFn","_onceWrap","state","wrapped","_listeners","unwrap","evlistener","arr","ret","Array","unwrapListeners","arrayClone","listenerCount","copy","addEventListener","wrapListener","arg","removeEventListener","set","RangeError","getPrototypeOf","setMaxListeners","getMaxListeners","doError","er","context","len","listeners","addListener","prependListener","prependOnceListener","list","position","originalListener","shift","index","pop","spliceOne","off","removeAllListeners","keys","rawListeners","eventNames","dts","pts","duration","originalDts","isSync","isSyncPoint","fileposition","beginDts","endDts","beginPts","endPts","originalBeginDts","originalEndDts","syncPoints","firstSample","lastSample","appendSyncPoint","sampleInfo","_list","clear","appendArray","getLastSyncPointBeforeDts","idx","last","mid","lbound","ubound","Math","floor","_lastAppendLocation","isEmpty","_searchNearestSegmentBefore","_searchNearestSegmentAfter","append","mediaSegmentInfo","msi","lastAppendIdx","insertIdx","splice","getLastSegmentBefore","getLastSampleBefore","segment","getLastSyncPointBefore","segmentIdx","mimeType","hasAudio","hasVideo","audioCodec","videoCodec","audioDataRate","videoDataRate","audioSampleRate","audioChannelCount","width","height","fps","profile","level","refFrames","chromaFormat","sarNum","sarDen","metadata","segments","segmentCount","hasKeyframesIndex","keyframesIndex","isComplete","audioInfoComplete","videoInfoComplete","isSeekable","getNearestKeyframe","milliseconds","table","keyframeIdx","_search","times","filepositions","enable","LoggingControl","_notifyChange","getConfig","globalTag","forceGlobalTag","enableVerbose","enableDebug","enableInfo","enableWarn","enableError","enableCallback","applyConfig","config","registerListener","addLogListener","removeLogListener","checkContinuation","uint8array","start","checkLength","array","buf","out","input","fromCharCode","ucs4","join","ArrayBuffer","DataView","setInt16","Int16Array","parseScriptData","arrayBuffer","dataOffset","dataSize","data","AMF","parseValue","size","parseObject","parseString","isObjectEnd","objectEnd","parseVariable","getUint16","Uint8Array","parseLongString","getUint32","parseDate","timestamp","getFloat64","localTimeOffset","getInt16","Date","offset","getUint8","amfstr","terminal","amfobj","amfvar","strictArrayLength","val","date","amfLongStr","TAG","_buffer","_buffer_index","_total_bytes","byteLength","_total_bits","_current_word","_current_word_bits_left","_fillCurrentWord","buffer_bytes_left","bytes_read","min","word","subarray","buffer","readBits","bits","result","bits_need_left","bits_read_next","result2","readBool","readByte","_skipLeadingZero","zero_count","readUEG","leading_zeros","readSEG","_ebsp2rbsp","src","src_length","dst","dst_idx","parseSPS","codec_array","codec_mimetype","j","h","rbsp","SPSParser","gb","profile_idc","level_idc","profile_string","getProfileString","level_string","getLevelString","chroma_format_idc","chroma_format","bit_depth_luma","bit_depth_chroma","scaling_list_count","_skipScalingList","pic_order_cnt_type","num_ref_frames_in_pic_order_cnt_cycle","ref_frames","pic_width_in_mbs_minus1","pic_height_in_map_units_minus1","frame_mbs_only_flag","frame_crop_left_offset","frame_crop_right_offset","frame_crop_top_offset","frame_crop_bottom_offset","sar_width","sar_height","fps_fixed","fps_num","fps_den","aspect_ratio_idc","num_units_in_tick","time_scale","sarScale","crop_unit_x","crop_unit_y","codec_width","codec_height","present_width","ceil","bit_depth","chroma_format_string","getChromaFormatString","frame_rate","fixed","sar_ratio","codec_size","present_size","last_scale","next_scale","toFixed","chroma","parseVPS","H265NaluParser","num_temporal_layers","temporal_id_nested","left_offset","right_offset","top_offset","bottom_offset","max_sub_layers_minus1","general_profile_space","general_tier_flag","general_profile_idc","general_profile_compatibility_flags_1","general_profile_compatibility_flags_2","general_profile_compatibility_flags_3","general_profile_compatibility_flags_4","general_constraint_indicator_flags_1","general_constraint_indicator_flags_2","general_constraint_indicator_flags_3","general_constraint_indicator_flags_4","general_constraint_indicator_flags_5","general_constraint_indicator_flags_6","general_level_idc","sub_layer_profile_present_flag","sub_layer_level_present_flag","pic_width_in_luma_samples","pic_height_in_luma_samples","bit_depth_luma_minus8","bit_depth_chroma_minus8","log2_max_pic_order_cnt_lsb_minus4","sizeId","matrixId","coefNum","num_short_term_ref_pic_sets","num_delta_pocs","inter_ref_pic_set_prediction_flag","next_num_delta_pocs","used_by_curr_pic_flag","use_delta_flag","num_negative_pics","num_positive_pics","num_long_term_ref_pics_sps","min_spatial_segmentation_idc","nal_hrd_parameters_present_flag","vcl_hrd_parameters_present_flag","sub_pic_hrd_params_present_flag","fixed_pic_rate_general_flag","fixed_pic_rate_within_cvs_flag","cpbCnt","low_delay_hrd_flag","sar_scale","constant_frame_rate","parsePPS","tiles_enabled_flag","entropy_coding_sync_enabled_flag","parallelismType","chroma_idc","isAligned16","a","byteOffset","isAligned32","compareArray","b","Uint32Array","equal32","Uint16Array","equal16","equal8","StreamType","probeData","_config","_onMediaInfo","_onMetaDataArrived","_onScriptDataArrived","_onTrackMetadata","_onDataAvailable","_dataOffset","_firstParse","_dispatch","_hasAudio","hasAudioTrack","_hasVideo","hasVideoTrack","_hasAudioFlagOverrided","_hasVideoFlagOverrided","_audioInitialMetadataDispatched","_videoInitialMetadataDispatched","_mediaInfo","_metadata","_audioMetadata","_videoMetadata","_naluLengthSize","_timestampBase","_timescale","_duration","_durationOverrided","_referenceFrameRate","_flvSoundRateTable","_mpegSamplingRates","_mpegAudioV10SampleRateTable","_mpegAudioV20SampleRateTable","_mpegAudioV25SampleRateTable","_mpegAudioL1BitRateTable","_mpegAudioL2BitRateTable","_mpegAudioL3BitRateTable","_videoTrack","id","sequenceNumber","samples","_audioTrack","_littleEndian","probe","needMoreData","mismatch","consumed","bindDataSource","loader","onDataArrival","parseChunks","base","resetMediaInfo","_isInitialMetadataDispatched","chunk","byteStart","le","FLVDemuxer","tagType","ts2","ts1","_parseAudioData","_parseVideoData","_parseScriptData","prevTagSize","scriptData","onMetaData","audiodatarate","videodatarate","framerate","keyframes","_parseKeyframesIndex","time","tagTimestamp","soundSpec","soundFormat","soundRate","soundRateIndex","soundType","meta","track","timescale","channelCount","aacData","_parseAACAudioData","packetType","misc","samplingRate","codec","originalCodec","refSampleDuration","mi","aacSample","unit","_parseMP3AudioData","bitRate","mp3Sample","_parseAACAudioSpecificConfig","originalAudioObjectType","samplingIndex","audioObjectType","extensionSamplingIndex","samplingFrequence","channelConfig","requestHeader","ver","layer","bitrate_index","sampling_freq_index","channel_count","sample_rate","bit_rate","tagPosition","spec","frameType","fourcc","_parseEnhancedHEVCVideoPacket","codecId","_parseAVCVideoPacket","_parseHEVCVideoPacket","cts","_parseAVCDecoderConfigurationRecord","_parseAVCVideoData","_parseHEVCDecoderConfigurationRecord","_parseHEVCVideoData","avcc","new_avcc","avcProfile","spsCount","sps","codecWidth","codecHeight","presentWidth","presentHeight","bitDepth","sarRatio","frameRate","codecArray","codecString","ppsCount","hvcc","new_hvcc","hevcProfile","numOfArrays","nalUnitType","numNalus","units","lengthSize","keyframe","naluSize","unitType","avcSample","isKeyframe","hevcSample","onError","onMediaInfo","onMetaDataArrived","onTrackMetadata","onDataAvailable","onTimedID3Metadata","onSMPTE2038Metadata","onSCTE35Metadata","onPESPrivateData","onPESPrivateDataDescriptor","program_pmt_pid","H264NaluType","pid_stream_type","common_pids","h264","h265","adts_aac","loas_aac","opus","ac3","mp3","pes_private_data_pids","timed_id3_pids","scte_35_pids","smpte2038_pids","slices","total_length","expected_length","file_position","MPEG4AudioObjectTypes","MPEG4SamplingFrequencyIndex","nalu","nalu_size","setUint32","current_startcode_offset_","eof_flag_","data_","findNextStartCodeOffset","start_offset","uint32","uint24","readNextNaluPayload","nalu_payload","nalu_type","forbidden_bit","next_startcode_offset","kReserved0","payload_data","H264NaluPayload","pps","sps_details","need_extra_fields","sps_length","pps_length","getData","SCTE35CommandType","MPEG4SamplingFrequencies","AACFrame","current_syncword_offset_","findNextSyncwordOffset","syncword_offset","readNextAACFrame","aac_frame","ID","protection_absent","sampling_frequency_index","channel_configuration","aac_frame_length","has_last_incomplete_data","adts_header_length","adts_frame_payload_length","next_syncword_offset","frame_data","audio_object_type","sampling_frequency","channel_config","hasIncompleteData","getIncompleteData","getLATMValue","bytesForValue","privious","audioMuxLengthBytes","streamMuxConfig","audioMuxVersion","fillBits","frameLengthType","otherDataPresent","otherDataLenBits","otherDataLenEsc","LOASAACFrame","other_data_present","tmp","aac_data","frame","original_audio_object_type","sampling_index","extension_sampling_index","sampling_rate","original_codec_mimetype","H265NaluType","parseSpliceTime","reader","time_specified_flag","pts_time","parseBreakDuration","auto_return","parseSpliceInsertComponent","splice_immediate_flag","component_tag","splice_time","parseSpliceScheduleEventComponent","utc_splice_time","parseSpliceScheduleEvent","splice_event_id","splice_event_cancel_indicator","spliceScheduleEvent","out_of_network_indicator","program_splice_flag","duration_flag","component_count","components","break_duration","unique_program_id","avail_num","avails_expected","parseAvailDescriptor","descriptor_tag","descriptor_length","identifier","provider_avail_id","parseDTMFDescriptor","preroll","dtmf_count","DTMF_char","parseSegmentationDescriptorComponent","pts_offset","parseSegmentationDescriptor","segmentation_event_id","segmentation_event_cancel_indicator","segmentationDescriptor","program_segmentation_flag","segmentation_duration_flag","delivery_not_restricted_flag","web_delivery_allowed_flag","no_regional_blackout_flag","archive_allowed_flag","device_restrictions","segmentation_duration","segmentation_upid_type","segmentation_upid_length","upid","segmentation_upid","segmentation_type_id","segment_num","segments_expected","sub_segment_num","sub_segments_expected","parseTimeDescriptor","TAI_seconds","TAI_ns","UTC_offset","parseAudioDescriptorComponent","ISO_code","Bit_Stream_Mode","Num_Channels","Full_Srvc_Audio","parseAudioDescriptor","audio_count","readSCTE35","table_id","section_syntax_indicator","private_indicator","section_length","protocol_version","encrypted_packet","encryption_algorithm","pts_adjustment","cw_index","tier","splice_command_length","splice_command_type","splice_command","kSpliceNull","kSpliceSchedule","splice_count","parseSpliceSchedule","kSpliceInsert","spliceInsert","parseSpliceInsert","kTimeSignal","parseTimeSignal","kBandwidthReservation","kPrivateCommand","private_data","parsePrivateCommand","splice_descriptors","descriptor_loop_length","detail","E_CRC32","CRC32","duraiton","timeSignal","H265NaluPayload","vps","kSliceVPS","kSliceSPS","kSlicePPS","frame_size_code_table","readNextAC3Frame","ac3_frame","sampling_rate_code","frame_size_code","frame_size","bit_stream_identification","bit_stream_mode","channel_mode","lfe_skip","low_frequency_effects_channel_on","AC3Frame","probe_data","first_parse_","media_info_","timescale_","duration_","current_pmt_pid_","program_pmt_map_","pes_slice_queues_","section_slice_queues_","video_metadata_","details","audio_metadata_","aac_last_sample_pts_","aac_last_incomplete_data_","has_video_","has_audio_","video_init_segment_dispatched_","audio_init_segment_dispatched_","video_metadata_changed_","audio_metadata_changed_","loas_previous_frame","video_track_","audio_track_","ts_packet_size_","ts_packet_size","sync_offset_","sync_offset","config_","scan_window","byte_start","sync_byte","payload_unit_start_indicator","pid","adaptation_field_control","continuity_conunter","adaptation_field_info","ts_payload_start_index","adaptation_field_length","parseAdaptationField","pmt_","kSCTE35","ts_payload_length","handleSectionSlice","random_access_indicator","stream_type","handlePESSlice","dispatchAudioVideoMediaSegment","discontinuity_indicator","elementary_stream_priority_indicator","slice_queue","pointer_field","remain_section","emitSectionSlices","clearSlices","SliceQueue","packet_start_code_prefix","PES_packet_length","emitPESSlices","section_data","SectionData","parseSection","pes_data","PESData","parsePES","parsePAT","parsePMT","parseSCTE35","stream_id","PTS_DTS_flags","PES_header_data_length","payload_start_index","payload_length","payload","kMPEG1Audio","kMPEG2Audio","parseMP3Payload","kPESPrivateData","parseOpusPayload","parseAC3Payload","parseSMPTE2038MetadataPayload","parsePESPrivateDataPayload","kADTSAAC","parseADTSAACPayload","kLOASAAC","parseLOASAACPayload","kAC3","kID3","parseTimedID3MetadataPayload","kH264","parseH264Payload","kH265","parseH265Payload","version_number","current_next_indicator","section_number","pat","PAT","pat_","program_bytes","first_program_number","first_pmt_pid","program_number","network_pid","JSON","stringify","current_program_","pmt","PMT","program_info_length","info_start_index","info_bytes","elementary_PID","ES_info_length","already_has_video","already_has_audio","registration","from","channel_config_code","sample","dispatchAudioInitSegment","detectAudioMetadataChange","dispatchAudioMediaSegment","descriptors","dispatchPESPrivateDataDescriptor","scte35","pts_ms","nearest_pts","annexb_parser","nalu_avc1","H264NaluAVC1","detectVideoMetadataChange","dispatchVideoMediaSegment","dispatchVideoInitSegment","kSliceIDR","kSliceNonIDR","dts_ms","avc_sample","nalu_hvc1","H265NaluHVC1","kSliceIDR_W_RADL","kSliceIDR_N_LP","kSliceCRA_NUT","hvc_sample","new_sps","new_details","old_size","new_size","isInitSegmentDispatched","vps_without_header","sps_without_header","pps_without_header","HEVCDecoderConfigurationRecord","AVCDecoderConfigurationRecord","ref_sample_duration","base_pts_ms","new_pts_ms","abs","last_sample_pts_ms","adts_parser","sample_pts_ms","audio_sample","sample_pts_ms_int","aac_sample","loas_parser","ac3_sample","opus_pending_trim_start","trim_end","opus_sample","object_type","MP3Data","mp3_sample","audio_specific_config","ac3_config","AC3Config","channelConfigCode","descriptor","desc","PESPrivateDataDescriptor","PESPrivateData","timed_id3_metadata","smpte2038_data","SMPTE2038Data","ancillaries","YC_indicator","line_number","horizontal_offset","data_ID","data_SDID","data_count","user_data","user_data_word","description","yc_indicator","did","sdid","information","smpte2038parse","MP4","types","avc1","avcC","btrt","dinf","dref","esds","ftyp","hdlr","hvc1","hvcC","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","sdtp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trun","trex","tkhd","vmhd","smhd","Opus","dOps","dac3","charCodeAt","constants","FTYP","STSD_PREFIX","STTS","STSC","STCO","STSZ","HDLR_VIDEO","HDLR_AUDIO","DREF","SMHD","VMHD","box","datas","arrayCount","generateInitSegment","trackId","xmhd","startsWith","sampleRate","configSize","mapping","baseMediaDecodeTime","sampleCount","isLeading","dependsOn","isDependedOn","hasRedundancy","isNonSync","getSilentFrame","_isLive","isLive","_dtsBase","_dtsBaseInited","_audioDtsBase","Infinity","_videoDtsBase","_audioNextDts","_videoNextDts","_audioStashedLastSample","_videoStashedLastSample","_audioMeta","_videoMeta","_audioSegmentInfoList","_videoSegmentInfoList","_onInitSegment","_onMediaSegment","_forceFirstIDR","_fillSilentAfterSeek","msedge","msie","_mp3UseMpegAudio","firefox","_fillAudioTimestampGap","fixAudioTimestampGap","producer","remux","_onTrackMetadataReceived","insertDiscontinuity","seek","audioTrack","videoTrack","_calculateDtsBase","_remuxVideo","_remuxAudio","metabox","container","mediaDuration","getTimestampBase","flushStashedSamples","videoSample","audioSample","force","lastDts","dtsCorrection","firstDts","mpegRawTrack","firstSegmentAfterSeek","insertPrefixSilentFrame","mdatbox","mdatBytes","firstSampleOriginalDts","distance","firstSampleDts","videoSegment","silentUnit","silentFrameDuration","mp4Samples","needFillSilentFrames","silentFrames","sampleDuration","curRefDts","frameCount","round","intDts","intDuration","latest","moofbox","_mergeBoxes","timestampOffset","lastPts","firstPts","syncPoint","mediaDataSource","_emitter","filesize","url","cors","withCredentials","_mediaDataSource","_currentSegmentIndex","totalDuration","forEach","timestampBase","referrerPolicy","_demuxer","_remuxer","_ioctl","_pendingSeekTime","_pendingResolveSeekPoint","_statisticsReporter","_disableStatisticsReporter","event","_loadSegment","_enableStatisticsReporter","segmentIndex","optionalFrom","ioctl","_onIOException","onSeeked","_onIOSeeked","onComplete","_onIOComplete","onRedirect","_onIORedirect","onRecoveredEarlyEof","_onIORecoveredEarlyEof","_onInitChunkArrival","stop","_internalAbort","pause","resume","isPaused","targetSegmentIndex","_searchSegmentIndexContains","segmentInfo","targetSegmentInfo","_reportSegmentMediaInfo","_setupFLVDemuxerRemuxer","_setupTSDemuxerRemuxer","then","mds","overridedDuration","overridedHasAudio","overridedHasVideo","_onDemuxException","onScriptDataArrived","onInitSegment","_onRemuxerInitSegmentArrival","onMediaSegment","_onRemuxerMediaSegmentArrival","demuxer","_onTimedID3Metadata","_onSMPTE2038Metadata","_onSCTE35Metadata","_onPESPrivateDataDescriptor","_onPESPrivateData","mediaInfo","setPrototypeOf","timestamp_base","smpte2038_metadata","extraData","nextSegmentIndex","redirectedURL","code","initSegment","mediaSegment","seekpoint","setInterval","_reportStatisticsInfo","statisticsInfoReportInterval","clearInterval","exportInfo","currentURL","hasRedirect","currentRedirectedURL","speed","currentSpeed","loaderType","currentSegmentIndex","totalSegmentCount","_firstCheckpoint","_lastCheckpoint","_intervalBytes","_totalBytes","_lastSecondBytes","performance","now","_now","reset","addBytes","bytes","durationSeconds","currentKBps","seekHandler","_seekHandler","_requestAbort","_abortController","_contentLength","_receivedLength","isSupported","isWorkWellEdge","browserNotBlacklisted","fetch","ReadableStream","_dataSource","_range","sourceURL","reuseRedirectedURL","seekConfig","headers","Headers","configHeaders","params","method","cache","credentials","AbortController","signal","res","body","cancel","ok","status","removeURLParameters","lengthHeader","_pump","getReader","statusText","catch","aborted","read","done","_xhr","xhr","XMLHttpRequest","responseType","onreadystatechange","onprogress","onloadend","onerror","_requestURL","_onReadyStateChange","_onProgress","_onLoadEnd","_onXhrError","setRequestHeader","send","readyState","responseURL","total","response","loaded","constructor","_chunkSizeKBList","_currentChunkSizeKB","_currentSpeedNormalized","_zeroSpeedChunkCount","_speedSampler","_waitForTotalLength","_totalLengthReceived","_currentRequestURL","_currentRedirectedURL","_currentRequestRange","_totalLength","_lastTimeLoaded","onload","lastSecondKBps","useRefTotalLength","_openSubRange","_internalOpen","to","chunkSize","_onLoad","openNextRange","delta","_normalizeSpeed","KBps","normalized","reportComplete","_ws","WebSocket","ws","binaryType","onopen","_onWebSocketOpen","onclose","_onWebSocketClose","onmessage","_onWebSocketMessage","_onWebSocketError","close","_dispatchArrayBuffer","Blob","FileReader","readAsArrayBuffer","arraybuffer","zeroStart","_zeroStart","param","seekedURL","paramStart","paramEnd","_startName","_endName","baseUrl","needAnd","baseURL","queryIndex","substring","resultParams","pairs","pair","requireAnd","_extraData","_stashInitialSize","stashInitialSize","_stashUsed","_stashSize","_bufferSize","_stashBuffer","_stashByteStart","_enableStash","enableStashBuffer","_loader","_loaderClass","_isWebSocketURL","test","_refTotalLength","_fullRequestFlag","_currentRange","_redirectedURL","_speedNormalized","_speedNormalizeList","_isEarlyEofReconnecting","_paused","_resumeFrom","_onSeeked","_onRedirect","_onRecoveredEarlyEof","_selectSeekHandler","_selectLoader","_createLoader","seekType","rangeLoadZeroStart","seekParamStart","seekParamEnd","customSeekHandler","customLoader","needStashBuffer","onContentLengthKnown","onURLRedirect","_onLoaderChunkArrival","_onLoaderComplete","_onLoaderError","_internalSeek","dropUnconsumed","_flushStashBuffer","requestRange","updateUrl","_expandBuffer","expectedBytes","bufferNewSize","newBuffer","stashOldArray","_adjustStashSize","stashSizeKB","bufferSize","_dispatchChunks","chunks","contentLength","receivedLength","stashArray","remainArray","remain","nextFrom","install","obj","proto","__proto__","output","source","polyfill","Polyfill","webpackBootstrapFunc","configurable","oe","f","ENTRY_MODULE","default","quoteRegExp","replace","getModuleDependencies","sources","queueName","retval","fnString","wrapperSignature","webpackRequireName","re","RegExp","hasValuesInQueues","queues","reduce","hasValues","options","main","requiredModules","all","modulesQueue","seenModules","moduleToCheck","newModules","newModulesKeys","getRequiredModules","filter","entryModule","map","blob","bare","workerUrl","URL","webkitURL","mozURL","msURL","createObjectURL","worker","Worker","objectURL","isFunction","x","isArray","vertxNext","customSchedulerFn","asap","queue","flush","scheduleFlush","browserWindow","browserGlobal","BrowserMutationObserver","MutationObserver","WebKitMutationObserver","isNode","process","isWorker","Uint8ClampedArray","importScripts","MessageChannel","useSetTimeout","globalSetTimeout","setTimeout","channel","iterations","observer","node","onFulfillment","onRejection","parent","child","noop","PROMISE_ID","makePromise","_state","invokeCallback","_result","subscribe","resolve$1","promise","nextTick","document","createTextNode","observe","characterData","port1","port2","postMessage","vertx","require","runOnLoop","runOnContext","attemptVertx","random","handleMaybeThenable","maybeThenable","then$$1","thenable","fulfill","reason","handleOwnThenable","sealed","fulfillmentHandler","rejectionHandler","tryThen","_label","handleForeignThenable","publishRejection","_onerror","publish","_subscribers","subscribers","settled","hasCallback","succeeded","Enumerator","Constructor","_instanceConstructor","_remaining","_enumerate","_eachEntry","entry","resolve$$1","_then","didError","_settledAt","Promise$1","_willSettleAt","enumerator","needsResolver","initializePromise","needsNew","finally","entries","race","_","_setScheduler","scheduleFn","_setAsap","asapFn","_asap","local","global","P","promiseToString","cast","cachedSetTimeout","cachedClearTimeout","defaultSetTimout","defaultClearTimeout","runTimeout","fun","clearTimeout","currentQueue","draining","queueIndex","cleanUpNextTick","drainQueue","timeout","run","marker","runClearTimeout","Item","title","env","argv","versions","binding","cwd","chdir","dir","umask","g","controller","logcatListener","logcat","onLoadingComplete","onTimedID3MetadataArrived","onSMPTE2038MetadataArrived","onSCTE35MetadataArrived","onPESPrivateDataArrived","onStatisticsInfo","statInfo","onIOError","onDemuxError","onRecommendSeekpoint","cmd","defaultConfig","enableWorker","liveBufferLatencyChasing","liveBufferLatencyMaxLatency","liveBufferLatencyMinRemain","lazyLoad","lazyLoadMaxDuration","lazyLoadRecoverDuration","deferLoadAfterSourceOpen","autoCleanupMaxBackwardDuration","autoCleanupMinBackwardDuration","accurateSeek","createDefaultConfig","supportMSEH264Playback","MediaSource","isTypeSupported","supportMSEH265Playback","supportNetworkStreamIO","getNetworkLoaderTypeName","supportNativeMediaPlayback","Features","videoElement","createElement","canPlay","canPlayType","getFeatureList","features","msePlayback","mseLivePlayback","mseH265Playback","networkStreamIO","networkLoaderName","nativeMP4H264Playback","nativeMP4H265Playback","nativeWebmVP8Playback","nativeWebmVP9Playback","ERROR","_worker","_workerDestroying","_onWorkerMessage","onLoggingConfigChanged","_onLoggingConfigChanged","_controller","ctl","_onIOError","_onDemuxError","_onLoadingComplete","_onTimedID3MetadataArrived","_onSMPTE2038MetadataArrived","_onSCTE35MetadataArrived","_onPESPrivateDataArrived","_onStatisticsInfo","_onRecommendSeekpoint","hasWorker","statisticsInfo","terminate","SOURCE_OPEN","UPDATE_END","BUFFER_FULL","autoCleanupSourceBuffer","onSourceOpen","_onSourceOpen","onSourceEnded","_onSourceEnded","onSourceClose","_onSourceClose","onSourceBufferError","_onSourceBufferError","onSourceBufferUpdateEnd","_onSourceBufferUpdateEnd","_mediaSource","_mediaSourceObjectURL","_mediaElement","_isBufferFull","_hasPendingEos","_requireSetMediaDuration","_pendingMediaDuration","_pendingSourceBufferInit","_mimeTypes","video","audio","_sourceBuffers","_lastInitSegments","_pendingSegments","_pendingRemoveRanges","_idrList","detachMediaElement","attachMediaElement","mediaElement","ms","ps","sb","removeSourceBuffer","endOfStream","removeAttribute","revokeObjectURL","appendInitSegment","deferred","is","firstInitSegment","addSourceBuffer","updating","_doAppendSegments","_updateMediaSourceDuration","appendMediaSegment","_needCleanupSourceBuffer","_doCleanupSourceBuffer","_hasPendingRemoveRanges","seconds","buffered","end","_doRemoveRanges","lastInitSegment","_hasPendingSegments","currentTime","doRemove","removeEnd","current","ranges","remove","pendingSegments","currentOffset","targetOffset","appendBuffer","pendings","prr","ErrorTypes","NETWORK_ERROR","MEDIA_ERROR","OTHER_ERROR","ErrorDetails","NETWORK_EXCEPTION","NETWORK_STATUS_CODE_INVALID","NETWORK_TIMEOUT","NETWORK_UNRECOVERABLE_EARLY_EOF","MEDIA_MSE_ERROR","MEDIA_FORMAT_ERROR","MEDIA_FORMAT_UNSUPPORTED","MEDIA_CODEC_UNSUPPORTED","typeLowerCase","onvLoadedMetadata","_onvLoadedMetadata","onvSeeking","_onvSeeking","onvCanPlay","_onvCanPlay","onvStalled","_onvStalled","onvProgress","_onvProgress","_requestSetTime","_seekpointRecord","_progressChecker","_msectl","_transmuxer","_mseSourceOpened","_hasPendingLoad","_receivedCanPlay","_statisticsInfo","chromeNeedIDRFix","_alwaysSeekKeyframe","unload","_onmseUpdateEnd","_onmseBufferFull","load","_suspendTransmuxer","scte35_metadata","_fillStatisticsInfo","play","volume","muted","playerType","HTMLVideoElement","hasQualityInfo","decoded","dropped","getVideoPlaybackQuality","quality","totalVideoFrames","droppedVideoFrames","webkitDecodedFrameCount","webkitDroppedFrameCount","decodedFrames","droppedFrames","paused","buffered_end","target_time","currentRangeEnd","_checkProgressAndResume","needResume","_isTimepointBuffered","directSeek","directSeekBegin","directSeekBeginTime","videoBeginTime","idr","_checkAndApplyUnbufferedSeekpoint","recordTime","_checkAndResumeStuckPlayback","stalled","media","seekPoint","preload","HTMLAudioElement","videoWidth","videoHeight","mpegts","optionalConfig","BaseLoader","Events","MSEPlayer","NativePlayer"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAK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EAChBH,EAAOhF,WAAaA,EACpBgF,EAAO5E,aAAeA,EAEtB4E,EAAOI,UAAY,EACnBJ,EAAOK,aAAe,EACtBL,EAAO1lD,eAAiB,IAExBvT,OAAOC,eAAeg5D,EAAQ,UAAW,CACrC/4D,YAAY,EACZC,IAAK,WAED,MAAO,WAIA","file":"mpegts.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"mpegts\"] = factory();\n\telse\n\t\troot[\"mpegts\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 14);\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\n\nclass Log {\n\n static e(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'error', str);\n }\n\n if (!Log.ENABLE_ERROR) {\n return;\n }\n\n if (console.error) {\n console.error(str);\n } else if (console.warn) {\n console.warn(str);\n } else {\n console.log(str);\n }\n }\n\n static i(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'info', str);\n }\n\n if (!Log.ENABLE_INFO) {\n return;\n }\n\n if (console.info) {\n console.info(str);\n } else {\n console.log(str);\n }\n }\n\n static w(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'warn', str);\n }\n\n if (!Log.ENABLE_WARN) {\n return;\n }\n\n if (console.warn) {\n console.warn(str);\n } else {\n console.log(str);\n }\n }\n\n static d(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'debug', str);\n }\n\n if (!Log.ENABLE_DEBUG) {\n return;\n }\n\n if (console.debug) {\n console.debug(str);\n } else {\n console.log(str);\n }\n }\n\n static v(tag, msg) {\n if (!tag || Log.FORCE_GLOBAL_TAG)\n tag = Log.GLOBAL_TAG;\n\n let str = `[${tag}] > ${msg}`;\n\n if (Log.ENABLE_CALLBACK) {\n Log.emitter.emit('log', 'verbose', str);\n }\n\n if (!Log.ENABLE_VERBOSE) {\n return;\n }\n\n console.log(str);\n }\n\n}\n\nLog.GLOBAL_TAG = 'mpegts.js';\nLog.FORCE_GLOBAL_TAG = false;\nLog.ENABLE_ERROR = true;\nLog.ENABLE_INFO = true;\nLog.ENABLE_WARN = true;\nLog.ENABLE_DEBUG = true;\nLog.ENABLE_VERBOSE = true;\n\nLog.ENABLE_CALLBACK = false;\n\nLog.emitter = new EventEmitter();\n\nexport default Log;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst TransmuxingEvents = {\n IO_ERROR: 'io_error',\n DEMUX_ERROR: 'demux_error',\n INIT_SEGMENT: 'init_segment',\n MEDIA_SEGMENT: 'media_segment',\n LOADING_COMPLETE: 'loading_complete',\n RECOVERED_EARLY_EOF: 'recovered_early_eof',\n MEDIA_INFO: 'media_info',\n METADATA_ARRIVED: 'metadata_arrived',\n SCRIPTDATA_ARRIVED: 'scriptdata_arrived',\n TIMED_ID3_METADATA_ARRIVED: 'timed_id3_metadata_arrived',\n SMPTE2038_METADATA_ARRIVED: 'smpte2038_metadata_arrived',\n SCTE35_METADATA_ARRIVED: 'scte35_metadata_arrived',\n PES_PRIVATE_DATA_DESCRIPTOR: 'pes_private_data_descriptor',\n PES_PRIVATE_DATA_ARRIVED: 'pes_private_data_arrived',\n STATISTICS_INFO: 'statistics_info',\n RECOMMEND_SEEKPOINT: 'recommend_seekpoint'\n};\n\nexport default TransmuxingEvents;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {NotImplementedException} from '../utils/exception.js';\n\nexport const LoaderStatus = {\n kIdle: 0,\n kConnecting: 1,\n kBuffering: 2,\n kError: 3,\n kComplete: 4\n};\n\nexport const LoaderErrors = {\n OK: 'OK',\n EXCEPTION: 'Exception',\n HTTP_STATUS_CODE_INVALID: 'HttpStatusCodeInvalid',\n CONNECTING_TIMEOUT: 'ConnectingTimeout',\n EARLY_EOF: 'EarlyEof',\n UNRECOVERABLE_EARLY_EOF: 'UnrecoverableEarlyEof'\n};\n\n/* Loader has callbacks which have following prototypes:\n * function onContentLengthKnown(contentLength: number): void\n * function onURLRedirect(url: string): void\n * function onDataArrival(chunk: ArrayBuffer, byteStart: number, receivedLength: number): void\n * function onError(errorType: number, errorInfo: {code: number, msg: string}): void\n * function onComplete(rangeFrom: number, rangeTo: number): void\n */\nexport class BaseLoader {\n\n constructor(typeName) {\n this._type = typeName || 'undefined';\n this._status = LoaderStatus.kIdle;\n this._needStash = false;\n // callbacks\n this._onContentLengthKnown = null;\n this._onURLRedirect = null;\n this._onDataArrival = null;\n this._onError = null;\n this._onComplete = null;\n }\n\n destroy() {\n this._status = LoaderStatus.kIdle;\n this._onContentLengthKnown = null;\n this._onURLRedirect = null;\n this._onDataArrival = null;\n this._onError = null;\n this._onComplete = null;\n }\n\n isWorking() {\n return this._status === LoaderStatus.kConnecting || this._status === LoaderStatus.kBuffering;\n }\n\n get type() {\n return this._type;\n }\n\n get status() {\n return this._status;\n }\n\n get needStashBuffer() {\n return this._needStash;\n }\n\n get onContentLengthKnown() {\n return this._onContentLengthKnown;\n }\n\n set onContentLengthKnown(callback) {\n this._onContentLengthKnown = callback;\n }\n\n get onURLRedirect() {\n return this._onURLRedirect;\n }\n\n set onURLRedirect(callback) {\n this._onURLRedirect = callback;\n }\n\n get onDataArrival() {\n return this._onDataArrival;\n }\n\n set onDataArrival(callback) {\n this._onDataArrival = callback;\n }\n\n get onError() {\n return this._onError;\n }\n\n set onError(callback) {\n this._onError = callback;\n }\n\n get onComplete() {\n return this._onComplete;\n }\n\n set onComplete(callback) {\n this._onComplete = callback;\n }\n\n // pure virtual\n open(dataSource, range) {\n throw new NotImplementedException('Unimplemented abstract function!');\n }\n\n abort() {\n throw new NotImplementedException('Unimplemented abstract function!');\n }\n\n\n}","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport class RuntimeException {\n\n constructor(message) {\n this._message = message;\n }\n\n get name() {\n return 'RuntimeException';\n }\n\n get message() {\n return this._message;\n }\n\n toString() {\n return this.name + ': ' + this.message;\n }\n\n}\n\nexport class IllegalStateException extends RuntimeException {\n\n constructor(message) {\n super(message);\n }\n\n get name() {\n return 'IllegalStateException';\n }\n\n}\n\nexport class InvalidArgumentException extends RuntimeException {\n\n constructor(message) {\n super(message);\n }\n\n get name() {\n return 'InvalidArgumentException';\n }\n\n}\n\nexport class NotImplementedException extends RuntimeException {\n\n constructor(message) {\n super(message);\n }\n\n get name() {\n return 'NotImplementedException';\n }\n\n}\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nlet Browser = {};\n\nfunction detect() {\n // modified from jquery-browser-plugin\n\n let ua = self.navigator.userAgent.toLowerCase();\n\n let match = /(edge)\\/([\\w.]+)/.exec(ua) ||\n /(opr)[\\/]([\\w.]+)/.exec(ua) ||\n /(chrome)[ \\/]([\\w.]+)/.exec(ua) ||\n /(iemobile)[\\/]([\\w.]+)/.exec(ua) ||\n /(version)(applewebkit)[ \\/]([\\w.]+).*(safari)[ \\/]([\\w.]+)/.exec(ua) ||\n /(webkit)[ \\/]([\\w.]+).*(version)[ \\/]([\\w.]+).*(safari)[ \\/]([\\w.]+)/.exec(ua) ||\n /(webkit)[ \\/]([\\w.]+)/.exec(ua) ||\n /(opera)(?:.*version|)[ \\/]([\\w.]+)/.exec(ua) ||\n /(msie) ([\\w.]+)/.exec(ua) ||\n ua.indexOf('trident') >= 0 && /(rv)(?::| )([\\w.]+)/.exec(ua) ||\n ua.indexOf('compatible') < 0 && /(firefox)[ \\/]([\\w.]+)/.exec(ua) ||\n [];\n\n let platform_match = /(ipad)/.exec(ua) ||\n /(ipod)/.exec(ua) ||\n /(windows phone)/.exec(ua) ||\n /(iphone)/.exec(ua) ||\n /(kindle)/.exec(ua) ||\n /(android)/.exec(ua) ||\n /(windows)/.exec(ua) ||\n /(mac)/.exec(ua) ||\n /(linux)/.exec(ua) ||\n /(cros)/.exec(ua) ||\n [];\n\n let matched = {\n browser: match[5] || match[3] || match[1] || '',\n version: match[2] || match[4] || '0',\n majorVersion: match[4] || match[2] || '0',\n platform: platform_match[0] || ''\n };\n\n let browser = {};\n if (matched.browser) {\n browser[matched.browser] = true;\n\n let versionArray = matched.majorVersion.split('.');\n browser.version = {\n major: parseInt(matched.majorVersion, 10),\n string: matched.version\n };\n if (versionArray.length > 1) {\n browser.version.minor = parseInt(versionArray[1], 10);\n }\n if (versionArray.length > 2) {\n browser.version.build = parseInt(versionArray[2], 10);\n }\n }\n\n if (matched.platform) {\n browser[matched.platform] = true;\n }\n\n if (browser.chrome || browser.opr || browser.safari) {\n browser.webkit = true;\n }\n\n // MSIE. IE11 has 'rv' identifer\n if (browser.rv || browser.iemobile) {\n if (browser.rv) {\n delete browser.rv;\n }\n let msie = 'msie';\n matched.browser = msie;\n browser[msie] = true;\n }\n\n // Microsoft Edge\n if (browser.edge) {\n delete browser.edge;\n let msedge = 'msedge';\n matched.browser = msedge;\n browser[msedge] = true;\n }\n\n // Opera 15+\n if (browser.opr) {\n let opera = 'opera';\n matched.browser = opera;\n browser[opera] = true;\n }\n\n // Stock android browsers are marked as Safari\n if (browser.safari && browser.android) {\n let android = 'android';\n matched.browser = android;\n browser[android] = true;\n }\n\n browser.name = matched.browser;\n browser.platform = matched.platform;\n\n for (let key in Browser) {\n if (Browser.hasOwnProperty(key)) {\n delete Browser[key];\n }\n }\n Object.assign(Browser, browser);\n}\n\ndetect();\n\nexport default Browser;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst DemuxErrors = {\n OK: 'OK',\n FORMAT_ERROR: 'FormatError',\n FORMAT_UNSUPPORTED: 'FormatUnsupported',\n CODEC_UNSUPPORTED: 'CodecUnsupported'\n};\n\nexport default DemuxErrors;","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Represents an media sample (audio / video)\nexport class SampleInfo {\n\n constructor(dts, pts, duration, originalDts, isSync) {\n this.dts = dts;\n this.pts = pts;\n this.duration = duration;\n this.originalDts = originalDts;\n this.isSyncPoint = isSync;\n this.fileposition = null;\n }\n\n}\n\n// Media Segment concept is defined in Media Source Extensions spec.\n// Particularly in ISO BMFF format, an Media Segment contains a moof box followed by a mdat box.\nexport class MediaSegmentInfo {\n\n constructor() {\n this.beginDts = 0;\n this.endDts = 0;\n this.beginPts = 0;\n this.endPts = 0;\n this.originalBeginDts = 0;\n this.originalEndDts = 0;\n this.syncPoints = []; // SampleInfo[n], for video IDR frames only\n this.firstSample = null; // SampleInfo\n this.lastSample = null; // SampleInfo\n }\n\n appendSyncPoint(sampleInfo) { // also called Random Access Point\n sampleInfo.isSyncPoint = true;\n this.syncPoints.push(sampleInfo);\n }\n\n}\n\n// Ordered list for recording video IDR frames, sorted by originalDts\nexport class IDRSampleList {\n\n constructor() {\n this._list = [];\n }\n\n clear() {\n this._list = [];\n }\n\n appendArray(syncPoints) {\n let list = this._list;\n\n if (syncPoints.length === 0) {\n return;\n }\n\n if (list.length > 0 && syncPoints[0].originalDts < list[list.length - 1].originalDts) {\n this.clear();\n }\n\n Array.prototype.push.apply(list, syncPoints);\n }\n\n getLastSyncPointBeforeDts(dts) {\n if (this._list.length == 0) {\n return null;\n }\n\n let list = this._list;\n let idx = 0;\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n if (dts < list[0].dts) {\n idx = 0;\n lbound = ubound + 1;\n }\n\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (dts >= list[mid].dts && dts < list[mid + 1].dts)) {\n idx = mid;\n break;\n } else if (list[mid].dts < dts) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n return this._list[idx];\n }\n\n}\n\n// Data structure for recording information of media segments in single track.\nexport class MediaSegmentInfoList {\n\n constructor(type) {\n this._type = type;\n this._list = [];\n this._lastAppendLocation = -1; // cached last insert location\n }\n\n get type() {\n return this._type;\n }\n\n get length() {\n return this._list.length;\n }\n\n isEmpty() {\n return this._list.length === 0;\n }\n\n clear() {\n this._list = [];\n this._lastAppendLocation = -1;\n }\n\n _searchNearestSegmentBefore(originalBeginDts) {\n let list = this._list;\n if (list.length === 0) {\n return -2;\n }\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n let idx = 0;\n\n if (originalBeginDts < list[0].originalBeginDts) {\n idx = -1;\n return idx;\n }\n\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (originalBeginDts > list[mid].lastSample.originalDts &&\n (originalBeginDts < list[mid + 1].originalBeginDts))) {\n idx = mid;\n break;\n } else if (list[mid].originalBeginDts < originalBeginDts) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n return idx;\n }\n\n _searchNearestSegmentAfter(originalBeginDts) {\n return this._searchNearestSegmentBefore(originalBeginDts) + 1;\n }\n\n append(mediaSegmentInfo) {\n let list = this._list;\n let msi = mediaSegmentInfo;\n let lastAppendIdx = this._lastAppendLocation;\n let insertIdx = 0;\n\n if (lastAppendIdx !== -1 && lastAppendIdx < list.length &&\n msi.originalBeginDts >= list[lastAppendIdx].lastSample.originalDts &&\n ((lastAppendIdx === list.length - 1) ||\n (lastAppendIdx < list.length - 1 &&\n msi.originalBeginDts < list[lastAppendIdx + 1].originalBeginDts))) {\n insertIdx = lastAppendIdx + 1; // use cached location idx\n } else {\n if (list.length > 0) {\n insertIdx = this._searchNearestSegmentBefore(msi.originalBeginDts) + 1;\n }\n }\n\n this._lastAppendLocation = insertIdx;\n this._list.splice(insertIdx, 0, msi);\n }\n\n getLastSegmentBefore(originalBeginDts) {\n let idx = this._searchNearestSegmentBefore(originalBeginDts);\n if (idx >= 0) {\n return this._list[idx];\n } else { // -1\n return null;\n }\n }\n\n getLastSampleBefore(originalBeginDts) {\n let segment = this.getLastSegmentBefore(originalBeginDts);\n if (segment != null) {\n return segment.lastSample;\n } else {\n return null;\n }\n }\n\n getLastSyncPointBefore(originalBeginDts) {\n let segmentIdx = this._searchNearestSegmentBefore(originalBeginDts);\n let syncPoints = this._list[segmentIdx].syncPoints;\n while (syncPoints.length === 0 && segmentIdx > 0) {\n segmentIdx--;\n syncPoints = this._list[segmentIdx].syncPoints;\n }\n if (syncPoints.length > 0) {\n return syncPoints[syncPoints.length - 1];\n } else {\n return null;\n }\n }\n\n}","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass MediaInfo {\n\n constructor() {\n this.mimeType = null;\n this.duration = null;\n\n this.hasAudio = null;\n this.hasVideo = null;\n this.audioCodec = null;\n this.videoCodec = null;\n this.audioDataRate = null;\n this.videoDataRate = null;\n\n this.audioSampleRate = null;\n this.audioChannelCount = null;\n\n this.width = null;\n this.height = null;\n this.fps = null;\n this.profile = null;\n this.level = null;\n this.refFrames = null;\n this.chromaFormat = null;\n this.sarNum = null;\n this.sarDen = null;\n\n this.metadata = null;\n this.segments = null; // MediaInfo[]\n this.segmentCount = null;\n this.hasKeyframesIndex = null;\n this.keyframesIndex = null;\n }\n\n isComplete() {\n let audioInfoComplete = (this.hasAudio === false) ||\n (this.hasAudio === true &&\n this.audioCodec != null &&\n this.audioSampleRate != null &&\n this.audioChannelCount != null);\n\n let videoInfoComplete = (this.hasVideo === false) ||\n (this.hasVideo === true &&\n this.videoCodec != null &&\n this.width != null &&\n this.height != null &&\n this.fps != null &&\n this.profile != null &&\n this.level != null &&\n this.refFrames != null &&\n this.chromaFormat != null &&\n this.sarNum != null &&\n this.sarDen != null);\n\n // keyframesIndex may not be present\n return this.mimeType != null &&\n audioInfoComplete &&\n videoInfoComplete;\n }\n\n isSeekable() {\n return this.hasKeyframesIndex === true;\n }\n\n getNearestKeyframe(milliseconds) {\n if (this.keyframesIndex == null) {\n return null;\n }\n\n let table = this.keyframesIndex;\n let keyframeIdx = this._search(table.times, milliseconds);\n\n return {\n index: keyframeIdx,\n milliseconds: table.times[keyframeIdx],\n fileposition: table.filepositions[keyframeIdx]\n };\n }\n\n _search(list, value) {\n let idx = 0;\n\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n if (value < list[0]) {\n idx = 0;\n lbound = ubound + 1; // skip search\n }\n\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (value >= list[mid] && value < list[mid + 1])) {\n idx = mid;\n break;\n } else if (list[mid] < value) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n\n return idx;\n }\n\n}\n\nexport default MediaInfo;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport Log from './logger.js';\n\nclass LoggingControl {\n\n static get forceGlobalTag() {\n return Log.FORCE_GLOBAL_TAG;\n }\n\n static set forceGlobalTag(enable) {\n Log.FORCE_GLOBAL_TAG = enable;\n LoggingControl._notifyChange();\n }\n\n static get globalTag() {\n return Log.GLOBAL_TAG;\n }\n\n static set globalTag(tag) {\n Log.GLOBAL_TAG = tag;\n LoggingControl._notifyChange();\n }\n\n static get enableAll() {\n return Log.ENABLE_VERBOSE\n && Log.ENABLE_DEBUG\n && Log.ENABLE_INFO\n && Log.ENABLE_WARN\n && Log.ENABLE_ERROR;\n }\n\n static set enableAll(enable) {\n Log.ENABLE_VERBOSE = enable;\n Log.ENABLE_DEBUG = enable;\n Log.ENABLE_INFO = enable;\n Log.ENABLE_WARN = enable;\n Log.ENABLE_ERROR = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableDebug() {\n return Log.ENABLE_DEBUG;\n }\n\n static set enableDebug(enable) {\n Log.ENABLE_DEBUG = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableVerbose() {\n return Log.ENABLE_VERBOSE;\n }\n\n static set enableVerbose(enable) {\n Log.ENABLE_VERBOSE = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableInfo() {\n return Log.ENABLE_INFO;\n }\n\n static set enableInfo(enable) {\n Log.ENABLE_INFO = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableWarn() {\n return Log.ENABLE_WARN;\n }\n\n static set enableWarn(enable) {\n Log.ENABLE_WARN = enable;\n LoggingControl._notifyChange();\n }\n\n static get enableError() {\n return Log.ENABLE_ERROR;\n }\n\n static set enableError(enable) {\n Log.ENABLE_ERROR = enable;\n LoggingControl._notifyChange();\n }\n\n static getConfig() {\n return {\n globalTag: Log.GLOBAL_TAG,\n forceGlobalTag: Log.FORCE_GLOBAL_TAG,\n enableVerbose: Log.ENABLE_VERBOSE,\n enableDebug: Log.ENABLE_DEBUG,\n enableInfo: Log.ENABLE_INFO,\n enableWarn: Log.ENABLE_WARN,\n enableError: Log.ENABLE_ERROR,\n enableCallback: Log.ENABLE_CALLBACK\n };\n }\n\n static applyConfig(config) {\n Log.GLOBAL_TAG = config.globalTag;\n Log.FORCE_GLOBAL_TAG = config.forceGlobalTag;\n Log.ENABLE_VERBOSE = config.enableVerbose;\n Log.ENABLE_DEBUG = config.enableDebug;\n Log.ENABLE_INFO = config.enableInfo;\n Log.ENABLE_WARN = config.enableWarn;\n Log.ENABLE_ERROR = config.enableError;\n Log.ENABLE_CALLBACK = config.enableCallback;\n }\n\n static _notifyChange() {\n let emitter = LoggingControl.emitter;\n\n if (emitter.listenerCount('change') > 0) {\n let config = LoggingControl.getConfig();\n emitter.emit('change', config);\n }\n }\n\n static registerListener(listener) {\n LoggingControl.emitter.addListener('change', listener);\n }\n\n static removeListener(listener) {\n LoggingControl.emitter.removeListener('change', listener);\n }\n\n static addLogListener(listener) {\n Log.emitter.addListener('log', listener);\n if (Log.emitter.listenerCount('log') > 0) {\n Log.ENABLE_CALLBACK = true;\n LoggingControl._notifyChange();\n }\n }\n\n static removeLogListener(listener) {\n Log.emitter.removeListener('log', listener);\n if (Log.emitter.listenerCount('log') === 0) {\n Log.ENABLE_CALLBACK = false;\n LoggingControl._notifyChange();\n }\n }\n\n}\n\nLoggingControl.emitter = new EventEmitter();\n\nexport default LoggingControl;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * This file is derived from C++ project libWinTF8 (https://github.com/m13253/libWinTF8)\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nfunction checkContinuation(uint8array, start, checkLength) {\n let array = uint8array;\n if (start + checkLength < array.length) {\n while (checkLength--) {\n if ((array[++start] & 0xC0) !== 0x80)\n return false;\n }\n return true;\n } else {\n return false;\n }\n}\n\nfunction decodeUTF8(uint8array) {\n let out = [];\n let input = uint8array;\n let i = 0;\n let length = uint8array.length;\n\n while (i < length) {\n if (input[i] < 0x80) {\n out.push(String.fromCharCode(input[i]));\n ++i;\n continue;\n } else if (input[i] < 0xC0) {\n // fallthrough\n } else if (input[i] < 0xE0) {\n if (checkContinuation(input, i, 1)) {\n let ucs4 = (input[i] & 0x1F) << 6 | (input[i + 1] & 0x3F);\n if (ucs4 >= 0x80) {\n out.push(String.fromCharCode(ucs4 & 0xFFFF));\n i += 2;\n continue;\n }\n }\n } else if (input[i] < 0xF0) {\n if (checkContinuation(input, i, 2)) {\n let ucs4 = (input[i] & 0xF) << 12 | (input[i + 1] & 0x3F) << 6 | input[i + 2] & 0x3F;\n if (ucs4 >= 0x800 && (ucs4 & 0xF800) !== 0xD800) {\n out.push(String.fromCharCode(ucs4 & 0xFFFF));\n i += 3;\n continue;\n }\n }\n } else if (input[i] < 0xF8) {\n if (checkContinuation(input, i, 3)) {\n let ucs4 = (input[i] & 0x7) << 18 | (input[i + 1] & 0x3F) << 12\n | (input[i + 2] & 0x3F) << 6 | (input[i + 3] & 0x3F);\n if (ucs4 > 0x10000 && ucs4 < 0x110000) {\n ucs4 -= 0x10000;\n out.push(String.fromCharCode((ucs4 >>> 10) | 0xD800));\n out.push(String.fromCharCode((ucs4 & 0x3FF) | 0xDC00));\n i += 4;\n continue;\n }\n }\n }\n out.push(String.fromCharCode(0xFFFD));\n ++i;\n }\n\n return out.join('');\n}\n\nexport default decodeUTF8;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport decodeUTF8 from '../utils/utf8-conv.js';\nimport {IllegalStateException} from '../utils/exception.js';\n\nlet le = (function () {\n let buf = new ArrayBuffer(2);\n (new DataView(buf)).setInt16(0, 256, true); // little-endian write\n return (new Int16Array(buf))[0] === 256; // platform-spec read, if equal then LE\n})();\n\nclass AMF {\n\n static parseScriptData(arrayBuffer, dataOffset, dataSize) {\n let data = {};\n\n try {\n let name = AMF.parseValue(arrayBuffer, dataOffset, dataSize);\n let value = AMF.parseValue(arrayBuffer, dataOffset + name.size, dataSize - name.size);\n\n data[name.data] = value.data;\n } catch (e) {\n Log.e('AMF', e.toString());\n }\n\n return data;\n }\n\n static parseObject(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 3) {\n throw new IllegalStateException('Data not enough when parse ScriptDataObject');\n }\n let name = AMF.parseString(arrayBuffer, dataOffset, dataSize);\n let value = AMF.parseValue(arrayBuffer, dataOffset + name.size, dataSize - name.size);\n let isObjectEnd = value.objectEnd;\n\n return {\n data: {\n name: name.data,\n value: value.data\n },\n size: name.size + value.size,\n objectEnd: isObjectEnd\n };\n }\n\n static parseVariable(arrayBuffer, dataOffset, dataSize) {\n return AMF.parseObject(arrayBuffer, dataOffset, dataSize);\n }\n\n static parseString(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 2) {\n throw new IllegalStateException('Data not enough when parse String');\n }\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n let length = v.getUint16(0, !le);\n\n let str;\n if (length > 0) {\n str = decodeUTF8(new Uint8Array(arrayBuffer, dataOffset + 2, length));\n } else {\n str = '';\n }\n\n return {\n data: str,\n size: 2 + length\n };\n }\n\n static parseLongString(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 4) {\n throw new IllegalStateException('Data not enough when parse LongString');\n }\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n let length = v.getUint32(0, !le);\n\n let str;\n if (length > 0) {\n str = decodeUTF8(new Uint8Array(arrayBuffer, dataOffset + 4, length));\n } else {\n str = '';\n }\n\n return {\n data: str,\n size: 4 + length\n };\n }\n\n static parseDate(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 10) {\n throw new IllegalStateException('Data size invalid when parse Date');\n }\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n let timestamp = v.getFloat64(0, !le);\n let localTimeOffset = v.getInt16(8, !le);\n timestamp += localTimeOffset * 60 * 1000; // get UTC time\n\n return {\n data: new Date(timestamp),\n size: 8 + 2\n };\n }\n\n static parseValue(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 1) {\n throw new IllegalStateException('Data not enough when parse Value');\n }\n\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let offset = 1;\n let type = v.getUint8(0);\n let value;\n let objectEnd = false;\n\n try {\n switch (type) {\n case 0: // Number(Double) type\n value = v.getFloat64(1, !le);\n offset += 8;\n break;\n case 1: { // Boolean type\n let b = v.getUint8(1);\n value = b ? true : false;\n offset += 1;\n break;\n }\n case 2: { // String type\n let amfstr = AMF.parseString(arrayBuffer, dataOffset + 1, dataSize - 1);\n value = amfstr.data;\n offset += amfstr.size;\n break;\n }\n case 3: { // Object(s) type\n value = {};\n let terminal = 0; // workaround for malformed Objects which has missing ScriptDataObjectEnd\n if ((v.getUint32(dataSize - 4, !le) & 0x00FFFFFF) === 9) {\n terminal = 3;\n }\n while (offset < dataSize - 4) { // 4 === type(UI8) + ScriptDataObjectEnd(UI24)\n let amfobj = AMF.parseObject(arrayBuffer, dataOffset + offset, dataSize - offset - terminal);\n if (amfobj.objectEnd)\n break;\n value[amfobj.data.name] = amfobj.data.value;\n offset += amfobj.size;\n }\n if (offset <= dataSize - 3) {\n let marker = v.getUint32(offset - 1, !le) & 0x00FFFFFF;\n if (marker === 9) {\n offset += 3;\n }\n }\n break;\n }\n case 8: { // ECMA array type (Mixed array)\n value = {};\n offset += 4; // ECMAArrayLength(UI32)\n let terminal = 0; // workaround for malformed MixedArrays which has missing ScriptDataObjectEnd\n if ((v.getUint32(dataSize - 4, !le) & 0x00FFFFFF) === 9) {\n terminal = 3;\n }\n while (offset < dataSize - 8) { // 8 === type(UI8) + ECMAArrayLength(UI32) + ScriptDataVariableEnd(UI24)\n let amfvar = AMF.parseVariable(arrayBuffer, dataOffset + offset, dataSize - offset - terminal);\n if (amfvar.objectEnd)\n break;\n value[amfvar.data.name] = amfvar.data.value;\n offset += amfvar.size;\n }\n if (offset <= dataSize - 3) {\n let marker = v.getUint32(offset - 1, !le) & 0x00FFFFFF;\n if (marker === 9) {\n offset += 3;\n }\n }\n break;\n }\n case 9: // ScriptDataObjectEnd\n value = undefined;\n offset = 1;\n objectEnd = true;\n break;\n case 10: { // Strict array type\n // ScriptDataValue[n]. NOTE: according to video_file_format_spec_v10_1.pdf\n value = [];\n let strictArrayLength = v.getUint32(1, !le);\n offset += 4;\n for (let i = 0; i < strictArrayLength; i++) {\n let val = AMF.parseValue(arrayBuffer, dataOffset + offset, dataSize - offset);\n value.push(val.data);\n offset += val.size;\n }\n break;\n }\n case 11: { // Date type\n let date = AMF.parseDate(arrayBuffer, dataOffset + 1, dataSize - 1);\n value = date.data;\n offset += date.size;\n break;\n }\n case 12: { // Long string type\n let amfLongStr = AMF.parseString(arrayBuffer, dataOffset + 1, dataSize - 1);\n value = amfLongStr.data;\n offset += amfLongStr.size;\n break;\n }\n default:\n // ignore and skip\n offset = dataSize;\n Log.w('AMF', 'Unsupported AMF value type ' + type);\n }\n } catch (e) {\n Log.e('AMF', e.toString());\n }\n\n return {\n data: value,\n size: offset,\n objectEnd: objectEnd\n };\n }\n\n}\n\nexport default AMF;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {IllegalStateException, InvalidArgumentException} from '../utils/exception.js';\n\n// Exponential-Golomb buffer decoder\nclass ExpGolomb {\n\n constructor(uint8array) {\n this.TAG = 'ExpGolomb';\n\n this._buffer = uint8array;\n this._buffer_index = 0;\n this._total_bytes = uint8array.byteLength;\n this._total_bits = uint8array.byteLength * 8;\n this._current_word = 0;\n this._current_word_bits_left = 0;\n }\n\n destroy() {\n this._buffer = null;\n }\n\n _fillCurrentWord() {\n let buffer_bytes_left = this._total_bytes - this._buffer_index;\n if (buffer_bytes_left <= 0)\n throw new IllegalStateException('ExpGolomb: _fillCurrentWord() but no bytes available');\n\n let bytes_read = Math.min(4, buffer_bytes_left);\n let word = new Uint8Array(4);\n word.set(this._buffer.subarray(this._buffer_index, this._buffer_index + bytes_read));\n this._current_word = new DataView(word.buffer).getUint32(0, false);\n\n this._buffer_index += bytes_read;\n this._current_word_bits_left = bytes_read * 8;\n }\n\n readBits(bits) {\n if (bits > 32)\n throw new InvalidArgumentException('ExpGolomb: readBits() bits exceeded max 32bits!');\n\n if (bits <= this._current_word_bits_left) {\n let result = this._current_word >>> (32 - bits);\n this._current_word <<= bits;\n this._current_word_bits_left -= bits;\n return result;\n }\n\n let result = this._current_word_bits_left ? this._current_word : 0;\n result = result >>> (32 - this._current_word_bits_left);\n let bits_need_left = bits - this._current_word_bits_left;\n\n this._fillCurrentWord();\n let bits_read_next = Math.min(bits_need_left, this._current_word_bits_left);\n\n let result2 = this._current_word >>> (32 - bits_read_next);\n this._current_word <<= bits_read_next;\n this._current_word_bits_left -= bits_read_next;\n\n result = (result << bits_read_next) | result2;\n return result;\n }\n\n readBool() {\n return this.readBits(1) === 1;\n }\n\n readByte() {\n return this.readBits(8);\n }\n\n _skipLeadingZero() {\n let zero_count;\n for (zero_count = 0; zero_count < this._current_word_bits_left; zero_count++) {\n if (0 !== (this._current_word & (0x80000000 >>> zero_count))) {\n this._current_word <<= zero_count;\n this._current_word_bits_left -= zero_count;\n return zero_count;\n }\n }\n this._fillCurrentWord();\n return zero_count + this._skipLeadingZero();\n }\n\n readUEG() { // unsigned exponential golomb\n let leading_zeros = this._skipLeadingZero();\n return this.readBits(leading_zeros + 1) - 1;\n }\n\n readSEG() { // signed exponential golomb\n let value = this.readUEG();\n if (value & 0x01) {\n return (value + 1) >>> 1;\n } else {\n return -1 * (value >>> 1);\n }\n }\n\n}\n\nexport default ExpGolomb;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport ExpGolomb from './exp-golomb.js';\n\nclass SPSParser {\n\n static _ebsp2rbsp(uint8array) {\n let src = uint8array;\n let src_length = src.byteLength;\n let dst = new Uint8Array(src_length);\n let dst_idx = 0;\n\n for (let i = 0; i < src_length; i++) {\n if (i >= 2) {\n // Unescape: Skip 0x03 after 00 00\n if (src[i] === 0x03 && src[i - 1] === 0x00 && src[i - 2] === 0x00) {\n continue;\n }\n }\n dst[dst_idx] = src[i];\n dst_idx++;\n }\n\n return new Uint8Array(dst.buffer, 0, dst_idx);\n }\n\n static parseSPS(uint8array) {\n let codec_array = uint8array.subarray(1, 4);\n let codec_mimetype = 'avc1.';\n for (let j = 0; j < 3; j++) {\n let h = codec_array[j].toString(16);\n if (h.length < 2) {\n h = '0' + h;\n }\n codec_mimetype += h;\n }\n\n let rbsp = SPSParser._ebsp2rbsp(uint8array);\n let gb = new ExpGolomb(rbsp);\n\n gb.readByte();\n let profile_idc = gb.readByte(); // profile_idc\n gb.readByte(); // constraint_set_flags[5] + reserved_zero[3]\n let level_idc = gb.readByte(); // level_idc\n gb.readUEG(); // seq_parameter_set_id\n\n let profile_string = SPSParser.getProfileString(profile_idc);\n let level_string = SPSParser.getLevelString(level_idc);\n let chroma_format_idc = 1;\n let chroma_format = 420;\n let chroma_format_table = [0, 420, 422, 444];\n let bit_depth_luma = 8;\n let bit_depth_chroma = 8;\n\n if (profile_idc === 100 || profile_idc === 110 || profile_idc === 122 ||\n profile_idc === 244 || profile_idc === 44 || profile_idc === 83 ||\n profile_idc === 86 || profile_idc === 118 || profile_idc === 128 ||\n profile_idc === 138 || profile_idc === 144) {\n\n chroma_format_idc = gb.readUEG();\n if (chroma_format_idc === 3) {\n gb.readBits(1); // separate_colour_plane_flag\n }\n if (chroma_format_idc <= 3) {\n chroma_format = chroma_format_table[chroma_format_idc];\n }\n\n bit_depth_luma = gb.readUEG() + 8; // bit_depth_luma_minus8\n bit_depth_chroma = gb.readUEG() + 8; // bit_depth_chroma_minus8\n gb.readBits(1); // qpprime_y_zero_transform_bypass_flag\n if (gb.readBool()) { // seq_scaling_matrix_present_flag\n let scaling_list_count = (chroma_format_idc !== 3) ? 8 : 12;\n for (let i = 0; i < scaling_list_count; i++) {\n if (gb.readBool()) { // seq_scaling_list_present_flag\n if (i < 6) {\n SPSParser._skipScalingList(gb, 16);\n } else {\n SPSParser._skipScalingList(gb, 64);\n }\n }\n }\n }\n }\n gb.readUEG(); // log2_max_frame_num_minus4\n let pic_order_cnt_type = gb.readUEG();\n if (pic_order_cnt_type === 0) {\n gb.readUEG(); // log2_max_pic_order_cnt_lsb_minus_4\n } else if (pic_order_cnt_type === 1) {\n gb.readBits(1); // delta_pic_order_always_zero_flag\n gb.readSEG(); // offset_for_non_ref_pic\n gb.readSEG(); // offset_for_top_to_bottom_field\n let num_ref_frames_in_pic_order_cnt_cycle = gb.readUEG();\n for (let i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {\n gb.readSEG(); // offset_for_ref_frame\n }\n }\n let ref_frames = gb.readUEG(); // max_num_ref_frames\n gb.readBits(1); // gaps_in_frame_num_value_allowed_flag\n\n let pic_width_in_mbs_minus1 = gb.readUEG();\n let pic_height_in_map_units_minus1 = gb.readUEG();\n\n let frame_mbs_only_flag = gb.readBits(1);\n if (frame_mbs_only_flag === 0) {\n gb.readBits(1); // mb_adaptive_frame_field_flag\n }\n gb.readBits(1); // direct_8x8_inference_flag\n\n let frame_crop_left_offset = 0;\n let frame_crop_right_offset = 0;\n let frame_crop_top_offset = 0;\n let frame_crop_bottom_offset = 0;\n\n let frame_cropping_flag = gb.readBool();\n if (frame_cropping_flag) {\n frame_crop_left_offset = gb.readUEG();\n frame_crop_right_offset = gb.readUEG();\n frame_crop_top_offset = gb.readUEG();\n frame_crop_bottom_offset = gb.readUEG();\n }\n\n let sar_width = 1, sar_height = 1;\n let fps = 0, fps_fixed = true, fps_num = 0, fps_den = 0;\n\n let vui_parameters_present_flag = gb.readBool();\n if (vui_parameters_present_flag) {\n if (gb.readBool()) { // aspect_ratio_info_present_flag\n let aspect_ratio_idc = gb.readByte();\n let sar_w_table = [1, 12, 10, 16, 40, 24, 20, 32, 80, 18, 15, 64, 160, 4, 3, 2];\n let sar_h_table = [1, 11, 11, 11, 33, 11, 11, 11, 33, 11, 11, 33, 99, 3, 2, 1];\n\n if (aspect_ratio_idc > 0 && aspect_ratio_idc < 16) {\n sar_width = sar_w_table[aspect_ratio_idc - 1];\n sar_height = sar_h_table[aspect_ratio_idc - 1];\n } else if (aspect_ratio_idc === 255) {\n sar_width = gb.readByte() << 8 | gb.readByte();\n sar_height = gb.readByte() << 8 | gb.readByte();\n }\n }\n\n if (gb.readBool()) { // overscan_info_present_flag\n gb.readBool(); // overscan_appropriate_flag\n }\n if (gb.readBool()) { // video_signal_type_present_flag\n gb.readBits(4); // video_format & video_full_range_flag\n if (gb.readBool()) { // colour_description_present_flag\n gb.readBits(24); // colour_primaries & transfer_characteristics & matrix_coefficients\n }\n }\n if (gb.readBool()) { // chroma_loc_info_present_flag\n gb.readUEG(); // chroma_sample_loc_type_top_field\n gb.readUEG(); // chroma_sample_loc_type_bottom_field\n }\n if (gb.readBool()) { // timing_info_present_flag\n let num_units_in_tick = gb.readBits(32);\n let time_scale = gb.readBits(32);\n fps_fixed = gb.readBool(); // fixed_frame_rate_flag\n\n fps_num = time_scale;\n fps_den = num_units_in_tick * 2;\n fps = fps_num / fps_den;\n }\n }\n\n let sarScale = 1;\n if (sar_width !== 1 || sar_height !== 1) {\n sarScale = sar_width / sar_height;\n }\n\n let crop_unit_x = 0, crop_unit_y = 0;\n if (chroma_format_idc === 0) {\n crop_unit_x = 1;\n crop_unit_y = 2 - frame_mbs_only_flag;\n } else {\n let sub_wc = (chroma_format_idc === 3) ? 1 : 2;\n let sub_hc = (chroma_format_idc === 1) ? 2 : 1;\n crop_unit_x = sub_wc;\n crop_unit_y = sub_hc * (2 - frame_mbs_only_flag);\n }\n\n let codec_width = (pic_width_in_mbs_minus1 + 1) * 16;\n let codec_height = (2 - frame_mbs_only_flag) * ((pic_height_in_map_units_minus1 + 1) * 16);\n\n codec_width -= (frame_crop_left_offset + frame_crop_right_offset) * crop_unit_x;\n codec_height -= (frame_crop_top_offset + frame_crop_bottom_offset) * crop_unit_y;\n\n let present_width = Math.ceil(codec_width * sarScale);\n\n gb.destroy();\n gb = null;\n\n return {\n codec_mimetype,\n profile_idc,\n level_idc,\n profile_string, // baseline, high, high10, ...\n level_string, // 3, 3.1, 4, 4.1, 5, 5.1, ...\n chroma_format_idc,\n bit_depth: bit_depth_luma, // 8bit, 10bit, ...\n bit_depth_luma,\n bit_depth_chroma,\n ref_frames,\n chroma_format, // 4:2:0, 4:2:2, ...\n chroma_format_string: SPSParser.getChromaFormatString(chroma_format),\n\n frame_rate: {\n fixed: fps_fixed,\n fps: fps,\n fps_den: fps_den,\n fps_num: fps_num\n },\n\n sar_ratio: {\n width: sar_width,\n height: sar_height\n },\n\n codec_size: {\n width: codec_width,\n height: codec_height\n },\n\n present_size: {\n width: present_width,\n height: codec_height\n }\n };\n }\n\n static _skipScalingList(gb, count) {\n let last_scale = 8, next_scale = 8;\n let delta_scale = 0;\n for (let i = 0; i < count; i++) {\n if (next_scale !== 0) {\n delta_scale = gb.readSEG();\n next_scale = (last_scale + delta_scale + 256) % 256;\n }\n last_scale = (next_scale === 0) ? last_scale : next_scale;\n }\n }\n\n static getProfileString(profile_idc) {\n switch (profile_idc) {\n case 66:\n return 'Baseline';\n case 77:\n return 'Main';\n case 88:\n return 'Extended';\n case 100:\n return 'High';\n case 110:\n return 'High10';\n case 122:\n return 'High422';\n case 244:\n return 'High444';\n default:\n return 'Unknown';\n }\n }\n\n static getLevelString(level_idc) {\n return (level_idc / 10).toFixed(1);\n }\n\n static getChromaFormatString(chroma) {\n switch (chroma) {\n case 420:\n return '4:2:0';\n case 422:\n return '4:2:2';\n case 444:\n return '4:4:4';\n default:\n return 'Unknown';\n }\n }\n\n}\n\nexport default SPSParser;","/*\n * Copyright (C) 2022 もにょてっく. All Rights Reserved.\n *\n * @author もにょ〜ん \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport ExpGolomb from './exp-golomb.js';\n\nclass H265NaluParser {\n\n static _ebsp2rbsp(uint8array) {\n let src = uint8array;\n let src_length = src.byteLength;\n let dst = new Uint8Array(src_length);\n let dst_idx = 0;\n\n for (let i = 0; i < src_length; i++) {\n if (i >= 2) {\n // Unescape: Skip 0x03 after 00 00\n if (src[i] === 0x03 && src[i - 1] === 0x00 && src[i - 2] === 0x00) {\n continue;\n }\n }\n dst[dst_idx] = src[i];\n dst_idx++;\n }\n\n return new Uint8Array(dst.buffer, 0, dst_idx);\n }\n\n static parseVPS(uint8array) {\n let rbsp = H265NaluParser._ebsp2rbsp(uint8array);\n let gb = new ExpGolomb(rbsp);\n\n /* remove NALu Header */\n gb.readByte();\n gb.readByte();\n\n // VPS\n let video_parameter_set_id = gb.readBits(4);\n gb.readBits(2);\n let max_layers_minus1 = gb.readBits(6);\n let max_sub_layers_minus1 = gb.readBits(3);\n let temporal_id_nesting_flag = gb.readBool();\n // and more ...\n\n return {\n num_temporal_layers: max_sub_layers_minus1 + 1,\n temporal_id_nested: temporal_id_nesting_flag\n }\n }\n\n static parseSPS(uint8array) {\n let rbsp = H265NaluParser._ebsp2rbsp(uint8array);\n let gb = new ExpGolomb(rbsp);\n\n /* remove NALu Header */\n gb.readByte();\n gb.readByte();\n\n let left_offset = 0, right_offset = 0, top_offset = 0, bottom_offset = 0;\n\n // SPS\n let video_paramter_set_id = gb.readBits(4);\n let max_sub_layers_minus1 = gb.readBits(3);\n let temporal_id_nesting_flag = gb.readBool();\n\n // profile_tier_level begin\n let general_profile_space = gb.readBits(2);\n let general_tier_flag = gb.readBool();\n let general_profile_idc = gb.readBits(5);\n let general_profile_compatibility_flags_1 = gb.readByte();\n let general_profile_compatibility_flags_2 = gb.readByte();\n let general_profile_compatibility_flags_3 = gb.readByte();\n let general_profile_compatibility_flags_4 = gb.readByte();\n let general_constraint_indicator_flags_1 = gb.readByte();\n let general_constraint_indicator_flags_2 = gb.readByte();\n let general_constraint_indicator_flags_3 = gb.readByte();\n let general_constraint_indicator_flags_4 = gb.readByte();\n let general_constraint_indicator_flags_5 = gb.readByte();\n let general_constraint_indicator_flags_6 = gb.readByte();\n let general_level_idc = gb.readByte();\n let sub_layer_profile_present_flag = [];\n let sub_layer_level_present_flag = [];\n for (let i = 0; i < max_sub_layers_minus1; i++) {\n sub_layer_profile_present_flag.push(gb.readBool());\n sub_layer_level_present_flag.push(gb.readBool());\n }\n if (max_sub_layers_minus1 > 0) {\n for (let i = max_sub_layers_minus1; i < 8; i++) { gb.readBits(2); }\n }\n for (let i = 0; i < max_sub_layers_minus1; i++) {\n if (sub_layer_profile_present_flag[i]) {\n gb.readByte(); // sub_layer_profile_space, sub_layer_tier_flag, sub_layer_profile_idc\n gb.readByte(); gb.readByte(); gb.readByte(); gb.readByte(); // sub_layer_profile_compatibility_flag\n gb.readByte(); gb.readByte(); gb.readByte(); gb.readByte(); gb.readByte(); gb.readByte();\n }\n if (sub_layer_level_present_flag[i]) {\n gb.readByte();\n }\n }\n // profile_tier_level end\n\n let seq_parameter_set_id = gb.readUEG();\n let chroma_format_idc = gb.readUEG();\n if (chroma_format_idc == 3) {\n gb.readBits(1); // separate_colour_plane_flag\n }\n let pic_width_in_luma_samples = gb.readUEG();\n let pic_height_in_luma_samples = gb.readUEG();\n let conformance_window_flag = gb.readBool();\n if (conformance_window_flag) {\n left_offset += gb.readUEG();\n right_offset += gb.readUEG();\n top_offset += gb.readUEG();\n bottom_offset += gb.readUEG();\n }\n let bit_depth_luma_minus8 = gb.readUEG();\n let bit_depth_chroma_minus8 = gb.readUEG();\n let log2_max_pic_order_cnt_lsb_minus4 = gb.readUEG();\n let sub_layer_ordering_info_present_flag = gb.readBool();\n for (let i = sub_layer_ordering_info_present_flag ? 0 : max_sub_layers_minus1; i <= max_sub_layers_minus1; i++) {\n gb.readUEG(); // max_dec_pic_buffering_minus1[i]\n gb.readUEG(); // max_num_reorder_pics[i]\n gb.readUEG(); // max_latency_increase_plus1[i]\n }\n let log2_min_luma_coding_block_size_minus3 = gb.readUEG();\n let log2_diff_max_min_luma_coding_block_size = gb.readUEG();\n let log2_min_transform_block_size_minus2 = gb.readUEG();\n let log2_diff_max_min_transform_block_size = gb.readUEG();\n let max_transform_hierarchy_depth_inter = gb.readUEG();\n let max_transform_hierarchy_depth_intra = gb.readUEG();\n let scaling_list_enabled_flag = gb.readBool();\n if (scaling_list_enabled_flag) {\n let sps_scaling_list_data_present_flag = gb.readBool();\n if (sps_scaling_list_data_present_flag) {\n for (let sizeId = 0; sizeId < 4; sizeId++) {\n for(let matrixId = 0; matrixId < ((sizeId === 3) ? 2 : 6); matrixId++){\n let scaling_list_pred_mode_flag = gb.readBool();\n if (!scaling_list_pred_mode_flag) {\n gb.readUEG(); // scaling_list_pred_matrix_id_delta\n } else {\n let coefNum = Math.min(64, (1 << (4 + (sizeId << 1))));\n if (sizeId > 1) { gb.readSEG() }\n for (let i = 0; i < coefNum; i++) { gb.readSEG(); }\n }\n }\n }\n }\n }\n let amp_enabled_flag = gb.readBool();\n let sample_adaptive_offset_enabled_flag = gb.readBool();\n let pcm_enabled_flag = gb.readBool();\n if (pcm_enabled_flag) {\n gb.readByte();\n gb.readUEG();\n gb.readUEG();\n gb.readBool();\n }\n let num_short_term_ref_pic_sets = gb.readUEG();\n let num_delta_pocs = 0;\n for (let i = 0; i < num_short_term_ref_pic_sets; i++) {\n let inter_ref_pic_set_prediction_flag = false;\n if (i !== 0) { inter_ref_pic_set_prediction_flag = gb.readBool(); }\n if (inter_ref_pic_set_prediction_flag) {\n if (i === num_short_term_ref_pic_sets) { gb.readUEG(); }\n gb.readBool();\n gb.readUEG();\n let next_num_delta_pocs = 0;\n for (let j = 0; j <= num_delta_pocs; j++) {\n let used_by_curr_pic_flag = gb.readBool();\n let use_delta_flag = false;\n if (!used_by_curr_pic_flag) {\n use_delta_flag = gb.readBool();\n }\n if (used_by_curr_pic_flag || use_delta_flag) {\n next_num_delta_pocs++;\n }\n }\n num_delta_pocs = next_num_delta_pocs;\n } else {\n let num_negative_pics = gb.readUEG();\n let num_positive_pics = gb.readUEG();\n num_delta_pocs = num_negative_pics + num_positive_pics;\n for (let j = 0; j < num_negative_pics; j++) {\n gb.readUEG();\n gb.readBool();\n }\n for (let j = 0; j < num_positive_pics; j++) {\n gb.readUEG();\n gb.readBool();\n }\n }\n }\n let long_term_ref_pics_present_flag = gb.readBool();\n if (long_term_ref_pics_present_flag) {\n let num_long_term_ref_pics_sps = gb.readUEG();\n for (let i = 0; i < num_long_term_ref_pics_sps; i++) {\n for (let j = 0; j < (log2_max_pic_order_cnt_lsb_minus4 + 4); j++) { gb.readBits(1); }\n gb.readBits(1);\n }\n }\n //*\n let default_display_window_flag = false; // for calc offset\n let min_spatial_segmentation_idc = 0; // for hvcC\n let sar_width = 1, sar_height = 1;\n let fps_fixed = false, fps_den = 1, fps_num = 1;\n //*/\n let sps_temporal_mvp_enabled_flag = gb.readBool();\n let strong_intra_smoothing_enabled_flag = gb.readBool();\n let vui_parameters_present_flag = gb.readBool();\n if (vui_parameters_present_flag) {\n let aspect_ratio_info_present_flag = gb.readBool();\n if (aspect_ratio_info_present_flag) {\n let aspect_ratio_idc = gb.readByte();\n\n let sar_w_table = [1, 12, 10, 16, 40, 24, 20, 32, 80, 18, 15, 64, 160, 4, 3, 2];\n let sar_h_table = [1, 11, 11, 11, 33, 11, 11, 11, 33, 11, 11, 33, 99, 3, 2, 1];\n\n if (aspect_ratio_idc > 0 && aspect_ratio_idc <= 16) {\n sar_width = sar_w_table[aspect_ratio_idc - 1];\n sar_height = sar_h_table[aspect_ratio_idc - 1];\n } else if (aspect_ratio_idc === 255) {\n sar_width = gb.readBits(16);\n sar_height = gb.readBits(16);\n }\n }\n let overscan_info_present_flag = gb.readBool();\n if (overscan_info_present_flag) {\n gb.readBool();\n }\n let video_signal_type_present_flag = gb.readBool();\n if (video_signal_type_present_flag) {\n gb.readBits(3);\n gb.readBool();\n let colour_description_present_flag = gb.readBool();\n if (colour_description_present_flag) {\n gb.readByte();\n gb.readByte();\n gb.readByte();\n }\n }\n let chroma_loc_info_present_flag = gb.readBool();\n if (chroma_loc_info_present_flag) {\n gb.readUEG();\n gb.readUEG();\n }\n let neutral_chroma_indication_flag = gb.readBool();\n let field_seq_flag = gb.readBool();\n let frame_field_info_present_flag = gb.readBool();\n default_display_window_flag = gb.readBool();\n if (default_display_window_flag) {\n gb.readUEG();\n gb.readUEG();\n gb.readUEG();\n gb.readUEG();\n }\n let vui_timing_info_present_flag = gb.readBool();\n if (vui_timing_info_present_flag) {\n fps_den = gb.readBits(32);\n fps_num = gb.readBits(32);\n let vui_poc_proportional_to_timing_flag = gb.readBool();\n if (vui_poc_proportional_to_timing_flag) {\n gb.readUEG();\n let vui_hrd_parameters_present_flag = gb.readBool();\n if (vui_hrd_parameters_present_flag) {\n let commonInfPresentFlag = 1;\n let nal_hrd_parameters_present_flag = false;\n let vcl_hrd_parameters_present_flag = false;\n let sub_pic_hrd_params_present_flag = false;\n if (commonInfPresentFlag) {\n nal_hrd_parameters_present_flag = gb.readBool();\n vcl_hrd_parameters_present_flag = gb.readBool();\n if( nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag ){\n sub_pic_hrd_params_present_flag = gb.readBool();\n if (sub_pic_hrd_params_present_flag) {\n gb.readByte();\n gb.readBits(5);\n gb.readBool();\n gb.readBits(5);\n }\n let bit_rate_scale = gb.readBits(4);\n let cpb_size_scale = gb.readBits(4);\n if (sub_pic_hrd_params_present_flag) {\n gb.readBits(4);\n }\n gb.readBits(5);\n gb.readBits(5);\n gb.readBits(5);\n }\n }\n for (let i = 0; i <= max_sub_layers_minus1; i++) {\n let fixed_pic_rate_general_flag = gb.readBool();\n fps_fixed = fixed_pic_rate_general_flag;\n let fixed_pic_rate_within_cvs_flag = false;\n let cpbCnt = 1;\n if (!fixed_pic_rate_general_flag) {\n fixed_pic_rate_within_cvs_flag = gb.readBool();\n }\n let low_delay_hrd_flag = false;\n if (fixed_pic_rate_within_cvs_flag) {\n gb.readSEG();\n } else {\n low_delay_hrd_flag = gb.readBool();\n }\n if (!low_delay_hrd_flag) {\n cpbCnt = gb.readUEG() + 1;\n }\n if (nal_hrd_parameters_present_flag) {\n for (let j = 0; j < cpbCnt; j++) {\n gb.readUEG(); gb.readUEG();\n if (sub_pic_hrd_params_present_flag) {\n gb.readUEG(); gb.readUEG();\n }\n }\n }\n if (vcl_hrd_parameters_present_flag) {\n for (let j = 0; j < cpbCnt; j++) {\n gb.readUEG(); gb.readUEG();\n if (sub_pic_hrd_params_present_flag) {\n gb.readUEG(); gb.readUEG();\n }\n }\n }\n }\n }\n }\n }\n let bitstream_restriction_flag = gb.readBool();\n if (bitstream_restriction_flag) {\n let tiles_fixed_structure_flag = gb.readBool()\n let motion_vectors_over_pic_boundaries_flag = gb.readBool()\n let restricted_ref_pic_lists_flag = gb.readBool();\n min_spatial_segmentation_idc = gb.readUEG();\n let max_bytes_per_pic_denom = gb.readUEG();\n let max_bits_per_min_cu_denom = gb.readUEG();\n let log2_max_mv_length_horizontal = gb.readUEG();\n let log2_max_mv_length_vertical = gb.readUEG();\n }\n }\n let sps_extension_flag = gb.readBool(); // ignore...\n\n // for meta data\n let codec_mimetype = `hvc1.${general_profile_idc}.1.L${general_level_idc}.B0`;\n\n let sub_wc = (chroma_format_idc === 1 || chroma_format_idc === 2) ? 2 : 1;\n let sub_hc = (chroma_format_idc === 1) ? 2 : 1;\n let codec_width = pic_width_in_luma_samples - (left_offset + right_offset) * sub_wc;\n let codec_height = pic_height_in_luma_samples - (top_offset + bottom_offset) * sub_hc;\n let sar_scale = 1;\n if (sar_width !== 1 && sar_height !== 1) {\n sar_scale = sar_width / sar_height;\n }\n\n gb.destroy();\n gb = null;\n\n return {\n codec_mimetype,\n level_string: H265NaluParser.getLevelString(general_level_idc),\n profile_idc: general_profile_idc,\n bit_depth: bit_depth_luma_minus8 + 8,\n ref_frames: 1, // FIXME!!!\n chroma_format: chroma_format_idc,\n chroma_format_string: H265NaluParser.getChromaFormatString(chroma_format_idc),\n\n general_level_idc,\n general_profile_space,\n general_tier_flag,\n general_profile_idc,\n general_profile_compatibility_flags_1,\n general_profile_compatibility_flags_2,\n general_profile_compatibility_flags_3,\n general_profile_compatibility_flags_4,\n general_constraint_indicator_flags_1,\n general_constraint_indicator_flags_2,\n general_constraint_indicator_flags_3,\n general_constraint_indicator_flags_4,\n general_constraint_indicator_flags_5,\n general_constraint_indicator_flags_6,\n min_spatial_segmentation_idc,\n constant_frame_rate: 0 /* FIXME!! fps_fixed ? 1 : 0? */,\n chroma_format_idc,\n bit_depth_luma_minus8,\n bit_depth_chroma_minus8,\n\n frame_rate: {\n fixed: fps_fixed,\n fps: fps_num / fps_den,\n fps_den: fps_den,\n fps_num: fps_num,\n },\n\n sar_ratio: {\n width: sar_width,\n height: sar_height\n },\n\n codec_size: {\n width: codec_width,\n height: codec_height\n },\n\n present_size: {\n width: codec_width * sar_scale,\n height: codec_height\n }\n };\n }\n\n static parsePPS(uint8array) {\n let rbsp = H265NaluParser._ebsp2rbsp(uint8array);\n let gb = new ExpGolomb(rbsp);\n\n /* remove NALu Header */\n gb.readByte();\n gb.readByte();\n\n let pic_parameter_set_id = gb.readUEG();\n let seq_parameter_set_id = gb.readUEG();\n let dependent_slice_segments_enabled_flag = gb.readBool();\n let output_flag_present_flag = gb.readBool();\n let num_extra_slice_header_bits = gb.readBits(3);\n let sign_data_hiding_enabled_flag = gb.readBool();\n let cabac_init_present_flag = gb.readBool();\n let num_ref_idx_l0_default_active_minus1 = gb.readUEG();\n let num_ref_idx_l1_default_active_minus1 = gb.readUEG();\n let init_qp_minus26 = gb.readSEG();\n let constrained_intra_pred_flag = gb.readBool();\n let transform_skip_enabled_flag = gb.readBool();\n let cu_qp_delta_enabled_flag = gb.readBool();\n if (cu_qp_delta_enabled_flag) {\n let diff_cu_qp_delta_depth = gb.readUEG();\n }\n let cb_qp_offset = gb.readSEG();\n let cr_qp_offset = gb.readSEG();\n let pps_slice_chroma_qp_offsets_present_flag = gb.readBool();\n let weighted_pred_flag = gb.readBool();\n let weighted_bipred_flag = gb.readBool();\n let transquant_bypass_enabled_flag = gb.readBool();\n let tiles_enabled_flag = gb.readBool();\n let entropy_coding_sync_enabled_flag = gb.readBool();\n // and more ...\n\n // needs hvcC\n let parallelismType = 1; // slice-based parallel decoding\n if (entropy_coding_sync_enabled_flag && tiles_enabled_flag) {\n parallelismType = 0; // mixed-type parallel decoding\n } else if (entropy_coding_sync_enabled_flag) {\n parallelismType = 3; // wavefront-based parallel decoding\n } else if (tiles_enabled_flag) {\n parallelismType = 2; // tile-based parallel decoding\n }\n\n return {\n parallelismType\n }\n }\n\n static getChromaFormatString(chroma_idc) {\n switch (chroma_idc) {\n case 0: return '4:0:0';\n case 1: return '4:2:0';\n case 2: return '4:2:2';\n case 3: return '4:4:4';\n default: return 'Unknown';\n }\n }\n\n static getProfileString(profile_idc) {\n switch (profile_idc) {\n case 1: return 'Main';\n case 2: return 'Main10';\n case 3: return 'MainSP';\n case 4: return 'Rext';\n case 9: return 'SCC';\n default: return 'Unknown';\n }\n }\n\n static getLevelString(level_idc) {\n return (level_idc / 30).toFixed(1);\n }\n}\n\nexport default H265NaluParser;\n","/*\n * Copyright (C) 2022 magicxqq. All Rights Reserved.\n *\n * @author magicxqq \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nfunction isAligned16(a: Uint8Array) : boolean {\n return a.byteOffset % 2 === 0 && a.byteLength % 2 === 0;\n}\n\nfunction isAligned32(a: Uint8Array) : boolean {\n return a.byteOffset % 4 === 0 && a.byteLength % 4 === 0;\n}\n\nfunction compareArray(a: Uint8Array | Uint16Array | Uint32Array,\n b: Uint8Array | Uint16Array | Uint32Array): boolean {\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\nfunction equal8(a: Uint8Array, b: Uint8Array) : boolean {\n return compareArray(a, b);\n}\n\nfunction equal16(a: Uint8Array, b: Uint8Array) : boolean {\n let a16 = new Uint16Array(a.buffer, a.byteOffset, a.byteLength / 2);\n let b16 = new Uint16Array(b.buffer, b.byteOffset, b.byteLength / 2);\n return compareArray(a16, b16);\n}\n\nfunction equal32(a: Uint8Array, b: Uint8Array) : boolean {\n let a32 = new Uint32Array(a.buffer, a.byteOffset, a.byteLength / 4);\n let b32 = new Uint32Array(b.buffer, b.byteOffset, b.byteLength / 4);\n return compareArray(a32, b32);\n}\n\nfunction buffersAreEqual(a: Uint8Array, b: Uint8Array) : boolean {\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n\n if (isAligned32(a) && isAligned32(b)) {\n return equal32(a, b);\n }\n\n if (isAligned16(a) && isAligned16(b)) {\n return equal16(a, b);\n }\n\n return equal8(a, b);\n}\n\nexport default buffersAreEqual;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport AMF from './amf-parser.js';\nimport SPSParser from './sps-parser.js';\nimport DemuxErrors from './demux-errors.js';\nimport MediaInfo from '../core/media-info.js';\nimport {IllegalStateException} from '../utils/exception.js';\nimport H265Parser from './h265-parser.js';\nimport buffersAreEqual from '../utils/typedarray-equality.ts';\n\nfunction Swap16(src) {\n return (((src >>> 8) & 0xFF) |\n ((src & 0xFF) << 8));\n}\n\nfunction Swap32(src) {\n return (((src & 0xFF000000) >>> 24) |\n ((src & 0x00FF0000) >>> 8) |\n ((src & 0x0000FF00) << 8) |\n ((src & 0x000000FF) << 24));\n}\n\nfunction ReadBig32(array, index) {\n return ((array[index] << 24) |\n (array[index + 1] << 16) |\n (array[index + 2] << 8) |\n (array[index + 3]));\n}\n\n\nclass FLVDemuxer {\n\n constructor(probeData, config) {\n this.TAG = 'FLVDemuxer';\n\n this._config = config;\n\n this._onError = null;\n this._onMediaInfo = null;\n this._onMetaDataArrived = null;\n this._onScriptDataArrived = null;\n this._onTrackMetadata = null;\n this._onDataAvailable = null;\n\n this._dataOffset = probeData.dataOffset;\n this._firstParse = true;\n this._dispatch = false;\n\n this._hasAudio = probeData.hasAudioTrack;\n this._hasVideo = probeData.hasVideoTrack;\n\n this._hasAudioFlagOverrided = false;\n this._hasVideoFlagOverrided = false;\n\n this._audioInitialMetadataDispatched = false;\n this._videoInitialMetadataDispatched = false;\n\n this._mediaInfo = new MediaInfo();\n this._mediaInfo.hasAudio = this._hasAudio;\n this._mediaInfo.hasVideo = this._hasVideo;\n this._metadata = null;\n this._audioMetadata = null;\n this._videoMetadata = null;\n\n this._naluLengthSize = 4;\n this._timestampBase = 0; // int32, in milliseconds\n this._timescale = 1000;\n this._duration = 0; // int32, in milliseconds\n this._durationOverrided = false;\n this._referenceFrameRate = {\n fixed: true,\n fps: 23.976,\n fps_num: 23976,\n fps_den: 1000\n };\n\n this._flvSoundRateTable = [5500, 11025, 22050, 44100, 48000];\n\n this._mpegSamplingRates = [\n 96000, 88200, 64000, 48000, 44100, 32000,\n 24000, 22050, 16000, 12000, 11025, 8000, 7350\n ];\n\n this._mpegAudioV10SampleRateTable = [44100, 48000, 32000, 0];\n this._mpegAudioV20SampleRateTable = [22050, 24000, 16000, 0];\n this._mpegAudioV25SampleRateTable = [11025, 12000, 8000, 0];\n\n this._mpegAudioL1BitRateTable = [0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, -1];\n this._mpegAudioL2BitRateTable = [0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, -1];\n this._mpegAudioL3BitRateTable = [0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1];\n\n this._videoTrack = {type: 'video', id: 1, sequenceNumber: 0, samples: [], length: 0};\n this._audioTrack = {type: 'audio', id: 2, sequenceNumber: 0, samples: [], length: 0};\n\n this._littleEndian = (function () {\n let buf = new ArrayBuffer(2);\n (new DataView(buf)).setInt16(0, 256, true); // little-endian write\n return (new Int16Array(buf))[0] === 256; // platform-spec read, if equal then LE\n })();\n }\n\n destroy() {\n this._mediaInfo = null;\n this._metadata = null;\n this._audioMetadata = null;\n this._videoMetadata = null;\n this._videoTrack = null;\n this._audioTrack = null;\n\n this._onError = null;\n this._onMediaInfo = null;\n this._onMetaDataArrived = null;\n this._onScriptDataArrived = null;\n this._onTrackMetadata = null;\n this._onDataAvailable = null;\n }\n\n static probe(buffer) {\n let data = new Uint8Array(buffer);\n if (data.byteLength < 9) {\n return {needMoreData: true};\n }\n\n let mismatch = {match: false};\n\n if (data[0] !== 0x46 || data[1] !== 0x4C || data[2] !== 0x56 || data[3] !== 0x01) {\n return mismatch;\n }\n\n let hasAudio = ((data[4] & 4) >>> 2) !== 0;\n let hasVideo = (data[4] & 1) !== 0;\n\n let offset = ReadBig32(data, 5);\n\n if (offset < 9) {\n return mismatch;\n }\n\n return {\n match: true,\n consumed: offset,\n dataOffset: offset,\n hasAudioTrack: hasAudio,\n hasVideoTrack: hasVideo\n };\n }\n\n bindDataSource(loader) {\n loader.onDataArrival = this.parseChunks.bind(this);\n return this;\n }\n\n // prototype: function(type: string, metadata: any): void\n get onTrackMetadata() {\n return this._onTrackMetadata;\n }\n\n set onTrackMetadata(callback) {\n this._onTrackMetadata = callback;\n }\n\n // prototype: function(mediaInfo: MediaInfo): void\n get onMediaInfo() {\n return this._onMediaInfo;\n }\n\n set onMediaInfo(callback) {\n this._onMediaInfo = callback;\n }\n\n get onMetaDataArrived() {\n return this._onMetaDataArrived;\n }\n\n set onMetaDataArrived(callback) {\n this._onMetaDataArrived = callback;\n }\n\n get onScriptDataArrived() {\n return this._onScriptDataArrived;\n }\n\n set onScriptDataArrived(callback) {\n this._onScriptDataArrived = callback;\n }\n\n // prototype: function(type: number, info: string): void\n get onError() {\n return this._onError;\n }\n\n set onError(callback) {\n this._onError = callback;\n }\n\n // prototype: function(videoTrack: any, audioTrack: any): void\n get onDataAvailable() {\n return this._onDataAvailable;\n }\n\n set onDataAvailable(callback) {\n this._onDataAvailable = callback;\n }\n\n // timestamp base for output samples, must be in milliseconds\n get timestampBase() {\n return this._timestampBase;\n }\n\n set timestampBase(base) {\n this._timestampBase = base;\n }\n\n get overridedDuration() {\n return this._duration;\n }\n\n // Force-override media duration. Must be in milliseconds, int32\n set overridedDuration(duration) {\n this._durationOverrided = true;\n this._duration = duration;\n this._mediaInfo.duration = duration;\n }\n\n // Force-override audio track present flag, boolean\n set overridedHasAudio(hasAudio) {\n this._hasAudioFlagOverrided = true;\n this._hasAudio = hasAudio;\n this._mediaInfo.hasAudio = hasAudio;\n }\n\n // Force-override video track present flag, boolean\n set overridedHasVideo(hasVideo) {\n this._hasVideoFlagOverrided = true;\n this._hasVideo = hasVideo;\n this._mediaInfo.hasVideo = hasVideo;\n }\n\n resetMediaInfo() {\n this._mediaInfo = new MediaInfo();\n }\n\n _isInitialMetadataDispatched() {\n if (this._hasAudio && this._hasVideo) { // both audio & video\n return this._audioInitialMetadataDispatched && this._videoInitialMetadataDispatched;\n }\n if (this._hasAudio && !this._hasVideo) { // audio only\n return this._audioInitialMetadataDispatched;\n }\n if (!this._hasAudio && this._hasVideo) { // video only\n return this._videoInitialMetadataDispatched;\n }\n return false;\n }\n\n // function parseChunks(chunk: ArrayBuffer, byteStart: number): number;\n parseChunks(chunk, byteStart) {\n if (!this._onError || !this._onMediaInfo || !this._onTrackMetadata || !this._onDataAvailable) {\n throw new IllegalStateException('Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified');\n }\n\n let offset = 0;\n let le = this._littleEndian;\n\n if (byteStart === 0) { // buffer with FLV header\n if (chunk.byteLength > 13) {\n let probeData = FLVDemuxer.probe(chunk);\n offset = probeData.dataOffset;\n } else {\n return 0;\n }\n }\n\n if (this._firstParse) { // handle PreviousTagSize0 before Tag1\n this._firstParse = false;\n if (byteStart + offset !== this._dataOffset) {\n Log.w(this.TAG, 'First time parsing but chunk byteStart invalid!');\n }\n\n let v = new DataView(chunk, offset);\n let prevTagSize0 = v.getUint32(0, !le);\n if (prevTagSize0 !== 0) {\n Log.w(this.TAG, 'PrevTagSize0 !== 0 !!!');\n }\n offset += 4;\n }\n\n while (offset < chunk.byteLength) {\n this._dispatch = true;\n\n let v = new DataView(chunk, offset);\n\n if (offset + 11 + 4 > chunk.byteLength) {\n // data not enough for parsing an flv tag\n break;\n }\n\n let tagType = v.getUint8(0);\n let dataSize = v.getUint32(0, !le) & 0x00FFFFFF;\n\n if (offset + 11 + dataSize + 4 > chunk.byteLength) {\n // data not enough for parsing actual data body\n break;\n }\n\n if (tagType !== 8 && tagType !== 9 && tagType !== 18) {\n Log.w(this.TAG, `Unsupported tag type ${tagType}, skipped`);\n // consume the whole tag (skip it)\n offset += 11 + dataSize + 4;\n continue;\n }\n\n let ts2 = v.getUint8(4);\n let ts1 = v.getUint8(5);\n let ts0 = v.getUint8(6);\n let ts3 = v.getUint8(7);\n\n let timestamp = ts0 | (ts1 << 8) | (ts2 << 16) | (ts3 << 24);\n\n let streamId = v.getUint32(7, !le) & 0x00FFFFFF;\n if (streamId !== 0) {\n Log.w(this.TAG, 'Meet tag which has StreamID != 0!');\n }\n\n let dataOffset = offset + 11;\n\n switch (tagType) {\n case 8: // Audio\n this._parseAudioData(chunk, dataOffset, dataSize, timestamp);\n break;\n case 9: // Video\n this._parseVideoData(chunk, dataOffset, dataSize, timestamp, byteStart + offset);\n break;\n case 18: // ScriptDataObject\n this._parseScriptData(chunk, dataOffset, dataSize);\n break;\n }\n\n let prevTagSize = v.getUint32(11 + dataSize, !le);\n if (prevTagSize !== 11 + dataSize) {\n Log.w(this.TAG, `Invalid PrevTagSize ${prevTagSize}`);\n }\n\n offset += 11 + dataSize + 4; // tagBody + dataSize + prevTagSize\n }\n\n // dispatch parsed frames to consumer (typically, the remuxer)\n if (this._isInitialMetadataDispatched()) {\n if (this._dispatch && (this._audioTrack.length || this._videoTrack.length)) {\n this._onDataAvailable(this._audioTrack, this._videoTrack);\n }\n }\n\n return offset; // consumed bytes, just equals latest offset index\n }\n\n _parseScriptData(arrayBuffer, dataOffset, dataSize) {\n let scriptData = AMF.parseScriptData(arrayBuffer, dataOffset, dataSize);\n\n if (scriptData.hasOwnProperty('onMetaData')) {\n if (scriptData.onMetaData == null || typeof scriptData.onMetaData !== 'object') {\n Log.w(this.TAG, 'Invalid onMetaData structure!');\n return;\n }\n if (this._metadata) {\n Log.w(this.TAG, 'Found another onMetaData tag!');\n }\n this._metadata = scriptData;\n let onMetaData = this._metadata.onMetaData;\n\n if (this._onMetaDataArrived) {\n this._onMetaDataArrived(Object.assign({}, onMetaData));\n }\n\n if (typeof onMetaData.hasAudio === 'boolean') { // hasAudio\n if (this._hasAudioFlagOverrided === false) {\n this._hasAudio = onMetaData.hasAudio;\n this._mediaInfo.hasAudio = this._hasAudio;\n }\n }\n if (typeof onMetaData.hasVideo === 'boolean') { // hasVideo\n if (this._hasVideoFlagOverrided === false) {\n this._hasVideo = onMetaData.hasVideo;\n this._mediaInfo.hasVideo = this._hasVideo;\n }\n }\n if (typeof onMetaData.audiodatarate === 'number') { // audiodatarate\n this._mediaInfo.audioDataRate = onMetaData.audiodatarate;\n }\n if (typeof onMetaData.videodatarate === 'number') { // videodatarate\n this._mediaInfo.videoDataRate = onMetaData.videodatarate;\n }\n if (typeof onMetaData.width === 'number') { // width\n this._mediaInfo.width = onMetaData.width;\n }\n if (typeof onMetaData.height === 'number') { // height\n this._mediaInfo.height = onMetaData.height;\n }\n if (typeof onMetaData.duration === 'number') { // duration\n if (!this._durationOverrided) {\n let duration = Math.floor(onMetaData.duration * this._timescale);\n this._duration = duration;\n this._mediaInfo.duration = duration;\n }\n } else {\n this._mediaInfo.duration = 0;\n }\n if (typeof onMetaData.framerate === 'number') { // framerate\n let fps_num = Math.floor(onMetaData.framerate * 1000);\n if (fps_num > 0) {\n let fps = fps_num / 1000;\n this._referenceFrameRate.fixed = true;\n this._referenceFrameRate.fps = fps;\n this._referenceFrameRate.fps_num = fps_num;\n this._referenceFrameRate.fps_den = 1000;\n this._mediaInfo.fps = fps;\n }\n }\n if (typeof onMetaData.keyframes === 'object') { // keyframes\n this._mediaInfo.hasKeyframesIndex = true;\n let keyframes = onMetaData.keyframes;\n this._mediaInfo.keyframesIndex = this._parseKeyframesIndex(keyframes);\n onMetaData.keyframes = null; // keyframes has been extracted, remove it\n } else {\n this._mediaInfo.hasKeyframesIndex = false;\n }\n this._dispatch = false;\n this._mediaInfo.metadata = onMetaData;\n Log.v(this.TAG, 'Parsed onMetaData');\n if (this._mediaInfo.isComplete()) {\n this._onMediaInfo(this._mediaInfo);\n }\n }\n\n if (Object.keys(scriptData).length > 0) {\n if (this._onScriptDataArrived) {\n this._onScriptDataArrived(Object.assign({}, scriptData));\n }\n }\n }\n\n _parseKeyframesIndex(keyframes) {\n let times = [];\n let filepositions = [];\n\n // ignore first keyframe which is actually AVC/HEVC Sequence Header (AVCDecoderConfigurationRecord or HEVCDecoderConfigurationRecord)\n for (let i = 1; i < keyframes.times.length; i++) {\n let time = this._timestampBase + Math.floor(keyframes.times[i] * 1000);\n times.push(time);\n filepositions.push(keyframes.filepositions[i]);\n }\n\n return {\n times: times,\n filepositions: filepositions\n };\n }\n\n _parseAudioData(arrayBuffer, dataOffset, dataSize, tagTimestamp) {\n if (dataSize <= 1) {\n Log.w(this.TAG, 'Flv: Invalid audio packet, missing SoundData payload!');\n return;\n }\n\n if (this._hasAudioFlagOverrided === true && this._hasAudio === false) {\n // If hasAudio: false indicated explicitly in MediaDataSource,\n // Ignore all the audio packets\n return;\n }\n\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let soundSpec = v.getUint8(0);\n\n let soundFormat = soundSpec >>> 4;\n if (soundFormat !== 2 && soundFormat !== 10) { // MP3 or AAC\n this._onError(DemuxErrors.CODEC_UNSUPPORTED, 'Flv: Unsupported audio codec idx: ' + soundFormat);\n return;\n }\n\n let soundRate = 0;\n let soundRateIndex = (soundSpec & 12) >>> 2;\n if (soundRateIndex >= 0 && soundRateIndex <= 4) {\n soundRate = this._flvSoundRateTable[soundRateIndex];\n } else {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: Invalid audio sample rate idx: ' + soundRateIndex);\n return;\n }\n\n let soundSize = (soundSpec & 2) >>> 1; // unused\n let soundType = (soundSpec & 1);\n\n\n let meta = this._audioMetadata;\n let track = this._audioTrack;\n\n if (!meta) {\n if (this._hasAudio === false && this._hasAudioFlagOverrided === false) {\n this._hasAudio = true;\n this._mediaInfo.hasAudio = true;\n }\n\n // initial metadata\n meta = this._audioMetadata = {};\n meta.type = 'audio';\n meta.id = track.id;\n meta.timescale = this._timescale;\n meta.duration = this._duration;\n meta.audioSampleRate = soundRate;\n meta.channelCount = (soundType === 0 ? 1 : 2);\n }\n\n if (soundFormat === 10) { // AAC\n let aacData = this._parseAACAudioData(arrayBuffer, dataOffset + 1, dataSize - 1);\n if (aacData == undefined) {\n return;\n }\n\n if (aacData.packetType === 0) { // AAC sequence header (AudioSpecificConfig)\n if (meta.config) {\n if (buffersAreEqual(aacData.data.config, meta.config)) {\n // If AudioSpecificConfig is not changed, ignore it to avoid generating initialization segment repeatedly\n return;\n } else {\n Log.w(this.TAG, 'AudioSpecificConfig has been changed, re-generate initialization segment');\n }\n }\n let misc = aacData.data;\n meta.audioSampleRate = misc.samplingRate;\n meta.channelCount = misc.channelCount;\n meta.codec = misc.codec;\n meta.originalCodec = misc.originalCodec;\n meta.config = misc.config;\n // The decode result of an aac sample is 1024 PCM samples\n meta.refSampleDuration = 1024 / meta.audioSampleRate * meta.timescale;\n Log.v(this.TAG, 'Parsed AudioSpecificConfig');\n\n if (this._isInitialMetadataDispatched()) {\n // Non-initial metadata, force dispatch (or flush) parsed frames to remuxer\n if (this._dispatch && (this._audioTrack.length || this._videoTrack.length)) {\n this._onDataAvailable(this._audioTrack, this._videoTrack);\n }\n } else {\n this._audioInitialMetadataDispatched = true;\n }\n // then notify new metadata\n this._dispatch = false;\n this._onTrackMetadata('audio', meta);\n\n let mi = this._mediaInfo;\n mi.audioCodec = meta.originalCodec;\n mi.audioSampleRate = meta.audioSampleRate;\n mi.audioChannelCount = meta.channelCount;\n if (mi.hasVideo) {\n if (mi.videoCodec != null) {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + ',' + mi.audioCodec + '\"';\n }\n } else {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.audioCodec + '\"';\n }\n if (mi.isComplete()) {\n this._onMediaInfo(mi);\n }\n } else if (aacData.packetType === 1) { // AAC raw frame data\n let dts = this._timestampBase + tagTimestamp;\n let aacSample = {unit: aacData.data, length: aacData.data.byteLength, dts: dts, pts: dts};\n track.samples.push(aacSample);\n track.length += aacData.data.length;\n } else {\n Log.e(this.TAG, `Flv: Unsupported AAC data type ${aacData.packetType}`);\n }\n } else if (soundFormat === 2) { // MP3\n if (!meta.codec) {\n // We need metadata for mp3 audio track, extract info from frame header\n let misc = this._parseMP3AudioData(arrayBuffer, dataOffset + 1, dataSize - 1, true);\n if (misc == undefined) {\n return;\n }\n meta.audioSampleRate = misc.samplingRate;\n meta.channelCount = misc.channelCount;\n meta.codec = misc.codec;\n meta.originalCodec = misc.originalCodec;\n // The decode result of an mp3 sample is 1152 PCM samples\n meta.refSampleDuration = 1152 / meta.audioSampleRate * meta.timescale;\n Log.v(this.TAG, 'Parsed MPEG Audio Frame Header');\n\n this._audioInitialMetadataDispatched = true;\n this._onTrackMetadata('audio', meta);\n\n let mi = this._mediaInfo;\n mi.audioCodec = meta.codec;\n mi.audioSampleRate = meta.audioSampleRate;\n mi.audioChannelCount = meta.channelCount;\n mi.audioDataRate = misc.bitRate;\n if (mi.hasVideo) {\n if (mi.videoCodec != null) {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + ',' + mi.audioCodec + '\"';\n }\n } else {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.audioCodec + '\"';\n }\n if (mi.isComplete()) {\n this._onMediaInfo(mi);\n }\n }\n\n // This packet is always a valid audio packet, extract it\n let data = this._parseMP3AudioData(arrayBuffer, dataOffset + 1, dataSize - 1, false);\n if (data == undefined) {\n return;\n }\n let dts = this._timestampBase + tagTimestamp;\n let mp3Sample = {unit: data, length: data.byteLength, dts: dts, pts: dts};\n track.samples.push(mp3Sample);\n track.length += data.length;\n }\n }\n\n _parseAACAudioData(arrayBuffer, dataOffset, dataSize) {\n if (dataSize <= 1) {\n Log.w(this.TAG, 'Flv: Invalid AAC packet, missing AACPacketType or/and Data!');\n return;\n }\n\n let result = {};\n let array = new Uint8Array(arrayBuffer, dataOffset, dataSize);\n\n result.packetType = array[0];\n\n if (array[0] === 0) {\n result.data = this._parseAACAudioSpecificConfig(arrayBuffer, dataOffset + 1, dataSize - 1);\n } else {\n result.data = array.subarray(1);\n }\n\n return result;\n }\n\n _parseAACAudioSpecificConfig(arrayBuffer, dataOffset, dataSize) {\n let array = new Uint8Array(arrayBuffer, dataOffset, dataSize);\n let config = null;\n\n /* Audio Object Type:\n 0: Null\n 1: AAC Main\n 2: AAC LC\n 3: AAC SSR (Scalable Sample Rate)\n 4: AAC LTP (Long Term Prediction)\n 5: HE-AAC / SBR (Spectral Band Replication)\n 6: AAC Scalable\n */\n\n let audioObjectType = 0;\n let originalAudioObjectType = 0;\n let audioExtensionObjectType = null;\n let samplingIndex = 0;\n let extensionSamplingIndex = null;\n\n // 5 bits\n audioObjectType = originalAudioObjectType = array[0] >>> 3;\n // 4 bits\n samplingIndex = ((array[0] & 0x07) << 1) | (array[1] >>> 7);\n if (samplingIndex < 0 || samplingIndex >= this._mpegSamplingRates.length) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: AAC invalid sampling frequency index!');\n return;\n }\n\n let samplingFrequence = this._mpegSamplingRates[samplingIndex];\n\n // 4 bits\n let channelConfig = (array[1] & 0x78) >>> 3;\n if (channelConfig < 0 || channelConfig >= 8) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: AAC invalid channel configuration');\n return;\n }\n\n if (audioObjectType === 5) { // HE-AAC?\n // 4 bits\n extensionSamplingIndex = ((array[1] & 0x07) << 1) | (array[2] >>> 7);\n // 5 bits\n audioExtensionObjectType = (array[2] & 0x7C) >>> 2;\n }\n\n // workarounds for various browsers\n let userAgent = self.navigator.userAgent.toLowerCase();\n\n if (userAgent.indexOf('firefox') !== -1) {\n // firefox: use SBR (HE-AAC) if freq less than 24kHz\n if (samplingIndex >= 6) {\n audioObjectType = 5;\n config = new Array(4);\n extensionSamplingIndex = samplingIndex - 3;\n } else { // use LC-AAC\n audioObjectType = 2;\n config = new Array(2);\n extensionSamplingIndex = samplingIndex;\n }\n } else if (userAgent.indexOf('android') !== -1) {\n // android: always use LC-AAC\n audioObjectType = 2;\n config = new Array(2);\n extensionSamplingIndex = samplingIndex;\n } else {\n // for other browsers, e.g. chrome...\n // Always use HE-AAC to make it easier to switch aac codec profile\n audioObjectType = 5;\n extensionSamplingIndex = samplingIndex;\n config = new Array(4);\n\n if (samplingIndex >= 6) {\n extensionSamplingIndex = samplingIndex - 3;\n } else if (channelConfig === 1) { // Mono channel\n audioObjectType = 2;\n config = new Array(2);\n extensionSamplingIndex = samplingIndex;\n }\n }\n\n config[0] = audioObjectType << 3;\n config[0] |= (samplingIndex & 0x0F) >>> 1;\n config[1] = (samplingIndex & 0x0F) << 7;\n config[1] |= (channelConfig & 0x0F) << 3;\n if (audioObjectType === 5) {\n config[1] |= ((extensionSamplingIndex & 0x0F) >>> 1);\n config[2] = (extensionSamplingIndex & 0x01) << 7;\n // extended audio object type: force to 2 (LC-AAC)\n config[2] |= (2 << 2);\n config[3] = 0;\n }\n\n return {\n config: config,\n samplingRate: samplingFrequence,\n channelCount: channelConfig,\n codec: 'mp4a.40.' + audioObjectType,\n originalCodec: 'mp4a.40.' + originalAudioObjectType\n };\n }\n\n _parseMP3AudioData(arrayBuffer, dataOffset, dataSize, requestHeader) {\n if (dataSize < 4) {\n Log.w(this.TAG, 'Flv: Invalid MP3 packet, header missing!');\n return;\n }\n\n let le = this._littleEndian;\n let array = new Uint8Array(arrayBuffer, dataOffset, dataSize);\n let result = null;\n\n if (requestHeader) {\n if (array[0] !== 0xFF) {\n return;\n }\n let ver = (array[1] >>> 3) & 0x03;\n let layer = (array[1] & 0x06) >> 1;\n\n let bitrate_index = (array[2] & 0xF0) >>> 4;\n let sampling_freq_index = (array[2] & 0x0C) >>> 2;\n\n let channel_mode = (array[3] >>> 6) & 0x03;\n let channel_count = channel_mode !== 3 ? 2 : 1;\n\n let sample_rate = 0;\n let bit_rate = 0;\n let object_type = 34; // Layer-3, listed in MPEG-4 Audio Object Types\n\n let codec = 'mp3';\n\n switch (ver) {\n case 0: // MPEG 2.5\n sample_rate = this._mpegAudioV25SampleRateTable[sampling_freq_index];\n break;\n case 2: // MPEG 2\n sample_rate = this._mpegAudioV20SampleRateTable[sampling_freq_index];\n break;\n case 3: // MPEG 1\n sample_rate = this._mpegAudioV10SampleRateTable[sampling_freq_index];\n break;\n }\n\n switch (layer) {\n case 1: // Layer 3\n object_type = 34;\n if (bitrate_index < this._mpegAudioL3BitRateTable.length) {\n bit_rate = this._mpegAudioL3BitRateTable[bitrate_index];\n }\n break;\n case 2: // Layer 2\n object_type = 33;\n if (bitrate_index < this._mpegAudioL2BitRateTable.length) {\n bit_rate = this._mpegAudioL2BitRateTable[bitrate_index];\n }\n break;\n case 3: // Layer 1\n object_type = 32;\n if (bitrate_index < this._mpegAudioL1BitRateTable.length) {\n bit_rate = this._mpegAudioL1BitRateTable[bitrate_index];\n }\n break;\n }\n\n result = {\n bitRate: bit_rate,\n samplingRate: sample_rate,\n channelCount: channel_count,\n codec: codec,\n originalCodec: codec\n };\n } else {\n result = array;\n }\n\n return result;\n }\n\n _parseVideoData(arrayBuffer, dataOffset, dataSize, tagTimestamp, tagPosition) {\n if (dataSize <= 1) {\n Log.w(this.TAG, 'Flv: Invalid video packet, missing VideoData payload!');\n return;\n }\n\n if (this._hasVideoFlagOverrided === true && this._hasVideo === false) {\n // If hasVideo: false indicated explicitly in MediaDataSource,\n // Ignore all the video packets\n return;\n }\n\n let spec = (new Uint8Array(arrayBuffer, dataOffset, dataSize))[0];\n\n let isExHeader = (spec & 0b10000000) !== 0;\n let frameType = (spec & 0b01110000) >>> 4;\n\n if (!isExHeader) {\n let codecId = spec & 0b00001111;\n if (codecId === 7) { // AVC\n this._parseAVCVideoPacket(arrayBuffer, dataOffset + 1, dataSize - 1, tagTimestamp, tagPosition, frameType);\n } else if (codecId === 12) { // HEVC\n this._parseHEVCVideoPacket(arrayBuffer, dataOffset + 1, dataSize - 1, tagTimestamp, tagPosition, frameType);\n } else {\n this._onError(DemuxErrors.CODEC_UNSUPPORTED, `Flv: Unsupported codec in video frame: ${codecId}`);\n return;\n }\n } else {\n let packetType = spec & 0b00001111;\n let fourcc = String.fromCharCode(... (new Uint8Array(arrayBuffer, dataOffset, dataSize)).slice(1, 5));\n\n if (fourcc === 'hvc1') { // HEVC\n this._parseEnhancedHEVCVideoPacket(arrayBuffer, dataOffset + 5, dataSize - 5, tagTimestamp, tagPosition, frameType, packetType);\n } else {\n this._onError(DemuxErrors.CODEC_UNSUPPORTED, `Flv: Unsupported codec in video frame: ${fourcc}`);\n return;\n }\n }\n }\n\n _parseAVCVideoPacket(arrayBuffer, dataOffset, dataSize, tagTimestamp, tagPosition, frameType) {\n if (dataSize < 4) {\n Log.w(this.TAG, 'Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime');\n return;\n }\n\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let packetType = v.getUint8(0);\n let cts_unsigned = v.getUint32(0, !le) & 0x00FFFFFF;\n let cts = (cts_unsigned << 8) >> 8; // convert to 24-bit signed int\n\n if (packetType === 0) { // AVCDecoderConfigurationRecord\n this._parseAVCDecoderConfigurationRecord(arrayBuffer, dataOffset + 4, dataSize - 4);\n } else if (packetType === 1) { // One or more Nalus\n this._parseAVCVideoData(arrayBuffer, dataOffset + 4, dataSize - 4, tagTimestamp, tagPosition, frameType, cts);\n } else if (packetType === 2) {\n // empty, AVC end of sequence\n } else {\n this._onError(DemuxErrors.FORMAT_ERROR, `Flv: Invalid video packet type ${packetType}`);\n return;\n }\n }\n\n _parseHEVCVideoPacket(arrayBuffer, dataOffset, dataSize, tagTimestamp, tagPosition, frameType) {\n if (dataSize < 4) {\n Log.w(this.TAG, 'Flv: Invalid HEVC packet, missing HEVCPacketType or/and CompositionTime');\n return;\n }\n\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let packetType = v.getUint8(0);\n let cts_unsigned = v.getUint32(0, !le) & 0x00FFFFFF;\n let cts = (cts_unsigned << 8) >> 8; // convert to 24-bit signed int\n\n if (packetType === 0) { // HEVCDecoderConfigurationRecord\n this._parseHEVCDecoderConfigurationRecord(arrayBuffer, dataOffset + 4, dataSize - 4);\n } else if (packetType === 1) { // One or more Nalus\n this._parseHEVCVideoData(arrayBuffer, dataOffset + 4, dataSize - 4, tagTimestamp, tagPosition, frameType, cts);\n } else if (packetType === 2) {\n // empty, HEVC end of sequence\n } else {\n this._onError(DemuxErrors.FORMAT_ERROR, `Flv: Invalid video packet type ${packetType}`);\n return;\n }\n }\n\n _parseEnhancedHEVCVideoPacket(arrayBuffer, dataOffset, dataSize, tagTimestamp, tagPosition, frameType, packetType) {\n if (dataSize < 4) {\n Log.w(this.TAG, 'Flv: Invalid HEVC packet, missing HEVCPacketType or/and CompositionTime');\n return;\n }\n\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n if (packetType === 0) { // HEVCDecoderConfigurationRecord\n this._parseHEVCDecoderConfigurationRecord(arrayBuffer, dataOffset, dataSize);\n } else if (packetType === 1) { // One or more Nalus\n let cts_unsigned = v.getUint32(0, !le) & 0xFFFFFF00;\n let cts = cts_unsigned >> 8; // convert to 24-bit signed int\n\n this._parseHEVCVideoData(arrayBuffer, dataOffset + 3, dataSize - 3, tagTimestamp, tagPosition, frameType, cts);\n } else if (packetType === 3) {\n this._parseHEVCVideoData(arrayBuffer, dataOffset, dataSize, tagTimestamp, tagPosition, frameType, 0);\n } else if (packetType === 2) {\n // empty, HEVC end of sequence\n } else {\n this._onError(DemuxErrors.FORMAT_ERROR, `Flv: Invalid video packet type ${packetType}`);\n return;\n }\n }\n\n _parseAVCDecoderConfigurationRecord(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 7) {\n Log.w(this.TAG, 'Flv: Invalid AVCDecoderConfigurationRecord, lack of data!');\n return;\n }\n\n let meta = this._videoMetadata;\n let track = this._videoTrack;\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n if (!meta) {\n if (this._hasVideo === false && this._hasVideoFlagOverrided === false) {\n this._hasVideo = true;\n this._mediaInfo.hasVideo = true;\n }\n\n meta = this._videoMetadata = {};\n meta.type = 'video';\n meta.id = track.id;\n meta.timescale = this._timescale;\n meta.duration = this._duration;\n } else {\n if (typeof meta.avcc !== 'undefined') {\n let new_avcc = new Uint8Array(arrayBuffer, dataOffset, dataSize);\n if (buffersAreEqual(new_avcc, meta.avcc)) {\n // AVCDecoderConfigurationRecord is not changed, ignore it to avoid initializaiton segment re-generating\n return;\n } else {\n Log.w(this.TAG, 'AVCDecoderConfigurationRecord has been changed, re-generate initialization segment');\n }\n }\n }\n\n let version = v.getUint8(0); // configurationVersion\n let avcProfile = v.getUint8(1); // avcProfileIndication\n let profileCompatibility = v.getUint8(2); // profile_compatibility\n let avcLevel = v.getUint8(3); // AVCLevelIndication\n\n if (version !== 1 || avcProfile === 0) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: Invalid AVCDecoderConfigurationRecord');\n return;\n }\n\n this._naluLengthSize = (v.getUint8(4) & 3) + 1; // lengthSizeMinusOne\n if (this._naluLengthSize !== 3 && this._naluLengthSize !== 4) { // holy shit!!!\n this._onError(DemuxErrors.FORMAT_ERROR, `Flv: Strange NaluLengthSizeMinusOne: ${this._naluLengthSize - 1}`);\n return;\n }\n\n let spsCount = v.getUint8(5) & 31; // numOfSequenceParameterSets\n if (spsCount === 0) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: Invalid AVCDecoderConfigurationRecord: No SPS');\n return;\n } else if (spsCount > 1) {\n Log.w(this.TAG, `Flv: Strange AVCDecoderConfigurationRecord: SPS Count = ${spsCount}`);\n }\n\n let offset = 6;\n\n for (let i = 0; i < spsCount; i++) {\n let len = v.getUint16(offset, !le); // sequenceParameterSetLength\n offset += 2;\n\n if (len === 0) {\n continue;\n }\n\n // Notice: Nalu without startcode header (00 00 00 01)\n let sps = new Uint8Array(arrayBuffer, dataOffset + offset, len);\n offset += len;\n\n let config = SPSParser.parseSPS(sps);\n if (i !== 0) {\n // ignore other sps's config\n continue;\n }\n\n meta.codecWidth = config.codec_size.width;\n meta.codecHeight = config.codec_size.height;\n meta.presentWidth = config.present_size.width;\n meta.presentHeight = config.present_size.height;\n\n meta.profile = config.profile_string;\n meta.level = config.level_string;\n meta.bitDepth = config.bit_depth;\n meta.chromaFormat = config.chroma_format;\n meta.sarRatio = config.sar_ratio;\n meta.frameRate = config.frame_rate;\n\n if (config.frame_rate.fixed === false ||\n config.frame_rate.fps_num === 0 ||\n config.frame_rate.fps_den === 0) {\n meta.frameRate = this._referenceFrameRate;\n }\n\n let fps_den = meta.frameRate.fps_den;\n let fps_num = meta.frameRate.fps_num;\n meta.refSampleDuration = meta.timescale * (fps_den / fps_num);\n\n let codecArray = sps.subarray(1, 4);\n let codecString = 'avc1.';\n for (let j = 0; j < 3; j++) {\n let h = codecArray[j].toString(16);\n if (h.length < 2) {\n h = '0' + h;\n }\n codecString += h;\n }\n meta.codec = codecString;\n\n let mi = this._mediaInfo;\n mi.width = meta.codecWidth;\n mi.height = meta.codecHeight;\n mi.fps = meta.frameRate.fps;\n mi.profile = meta.profile;\n mi.level = meta.level;\n mi.refFrames = config.ref_frames;\n mi.chromaFormat = config.chroma_format_string;\n mi.sarNum = meta.sarRatio.width;\n mi.sarDen = meta.sarRatio.height;\n mi.videoCodec = codecString;\n\n if (mi.hasAudio) {\n if (mi.audioCodec != null) {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + ',' + mi.audioCodec + '\"';\n }\n } else {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + '\"';\n }\n if (mi.isComplete()) {\n this._onMediaInfo(mi);\n }\n }\n\n let ppsCount = v.getUint8(offset); // numOfPictureParameterSets\n if (ppsCount === 0) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: Invalid AVCDecoderConfigurationRecord: No PPS');\n return;\n } else if (ppsCount > 1) {\n Log.w(this.TAG, `Flv: Strange AVCDecoderConfigurationRecord: PPS Count = ${ppsCount}`);\n }\n\n offset++;\n\n for (let i = 0; i < ppsCount; i++) {\n let len = v.getUint16(offset, !le); // pictureParameterSetLength\n offset += 2;\n\n if (len === 0) {\n continue;\n }\n\n // pps is useless for extracting video information\n offset += len;\n }\n\n meta.avcc = new Uint8Array(dataSize);\n meta.avcc.set(new Uint8Array(arrayBuffer, dataOffset, dataSize), 0);\n Log.v(this.TAG, 'Parsed AVCDecoderConfigurationRecord');\n\n if (this._isInitialMetadataDispatched()) {\n // flush parsed frames\n if (this._dispatch && (this._audioTrack.length || this._videoTrack.length)) {\n this._onDataAvailable(this._audioTrack, this._videoTrack);\n }\n } else {\n this._videoInitialMetadataDispatched = true;\n }\n // notify new metadata\n this._dispatch = false;\n this._onTrackMetadata('video', meta);\n }\n\n _parseHEVCDecoderConfigurationRecord(arrayBuffer, dataOffset, dataSize) {\n if (dataSize < 22) {\n Log.w(this.TAG, 'Flv: Invalid HEVCDecoderConfigurationRecord, lack of data!');\n return;\n }\n\n let meta = this._videoMetadata;\n let track = this._videoTrack;\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n if (!meta) {\n if (this._hasVideo === false && this._hasVideoFlagOverrided === false) {\n this._hasVideo = true;\n this._mediaInfo.hasVideo = true;\n }\n\n meta = this._videoMetadata = {};\n meta.type = 'video';\n meta.id = track.id;\n meta.timescale = this._timescale;\n meta.duration = this._duration;\n } else {\n if (typeof meta.hvcc !== 'undefined') {\n let new_hvcc = new Uint8Array(arrayBuffer, dataOffset, dataSize);\n if (buffersAreEqual(new_hvcc, meta.hvcc)) {\n // HEVCDecoderConfigurationRecord not changed, ignore it to avoid initializaiton segment re-generating\n return;\n } else {\n Log.w(this.TAG, 'HEVCDecoderConfigurationRecord has been changed, re-generate initialization segment');\n }\n }\n }\n\n let version = v.getUint8(0); // configurationVersion\n let hevcProfile = v.getUint8(1) & 0x1F; // hevcProfileIndication\n\n if (version !== 1 || hevcProfile === 0) {\n this._onError(DemuxErrors.FORMAT_ERROR, 'Flv: Invalid HEVCDecoderConfigurationRecord');\n return;\n }\n\n this._naluLengthSize = (v.getUint8(21) & 3) + 1; // lengthSizeMinusOne\n if (this._naluLengthSize !== 3 && this._naluLengthSize !== 4) { // holy shit!!!\n this._onError(DemuxErrors.FORMAT_ERROR, `Flv: Strange NaluLengthSizeMinusOne: ${this._naluLengthSize - 1}`);\n return;\n }\n\n let numOfArrays = v.getUint8(22);\n for (let i = 0, offset = 23; i < numOfArrays; i++) {\n let nalUnitType = v.getUint8(offset + 0) & 0x3F;\n let numNalus = v.getUint16(offset + 1, !le);\n\n offset += 3;\n for (let j = 0; j < numNalus; j++) {\n let len = v.getUint16(offset + 0, !le);\n if (j !== 0) {\n offset += 2 + len;\n continue;\n }\n\n if (nalUnitType === 33) {\n offset += 2;\n let sps = new Uint8Array(arrayBuffer, dataOffset + offset, len);\n\n let config = H265Parser.parseSPS(sps);\n meta.codecWidth = config.codec_size.width;\n meta.codecHeight = config.codec_size.height;\n meta.presentWidth = config.present_size.width;\n meta.presentHeight = config.present_size.height;\n\n meta.profile = config.profile_string;\n meta.level = config.level_string;\n meta.bitDepth = config.bit_depth;\n meta.chromaFormat = config.chroma_format;\n meta.sarRatio = config.sar_ratio;\n meta.frameRate = config.frame_rate;\n\n if (config.frame_rate.fixed === false ||\n config.frame_rate.fps_num === 0 ||\n config.frame_rate.fps_den === 0) {\n meta.frameRate = this._referenceFrameRate;\n }\n\n let fps_den = meta.frameRate.fps_den;\n let fps_num = meta.frameRate.fps_num;\n meta.refSampleDuration = meta.timescale * (fps_den / fps_num);\n meta.codec = config.codec_mimetype;\n\n let mi = this._mediaInfo;\n mi.width = meta.codecWidth;\n mi.height = meta.codecHeight;\n mi.fps = meta.frameRate.fps;\n mi.profile = meta.profile;\n mi.level = meta.level;\n mi.refFrames = config.ref_frames;\n mi.chromaFormat = config.chroma_format_string;\n mi.sarNum = meta.sarRatio.width;\n mi.sarDen = meta.sarRatio.height;\n mi.videoCodec = config.codec_mimetype;\n\n if (mi.hasAudio) {\n if (mi.audioCodec != null) {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + ',' + mi.audioCodec + '\"';\n }\n } else {\n mi.mimeType = 'video/x-flv; codecs=\"' + mi.videoCodec + '\"';\n }\n if (mi.isComplete()) {\n this._onMediaInfo(mi);\n }\n\n offset += len;\n } else {\n offset += 2 + len;\n }\n }\n }\n\n meta.hvcc = new Uint8Array(dataSize);\n meta.hvcc.set(new Uint8Array(arrayBuffer, dataOffset, dataSize), 0);\n Log.v(this.TAG, 'Parsed HEVCDecoderConfigurationRecord');\n\n if (this._isInitialMetadataDispatched()) {\n // flush parsed frames\n if (this._dispatch && (this._audioTrack.length || this._videoTrack.length)) {\n this._onDataAvailable(this._audioTrack, this._videoTrack);\n }\n } else {\n this._videoInitialMetadataDispatched = true;\n }\n // notify new metadata\n this._dispatch = false;\n this._onTrackMetadata('video', meta);\n }\n\n _parseAVCVideoData(arrayBuffer, dataOffset, dataSize, tagTimestamp, tagPosition, frameType, cts) {\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let units = [], length = 0;\n\n let offset = 0;\n const lengthSize = this._naluLengthSize;\n let dts = this._timestampBase + tagTimestamp;\n let keyframe = (frameType === 1); // from FLV Frame Type constants\n\n while (offset < dataSize) {\n if (offset + 4 >= dataSize) {\n Log.w(this.TAG, `Malformed Nalu near timestamp ${dts}, offset = ${offset}, dataSize = ${dataSize}`);\n break; // data not enough for next Nalu\n }\n // Nalu with length-header (AVC1)\n let naluSize = v.getUint32(offset, !le); // Big-Endian read\n if (lengthSize === 3) {\n naluSize >>>= 8;\n }\n if (naluSize > dataSize - lengthSize) {\n Log.w(this.TAG, `Malformed Nalus near timestamp ${dts}, NaluSize > DataSize!`);\n return;\n }\n\n let unitType = v.getUint8(offset + lengthSize) & 0x1F;\n\n if (unitType === 5) { // IDR\n keyframe = true;\n }\n\n let data = new Uint8Array(arrayBuffer, dataOffset + offset, lengthSize + naluSize);\n let unit = {type: unitType, data: data};\n units.push(unit);\n length += data.byteLength;\n\n offset += lengthSize + naluSize;\n }\n\n if (units.length) {\n let track = this._videoTrack;\n let avcSample = {\n units: units,\n length: length,\n isKeyframe: keyframe,\n dts: dts,\n cts: cts,\n pts: (dts + cts)\n };\n if (keyframe) {\n avcSample.fileposition = tagPosition;\n }\n track.samples.push(avcSample);\n track.length += length;\n }\n }\n\n _parseHEVCVideoData(arrayBuffer, dataOffset, dataSize, tagTimestamp, tagPosition, frameType, cts) {\n let le = this._littleEndian;\n let v = new DataView(arrayBuffer, dataOffset, dataSize);\n\n let units = [], length = 0;\n\n let offset = 0;\n const lengthSize = this._naluLengthSize;\n let dts = this._timestampBase + tagTimestamp;\n let keyframe = (frameType === 1); // from FLV Frame Type constants\n\n while (offset < dataSize) {\n if (offset + 4 >= dataSize) {\n Log.w(this.TAG, `Malformed Nalu near timestamp ${dts}, offset = ${offset}, dataSize = ${dataSize}`);\n break; // data not enough for next Nalu\n }\n // Nalu with length-header (HVC1)\n let naluSize = v.getUint32(offset, !le); // Big-Endian read\n if (lengthSize === 3) {\n naluSize >>>= 8;\n }\n if (naluSize > dataSize - lengthSize) {\n Log.w(this.TAG, `Malformed Nalus near timestamp ${dts}, NaluSize > DataSize!`);\n return;\n }\n\n let unitType = v.getUint8(offset + lengthSize) & 0x1F;\n\n if (unitType === 19 || unitType === 20) { // IDR\n keyframe = true;\n }\n\n let data = new Uint8Array(arrayBuffer, dataOffset + offset, lengthSize + naluSize);\n let unit = {type: unitType, data: data};\n units.push(unit);\n length += data.byteLength;\n\n offset += lengthSize + naluSize;\n }\n\n if (units.length) {\n let track = this._videoTrack;\n let hevcSample = {\n units: units,\n length: length,\n isKeyframe: keyframe,\n dts: dts,\n cts: cts,\n pts: (dts + cts)\n };\n if (keyframe) {\n hevcSample.fileposition = tagPosition;\n }\n track.samples.push(hevcSample);\n track.length += length;\n }\n }\n\n}\n\nexport default FLVDemuxer;","interface ProgramToPMTPIDMap {\n [program: number]: number;\n}\n\nexport class PAT {\n version_number: number;\n network_pid: number;\n // program_number -> pmt_pid\n program_pmt_pid: ProgramToPMTPIDMap = {};\n}\n\nexport enum StreamType {\n kMPEG1Audio = 0x03,\n kMPEG2Audio = 0x04,\n kPESPrivateData = 0x06,\n kADTSAAC = 0x0F,\n kLOASAAC = 0x11,\n kAC3 = 0x81,\n kID3 = 0x15,\n kSCTE35 = 0x86,\n kH264 = 0x1b,\n kH265 = 0x24\n}\n\ninterface PIDToStreamTypeMap {\n [pid: number]: StreamType;\n}\n\nexport class PMT {\n program_number: number;\n version_number: number;\n pcr_pid: number;\n // pid -> stream_type\n pid_stream_type: PIDToStreamTypeMap = {};\n\n common_pids: {\n h264: number | undefined,\n h265: number | undefined;\n adts_aac: number | undefined,\n loas_aac: number | undefined,\n opus: number | undefined,\n ac3: number | undefined,\n mp3: number | undefined\n } = {\n h264: undefined,\n h265: undefined,\n adts_aac: undefined,\n loas_aac: undefined,\n opus: undefined,\n ac3: undefined,\n mp3: undefined\n };\n\n pes_private_data_pids: {\n [pid: number]: boolean\n } = {};\n\n timed_id3_pids: {\n [pid: number]: boolean\n } = {};\n\n scte_35_pids: {\n [pid: number]: boolean\n } = {};\n\n smpte2038_pids: {\n [oid: number]: boolean\n } = {};\n}\n\nexport interface ProgramToPMTMap {\n [program: number]: PMT;\n}\n\nexport class PESData {\n pid: number;\n data: Uint8Array;\n stream_type: StreamType;\n file_position: number;\n random_access_indicator: number;\n}\n\nexport class SectionData {\n pid: number;\n data: Uint8Array;\n file_position: number;\n random_access_indicator: number;\n}\n\nexport class SliceQueue {\n slices: Uint8Array[] = [];\n total_length: number = 0;\n expected_length: number = 0;\n file_position: number = 0;\n random_access_indicator: 0;\n}\n\nexport interface PIDToSliceQueues {\n [pid: number]: SliceQueue;\n}\n","import MediaInfo from '../core/media-info';\nimport { PESPrivateData, PESPrivateDataDescriptor } from './pes-private-data';\nimport { SMPTE2038Data } from './smpte2038';\nimport { SCTE35Data } from './scte35';\n\ntype OnErrorCallback = (type: string, info: string) => void;\ntype OnMediaInfoCallback = (mediaInfo: MediaInfo) => void;\ntype OnMetaDataArrivedCallback = (metadata: any) => void;\ntype OnTrackMetadataCallback = (type: string, metadata: any) => void;\ntype OnDataAvailableCallback = (videoTrack: any, audioTrack: any) => void;\ntype OnTimedID3MetadataCallback = (timed_id3_data: PESPrivateData) => void;\ntype OnSMPTE2038MetadataCallback = (smpte2038_data: SMPTE2038Data) => void;\ntype OnSCTE35MetadataCallback = (scte35_data: SCTE35Data) => void;\ntype OnPESPrivateDataCallback = (private_data: PESPrivateData) => void;\ntype OnPESPrivateDataDescriptorCallback = (private_data_descriptor: PESPrivateDataDescriptor) => void;\n\nexport default abstract class BaseDemuxer {\n\n public onError: OnErrorCallback;\n public onMediaInfo: OnMediaInfoCallback;\n public onMetaDataArrived: OnMetaDataArrivedCallback;\n public onTrackMetadata: OnTrackMetadataCallback;\n public onDataAvailable: OnDataAvailableCallback;\n public onTimedID3Metadata: OnTimedID3MetadataCallback;\n public onSMPTE2038Metadata: OnSMPTE2038MetadataCallback;\n public onSCTE35Metadata: OnSCTE35MetadataCallback;\n public onPESPrivateData: OnPESPrivateDataCallback;\n public onPESPrivateDataDescriptor: OnPESPrivateDataDescriptorCallback;\n\n public constructor() {}\n\n public destroy(): void {\n this.onError = null;\n this.onMediaInfo = null;\n this.onMetaDataArrived = null;\n this.onTrackMetadata = null;\n this.onDataAvailable = null;\n this.onTimedID3Metadata = null;\n this.onSMPTE2038Metadata = null;\n this.onSCTE35Metadata = null;\n this.onPESPrivateData = null;\n this.onPESPrivateDataDescriptor = null;\n }\n\n abstract parseChunks(chunk: ArrayBuffer, byteStart: number): number;\n\n}\n","import Log from \"../utils/logger\";\n\nexport enum H264NaluType {\n kUnspecified = 0,\n kSliceNonIDR,\n kSliceDPA,\n kSliceDPB,\n kSliceDPC,\n kSliceIDR,\n kSliceSEI,\n kSliceSPS,\n kSlicePPS,\n kSliceAUD,\n kEndOfSequence,\n kEndOfStream,\n kFiller,\n kSPSExt,\n kReserved0\n}\n\nexport class H264NaluPayload {\n type: H264NaluType;\n data: Uint8Array;\n}\n\nexport class H264NaluAVC1 {\n type: H264NaluType;\n data: Uint8Array;\n\n constructor(nalu: H264NaluPayload) {\n let nalu_size = nalu.data.byteLength;\n\n this.type = nalu.type;\n this.data = new Uint8Array(4 + nalu_size); // 4 byte length-header + nalu payload\n\n let v = new DataView(this.data.buffer);\n // Fill 4 byte length-header\n v.setUint32(0, nalu_size);\n // Copy payload\n this.data.set(nalu.data, 4);\n }\n}\n\nexport class H264AnnexBParser {\n\n private readonly TAG: string = \"H264AnnexBParser\";\n\n private data_: Uint8Array;\n private current_startcode_offset_: number = 0;\n private eof_flag_: boolean = false;\n\n public constructor(data: Uint8Array) {\n this.data_ = data;\n this.current_startcode_offset_ = this.findNextStartCodeOffset(0);\n if (this.eof_flag_) {\n Log.e(this.TAG, \"Could not find H264 startcode until payload end!\");\n }\n }\n\n private findNextStartCodeOffset(start_offset: number) {\n let i = start_offset;\n let data = this.data_;\n\n while (true) {\n if (i + 3 >= data.byteLength) {\n this.eof_flag_ = true;\n return data.byteLength;\n }\n\n // search 00 00 00 01 or 00 00 01\n let uint32 = (data[i + 0] << 24)\n | (data[i + 1] << 16)\n | (data[i + 2] << 8)\n | (data[i + 3]);\n let uint24 = (data[i + 0] << 16)\n | (data[i + 1] << 8)\n | (data[i + 2]);\n if (uint32 === 0x00000001 || uint24 === 0x000001) {\n return i;\n } else {\n i++;\n }\n }\n }\n\n public readNextNaluPayload(): H264NaluPayload | null {\n let data = this.data_;\n let nalu_payload: H264NaluPayload = null;\n\n while (nalu_payload == null) {\n if (this.eof_flag_) {\n break;\n }\n // offset pointed to start code\n let startcode_offset = this.current_startcode_offset_;\n\n // nalu payload start offset\n let offset = startcode_offset;\n let u32 = (data[offset] << 24) | (data[offset + 1] << 16) | (data[offset + 2] << 8) | (data[offset + 3]);\n if (u32 === 0x00000001) {\n offset += 4;\n } else {\n offset += 3;\n }\n\n let nalu_type: H264NaluType = data[offset] & 0x1F;\n let forbidden_bit = (data[offset] & 0x80) >>> 7;\n\n let next_startcode_offset = this.findNextStartCodeOffset(offset);\n this.current_startcode_offset_ = next_startcode_offset;\n\n if (nalu_type >= H264NaluType.kReserved0) {\n continue;\n }\n if (forbidden_bit !== 0) {\n // Log.e(this.TAG, `forbidden_bit near offset ${offset} should be 0 but has value ${forbidden_bit}`);\n continue;\n }\n\n let payload_data = data.subarray(offset, next_startcode_offset);\n\n nalu_payload = new H264NaluPayload();\n nalu_payload.type = nalu_type;\n nalu_payload.data = payload_data;\n }\n\n return nalu_payload;\n }\n\n}\n\n\nexport class AVCDecoderConfigurationRecord {\n\n private data: Uint8Array;\n\n // sps, pps: require Nalu without 4 byte length-header\n public constructor(sps: Uint8Array, pps: Uint8Array, sps_details: any) {\n let length = 6 + 2 + sps.byteLength + 1 + 2 + pps.byteLength;\n let need_extra_fields = false;\n\n if (sps[3] !== 66 && sps[3] !== 77 && sps[3] !== 88) {\n need_extra_fields = true;\n length += 4;\n }\n\n let data = this.data = new Uint8Array(length);\n\n data[0] = 0x01; // configurationVersion\n data[1] = sps[1]; // AVCProfileIndication\n data[2] = sps[2]; // profile_compatibility\n data[3] = sps[3]; // AVCLevelIndication\n data[4] = 0xFF; // 111111 + lengthSizeMinusOne(3)\n\n data[5] = 0xE0 | 0x01 // 111 + numOfSequenceParameterSets\n\n let sps_length = sps.byteLength;\n data[6] = sps_length >>> 8; // sequenceParameterSetLength\n data[7] = sps_length & 0xFF;\n\n let offset = 8;\n data.set(sps, 8);\n offset += sps_length;\n\n data[offset] = 1; // numOfPictureParameterSets\n\n let pps_length = pps.byteLength;\n data[offset + 1] = pps_length >>> 8; // pictureParameterSetLength\n data[offset + 2] = pps_length & 0xFF;\n\n data.set(pps, offset + 3);\n offset += 3 + pps_length;\n\n if (need_extra_fields) {\n data[offset] = 0xFC | sps_details.chroma_format_idc;\n data[offset + 1] = 0xF8 | (sps_details.bit_depth_luma - 8);\n data[offset + 2] = 0xF8 | (sps_details.bit_depth_chroma - 8);\n data[offset + 3] = 0x00; // number of sps ext\n offset += 4;\n }\n }\n\n public getData() {\n return this.data;\n }\n\n}\n","export enum MPEG4AudioObjectTypes {\n kNull = 0,\n kAACMain,\n kAAC_LC, // LC-AAC\n kAAC_SSR,\n kAAC_LTP,\n kAAC_SBR, // HE-AAC\n kAAC_Scalable,\n\n kLayer1 = 32,\n kLayer2,\n kLayer3, // MP3\n}\n\nexport enum MPEG4SamplingFrequencyIndex {\n k96000Hz = 0,\n k88200Hz,\n k64000Hz,\n k48000Hz,\n k44100Hz,\n k32000Hz,\n k24000Hz,\n k22050Hz,\n k16000Hz,\n k12000Hz,\n k11025Hz,\n k8000Hz,\n k7350Hz,\n}\n\nexport const MPEG4SamplingFrequencies = [\n 96000,\n 88200,\n 64000,\n 48000,\n 44100,\n 32000,\n 24000,\n 22050,\n 16000,\n 12000,\n 11025,\n 8000,\n 7350,\n];\n","import ExpGolomb from './exp-golomb.js';\n\nexport type SCTE35Data = {\n splice_command_type: SCTE35CommandType.kSpliceInsert\n pts?: number,\n nearest_pts?: number\n auto_return?: boolean\n duraiton?: number,\n detail: SCTE35Detail\n data: Uint8Array\n} | {\n splice_command_type: SCTE35CommandType.kTimeSignal\n pts?: number,\n nearest_pts?: number\n detail: SCTE35Detail\n data: Uint8Array\n} | {\n splice_command_type: SCTE35CommandType.kSpliceNull | SCTE35CommandType.kBandwidthReservation | SCTE35CommandType.kSpliceSchedule | SCTE35CommandType.kPrivateCommand\n pts: undefined,\n nearest_pts?: number\n detail: SCTE35Detail\n data: Uint8Array\n}\n\ntype SCTE35Detail = {\n table_id: number\n section_syntax_indicator: boolean\n private_indicator: boolean\n section_length: number\n protocol_version: number\n encrypted_packet: boolean\n encryption_algorithm: number\n pts_adjustment: number\n cw_index: number\n tier: number\n splice_command_length: number\n splice_command_type: SCTE35CommandType.kSpliceNull\n splice_command: SpliceNull\n descriptor_loop_length: number\n splice_descriptors: SpliceDescriptor[]\n E_CRC32?: number\n CRC32: number\n} | {\n table_id: number\n section_syntax_indicator: boolean\n private_indicator: boolean\n section_length: number\n protocol_version: number\n encrypted_packet: boolean\n encryption_algorithm: number\n pts_adjustment: number\n cw_index: number\n tier: number\n splice_command_length: number\n splice_command_type: SCTE35CommandType.kSpliceSchedule\n splice_command: SpliceSchedule\n descriptor_loop_length: number\n splice_descriptors: SpliceDescriptor[]\n E_CRC32?: number\n CRC32: number\n} | {\n table_id: number\n section_syntax_indicator: boolean\n private_indicator: boolean\n section_length: number\n protocol_version: number\n encrypted_packet: boolean\n encryption_algorithm: number\n pts_adjustment: number\n cw_index: number\n tier: number\n splice_command_length: number\n splice_command_type: SCTE35CommandType.kSpliceInsert\n splice_command: SpliceInsert\n descriptor_loop_length: number\n splice_descriptors: SpliceDescriptor[]\n E_CRC32?: number\n CRC32: number\n} | {\n table_id: number\n section_syntax_indicator: boolean\n private_indicator: boolean\n section_length: number\n protocol_version: number\n encrypted_packet: boolean\n encryption_algorithm: number\n pts_adjustment: number\n cw_index: number\n tier: number\n splice_command_length: number\n splice_command_type: SCTE35CommandType.kTimeSignal\n splice_command: TimeSignal\n descriptor_loop_length: number\n splice_descriptors: SpliceDescriptor[]\n E_CRC32?: number\n CRC32: number\n} | {\n table_id: number\n section_syntax_indicator: boolean\n private_indicator: boolean\n section_length: number\n protocol_version: number\n encrypted_packet: boolean\n encryption_algorithm: number\n pts_adjustment: number\n cw_index: number\n tier: number\n splice_command_length: number\n splice_command_type: SCTE35CommandType.kBandwidthReservation\n splice_command: BandwidthReservation\n descriptor_loop_length: number\n splice_descriptors: SpliceDescriptor[]\n E_CRC32?: number\n CRC32: number\n} | {\n table_id: number\n section_syntax_indicator: boolean\n private_indicator: boolean\n section_length: number\n protocol_version: number\n encrypted_packet: boolean\n encryption_algorithm: number\n pts_adjustment: number\n cw_index: number\n tier: number\n splice_command_length: number\n splice_command_type: SCTE35CommandType.kPrivateCommand\n splice_command: PrivateCommand\n descriptor_loop_length: number\n splice_descriptors: SpliceDescriptor[],\n E_CRC32?: number\n CRC32: number\n};\n\nexport enum SCTE35CommandType {\n kSpliceNull = 0x0,\n kSpliceSchedule = 0x4,\n kSpliceInsert = 0x5,\n kTimeSignal = 0x6,\n kBandwidthReservation = 0x07,\n kPrivateCommand = 0xff\n}\n\ntype SpliceTime = {\n time_specified_flag: boolean,\n pts_time?: number\n}\n\nconst parseSpliceTime = (reader: ExpGolomb): SpliceTime => {\n const time_specified_flag = reader.readBool()\n\n if (!time_specified_flag) {\n reader.readBits(7);\n return { time_specified_flag }\n } else {\n reader.readBits(6)\n const pts_time = reader.readBits(31) * 4 + reader.readBits(2);\n return {\n time_specified_flag,\n pts_time\n }\n }\n}\n\ntype BreakDuration = {\n auto_return: boolean,\n duration: number\n}\nconst parseBreakDuration = (reader: ExpGolomb): BreakDuration => {\n const auto_return = reader.readBool();\n reader.readBits(6);\n const duration = reader.readBits(31) * 4 + reader.readBits(2);\n return {\n auto_return,\n duration\n };\n}\n\ntype SpliceInsertComponent = {\n component_tag: number,\n splice_time?: SpliceTime\n}\nconst parseSpliceInsertComponent = (splice_immediate_flag: boolean, reader: ExpGolomb): SpliceInsertComponent => {\n const component_tag = reader.readBits(8);\n if (splice_immediate_flag) {\n return { component_tag };\n }\n\n const splice_time = parseSpliceTime(reader);\n return {\n component_tag,\n splice_time\n };\n}\ntype SpliceScheduleEventComponent = {\n component_tag: number,\n utc_splice_time: number\n}\nconst parseSpliceScheduleEventComponent = (reader: ExpGolomb): SpliceScheduleEventComponent => {\n const component_tag = reader.readBits(8);\n const utc_splice_time = reader.readBits(32);\n return {\n component_tag,\n utc_splice_time\n };\n}\n\ntype SpliceScheduleEvent = {\n splice_event_id: number,\n splice_event_cancel_indicator: boolean,\n out_of_network_indicator?: boolean,\n program_splice_flag?: boolean,\n duration_flag?: boolean,\n utc_splice_time?: number,\n component_count?: number,\n components?: SpliceScheduleEventComponent[]\n break_duration?: BreakDuration,\n unique_program_id?: number\n avail_num?: number,\n avails_expected?: number\n}\nconst parseSpliceScheduleEvent = (reader: ExpGolomb): SpliceScheduleEvent => {\n const splice_event_id = reader.readBits(32);\n const splice_event_cancel_indicator = reader.readBool();\n reader.readBits(7);\n\n const spliceScheduleEvent: SpliceScheduleEvent = {\n splice_event_id,\n splice_event_cancel_indicator\n }\n\n if (splice_event_cancel_indicator) {\n return spliceScheduleEvent;\n }\n\n spliceScheduleEvent.out_of_network_indicator = reader.readBool()\n spliceScheduleEvent.program_splice_flag = reader.readBool()\n spliceScheduleEvent.duration_flag = reader.readBool()\n reader.readBits(5)\n\n if (spliceScheduleEvent.program_splice_flag) {\n spliceScheduleEvent.utc_splice_time = reader.readBits(32);\n } else {\n spliceScheduleEvent.component_count = reader.readBits(8);\n spliceScheduleEvent.components = [];\n for (let i = 0; i < spliceScheduleEvent.component_count; i++) {\n spliceScheduleEvent.components.push(parseSpliceScheduleEventComponent(reader));\n }\n }\n\n if (spliceScheduleEvent.duration_flag) {\n spliceScheduleEvent.break_duration = parseBreakDuration(reader);\n }\n\n spliceScheduleEvent.unique_program_id = reader.readBits(16);\n spliceScheduleEvent.avail_num = reader.readBits(8);\n spliceScheduleEvent.avails_expected = reader.readBits(8);\n\n return spliceScheduleEvent;\n}\n\ntype SpliceNull = {}\ntype SpliceSchedule = {\n splice_count: number,\n events: SpliceScheduleEvent[],\n}\ntype SpliceInsert = {\n splice_event_id: number,\n splice_event_cancel_indicator: boolean,\n out_of_network_indicator?: boolean,\n program_splice_flag?: boolean,\n duration_flag?: boolean,\n splice_immediate_flag?: boolean,\n splice_time?: SpliceTime,\n component_count?: number,\n components?: SpliceInsertComponent[],\n break_duration?: BreakDuration,\n unique_program_id?: number,\n avail_num?: number,\n avails_expected?: number\n}\ntype TimeSignal = {\n splice_time: SpliceTime\n}\ntype BandwidthReservation = {}\ntype PrivateCommand = {\n identifier: string,\n private_data: ArrayBuffer\n}\n\ntype SpliceCommand = SpliceNull | SpliceSchedule | SpliceInsert | TimeSignal | BandwidthReservation | PrivateCommand\n\nconst parseSpliceNull = (): SpliceNull => {\n return {};\n};\nconst parseSpliceSchedule = (reader: ExpGolomb): SpliceSchedule => {\n const splice_count = reader.readBits(8)\n const events: SpliceScheduleEvent[] = [];\n for (let i = 0; i < splice_count; i++) {\n events.push(parseSpliceScheduleEvent(reader));\n }\n return {\n splice_count,\n events\n };\n}\nconst parseSpliceInsert = (reader: ExpGolomb): SpliceInsert => {\n const splice_event_id = reader.readBits(32);\n const splice_event_cancel_indicator = reader.readBool();\n reader.readBits(7);\n\n const spliceInsert: SpliceInsert = {\n splice_event_id,\n splice_event_cancel_indicator\n }\n\n if (splice_event_cancel_indicator) {\n return spliceInsert;\n }\n\n spliceInsert.out_of_network_indicator = reader.readBool()\n spliceInsert.program_splice_flag = reader.readBool()\n spliceInsert.duration_flag = reader.readBool()\n spliceInsert.splice_immediate_flag = reader.readBool()\n reader.readBits(4)\n\n if (spliceInsert.program_splice_flag && !spliceInsert.splice_immediate_flag) {\n spliceInsert.splice_time = parseSpliceTime(reader);\n }\n if (!spliceInsert.program_splice_flag) {\n spliceInsert.component_count = reader.readBits(8)\n spliceInsert.components = [];\n for (let i = 0; i < spliceInsert.component_count; i++) {\n spliceInsert.components.push(parseSpliceInsertComponent(spliceInsert.splice_immediate_flag, reader));\n }\n }\n\n if (spliceInsert.duration_flag) {\n spliceInsert.break_duration = parseBreakDuration(reader);\n }\n\n spliceInsert.unique_program_id = reader.readBits(16);\n spliceInsert.avail_num = reader.readBits(8);\n spliceInsert.avails_expected = reader.readBits(8);\n\n return spliceInsert;\n}\nconst parseTimeSignal = (reader: ExpGolomb): TimeSignal => {\n return {\n splice_time: parseSpliceTime(reader)\n };\n}\nconst parseBandwidthReservation = (): BandwidthReservation => {\n return {};\n}\nconst parsePrivateCommand = (splice_command_length: number, reader: ExpGolomb): PrivateCommand => {\n const identifier = String.fromCharCode(reader.readBits(8), reader.readBits(8), reader.readBits(8), reader.readBits(8))\n const data = new Uint8Array(splice_command_length - 4);\n for (let i = 0; i < splice_command_length - 4; i++) {\n data[i] = reader.readBits(8);\n }\n\n return {\n identifier,\n private_data: data.buffer\n }\n}\n\ntype Descriptor = {\n descriptor_tag: number,\n descriptor_length: number,\n identifier: string\n}\ntype AvailDescriptor = Descriptor & {\n provider_avail_id: number\n}\nconst parseAvailDescriptor = (descriptor_tag: number, descriptor_length: number, identifier: string, reader: ExpGolomb): AvailDescriptor => {\n const provider_avail_id = reader.readBits(32);\n\n return {\n descriptor_tag,\n descriptor_length,\n identifier,\n provider_avail_id\n }\n}\ntype DTMFDescriptor = Descriptor & {\n preroll: number,\n dtmf_count: number,\n DTMF_char: string\n}\nconst parseDTMFDescriptor = (descriptor_tag: number, descriptor_length: number, identifier: string, reader: ExpGolomb): DTMFDescriptor => {\n const preroll = reader.readBits(8);\n const dtmf_count = reader.readBits(3);\n reader.readBits(5);\n let DTMF_char = '';\n for (let i = 0; i < dtmf_count; i++) {\n DTMF_char += String.fromCharCode(reader.readBits(8));\n }\n\n return {\n descriptor_tag,\n descriptor_length,\n identifier,\n preroll,\n dtmf_count,\n DTMF_char\n };\n}\ntype SegmentationDescriptorComponent = {\n component_tag: number,\n pts_offset: number\n}\nconst parseSegmentationDescriptorComponent = (reader: ExpGolomb): SegmentationDescriptorComponent => {\n const component_tag = reader.readBits(8);\n reader.readBits(7)\n const pts_offset = reader.readBits(31) * 4 + reader.readBits(2);\n return {\n component_tag,\n pts_offset\n };\n}\ntype SegmentationDescriptor = Descriptor & {\n segmentation_event_id: number,\n segmentation_event_cancel_indicator: boolean,\n program_segmentation_flag?: boolean,\n segmentation_duration_flag?: boolean\n delivery_not_restricted_flag?: boolean\n web_delivery_allowed_flag?: boolean\n no_regional_blackout_flag?: boolean,\n archive_allowed_flag?: boolean,\n device_restrictions?: number\n component_count?: number,\n components?: any[]\n segmentation_duration?: number\n segmentation_upid_type?: number,\n segmentation_upid_length?: number,\n segmentation_upid?: ArrayBuffer,\n segmentation_type_id?: number,\n segment_num?: number,\n segments_expected?: number,\n sub_segment_num?: number,\n sub_segments_expected?: number\n}\nconst parseSegmentationDescriptor = (descriptor_tag: number, descriptor_length: number, identifier: string, reader: ExpGolomb): SegmentationDescriptor => {\n const segmentation_event_id = reader.readBits(32);\n const segmentation_event_cancel_indicator = reader.readBool();\n reader.readBits(7);\n\n const segmentationDescriptor: SegmentationDescriptor = {\n descriptor_tag,\n descriptor_length,\n identifier,\n segmentation_event_id,\n segmentation_event_cancel_indicator\n }\n\n if (segmentation_event_cancel_indicator) {\n return segmentationDescriptor;\n }\n\n segmentationDescriptor.program_segmentation_flag = reader.readBool();\n segmentationDescriptor.segmentation_duration_flag = reader.readBool();\n segmentationDescriptor.delivery_not_restricted_flag = reader.readBool();\n\n if (!segmentationDescriptor.delivery_not_restricted_flag) {\n segmentationDescriptor.web_delivery_allowed_flag = reader.readBool();\n segmentationDescriptor.no_regional_blackout_flag = reader.readBool();\n segmentationDescriptor.archive_allowed_flag = reader.readBool();\n segmentationDescriptor.device_restrictions = reader.readBits(2);\n } else {\n reader.readBits(5);\n }\n\n if (!segmentationDescriptor.program_segmentation_flag) {\n segmentationDescriptor.component_count = reader.readBits(8);\n segmentationDescriptor.components = [];\n for (let i = 0; i < segmentationDescriptor.component_count; i++) {\n segmentationDescriptor.components.push(parseSegmentationDescriptorComponent(reader));\n }\n }\n\n if (segmentationDescriptor.segmentation_duration_flag) {\n segmentationDescriptor.segmentation_duration = reader.readBits(40);\n }\n\n segmentationDescriptor.segmentation_upid_type = reader.readBits(8);\n segmentationDescriptor.segmentation_upid_length = reader.readBits(8);\n {\n const upid = new Uint8Array(segmentationDescriptor.segmentation_upid_length)\n for (let i = 0; i < segmentationDescriptor.segmentation_upid_length; i++) {\n upid[i] = reader.readBits(8);\n }\n segmentationDescriptor.segmentation_upid = upid.buffer;\n }\n segmentationDescriptor.segmentation_type_id = reader.readBits(8);\n segmentationDescriptor.segment_num = reader.readBits(8);\n segmentationDescriptor.segments_expected = reader.readBits(8);\n if (\n segmentationDescriptor.segmentation_type_id === 0x34 ||\n segmentationDescriptor.segmentation_type_id === 0x36 ||\n segmentationDescriptor.segmentation_type_id === 0x38 ||\n segmentationDescriptor.segmentation_type_id === 0x3A\n ) {\n segmentationDescriptor.sub_segment_num = reader.readBits(8);\n segmentationDescriptor.sub_segments_expected = reader.readBits(8);\n }\n\n return segmentationDescriptor;\n}\ntype TimeDescriptor = Descriptor & {\n TAI_seconds: number,\n TAI_ns: number,\n UTC_offset: number\n}\nconst parseTimeDescriptor = (descriptor_tag: number, descriptor_length: number, identifier: string, reader: ExpGolomb): TimeDescriptor => {\n const TAI_seconds = reader.readBits(48);\n const TAI_ns = reader.readBits(32);\n const UTC_offset = reader.readBits(16);\n\n return {\n descriptor_tag,\n descriptor_length,\n identifier,\n TAI_seconds,\n TAI_ns,\n UTC_offset\n };\n}\ntype AudioDescriptorComponent = {\n component_tag: number,\n ISO_code: string\n Bit_Stream_Mode: number\n Num_Channels: number,\n Full_Srvc_Audio: boolean\n}\nconst parseAudioDescriptorComponent = (reader: ExpGolomb): AudioDescriptorComponent => {\n const component_tag = reader.readBits(8)\n const ISO_code = String.fromCharCode(reader.readBits(8), reader.readBits(8), reader.readBits(8));\n const Bit_Stream_Mode = reader.readBits(3);\n const Num_Channels = reader.readBits(4);\n const Full_Srvc_Audio = reader.readBool();\n\n return {\n component_tag,\n ISO_code,\n Bit_Stream_Mode,\n Num_Channels,\n Full_Srvc_Audio\n };\n}\ntype AudioDescriptor = Descriptor & {\n audio_count: number,\n components: AudioDescriptorComponent[]\n}\nconst parseAudioDescriptor = (descriptor_tag: number, descriptor_length: number, identifier: string, reader: ExpGolomb): AudioDescriptor => {\n const audio_count = reader.readBits(4);\n const components: AudioDescriptorComponent[] = [];\n for (let i = 0; i < audio_count; i++) {\n components.push(parseAudioDescriptorComponent(reader));\n }\n\n return {\n descriptor_tag,\n descriptor_length,\n identifier,\n audio_count,\n components\n };\n}\n\ntype SpliceDescriptor = AvailDescriptor | DTMFDescriptor | SegmentationDescriptor | TimeDescriptor | AudioDescriptor;\n\nexport const readSCTE35 = (data: Uint8Array): SCTE35Data => {\n const reader = new ExpGolomb(data);\n\n const table_id = reader.readBits(8);\n const section_syntax_indicator = reader.readBool();\n const private_indicator = reader.readBool();\n reader.readBits(2);\n const section_length = reader.readBits(12);\n const protocol_version = reader.readBits(8);\n const encrypted_packet = reader.readBool();\n const encryption_algorithm = reader.readBits(6);\n const pts_adjustment = reader.readBits(31) * 4 + reader.readBits(2);\n const cw_index = reader.readBits(8);\n const tier = reader.readBits(12);\n const splice_command_length = reader.readBits(12)\n const splice_command_type = reader.readBits(8)\n\n let splice_command: SpliceCommand | null = null;\n if (splice_command_type === SCTE35CommandType.kSpliceNull) {\n splice_command = parseSpliceNull();\n } else if (splice_command_type === SCTE35CommandType.kSpliceSchedule) {\n splice_command = parseSpliceSchedule(reader);\n } else if (splice_command_type === SCTE35CommandType.kSpliceInsert) {\n splice_command = parseSpliceInsert(reader);\n } else if (splice_command_type === SCTE35CommandType.kTimeSignal) {\n splice_command = parseTimeSignal(reader);\n } else if (splice_command_type === SCTE35CommandType.kBandwidthReservation) {\n splice_command = parseBandwidthReservation();\n } else if (splice_command_type === SCTE35CommandType.kPrivateCommand) {\n splice_command = parsePrivateCommand(splice_command_length, reader)\n } else {\n reader.readBits(splice_command_length * 8);\n }\n\n const splice_descriptors: SpliceDescriptor[] = [];\n\n const descriptor_loop_length = reader.readBits(16);\n for (let length = 0; length < descriptor_loop_length;) {\n const descriptor_tag = reader.readBits(8);\n const descriptor_length = reader.readBits(8);\n const identifier = String.fromCharCode(reader.readBits(8), reader.readBits(8), reader.readBits(8), reader.readBits(8));\n\n if (descriptor_tag === 0x00) {\n splice_descriptors.push(parseAvailDescriptor(descriptor_tag, descriptor_length, identifier, reader));\n } else if (descriptor_tag === 0x01) {\n splice_descriptors.push(parseDTMFDescriptor(descriptor_tag, descriptor_length, identifier, reader));\n } else if (descriptor_tag === 0x02) {\n splice_descriptors.push(parseSegmentationDescriptor(descriptor_tag, descriptor_length, identifier, reader));\n } else if (descriptor_tag === 0x03) {\n splice_descriptors.push(parseTimeDescriptor(descriptor_tag, descriptor_length, identifier, reader));\n } else if (descriptor_tag === 0x04) {\n splice_descriptors.push(parseAudioDescriptor(descriptor_tag, descriptor_length, identifier, reader));\n } else {\n reader.readBits((descriptor_length - 4) * 8);\n }\n\n length += 2 + descriptor_length;\n }\n\n const E_CRC32 = encrypted_packet ? reader.readBits(32) : undefined;\n const CRC32 = reader.readBits(32);\n\n const detail = {\n table_id,\n section_syntax_indicator,\n private_indicator,\n section_length,\n protocol_version,\n encrypted_packet,\n encryption_algorithm,\n pts_adjustment,\n cw_index,\n tier,\n splice_command_length,\n splice_command_type,\n splice_command,\n descriptor_loop_length,\n splice_descriptors,\n E_CRC32,\n CRC32\n };\n\n if (splice_command_type === SCTE35CommandType.kSpliceInsert) {\n const spliceInsert = splice_command as SpliceInsert;\n\n if (spliceInsert.splice_event_cancel_indicator) {\n return {\n splice_command_type,\n detail,\n data\n }\n } else if (spliceInsert.program_splice_flag && !spliceInsert.splice_immediate_flag) {\n const auto_return = spliceInsert.duration_flag ? spliceInsert.break_duration.auto_return : undefined;\n const duraiton = spliceInsert.duration_flag ? spliceInsert.break_duration.duration / 90 : undefined;\n\n if (spliceInsert.splice_time.time_specified_flag) {\n return {\n splice_command_type,\n pts: (pts_adjustment + spliceInsert.splice_time.pts_time) % (2 ** 33),\n auto_return,\n duraiton,\n detail,\n data\n }\n } else {\n return {\n splice_command_type,\n auto_return,\n duraiton,\n detail,\n data\n } \n }\n } else {\n const auto_return = spliceInsert.duration_flag ? spliceInsert.break_duration.auto_return : undefined;\n const duraiton = spliceInsert.duration_flag ? spliceInsert.break_duration.duration / 90 : undefined;\n\n return {\n splice_command_type,\n auto_return,\n duraiton,\n detail,\n data\n }\n }\n } else if (splice_command_type === SCTE35CommandType.kTimeSignal) {\n const timeSignal = splice_command as TimeSignal;\n\n if (timeSignal.splice_time.time_specified_flag) {\n return {\n splice_command_type,\n pts: (pts_adjustment + timeSignal.splice_time.pts_time) % (2 ** 33),\n detail,\n data\n }\n } else {\n return {\n splice_command_type,\n detail,\n data\n }\n }\n } else {\n return {\n splice_command_type,\n detail,\n data\n }\n }\n}","import Log from \"../utils/logger\";\nimport ExpGolomb from \"./exp-golomb\";\nimport { MPEG4AudioObjectTypes, MPEG4SamplingFrequencies, MPEG4SamplingFrequencyIndex } from \"./mpeg4-audio\";\n\nexport class AACFrame {\n audio_object_type: MPEG4AudioObjectTypes;\n sampling_freq_index: MPEG4SamplingFrequencyIndex;\n sampling_frequency: number;\n channel_config: number;\n\n data: Uint8Array;\n}\n\nexport class LOASAACFrame extends AACFrame {\n other_data_present: boolean;\n}\n\nexport class AACADTSParser {\n\n private readonly TAG: string = \"AACADTSParser\";\n\n private data_: Uint8Array;\n private current_syncword_offset_: number;\n private eof_flag_: boolean;\n private has_last_incomplete_data: boolean;\n\n public constructor(data: Uint8Array) {\n this.data_ = data;\n this.current_syncword_offset_ = this.findNextSyncwordOffset(0);\n if (this.eof_flag_) {\n Log.e(this.TAG, `Could not found ADTS syncword until payload end`);\n }\n }\n\n private findNextSyncwordOffset(syncword_offset: number): number {\n let i = syncword_offset;\n let data = this.data_;\n\n while (true) {\n if (i + 7 >= data.byteLength) {\n this.eof_flag_ = true;\n return data.byteLength;\n }\n\n // search 12-bit 0xFFF syncword\n let syncword = ((data[i + 0] << 8) | data[i + 1]) >>> 4;\n if (syncword === 0xFFF) {\n return i;\n } else {\n i++;\n }\n }\n }\n\n public readNextAACFrame(): AACFrame | null {\n let data = this.data_;\n let aac_frame: AACFrame = null;\n\n while (aac_frame == null) {\n if (this.eof_flag_) {\n break;\n }\n\n let syncword_offset = this.current_syncword_offset_;\n let offset = syncword_offset;\n\n // adts_fixed_header()\n // syncword 0xFFF: 12-bit\n let ID = (data[offset + 1] & 0x08) >>> 3;\n let layer = (data[offset + 1] & 0x06) >>> 1;\n let protection_absent = data[offset + 1] & 0x01;\n let profile = (data[offset + 2] & 0xC0) >>> 6;\n let sampling_frequency_index = (data[offset + 2] & 0x3C) >>> 2;\n let channel_configuration = ((data[offset + 2] & 0x01) << 2)\n | ((data[offset + 3] & 0xC0) >>> 6);\n\n // adts_variable_header()\n let aac_frame_length = ((data[offset + 3] & 0x03) << 11)\n | (data[offset + 4] << 3)\n | ((data[offset + 5] & 0xE0) >>> 5);\n let number_of_raw_data_blocks_in_frame = data[offset + 6] & 0x03;\n\n if (offset + aac_frame_length > this.data_.byteLength) {\n // data not enough for extracting last sample\n this.eof_flag_ = true;\n this.has_last_incomplete_data = true;\n break;\n }\n\n let adts_header_length = (protection_absent === 1) ? 7 : 9;\n let adts_frame_payload_length = aac_frame_length - adts_header_length;\n\n offset += adts_header_length;\n\n let next_syncword_offset = this.findNextSyncwordOffset(offset + adts_frame_payload_length);\n this.current_syncword_offset_ = next_syncword_offset;\n\n if ((ID !== 0 && ID !== 1) || layer !== 0) {\n // invalid adts frame ?\n continue;\n }\n\n let frame_data = data.subarray(offset, offset + adts_frame_payload_length);\n\n aac_frame = new AACFrame();\n aac_frame.audio_object_type = (profile + 1) as MPEG4AudioObjectTypes;\n aac_frame.sampling_freq_index = sampling_frequency_index as MPEG4SamplingFrequencyIndex;\n aac_frame.sampling_frequency = MPEG4SamplingFrequencies[sampling_frequency_index];\n aac_frame.channel_config = channel_configuration;\n aac_frame.data = frame_data;\n }\n\n return aac_frame;\n }\n\n public hasIncompleteData(): boolean {\n return this.has_last_incomplete_data;\n }\n\n public getIncompleteData(): Uint8Array {\n if (!this.has_last_incomplete_data) {\n return null;\n }\n\n return this.data_.subarray(this.current_syncword_offset_);\n }\n}\n\nexport class AACLOASParser {\n\n private readonly TAG: string = \"AACLOASParser\";\n\n private data_: Uint8Array;\n private current_syncword_offset_: number;\n private eof_flag_: boolean;\n private has_last_incomplete_data: boolean;\n\n public constructor(data: Uint8Array) {\n this.data_ = data;\n this.current_syncword_offset_ = this.findNextSyncwordOffset(0);\n if (this.eof_flag_) {\n Log.e(this.TAG, `Could not found LOAS syncword until payload end`);\n }\n }\n\n private findNextSyncwordOffset(syncword_offset: number): number {\n let i = syncword_offset;\n let data = this.data_;\n\n while (true) {\n if (i + 1 >= data.byteLength) {\n this.eof_flag_ = true;\n return data.byteLength;\n }\n\n // search 12-bit 0xFFF syncword\n let syncword = (data[i + 0] << 3) | (data[i + 1] >>> 5);\n if (syncword === 0x2B7) {\n return i;\n } else {\n i++;\n }\n }\n }\n\n private getLATMValue(gb: ExpGolomb) {\n let bytesForValue = gb.readBits(2);\n let value = 0;\n for (let i = 0; i <= bytesForValue; i++) {\n value = value << 8;\n value = value | gb.readByte();\n }\n return value;\n }\n\n public readNextAACFrame(privious?: LOASAACFrame): LOASAACFrame | null {\n let data = this.data_;\n let aac_frame: LOASAACFrame = null;\n\n while (aac_frame == null) {\n if (this.eof_flag_) {\n break;\n }\n\n let syncword_offset = this.current_syncword_offset_;\n let offset = syncword_offset;\n\n let audioMuxLengthBytes = ((data[offset + 1] & 0x1F) << 8) | data[offset + 2];\n if (offset + 3 + audioMuxLengthBytes >= this.data_.byteLength) {\n // data not enough for extracting last sample\n this.eof_flag_ = true;\n this.has_last_incomplete_data = true;\n break;\n }\n\n // AudioMuxElement(1)\n let gb = new ExpGolomb(data.subarray(offset + 3, offset + 3 + audioMuxLengthBytes));\n let useSameStreamMux = gb.readBool();\n let streamMuxConfig: LOASAACFrame | null = null;\n if (!useSameStreamMux) {\n let audioMuxVersion = gb.readBool();\n let audioMuxVersionA = audioMuxVersion && gb.readBool();\n if (audioMuxVersionA) {\n Log.e(this.TAG, 'audioMuxVersionA is Not Supported');\n gb.destroy();\n break;\n }\n if (audioMuxVersion) {\n this.getLATMValue(gb);\n }\n let allStreamsSameTimeFraming = gb.readBool();\n if (!allStreamsSameTimeFraming) {\n Log.e(this.TAG, 'allStreamsSameTimeFraming zero is Not Supported');\n gb.destroy();\n break;\n }\n let numSubFrames = gb.readBits(6);\n if (numSubFrames !== 0) {\n Log.e(this.TAG, 'more than 2 numSubFrames Not Supported');\n gb.destroy();\n break;\n }\n let numProgram = gb.readBits(4);\n if (numProgram !== 0) {\n Log.e(this.TAG, 'more than 2 numProgram Not Supported');\n gb.destroy();\n break;\n }\n let numLayer = gb.readBits(3);\n if (numLayer !== 0) {\n Log.e(this.TAG, 'more than 2 numLayer Not Supported');\n gb.destroy();\n break;\n }\n\n let fillBits = audioMuxVersion ? this.getLATMValue(gb) : 0;\n let audio_object_type = gb.readBits(5); fillBits -= 5;\n let sampling_freq_index = gb.readBits(4);fillBits -= 4;\n let channel_config = gb.readBits(4); fillBits -= 4;\n gb.readBits(3); fillBits -= 3; // GA Specfic Config\n if (fillBits > 0) { gb.readBits(fillBits); }\n\n let frameLengthType = gb.readBits(3);\n if (frameLengthType === 0) {\n gb.readByte();\n } else {\n Log.e(this.TAG, `frameLengthType = ${frameLengthType}. Only frameLengthType = 0 Supported`);\n gb.destroy();\n break;\n }\n\n let otherDataPresent = gb.readBool();\n if (otherDataPresent) {\n if (audioMuxVersion) {\n this.getLATMValue(gb);\n } else {\n let otherDataLenBits = 0;\n while (true) {\n otherDataLenBits = otherDataLenBits << 8;\n let otherDataLenEsc = gb.readBool();\n let otherDataLenTmp = gb.readByte();\n otherDataLenBits += otherDataLenTmp\n if (!otherDataLenEsc) { break; }\n }\n console.log(otherDataLenBits)\n }\n }\n\n let crcCheckPresent = gb.readBool();\n if (crcCheckPresent) {\n gb.readByte();\n }\n\n streamMuxConfig = new LOASAACFrame();\n streamMuxConfig.audio_object_type = audio_object_type;\n streamMuxConfig.sampling_freq_index = sampling_freq_index;\n streamMuxConfig.sampling_frequency = MPEG4SamplingFrequencies[streamMuxConfig.sampling_freq_index];\n streamMuxConfig.channel_config = channel_config;\n streamMuxConfig.other_data_present = otherDataPresent;\n } else if (privious == null) {\n Log.w(this.TAG, 'StreamMuxConfig Missing')\n this.current_syncword_offset_ = this.findNextSyncwordOffset(offset + 3 + audioMuxLengthBytes);\n gb.destroy();\n continue;\n } else {\n streamMuxConfig = privious;\n }\n\n let length = 0;\n while (true) {\n let tmp = gb.readByte();\n length += tmp;\n if (tmp !== 0xFF) { break; }\n }\n\n let aac_data = new Uint8Array(length);\n for (let i = 0; i < length; i++) {\n aac_data[i] = gb.readByte();\n }\n\n aac_frame = new LOASAACFrame();\n aac_frame.audio_object_type = (streamMuxConfig.audio_object_type) as MPEG4AudioObjectTypes;\n aac_frame.sampling_freq_index = (streamMuxConfig.sampling_freq_index) as MPEG4SamplingFrequencyIndex;\n aac_frame.sampling_frequency = MPEG4SamplingFrequencies[streamMuxConfig.sampling_freq_index];\n aac_frame.channel_config = streamMuxConfig.channel_config;\n aac_frame.other_data_present = streamMuxConfig.other_data_present;\n aac_frame.data = aac_data;\n\n this.current_syncword_offset_ = this.findNextSyncwordOffset(offset + 3 + audioMuxLengthBytes);\n }\n\n return aac_frame;\n }\n\n public hasIncompleteData(): boolean {\n return this.has_last_incomplete_data;\n }\n\n public getIncompleteData(): Uint8Array {\n if (!this.has_last_incomplete_data) {\n return null;\n }\n\n return this.data_.subarray(this.current_syncword_offset_);\n }\n}\n\nexport class AudioSpecificConfig {\n\n public config: Array;\n public sampling_rate: number;\n public channel_count: number;\n public codec_mimetype: string;\n public original_codec_mimetype: string;\n\n public constructor(frame: AACFrame) {\n let config: Array = null;\n\n let original_audio_object_type = frame.audio_object_type;\n let audio_object_type = frame.audio_object_type;\n let sampling_index = frame.sampling_freq_index;\n let channel_config = frame.channel_config;\n let extension_sampling_index = 0;\n\n let userAgent = navigator.userAgent.toLowerCase();\n\n if (userAgent.indexOf('firefox') !== -1) {\n // firefox: use SBR (HE-AAC) if freq less than 24kHz\n if (sampling_index >= 6) {\n audio_object_type = 5;\n config = new Array(4);\n extension_sampling_index = sampling_index - 3;\n } else { // use LC-AAC\n audio_object_type = 2;\n config = new Array(2);\n extension_sampling_index = sampling_index;\n }\n } else if (userAgent.indexOf('android') !== -1) {\n // android: always use LC-AAC\n audio_object_type = 2;\n config = new Array(2);\n extension_sampling_index = sampling_index;\n } else {\n // for other browsers, e.g. chrome...\n // Always use HE-AAC to make it easier to switch aac codec profile\n audio_object_type = 5;\n extension_sampling_index = sampling_index;\n config = new Array(4);\n\n if (sampling_index >= 6) {\n extension_sampling_index = sampling_index - 3;\n } else if (channel_config === 1) { // Mono channel\n audio_object_type = 2;\n config = new Array(2);\n extension_sampling_index = sampling_index;\n }\n }\n\n config[0] = audio_object_type << 3;\n config[0] |= (sampling_index & 0x0F) >>> 1;\n config[1] = (sampling_index & 0x0F) << 7;\n config[1] |= (channel_config & 0x0F) << 3;\n if (audio_object_type === 5) {\n config[1] |= ((extension_sampling_index & 0x0F) >>> 1);\n config[2] = (extension_sampling_index & 0x01) << 7;\n // extended audio object type: force to 2 (LC-AAC)\n config[2] |= (2 << 2);\n config[3] = 0;\n }\n\n this.config = config;\n this.sampling_rate = MPEG4SamplingFrequencies[sampling_index];\n this.channel_count = channel_config;\n this.codec_mimetype = 'mp4a.40.' + audio_object_type;\n this.original_codec_mimetype = 'mp4a.40.' + original_audio_object_type;\n }\n}\n","// ISO/IEC 13818-1 PES packets containing private data (stream_type=0x06)\nexport class PESPrivateData {\n pid: number;\n stream_id: number;\n pts?: number;\n dts?: number;\n nearest_pts?: number;\n data: Uint8Array;\n len: number;\n}\n\nexport class PESPrivateDataDescriptor {\n pid: number;\n stream_type: number;\n descriptor: Uint8Array;\n}\n","import Log from \"../utils/logger\";\n\nexport enum H265NaluType {\n kSliceIDR_W_RADL = 19,\n kSliceIDR_N_LP = 20,\n kSliceCRA_NUT = 21,\n kSliceVPS = 32,\n kSliceSPS = 33,\n kSlicePPS = 34,\n kSliceAUD = 35,\n}\n\nexport class H265NaluPayload {\n type: H265NaluType;\n data: Uint8Array;\n}\n\nexport class H265NaluHVC1 {\n type: H265NaluType;\n data: Uint8Array;\n\n constructor(nalu: H265NaluPayload) {\n let nalu_size = nalu.data.byteLength;\n\n this.type = nalu.type;\n this.data = new Uint8Array(4 + nalu_size); // 4 byte length-header + nalu payload\n\n let v = new DataView(this.data.buffer);\n // Fill 4 byte length-header\n v.setUint32(0, nalu_size);\n // Copy payload\n this.data.set(nalu.data, 4);\n }\n}\n\nexport class H265AnnexBParser {\n\n private readonly TAG: string = \"H265AnnexBParser\";\n\n private data_: Uint8Array;\n private current_startcode_offset_: number = 0;\n private eof_flag_: boolean = false;\n\n public constructor(data: Uint8Array) {\n this.data_ = data;\n this.current_startcode_offset_ = this.findNextStartCodeOffset(0);\n if (this.eof_flag_) {\n Log.e(this.TAG, \"Could not find H265 startcode until payload end!\");\n }\n }\n\n private findNextStartCodeOffset(start_offset: number) {\n let i = start_offset;\n let data = this.data_;\n\n while (true) {\n if (i + 3 >= data.byteLength) {\n this.eof_flag_ = true;\n return data.byteLength;\n }\n\n // search 00 00 00 01 or 00 00 01\n let uint32 = (data[i + 0] << 24)\n | (data[i + 1] << 16)\n | (data[i + 2] << 8)\n | (data[i + 3]);\n let uint24 = (data[i + 0] << 16)\n | (data[i + 1] << 8)\n | (data[i + 2]);\n if (uint32 === 0x00000001 || uint24 === 0x000001) {\n return i;\n } else {\n i++;\n }\n }\n }\n\n public readNextNaluPayload(): H265NaluPayload | null {\n let data = this.data_;\n let nalu_payload: H265NaluPayload = null;\n\n while (nalu_payload == null) {\n if (this.eof_flag_) {\n break;\n }\n // offset pointed to start code\n let startcode_offset = this.current_startcode_offset_;\n\n // nalu payload start offset\n let offset = startcode_offset;\n let u32 = (data[offset] << 24) | (data[offset + 1] << 16) | (data[offset + 2] << 8) | (data[offset + 3]);\n if (u32 === 0x00000001) {\n offset += 4;\n } else {\n offset += 3;\n }\n\n let nalu_type: H265NaluType = (data[offset] >> 1) & 0x3F;\n let forbidden_bit = (data[offset] & 0x80) >>> 7;\n\n let next_startcode_offset = this.findNextStartCodeOffset(offset);\n this.current_startcode_offset_ = next_startcode_offset;\n\n if (forbidden_bit !== 0) {\n // Log.e(this.TAG, `forbidden_bit near offset ${offset} should be 0 but has value ${forbidden_bit}`);\n continue;\n }\n\n let payload_data = data.subarray(offset, next_startcode_offset);\n\n nalu_payload = new H265NaluPayload();\n nalu_payload.type = nalu_type;\n nalu_payload.data = payload_data;\n }\n\n return nalu_payload;\n }\n\n}\n\nexport type HEVCDecoderConfigurationRecordType = {\n configurationVersion: 1;\n} & VPSHEVCDecoderConfigurationRecordType & SPSHEVCDecoderConfigurationRecordType & PPSHEVCDecoderConfigurationRecordType;\n\nexport type VPSHEVCDecoderConfigurationRecordType = {\n num_temporal_layers: number;\n temporal_id_nested: boolean;\n}\n\nexport type SPSHEVCDecoderConfigurationRecordType = {\n general_profile_space: number;\n general_tier_flag: number;\n general_level_idc: number;\n general_profile_idc: number;\n general_profile_compatibility_flags_1: number;\n general_profile_compatibility_flags_2: number;\n general_profile_compatibility_flags_3: number;\n general_profile_compatibility_flags_4: number;\n general_constraint_indicator_flags_1: number;\n general_constraint_indicator_flags_2: number;\n general_constraint_indicator_flags_3: number;\n general_constraint_indicator_flags_4: number;\n general_constraint_indicator_flags_5: number;\n general_constraint_indicator_flags_6: number;\n constant_frame_rate: number;\n min_spatial_segmentation_idc: number;\n chroma_format_idc: number,\n bit_depth_luma_minus8: number,\n bit_depth_chroma_minus8: number,\n}\n\nexport type PPSHEVCDecoderConfigurationRecordType = {\n parallelismType: number;\n}\n\nexport class HEVCDecoderConfigurationRecord {\n\n private data: Uint8Array;\n\n // sps, pps: require Nalu without 4 byte length-header\n public constructor(vps: Uint8Array, sps: Uint8Array, pps: Uint8Array, detail: HEVCDecoderConfigurationRecordType) {\n let length = 23 + (3 + 2 + vps.byteLength) + (3 + 2 + sps.byteLength) + (3 + 2 + pps.byteLength);\n let data = this.data = new Uint8Array(length);\n\n data[0] = 0x01; // configurationVersion\n data[1] = ((detail.general_profile_space & 0x03) << 6) | ((detail.general_tier_flag ? 1 : 0) << 5) | ((detail.general_profile_idc & 0x1F));\n data[2] = detail.general_profile_compatibility_flags_1;\n data[3] = detail.general_profile_compatibility_flags_2;\n data[4] = detail.general_profile_compatibility_flags_3;\n data[5] = detail.general_profile_compatibility_flags_4;\n data[6] = detail.general_constraint_indicator_flags_1;\n data[7] = detail.general_constraint_indicator_flags_2;\n data[8] = detail.general_constraint_indicator_flags_3;\n data[9] = detail.general_constraint_indicator_flags_4;\n data[10] = detail.general_constraint_indicator_flags_5;\n data[11] = detail.general_constraint_indicator_flags_6;\n data[12] = detail.general_level_idc;\n data[13] = 0xF0 | ((detail.min_spatial_segmentation_idc & 0x0F00) >> 8)\n data[14] = (detail.min_spatial_segmentation_idc & 0xFF);\n data[15] = 0xFC | (detail.parallelismType & 0x03);\n data[16] = 0xFC | (detail.chroma_format_idc & 0x03);\n data[17] = 0xF8 | (detail.bit_depth_luma_minus8 & 0x07);\n data[18] = 0xF8 | (detail.bit_depth_chroma_minus8 & 0x07);\n data[19] = 0;\n data[20] = 0;\n data[21] = ((detail.constant_frame_rate & 0x03) << 6) | ((detail.num_temporal_layers & 0x07) << 3) | ((detail.temporal_id_nested ? 1 : 0) << 2) | 3;\n data[22] = 3;\n data[23 + 0 + 0] = 0x80 | H265NaluType.kSliceVPS;\n data[23 + 0 + 1] = 0;\n data[23 + 0 + 2] = 1;\n data[23 + 0 + 3] = (vps.byteLength & 0xFF00) >> 8;\n data[23 + 0 + 4] = (vps.byteLength & 0x00FF) >> 0;\n data.set(vps, 23 + 0 + 5);\n data[23 + (5 + vps.byteLength) + 0] = 0x80 | H265NaluType.kSliceSPS;\n data[23 + (5 + vps.byteLength) + 1] = 0;\n data[23 + (5 + vps.byteLength) + 2] = 1;\n data[23 + (5 + vps.byteLength) + 3] = (sps.byteLength & 0xFF00) >> 8;\n data[23 + (5 + vps.byteLength) + 4] = (sps.byteLength & 0x00FF) >> 0;\n data.set(sps, 23 + (5 + vps.byteLength) + 5);\n data[23 + (5 + vps.byteLength + 5 + sps.byteLength) + 0] = 0x80 | H265NaluType.kSlicePPS;\n data[23 + (5 + vps.byteLength + 5 + sps.byteLength) + 1] = 0;\n data[23 + (5 + vps.byteLength + 5 + sps.byteLength) + 2] = 1;\n data[23 + (5 + vps.byteLength + 5 + sps.byteLength) + 3] = (pps.byteLength & 0xFF00) >> 8;\n data[23 + (5 + vps.byteLength + 5 + sps.byteLength) + 4] = (pps.byteLength & 0x00FF) >> 0;\n data.set(pps, 23 + (5 + vps.byteLength + 5 + sps.byteLength) + 5);\n }\n\n public getData() {\n return this.data;\n }\n\n}\n","import ExpGolomb from \"./exp-golomb\";\n\nexport class SMPTE2038Data {\n pid: number;\n stream_id: number;\n pts?: number;\n dts?: number;\n nearest_pts?: number;\n ancillaries: AncillaryData[];\n data: Uint8Array;\n len: number;\n}\n\ntype AncillaryData = {\n yc_indicator: boolean;\n line_number: number;\n horizontal_offset: number;\n did: number;\n sdid: number;\n user_data: Uint8Array;\n description: string;\n information: any;\n}\n\n\nexport const smpte2038parse = (data: Uint8Array) => {\n let gb = new ExpGolomb(data);\n let readBits = 0;\n\n let ancillaries: AncillaryData[] = [];\n while (true) {\n let zero = gb.readBits(6); readBits += 6;\n if (zero !== 0) { break; }\n let YC_indicator = gb.readBool(); readBits += 1;\n let line_number = gb.readBits(11); readBits += 11;\n let horizontal_offset = gb.readBits(12); readBits += 12;\n let data_ID = gb.readBits(10) & 0xFF; readBits += 10;\n let data_SDID = gb.readBits(10) & 0xFF; readBits += 10;\n let data_count = gb.readBits(10) & 0xFF; readBits += 10;\n let user_data = new Uint8Array(data_count);\n for (let i = 0; i < data_count; i++) {\n let user_data_word = gb.readBits(10) & 0xFF; readBits += 10;\n user_data[i] = user_data_word;\n }\n let checksum_word = gb.readBits(10); readBits += 10;\n\n let description = 'User Defined';\n let information: any = {};\n if (data_ID === 0x41) {\n if (data_SDID === 0x07) {\n description = 'SCTE-104'\n }\n } else if (data_ID === 0x5F) {\n if (data_SDID === 0xDC) {\n description = 'ARIB STD-B37 (1SEG)';\n } else if (data_SDID === 0xDD) {\n description = 'ARIB STD-B37 (ANALOG)';\n } else if (data_SDID === 0xDE) {\n description = 'ARIB STD-B37 (SD)';\n } else if (data_SDID === 0xDF) {\n description = 'ARIB STD-B37 (HD)';\n }\n } else if (data_ID === 0x61) {\n if (data_SDID === 0x01) {\n description = 'EIA-708';\n } else if (data_SDID === 0x02) {\n description = 'EIA-608';\n }\n }\n\n ancillaries.push({\n yc_indicator: YC_indicator,\n line_number,\n horizontal_offset,\n did: data_ID,\n sdid: data_SDID,\n user_data,\n description,\n information\n });\n gb.readBits(8 - (readBits - Math.floor(readBits / 8)) % 8);\n readBits += (8 - (readBits - Math.floor(readBits / 8))) % 8;\n }\n\n gb.destroy();\n gb = null;\n\n return ancillaries;\n}","export class MP3Data {\n object_type: number;\n sample_rate: number;\n channel_count: number;\n\n data: Uint8Array;\n}\n","import Log from \"../utils/logger\";\nimport ExpGolomb from \"./exp-golomb\";\nimport { MPEG4AudioObjectTypes, MPEG4SamplingFrequencies, MPEG4SamplingFrequencyIndex } from \"./mpeg4-audio\";\n\nexport class AC3Frame {\n sampling_frequency: number;\n sampling_rate_code: number;\n bit_stream_identification: number;\n bit_stream_mode: number;\n low_frequency_effects_channel_on: number;\n frame_size_code: number;\n channel_count: number;\n channel_mode: number;\n\n data: Uint8Array;\n}\n\nconst frame_size_code_table = [\n [\n 64, 64, 80, 80, 96, 96, 112, 112, 128, 128,\n 160, 160, 192, 192, 224, 224, 256, 256, 320, 320,\n 384, 384, 448, 448, 512, 512, 640, 640, 768, 768,\n 896, 896, 1024, 1024, 1152, 1152, 1280, 1280,\n ],\n [\n 69, 70, 87, 88, 104, 105, 121, 122, 139, 140,\n 174, 175, 208, 209, 243, 244, 278, 279, 348, 349,\n 417, 418, 487, 488, 557, 558, 696, 697, 835, 836,\n 975, 976, 1114, 1115, 1253, 1254, 1393, 1394\n ],\n [\n 96, 96, 120, 120, 144, 144, 168, 168, 192, 192,\n 240, 240, 288, 288, 336, 336, 384, 384, 480, 480,\n 576, 576, 672, 672, 768, 768, 960, 960, 1152, 1152,\n 1344, 1344, 1536, 1536, 1728, 1728, 1920, 1920,\n ],\n]\n\nexport class AC3Parser {\n\n private readonly TAG: string = \"AC3Parser\";\n\n private data_: Uint8Array;\n private current_syncword_offset_: number;\n private eof_flag_: boolean;\n private has_last_incomplete_data: boolean;\n\n public constructor(data: Uint8Array) {\n this.data_ = data;\n this.current_syncword_offset_ = this.findNextSyncwordOffset(0);\n if (this.eof_flag_) {\n Log.e(this.TAG, `Could not found AC3 syncword until payload end`);\n }\n }\n\n private findNextSyncwordOffset(syncword_offset: number): number {\n let i = syncword_offset;\n let data = this.data_;\n\n while (true) {\n if (i + 7 >= data.byteLength) {\n this.eof_flag_ = true;\n return data.byteLength;\n }\n\n // search 16-bit 0x0B77 syncword\n let syncword = (data[i + 0] << 8) | (data[i + 1] << 0)\n if (syncword === 0x0B77) {\n return i;\n } else {\n i++;\n }\n }\n }\n\n public readNextAC3Frame(): AC3Frame | null {\n let data = this.data_;\n let ac3_frame: AC3Frame = null;\n\n while (ac3_frame == null) {\n if (this.eof_flag_) {\n break;\n }\n\n let syncword_offset = this.current_syncword_offset_;\n let offset = syncword_offset;\n\n let sampling_rate_code = data[offset + 4] >> 6;\n let sampling_frequency = [48000, 44200, 33000][sampling_rate_code];\n\n let frame_size_code = data[offset + 4] & 0x3F;\n let frame_size = frame_size_code_table[sampling_rate_code][frame_size_code] * 2;\n\n if (offset + frame_size > this.data_.byteLength) {\n // data not enough for extracting last sample\n this.eof_flag_ = true;\n this.has_last_incomplete_data = true;\n break;\n }\n\n let next_syncword_offset = this.findNextSyncwordOffset(offset + frame_size);\n this.current_syncword_offset_ = next_syncword_offset;\n\n let bit_stream_identification = data[offset + 5] >> 3;\n let bit_stream_mode = data[offset + 5] & 0x07;\n\n let channel_mode = data[offset + 6] >> 5;\n\n let lfe_skip = 0;\n if ((channel_mode & 0x01) !== 0 && channel_mode !== 1) { lfe_skip += 2; }\n if ((channel_mode & 0x04) !== 0) { lfe_skip += 2; }\n if (channel_mode === 0x02) { lfe_skip += 2; }\n\n let low_frequency_effects_channel_on = (((data[offset + 6] << 8) | (data[offset + 7] << 0)) >> (12 - lfe_skip)) & 0x01;\n\n let channel_count = [2, 1, 2, 3, 3, 4, 4, 5][channel_mode] + low_frequency_effects_channel_on;\n\n ac3_frame = new AC3Frame();\n ac3_frame.sampling_frequency = sampling_frequency;\n ac3_frame.channel_count = channel_count;\n ac3_frame.channel_mode = channel_mode;\n ac3_frame.bit_stream_identification = bit_stream_identification;\n ac3_frame.low_frequency_effects_channel_on = low_frequency_effects_channel_on;\n ac3_frame.bit_stream_mode = bit_stream_mode;\n ac3_frame.frame_size_code = frame_size_code;\n ac3_frame.data = data.subarray(offset, offset + frame_size);\n }\n\n return ac3_frame;\n }\n\n public hasIncompleteData(): boolean {\n return this.has_last_incomplete_data;\n }\n\n public getIncompleteData(): Uint8Array {\n if (!this.has_last_incomplete_data) {\n return null;\n }\n\n return this.data_.subarray(this.current_syncword_offset_);\n }\n}\n\n\nexport class AC3Config {\n\n public config: Array;\n public sampling_rate: number;\n public bit_stream_identification: number;\n public bit_stream_mode: number;\n public low_frequency_effects_channel_on: number;\n public channel_count: number;\n public channel_mode: number;\n public codec_mimetype: string;\n public original_codec_mimetype: string;\n\n public constructor(frame: AC3Frame) {\n let config: Array = null;\n\n config = [\n (frame.sampling_rate_code << 6) | (frame.bit_stream_identification << 1) | (frame.bit_stream_mode >> 2),\n ((frame.bit_stream_mode & 0x03) << 6) | (frame.channel_mode << 3) | (frame.low_frequency_effects_channel_on << 2) | (frame.frame_size_code >> 4),\n (frame.frame_size_code << 4) & 0xE0,\n ]\n\n this.config = config;\n this.sampling_rate = frame.sampling_frequency;\n this.bit_stream_identification = frame.bit_stream_identification;\n this.bit_stream_mode = frame.bit_stream_mode;\n this.low_frequency_effects_channel_on = frame.low_frequency_effects_channel_on;\n this.channel_count = frame.channel_count;\n this.channel_mode = frame.channel_mode;\n this.codec_mimetype = 'ac-3';\n this.original_codec_mimetype = 'ac-3';\n }\n}\n","/*\n * Copyright (C) 2021 magicxqq. All Rights Reserved.\n *\n * @author magicxqq \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger';\nimport DemuxErrors from './demux-errors';\nimport MediaInfo from '../core/media-info';\nimport {IllegalStateException} from '../utils/exception';\nimport BaseDemuxer from './base-demuxer';\nimport { PAT, PESData, SectionData, SliceQueue, PIDToSliceQueues, PMT, ProgramToPMTMap, StreamType } from './pat-pmt-pes';\nimport { AVCDecoderConfigurationRecord, H264AnnexBParser, H264NaluAVC1, H264NaluPayload, H264NaluType } from './h264';\nimport SPSParser from './sps-parser';\nimport { AACADTSParser, AACFrame, AACLOASParser, AudioSpecificConfig, LOASAACFrame } from './aac';\nimport { MPEG4AudioObjectTypes, MPEG4SamplingFrequencyIndex } from './mpeg4-audio';\nimport { PESPrivateData, PESPrivateDataDescriptor } from './pes-private-data';\nimport { readSCTE35, SCTE35Data } from './scte35';\nimport { H265AnnexBParser, H265NaluHVC1, H265NaluPayload, H265NaluType, HEVCDecoderConfigurationRecord } from './h265';\nimport H265Parser from './h265-parser';\nimport { SMPTE2038Data, smpte2038parse } from './smpte2038';\nimport { MP3Data } from './mp3';\nimport { AC3Config, AC3Frame, AC3Parser } from './ac3';\n\ntype AACAudioMetadata = {\n codec: 'aac',\n audio_object_type: MPEG4AudioObjectTypes;\n sampling_freq_index: MPEG4SamplingFrequencyIndex;\n sampling_frequency: number;\n channel_config: number;\n};\ntype AC3AudioMetadata = {\n codec: 'ac-3',\n sampling_frequency: number;\n bit_stream_identification: number;\n bit_stream_mode: number;\n low_frequency_effects_channel_on: number;\n channel_mode: number;\n};\ntype OpusAudioMetadata = {\n codec: 'opus';\n channel_count: number;\n channel_config_code: number;\n sample_rate: number;\n}\ntype MP3AudioMetadata = {\n codec: 'mp3',\n object_type: number,\n sample_rate: number,\n channel_count: number;\n};\ntype AudioData = {\n codec: 'aac';\n data: AACFrame;\n} | {\n codec: 'ac-3';\n data: AC3Frame,\n} | {\n codec: 'opus';\n meta: OpusAudioMetadata,\n} | {\n codec: 'mp3';\n data: MP3Data;\n}\n\nclass TSDemuxer extends BaseDemuxer {\n\n private readonly TAG: string = 'TSDemuxer';\n\n private config_: any;\n private ts_packet_size_: number;\n private sync_offset_: number;\n private first_parse_: boolean = true;\n\n private media_info_ = new MediaInfo();\n\n private timescale_ = 90;\n private duration_ = 0;\n\n private pat_: PAT;\n private current_program_: number;\n private current_pmt_pid_: number = -1;\n private pmt_: PMT;\n private program_pmt_map_: ProgramToPMTMap = {};\n\n private pes_slice_queues_: PIDToSliceQueues = {};\n private section_slice_queues_: PIDToSliceQueues = {};\n\n private video_metadata_: {\n vps: H265NaluHVC1 | undefined,\n sps: H264NaluAVC1 | H265NaluHVC1 | undefined,\n pps: H264NaluAVC1 | H265NaluHVC1 | undefined,\n details: any\n } = {\n vps: undefined,\n sps: undefined,\n pps: undefined,\n details: undefined\n };\n\n private audio_metadata_: AACAudioMetadata | AC3AudioMetadata | OpusAudioMetadata | MP3AudioMetadata = {\n codec: undefined,\n audio_object_type: undefined,\n sampling_freq_index: undefined,\n sampling_frequency: undefined,\n channel_config: undefined\n };\n\n private aac_last_sample_pts_: number = undefined;\n private aac_last_incomplete_data_: Uint8Array = null;\n\n private has_video_ = false;\n private has_audio_ = false;\n private video_init_segment_dispatched_ = false;\n private audio_init_segment_dispatched_ = false;\n private video_metadata_changed_ = false;\n private audio_metadata_changed_ = false;\n private loas_previous_frame: LOASAACFrame | null = null;\n\n private video_track_ = {type: 'video', id: 1, sequenceNumber: 0, samples: [], length: 0};\n private audio_track_ = {type: 'audio', id: 2, sequenceNumber: 0, samples: [], length: 0};\n\n public constructor(probe_data: any, config: any) {\n super();\n\n this.ts_packet_size_ = probe_data.ts_packet_size;\n this.sync_offset_ = probe_data.sync_offset;\n this.config_ = config;\n }\n\n public destroy() {\n this.media_info_ = null;\n this.pes_slice_queues_ = null;\n this.section_slice_queues_ = null;\n\n this.video_metadata_ = null;\n this.audio_metadata_ = null;\n this.aac_last_incomplete_data_ = null;\n\n this.video_track_ = null;\n this.audio_track_ = null;\n\n super.destroy();\n }\n\n public static probe(buffer: ArrayBuffer) {\n let data = new Uint8Array(buffer);\n let sync_offset = -1;\n let ts_packet_size = 188;\n\n if (data.byteLength <= 3 * ts_packet_size) {\n return {needMoreData: true};\n }\n\n while (sync_offset === -1) {\n let scan_window = Math.min(1000, data.byteLength - 3 * ts_packet_size);\n\n for (let i = 0; i < scan_window; ) {\n // sync_byte should all be 0x47\n if (data[i] === 0x47\n && data[i + ts_packet_size] === 0x47\n && data[i + 2 * ts_packet_size] === 0x47) {\n sync_offset = i;\n break;\n } else {\n i++;\n }\n }\n\n // find sync_offset failed in previous ts_packet_size\n if (sync_offset === -1) {\n if (ts_packet_size === 188) {\n // try 192 packet size (BDAV, etc.)\n ts_packet_size = 192;\n } else if (ts_packet_size === 192) {\n // try 204 packet size (European DVB, etc.)\n ts_packet_size = 204;\n } else {\n // 192, 204 also failed, exit\n break;\n }\n }\n }\n\n if (sync_offset === -1) {\n // both 188, 192, 204 failed, Non MPEG-TS\n return {match: false};\n }\n\n if (ts_packet_size === 192 && sync_offset >= 4) {\n Log.v('TSDemuxer', `ts_packet_size = 192, m2ts mode`);\n sync_offset -= 4;\n } else if (ts_packet_size === 204) {\n Log.v('TSDemuxer', `ts_packet_size = 204, RS encoded MPEG2-TS stream`);\n }\n\n return {\n match: true,\n consumed: 0,\n ts_packet_size,\n sync_offset\n };\n }\n\n public bindDataSource(loader) {\n loader.onDataArrival = this.parseChunks.bind(this);\n return this;\n }\n\n public resetMediaInfo() {\n this.media_info_ = new MediaInfo();\n }\n\n public parseChunks(chunk: ArrayBuffer, byte_start: number): number {\n if (!this.onError\n || !this.onMediaInfo\n || !this.onTrackMetadata\n || !this.onDataAvailable) {\n throw new IllegalStateException('onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified');\n }\n\n let offset = 0;\n\n if (this.first_parse_) {\n this.first_parse_ = false;\n offset = this.sync_offset_;\n }\n\n while (offset + this.ts_packet_size_ <= chunk.byteLength) {\n let file_position = byte_start + offset;\n\n if (this.ts_packet_size_ === 192) {\n // skip ATS field (2-bits copy-control + 30-bits timestamp) for m2ts\n offset += 4;\n }\n\n let data = new Uint8Array(chunk, offset, 188);\n\n let sync_byte = data[0];\n if (sync_byte !== 0x47) {\n Log.e(this.TAG, `sync_byte = ${sync_byte}, not 0x47`);\n break;\n }\n\n let payload_unit_start_indicator = (data[1] & 0x40) >>> 6;\n let transport_priority = (data[1] & 0x20) >>> 5;\n let pid = ((data[1] & 0x1F) << 8) | data[2];\n let adaptation_field_control = (data[3] & 0x30) >>> 4;\n let continuity_conunter = (data[3] & 0x0F);\n\n let adaptation_field_info: {\n discontinuity_indicator?: number,\n random_access_indicator?: number,\n elementary_stream_priority_indicator?: number\n } = {};\n let ts_payload_start_index = 4;\n\n if (adaptation_field_control == 0x02 || adaptation_field_control == 0x03) {\n let adaptation_field_length = data[4];\n if (5 + adaptation_field_length === 188) {\n // TS packet only has adaption field, jump to next\n offset += 188;\n if (this.ts_packet_size_ === 204) {\n // skip parity word (16 bytes) for RS encoded TS\n offset += 16;\n }\n continue;\n } else {\n // parse leading adaptation_field if has payload\n if (adaptation_field_length > 0) {\n adaptation_field_info = this.parseAdaptationField(chunk,\n offset + 4,\n 1 + adaptation_field_length);\n }\n ts_payload_start_index = 4 + 1 + adaptation_field_length;\n }\n }\n\n if (adaptation_field_control == 0x01 || adaptation_field_control == 0x03) {\n if (pid === 0 || pid === this.current_pmt_pid_ || (this.pmt_ != undefined && this.pmt_.pid_stream_type[pid] === StreamType.kSCTE35)) { // PAT(pid === 0) or PMT or SCTE35\n let ts_payload_length = 188 - ts_payload_start_index;\n\n this.handleSectionSlice(chunk,\n offset + ts_payload_start_index,\n ts_payload_length,\n {\n pid,\n file_position,\n payload_unit_start_indicator,\n continuity_conunter,\n random_access_indicator: adaptation_field_info.random_access_indicator\n });\n } else if (this.pmt_ != undefined && this.pmt_.pid_stream_type[pid] != undefined) {\n // PES\n let ts_payload_length = 188 - ts_payload_start_index;\n let stream_type = this.pmt_.pid_stream_type[pid];\n\n // process PES only for known common_pids\n if (pid === this.pmt_.common_pids.h264\n || pid === this.pmt_.common_pids.h265\n || pid === this.pmt_.common_pids.adts_aac\n || pid === this.pmt_.common_pids.loas_aac\n || pid === this.pmt_.common_pids.ac3\n || pid === this.pmt_.common_pids.opus\n || pid === this.pmt_.common_pids.mp3\n || this.pmt_.pes_private_data_pids[pid] === true\n || this.pmt_.timed_id3_pids[pid] === true) {\n this.handlePESSlice(chunk,\n offset + ts_payload_start_index,\n ts_payload_length,\n {\n pid,\n stream_type,\n file_position,\n payload_unit_start_indicator,\n continuity_conunter,\n random_access_indicator: adaptation_field_info.random_access_indicator\n });\n }\n }\n }\n\n offset += 188;\n\n if (this.ts_packet_size_ === 204) {\n // skip parity word (16 bytes) for RS encoded TS\n offset += 16;\n }\n }\n\n // dispatch parsed frames to the remuxer (consumer)\n this.dispatchAudioVideoMediaSegment();\n\n return offset; // consumed bytes\n }\n\n private parseAdaptationField(buffer: ArrayBuffer, offset: number, length: number): {\n discontinuity_indicator?: number,\n random_access_indicator?: number,\n elementary_stream_priority_indicator?: number\n } {\n let data = new Uint8Array(buffer, offset, length);\n\n let adaptation_field_length = data[0];\n if (adaptation_field_length > 0) {\n if (adaptation_field_length > 183) {\n Log.w(this.TAG, `Illegal adaptation_field_length: ${adaptation_field_length}`);\n return {};\n }\n\n let discontinuity_indicator: number = (data[1] & 0x80) >>> 7;\n let random_access_indicator: number = (data[1] & 0x40) >>> 6;\n let elementary_stream_priority_indicator: number = (data[1] & 0x20) >>> 5;\n\n return {\n discontinuity_indicator,\n random_access_indicator,\n elementary_stream_priority_indicator\n };\n }\n\n return {};\n }\n\n private handleSectionSlice(buffer: ArrayBuffer, offset: number, length: number, misc: any): void {\n let data = new Uint8Array(buffer, offset, length);\n let slice_queue = this.section_slice_queues_[misc.pid];\n\n if (misc.payload_unit_start_indicator) {\n let pointer_field = data[0];\n\n if (slice_queue != undefined && slice_queue.total_length !== 0) {\n let remain_section = new Uint8Array(buffer, offset + 1, Math.min(length, pointer_field));\n slice_queue.slices.push(remain_section);\n slice_queue.total_length += remain_section.byteLength;\n\n if (slice_queue.total_length === slice_queue.expected_length) {\n this.emitSectionSlices(slice_queue, misc);\n } else {\n this.clearSlices(slice_queue, misc);\n }\n }\n\n for (let i = 1 + pointer_field; i < data.byteLength; ){\n let table_id = data[i + 0];\n if (table_id === 0xFF) { break; }\n\n let section_length = ((data[i + 1] & 0x0F) << 8) | data[i + 2];\n\n this.section_slice_queues_[misc.pid] = new SliceQueue();\n slice_queue = this.section_slice_queues_[misc.pid];\n\n slice_queue.expected_length = section_length + 3;\n slice_queue.file_position = misc.file_position;\n slice_queue.random_access_indicator = misc.random_access_indicator;\n\n let remain_section = new Uint8Array(buffer, offset + i, Math.min(length - i, slice_queue.expected_length - slice_queue.total_length));\n slice_queue.slices.push(remain_section);\n slice_queue.total_length += remain_section.byteLength;\n\n if (slice_queue.total_length === slice_queue.expected_length) {\n this.emitSectionSlices(slice_queue, misc);\n } else if (slice_queue.total_length >= slice_queue.expected_length) {\n this.clearSlices(slice_queue, misc);\n }\n\n i += remain_section.byteLength;\n }\n } else if (slice_queue != undefined && slice_queue.total_length !== 0) {\n let remain_section = new Uint8Array(buffer, offset, Math.min(length, slice_queue.expected_length - slice_queue.total_length));\n slice_queue.slices.push(remain_section);\n slice_queue.total_length += remain_section.byteLength;\n\n if (slice_queue.total_length === slice_queue.expected_length) {\n this.emitSectionSlices(slice_queue, misc);\n } else if (slice_queue.total_length >= slice_queue.expected_length) {\n this.clearSlices(slice_queue, misc);\n }\n }\n }\n\n private handlePESSlice(buffer: ArrayBuffer, offset: number, length: number, misc: any): void {\n let data = new Uint8Array(buffer, offset, length);\n\n let packet_start_code_prefix = (data[0] << 16) | (data[1] << 8) | (data[2]);\n let stream_id = data[3];\n let PES_packet_length = (data[4] << 8) | data[5];\n\n if (misc.payload_unit_start_indicator) {\n if (packet_start_code_prefix !== 1) {\n Log.e(this.TAG, `handlePESSlice: packet_start_code_prefix should be 1 but with value ${packet_start_code_prefix}`);\n return;\n }\n\n // handle queued PES slices:\n // Merge into a big Uint8Array then call parsePES()\n let slice_queue = this.pes_slice_queues_[misc.pid];\n if (slice_queue) {\n if (slice_queue.expected_length === 0 || slice_queue.expected_length === slice_queue.total_length) {\n this.emitPESSlices(slice_queue, misc);\n } else {\n this.clearSlices(slice_queue, misc);\n }\n }\n\n // Make a new PES queue for new PES slices\n this.pes_slice_queues_[misc.pid] = new SliceQueue();\n this.pes_slice_queues_[misc.pid].file_position = misc.file_position;\n this.pes_slice_queues_[misc.pid].random_access_indicator = misc.random_access_indicator;\n }\n\n if (this.pes_slice_queues_[misc.pid] == undefined) {\n // ignore PES slices without [PES slice that has payload_unit_start_indicator]\n return;\n }\n\n // push subsequent PES slices into pes_queue\n let slice_queue = this.pes_slice_queues_[misc.pid];\n slice_queue.slices.push(data);\n if (misc.payload_unit_start_indicator) {\n slice_queue.expected_length = PES_packet_length === 0 ? 0 : PES_packet_length + 6;\n }\n slice_queue.total_length += data.byteLength;\n\n if (slice_queue.expected_length > 0 && slice_queue.expected_length === slice_queue.total_length) {\n this.emitPESSlices(slice_queue, misc);\n } else if (slice_queue.expected_length > 0 && slice_queue.expected_length < slice_queue.total_length) {\n this.clearSlices(slice_queue, misc);\n }\n }\n\n private emitSectionSlices(slice_queue: SliceQueue, misc: any): void {\n let data = new Uint8Array(slice_queue.total_length);\n for (let i = 0, offset = 0; i < slice_queue.slices.length; i++) {\n let slice = slice_queue.slices[i];\n data.set(slice, offset);\n offset += slice.byteLength;\n }\n slice_queue.slices = [];\n slice_queue.expected_length = -1;\n slice_queue.total_length = 0;\n\n let section_data = new SectionData();\n section_data.pid = misc.pid;\n section_data.data = data;\n section_data.file_position = slice_queue.file_position;\n section_data.random_access_indicator = slice_queue.random_access_indicator;\n this.parseSection(section_data);\n }\n\n private emitPESSlices(slice_queue: SliceQueue, misc: any): void {\n let data = new Uint8Array(slice_queue.total_length);\n for (let i = 0, offset = 0; i < slice_queue.slices.length; i++) {\n let slice = slice_queue.slices[i];\n data.set(slice, offset);\n offset += slice.byteLength;\n }\n slice_queue.slices = [];\n slice_queue.expected_length = -1;\n slice_queue.total_length = 0;\n\n let pes_data = new PESData();\n pes_data.pid = misc.pid;\n pes_data.data = data;\n pes_data.stream_type = misc.stream_type;\n pes_data.file_position = slice_queue.file_position;\n pes_data.random_access_indicator = slice_queue.random_access_indicator;\n this.parsePES(pes_data);\n }\n\n private clearSlices(slice_queue: SliceQueue, misc: any): void {\n slice_queue.slices = [];\n slice_queue.expected_length = -1;\n slice_queue.total_length = 0;\n }\n\n private parseSection(section_data: SectionData): void {\n let data = section_data.data;\n let pid = section_data.pid;\n\n if (pid === 0x00) {\n this.parsePAT(data);\n } else if (pid === this.current_pmt_pid_) {\n this.parsePMT(data);\n } else if (this.pmt_ != undefined && this.pmt_.scte_35_pids[pid]) {\n this.parseSCTE35(data);\n }\n }\n\n private parsePES(pes_data: PESData): void {\n let data = pes_data.data;\n let packet_start_code_prefix = (data[0] << 16) | (data[1] << 8) | (data[2]);\n let stream_id = data[3];\n let PES_packet_length = (data[4] << 8) | data[5];\n\n if (packet_start_code_prefix !== 1) {\n Log.e(this.TAG, `parsePES: packet_start_code_prefix should be 1 but with value ${packet_start_code_prefix}`);\n return;\n }\n\n if (stream_id !== 0xBC // program_stream_map\n && stream_id !== 0xBE // padding_stream\n && stream_id !== 0xBF // private_stream_2\n && stream_id !== 0xF0 // ECM\n && stream_id !== 0xF1 // EMM\n && stream_id !== 0xFF // program_stream_directory\n && stream_id !== 0xF2 // DSMCC\n && stream_id !== 0xF8) {\n let PES_scrambling_control = (data[6] & 0x30) >>> 4;\n let PTS_DTS_flags = (data[7] & 0xC0) >>> 6;\n let PES_header_data_length = data[8];\n\n let pts: number | undefined;\n let dts: number | undefined;\n\n if (PTS_DTS_flags === 0x02 || PTS_DTS_flags === 0x03) {\n pts = (data[9] & 0x0E) * 536870912 + // 1 << 29\n (data[10] & 0xFF) * 4194304 + // 1 << 22\n (data[11] & 0xFE) * 16384 + // 1 << 14\n (data[12] & 0xFF) * 128 + // 1 << 7\n (data[13] & 0xFE) / 2;\n\n if (PTS_DTS_flags === 0x03) {\n dts = (data[14] & 0x0E) * 536870912 + // 1 << 29\n (data[15] & 0xFF) * 4194304 + // 1 << 22\n (data[16] & 0xFE) * 16384 + // 1 << 14\n (data[17] & 0xFF) * 128 + // 1 << 7\n (data[18] & 0xFE) / 2;\n } else {\n dts = pts;\n }\n }\n\n let payload_start_index = 6 + 3 + PES_header_data_length;\n let payload_length: number;\n\n if (PES_packet_length !== 0) {\n if (PES_packet_length < 3 + PES_header_data_length) {\n Log.v(this.TAG, `Malformed PES: PES_packet_length < 3 + PES_header_data_length`);\n return;\n }\n payload_length = PES_packet_length - 3 - PES_header_data_length;\n } else { // PES_packet_length === 0\n payload_length = data.byteLength - payload_start_index;\n }\n\n let payload = data.subarray(payload_start_index, payload_start_index + payload_length);\n\n switch (pes_data.stream_type) {\n case StreamType.kMPEG1Audio:\n case StreamType.kMPEG2Audio:\n this.parseMP3Payload(payload, pts);\n break;\n case StreamType.kPESPrivateData:\n if (this.pmt_.common_pids.opus === pes_data.pid) {\n this.parseOpusPayload(payload, pts);\n } else if (this.pmt_.common_pids.ac3 === pes_data.pid) {\n this.parseAC3Payload(payload, pts);\n } else if (this.pmt_.smpte2038_pids[pes_data.pid]) {\n this.parseSMPTE2038MetadataPayload(payload, pts, dts, pes_data.pid, stream_id);\n } else {\n this.parsePESPrivateDataPayload(payload, pts, dts, pes_data.pid, stream_id);\n }\n break;\n case StreamType.kADTSAAC:\n this.parseADTSAACPayload(payload, pts);\n break;\n case StreamType.kLOASAAC:\n this.parseLOASAACPayload(payload, pts);\n break;\n case StreamType.kAC3:\n this.parseAC3Payload(payload, pts);\n break;\n case StreamType.kID3:\n this.parseTimedID3MetadataPayload(payload, pts, dts, pes_data.pid, stream_id);\n break;\n case StreamType.kH264:\n this.parseH264Payload(payload, pts, dts, pes_data.file_position, pes_data.random_access_indicator);\n break;\n case StreamType.kH265:\n this.parseH265Payload(payload, pts, dts, pes_data.file_position, pes_data.random_access_indicator);\n break;\n default:\n break;\n }\n } else if (stream_id === 0xBC // program_stream_map\n || stream_id === 0xBF // private_stream_2\n || stream_id === 0xF0 // ECM\n || stream_id === 0xF1 // EMM\n || stream_id === 0xFF // program_stream_directory\n || stream_id === 0xF2 // DSMCC_stream\n || stream_id === 0xF8) { // ITU-T Rec. H.222.1 type E stream\n if (pes_data.stream_type === StreamType.kPESPrivateData) {\n let payload_start_index = 6;\n let payload_length: number;\n\n if (PES_packet_length !== 0) {\n payload_length = PES_packet_length;\n } else { // PES_packet_length === 0\n payload_length = data.byteLength - payload_start_index;\n }\n\n let payload = data.subarray(payload_start_index, payload_start_index + payload_length);\n this.parsePESPrivateDataPayload(payload, undefined, undefined, pes_data.pid, stream_id);\n }\n }\n }\n\n private parsePAT(data: Uint8Array): void {\n let table_id = data[0];\n if (table_id !== 0x00) {\n Log.e(this.TAG, `parsePAT: table_id ${table_id} is not corresponded to PAT!`);\n return;\n }\n\n let section_length = ((data[1] & 0x0F) << 8) | data[2];\n\n let transport_stream_id = (data[3] << 8) | data[4];\n let version_number = (data[5] & 0x3E) >>> 1;\n let current_next_indicator = data[5] & 0x01;\n let section_number = data[6];\n let last_section_number = data[7];\n\n let pat: PAT = null;\n\n if (current_next_indicator === 1 && section_number === 0) {\n pat = new PAT();\n pat.version_number = version_number;\n } else {\n pat = this.pat_;\n if (pat == undefined) {\n return;\n }\n }\n\n let program_start_index = 8;\n let program_bytes = section_length - 5 - 4; // section_length - (headers + crc)\n let first_program_number = -1;\n let first_pmt_pid = -1;\n\n for (let i = program_start_index; i < program_start_index + program_bytes; i += 4) {\n let program_number = (data[i] << 8) | data[i + 1];\n let pid = ((data[i + 2] & 0x1F) << 8) | data[i + 3];\n\n if (program_number === 0) {\n // network_PID\n pat.network_pid = pid;\n } else {\n // program_map_PID\n pat.program_pmt_pid[program_number] = pid;\n\n if (first_program_number === -1) {\n first_program_number = program_number;\n }\n\n if (first_pmt_pid === -1) {\n first_pmt_pid = pid;\n }\n }\n }\n\n // Currently we only deal with first appeared PMT pid\n if (current_next_indicator === 1 && section_number === 0) {\n if (this.pat_ == undefined) {\n Log.v(this.TAG, `Parsed first PAT: ${JSON.stringify(pat)}`);\n }\n this.pat_ = pat;\n this.current_program_ = first_program_number;\n this.current_pmt_pid_ = first_pmt_pid;\n }\n }\n\n private parsePMT(data: Uint8Array): void {\n let table_id = data[0];\n if (table_id !== 0x02) {\n Log.e(this.TAG, `parsePMT: table_id ${table_id} is not corresponded to PMT!`);\n return;\n }\n\n let section_length = ((data[1] & 0x0F) << 8) | data[2];\n\n let program_number = (data[3] << 8) | data[4];\n let version_number = (data[5] & 0x3E) >>> 1;\n let current_next_indicator = data[5] & 0x01;\n let section_number = data[6];\n let last_section_number = data[7];\n\n let pmt: PMT = null;\n\n if (current_next_indicator === 1 && section_number === 0) {\n pmt = new PMT();\n pmt.program_number = program_number;\n pmt.version_number = version_number;\n this.program_pmt_map_[program_number] = pmt;\n } else {\n pmt = this.program_pmt_map_[program_number];\n if (pmt == undefined) {\n return;\n }\n }\n\n let PCR_PID = ((data[8] & 0x1F) << 8) | data[9];\n let program_info_length = ((data[10] & 0x0F) << 8) | data[11];\n\n let info_start_index = 12 + program_info_length;\n let info_bytes = section_length - 9 - program_info_length - 4;\n\n for (let i = info_start_index; i < info_start_index + info_bytes; ) {\n let stream_type = data[i] as StreamType;\n let elementary_PID = ((data[i + 1] & 0x1F) << 8) | data[i + 2];\n let ES_info_length = ((data[i + 3] & 0x0F) << 8) | data[i + 4];\n\n pmt.pid_stream_type[elementary_PID] = stream_type;\n\n let already_has_video = pmt.common_pids.h264 || pmt.common_pids.h265;\n let already_has_audio = pmt.common_pids.adts_aac || pmt.common_pids.loas_aac || pmt.common_pids.ac3 || pmt.common_pids.opus || pmt.common_pids.mp3;\n\n if (stream_type === StreamType.kH264 && !already_has_video) {\n pmt.common_pids.h264 = elementary_PID;\n } else if (stream_type === StreamType.kH265 && !already_has_video) {\n pmt.common_pids.h265 = elementary_PID;\n } else if (stream_type === StreamType.kADTSAAC && !already_has_audio) {\n pmt.common_pids.adts_aac = elementary_PID;\n } else if (stream_type === StreamType.kLOASAAC && !already_has_audio) {\n pmt.common_pids.loas_aac = elementary_PID;\n } else if (stream_type === StreamType.kAC3 && !already_has_audio) {\n pmt.common_pids.ac3 = elementary_PID; // ATSC AC-3\n } else if ((stream_type === StreamType.kMPEG1Audio || stream_type === StreamType.kMPEG2Audio) && !already_has_audio) {\n pmt.common_pids.mp3 = elementary_PID;\n } else if (stream_type === StreamType.kPESPrivateData) {\n pmt.pes_private_data_pids[elementary_PID] = true;\n if (ES_info_length > 0) {\n // parse descriptor for PES private data\n for (let offset = i + 5; offset < i + 5 + ES_info_length; ) {\n let tag = data[offset + 0];\n let length = data[offset + 1];\n if (tag === 0x05) { // Registration Descriptor\n let registration = String.fromCharCode(... Array.from(data.subarray(offset + 2, offset + 2 + length)));\n\n if (registration === 'VANC') {\n pmt.smpte2038_pids[elementary_PID] = true;\n } /* else if (registration === 'AC-3' && !already_has_audio) {\n pmt.common_pids.ac3 = elementary_PID; // DVB AC-3 (FIXME: NEED VERIFY)\n } */ else if (registration === 'Opus') {\n pmt.common_pids.opus = elementary_PID;\n }\n } else if (tag === 0x7F) { // DVB extension descriptor\n if (elementary_PID === pmt.common_pids.opus) {\n let ext_desc_tag = data[offset + 2];\n let channel_config_code: number | null = null;\n if (ext_desc_tag === 0x80) { // User defined (provisional Opus)\n channel_config_code = data[offset + 3];\n }\n\n if (channel_config_code == null) {\n Log.e(this.TAG, `Not Supported Opus channel count.`);\n continue;\n }\n\n const meta = {\n codec: 'opus',\n channel_count: (channel_config_code & 0x0F) === 0 ? 2 : (channel_config_code & 0x0F),\n channel_config_code,\n sample_rate: 48000\n } as const;\n const sample = {\n codec: 'opus',\n meta\n } as const;\n\n if (this.audio_init_segment_dispatched_ == false) {\n this.audio_metadata_ = meta;\n this.dispatchAudioInitSegment(sample);\n } else if (this.detectAudioMetadataChange(sample)) {\n // flush stashed frames before notify new AudioSpecificConfig\n this.dispatchAudioMediaSegment();\n // notify new AAC AudioSpecificConfig\n this.dispatchAudioInitSegment(sample);\n }\n }\n }\n\n offset += 2 + length;\n }\n // provide descriptor for PES private data via callback\n let descriptors = data.subarray(i + 5, i + 5 + ES_info_length);\n this.dispatchPESPrivateDataDescriptor(elementary_PID, stream_type, descriptors);\n }\n } else if (stream_type === StreamType.kID3) {\n pmt.timed_id3_pids[elementary_PID] = true;\n } else if (stream_type === StreamType.kSCTE35) {\n pmt.scte_35_pids[elementary_PID] = true;\n }\n\n i += 5 + ES_info_length;\n }\n\n if (program_number === this.current_program_) {\n if (this.pmt_ == undefined) {\n Log.v(this.TAG, `Parsed first PMT: ${JSON.stringify(pmt)}`);\n }\n this.pmt_ = pmt;\n if (pmt.common_pids.h264 || pmt.common_pids.h265) {\n this.has_video_ = true;\n }\n if (pmt.common_pids.adts_aac || pmt.common_pids.loas_aac || pmt.common_pids.ac3 || pmt.common_pids.opus || pmt.common_pids.mp3) {\n this.has_audio_ = true;\n }\n }\n }\n\n private parseSCTE35(data: Uint8Array): void {\n const scte35 = readSCTE35(data);\n\n if (scte35.pts != undefined) {\n let pts_ms = Math.floor(scte35.pts / this.timescale_);\n scte35.pts = pts_ms;\n } else {\n scte35.nearest_pts = this.aac_last_sample_pts_;\n }\n\n if (this.onSCTE35Metadata) {\n this.onSCTE35Metadata(scte35);\n }\n }\n\n private parseH264Payload(data: Uint8Array, pts: number, dts: number, file_position: number, random_access_indicator: number) {\n let annexb_parser = new H264AnnexBParser(data);\n let nalu_payload: H264NaluPayload = null;\n let units: {type: H264NaluType, data: Uint8Array}[] = [];\n let length = 0;\n let keyframe = false;\n\n while ((nalu_payload = annexb_parser.readNextNaluPayload()) != null) {\n let nalu_avc1 = new H264NaluAVC1(nalu_payload);\n\n if (nalu_avc1.type === H264NaluType.kSliceSPS) {\n // Notice: parseSPS requires Nalu without startcode or length-header\n let details = SPSParser.parseSPS(nalu_payload.data);\n if (!this.video_init_segment_dispatched_) {\n this.video_metadata_.sps = nalu_avc1;\n this.video_metadata_.details = details;\n } else if (this.detectVideoMetadataChange(nalu_avc1, details) === true) {\n Log.v(this.TAG, `H264: Critical h264 metadata has been changed, attempt to re-generate InitSegment`);\n this.video_metadata_changed_ = true;\n this.video_metadata_ = {vps: undefined, sps: nalu_avc1, pps: undefined, details: details};\n }\n } else if (nalu_avc1.type === H264NaluType.kSlicePPS) {\n if (!this.video_init_segment_dispatched_ || this.video_metadata_changed_) {\n this.video_metadata_.pps = nalu_avc1;\n if (this.video_metadata_.sps && this.video_metadata_.pps) {\n if (this.video_metadata_changed_) {\n // flush stashed frames before changing codec metadata\n this.dispatchVideoMediaSegment();\n }\n // notify new codec metadata (maybe changed)\n this.dispatchVideoInitSegment();\n }\n }\n } else if (nalu_avc1.type === H264NaluType.kSliceIDR) {\n keyframe = true;\n } else if (nalu_avc1.type === H264NaluType.kSliceNonIDR && random_access_indicator === 1) {\n // For open-gop stream, use random_access_indicator to identify keyframe\n keyframe = true;\n }\n\n // Push samples to remuxer only if initialization metadata has been dispatched\n if (this.video_init_segment_dispatched_) {\n units.push(nalu_avc1);\n length += nalu_avc1.data.byteLength;\n }\n }\n\n let pts_ms = Math.floor(pts / this.timescale_);\n let dts_ms = Math.floor(dts / this.timescale_);\n\n if (units.length) {\n let track = this.video_track_;\n let avc_sample = {\n units,\n length,\n isKeyframe: keyframe,\n dts: dts_ms,\n pts: pts_ms,\n cts: pts_ms - dts_ms,\n file_position\n };\n track.samples.push(avc_sample);\n track.length += length;\n }\n }\n\n private parseH265Payload(data: Uint8Array, pts: number, dts: number, file_position: number, random_access_indicator: number) {\n let annexb_parser = new H265AnnexBParser(data);\n let nalu_payload: H265NaluPayload = null;\n let units: {type: H265NaluType, data: Uint8Array}[] = [];\n let length = 0;\n let keyframe = false;\n\n while ((nalu_payload = annexb_parser.readNextNaluPayload()) != null) {\n let nalu_hvc1 = new H265NaluHVC1(nalu_payload);\n\n if (nalu_hvc1.type === H265NaluType.kSliceVPS) {\n if (!this.video_init_segment_dispatched_) {\n let details = H265Parser.parseVPS(nalu_payload.data);\n this.video_metadata_.vps = nalu_hvc1;\n this.video_metadata_.details = {\n ... this.video_metadata_.details,\n ... details\n };\n }\n } else if (nalu_hvc1.type === H265NaluType.kSliceSPS) {\n let details = H265Parser.parseSPS(nalu_payload.data);\n if (!this.video_init_segment_dispatched_) {\n this.video_metadata_.sps = nalu_hvc1;\n this.video_metadata_.details = {\n ... this.video_metadata_.details,\n ... details\n };\n } else if (this.detectVideoMetadataChange(nalu_hvc1, details) === true) {\n Log.v(this.TAG, `H265: Critical h265 metadata has been changed, attempt to re-generate InitSegment`);\n this.video_metadata_changed_ = true;\n this.video_metadata_ = { vps: undefined, sps: nalu_hvc1, pps: undefined, details: details};\n }\n } else if (nalu_hvc1.type === H265NaluType.kSlicePPS) {\n if (!this.video_init_segment_dispatched_ || this.video_metadata_changed_) {\n let details = H265Parser.parsePPS(nalu_payload.data);\n this.video_metadata_.pps = nalu_hvc1;\n this.video_metadata_.details = {\n ... this.video_metadata_.details,\n ... details\n };\n\n if (this.video_metadata_.vps && this.video_metadata_.sps && this.video_metadata_.pps) {\n if (this.video_metadata_changed_) {\n // flush stashed frames before changing codec metadata\n this.dispatchVideoMediaSegment();\n }\n // notify new codec metadata (maybe changed)\n this.dispatchVideoInitSegment();\n }\n }\n } else if (nalu_hvc1.type === H265NaluType.kSliceIDR_W_RADL || nalu_hvc1.type === H265NaluType.kSliceIDR_N_LP || nalu_hvc1.type === H265NaluType.kSliceCRA_NUT) {\n keyframe = true;\n }\n\n // Push samples to remuxer only if initialization metadata has been dispatched\n if (this.video_init_segment_dispatched_) {\n units.push(nalu_hvc1);\n length += nalu_hvc1.data.byteLength;\n }\n }\n\n let pts_ms = Math.floor(pts / this.timescale_);\n let dts_ms = Math.floor(dts / this.timescale_);\n\n if (units.length) {\n let track = this.video_track_;\n let hvc_sample = {\n units,\n length,\n isKeyframe: keyframe,\n dts: dts_ms,\n pts: pts_ms,\n cts: pts_ms - dts_ms,\n file_position\n };\n track.samples.push(hvc_sample);\n track.length += length;\n }\n }\n\n private detectVideoMetadataChange(new_sps: H264NaluAVC1 | H265NaluHVC1, new_details: any): boolean {\n if (new_details.codec_mimetype !== this.video_metadata_.details.codec_mimetype) {\n Log.v(this.TAG, `Video: Codec mimeType changed from ` +\n `${this.video_metadata_.details.codec_mimetype} to ${new_details.codec_mimetype}`);\n return true;\n }\n\n if (new_details.codec_size.width !== this.video_metadata_.details.codec_size.width\n || new_details.codec_size.height !== this.video_metadata_.details.codec_size.height) {\n let old_size = this.video_metadata_.details.codec_size;\n let new_size = new_details.codec_size;\n Log.v(this.TAG, `Video: Coded Resolution changed from ` +\n `${old_size.width}x${old_size.height} to ${new_size.width}x${new_size.height}`);\n return true;\n }\n\n if (new_details.present_size.width !== this.video_metadata_.details.present_size.width) {\n Log.v(this.TAG, `Video: Present resolution width changed from ` +\n `${this.video_metadata_.details.present_size.width} to ${new_details.present_size.width}`);\n return true;\n }\n\n return false;\n }\n\n private isInitSegmentDispatched(): boolean {\n if (this.has_video_ && this.has_audio_) { // both video & audio\n return this.video_init_segment_dispatched_ && this.audio_init_segment_dispatched_;\n }\n if (this.has_video_ && !this.has_audio_) { // video only\n return this.video_init_segment_dispatched_;\n }\n if (!this.has_video_ && this.has_audio_) { // audio only\n return this.audio_init_segment_dispatched_;\n }\n return false;\n }\n\n private dispatchVideoInitSegment() {\n let details = this.video_metadata_.details;\n let meta: any = {};\n\n meta.type = 'video';\n meta.id = this.video_track_.id;\n meta.timescale = 1000;\n meta.duration = this.duration_;\n\n meta.codecWidth = details.codec_size.width;\n meta.codecHeight = details.codec_size.height;\n meta.presentWidth = details.present_size.width;\n meta.presentHeight = details.present_size.height;\n\n meta.profile = details.profile_string;\n meta.level = details.level_string;\n meta.bitDepth = details.bit_depth;\n meta.chromaFormat = details.chroma_format;\n meta.sarRatio = details.sar_ratio;\n meta.frameRate = details.frame_rate;\n\n let fps_den = meta.frameRate.fps_den;\n let fps_num = meta.frameRate.fps_num;\n meta.refSampleDuration = 1000 * (fps_den / fps_num);\n\n meta.codec = details.codec_mimetype;\n\n if (this.video_metadata_.vps) {\n let vps_without_header = this.video_metadata_.vps.data.subarray(4);\n let sps_without_header = this.video_metadata_.sps.data.subarray(4);\n let pps_without_header = this.video_metadata_.pps.data.subarray(4);\n let hvcc = new HEVCDecoderConfigurationRecord(vps_without_header, sps_without_header, pps_without_header, details);\n meta.hvcc = hvcc.getData();\n\n if (this.video_init_segment_dispatched_ == false) {\n Log.v(this.TAG, `Generated first HEVCDecoderConfigurationRecord for mimeType: ${meta.codec}`);\n }\n } else {\n let sps_without_header = this.video_metadata_.sps.data.subarray(4);\n let pps_without_header = this.video_metadata_.pps.data.subarray(4);\n let avcc = new AVCDecoderConfigurationRecord(sps_without_header, pps_without_header, details);\n meta.avcc = avcc.getData();\n\n if (this.video_init_segment_dispatched_ == false) {\n Log.v(this.TAG, `Generated first AVCDecoderConfigurationRecord for mimeType: ${meta.codec}`);\n }\n }\n this.onTrackMetadata('video', meta);\n this.video_init_segment_dispatched_ = true;\n this.video_metadata_changed_ = false;\n\n // notify new MediaInfo\n let mi = this.media_info_;\n mi.hasVideo = true;\n mi.width = meta.codecWidth;\n mi.height = meta.codecHeight;\n mi.fps = meta.frameRate.fps;\n mi.profile = meta.profile;\n mi.level = meta.level;\n mi.refFrames = details.ref_frames;\n mi.chromaFormat = details.chroma_format_string;\n mi.sarNum = meta.sarRatio.width;\n mi.sarDen = meta.sarRatio.height;\n mi.videoCodec = meta.codec;\n\n if (mi.hasAudio && mi.audioCodec) {\n mi.mimeType = `video/mp2t; codecs=\"${mi.videoCodec},${mi.audioCodec}\"`;\n } else {\n mi.mimeType = `video/mp2t; codecs=\"${mi.videoCodec}\"`;\n }\n\n if (mi.isComplete()) {\n this.onMediaInfo(mi);\n }\n }\n\n private dispatchVideoMediaSegment() {\n if (this.isInitSegmentDispatched()) {\n if (this.video_track_.length) {\n this.onDataAvailable(null, this.video_track_);\n }\n }\n }\n\n private dispatchAudioMediaSegment() {\n if (this.isInitSegmentDispatched()) {\n if (this.audio_track_.length) {\n this.onDataAvailable(this.audio_track_, null);\n }\n }\n }\n\n private dispatchAudioVideoMediaSegment() {\n if (this.isInitSegmentDispatched()) {\n if (this.audio_track_.length || this.video_track_.length) {\n this.onDataAvailable(this.audio_track_, this.video_track_);\n }\n }\n }\n\n private parseADTSAACPayload(data: Uint8Array, pts: number) {\n if (this.has_video_ && !this.video_init_segment_dispatched_) {\n // If first video IDR frame hasn't been detected,\n // Wait for first IDR frame and video init segment being dispatched\n return;\n }\n\n if (this.aac_last_incomplete_data_) {\n let buf = new Uint8Array(data.byteLength + this.aac_last_incomplete_data_.byteLength);\n buf.set(this.aac_last_incomplete_data_, 0);\n buf.set(data, this.aac_last_incomplete_data_.byteLength);\n data = buf;\n }\n\n let ref_sample_duration: number;\n let base_pts_ms: number;\n\n if (pts != undefined) {\n base_pts_ms = pts / this.timescale_;\n }\n if (this.audio_metadata_.codec === 'aac') {\n if (pts == undefined && this.aac_last_sample_pts_ != undefined) {\n ref_sample_duration = 1024 / this.audio_metadata_.sampling_frequency * 1000;\n base_pts_ms = this.aac_last_sample_pts_ + ref_sample_duration;\n } else if (pts == undefined){\n Log.w(this.TAG, `AAC: Unknown pts`);\n return;\n }\n\n if (this.aac_last_incomplete_data_ && this.aac_last_sample_pts_) {\n ref_sample_duration = 1024 / this.audio_metadata_.sampling_frequency * 1000;\n let new_pts_ms = this.aac_last_sample_pts_ + ref_sample_duration;\n\n if (Math.abs(new_pts_ms - base_pts_ms) > 1) {\n Log.w(this.TAG, `AAC: Detected pts overlapped, ` +\n `expected: ${new_pts_ms}ms, PES pts: ${base_pts_ms}ms`);\n base_pts_ms = new_pts_ms;\n }\n }\n }\n\n let adts_parser = new AACADTSParser(data);\n let aac_frame: AACFrame = null;\n let sample_pts_ms = base_pts_ms;\n let last_sample_pts_ms: number;\n\n while ((aac_frame = adts_parser.readNextAACFrame()) != null) {\n ref_sample_duration = 1024 / aac_frame.sampling_frequency * 1000;\n const audio_sample = {\n codec: 'aac',\n data: aac_frame\n } as const;\n\n if (this.audio_init_segment_dispatched_ == false) {\n this.audio_metadata_ = {\n codec: 'aac',\n audio_object_type: aac_frame.audio_object_type,\n sampling_freq_index: aac_frame.sampling_freq_index,\n sampling_frequency: aac_frame.sampling_frequency,\n channel_config: aac_frame.channel_config\n };\n this.dispatchAudioInitSegment(audio_sample);\n } else if (this.detectAudioMetadataChange(audio_sample)) {\n // flush stashed frames before notify new AudioSpecificConfig\n this.dispatchAudioMediaSegment();\n // notify new AAC AudioSpecificConfig\n this.dispatchAudioInitSegment(audio_sample);\n }\n\n last_sample_pts_ms = sample_pts_ms;\n let sample_pts_ms_int = Math.floor(sample_pts_ms);\n\n let aac_sample = {\n unit: aac_frame.data,\n length: aac_frame.data.byteLength,\n pts: sample_pts_ms_int,\n dts: sample_pts_ms_int\n };\n this.audio_track_.samples.push(aac_sample);\n this.audio_track_.length += aac_frame.data.byteLength;\n\n sample_pts_ms += ref_sample_duration;\n }\n\n if (adts_parser.hasIncompleteData()) {\n this.aac_last_incomplete_data_ = adts_parser.getIncompleteData();\n }\n\n if (last_sample_pts_ms) {\n this.aac_last_sample_pts_ = last_sample_pts_ms;\n }\n }\n\n private parseLOASAACPayload(data: Uint8Array, pts: number) {\n if (this.has_video_ && !this.video_init_segment_dispatched_) {\n // If first video IDR frame hasn't been detected,\n // Wait for first IDR frame and video init segment being dispatched\n return;\n }\n\n if (this.aac_last_incomplete_data_) {\n let buf = new Uint8Array(data.byteLength + this.aac_last_incomplete_data_.byteLength);\n buf.set(this.aac_last_incomplete_data_, 0);\n buf.set(data, this.aac_last_incomplete_data_.byteLength);\n data = buf;\n }\n\n let ref_sample_duration: number;\n let base_pts_ms: number;\n\n if (pts != undefined) {\n base_pts_ms = pts / this.timescale_;\n }\n if (this.audio_metadata_.codec === 'aac') {\n if (pts == undefined && this.aac_last_sample_pts_ != undefined) {\n ref_sample_duration = 1024 / this.audio_metadata_.sampling_frequency * 1000;\n base_pts_ms = this.aac_last_sample_pts_ + ref_sample_duration;\n } else if (pts == undefined){\n Log.w(this.TAG, `AAC: Unknown pts`);\n return;\n }\n\n if (this.aac_last_incomplete_data_ && this.aac_last_sample_pts_) {\n ref_sample_duration = 1024 / this.audio_metadata_.sampling_frequency * 1000;\n let new_pts_ms = this.aac_last_sample_pts_ + ref_sample_duration;\n\n if (Math.abs(new_pts_ms - base_pts_ms) > 1) {\n Log.w(this.TAG, `AAC: Detected pts overlapped, ` +\n `expected: ${new_pts_ms}ms, PES pts: ${base_pts_ms}ms`);\n base_pts_ms = new_pts_ms;\n }\n }\n }\n\n let loas_parser = new AACLOASParser(data);\n let aac_frame: LOASAACFrame = null;\n let sample_pts_ms = base_pts_ms;\n let last_sample_pts_ms: number;\n\n while ((aac_frame = loas_parser.readNextAACFrame(this.loas_previous_frame ?? undefined)) != null) {\n this.loas_previous_frame = aac_frame;\n ref_sample_duration = 1024 / aac_frame.sampling_frequency * 1000;\n const audio_sample = {\n codec: 'aac',\n data: aac_frame\n } as const;\n\n if (this.audio_init_segment_dispatched_ == false) {\n this.audio_metadata_ = {\n codec: 'aac',\n audio_object_type: aac_frame.audio_object_type,\n sampling_freq_index: aac_frame.sampling_freq_index,\n sampling_frequency: aac_frame.sampling_frequency,\n channel_config: aac_frame.channel_config\n };\n this.dispatchAudioInitSegment(audio_sample);\n } else if (this.detectAudioMetadataChange(audio_sample)) {\n // flush stashed frames before notify new AudioSpecificConfig\n this.dispatchAudioMediaSegment();\n // notify new AAC AudioSpecificConfig\n this.dispatchAudioInitSegment(audio_sample);\n }\n\n last_sample_pts_ms = sample_pts_ms;\n let sample_pts_ms_int = Math.floor(sample_pts_ms);\n\n let aac_sample = {\n unit: aac_frame.data,\n length: aac_frame.data.byteLength,\n pts: sample_pts_ms_int,\n dts: sample_pts_ms_int\n };\n this.audio_track_.samples.push(aac_sample);\n this.audio_track_.length += aac_frame.data.byteLength;\n\n sample_pts_ms += ref_sample_duration;\n }\n\n if (loas_parser.hasIncompleteData()) {\n this.aac_last_incomplete_data_ = loas_parser.getIncompleteData();\n }\n\n if (last_sample_pts_ms) {\n this.aac_last_sample_pts_ = last_sample_pts_ms;\n }\n }\n\n private parseAC3Payload(data: Uint8Array, pts: number) {\n if (this.has_video_ && !this.video_init_segment_dispatched_) {\n // If first video IDR frame hasn't been detected,\n // Wait for first IDR frame and video init segment being dispatched\n return;\n }\n\n let ref_sample_duration: number;\n let base_pts_ms: number;\n\n if (pts != undefined) {\n base_pts_ms = pts / this.timescale_;\n }\n\n if (this.audio_metadata_.codec === 'ac-3') {\n if (pts == undefined && this.aac_last_sample_pts_ != undefined) {\n ref_sample_duration = 1536 / this.audio_metadata_.sampling_frequency * 1000;;\n base_pts_ms = this.aac_last_sample_pts_ + ref_sample_duration;\n } else if (pts == undefined){\n Log.w(this.TAG, `Opus: Unknown pts`);\n return;\n }\n }\n\n let adts_parser = new AC3Parser(data);\n let ac3_frame: AC3Frame = null;\n let sample_pts_ms = base_pts_ms;\n let last_sample_pts_ms: number;\n\n while ((ac3_frame = adts_parser.readNextAC3Frame()) != null) {\n ref_sample_duration = 1536 / ac3_frame.sampling_frequency * 1000;\n const audio_sample = {\n codec: 'ac-3',\n data: ac3_frame\n } as const;\n\n if (this.audio_init_segment_dispatched_ == false) {\n this.audio_metadata_ = {\n codec: 'ac-3',\n sampling_frequency: ac3_frame.sampling_frequency,\n bit_stream_identification: ac3_frame.bit_stream_identification,\n bit_stream_mode: ac3_frame.bit_stream_mode,\n low_frequency_effects_channel_on: ac3_frame.low_frequency_effects_channel_on,\n channel_mode: ac3_frame.channel_mode,\n };\n console.log(JSON.stringify(this.audio_metadata_))\n this.dispatchAudioInitSegment(audio_sample);\n } else if (this.detectAudioMetadataChange(audio_sample)) {\n // flush stashed frames before notify new AudioSpecificConfig\n this.dispatchAudioMediaSegment();\n // notify new AAC AudioSpecificConfig\n this.dispatchAudioInitSegment(audio_sample);\n }\n\n last_sample_pts_ms = sample_pts_ms;\n let sample_pts_ms_int = Math.floor(sample_pts_ms);\n\n let ac3_sample = {\n unit: ac3_frame.data,\n length: ac3_frame.data.byteLength,\n pts: sample_pts_ms_int,\n dts: sample_pts_ms_int\n };\n\n this.audio_track_.samples.push(ac3_sample);\n this.audio_track_.length += ac3_frame.data.byteLength;\n\n sample_pts_ms += ref_sample_duration;\n }\n\n if (last_sample_pts_ms) {\n this.aac_last_sample_pts_ = last_sample_pts_ms;\n }\n }\n\n private parseOpusPayload(data: Uint8Array, pts: number) {\n if (this.has_video_ && !this.video_init_segment_dispatched_) {\n // If first video IDR frame hasn't been detected,\n // Wait for first IDR frame and video init segment being dispatched\n return;\n }\n\n let ref_sample_duration: number;\n let base_pts_ms: number;\n\n if (pts != undefined) {\n base_pts_ms = pts / this.timescale_;\n }\n if (this.audio_metadata_.codec === 'opus') {\n if (pts == undefined && this.aac_last_sample_pts_ != undefined) {\n ref_sample_duration = 20;\n base_pts_ms = this.aac_last_sample_pts_ + ref_sample_duration;\n } else if (pts == undefined){\n Log.w(this.TAG, `Opus: Unknown pts`);\n return;\n }\n }\n\n let sample_pts_ms = base_pts_ms;\n let last_sample_pts_ms: number;\n\n for (let offset = 0; offset < data.length; ) {\n ref_sample_duration = 20;\n\n const opus_pending_trim_start = (data[offset + 1] & 0x10) !== 0;\n const trim_end = (data[offset + 1] & 0x08) !== 0;\n let index = offset + 2;\n let size = 0;\n\n while (data[index] === 0xFF) {\n size += 255;\n index += 1;\n }\n size += data[index];\n index += 1;\n index += opus_pending_trim_start ? 2 : 0;\n index += trim_end ? 2 : 0;\n\n last_sample_pts_ms = sample_pts_ms;\n let sample_pts_ms_int = Math.floor(sample_pts_ms);\n let sample = data.slice(index, index + size)\n\n let opus_sample = {\n unit: sample,\n length: sample.byteLength,\n pts: sample_pts_ms_int,\n dts: sample_pts_ms_int\n };\n this.audio_track_.samples.push(opus_sample);\n this.audio_track_.length += sample.byteLength;\n\n sample_pts_ms += ref_sample_duration;\n offset = index + size;\n }\n\n if (last_sample_pts_ms) {\n this.aac_last_sample_pts_ = last_sample_pts_ms;\n }\n }\n\n private parseMP3Payload(data: Uint8Array, pts: number) {\n if (this.has_video_ && !this.video_init_segment_dispatched_) {\n // If first video IDR frame hasn't been detected,\n // Wait for first IDR frame and video init segment being dispatched\n return;\n }\n\n let _mpegAudioV10SampleRateTable = [44100, 48000, 32000, 0];\n let _mpegAudioV20SampleRateTable = [22050, 24000, 16000, 0];\n let _mpegAudioV25SampleRateTable = [11025, 12000, 8000, 0];\n let _mpegAudioL1BitRateTable = [0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, -1];\n let _mpegAudioL2BitRateTable = [0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, -1];\n let _mpegAudioL3BitRateTable = [0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1];\n\n let ver = (data[1] >>> 3) & 0x03;\n let layer = (data[1] & 0x06) >> 1;\n let bitrate_index = (data[2] & 0xF0) >>> 4;\n let sampling_freq_index = (data[2] & 0x0C) >>> 2;\n let channel_mode = (data[3] >>> 6) & 0x03;\n let channel_count = channel_mode !== 3 ? 2 : 1;\n\n let sample_rate = 0;\n let bit_rate = 0;\n let object_type = 34; // Layer-3, listed in MPEG-4 Audio Object Types\n\n let codec = 'mp3';\n switch (ver) {\n case 0: // MPEG 2.5\n sample_rate = _mpegAudioV25SampleRateTable[sampling_freq_index];\n break;\n case 2: // MPEG 2\n sample_rate = _mpegAudioV20SampleRateTable[sampling_freq_index];\n break;\n case 3: // MPEG 1\n sample_rate = _mpegAudioV10SampleRateTable[sampling_freq_index];\n break;\n }\n\n switch (layer) {\n case 1: // Layer 3\n object_type = 34;\n if (bitrate_index < _mpegAudioL3BitRateTable.length) {\n bit_rate = _mpegAudioL3BitRateTable[bitrate_index];\n }\n break;\n case 2: // Layer 2\n object_type = 33;\n if (bitrate_index < _mpegAudioL2BitRateTable.length) {\n bit_rate = _mpegAudioL2BitRateTable[bitrate_index];\n }\n break;\n case 3: // Layer 1\n object_type = 32;\n if (bitrate_index < _mpegAudioL1BitRateTable.length) {\n bit_rate = _mpegAudioL1BitRateTable[bitrate_index];\n }\n break;\n }\n\n const sample = new MP3Data();\n sample.object_type = object_type;\n sample.sample_rate = sample_rate;\n sample.channel_count = channel_count;\n sample.data = data;\n const audio_sample = {\n codec: 'mp3',\n data: sample\n } as const;\n\n\n if (this.audio_init_segment_dispatched_ == false) {\n this.audio_metadata_ = {\n codec: 'mp3',\n object_type,\n sample_rate,\n channel_count\n }\n this.dispatchAudioInitSegment(audio_sample);\n } else if (this.detectAudioMetadataChange(audio_sample)) {\n // flush stashed frames before notify new AudioSpecificConfig\n this.dispatchAudioMediaSegment();\n // notify new AAC AudioSpecificConfig\n this.dispatchAudioInitSegment(audio_sample);\n }\n\n let mp3_sample = {\n unit: data,\n length: data.byteLength,\n pts: pts / this.timescale_,\n dts: pts / this.timescale_\n };\n this.audio_track_.samples.push(mp3_sample);\n this.audio_track_.length += data.byteLength;\n }\n\n private detectAudioMetadataChange(sample: AudioData): boolean {\n if (sample.codec !== this.audio_metadata_.codec) {\n Log.v(this.TAG, `Audio: Audio Codecs changed from ` +\n `${this.audio_metadata_.codec} to ${sample.codec}`);\n return true;\n }\n\n if (sample.codec === 'aac' && this.audio_metadata_.codec === 'aac') {\n const frame = sample.data;\n if (frame.audio_object_type !== this.audio_metadata_.audio_object_type) {\n Log.v(this.TAG, `AAC: AudioObjectType changed from ` +\n `${this.audio_metadata_.audio_object_type} to ${frame.audio_object_type}`);\n return true;\n }\n\n if (frame.sampling_freq_index !== this.audio_metadata_.sampling_freq_index) {\n Log.v(this.TAG, `AAC: SamplingFrequencyIndex changed from ` +\n `${this.audio_metadata_.sampling_freq_index} to ${frame.sampling_freq_index}`);\n return true;\n }\n\n if (frame.channel_config !== this.audio_metadata_.channel_config) {\n Log.v(this.TAG, `AAC: Channel configuration changed from ` +\n `${this.audio_metadata_.channel_config} to ${frame.channel_config}`);\n return true;\n }\n } else if (sample.codec === 'ac-3' && this.audio_metadata_.codec === 'ac-3') {\n const frame = sample.data;\n if (frame.sampling_frequency !== this.audio_metadata_.sampling_frequency) {\n Log.v(this.TAG, `AC3: Sampling Frequency changed from ` +\n `${this.audio_metadata_.sampling_frequency} to ${frame.sampling_frequency}`);\n return true;\n }\n\n if (frame.bit_stream_identification !== this.audio_metadata_.bit_stream_identification) {\n Log.v(this.TAG, `AC3: Bit Stream Identification changed from ` +\n `${this.audio_metadata_.bit_stream_identification} to ${frame.bit_stream_identification}`);\n return true;\n }\n\n if (frame.bit_stream_mode !== this.audio_metadata_.bit_stream_mode) {\n Log.v(this.TAG, `AC3: BitStream Mode changed from ` +\n `${this.audio_metadata_.bit_stream_mode} to ${frame.bit_stream_mode}`);\n return true;\n }\n\n if (frame.channel_mode !== this.audio_metadata_.channel_mode) {\n Log.v(this.TAG, `AC3: Channel Mode changed from ` +\n `${this.audio_metadata_.channel_mode} to ${frame.channel_mode}`);\n return true;\n }\n\n if (frame.low_frequency_effects_channel_on !== this.audio_metadata_.low_frequency_effects_channel_on) {\n Log.v(this.TAG, `AC3: Low Frequency Effects Channel On changed from ` +\n `${this.audio_metadata_.low_frequency_effects_channel_on} to ${frame.low_frequency_effects_channel_on}`);\n return true;\n }\n } else if (sample.codec === 'opus' && this.audio_metadata_.codec === 'opus') {\n const data = sample.meta;\n\n if (data.sample_rate !== this.audio_metadata_.sample_rate) {\n Log.v(this.TAG, `Opus: SamplingFrequencyIndex changed from ` +\n `${this.audio_metadata_.sample_rate} to ${data.sample_rate}`);\n return true;\n }\n\n if (data.channel_count !== this.audio_metadata_.channel_count) {\n Log.v(this.TAG, `Opus: Channel count changed from ` +\n `${this.audio_metadata_.channel_count} to ${data.channel_count}`);\n return true;\n }\n } else if (sample.codec === 'mp3' && this.audio_metadata_.codec === 'mp3') {\n const data = sample.data;\n if (data.object_type !== this.audio_metadata_.object_type) {\n Log.v(this.TAG, `MP3: AudioObjectType changed from ` +\n `${this.audio_metadata_.object_type} to ${data.object_type}`);\n return true;\n }\n\n if (data.sample_rate !== this.audio_metadata_.sample_rate) {\n Log.v(this.TAG, `MP3: SamplingFrequencyIndex changed from ` +\n `${this.audio_metadata_.sample_rate} to ${data.sample_rate}`);\n return true;\n }\n\n if (data.channel_count !== this.audio_metadata_.channel_count) {\n Log.v(this.TAG, `MP3: Channel count changed from ` +\n `${this.audio_metadata_.channel_count} to ${data.channel_count}`);\n return true;\n }\n }\n\n return false;\n }\n\n private dispatchAudioInitSegment(sample: AudioData) {\n let meta: any = {};\n meta.type = 'audio';\n meta.id = this.audio_track_.id;\n meta.timescale = 1000;\n meta.duration = this.duration_;\n\n if (this.audio_metadata_.codec === 'aac') {\n let aac_frame = sample.codec === 'aac' ? sample.data : null;\n let audio_specific_config = new AudioSpecificConfig(aac_frame);\n\n meta.audioSampleRate = audio_specific_config.sampling_rate;\n meta.channelCount = audio_specific_config.channel_count;\n meta.codec = audio_specific_config.codec_mimetype;\n meta.originalCodec = audio_specific_config.original_codec_mimetype;\n meta.config = audio_specific_config.config;\n meta.refSampleDuration = 1024 / meta.audioSampleRate * meta.timescale;\n } else if (this.audio_metadata_.codec === 'ac-3') {\n let ac3_frame = sample.codec === 'ac-3' ? sample.data : null;\n let ac3_config = new AC3Config(ac3_frame);\n meta.audioSampleRate = ac3_config.sampling_rate\n meta.channelCount = ac3_config.channel_count;\n meta.codec = ac3_config.codec_mimetype;\n meta.originalCodec = ac3_config.original_codec_mimetype;\n meta.config = ac3_config.config;\n meta.refSampleDuration = 1536 / meta.audioSampleRate * meta.timescale;\n } else if (this.audio_metadata_.codec === 'opus') {\n meta.audioSampleRate = this.audio_metadata_.sample_rate;\n meta.channelCount = this.audio_metadata_.channel_count;\n meta.channelConfigCode = this.audio_metadata_.channel_config_code;\n meta.codec = 'opus';\n meta.originalCodec = 'opus';\n meta.config = undefined;\n meta.refSampleDuration = 20;\n } else if (this.audio_metadata_.codec === 'mp3') {\n meta.audioSampleRate = this.audio_metadata_.sample_rate;\n meta.channelCount = this.audio_metadata_.channel_count;\n meta.codec = 'mp3';\n meta.originalCodec = 'mp3';\n meta.config = undefined;\n }\n\n if (this.audio_init_segment_dispatched_ == false) {\n Log.v(this.TAG, `Generated first AudioSpecificConfig for mimeType: ${meta.codec}`);\n }\n\n this.onTrackMetadata('audio', meta);\n this.audio_init_segment_dispatched_ = true;\n this.video_metadata_changed_ = false;\n\n // notify new MediaInfo\n let mi = this.media_info_;\n mi.hasAudio = true;\n mi.audioCodec = meta.originalCodec;\n mi.audioSampleRate = meta.audioSampleRate;\n mi.audioChannelCount = meta.channelCount;\n\n if (mi.hasVideo && mi.videoCodec) {\n mi.mimeType = `video/mp2t; codecs=\"${mi.videoCodec},${mi.audioCodec}\"`;\n } else {\n mi.mimeType = `video/mp2t; codecs=\"${mi.audioCodec}\"`;\n }\n\n if (mi.isComplete()) {\n this.onMediaInfo(mi);\n }\n }\n\n private dispatchPESPrivateDataDescriptor(pid: number, stream_type: number, descriptor: Uint8Array) {\n let desc = new PESPrivateDataDescriptor();\n desc.pid = pid;\n desc.stream_type = stream_type;\n desc.descriptor = descriptor;\n\n if (this.onPESPrivateDataDescriptor) {\n this.onPESPrivateDataDescriptor(desc);\n }\n }\n\n private parsePESPrivateDataPayload(data: Uint8Array, pts: number, dts: number, pid: number, stream_id: number) {\n let private_data = new PESPrivateData();\n\n private_data.pid = pid;\n private_data.stream_id = stream_id;\n private_data.len = data.byteLength;\n private_data.data = data;\n\n if (pts != undefined) {\n let pts_ms = Math.floor(pts / this.timescale_);\n private_data.pts = pts_ms;\n } else {\n private_data.nearest_pts = this.aac_last_sample_pts_;\n }\n\n if (dts != undefined) {\n let dts_ms = Math.floor(dts / this.timescale_);\n private_data.dts = dts_ms;\n }\n\n if (this.onPESPrivateData) {\n this.onPESPrivateData(private_data);\n }\n }\n\n private parseTimedID3MetadataPayload(data: Uint8Array, pts: number, dts: number, pid: number, stream_id: number) {\n let timed_id3_metadata = new PESPrivateData();\n\n timed_id3_metadata.pid = pid;\n timed_id3_metadata.stream_id = stream_id;\n timed_id3_metadata.len = data.byteLength;\n timed_id3_metadata.data = data;\n\n if (pts != undefined) {\n let pts_ms = Math.floor(pts / this.timescale_);\n timed_id3_metadata.pts = pts_ms;\n }\n\n if (dts != undefined) {\n let dts_ms = Math.floor(dts / this.timescale_);\n timed_id3_metadata.dts = dts_ms;\n }\n\n if (this.onTimedID3Metadata) {\n this.onTimedID3Metadata(timed_id3_metadata);\n }\n }\n\n private parseSMPTE2038MetadataPayload(data: Uint8Array, pts: number, dts: number, pid: number, stream_id: number) {\n let smpte2038_data = new SMPTE2038Data();\n\n smpte2038_data.pid = pid;\n smpte2038_data.stream_id = stream_id;\n smpte2038_data.len = data.byteLength;\n smpte2038_data.data = data;\n\n if (pts != undefined) {\n let pts_ms = Math.floor(pts / this.timescale_);\n smpte2038_data.pts = pts_ms;\n }\n smpte2038_data.nearest_pts = this.aac_last_sample_pts_;\n\n if (dts != undefined) {\n let dts_ms = Math.floor(dts / this.timescale_);\n smpte2038_data.dts = dts_ms;\n }\n\n smpte2038_data.ancillaries = smpte2038parse(data);\n if (this.onSMPTE2038Metadata) {\n this.onSMPTE2038Metadata(smpte2038_data);\n }\n }\n}\n\nexport default TSDemuxer;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * This file is derived from dailymotion's hls.js library (hls.js/src/remux/mp4-generator.js)\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// MP4 boxes generator for ISO BMFF (ISO Base Media File Format, defined in ISO/IEC 14496-12)\nclass MP4 {\n\n static init() {\n MP4.types = {\n avc1: [], avcC: [], btrt: [], dinf: [],\n dref: [], esds: [], ftyp: [], hdlr: [],\n hvc1: [], hvcC: [],\n mdat: [], mdhd: [], mdia: [], mfhd: [],\n minf: [], moof: [], moov: [], mp4a: [],\n mvex: [], mvhd: [], sdtp: [], stbl: [],\n stco: [], stsc: [], stsd: [], stsz: [],\n stts: [], tfdt: [], tfhd: [], traf: [],\n trak: [], trun: [], trex: [], tkhd: [],\n vmhd: [], smhd: [], '.mp3': [],\n Opus: [], dOps: [], 'ac-3': [], dac3: [],\n };\n\n for (let name in MP4.types) {\n if (MP4.types.hasOwnProperty(name)) {\n MP4.types[name] = [\n name.charCodeAt(0),\n name.charCodeAt(1),\n name.charCodeAt(2),\n name.charCodeAt(3)\n ];\n }\n }\n\n let constants = MP4.constants = {};\n\n constants.FTYP = new Uint8Array([\n 0x69, 0x73, 0x6F, 0x6D, // major_brand: isom\n 0x0, 0x0, 0x0, 0x1, // minor_version: 0x01\n 0x69, 0x73, 0x6F, 0x6D, // isom\n 0x61, 0x76, 0x63, 0x31 // avc1\n ]);\n\n constants.STSD_PREFIX = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x01 // entry_count\n ]);\n\n constants.STTS = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00 // entry_count\n ]);\n\n constants.STSC = constants.STCO = constants.STTS;\n\n constants.STSZ = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // sample_size\n 0x00, 0x00, 0x00, 0x00 // sample_count\n ]);\n\n constants.HDLR_VIDEO = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // pre_defined\n 0x76, 0x69, 0x64, 0x65, // handler_type: 'vide'\n 0x00, 0x00, 0x00, 0x00, // reserved: 3 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x56, 0x69, 0x64, 0x65,\n 0x6F, 0x48, 0x61, 0x6E,\n 0x64, 0x6C, 0x65, 0x72, 0x00 // name: VideoHandler\n ]);\n\n constants.HDLR_AUDIO = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // pre_defined\n 0x73, 0x6F, 0x75, 0x6E, // handler_type: 'soun'\n 0x00, 0x00, 0x00, 0x00, // reserved: 3 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x53, 0x6F, 0x75, 0x6E,\n 0x64, 0x48, 0x61, 0x6E,\n 0x64, 0x6C, 0x65, 0x72, 0x00 // name: SoundHandler\n ]);\n\n constants.DREF = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x01, // entry_count\n 0x00, 0x00, 0x00, 0x0C, // entry_size\n 0x75, 0x72, 0x6C, 0x20, // type 'url '\n 0x00, 0x00, 0x00, 0x01 // version(0) + flags\n ]);\n\n // Sound media header\n constants.SMHD = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00 // balance(2) + reserved(2)\n ]);\n\n // video media header\n constants.VMHD = new Uint8Array([\n 0x00, 0x00, 0x00, 0x01, // version(0) + flags\n 0x00, 0x00, // graphicsmode: 2 bytes\n 0x00, 0x00, 0x00, 0x00, // opcolor: 3 * 2 bytes\n 0x00, 0x00\n ]);\n }\n\n // Generate a box\n static box(type) {\n let size = 8;\n let result = null;\n let datas = Array.prototype.slice.call(arguments, 1);\n let arrayCount = datas.length;\n\n for (let i = 0; i < arrayCount; i++) {\n size += datas[i].byteLength;\n }\n\n result = new Uint8Array(size);\n result[0] = (size >>> 24) & 0xFF; // size\n result[1] = (size >>> 16) & 0xFF;\n result[2] = (size >>> 8) & 0xFF;\n result[3] = (size) & 0xFF;\n\n result.set(type, 4); // type\n\n let offset = 8;\n for (let i = 0; i < arrayCount; i++) { // data body\n result.set(datas[i], offset);\n offset += datas[i].byteLength;\n }\n\n return result;\n }\n\n // emit ftyp & moov\n static generateInitSegment(meta) {\n let ftyp = MP4.box(MP4.types.ftyp, MP4.constants.FTYP);\n let moov = MP4.moov(meta);\n\n let result = new Uint8Array(ftyp.byteLength + moov.byteLength);\n result.set(ftyp, 0);\n result.set(moov, ftyp.byteLength);\n return result;\n }\n\n // Movie metadata box\n static moov(meta) {\n let mvhd = MP4.mvhd(meta.timescale, meta.duration);\n let trak = MP4.trak(meta);\n let mvex = MP4.mvex(meta);\n return MP4.box(MP4.types.moov, mvhd, trak, mvex);\n }\n\n // Movie header box\n static mvhd(timescale, duration) {\n return MP4.box(MP4.types.mvhd, new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // creation_time\n 0x00, 0x00, 0x00, 0x00, // modification_time\n (timescale >>> 24) & 0xFF, // timescale: 4 bytes\n (timescale >>> 16) & 0xFF,\n (timescale >>> 8) & 0xFF,\n (timescale) & 0xFF,\n (duration >>> 24) & 0xFF, // duration: 4 bytes\n (duration >>> 16) & 0xFF,\n (duration >>> 8) & 0xFF,\n (duration) & 0xFF,\n 0x00, 0x01, 0x00, 0x00, // Preferred rate: 1.0\n 0x01, 0x00, 0x00, 0x00, // PreferredVolume(1.0, 2bytes) + reserved(2bytes)\n 0x00, 0x00, 0x00, 0x00, // reserved: 4 + 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x01, 0x00, 0x00, // ----begin composition matrix----\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x01, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x40, 0x00, 0x00, 0x00, // ----end composition matrix----\n 0x00, 0x00, 0x00, 0x00, // ----begin pre_defined 6 * 4 bytes----\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, // ----end pre_defined 6 * 4 bytes----\n 0xFF, 0xFF, 0xFF, 0xFF // next_track_ID\n ]));\n }\n\n // Track box\n static trak(meta) {\n return MP4.box(MP4.types.trak, MP4.tkhd(meta), MP4.mdia(meta));\n }\n\n // Track header box\n static tkhd(meta) {\n let trackId = meta.id, duration = meta.duration;\n let width = meta.presentWidth, height = meta.presentHeight;\n\n return MP4.box(MP4.types.tkhd, new Uint8Array([\n 0x00, 0x00, 0x00, 0x07, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // creation_time\n 0x00, 0x00, 0x00, 0x00, // modification_time\n (trackId >>> 24) & 0xFF, // track_ID: 4 bytes\n (trackId >>> 16) & 0xFF,\n (trackId >>> 8) & 0xFF,\n (trackId) & 0xFF,\n 0x00, 0x00, 0x00, 0x00, // reserved: 4 bytes\n (duration >>> 24) & 0xFF, // duration: 4 bytes\n (duration >>> 16) & 0xFF,\n (duration >>> 8) & 0xFF,\n (duration) & 0xFF,\n 0x00, 0x00, 0x00, 0x00, // reserved: 2 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, // layer(2bytes) + alternate_group(2bytes)\n 0x00, 0x00, 0x00, 0x00, // volume(2bytes) + reserved(2bytes)\n 0x00, 0x01, 0x00, 0x00, // ----begin composition matrix----\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x01, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x40, 0x00, 0x00, 0x00, // ----end composition matrix----\n (width >>> 8) & 0xFF, // width and height\n (width) & 0xFF,\n 0x00, 0x00,\n (height >>> 8) & 0xFF,\n (height) & 0xFF,\n 0x00, 0x00\n ]));\n }\n\n // Media Box\n static mdia(meta) {\n return MP4.box(MP4.types.mdia, MP4.mdhd(meta), MP4.hdlr(meta), MP4.minf(meta));\n }\n\n // Media header box\n static mdhd(meta) {\n let timescale = meta.timescale;\n let duration = meta.duration;\n return MP4.box(MP4.types.mdhd, new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n 0x00, 0x00, 0x00, 0x00, // creation_time\n 0x00, 0x00, 0x00, 0x00, // modification_time\n (timescale >>> 24) & 0xFF, // timescale: 4 bytes\n (timescale >>> 16) & 0xFF,\n (timescale >>> 8) & 0xFF,\n (timescale) & 0xFF,\n (duration >>> 24) & 0xFF, // duration: 4 bytes\n (duration >>> 16) & 0xFF,\n (duration >>> 8) & 0xFF,\n (duration) & 0xFF,\n 0x55, 0xC4, // language: und (undetermined)\n 0x00, 0x00 // pre_defined = 0\n ]));\n }\n\n // Media handler reference box\n static hdlr(meta) {\n let data = null;\n if (meta.type === 'audio') {\n data = MP4.constants.HDLR_AUDIO;\n } else {\n data = MP4.constants.HDLR_VIDEO;\n }\n return MP4.box(MP4.types.hdlr, data);\n }\n\n // Media infomation box\n static minf(meta) {\n let xmhd = null;\n if (meta.type === 'audio') {\n xmhd = MP4.box(MP4.types.smhd, MP4.constants.SMHD);\n } else {\n xmhd = MP4.box(MP4.types.vmhd, MP4.constants.VMHD);\n }\n return MP4.box(MP4.types.minf, xmhd, MP4.dinf(), MP4.stbl(meta));\n }\n\n // Data infomation box\n static dinf() {\n let result = MP4.box(MP4.types.dinf,\n MP4.box(MP4.types.dref, MP4.constants.DREF)\n );\n return result;\n }\n\n // Sample table box\n static stbl(meta) {\n let result = MP4.box(MP4.types.stbl, // type: stbl\n MP4.stsd(meta), // Sample Description Table\n MP4.box(MP4.types.stts, MP4.constants.STTS), // Time-To-Sample\n MP4.box(MP4.types.stsc, MP4.constants.STSC), // Sample-To-Chunk\n MP4.box(MP4.types.stsz, MP4.constants.STSZ), // Sample size\n MP4.box(MP4.types.stco, MP4.constants.STCO) // Chunk offset\n );\n return result;\n }\n\n // Sample description box\n static stsd(meta) {\n if (meta.type === 'audio') {\n if (meta.codec === 'mp3') {\n return MP4.box(MP4.types.stsd, MP4.constants.STSD_PREFIX, MP4.mp3(meta));\n } else if (meta.codec === 'ac-3') {\n return MP4.box(MP4.types.stsd, MP4.constants.STSD_PREFIX, MP4.ac3(meta));\n } else if(meta.codec === 'opus') {\n return MP4.box(MP4.types.stsd, MP4.constants.STSD_PREFIX, MP4.Opus(meta));\n }\n // else: aac -> mp4a\n return MP4.box(MP4.types.stsd, MP4.constants.STSD_PREFIX, MP4.mp4a(meta));\n } else if (meta.type === 'video' && meta.codec.startsWith('hvc1')) {\n return MP4.box(MP4.types.stsd, MP4.constants.STSD_PREFIX, MP4.hvc1(meta));\n } else {\n return MP4.box(MP4.types.stsd, MP4.constants.STSD_PREFIX, MP4.avc1(meta));\n }\n }\n\n static mp3(meta) {\n let channelCount = meta.channelCount;\n let sampleRate = meta.audioSampleRate;\n\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n 0x00, 0x00, 0x00, 0x01, // reserved(2) + data_reference_index(2)\n 0x00, 0x00, 0x00, 0x00, // reserved: 2 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, channelCount, // channelCount(2)\n 0x00, 0x10, // sampleSize(2)\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n (sampleRate >>> 8) & 0xFF, // Audio sample rate\n (sampleRate) & 0xFF,\n 0x00, 0x00\n ]);\n\n return MP4.box(MP4.types['.mp3'], data);\n }\n\n static mp4a(meta) {\n let channelCount = meta.channelCount;\n let sampleRate = meta.audioSampleRate;\n\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n 0x00, 0x00, 0x00, 0x01, // reserved(2) + data_reference_index(2)\n 0x00, 0x00, 0x00, 0x00, // reserved: 2 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, channelCount, // channelCount(2)\n 0x00, 0x10, // sampleSize(2)\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n (sampleRate >>> 8) & 0xFF, // Audio sample rate\n (sampleRate) & 0xFF,\n 0x00, 0x00\n ]);\n\n return MP4.box(MP4.types.mp4a, data, MP4.esds(meta));\n }\n\n static ac3(meta) {\n let channelCount = meta.channelCount;\n let sampleRate = meta.audioSampleRate;\n\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n 0x00, 0x00, 0x00, 0x01, // reserved(2) + data_reference_index(2)\n 0x00, 0x00, 0x00, 0x00, // reserved: 2 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, channelCount, // channelCount(2)\n 0x00, 0x10, // sampleSize(2)\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n (sampleRate >>> 8) & 0xFF, // Audio sample rate\n (sampleRate) & 0xFF,\n 0x00, 0x00\n ]);\n\n return MP4.box(MP4.types['ac-3'], data, MP4.box(MP4.types.dac3, new Uint8Array(meta.config)));\n }\n\n static esds(meta) {\n let config = meta.config || [];\n let configSize = config.length;\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version 0 + flags\n\n 0x03, // descriptor_type\n 0x17 + configSize, // length3\n 0x00, 0x01, // es_id\n 0x00, // stream_priority\n\n 0x04, // descriptor_type\n 0x0F + configSize, // length\n 0x40, // codec: mpeg4_audio\n 0x15, // stream_type: Audio\n 0x00, 0x00, 0x00, // buffer_size\n 0x00, 0x00, 0x00, 0x00, // maxBitrate\n 0x00, 0x00, 0x00, 0x00, // avgBitrate\n\n 0x05 // descriptor_type\n ].concat([\n configSize\n ]).concat(\n config\n ).concat([\n 0x06, 0x01, 0x02 // GASpecificConfig\n ]));\n return MP4.box(MP4.types.esds, data);\n }\n\n static Opus(meta) {\n let channelCount = meta.channelCount;\n let sampleRate = meta.audioSampleRate;\n\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n 0x00, 0x00, 0x00, 0x01, // reserved(2) + data_reference_index(2)\n 0x00, 0x00, 0x00, 0x00, // reserved: 2 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, channelCount, // channelCount(2)\n 0x00, 0x10, // sampleSize(2)\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n (sampleRate >>> 8) & 0xFF, // Audio sample rate\n (sampleRate) & 0xFF,\n 0x00, 0x00\n ]);\n\n return MP4.box(MP4.types.Opus, data, MP4.dOps(meta));\n }\n\n static dOps(meta) {\n let channelCount = meta.channelCount;\n let channelConfigCode = meta.channelConfigCode;\n let sampleRate = meta.audioSampleRate;\n\n if (meta.config) {\n return MP4.box(MP4.types.dOps, data);\n }\n\n let mapping = [];\n switch (channelConfigCode) {\n case 0x01:\n case 0x02:\n mapping = [0x0];\n break;\n case 0x00: // dualmono\n mapping = [0xFF, 1, 1, 0, 1];\n break;\n case 0x80: // dualmono\n mapping = [0xFF, 2, 0, 0, 1];\n break;\n case 0x03:\n mapping = [0x01, 2, 1, 0, 2, 1];\n break;\n case 0x04:\n mapping = [0x01, 2, 2, 0, 1, 2, 3];\n break;\n case 0x05:\n mapping = [0x01, 3, 2, 0, 4, 1, 2, 3];\n break;\n case 0x06:\n mapping = [0x01, 4, 2, 0, 4, 1, 2, 3, 5];\n break;\n case 0x07:\n mapping = [0x01, 4, 2, 0, 4, 1, 2, 3, 5, 6];\n break;\n case 0x08:\n mapping = [0x01, 5, 3, 0, 6, 1, 2, 3, 4, 5, 7];\n break;\n case 0x82:\n mapping = [0x01, 1, 2, 0, 1];\n break;\n case 0x83:\n mapping = [0x01, 1, 3, 0, 1, 2];\n break;\n case 0x84:\n mapping = [0x01, 1, 4, 0, 1, 2, 3];\n break;\n case 0x85:\n mapping = [0x01, 1, 5, 0, 1, 2, 3, 4];\n break;\n case 0x86:\n mapping = [0x01, 1, 6, 0, 1, 2, 3, 4, 5];\n break;\n case 0x87:\n mapping = [0x01, 1, 7, 0, 1, 2, 3, 4, 5, 6];\n break;\n case 0x88:\n mapping = [0x01, 1, 8, 0, 1, 2, 3, 4, 5, 6, 7];\n break;\n }\n\n let data = new Uint8Array([\n 0x00, // Version (1)\n channelCount, // OutputChannelCount: 2\n 0x00, 0x00, // PreSkip: 2\n (sampleRate >>> 24) & 0xFF, // Audio sample rate: 4\n (sampleRate >>> 17) & 0xFF,\n (sampleRate >>> 8) & 0xFF,\n (sampleRate >>> 0) & 0xFF,\n 0x00, 0x00, // Global Gain : 2\n ... mapping\n ]);\n return MP4.box(MP4.types.dOps, data);\n }\n\n static avc1(meta) {\n let avcc = meta.avcc;\n let width = meta.codecWidth, height = meta.codecHeight;\n\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n 0x00, 0x00, 0x00, 0x01, // reserved(2) + data_reference_index(2)\n 0x00, 0x00, 0x00, 0x00, // pre_defined(2) + reserved(2)\n 0x00, 0x00, 0x00, 0x00, // pre_defined: 3 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n (width >>> 8) & 0xFF, // width: 2 bytes\n (width) & 0xFF,\n (height >>> 8) & 0xFF, // height: 2 bytes\n (height) & 0xFF,\n 0x00, 0x48, 0x00, 0x00, // horizresolution: 4 bytes\n 0x00, 0x48, 0x00, 0x00, // vertresolution: 4 bytes\n 0x00, 0x00, 0x00, 0x00, // reserved: 4 bytes\n 0x00, 0x01, // frame_count\n 0x0A, // strlen\n 0x78, 0x71, 0x71, 0x2F, // compressorname: 32 bytes\n 0x66, 0x6C, 0x76, 0x2E,\n 0x6A, 0x73, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00,\n 0x00, 0x18, // depth\n 0xFF, 0xFF // pre_defined = -1\n ]);\n return MP4.box(MP4.types.avc1, data, MP4.box(MP4.types.avcC, avcc));\n }\n\n static hvc1(meta) {\n let hvcc = meta.hvcc;\n let width = meta.codecWidth, height = meta.codecHeight;\n\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // reserved(4)\n 0x00, 0x00, 0x00, 0x01, // reserved(2) + data_reference_index(2)\n 0x00, 0x00, 0x00, 0x00, // pre_defined(2) + reserved(2)\n 0x00, 0x00, 0x00, 0x00, // pre_defined: 3 * 4 bytes\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n (width >>> 8) & 0xFF, // width: 2 bytes\n (width) & 0xFF,\n (height >>> 8) & 0xFF, // height: 2 bytes\n (height) & 0xFF,\n 0x00, 0x48, 0x00, 0x00, // horizresolution: 4 bytes\n 0x00, 0x48, 0x00, 0x00, // vertresolution: 4 bytes\n 0x00, 0x00, 0x00, 0x00, // reserved: 4 bytes\n 0x00, 0x01, // frame_count\n 0x0A, // strlen\n 0x78, 0x71, 0x71, 0x2F, // compressorname: 32 bytes\n 0x66, 0x6C, 0x76, 0x2E,\n 0x6A, 0x73, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00,\n 0x00, 0x18, // depth\n 0xFF, 0xFF // pre_defined = -1\n ]);\n return MP4.box(MP4.types.hvc1, data, MP4.box(MP4.types.hvcC, hvcc));\n }\n\n // Movie Extends box\n static mvex(meta) {\n return MP4.box(MP4.types.mvex, MP4.trex(meta));\n }\n\n // Track Extends box\n static trex(meta) {\n let trackId = meta.id;\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) + flags\n (trackId >>> 24) & 0xFF, // track_ID\n (trackId >>> 16) & 0xFF,\n (trackId >>> 8) & 0xFF,\n (trackId) & 0xFF,\n 0x00, 0x00, 0x00, 0x01, // default_sample_description_index\n 0x00, 0x00, 0x00, 0x00, // default_sample_duration\n 0x00, 0x00, 0x00, 0x00, // default_sample_size\n 0x00, 0x01, 0x00, 0x01 // default_sample_flags\n ]);\n return MP4.box(MP4.types.trex, data);\n }\n\n // Movie fragment box\n static moof(track, baseMediaDecodeTime) {\n return MP4.box(MP4.types.moof, MP4.mfhd(track.sequenceNumber), MP4.traf(track, baseMediaDecodeTime));\n }\n\n static mfhd(sequenceNumber) {\n let data = new Uint8Array([\n 0x00, 0x00, 0x00, 0x00,\n (sequenceNumber >>> 24) & 0xFF, // sequence_number: int32\n (sequenceNumber >>> 16) & 0xFF,\n (sequenceNumber >>> 8) & 0xFF,\n (sequenceNumber) & 0xFF\n ]);\n return MP4.box(MP4.types.mfhd, data);\n }\n\n // Track fragment box\n static traf(track, baseMediaDecodeTime) {\n let trackId = track.id;\n\n // Track fragment header box\n let tfhd = MP4.box(MP4.types.tfhd, new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) & flags\n (trackId >>> 24) & 0xFF, // track_ID\n (trackId >>> 16) & 0xFF,\n (trackId >>> 8) & 0xFF,\n (trackId) & 0xFF\n ]));\n // Track Fragment Decode Time\n let tfdt = MP4.box(MP4.types.tfdt, new Uint8Array([\n 0x00, 0x00, 0x00, 0x00, // version(0) & flags\n (baseMediaDecodeTime >>> 24) & 0xFF, // baseMediaDecodeTime: int32\n (baseMediaDecodeTime >>> 16) & 0xFF,\n (baseMediaDecodeTime >>> 8) & 0xFF,\n (baseMediaDecodeTime) & 0xFF\n ]));\n let sdtp = MP4.sdtp(track);\n let trun = MP4.trun(track, sdtp.byteLength + 16 + 16 + 8 + 16 + 8 + 8);\n\n return MP4.box(MP4.types.traf, tfhd, tfdt, trun, sdtp);\n }\n\n // Sample Dependency Type box\n static sdtp(track) {\n let samples = track.samples || [];\n let sampleCount = samples.length;\n let data = new Uint8Array(4 + sampleCount);\n // 0~4 bytes: version(0) & flags\n for (let i = 0; i < sampleCount; i++) {\n let flags = samples[i].flags;\n data[i + 4] = (flags.isLeading << 6) // is_leading: 2 (bit)\n | (flags.dependsOn << 4) // sample_depends_on\n | (flags.isDependedOn << 2) // sample_is_depended_on\n | (flags.hasRedundancy); // sample_has_redundancy\n }\n return MP4.box(MP4.types.sdtp, data);\n }\n\n // Track fragment run box\n static trun(track, offset) {\n let samples = track.samples || [];\n let sampleCount = samples.length;\n let dataSize = 12 + 16 * sampleCount;\n let data = new Uint8Array(dataSize);\n offset += 8 + dataSize;\n\n data.set([\n 0x00, 0x00, 0x0F, 0x01, // version(0) & flags\n (sampleCount >>> 24) & 0xFF, // sample_count\n (sampleCount >>> 16) & 0xFF,\n (sampleCount >>> 8) & 0xFF,\n (sampleCount) & 0xFF,\n (offset >>> 24) & 0xFF, // data_offset\n (offset >>> 16) & 0xFF,\n (offset >>> 8) & 0xFF,\n (offset) & 0xFF\n ], 0);\n\n for (let i = 0; i < sampleCount; i++) {\n let duration = samples[i].duration;\n let size = samples[i].size;\n let flags = samples[i].flags;\n let cts = samples[i].cts;\n data.set([\n (duration >>> 24) & 0xFF, // sample_duration\n (duration >>> 16) & 0xFF,\n (duration >>> 8) & 0xFF,\n (duration) & 0xFF,\n (size >>> 24) & 0xFF, // sample_size\n (size >>> 16) & 0xFF,\n (size >>> 8) & 0xFF,\n (size) & 0xFF,\n (flags.isLeading << 2) | flags.dependsOn, // sample_flags\n (flags.isDependedOn << 6) | (flags.hasRedundancy << 4) | flags.isNonSync,\n 0x00, 0x00, // sample_degradation_priority\n (cts >>> 24) & 0xFF, // sample_composition_time_offset\n (cts >>> 16) & 0xFF,\n (cts >>> 8) & 0xFF,\n (cts) & 0xFF\n ], 12 + 16 * i);\n }\n return MP4.box(MP4.types.trun, data);\n }\n\n static mdat(data) {\n return MP4.box(MP4.types.mdat, data);\n }\n\n}\n\nMP4.init();\n\nexport default MP4;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * This file is modified from dailymotion's hls.js library (hls.js/src/helper/aac.js)\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass AAC {\n\n static getSilentFrame(codec, channelCount) {\n if (codec === 'mp4a.40.2') {\n // handle LC-AAC\n if (channelCount === 1) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x23, 0x80]);\n } else if (channelCount === 2) {\n return new Uint8Array([0x21, 0x00, 0x49, 0x90, 0x02, 0x19, 0x00, 0x23, 0x80]);\n } else if (channelCount === 3) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x20, 0x84, 0x01, 0x26, 0x40, 0x08, 0x64, 0x00, 0x8e]);\n } else if (channelCount === 4) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x20, 0x84, 0x01, 0x26, 0x40, 0x08, 0x64, 0x00, 0x80, 0x2c, 0x80, 0x08, 0x02, 0x38]);\n } else if (channelCount === 5) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x20, 0x84, 0x01, 0x26, 0x40, 0x08, 0x64, 0x00, 0x82, 0x30, 0x04, 0x99, 0x00, 0x21, 0x90, 0x02, 0x38]);\n } else if (channelCount === 6) {\n return new Uint8Array([0x00, 0xc8, 0x00, 0x80, 0x20, 0x84, 0x01, 0x26, 0x40, 0x08, 0x64, 0x00, 0x82, 0x30, 0x04, 0x99, 0x00, 0x21, 0x90, 0x02, 0x00, 0xb2, 0x00, 0x20, 0x08, 0xe0]);\n }\n } else {\n // handle HE-AAC (mp4a.40.5 / mp4a.40.29)\n if (channelCount === 1) {\n // ffmpeg -y -f lavfi -i \"aevalsrc=0:d=0.05\" -c:a libfdk_aac -profile:a aac_he -b:a 4k output.aac && hexdump -v -e '16/1 \"0x%x,\" \"\\n\"' -v output.aac\n return new Uint8Array([0x1, 0x40, 0x22, 0x80, 0xa3, 0x4e, 0xe6, 0x80, 0xba, 0x8, 0x0, 0x0, 0x0, 0x1c, 0x6, 0xf1, 0xc1, 0xa, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5e]);\n } else if (channelCount === 2) {\n // ffmpeg -y -f lavfi -i \"aevalsrc=0|0:d=0.05\" -c:a libfdk_aac -profile:a aac_he_v2 -b:a 4k output.aac && hexdump -v -e '16/1 \"0x%x,\" \"\\n\"' -v output.aac\n return new Uint8Array([0x1, 0x40, 0x22, 0x80, 0xa3, 0x5e, 0xe6, 0x80, 0xba, 0x8, 0x0, 0x0, 0x0, 0x0, 0x95, 0x0, 0x6, 0xf1, 0xa1, 0xa, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5e]);\n } else if (channelCount === 3) {\n // ffmpeg -y -f lavfi -i \"aevalsrc=0|0|0:d=0.05\" -c:a libfdk_aac -profile:a aac_he_v2 -b:a 4k output.aac && hexdump -v -e '16/1 \"0x%x,\" \"\\n\"' -v output.aac\n return new Uint8Array([0x1, 0x40, 0x22, 0x80, 0xa3, 0x5e, 0xe6, 0x80, 0xba, 0x8, 0x0, 0x0, 0x0, 0x0, 0x95, 0x0, 0x6, 0xf1, 0xa1, 0xa, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5e]);\n }\n }\n return null;\n }\n\n}\n\nexport default AAC;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport MP4 from './mp4-generator.js';\nimport AAC from './aac-silent.js';\nimport Browser from '../utils/browser.js';\nimport { SampleInfo, MediaSegmentInfo, MediaSegmentInfoList } from '../core/media-segment-info.js';\nimport { IllegalStateException } from '../utils/exception.js';\n\n\n// Fragmented mp4 remuxer\nclass MP4Remuxer {\n\n constructor(config) {\n this.TAG = 'MP4Remuxer';\n\n this._config = config;\n this._isLive = (config.isLive === true) ? true : false;\n\n this._dtsBase = -1;\n this._dtsBaseInited = false;\n this._audioDtsBase = Infinity;\n this._videoDtsBase = Infinity;\n this._audioNextDts = undefined;\n this._videoNextDts = undefined;\n this._audioStashedLastSample = null;\n this._videoStashedLastSample = null;\n\n this._audioMeta = null;\n this._videoMeta = null;\n\n this._audioSegmentInfoList = new MediaSegmentInfoList('audio');\n this._videoSegmentInfoList = new MediaSegmentInfoList('video');\n\n this._onInitSegment = null;\n this._onMediaSegment = null;\n\n // Workaround for chrome < 50: Always force first sample as a Random Access Point in media segment\n // see https://bugs.chromium.org/p/chromium/issues/detail?id=229412\n this._forceFirstIDR = (Browser.chrome &&\n (Browser.version.major < 50 ||\n (Browser.version.major === 50 && Browser.version.build < 2661))) ? true : false;\n\n // Workaround for IE11/Edge: Fill silent aac frame after keyframe-seeking\n // Make audio beginDts equals with video beginDts, in order to fix seek freeze\n this._fillSilentAfterSeek = (Browser.msedge || Browser.msie);\n\n // While only FireFox supports 'audio/mp4, codecs=\"mp3\"', use 'audio/mpeg' for chrome, safari, ...\n this._mp3UseMpegAudio = !Browser.firefox;\n\n this._fillAudioTimestampGap = this._config.fixAudioTimestampGap;\n }\n\n destroy() {\n this._dtsBase = -1;\n this._dtsBaseInited = false;\n this._audioMeta = null;\n this._videoMeta = null;\n this._audioSegmentInfoList.clear();\n this._audioSegmentInfoList = null;\n this._videoSegmentInfoList.clear();\n this._videoSegmentInfoList = null;\n this._onInitSegment = null;\n this._onMediaSegment = null;\n }\n\n bindDataSource(producer) {\n producer.onDataAvailable = this.remux.bind(this);\n producer.onTrackMetadata = this._onTrackMetadataReceived.bind(this);\n return this;\n }\n\n /* prototype: function onInitSegment(type: string, initSegment: ArrayBuffer): void\n InitSegment: {\n type: string,\n data: ArrayBuffer,\n codec: string,\n container: string\n }\n */\n get onInitSegment() {\n return this._onInitSegment;\n }\n\n set onInitSegment(callback) {\n this._onInitSegment = callback;\n }\n\n /* prototype: function onMediaSegment(type: string, mediaSegment: MediaSegment): void\n MediaSegment: {\n type: string,\n data: ArrayBuffer,\n sampleCount: int32\n info: MediaSegmentInfo\n }\n */\n get onMediaSegment() {\n return this._onMediaSegment;\n }\n\n set onMediaSegment(callback) {\n this._onMediaSegment = callback;\n }\n\n insertDiscontinuity() {\n this._audioNextDts = this._videoNextDts = undefined;\n }\n\n seek(originalDts) {\n this._audioStashedLastSample = null;\n this._videoStashedLastSample = null;\n this._videoSegmentInfoList.clear();\n this._audioSegmentInfoList.clear();\n }\n\n remux(audioTrack, videoTrack) {\n if (!this._onMediaSegment) {\n throw new IllegalStateException('MP4Remuxer: onMediaSegment callback must be specificed!');\n }\n if (!this._dtsBaseInited) {\n this._calculateDtsBase(audioTrack, videoTrack);\n }\n if (videoTrack) {\n this._remuxVideo(videoTrack);\n }\n if (audioTrack) {\n this._remuxAudio(audioTrack);\n }\n }\n\n _onTrackMetadataReceived(type, metadata) {\n let metabox = null;\n\n let container = 'mp4';\n let codec = metadata.codec;\n\n if (type === 'audio') {\n this._audioMeta = metadata;\n if (metadata.codec === 'mp3' && this._mp3UseMpegAudio) {\n // 'audio/mpeg' for MP3 audio track\n container = 'mpeg';\n codec = '';\n metabox = new Uint8Array();\n } else {\n // 'audio/mp4, codecs=\"codec\"'\n metabox = MP4.generateInitSegment(metadata);\n }\n } else if (type === 'video') {\n this._videoMeta = metadata;\n metabox = MP4.generateInitSegment(metadata);\n } else {\n return;\n }\n\n // dispatch metabox (Initialization Segment)\n if (!this._onInitSegment) {\n throw new IllegalStateException('MP4Remuxer: onInitSegment callback must be specified!');\n }\n this._onInitSegment(type, {\n type: type,\n data: metabox.buffer,\n codec: codec,\n container: `${type}/${container}`,\n mediaDuration: metadata.duration // in timescale 1000 (milliseconds)\n });\n }\n\n _calculateDtsBase(audioTrack, videoTrack) {\n if (this._dtsBaseInited) {\n return;\n }\n\n if (audioTrack && audioTrack.samples && audioTrack.samples.length) {\n this._audioDtsBase = audioTrack.samples[0].dts;\n }\n if (videoTrack && videoTrack.samples && videoTrack.samples.length) {\n this._videoDtsBase = videoTrack.samples[0].dts;\n }\n\n this._dtsBase = Math.min(this._audioDtsBase, this._videoDtsBase);\n this._dtsBaseInited = true;\n }\n\n getTimestampBase() {\n if (!this._dtsBaseInited) {\n return undefined;\n }\n return this._dtsBase;\n }\n\n flushStashedSamples() {\n let videoSample = this._videoStashedLastSample;\n let audioSample = this._audioStashedLastSample;\n\n let videoTrack = {\n type: 'video',\n id: 1,\n sequenceNumber: 0,\n samples: [],\n length: 0\n };\n\n if (videoSample != null) {\n videoTrack.samples.push(videoSample);\n videoTrack.length = videoSample.length;\n }\n\n let audioTrack = {\n type: 'audio',\n id: 2,\n sequenceNumber: 0,\n samples: [],\n length: 0\n };\n\n if (audioSample != null) {\n audioTrack.samples.push(audioSample);\n audioTrack.length = audioSample.length;\n }\n\n this._videoStashedLastSample = null;\n this._audioStashedLastSample = null;\n\n this._remuxVideo(videoTrack, true);\n this._remuxAudio(audioTrack, true);\n }\n\n _remuxAudio(audioTrack, force) {\n if (this._audioMeta == null) {\n return;\n }\n\n let track = audioTrack;\n let samples = track.samples;\n let dtsCorrection = undefined;\n let firstDts = -1, lastDts = -1, lastPts = -1;\n let refSampleDuration = this._audioMeta.refSampleDuration;\n\n let mpegRawTrack = this._audioMeta.codec === 'mp3' && this._mp3UseMpegAudio;\n let firstSegmentAfterSeek = this._dtsBaseInited && this._audioNextDts === undefined;\n\n let insertPrefixSilentFrame = false;\n\n if (!samples || samples.length === 0) {\n return;\n }\n if (samples.length === 1 && !force) {\n // If [sample count in current batch] === 1 && (force != true)\n // Ignore and keep in demuxer's queue\n return;\n } // else if (force === true) do remux\n\n let offset = 0;\n let mdatbox = null;\n let mdatBytes = 0;\n\n // calculate initial mdat size\n if (mpegRawTrack) {\n // for raw mpeg buffer\n offset = 0;\n mdatBytes = track.length;\n } else {\n // for fmp4 mdat box\n offset = 8; // size + type\n mdatBytes = 8 + track.length;\n }\n\n\n let lastSample = null;\n\n // Pop the lastSample and waiting for stash\n if (samples.length > 1) {\n lastSample = samples.pop();\n mdatBytes -= lastSample.length;\n }\n\n // Insert [stashed lastSample in the previous batch] to the front\n if (this._audioStashedLastSample != null) {\n let sample = this._audioStashedLastSample;\n this._audioStashedLastSample = null;\n samples.unshift(sample);\n mdatBytes += sample.length;\n }\n\n // Stash the lastSample of current batch, waiting for next batch\n if (lastSample != null) {\n this._audioStashedLastSample = lastSample;\n }\n\n\n let firstSampleOriginalDts = samples[0].dts - this._dtsBase;\n\n // calculate dtsCorrection\n if (this._audioNextDts) {\n dtsCorrection = firstSampleOriginalDts - this._audioNextDts;\n } else { // this._audioNextDts == undefined\n if (this._audioSegmentInfoList.isEmpty()) {\n dtsCorrection = 0;\n if (this._fillSilentAfterSeek && !this._videoSegmentInfoList.isEmpty()) {\n if (this._audioMeta.originalCodec !== 'mp3') {\n insertPrefixSilentFrame = true;\n }\n }\n } else {\n let lastSample = this._audioSegmentInfoList.getLastSampleBefore(firstSampleOriginalDts);\n if (lastSample != null) {\n let distance = (firstSampleOriginalDts - (lastSample.originalDts + lastSample.duration));\n if (distance <= 3) {\n distance = 0;\n }\n let expectedDts = lastSample.dts + lastSample.duration + distance;\n dtsCorrection = firstSampleOriginalDts - expectedDts;\n } else { // lastSample == null, cannot found\n dtsCorrection = 0;\n }\n }\n }\n\n if (insertPrefixSilentFrame) {\n // align audio segment beginDts to match with current video segment's beginDts\n let firstSampleDts = firstSampleOriginalDts - dtsCorrection;\n let videoSegment = this._videoSegmentInfoList.getLastSegmentBefore(firstSampleOriginalDts);\n if (videoSegment != null && videoSegment.beginDts < firstSampleDts) {\n let silentUnit = AAC.getSilentFrame(this._audioMeta.originalCodec, this._audioMeta.channelCount);\n if (silentUnit) {\n let dts = videoSegment.beginDts;\n let silentFrameDuration = firstSampleDts - videoSegment.beginDts;\n Log.v(this.TAG, `InsertPrefixSilentAudio: dts: ${dts}, duration: ${silentFrameDuration}`);\n samples.unshift({ unit: silentUnit, dts: dts, pts: dts });\n mdatBytes += silentUnit.byteLength;\n } // silentUnit == null: Cannot generate, skip\n } else {\n insertPrefixSilentFrame = false;\n }\n }\n\n let mp4Samples = [];\n\n // Correct dts for each sample, and calculate sample duration. Then output to mp4Samples\n for (let i = 0; i < samples.length; i++) {\n let sample = samples[i];\n let unit = sample.unit;\n let originalDts = sample.dts - this._dtsBase;\n let dts = originalDts;\n let needFillSilentFrames = false;\n let silentFrames = null;\n let sampleDuration = 0;\n\n if (originalDts < -0.001) {\n continue; //pass the first sample with the invalid dts\n }\n\n if (this._audioMeta.codec !== 'mp3') {\n // for AAC codec, we need to keep dts increase based on refSampleDuration\n let curRefDts = originalDts;\n const maxAudioFramesDrift = 3;\n if (this._audioNextDts) {\n curRefDts = this._audioNextDts;\n }\n\n dtsCorrection = originalDts - curRefDts;\n if (dtsCorrection <= -maxAudioFramesDrift * refSampleDuration) {\n // If we're overlapping by more than maxAudioFramesDrift number of frame, drop this sample\n Log.w(this.TAG, `Dropping 1 audio frame (originalDts: ${originalDts} ms ,curRefDts: ${curRefDts} ms) due to dtsCorrection: ${dtsCorrection} ms overlap.`);\n continue;\n }\n else if (dtsCorrection >= maxAudioFramesDrift * refSampleDuration && this._fillAudioTimestampGap && !Browser.safari) {\n // Silent frame generation, if large timestamp gap detected && config.fixAudioTimestampGap\n needFillSilentFrames = true;\n // We need to insert silent frames to fill timestamp gap\n let frameCount = Math.floor(dtsCorrection / refSampleDuration);\n Log.w(this.TAG, 'Large audio timestamp gap detected, may cause AV sync to drift. ' +\n 'Silent frames will be generated to avoid unsync.\\n' +\n `originalDts: ${originalDts} ms, curRefDts: ${curRefDts} ms, ` +\n `dtsCorrection: ${Math.round(dtsCorrection)} ms, generate: ${frameCount} frames`);\n\n\n dts = Math.floor(curRefDts);\n sampleDuration = Math.floor(curRefDts + refSampleDuration) - dts;\n\n let silentUnit = AAC.getSilentFrame(this._audioMeta.originalCodec, this._audioMeta.channelCount);\n if (silentUnit == null) {\n Log.w(this.TAG, 'Unable to generate silent frame for ' +\n `${this._audioMeta.originalCodec} with ${this._audioMeta.channelCount} channels, repeat last frame`);\n // Repeat last frame\n silentUnit = unit;\n }\n silentFrames = [];\n\n for (let j = 0; j < frameCount; j++) {\n curRefDts = curRefDts + refSampleDuration;\n let intDts = Math.floor(curRefDts); // change to integer\n let intDuration = Math.floor(curRefDts + refSampleDuration) - intDts;\n let frame = {\n dts: intDts,\n pts: intDts,\n cts: 0,\n unit: silentUnit,\n size: silentUnit.byteLength,\n duration: intDuration, // wait for next sample\n originalDts: originalDts,\n flags: {\n isLeading: 0,\n dependsOn: 1,\n isDependedOn: 0,\n hasRedundancy: 0\n }\n };\n silentFrames.push(frame);\n mdatBytes += frame.size;;\n\n }\n\n this._audioNextDts = curRefDts + refSampleDuration;\n\n } else {\n\n dts = Math.floor(curRefDts);\n sampleDuration = Math.floor(curRefDts + refSampleDuration) - dts;\n this._audioNextDts = curRefDts + refSampleDuration;\n\n }\n } else {\n // keep the original dts calculate algorithm for mp3\n dts = originalDts - dtsCorrection;\n\n\n if (i !== samples.length - 1) {\n let nextDts = samples[i + 1].dts - this._dtsBase - dtsCorrection;\n sampleDuration = nextDts - dts;\n } else { // the last sample\n if (lastSample != null) { // use stashed sample's dts to calculate sample duration\n let nextDts = lastSample.dts - this._dtsBase - dtsCorrection;\n sampleDuration = nextDts - dts;\n } else if (mp4Samples.length >= 1) { // use second last sample duration\n sampleDuration = mp4Samples[mp4Samples.length - 1].duration;\n } else { // the only one sample, use reference sample duration\n sampleDuration = Math.floor(refSampleDuration);\n }\n }\n this._audioNextDts = dts + sampleDuration;\n }\n\n if (firstDts === -1) {\n firstDts = dts;\n }\n mp4Samples.push({\n dts: dts,\n pts: dts,\n cts: 0,\n unit: sample.unit,\n size: sample.unit.byteLength,\n duration: sampleDuration,\n originalDts: originalDts,\n flags: {\n isLeading: 0,\n dependsOn: 1,\n isDependedOn: 0,\n hasRedundancy: 0\n }\n });\n\n if (needFillSilentFrames) {\n // Silent frames should be inserted after wrong-duration frame\n mp4Samples.push.apply(mp4Samples, silentFrames);\n }\n }\n\n if (mp4Samples.length === 0) {\n //no samples need to remux\n track.samples = [];\n track.length = 0;\n return;\n }\n\n // allocate mdatbox\n if (mpegRawTrack) {\n // allocate for raw mpeg buffer\n mdatbox = new Uint8Array(mdatBytes);\n } else {\n // allocate for fmp4 mdat box\n mdatbox = new Uint8Array(mdatBytes);\n // size field\n mdatbox[0] = (mdatBytes >>> 24) & 0xFF;\n mdatbox[1] = (mdatBytes >>> 16) & 0xFF;\n mdatbox[2] = (mdatBytes >>> 8) & 0xFF;\n mdatbox[3] = (mdatBytes) & 0xFF;\n // type field (fourCC)\n mdatbox.set(MP4.types.mdat, 4);\n }\n\n // Write samples into mdatbox\n for (let i = 0; i < mp4Samples.length; i++) {\n let unit = mp4Samples[i].unit;\n mdatbox.set(unit, offset);\n offset += unit.byteLength;\n }\n\n let latest = mp4Samples[mp4Samples.length - 1];\n lastDts = latest.dts + latest.duration;\n //this._audioNextDts = lastDts;\n\n // fill media segment info & add to info list\n let info = new MediaSegmentInfo();\n info.beginDts = firstDts;\n info.endDts = lastDts;\n info.beginPts = firstDts;\n info.endPts = lastDts;\n info.originalBeginDts = mp4Samples[0].originalDts;\n info.originalEndDts = latest.originalDts + latest.duration;\n info.firstSample = new SampleInfo(mp4Samples[0].dts,\n mp4Samples[0].pts,\n mp4Samples[0].duration,\n mp4Samples[0].originalDts,\n false);\n info.lastSample = new SampleInfo(latest.dts,\n latest.pts,\n latest.duration,\n latest.originalDts,\n false);\n if (!this._isLive) {\n this._audioSegmentInfoList.append(info);\n }\n\n track.samples = mp4Samples;\n track.sequenceNumber++;\n\n let moofbox = null;\n\n if (mpegRawTrack) {\n // Generate empty buffer, because useless for raw mpeg\n moofbox = new Uint8Array();\n } else {\n // Generate moof for fmp4 segment\n moofbox = MP4.moof(track, firstDts);\n }\n\n track.samples = [];\n track.length = 0;\n\n let segment = {\n type: 'audio',\n data: this._mergeBoxes(moofbox, mdatbox).buffer,\n sampleCount: mp4Samples.length,\n info: info\n };\n\n if (mpegRawTrack && firstSegmentAfterSeek) {\n // For MPEG audio stream in MSE, if seeking occurred, before appending new buffer\n // We need explicitly set timestampOffset to the desired point in timeline for mpeg SourceBuffer.\n segment.timestampOffset = firstDts;\n }\n\n this._onMediaSegment('audio', segment);\n }\n\n _remuxVideo(videoTrack, force) {\n if (this._videoMeta == null) {\n return;\n }\n\n let track = videoTrack;\n let samples = track.samples;\n let dtsCorrection = undefined;\n let firstDts = -1, lastDts = -1;\n let firstPts = -1, lastPts = -1;\n\n if (!samples || samples.length === 0) {\n return;\n }\n if (samples.length === 1 && !force) {\n // If [sample count in current batch] === 1 && (force != true)\n // Ignore and keep in demuxer's queue\n return;\n } // else if (force === true) do remux\n\n let offset = 8;\n let mdatbox = null;\n let mdatBytes = 8 + videoTrack.length;\n\n\n let lastSample = null;\n\n // Pop the lastSample and waiting for stash\n if (samples.length > 1) {\n lastSample = samples.pop();\n mdatBytes -= lastSample.length;\n }\n\n // Insert [stashed lastSample in the previous batch] to the front\n if (this._videoStashedLastSample != null) {\n let sample = this._videoStashedLastSample;\n this._videoStashedLastSample = null;\n samples.unshift(sample);\n mdatBytes += sample.length;\n }\n\n // Stash the lastSample of current batch, waiting for next batch\n if (lastSample != null) {\n this._videoStashedLastSample = lastSample;\n }\n\n\n let firstSampleOriginalDts = samples[0].dts - this._dtsBase;\n\n // calculate dtsCorrection\n if (this._videoNextDts) {\n dtsCorrection = firstSampleOriginalDts - this._videoNextDts;\n } else { // this._videoNextDts == undefined\n if (this._videoSegmentInfoList.isEmpty()) {\n dtsCorrection = 0;\n } else {\n let lastSample = this._videoSegmentInfoList.getLastSampleBefore(firstSampleOriginalDts);\n if (lastSample != null) {\n let distance = (firstSampleOriginalDts - (lastSample.originalDts + lastSample.duration));\n if (distance <= 3) {\n distance = 0;\n }\n let expectedDts = lastSample.dts + lastSample.duration + distance;\n dtsCorrection = firstSampleOriginalDts - expectedDts;\n } else { // lastSample == null, cannot found\n dtsCorrection = 0;\n }\n }\n }\n\n let info = new MediaSegmentInfo();\n let mp4Samples = [];\n\n // Correct dts for each sample, and calculate sample duration. Then output to mp4Samples\n for (let i = 0; i < samples.length; i++) {\n let sample = samples[i];\n let originalDts = sample.dts - this._dtsBase;\n let isKeyframe = sample.isKeyframe;\n let dts = originalDts - dtsCorrection;\n let cts = sample.cts;\n let pts = dts + cts;\n\n if (firstDts === -1) {\n firstDts = dts;\n firstPts = pts;\n }\n\n let sampleDuration = 0;\n\n if (i !== samples.length - 1) {\n let nextDts = samples[i + 1].dts - this._dtsBase - dtsCorrection;\n sampleDuration = nextDts - dts;\n } else { // the last sample\n if (lastSample != null) { // use stashed sample's dts to calculate sample duration\n let nextDts = lastSample.dts - this._dtsBase - dtsCorrection;\n sampleDuration = nextDts - dts;\n } else if (mp4Samples.length >= 1) { // use second last sample duration\n sampleDuration = mp4Samples[mp4Samples.length - 1].duration;\n } else { // the only one sample, use reference sample duration\n sampleDuration = Math.floor(this._videoMeta.refSampleDuration);\n }\n }\n\n if (isKeyframe) {\n let syncPoint = new SampleInfo(dts, pts, sampleDuration, sample.dts, true);\n syncPoint.fileposition = sample.fileposition;\n info.appendSyncPoint(syncPoint);\n }\n\n mp4Samples.push({\n dts: dts,\n pts: pts,\n cts: cts,\n units: sample.units,\n size: sample.length,\n isKeyframe: isKeyframe,\n duration: sampleDuration,\n originalDts: originalDts,\n flags: {\n isLeading: 0,\n dependsOn: isKeyframe ? 2 : 1,\n isDependedOn: isKeyframe ? 1 : 0,\n hasRedundancy: 0,\n isNonSync: isKeyframe ? 0 : 1\n }\n });\n }\n\n // allocate mdatbox\n mdatbox = new Uint8Array(mdatBytes);\n mdatbox[0] = (mdatBytes >>> 24) & 0xFF;\n mdatbox[1] = (mdatBytes >>> 16) & 0xFF;\n mdatbox[2] = (mdatBytes >>> 8) & 0xFF;\n mdatbox[3] = (mdatBytes) & 0xFF;\n mdatbox.set(MP4.types.mdat, 4);\n\n // Write samples into mdatbox\n for (let i = 0; i < mp4Samples.length; i++) {\n let units = mp4Samples[i].units;\n while (units.length) {\n let unit = units.shift();\n let data = unit.data;\n mdatbox.set(data, offset);\n offset += data.byteLength;\n }\n }\n\n let latest = mp4Samples[mp4Samples.length - 1];\n lastDts = latest.dts + latest.duration;\n lastPts = latest.pts + latest.duration;\n this._videoNextDts = lastDts;\n\n // fill media segment info & add to info list\n info.beginDts = firstDts;\n info.endDts = lastDts;\n info.beginPts = firstPts;\n info.endPts = lastPts;\n info.originalBeginDts = mp4Samples[0].originalDts;\n info.originalEndDts = latest.originalDts + latest.duration;\n info.firstSample = new SampleInfo(mp4Samples[0].dts,\n mp4Samples[0].pts,\n mp4Samples[0].duration,\n mp4Samples[0].originalDts,\n mp4Samples[0].isKeyframe);\n info.lastSample = new SampleInfo(latest.dts,\n latest.pts,\n latest.duration,\n latest.originalDts,\n latest.isKeyframe);\n if (!this._isLive) {\n this._videoSegmentInfoList.append(info);\n }\n\n track.samples = mp4Samples;\n track.sequenceNumber++;\n\n // workaround for chrome < 50: force first sample as a random access point\n // see https://bugs.chromium.org/p/chromium/issues/detail?id=229412\n if (this._forceFirstIDR) {\n let flags = mp4Samples[0].flags;\n flags.dependsOn = 2;\n flags.isNonSync = 0;\n }\n\n let moofbox = MP4.moof(track, firstDts);\n track.samples = [];\n track.length = 0;\n\n this._onMediaSegment('video', {\n type: 'video',\n data: this._mergeBoxes(moofbox, mdatbox).buffer,\n sampleCount: mp4Samples.length,\n info: info\n });\n }\n\n _mergeBoxes(moof, mdat) {\n let result = new Uint8Array(moof.byteLength + mdat.byteLength);\n result.set(moof, 0);\n result.set(mdat, moof.byteLength);\n return result;\n }\n\n}\n\nexport default MP4Remuxer;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport Log from '../utils/logger.js';\nimport Browser from '../utils/browser.js';\nimport MediaInfo from './media-info.js';\nimport FLVDemuxer from '../demux/flv-demuxer.js';\nimport TSDemuxer from '../demux/ts-demuxer';\nimport MP4Remuxer from '../remux/mp4-remuxer.js';\nimport DemuxErrors from '../demux/demux-errors.js';\nimport IOController from '../io/io-controller.js';\nimport TransmuxingEvents from './transmuxing-events.js';\nimport {LoaderStatus, LoaderErrors} from '../io/loader.js';\n\n// Transmuxing (IO, Demuxing, Remuxing) controller, with multipart support\nclass TransmuxingController {\n\n constructor(mediaDataSource, config) {\n this.TAG = 'TransmuxingController';\n this._emitter = new EventEmitter();\n\n this._config = config;\n\n // treat single part media as multipart media, which has only one segment\n if (!mediaDataSource.segments) {\n mediaDataSource.segments = [{\n duration: mediaDataSource.duration,\n filesize: mediaDataSource.filesize,\n url: mediaDataSource.url\n }];\n }\n\n // fill in default IO params if not exists\n if (typeof mediaDataSource.cors !== 'boolean') {\n mediaDataSource.cors = true;\n }\n if (typeof mediaDataSource.withCredentials !== 'boolean') {\n mediaDataSource.withCredentials = false;\n }\n\n this._mediaDataSource = mediaDataSource;\n this._currentSegmentIndex = 0;\n let totalDuration = 0;\n\n this._mediaDataSource.segments.forEach((segment) => {\n // timestampBase for each segment, and calculate total duration\n segment.timestampBase = totalDuration;\n totalDuration += segment.duration;\n // params needed by IOController\n segment.cors = mediaDataSource.cors;\n segment.withCredentials = mediaDataSource.withCredentials;\n // referrer policy control, if exist\n if (config.referrerPolicy) {\n segment.referrerPolicy = config.referrerPolicy;\n }\n });\n\n if (!isNaN(totalDuration) && this._mediaDataSource.duration !== totalDuration) {\n this._mediaDataSource.duration = totalDuration;\n }\n\n this._mediaInfo = null;\n this._demuxer = null;\n this._remuxer = null;\n this._ioctl = null;\n\n this._pendingSeekTime = null;\n this._pendingResolveSeekPoint = null;\n\n this._statisticsReporter = null;\n }\n\n destroy() {\n this._mediaInfo = null;\n this._mediaDataSource = null;\n\n if (this._statisticsReporter) {\n this._disableStatisticsReporter();\n }\n if (this._ioctl) {\n this._ioctl.destroy();\n this._ioctl = null;\n }\n if (this._demuxer) {\n this._demuxer.destroy();\n this._demuxer = null;\n }\n if (this._remuxer) {\n this._remuxer.destroy();\n this._remuxer = null;\n }\n\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n start() {\n this._loadSegment(0);\n this._enableStatisticsReporter();\n }\n\n _loadSegment(segmentIndex, optionalFrom) {\n this._currentSegmentIndex = segmentIndex;\n let dataSource = this._mediaDataSource.segments[segmentIndex];\n\n let ioctl = this._ioctl = new IOController(dataSource, this._config, segmentIndex);\n ioctl.onError = this._onIOException.bind(this);\n ioctl.onSeeked = this._onIOSeeked.bind(this);\n ioctl.onComplete = this._onIOComplete.bind(this);\n ioctl.onRedirect = this._onIORedirect.bind(this);\n ioctl.onRecoveredEarlyEof = this._onIORecoveredEarlyEof.bind(this);\n\n if (optionalFrom) {\n this._demuxer.bindDataSource(this._ioctl);\n } else {\n ioctl.onDataArrival = this._onInitChunkArrival.bind(this);\n }\n\n ioctl.open(optionalFrom);\n }\n\n stop() {\n this._internalAbort();\n this._disableStatisticsReporter();\n }\n\n _internalAbort() {\n if (this._ioctl) {\n this._ioctl.destroy();\n this._ioctl = null;\n }\n }\n\n pause() { // take a rest\n if (this._ioctl && this._ioctl.isWorking()) {\n this._ioctl.pause();\n this._disableStatisticsReporter();\n }\n }\n\n resume() {\n if (this._ioctl && this._ioctl.isPaused()) {\n this._ioctl.resume();\n this._enableStatisticsReporter();\n }\n }\n\n seek(milliseconds) {\n if (this._mediaInfo == null || !this._mediaInfo.isSeekable()) {\n return;\n }\n\n let targetSegmentIndex = this._searchSegmentIndexContains(milliseconds);\n\n if (targetSegmentIndex === this._currentSegmentIndex) {\n // intra-segment seeking\n let segmentInfo = this._mediaInfo.segments[targetSegmentIndex];\n\n if (segmentInfo == undefined) {\n // current segment loading started, but mediainfo hasn't received yet\n // wait for the metadata loaded, then seek to expected position\n this._pendingSeekTime = milliseconds;\n } else {\n let keyframe = segmentInfo.getNearestKeyframe(milliseconds);\n this._remuxer.seek(keyframe.milliseconds);\n this._ioctl.seek(keyframe.fileposition);\n // Will be resolved in _onRemuxerMediaSegmentArrival()\n this._pendingResolveSeekPoint = keyframe.milliseconds;\n }\n } else {\n // cross-segment seeking\n let targetSegmentInfo = this._mediaInfo.segments[targetSegmentIndex];\n\n if (targetSegmentInfo == undefined) {\n // target segment hasn't been loaded. We need metadata then seek to expected time\n this._pendingSeekTime = milliseconds;\n this._internalAbort();\n this._remuxer.seek();\n this._remuxer.insertDiscontinuity();\n this._loadSegment(targetSegmentIndex);\n // Here we wait for the metadata loaded, then seek to expected position\n } else {\n // We have target segment's metadata, direct seek to target position\n let keyframe = targetSegmentInfo.getNearestKeyframe(milliseconds);\n this._internalAbort();\n this._remuxer.seek(milliseconds);\n this._remuxer.insertDiscontinuity();\n this._demuxer.resetMediaInfo();\n this._demuxer.timestampBase = this._mediaDataSource.segments[targetSegmentIndex].timestampBase;\n this._loadSegment(targetSegmentIndex, keyframe.fileposition);\n this._pendingResolveSeekPoint = keyframe.milliseconds;\n this._reportSegmentMediaInfo(targetSegmentIndex);\n }\n }\n\n this._enableStatisticsReporter();\n }\n\n _searchSegmentIndexContains(milliseconds) {\n let segments = this._mediaDataSource.segments;\n let idx = segments.length - 1;\n\n for (let i = 0; i < segments.length; i++) {\n if (milliseconds < segments[i].timestampBase) {\n idx = i - 1;\n break;\n }\n }\n return idx;\n }\n\n _onInitChunkArrival(data, byteStart) {\n let consumed = 0;\n\n if (byteStart > 0) {\n // IOController seeked immediately after opened, byteStart > 0 callback may received\n this._demuxer.bindDataSource(this._ioctl);\n this._demuxer.timestampBase = this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase;\n\n consumed = this._demuxer.parseChunks(data, byteStart);\n } else {\n // byteStart == 0, Initial data, probe it first\n let probeData = null;\n\n // Try probing input data as FLV first\n probeData = FLVDemuxer.probe(data);\n if (probeData.match) {\n // Hit as FLV\n this._setupFLVDemuxerRemuxer(probeData);\n consumed = this._demuxer.parseChunks(data, byteStart);\n }\n\n if (!probeData.match && !probeData.needMoreData) {\n // Non-FLV, try MPEG-TS probe\n probeData = TSDemuxer.probe(data);\n if (probeData.match) {\n // Hit as MPEG-TS\n this._setupTSDemuxerRemuxer(probeData);\n consumed = this._demuxer.parseChunks(data, byteStart);\n }\n }\n\n if (!probeData.match && !probeData.needMoreData) {\n // Both probing as FLV / MPEG-TS failed, report error\n probeData = null;\n Log.e(this.TAG, 'Non MPEG-TS/FLV, Unsupported media type!');\n Promise.resolve().then(() => {\n this._internalAbort();\n });\n this._emitter.emit(TransmuxingEvents.DEMUX_ERROR, DemuxErrors.FORMAT_UNSUPPORTED, 'Non MPEG-TS/FLV, Unsupported media type!');\n // Leave consumed as 0\n }\n }\n\n return consumed;\n }\n\n _setupFLVDemuxerRemuxer(probeData) {\n this._demuxer = new FLVDemuxer(probeData, this._config);\n\n if (!this._remuxer) {\n this._remuxer = new MP4Remuxer(this._config);\n }\n\n let mds = this._mediaDataSource;\n if (mds.duration != undefined && !isNaN(mds.duration)) {\n this._demuxer.overridedDuration = mds.duration;\n }\n if (typeof mds.hasAudio === 'boolean') {\n this._demuxer.overridedHasAudio = mds.hasAudio;\n }\n if (typeof mds.hasVideo === 'boolean') {\n this._demuxer.overridedHasVideo = mds.hasVideo;\n }\n\n this._demuxer.timestampBase = mds.segments[this._currentSegmentIndex].timestampBase;\n\n this._demuxer.onError = this._onDemuxException.bind(this);\n this._demuxer.onMediaInfo = this._onMediaInfo.bind(this);\n this._demuxer.onMetaDataArrived = this._onMetaDataArrived.bind(this);\n this._demuxer.onScriptDataArrived = this._onScriptDataArrived.bind(this);\n\n this._remuxer.bindDataSource(this._demuxer\n .bindDataSource(this._ioctl\n ));\n\n this._remuxer.onInitSegment = this._onRemuxerInitSegmentArrival.bind(this);\n this._remuxer.onMediaSegment = this._onRemuxerMediaSegmentArrival.bind(this);\n }\n\n _setupTSDemuxerRemuxer(probeData) {\n let demuxer = this._demuxer = new TSDemuxer(probeData, this._config);\n\n if (!this._remuxer) {\n this._remuxer = new MP4Remuxer(this._config);\n }\n\n demuxer.onError = this._onDemuxException.bind(this);\n demuxer.onMediaInfo = this._onMediaInfo.bind(this);\n demuxer.onMetaDataArrived = this._onMetaDataArrived.bind(this);\n demuxer.onTimedID3Metadata = this._onTimedID3Metadata.bind(this);\n demuxer.onSMPTE2038Metadata = this._onSMPTE2038Metadata.bind(this);\n demuxer.onSCTE35Metadata = this._onSCTE35Metadata.bind(this);\n demuxer.onPESPrivateDataDescriptor = this._onPESPrivateDataDescriptor.bind(this);\n demuxer.onPESPrivateData = this._onPESPrivateData.bind(this);\n\n this._remuxer.bindDataSource(this._demuxer);\n this._demuxer.bindDataSource(this._ioctl);\n\n this._remuxer.onInitSegment = this._onRemuxerInitSegmentArrival.bind(this);\n this._remuxer.onMediaSegment = this._onRemuxerMediaSegmentArrival.bind(this);\n }\n\n _onMediaInfo(mediaInfo) {\n if (this._mediaInfo == null) {\n // Store first segment's mediainfo as global mediaInfo\n this._mediaInfo = Object.assign({}, mediaInfo);\n this._mediaInfo.keyframesIndex = null;\n this._mediaInfo.segments = [];\n this._mediaInfo.segmentCount = this._mediaDataSource.segments.length;\n Object.setPrototypeOf(this._mediaInfo, MediaInfo.prototype);\n }\n\n let segmentInfo = Object.assign({}, mediaInfo);\n Object.setPrototypeOf(segmentInfo, MediaInfo.prototype);\n this._mediaInfo.segments[this._currentSegmentIndex] = segmentInfo;\n\n // notify mediaInfo update\n this._reportSegmentMediaInfo(this._currentSegmentIndex);\n\n if (this._pendingSeekTime != null) {\n Promise.resolve().then(() => {\n let target = this._pendingSeekTime;\n this._pendingSeekTime = null;\n this.seek(target);\n });\n }\n }\n\n _onMetaDataArrived(metadata) {\n this._emitter.emit(TransmuxingEvents.METADATA_ARRIVED, metadata);\n }\n\n _onScriptDataArrived(data) {\n this._emitter.emit(TransmuxingEvents.SCRIPTDATA_ARRIVED, data);\n }\n\n _onTimedID3Metadata(timed_id3_metadata) {\n let timestamp_base = this._remuxer.getTimestampBase();\n if (timestamp_base == undefined) { return; }\n\n if (timed_id3_metadata.pts != undefined) {\n timed_id3_metadata.pts -= timestamp_base;\n }\n\n if (timed_id3_metadata.dts != undefined) {\n timed_id3_metadata.dts -= timestamp_base;\n }\n\n this._emitter.emit(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, timed_id3_metadata);\n }\n\n _onSMPTE2038Metadata(smpte2038_metadata) {\n let timestamp_base = this._remuxer.getTimestampBase();\n if (timestamp_base == undefined) { return; }\n\n if (smpte2038_metadata.pts != undefined) {\n smpte2038_metadata.pts -= timestamp_base;\n }\n\n if (smpte2038_metadata.dts != undefined) {\n smpte2038_metadata.dts -= timestamp_base;\n }\n\n if (smpte2038_metadata.nearest_pts != undefined) {\n smpte2038_metadata.nearest_pts -= timestamp_base;\n }\n\n this._emitter.emit(TransmuxingEvents.SMPTE2038_METADATA_ARRIVED, smpte2038_metadata);\n }\n\n _onSCTE35Metadata(scte35) {\n let timestamp_base = this._remuxer.getTimestampBase();\n if (timestamp_base == undefined) { return; }\n\n if (scte35.pts != undefined) {\n scte35.pts -= timestamp_base;\n }\n\n if (scte35.nearest_pts != undefined) {\n scte35.nearest_pts -= timestamp_base;\n }\n\n this._emitter.emit(TransmuxingEvents.SCTE35_METADATA_ARRIVED, scte35);\n }\n\n _onPESPrivateDataDescriptor(descriptor) {\n this._emitter.emit(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, descriptor);\n }\n\n _onPESPrivateData(private_data) {\n let timestamp_base = this._remuxer.getTimestampBase();\n if (timestamp_base == undefined) { return; }\n\n if (private_data.pts != undefined) {\n private_data.pts -= timestamp_base;\n }\n\n if (private_data.nearest_pts != undefined) {\n private_data.nearest_pts -= timestamp_base;\n }\n\n if (private_data.dts != undefined) {\n private_data.dts -= timestamp_base;\n }\n\n this._emitter.emit(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, private_data);\n }\n\n _onIOSeeked() {\n this._remuxer.insertDiscontinuity();\n }\n\n _onIOComplete(extraData) {\n let segmentIndex = extraData;\n let nextSegmentIndex = segmentIndex + 1;\n\n if (nextSegmentIndex < this._mediaDataSource.segments.length) {\n this._internalAbort();\n if (this._remuxer) {\n this._remuxer.flushStashedSamples();\n }\n this._loadSegment(nextSegmentIndex);\n } else {\n if (this._remuxer) {\n this._remuxer.flushStashedSamples();\n }\n this._emitter.emit(TransmuxingEvents.LOADING_COMPLETE);\n this._disableStatisticsReporter();\n }\n }\n\n _onIORedirect(redirectedURL) {\n let segmentIndex = this._ioctl.extraData;\n this._mediaDataSource.segments[segmentIndex].redirectedURL = redirectedURL;\n }\n\n _onIORecoveredEarlyEof() {\n this._emitter.emit(TransmuxingEvents.RECOVERED_EARLY_EOF);\n }\n\n _onIOException(type, info) {\n Log.e(this.TAG, `IOException: type = ${type}, code = ${info.code}, msg = ${info.msg}`);\n this._emitter.emit(TransmuxingEvents.IO_ERROR, type, info);\n this._disableStatisticsReporter();\n }\n\n _onDemuxException(type, info) {\n Log.e(this.TAG, `DemuxException: type = ${type}, info = ${info}`);\n this._emitter.emit(TransmuxingEvents.DEMUX_ERROR, type, info);\n }\n\n _onRemuxerInitSegmentArrival(type, initSegment) {\n this._emitter.emit(TransmuxingEvents.INIT_SEGMENT, type, initSegment);\n }\n\n _onRemuxerMediaSegmentArrival(type, mediaSegment) {\n if (this._pendingSeekTime != null) {\n // Media segments after new-segment cross-seeking should be dropped.\n return;\n }\n this._emitter.emit(TransmuxingEvents.MEDIA_SEGMENT, type, mediaSegment);\n\n // Resolve pending seekPoint\n if (this._pendingResolveSeekPoint != null && type === 'video') {\n let syncPoints = mediaSegment.info.syncPoints;\n let seekpoint = this._pendingResolveSeekPoint;\n this._pendingResolveSeekPoint = null;\n\n // Safari: Pass PTS for recommend_seekpoint\n if (Browser.safari && syncPoints.length > 0 && syncPoints[0].originalDts === seekpoint) {\n seekpoint = syncPoints[0].pts;\n }\n // else: use original DTS (keyframe.milliseconds)\n\n this._emitter.emit(TransmuxingEvents.RECOMMEND_SEEKPOINT, seekpoint);\n }\n }\n\n _enableStatisticsReporter() {\n if (this._statisticsReporter == null) {\n this._statisticsReporter = self.setInterval(\n this._reportStatisticsInfo.bind(this),\n this._config.statisticsInfoReportInterval);\n }\n }\n\n _disableStatisticsReporter() {\n if (this._statisticsReporter) {\n self.clearInterval(this._statisticsReporter);\n this._statisticsReporter = null;\n }\n }\n\n _reportSegmentMediaInfo(segmentIndex) {\n let segmentInfo = this._mediaInfo.segments[segmentIndex];\n let exportInfo = Object.assign({}, segmentInfo);\n\n exportInfo.duration = this._mediaInfo.duration;\n exportInfo.segmentCount = this._mediaInfo.segmentCount;\n delete exportInfo.segments;\n delete exportInfo.keyframesIndex;\n\n this._emitter.emit(TransmuxingEvents.MEDIA_INFO, exportInfo);\n }\n\n _reportStatisticsInfo() {\n let info = {};\n\n info.url = this._ioctl.currentURL;\n info.hasRedirect = this._ioctl.hasRedirect;\n if (info.hasRedirect) {\n info.redirectedURL = this._ioctl.currentRedirectedURL;\n }\n\n info.speed = this._ioctl.currentSpeed;\n info.loaderType = this._ioctl.loaderType;\n info.currentSegmentIndex = this._currentSegmentIndex;\n info.totalSegmentCount = this._mediaDataSource.segments.length;\n\n this._emitter.emit(TransmuxingEvents.STATISTICS_INFO, info);\n }\n\n}\n\nexport default TransmuxingController;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Utility class to calculate realtime network I/O speed\nclass SpeedSampler {\n\n constructor() {\n // milliseconds\n this._firstCheckpoint = 0;\n this._lastCheckpoint = 0;\n this._intervalBytes = 0;\n this._totalBytes = 0;\n this._lastSecondBytes = 0;\n\n // compatibility detection\n if (self.performance && self.performance.now) {\n this._now = self.performance.now.bind(self.performance);\n } else {\n this._now = Date.now;\n }\n }\n\n reset() {\n this._firstCheckpoint = this._lastCheckpoint = 0;\n this._totalBytes = this._intervalBytes = 0;\n this._lastSecondBytes = 0;\n }\n\n addBytes(bytes) {\n if (this._firstCheckpoint === 0) {\n this._firstCheckpoint = this._now();\n this._lastCheckpoint = this._firstCheckpoint;\n this._intervalBytes += bytes;\n this._totalBytes += bytes;\n } else if (this._now() - this._lastCheckpoint < 1000) {\n this._intervalBytes += bytes;\n this._totalBytes += bytes;\n } else { // duration >= 1000\n this._lastSecondBytes = this._intervalBytes;\n this._intervalBytes = bytes;\n this._totalBytes += bytes;\n this._lastCheckpoint = this._now();\n }\n }\n\n get currentKBps() {\n this.addBytes(0);\n\n let durationSeconds = (this._now() - this._lastCheckpoint) / 1000;\n if (durationSeconds == 0) durationSeconds = 1;\n return (this._intervalBytes / durationSeconds) / 1024;\n }\n\n get lastSecondKBps() {\n this.addBytes(0);\n\n if (this._lastSecondBytes !== 0) {\n return this._lastSecondBytes / 1024;\n } else { // lastSecondBytes === 0\n if (this._now() - this._lastCheckpoint >= 500) {\n // if time interval since last checkpoint has exceeded 500ms\n // the speed is nearly accurate\n return this.currentKBps;\n } else {\n // We don't know\n return 0;\n }\n }\n }\n\n get averageKBps() {\n let durationSeconds = (this._now() - this._firstCheckpoint) / 1000;\n return (this._totalBytes / durationSeconds) / 1024;\n }\n\n}\n\nexport default SpeedSampler;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport Browser from '../utils/browser.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './loader.js';\nimport {RuntimeException} from '../utils/exception.js';\n\n/* fetch + stream IO loader. Currently working on chrome 43+.\n * fetch provides a better alternative http API to XMLHttpRequest\n *\n * fetch spec https://fetch.spec.whatwg.org/\n * stream spec https://streams.spec.whatwg.org/\n */\nclass FetchStreamLoader extends BaseLoader {\n\n static isSupported() {\n try {\n // fetch + stream is broken on Microsoft Edge. Disable before build 15048.\n // see https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8196907/\n // Fixed in Jan 10, 2017. Build 15048+ removed from blacklist.\n let isWorkWellEdge = Browser.msedge && Browser.version.minor >= 15048;\n let browserNotBlacklisted = Browser.msedge ? isWorkWellEdge : true;\n return (self.fetch && self.ReadableStream && browserNotBlacklisted);\n } catch (e) {\n return false;\n }\n }\n\n constructor(seekHandler, config) {\n super('fetch-stream-loader');\n this.TAG = 'FetchStreamLoader';\n\n this._seekHandler = seekHandler;\n this._config = config;\n this._needStash = true;\n\n this._requestAbort = false;\n this._abortController = null;\n this._contentLength = null;\n this._receivedLength = 0;\n }\n\n destroy() {\n if (this.isWorking()) {\n this.abort();\n }\n super.destroy();\n }\n\n open(dataSource, range) {\n this._dataSource = dataSource;\n this._range = range;\n\n let sourceURL = dataSource.url;\n if (this._config.reuseRedirectedURL && dataSource.redirectedURL != undefined) {\n sourceURL = dataSource.redirectedURL;\n }\n\n let seekConfig = this._seekHandler.getConfig(sourceURL, range);\n\n let headers = new self.Headers();\n\n if (typeof seekConfig.headers === 'object') {\n let configHeaders = seekConfig.headers;\n for (let key in configHeaders) {\n if (configHeaders.hasOwnProperty(key)) {\n headers.append(key, configHeaders[key]);\n }\n }\n }\n\n let params = {\n method: 'GET',\n headers: headers,\n mode: 'cors',\n cache: 'default',\n // The default policy of Fetch API in the whatwg standard\n // Safari incorrectly indicates 'no-referrer' as default policy, fuck it\n referrerPolicy: 'no-referrer-when-downgrade'\n };\n\n // add additional headers\n if (typeof this._config.headers === 'object') {\n for (let key in this._config.headers) {\n headers.append(key, this._config.headers[key]);\n }\n }\n\n // cors is enabled by default\n if (dataSource.cors === false) {\n // no-cors means 'disregard cors policy', which can only be used in ServiceWorker\n params.mode = 'same-origin';\n }\n\n // withCredentials is disabled by default\n if (dataSource.withCredentials) {\n params.credentials = 'include';\n }\n\n // referrerPolicy from config\n if (dataSource.referrerPolicy) {\n params.referrerPolicy = dataSource.referrerPolicy;\n }\n\n if (self.AbortController) {\n this._abortController = new self.AbortController();\n params.signal = this._abortController.signal;\n }\n\n this._status = LoaderStatus.kConnecting;\n self.fetch(seekConfig.url, params).then((res) => {\n if (this._requestAbort) {\n this._status = LoaderStatus.kIdle;\n res.body.cancel();\n return;\n }\n if (res.ok && (res.status >= 200 && res.status <= 299)) {\n if (res.url !== seekConfig.url) {\n if (this._onURLRedirect) {\n let redirectedURL = this._seekHandler.removeURLParameters(res.url);\n this._onURLRedirect(redirectedURL);\n }\n }\n\n let lengthHeader = res.headers.get('Content-Length');\n if (lengthHeader != null) {\n this._contentLength = parseInt(lengthHeader);\n if (this._contentLength !== 0) {\n if (this._onContentLengthKnown) {\n this._onContentLengthKnown(this._contentLength);\n }\n }\n }\n\n return this._pump.call(this, res.body.getReader());\n } else {\n this._status = LoaderStatus.kError;\n if (this._onError) {\n this._onError(LoaderErrors.HTTP_STATUS_CODE_INVALID, {code: res.status, msg: res.statusText});\n } else {\n throw new RuntimeException('FetchStreamLoader: Http code invalid, ' + res.status + ' ' + res.statusText);\n }\n }\n }).catch((e) => {\n if (this._abortController && this._abortController.signal.aborted) {\n return;\n }\n\n this._status = LoaderStatus.kError;\n if (this._onError) {\n this._onError(LoaderErrors.EXCEPTION, {code: -1, msg: e.message});\n } else {\n throw e;\n }\n });\n }\n\n abort() {\n this._requestAbort = true;\n\n if (this._status !== LoaderStatus.kBuffering || !Browser.chrome) {\n // Chrome may throw Exception-like things here, avoid using if is buffering\n if (this._abortController) {\n try {\n this._abortController.abort();\n } catch (e) {}\n }\n }\n }\n\n _pump(reader) { // ReadableStreamReader\n return reader.read().then((result) => {\n if (result.done) {\n // First check received length\n if (this._contentLength !== null && this._receivedLength < this._contentLength) {\n // Report Early-EOF\n this._status = LoaderStatus.kError;\n let type = LoaderErrors.EARLY_EOF;\n let info = {code: -1, msg: 'Fetch stream meet Early-EOF'};\n if (this._onError) {\n this._onError(type, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n } else {\n // OK. Download complete\n this._status = LoaderStatus.kComplete;\n if (this._onComplete) {\n this._onComplete(this._range.from, this._range.from + this._receivedLength - 1);\n }\n }\n } else {\n if (this._abortController && this._abortController.signal.aborted) {\n this._status = LoaderStatus.kComplete;\n return;\n } else if (this._requestAbort === true) {\n this._status = LoaderStatus.kComplete;\n return reader.cancel();\n }\n\n this._status = LoaderStatus.kBuffering;\n\n let chunk = result.value.buffer;\n let byteStart = this._range.from + this._receivedLength;\n this._receivedLength += chunk.byteLength;\n\n if (this._onDataArrival) {\n this._onDataArrival(chunk, byteStart, this._receivedLength);\n }\n\n this._pump(reader);\n }\n }).catch((e) => {\n if (this._abortController && this._abortController.signal.aborted) {\n this._status = LoaderStatus.kComplete;\n return;\n }\n\n if (e.code === 11 && Browser.msedge) { // InvalidStateError on Microsoft Edge\n // Workaround: Edge may throw InvalidStateError after ReadableStreamReader.cancel() call\n // Ignore the unknown exception.\n // Related issue: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/11265202/\n return;\n }\n\n this._status = LoaderStatus.kError;\n let type = 0;\n let info = null;\n\n if ((e.code === 19 || e.message === 'network error') && // NETWORK_ERR\n (this._contentLength === null ||\n (this._contentLength !== null && this._receivedLength < this._contentLength))) {\n type = LoaderErrors.EARLY_EOF;\n info = {code: e.code, msg: 'Fetch stream meet Early-EOF'};\n } else {\n type = LoaderErrors.EXCEPTION;\n info = {code: e.code, msg: e.message};\n }\n\n if (this._onError) {\n this._onError(type, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n });\n }\n\n}\n\nexport default FetchStreamLoader;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './loader.js';\nimport {RuntimeException} from '../utils/exception.js';\n\n// For FireFox browser which supports `xhr.responseType = 'moz-chunked-arraybuffer'`\nclass MozChunkedLoader extends BaseLoader {\n\n static isSupported() {\n try {\n let xhr = new XMLHttpRequest();\n // Firefox 37- requires .open() to be called before setting responseType\n xhr.open('GET', 'https://example.com', true);\n xhr.responseType = 'moz-chunked-arraybuffer';\n return (xhr.responseType === 'moz-chunked-arraybuffer');\n } catch (e) {\n Log.w('MozChunkedLoader', e.message);\n return false;\n }\n }\n\n constructor(seekHandler, config) {\n super('xhr-moz-chunked-loader');\n this.TAG = 'MozChunkedLoader';\n\n this._seekHandler = seekHandler;\n this._config = config;\n this._needStash = true;\n\n this._xhr = null;\n this._requestAbort = false;\n this._contentLength = null;\n this._receivedLength = 0;\n }\n\n destroy() {\n if (this.isWorking()) {\n this.abort();\n }\n if (this._xhr) {\n this._xhr.onreadystatechange = null;\n this._xhr.onprogress = null;\n this._xhr.onloadend = null;\n this._xhr.onerror = null;\n this._xhr = null;\n }\n super.destroy();\n }\n\n open(dataSource, range) {\n this._dataSource = dataSource;\n this._range = range;\n\n let sourceURL = dataSource.url;\n if (this._config.reuseRedirectedURL && dataSource.redirectedURL != undefined) {\n sourceURL = dataSource.redirectedURL;\n }\n\n let seekConfig = this._seekHandler.getConfig(sourceURL, range);\n this._requestURL = seekConfig.url;\n\n let xhr = this._xhr = new XMLHttpRequest();\n xhr.open('GET', seekConfig.url, true);\n xhr.responseType = 'moz-chunked-arraybuffer';\n xhr.onreadystatechange = this._onReadyStateChange.bind(this);\n xhr.onprogress = this._onProgress.bind(this);\n xhr.onloadend = this._onLoadEnd.bind(this);\n xhr.onerror = this._onXhrError.bind(this);\n\n // cors is auto detected and enabled by xhr\n\n // withCredentials is disabled by default\n if (dataSource.withCredentials) {\n xhr.withCredentials = true;\n }\n\n if (typeof seekConfig.headers === 'object') {\n let headers = seekConfig.headers;\n\n for (let key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n }\n\n // add additional headers\n if (typeof this._config.headers === 'object') {\n let headers = this._config.headers;\n\n for (let key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n }\n\n this._status = LoaderStatus.kConnecting;\n xhr.send();\n }\n\n abort() {\n this._requestAbort = true;\n if (this._xhr) {\n this._xhr.abort();\n }\n this._status = LoaderStatus.kComplete;\n }\n\n _onReadyStateChange(e) {\n let xhr = e.target;\n\n if (xhr.readyState === 2) { // HEADERS_RECEIVED\n if (xhr.responseURL != undefined && xhr.responseURL !== this._requestURL) {\n if (this._onURLRedirect) {\n let redirectedURL = this._seekHandler.removeURLParameters(xhr.responseURL);\n this._onURLRedirect(redirectedURL);\n }\n }\n\n if (xhr.status !== 0 && (xhr.status < 200 || xhr.status > 299)) {\n this._status = LoaderStatus.kError;\n if (this._onError) {\n this._onError(LoaderErrors.HTTP_STATUS_CODE_INVALID, {code: xhr.status, msg: xhr.statusText});\n } else {\n throw new RuntimeException('MozChunkedLoader: Http code invalid, ' + xhr.status + ' ' + xhr.statusText);\n }\n } else {\n this._status = LoaderStatus.kBuffering;\n }\n }\n }\n\n _onProgress(e) {\n if (this._status === LoaderStatus.kError) {\n // Ignore error response\n return;\n }\n\n if (this._contentLength === null) {\n if (e.total !== null && e.total !== 0) {\n this._contentLength = e.total;\n if (this._onContentLengthKnown) {\n this._onContentLengthKnown(this._contentLength);\n }\n }\n }\n\n let chunk = e.target.response;\n let byteStart = this._range.from + this._receivedLength;\n this._receivedLength += chunk.byteLength;\n\n if (this._onDataArrival) {\n this._onDataArrival(chunk, byteStart, this._receivedLength);\n }\n }\n\n _onLoadEnd(e) {\n if (this._requestAbort === true) {\n this._requestAbort = false;\n return;\n } else if (this._status === LoaderStatus.kError) {\n return;\n }\n\n this._status = LoaderStatus.kComplete;\n if (this._onComplete) {\n this._onComplete(this._range.from, this._range.from + this._receivedLength - 1);\n }\n }\n\n _onXhrError(e) {\n this._status = LoaderStatus.kError;\n let type = 0;\n let info = null;\n\n if (this._contentLength && e.loaded < this._contentLength) {\n type = LoaderErrors.EARLY_EOF;\n info = {code: -1, msg: 'Moz-Chunked stream meet Early-Eof'};\n } else {\n type = LoaderErrors.EXCEPTION;\n info = {code: -1, msg: e.constructor.name + ' ' + e.type};\n }\n\n if (this._onError) {\n this._onError(type, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n\n}\n\nexport default MozChunkedLoader;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport SpeedSampler from './speed-sampler.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './loader.js';\nimport {RuntimeException} from '../utils/exception.js';\n\n// Universal IO Loader, implemented by adding Range header in xhr's request header\nclass RangeLoader extends BaseLoader {\n\n static isSupported() {\n try {\n let xhr = new XMLHttpRequest();\n xhr.open('GET', 'https://example.com', true);\n xhr.responseType = 'arraybuffer';\n return (xhr.responseType === 'arraybuffer');\n } catch (e) {\n Log.w('RangeLoader', e.message);\n return false;\n }\n }\n\n constructor(seekHandler, config) {\n super('xhr-range-loader');\n this.TAG = 'RangeLoader';\n\n this._seekHandler = seekHandler;\n this._config = config;\n this._needStash = false;\n\n this._chunkSizeKBList = [\n 128, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 5120, 6144, 7168, 8192\n ];\n this._currentChunkSizeKB = 384;\n this._currentSpeedNormalized = 0;\n this._zeroSpeedChunkCount = 0;\n\n this._xhr = null;\n this._speedSampler = new SpeedSampler();\n\n this._requestAbort = false;\n this._waitForTotalLength = false;\n this._totalLengthReceived = false;\n\n this._currentRequestURL = null;\n this._currentRedirectedURL = null;\n this._currentRequestRange = null;\n this._totalLength = null; // size of the entire file\n this._contentLength = null; // Content-Length of entire request range\n this._receivedLength = 0; // total received bytes\n this._lastTimeLoaded = 0; // received bytes of current request sub-range\n }\n\n destroy() {\n if (this.isWorking()) {\n this.abort();\n }\n if (this._xhr) {\n this._xhr.onreadystatechange = null;\n this._xhr.onprogress = null;\n this._xhr.onload = null;\n this._xhr.onerror = null;\n this._xhr = null;\n }\n super.destroy();\n }\n\n get currentSpeed() {\n return this._speedSampler.lastSecondKBps;\n }\n\n open(dataSource, range) {\n this._dataSource = dataSource;\n this._range = range;\n this._status = LoaderStatus.kConnecting;\n\n let useRefTotalLength = false;\n if (this._dataSource.filesize != undefined && this._dataSource.filesize !== 0) {\n useRefTotalLength = true;\n this._totalLength = this._dataSource.filesize;\n }\n\n if (!this._totalLengthReceived && !useRefTotalLength) {\n // We need total filesize\n this._waitForTotalLength = true;\n this._internalOpen(this._dataSource, {from: 0, to: -1});\n } else {\n // We have filesize, start loading\n this._openSubRange();\n }\n }\n\n _openSubRange() {\n let chunkSize = this._currentChunkSizeKB * 1024;\n\n let from = this._range.from + this._receivedLength;\n let to = from + chunkSize;\n\n if (this._contentLength != null) {\n if (to - this._range.from >= this._contentLength) {\n to = this._range.from + this._contentLength - 1;\n }\n }\n\n this._currentRequestRange = {from, to};\n this._internalOpen(this._dataSource, this._currentRequestRange);\n }\n\n _internalOpen(dataSource, range) {\n this._lastTimeLoaded = 0;\n\n let sourceURL = dataSource.url;\n if (this._config.reuseRedirectedURL) {\n if (this._currentRedirectedURL != undefined) {\n sourceURL = this._currentRedirectedURL;\n } else if (dataSource.redirectedURL != undefined) {\n sourceURL = dataSource.redirectedURL;\n }\n }\n\n let seekConfig = this._seekHandler.getConfig(sourceURL, range);\n this._currentRequestURL = seekConfig.url;\n\n let xhr = this._xhr = new XMLHttpRequest();\n xhr.open('GET', seekConfig.url, true);\n xhr.responseType = 'arraybuffer';\n xhr.onreadystatechange = this._onReadyStateChange.bind(this);\n xhr.onprogress = this._onProgress.bind(this);\n xhr.onload = this._onLoad.bind(this);\n xhr.onerror = this._onXhrError.bind(this);\n\n if (dataSource.withCredentials) {\n xhr.withCredentials = true;\n }\n\n if (typeof seekConfig.headers === 'object') {\n let headers = seekConfig.headers;\n\n for (let key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n }\n\n // add additional headers\n if (typeof this._config.headers === 'object') {\n let headers = this._config.headers;\n\n for (let key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n }\n\n xhr.send();\n }\n\n abort() {\n this._requestAbort = true;\n this._internalAbort();\n this._status = LoaderStatus.kComplete;\n }\n\n _internalAbort() {\n if (this._xhr) {\n this._xhr.onreadystatechange = null;\n this._xhr.onprogress = null;\n this._xhr.onload = null;\n this._xhr.onerror = null;\n this._xhr.abort();\n this._xhr = null;\n }\n }\n\n _onReadyStateChange(e) {\n let xhr = e.target;\n\n if (xhr.readyState === 2) { // HEADERS_RECEIVED\n if (xhr.responseURL != undefined) { // if the browser support this property\n let redirectedURL = this._seekHandler.removeURLParameters(xhr.responseURL);\n if (xhr.responseURL !== this._currentRequestURL && redirectedURL !== this._currentRedirectedURL) {\n this._currentRedirectedURL = redirectedURL;\n if (this._onURLRedirect) {\n this._onURLRedirect(redirectedURL);\n }\n }\n }\n\n if ((xhr.status >= 200 && xhr.status <= 299)) {\n if (this._waitForTotalLength) {\n return;\n }\n this._status = LoaderStatus.kBuffering;\n } else {\n this._status = LoaderStatus.kError;\n if (this._onError) {\n this._onError(LoaderErrors.HTTP_STATUS_CODE_INVALID, {code: xhr.status, msg: xhr.statusText});\n } else {\n throw new RuntimeException('RangeLoader: Http code invalid, ' + xhr.status + ' ' + xhr.statusText);\n }\n }\n }\n }\n\n _onProgress(e) {\n if (this._status === LoaderStatus.kError) {\n // Ignore error response\n return;\n }\n\n if (this._contentLength === null) {\n let openNextRange = false;\n\n if (this._waitForTotalLength) {\n this._waitForTotalLength = false;\n this._totalLengthReceived = true;\n openNextRange = true;\n\n let total = e.total;\n this._internalAbort();\n if (total != null & total !== 0) {\n this._totalLength = total;\n }\n }\n\n // calculate currrent request range's contentLength\n if (this._range.to === -1) {\n this._contentLength = this._totalLength - this._range.from;\n } else { // to !== -1\n this._contentLength = this._range.to - this._range.from + 1;\n }\n\n if (openNextRange) {\n this._openSubRange();\n return;\n }\n if (this._onContentLengthKnown) {\n this._onContentLengthKnown(this._contentLength);\n }\n }\n\n let delta = e.loaded - this._lastTimeLoaded;\n this._lastTimeLoaded = e.loaded;\n this._speedSampler.addBytes(delta);\n }\n\n _normalizeSpeed(input) {\n let list = this._chunkSizeKBList;\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n if (input < list[0]) {\n return list[0];\n }\n\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (input >= list[mid] && input < list[mid + 1])) {\n return list[mid];\n } else if (list[mid] < input) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n }\n\n _onLoad(e) {\n if (this._status === LoaderStatus.kError) {\n // Ignore error response\n return;\n }\n\n if (this._waitForTotalLength) {\n this._waitForTotalLength = false;\n return;\n }\n\n this._lastTimeLoaded = 0;\n let KBps = this._speedSampler.lastSecondKBps;\n if (KBps === 0) {\n this._zeroSpeedChunkCount++;\n if (this._zeroSpeedChunkCount >= 3) {\n // Try get currentKBps after 3 chunks\n KBps = this._speedSampler.currentKBps;\n }\n }\n\n if (KBps !== 0) {\n let normalized = this._normalizeSpeed(KBps);\n if (this._currentSpeedNormalized !== normalized) {\n this._currentSpeedNormalized = normalized;\n this._currentChunkSizeKB = normalized;\n }\n }\n\n let chunk = e.target.response;\n let byteStart = this._range.from + this._receivedLength;\n this._receivedLength += chunk.byteLength;\n\n let reportComplete = false;\n\n if (this._contentLength != null && this._receivedLength < this._contentLength) {\n // continue load next chunk\n this._openSubRange();\n } else {\n reportComplete = true;\n }\n\n // dispatch received chunk\n if (this._onDataArrival) {\n this._onDataArrival(chunk, byteStart, this._receivedLength);\n }\n\n if (reportComplete) {\n this._status = LoaderStatus.kComplete;\n if (this._onComplete) {\n this._onComplete(this._range.from, this._range.from + this._receivedLength - 1);\n }\n }\n }\n\n _onXhrError(e) {\n this._status = LoaderStatus.kError;\n let type = 0;\n let info = null;\n\n if (this._contentLength && this._receivedLength > 0\n && this._receivedLength < this._contentLength) {\n type = LoaderErrors.EARLY_EOF;\n info = {code: -1, msg: 'RangeLoader meet Early-Eof'};\n } else {\n type = LoaderErrors.EXCEPTION;\n info = {code: -1, msg: e.constructor.name + ' ' + e.type};\n }\n\n if (this._onError) {\n this._onError(type, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n\n}\n\nexport default RangeLoader;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './loader.js';\nimport {RuntimeException} from '../utils/exception.js';\n\n// For MPEG-TS/FLV over WebSocket live stream\nclass WebSocketLoader extends BaseLoader {\n\n static isSupported() {\n try {\n return (typeof self.WebSocket !== 'undefined');\n } catch (e) {\n return false;\n }\n }\n\n constructor() {\n super('websocket-loader');\n this.TAG = 'WebSocketLoader';\n\n this._needStash = true;\n\n this._ws = null;\n this._requestAbort = false;\n this._receivedLength = 0;\n }\n\n destroy() {\n if (this._ws) {\n this.abort();\n }\n super.destroy();\n }\n\n open(dataSource) {\n try {\n let ws = this._ws = new self.WebSocket(dataSource.url);\n ws.binaryType = 'arraybuffer';\n ws.onopen = this._onWebSocketOpen.bind(this);\n ws.onclose = this._onWebSocketClose.bind(this);\n ws.onmessage = this._onWebSocketMessage.bind(this);\n ws.onerror = this._onWebSocketError.bind(this);\n\n this._status = LoaderStatus.kConnecting;\n } catch (e) {\n this._status = LoaderStatus.kError;\n\n let info = {code: e.code, msg: e.message};\n\n if (this._onError) {\n this._onError(LoaderErrors.EXCEPTION, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n }\n\n abort() {\n let ws = this._ws;\n if (ws && (ws.readyState === 0 || ws.readyState === 1)) { // CONNECTING || OPEN\n this._requestAbort = true;\n ws.close();\n }\n\n this._ws = null;\n this._status = LoaderStatus.kComplete;\n }\n\n _onWebSocketOpen(e) {\n this._status = LoaderStatus.kBuffering;\n }\n\n _onWebSocketClose(e) {\n if (this._requestAbort === true) {\n this._requestAbort = false;\n return;\n }\n\n this._status = LoaderStatus.kComplete;\n\n if (this._onComplete) {\n this._onComplete(0, this._receivedLength - 1);\n }\n }\n\n _onWebSocketMessage(e) {\n if (e.data instanceof ArrayBuffer) {\n this._dispatchArrayBuffer(e.data);\n } else if (e.data instanceof Blob) {\n let reader = new FileReader();\n reader.onload = () => {\n this._dispatchArrayBuffer(reader.result);\n };\n reader.readAsArrayBuffer(e.data);\n } else {\n this._status = LoaderStatus.kError;\n let info = {code: -1, msg: 'Unsupported WebSocket message type: ' + e.data.constructor.name};\n\n if (this._onError) {\n this._onError(LoaderErrors.EXCEPTION, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n }\n\n _dispatchArrayBuffer(arraybuffer) {\n let chunk = arraybuffer;\n let byteStart = this._receivedLength;\n this._receivedLength += chunk.byteLength;\n\n if (this._onDataArrival) {\n this._onDataArrival(chunk, byteStart, this._receivedLength);\n }\n }\n\n _onWebSocketError(e) {\n this._status = LoaderStatus.kError;\n\n let info = {\n code: e.code,\n msg: e.message\n };\n\n if (this._onError) {\n this._onError(LoaderErrors.EXCEPTION, info);\n } else {\n throw new RuntimeException(info.msg);\n }\n }\n\n}\n\nexport default WebSocketLoader;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass RangeSeekHandler {\n\n constructor(zeroStart) {\n this._zeroStart = zeroStart || false;\n }\n\n getConfig(url, range) {\n let headers = {};\n\n if (range.from !== 0 || range.to !== -1) {\n let param;\n if (range.to !== -1) {\n param = `bytes=${range.from.toString()}-${range.to.toString()}`;\n } else {\n param = `bytes=${range.from.toString()}-`;\n }\n headers['Range'] = param;\n } else if (this._zeroStart) {\n headers['Range'] = 'bytes=0-';\n }\n\n return {\n url: url,\n headers: headers\n };\n }\n\n removeURLParameters(seekedURL) {\n return seekedURL;\n }\n\n}\n\nexport default RangeSeekHandler;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass ParamSeekHandler {\n\n constructor(paramStart, paramEnd) {\n this._startName = paramStart;\n this._endName = paramEnd;\n }\n\n getConfig(baseUrl, range) {\n let url = baseUrl;\n\n if (range.from !== 0 || range.to !== -1) {\n let needAnd = true;\n if (url.indexOf('?') === -1) {\n url += '?';\n needAnd = false;\n }\n\n if (needAnd) {\n url += '&';\n }\n\n url += `${this._startName}=${range.from.toString()}`;\n\n if (range.to !== -1) {\n url += `&${this._endName}=${range.to.toString()}`;\n }\n }\n\n return {\n url: url,\n headers: {}\n };\n }\n\n removeURLParameters(seekedURL) {\n let baseURL = seekedURL.split('?')[0];\n let params = undefined;\n\n let queryIndex = seekedURL.indexOf('?');\n if (queryIndex !== -1) {\n params = seekedURL.substring(queryIndex + 1);\n }\n\n let resultParams = '';\n\n if (params != undefined && params.length > 0) {\n let pairs = params.split('&');\n\n for (let i = 0; i < pairs.length; i++) {\n let pair = pairs[i].split('=');\n let requireAnd = (i > 0);\n\n if (pair[0] !== this._startName && pair[0] !== this._endName) {\n if (requireAnd) {\n resultParams += '&';\n }\n resultParams += pairs[i];\n }\n }\n }\n\n return (resultParams.length === 0) ? baseURL : baseURL + '?' + resultParams;\n }\n\n}\n\nexport default ParamSeekHandler;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport SpeedSampler from './speed-sampler.js';\nimport {LoaderStatus, LoaderErrors} from './loader.js';\nimport FetchStreamLoader from './fetch-stream-loader.js';\nimport MozChunkedLoader from './xhr-moz-chunked-loader.js';\nimport MSStreamLoader from './xhr-msstream-loader.js';\nimport RangeLoader from './xhr-range-loader.js';\nimport WebSocketLoader from './websocket-loader.js';\nimport RangeSeekHandler from './range-seek-handler.js';\nimport ParamSeekHandler from './param-seek-handler.js';\nimport {RuntimeException, IllegalStateException, InvalidArgumentException} from '../utils/exception.js';\n\n/**\n * DataSource: {\n * url: string,\n * filesize: number,\n * cors: boolean,\n * withCredentials: boolean\n * }\n * \n */\n\n// Manage IO Loaders\nclass IOController {\n\n constructor(dataSource, config, extraData) {\n this.TAG = 'IOController';\n\n this._config = config;\n this._extraData = extraData;\n\n this._stashInitialSize = 64 * 1024; // default initial size: 64KB\n if (config.stashInitialSize != undefined && config.stashInitialSize > 0) {\n // apply from config\n this._stashInitialSize = config.stashInitialSize;\n }\n\n this._stashUsed = 0;\n this._stashSize = this._stashInitialSize;\n this._bufferSize = 1024 * 1024 * 3; // initial size: 3MB\n this._stashBuffer = new ArrayBuffer(this._bufferSize);\n this._stashByteStart = 0;\n this._enableStash = true;\n if (config.enableStashBuffer === false) {\n this._enableStash = false;\n }\n\n this._loader = null;\n this._loaderClass = null;\n this._seekHandler = null;\n\n this._dataSource = dataSource;\n this._isWebSocketURL = /wss?:\\/\\/(.+?)/.test(dataSource.url);\n this._refTotalLength = dataSource.filesize ? dataSource.filesize : null;\n this._totalLength = this._refTotalLength;\n this._fullRequestFlag = false;\n this._currentRange = null;\n this._redirectedURL = null;\n\n this._speedNormalized = 0;\n this._speedSampler = new SpeedSampler();\n this._speedNormalizeList = [32, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096];\n\n this._isEarlyEofReconnecting = false;\n\n this._paused = false;\n this._resumeFrom = 0;\n\n this._onDataArrival = null;\n this._onSeeked = null;\n this._onError = null;\n this._onComplete = null;\n this._onRedirect = null;\n this._onRecoveredEarlyEof = null;\n\n this._selectSeekHandler();\n this._selectLoader();\n this._createLoader();\n }\n\n destroy() {\n if (this._loader.isWorking()) {\n this._loader.abort();\n }\n this._loader.destroy();\n this._loader = null;\n this._loaderClass = null;\n this._dataSource = null;\n this._stashBuffer = null;\n this._stashUsed = this._stashSize = this._bufferSize = this._stashByteStart = 0;\n this._currentRange = null;\n this._speedSampler = null;\n\n this._isEarlyEofReconnecting = false;\n\n this._onDataArrival = null;\n this._onSeeked = null;\n this._onError = null;\n this._onComplete = null;\n this._onRedirect = null;\n this._onRecoveredEarlyEof = null;\n\n this._extraData = null;\n }\n\n isWorking() {\n return this._loader && this._loader.isWorking() && !this._paused;\n }\n\n isPaused() {\n return this._paused;\n }\n\n get status() {\n return this._loader.status;\n }\n\n get extraData() {\n return this._extraData;\n }\n\n set extraData(data) {\n this._extraData = data;\n }\n\n // prototype: function onDataArrival(chunks: ArrayBuffer, byteStart: number): number\n get onDataArrival() {\n return this._onDataArrival;\n }\n\n set onDataArrival(callback) {\n this._onDataArrival = callback;\n }\n\n get onSeeked() {\n return this._onSeeked;\n }\n\n set onSeeked(callback) {\n this._onSeeked = callback;\n }\n\n // prototype: function onError(type: number, info: {code: number, msg: string}): void\n get onError() {\n return this._onError;\n }\n\n set onError(callback) {\n this._onError = callback;\n }\n\n get onComplete() {\n return this._onComplete;\n }\n\n set onComplete(callback) {\n this._onComplete = callback;\n }\n\n get onRedirect() {\n return this._onRedirect;\n }\n\n set onRedirect(callback) {\n this._onRedirect = callback;\n }\n\n get onRecoveredEarlyEof() {\n return this._onRecoveredEarlyEof;\n }\n\n set onRecoveredEarlyEof(callback) {\n this._onRecoveredEarlyEof = callback;\n }\n\n get currentURL() {\n return this._dataSource.url;\n }\n\n get hasRedirect() {\n return (this._redirectedURL != null || this._dataSource.redirectedURL != undefined);\n }\n\n get currentRedirectedURL() {\n return this._redirectedURL || this._dataSource.redirectedURL;\n }\n\n // in KB/s\n get currentSpeed() {\n if (this._loaderClass === RangeLoader) {\n // SpeedSampler is inaccuracy if loader is RangeLoader\n return this._loader.currentSpeed;\n }\n return this._speedSampler.lastSecondKBps;\n }\n\n get loaderType() {\n return this._loader.type;\n }\n\n _selectSeekHandler() {\n let config = this._config;\n\n if (config.seekType === 'range') {\n this._seekHandler = new RangeSeekHandler(this._config.rangeLoadZeroStart);\n } else if (config.seekType === 'param') {\n let paramStart = config.seekParamStart || 'bstart';\n let paramEnd = config.seekParamEnd || 'bend';\n\n this._seekHandler = new ParamSeekHandler(paramStart, paramEnd);\n } else if (config.seekType === 'custom') {\n if (typeof config.customSeekHandler !== 'function') {\n throw new InvalidArgumentException('Custom seekType specified in config but invalid customSeekHandler!');\n }\n this._seekHandler = new config.customSeekHandler();\n } else {\n throw new InvalidArgumentException(`Invalid seekType in config: ${config.seekType}`);\n }\n }\n\n _selectLoader() {\n if (this._config.customLoader != null) {\n this._loaderClass = this._config.customLoader;\n } else if (this._isWebSocketURL) {\n this._loaderClass = WebSocketLoader;\n } else if (FetchStreamLoader.isSupported()) {\n this._loaderClass = FetchStreamLoader;\n } else if (MozChunkedLoader.isSupported()) {\n this._loaderClass = MozChunkedLoader;\n } else if (RangeLoader.isSupported()) {\n this._loaderClass = RangeLoader;\n } else {\n throw new RuntimeException('Your browser doesn\\'t support xhr with arraybuffer responseType!');\n }\n }\n\n _createLoader() {\n this._loader = new this._loaderClass(this._seekHandler, this._config);\n if (this._loader.needStashBuffer === false) {\n this._enableStash = false;\n }\n this._loader.onContentLengthKnown = this._onContentLengthKnown.bind(this);\n this._loader.onURLRedirect = this._onURLRedirect.bind(this);\n this._loader.onDataArrival = this._onLoaderChunkArrival.bind(this);\n this._loader.onComplete = this._onLoaderComplete.bind(this);\n this._loader.onError = this._onLoaderError.bind(this);\n }\n\n open(optionalFrom) {\n this._currentRange = {from: 0, to: -1};\n if (optionalFrom) {\n this._currentRange.from = optionalFrom;\n }\n\n this._speedSampler.reset();\n if (!optionalFrom) {\n this._fullRequestFlag = true;\n }\n\n this._loader.open(this._dataSource, Object.assign({}, this._currentRange));\n }\n\n abort() {\n this._loader.abort();\n\n if (this._paused) {\n this._paused = false;\n this._resumeFrom = 0;\n }\n }\n\n pause() {\n if (this.isWorking()) {\n this._loader.abort();\n\n if (this._stashUsed !== 0) {\n this._resumeFrom = this._stashByteStart;\n this._currentRange.to = this._stashByteStart - 1;\n } else {\n this._resumeFrom = this._currentRange.to + 1;\n }\n this._stashUsed = 0;\n this._stashByteStart = 0;\n this._paused = true;\n }\n }\n\n resume() {\n if (this._paused) {\n this._paused = false;\n let bytes = this._resumeFrom;\n this._resumeFrom = 0;\n this._internalSeek(bytes, true);\n }\n }\n\n seek(bytes) {\n this._paused = false;\n this._stashUsed = 0;\n this._stashByteStart = 0;\n this._internalSeek(bytes, true);\n }\n\n /**\n * When seeking request is from media seeking, unconsumed stash data should be dropped\n * However, stash data shouldn't be dropped if seeking requested from http reconnection\n *\n * @dropUnconsumed: Ignore and discard all unconsumed data in stash buffer\n */\n _internalSeek(bytes, dropUnconsumed) {\n if (this._loader.isWorking()) {\n this._loader.abort();\n }\n\n // dispatch & flush stash buffer before seek\n this._flushStashBuffer(dropUnconsumed);\n\n this._loader.destroy();\n this._loader = null;\n\n let requestRange = {from: bytes, to: -1};\n this._currentRange = {from: requestRange.from, to: -1};\n\n this._speedSampler.reset();\n this._stashSize = this._stashInitialSize;\n this._createLoader();\n this._loader.open(this._dataSource, requestRange);\n\n if (this._onSeeked) {\n this._onSeeked();\n }\n }\n\n updateUrl(url) {\n if (!url || typeof url !== 'string' || url.length === 0) {\n throw new InvalidArgumentException('Url must be a non-empty string!');\n }\n\n this._dataSource.url = url;\n\n // TODO: replace with new url\n }\n\n _expandBuffer(expectedBytes) {\n let bufferNewSize = this._stashSize;\n while (bufferNewSize + 1024 * 1024 * 1 < expectedBytes) {\n bufferNewSize *= 2;\n }\n\n bufferNewSize += 1024 * 1024 * 1; // bufferSize = stashSize + 1MB\n if (bufferNewSize === this._bufferSize) {\n return;\n }\n\n let newBuffer = new ArrayBuffer(bufferNewSize);\n\n if (this._stashUsed > 0) { // copy existing data into new buffer\n let stashOldArray = new Uint8Array(this._stashBuffer, 0, this._stashUsed);\n let stashNewArray = new Uint8Array(newBuffer, 0, bufferNewSize);\n stashNewArray.set(stashOldArray, 0);\n }\n\n this._stashBuffer = newBuffer;\n this._bufferSize = bufferNewSize;\n }\n\n _normalizeSpeed(input) {\n let list = this._speedNormalizeList;\n let last = list.length - 1;\n let mid = 0;\n let lbound = 0;\n let ubound = last;\n\n if (input < list[0]) {\n return list[0];\n }\n\n // binary search\n while (lbound <= ubound) {\n mid = lbound + Math.floor((ubound - lbound) / 2);\n if (mid === last || (input >= list[mid] && input < list[mid + 1])) {\n return list[mid];\n } else if (list[mid] < input) {\n lbound = mid + 1;\n } else {\n ubound = mid - 1;\n }\n }\n }\n\n _adjustStashSize(normalized) {\n let stashSizeKB = 0;\n\n if (this._config.isLive) {\n // live stream: always use 1/8 normalized speed for size of stashSizeKB\n stashSizeKB = normalized / 8;\n } else {\n if (normalized < 512) {\n stashSizeKB = normalized;\n } else if (normalized >= 512 && normalized <= 1024) {\n stashSizeKB = Math.floor(normalized * 1.5);\n } else {\n stashSizeKB = normalized * 2;\n }\n }\n\n if (stashSizeKB > 8192) {\n stashSizeKB = 8192;\n }\n\n let bufferSize = stashSizeKB * 1024 + 1024 * 1024 * 1; // stashSize + 1MB\n if (this._bufferSize < bufferSize) {\n this._expandBuffer(bufferSize);\n }\n this._stashSize = stashSizeKB * 1024;\n }\n\n _dispatchChunks(chunks, byteStart) {\n this._currentRange.to = byteStart + chunks.byteLength - 1;\n return this._onDataArrival(chunks, byteStart);\n }\n\n _onURLRedirect(redirectedURL) {\n this._redirectedURL = redirectedURL;\n if (this._onRedirect) {\n this._onRedirect(redirectedURL);\n }\n }\n\n _onContentLengthKnown(contentLength) {\n if (contentLength && this._fullRequestFlag) {\n this._totalLength = contentLength;\n this._fullRequestFlag = false;\n }\n }\n\n _onLoaderChunkArrival(chunk, byteStart, receivedLength) {\n if (!this._onDataArrival) {\n throw new IllegalStateException('IOController: No existing consumer (onDataArrival) callback!');\n }\n if (this._paused) {\n return;\n }\n if (this._isEarlyEofReconnecting) {\n // Auto-reconnect for EarlyEof succeed, notify to upper-layer by callback\n this._isEarlyEofReconnecting = false;\n if (this._onRecoveredEarlyEof) {\n this._onRecoveredEarlyEof();\n }\n }\n\n this._speedSampler.addBytes(chunk.byteLength);\n\n // adjust stash buffer size according to network speed dynamically\n let KBps = this._speedSampler.lastSecondKBps;\n if (KBps !== 0) {\n let normalized = this._normalizeSpeed(KBps);\n if (this._speedNormalized !== normalized) {\n this._speedNormalized = normalized;\n this._adjustStashSize(normalized);\n }\n }\n\n if (!this._enableStash) { // disable stash\n if (this._stashUsed === 0) {\n // dispatch chunk directly to consumer;\n // check ret value (consumed bytes) and stash unconsumed to stashBuffer\n let consumed = this._dispatchChunks(chunk, byteStart);\n if (consumed < chunk.byteLength) { // unconsumed data remain.\n let remain = chunk.byteLength - consumed;\n if (remain > this._bufferSize) {\n this._expandBuffer(remain);\n }\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n stashArray.set(new Uint8Array(chunk, consumed), 0);\n this._stashUsed += remain;\n this._stashByteStart = byteStart + consumed;\n }\n } else {\n // else: Merge chunk into stashBuffer, and dispatch stashBuffer to consumer.\n if (this._stashUsed + chunk.byteLength > this._bufferSize) {\n this._expandBuffer(this._stashUsed + chunk.byteLength);\n }\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n stashArray.set(new Uint8Array(chunk), this._stashUsed);\n this._stashUsed += chunk.byteLength;\n let consumed = this._dispatchChunks(this._stashBuffer.slice(0, this._stashUsed), this._stashByteStart);\n if (consumed < this._stashUsed && consumed > 0) { // unconsumed data remain\n let remainArray = new Uint8Array(this._stashBuffer, consumed);\n stashArray.set(remainArray, 0);\n }\n this._stashUsed -= consumed;\n this._stashByteStart += consumed;\n }\n } else { // enable stash\n if (this._stashUsed === 0 && this._stashByteStart === 0) { // seeked? or init chunk?\n // This is the first chunk after seek action\n this._stashByteStart = byteStart;\n }\n if (this._stashUsed + chunk.byteLength <= this._stashSize) {\n // just stash\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._stashSize);\n stashArray.set(new Uint8Array(chunk), this._stashUsed);\n this._stashUsed += chunk.byteLength;\n } else { // stashUsed + chunkSize > stashSize, size limit exceeded\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n if (this._stashUsed > 0) { // There're stash datas in buffer\n // dispatch the whole stashBuffer, and stash remain data\n // then append chunk to stashBuffer (stash)\n let buffer = this._stashBuffer.slice(0, this._stashUsed);\n let consumed = this._dispatchChunks(buffer, this._stashByteStart);\n if (consumed < buffer.byteLength) {\n if (consumed > 0) {\n let remainArray = new Uint8Array(buffer, consumed);\n stashArray.set(remainArray, 0);\n this._stashUsed = remainArray.byteLength;\n this._stashByteStart += consumed;\n }\n } else {\n this._stashUsed = 0;\n this._stashByteStart += consumed;\n }\n if (this._stashUsed + chunk.byteLength > this._bufferSize) {\n this._expandBuffer(this._stashUsed + chunk.byteLength);\n stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n }\n stashArray.set(new Uint8Array(chunk), this._stashUsed);\n this._stashUsed += chunk.byteLength;\n } else { // stash buffer empty, but chunkSize > stashSize (oh, holy shit)\n // dispatch chunk directly and stash remain data\n let consumed = this._dispatchChunks(chunk, byteStart);\n if (consumed < chunk.byteLength) {\n let remain = chunk.byteLength - consumed;\n if (remain > this._bufferSize) {\n this._expandBuffer(remain);\n stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n }\n stashArray.set(new Uint8Array(chunk, consumed), 0);\n this._stashUsed += remain;\n this._stashByteStart = byteStart + consumed;\n }\n }\n }\n }\n }\n\n _flushStashBuffer(dropUnconsumed) {\n if (this._stashUsed > 0) {\n let buffer = this._stashBuffer.slice(0, this._stashUsed);\n let consumed = this._dispatchChunks(buffer, this._stashByteStart);\n let remain = buffer.byteLength - consumed;\n\n if (consumed < buffer.byteLength) {\n if (dropUnconsumed) {\n Log.w(this.TAG, `${remain} bytes unconsumed data remain when flush buffer, dropped`);\n } else {\n if (consumed > 0) {\n let stashArray = new Uint8Array(this._stashBuffer, 0, this._bufferSize);\n let remainArray = new Uint8Array(buffer, consumed);\n stashArray.set(remainArray, 0);\n this._stashUsed = remainArray.byteLength;\n this._stashByteStart += consumed;\n }\n return 0;\n }\n }\n this._stashUsed = 0;\n this._stashByteStart = 0;\n return remain;\n }\n return 0;\n }\n\n _onLoaderComplete(from, to) {\n // Force-flush stash buffer, and drop unconsumed data\n this._flushStashBuffer(true);\n\n if (this._onComplete) {\n this._onComplete(this._extraData);\n }\n }\n\n _onLoaderError(type, data) {\n Log.e(this.TAG, `Loader error, code = ${data.code}, msg = ${data.msg}`);\n\n this._flushStashBuffer(false);\n\n if (this._isEarlyEofReconnecting) {\n // Auto-reconnect for EarlyEof failed, throw UnrecoverableEarlyEof error to upper-layer\n this._isEarlyEofReconnecting = false;\n type = LoaderErrors.UNRECOVERABLE_EARLY_EOF;\n }\n\n switch (type) {\n case LoaderErrors.EARLY_EOF: {\n if (!this._config.isLive) {\n // Do internal http reconnect if not live stream\n if (this._totalLength) {\n let nextFrom = this._currentRange.to + 1;\n if (nextFrom < this._totalLength) {\n Log.w(this.TAG, 'Connection lost, trying reconnect...');\n this._isEarlyEofReconnecting = true;\n this._internalSeek(nextFrom, false);\n }\n return;\n }\n // else: We don't know totalLength, throw UnrecoverableEarlyEof\n }\n // live stream: throw UnrecoverableEarlyEof error to upper-layer\n type = LoaderErrors.UNRECOVERABLE_EARLY_EOF;\n break;\n }\n case LoaderErrors.UNRECOVERABLE_EARLY_EOF:\n case LoaderErrors.CONNECTING_TIMEOUT:\n case LoaderErrors.HTTP_STATUS_CODE_INVALID:\n case LoaderErrors.EXCEPTION:\n break;\n }\n\n if (this._onError) {\n this._onError(type, data);\n } else {\n throw new RuntimeException('IOException: ' + data.msg);\n }\n }\n\n}\n\nexport default IOController;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass Polyfill {\n\n static install() {\n // ES6 Object.setPrototypeOf\n Object.setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {\n obj.__proto__ = proto;\n return obj;\n };\n\n // ES6 Object.assign\n Object.assign = Object.assign || function (target) {\n if (target === undefined || target === null) {\n throw new TypeError('Cannot convert undefined or null to object');\n }\n\n let output = Object(target);\n for (let i = 1; i < arguments.length; i++) {\n let source = arguments[i];\n if (source !== undefined && source !== null) {\n for (let key in source) {\n if (source.hasOwnProperty(key)) {\n output[key] = source[key];\n }\n }\n }\n }\n return output;\n };\n\n // ES6 Promise (missing support in IE11)\n if (typeof self.Promise !== 'function') {\n require('es6-promise').polyfill();\n }\n }\n\n}\n\nPolyfill.install();\n\nexport default Polyfill;","function webpackBootstrapFunc (modules) {\n/******/ // The module cache\n/******/ var installedModules = {};\n\n/******/ // The require function\n/******/ function __webpack_require__(moduleId) {\n\n/******/ // Check if module is in cache\n/******/ if(installedModules[moduleId])\n/******/ return installedModules[moduleId].exports;\n\n/******/ // Create a new module (and put it into the cache)\n/******/ var module = installedModules[moduleId] = {\n/******/ i: moduleId,\n/******/ l: false,\n/******/ exports: {}\n/******/ };\n\n/******/ // Execute the module function\n/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n/******/ // Flag the module as loaded\n/******/ module.l = true;\n\n/******/ // Return the exports of the module\n/******/ return module.exports;\n/******/ }\n\n/******/ // expose the modules object (__webpack_modules__)\n/******/ __webpack_require__.m = modules;\n\n/******/ // expose the module cache\n/******/ __webpack_require__.c = installedModules;\n\n/******/ // identity function for calling harmony imports with the correct context\n/******/ __webpack_require__.i = function(value) { return value; };\n\n/******/ // define getter function for harmony exports\n/******/ __webpack_require__.d = function(exports, name, getter) {\n/******/ if(!__webpack_require__.o(exports, name)) {\n/******/ Object.defineProperty(exports, name, {\n/******/ configurable: false,\n/******/ enumerable: true,\n/******/ get: getter\n/******/ });\n/******/ }\n/******/ };\n\n/******/ // define __esModule on exports\n/******/ __webpack_require__.r = function(exports) {\n/******/ Object.defineProperty(exports, '__esModule', { value: true });\n/******/ };\n\n/******/ // getDefaultExport function for compatibility with non-harmony modules\n/******/ __webpack_require__.n = function(module) {\n/******/ var getter = module && module.__esModule ?\n/******/ function getDefault() { return module['default']; } :\n/******/ function getModuleExports() { return module; };\n/******/ __webpack_require__.d(getter, 'a', getter);\n/******/ return getter;\n/******/ };\n\n/******/ // Object.prototype.hasOwnProperty.call\n/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n/******/ // __webpack_public_path__\n/******/ __webpack_require__.p = \"/\";\n\n/******/ // on error function for async loading\n/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n var f = __webpack_require__(__webpack_require__.s = ENTRY_MODULE)\n return f.default || f // try to call default if defined to also support babel esmodule exports\n}\n\nvar moduleNameReqExp = '[\\\\.|\\\\-|\\\\+|\\\\w|\\/|@]+'\nvar dependencyRegExp = '\\\\(\\\\s*(\\/\\\\*.*?\\\\*\\/)?\\\\s*.*?(' + moduleNameReqExp + ').*?\\\\)' // additional chars when output.pathinfo is true\n\n// http://stackoverflow.com/a/2593661/130442\nfunction quoteRegExp (str) {\n return (str + '').replace(/[.?*+^$[\\]\\\\(){}|-]/g, '\\\\$&')\n}\n\nfunction isNumeric(n) {\n return !isNaN(1 * n); // 1 * n converts integers, integers as string (\"123\"), 1e3 and \"1e3\" to integers and strings to NaN\n}\n\nfunction getModuleDependencies (sources, module, queueName) {\n var retval = {}\n retval[queueName] = []\n\n var fnString = module.toString()\n var wrapperSignature = fnString.match(/^function\\s?\\w*\\(\\w+,\\s*\\w+,\\s*(\\w+)\\)/)\n if (!wrapperSignature) return retval\n var webpackRequireName = wrapperSignature[1]\n\n // main bundle deps\n var re = new RegExp('(\\\\\\\\n|\\\\W)' + quoteRegExp(webpackRequireName) + dependencyRegExp, 'g')\n var match\n while ((match = re.exec(fnString))) {\n if (match[3] === 'dll-reference') continue\n retval[queueName].push(match[3])\n }\n\n // dll deps\n re = new RegExp('\\\\(' + quoteRegExp(webpackRequireName) + '\\\\(\"(dll-reference\\\\s(' + moduleNameReqExp + '))\"\\\\)\\\\)' + dependencyRegExp, 'g')\n while ((match = re.exec(fnString))) {\n if (!sources[match[2]]) {\n retval[queueName].push(match[1])\n sources[match[2]] = __webpack_require__(match[1]).m\n }\n retval[match[2]] = retval[match[2]] || []\n retval[match[2]].push(match[4])\n }\n\n // convert 1e3 back to 1000 - this can be important after uglify-js converted 1000 to 1e3\n var keys = Object.keys(retval);\n for (var i = 0; i < keys.length; i++) {\n for (var j = 0; j < retval[keys[i]].length; j++) {\n if (isNumeric(retval[keys[i]][j])) {\n retval[keys[i]][j] = 1 * retval[keys[i]][j];\n }\n }\n }\n\n return retval\n}\n\nfunction hasValuesInQueues (queues) {\n var keys = Object.keys(queues)\n return keys.reduce(function (hasValues, key) {\n return hasValues || queues[key].length > 0\n }, false)\n}\n\nfunction getRequiredModules (sources, moduleId) {\n var modulesQueue = {\n main: [moduleId]\n }\n var requiredModules = {\n main: []\n }\n var seenModules = {\n main: {}\n }\n\n while (hasValuesInQueues(modulesQueue)) {\n var queues = Object.keys(modulesQueue)\n for (var i = 0; i < queues.length; i++) {\n var queueName = queues[i]\n var queue = modulesQueue[queueName]\n var moduleToCheck = queue.pop()\n seenModules[queueName] = seenModules[queueName] || {}\n if (seenModules[queueName][moduleToCheck] || !sources[queueName][moduleToCheck]) continue\n seenModules[queueName][moduleToCheck] = true\n requiredModules[queueName] = requiredModules[queueName] || []\n requiredModules[queueName].push(moduleToCheck)\n var newModules = getModuleDependencies(sources, sources[queueName][moduleToCheck], queueName)\n var newModulesKeys = Object.keys(newModules)\n for (var j = 0; j < newModulesKeys.length; j++) {\n modulesQueue[newModulesKeys[j]] = modulesQueue[newModulesKeys[j]] || []\n modulesQueue[newModulesKeys[j]] = modulesQueue[newModulesKeys[j]].concat(newModules[newModulesKeys[j]])\n }\n }\n }\n\n return requiredModules\n}\n\nmodule.exports = function (moduleId, options) {\n options = options || {}\n var sources = {\n main: __webpack_modules__\n }\n\n var requiredModules = options.all ? { main: Object.keys(sources.main) } : getRequiredModules(sources, moduleId)\n\n var src = ''\n\n Object.keys(requiredModules).filter(function (m) { return m !== 'main' }).forEach(function (module) {\n var entryModule = 0\n while (requiredModules[module][entryModule]) {\n entryModule++\n }\n requiredModules[module].push(entryModule)\n sources[module][entryModule] = '(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })'\n src = src + 'var ' + module + ' = (' + webpackBootstrapFunc.toString().replace('ENTRY_MODULE', JSON.stringify(entryModule)) + ')({' + requiredModules[module].map(function (id) { return '' + JSON.stringify(id) + ': ' + sources[module][id].toString() }).join(',') + '});\\n'\n })\n\n src = src + 'new ((' + webpackBootstrapFunc.toString().replace('ENTRY_MODULE', JSON.stringify(moduleId)) + ')({' + requiredModules.main.map(function (id) { return '' + JSON.stringify(id) + ': ' + sources.main[id].toString() }).join(',') + '}))(self);'\n\n var blob = new window.Blob([src], { type: 'text/javascript' })\n if (options.bare) { return blob }\n\n var URL = window.URL || window.webkitURL || window.mozURL || window.msURL\n\n var workerUrl = URL.createObjectURL(blob)\n var worker = new window.Worker(workerUrl)\n worker.objectURL = workerUrl\n\n return worker\n}\n","// entry/index file\n\n// make it compatible with browserify's umd wrapper\nmodule.exports = require('./mpegts.js').default;\n","/*!\n * @overview es6-promise - a tiny implementation of Promises/A+.\n * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)\n * @license Licensed under MIT license\n * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE\n * @version v4.2.8+1e68dce6\n */\n\n(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global.ES6Promise = factory());\n}(this, (function () { 'use strict';\n\nfunction objectOrFunction(x) {\n var type = typeof x;\n return x !== null && (type === 'object' || type === 'function');\n}\n\nfunction isFunction(x) {\n return typeof x === 'function';\n}\n\n\n\nvar _isArray = void 0;\nif (Array.isArray) {\n _isArray = Array.isArray;\n} else {\n _isArray = function (x) {\n return Object.prototype.toString.call(x) === '[object Array]';\n };\n}\n\nvar isArray = _isArray;\n\nvar len = 0;\nvar vertxNext = void 0;\nvar customSchedulerFn = void 0;\n\nvar asap = function asap(callback, arg) {\n queue[len] = callback;\n queue[len + 1] = arg;\n len += 2;\n if (len === 2) {\n // If len is 2, that means that we need to schedule an async flush.\n // If additional callbacks are queued before the queue is flushed, they\n // will be processed by this flush that we are scheduling.\n if (customSchedulerFn) {\n customSchedulerFn(flush);\n } else {\n scheduleFlush();\n }\n }\n};\n\nfunction setScheduler(scheduleFn) {\n customSchedulerFn = scheduleFn;\n}\n\nfunction setAsap(asapFn) {\n asap = asapFn;\n}\n\nvar browserWindow = typeof window !== 'undefined' ? window : undefined;\nvar browserGlobal = browserWindow || {};\nvar BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;\nvar isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';\n\n// test for web worker but not in IE10\nvar isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';\n\n// node\nfunction useNextTick() {\n // node version 0.10.x displays a deprecation warning when nextTick is used recursively\n // see https://github.com/cujojs/when/issues/410 for details\n return function () {\n return process.nextTick(flush);\n };\n}\n\n// vertx\nfunction useVertxTimer() {\n if (typeof vertxNext !== 'undefined') {\n return function () {\n vertxNext(flush);\n };\n }\n\n return useSetTimeout();\n}\n\nfunction useMutationObserver() {\n var iterations = 0;\n var observer = new BrowserMutationObserver(flush);\n var node = document.createTextNode('');\n observer.observe(node, { characterData: true });\n\n return function () {\n node.data = iterations = ++iterations % 2;\n };\n}\n\n// web worker\nfunction useMessageChannel() {\n var channel = new MessageChannel();\n channel.port1.onmessage = flush;\n return function () {\n return channel.port2.postMessage(0);\n };\n}\n\nfunction useSetTimeout() {\n // Store setTimeout reference so es6-promise will be unaffected by\n // other code modifying setTimeout (like sinon.useFakeTimers())\n var globalSetTimeout = setTimeout;\n return function () {\n return globalSetTimeout(flush, 1);\n };\n}\n\nvar queue = new Array(1000);\nfunction flush() {\n for (var i = 0; i < len; i += 2) {\n var callback = queue[i];\n var arg = queue[i + 1];\n\n callback(arg);\n\n queue[i] = undefined;\n queue[i + 1] = undefined;\n }\n\n len = 0;\n}\n\nfunction attemptVertx() {\n try {\n var vertx = Function('return this')().require('vertx');\n vertxNext = vertx.runOnLoop || vertx.runOnContext;\n return useVertxTimer();\n } catch (e) {\n return useSetTimeout();\n }\n}\n\nvar scheduleFlush = void 0;\n// Decide what async method to use to triggering processing of queued callbacks:\nif (isNode) {\n scheduleFlush = useNextTick();\n} else if (BrowserMutationObserver) {\n scheduleFlush = useMutationObserver();\n} else if (isWorker) {\n scheduleFlush = useMessageChannel();\n} else if (browserWindow === undefined && typeof require === 'function') {\n scheduleFlush = attemptVertx();\n} else {\n scheduleFlush = useSetTimeout();\n}\n\nfunction then(onFulfillment, onRejection) {\n var parent = this;\n\n var child = new this.constructor(noop);\n\n if (child[PROMISE_ID] === undefined) {\n makePromise(child);\n }\n\n var _state = parent._state;\n\n\n if (_state) {\n var callback = arguments[_state - 1];\n asap(function () {\n return invokeCallback(_state, child, callback, parent._result);\n });\n } else {\n subscribe(parent, child, onFulfillment, onRejection);\n }\n\n return child;\n}\n\n/**\n `Promise.resolve` returns a promise that will become resolved with the\n passed `value`. It is shorthand for the following:\n\n ```javascript\n let promise = new Promise(function(resolve, reject){\n resolve(1);\n });\n\n promise.then(function(value){\n // value === 1\n });\n ```\n\n Instead of writing the above, your code now simply becomes the following:\n\n ```javascript\n let promise = Promise.resolve(1);\n\n promise.then(function(value){\n // value === 1\n });\n ```\n\n @method resolve\n @static\n @param {Any} value value that the returned promise will be resolved with\n Useful for tooling.\n @return {Promise} a promise that will become fulfilled with the given\n `value`\n*/\nfunction resolve$1(object) {\n /*jshint validthis:true */\n var Constructor = this;\n\n if (object && typeof object === 'object' && object.constructor === Constructor) {\n return object;\n }\n\n var promise = new Constructor(noop);\n resolve(promise, object);\n return promise;\n}\n\nvar PROMISE_ID = Math.random().toString(36).substring(2);\n\nfunction noop() {}\n\nvar PENDING = void 0;\nvar FULFILLED = 1;\nvar REJECTED = 2;\n\nfunction selfFulfillment() {\n return new TypeError(\"You cannot resolve a promise with itself\");\n}\n\nfunction cannotReturnOwn() {\n return new TypeError('A promises callback cannot return that same promise.');\n}\n\nfunction tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {\n try {\n then$$1.call(value, fulfillmentHandler, rejectionHandler);\n } catch (e) {\n return e;\n }\n}\n\nfunction handleForeignThenable(promise, thenable, then$$1) {\n asap(function (promise) {\n var sealed = false;\n var error = tryThen(then$$1, thenable, function (value) {\n if (sealed) {\n return;\n }\n sealed = true;\n if (thenable !== value) {\n resolve(promise, value);\n } else {\n fulfill(promise, value);\n }\n }, function (reason) {\n if (sealed) {\n return;\n }\n sealed = true;\n\n reject(promise, reason);\n }, 'Settle: ' + (promise._label || ' unknown promise'));\n\n if (!sealed && error) {\n sealed = true;\n reject(promise, error);\n }\n }, promise);\n}\n\nfunction handleOwnThenable(promise, thenable) {\n if (thenable._state === FULFILLED) {\n fulfill(promise, thenable._result);\n } else if (thenable._state === REJECTED) {\n reject(promise, thenable._result);\n } else {\n subscribe(thenable, undefined, function (value) {\n return resolve(promise, value);\n }, function (reason) {\n return reject(promise, reason);\n });\n }\n}\n\nfunction handleMaybeThenable(promise, maybeThenable, then$$1) {\n if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) {\n handleOwnThenable(promise, maybeThenable);\n } else {\n if (then$$1 === undefined) {\n fulfill(promise, maybeThenable);\n } else if (isFunction(then$$1)) {\n handleForeignThenable(promise, maybeThenable, then$$1);\n } else {\n fulfill(promise, maybeThenable);\n }\n }\n}\n\nfunction resolve(promise, value) {\n if (promise === value) {\n reject(promise, selfFulfillment());\n } else if (objectOrFunction(value)) {\n var then$$1 = void 0;\n try {\n then$$1 = value.then;\n } catch (error) {\n reject(promise, error);\n return;\n }\n handleMaybeThenable(promise, value, then$$1);\n } else {\n fulfill(promise, value);\n }\n}\n\nfunction publishRejection(promise) {\n if (promise._onerror) {\n promise._onerror(promise._result);\n }\n\n publish(promise);\n}\n\nfunction fulfill(promise, value) {\n if (promise._state !== PENDING) {\n return;\n }\n\n promise._result = value;\n promise._state = FULFILLED;\n\n if (promise._subscribers.length !== 0) {\n asap(publish, promise);\n }\n}\n\nfunction reject(promise, reason) {\n if (promise._state !== PENDING) {\n return;\n }\n promise._state = REJECTED;\n promise._result = reason;\n\n asap(publishRejection, promise);\n}\n\nfunction subscribe(parent, child, onFulfillment, onRejection) {\n var _subscribers = parent._subscribers;\n var length = _subscribers.length;\n\n\n parent._onerror = null;\n\n _subscribers[length] = child;\n _subscribers[length + FULFILLED] = onFulfillment;\n _subscribers[length + REJECTED] = onRejection;\n\n if (length === 0 && parent._state) {\n asap(publish, parent);\n }\n}\n\nfunction publish(promise) {\n var subscribers = promise._subscribers;\n var settled = promise._state;\n\n if (subscribers.length === 0) {\n return;\n }\n\n var child = void 0,\n callback = void 0,\n detail = promise._result;\n\n for (var i = 0; i < subscribers.length; i += 3) {\n child = subscribers[i];\n callback = subscribers[i + settled];\n\n if (child) {\n invokeCallback(settled, child, callback, detail);\n } else {\n callback(detail);\n }\n }\n\n promise._subscribers.length = 0;\n}\n\nfunction invokeCallback(settled, promise, callback, detail) {\n var hasCallback = isFunction(callback),\n value = void 0,\n error = void 0,\n succeeded = true;\n\n if (hasCallback) {\n try {\n value = callback(detail);\n } catch (e) {\n succeeded = false;\n error = e;\n }\n\n if (promise === value) {\n reject(promise, cannotReturnOwn());\n return;\n }\n } else {\n value = detail;\n }\n\n if (promise._state !== PENDING) {\n // noop\n } else if (hasCallback && succeeded) {\n resolve(promise, value);\n } else if (succeeded === false) {\n reject(promise, error);\n } else if (settled === FULFILLED) {\n fulfill(promise, value);\n } else if (settled === REJECTED) {\n reject(promise, value);\n }\n}\n\nfunction initializePromise(promise, resolver) {\n try {\n resolver(function resolvePromise(value) {\n resolve(promise, value);\n }, function rejectPromise(reason) {\n reject(promise, reason);\n });\n } catch (e) {\n reject(promise, e);\n }\n}\n\nvar id = 0;\nfunction nextId() {\n return id++;\n}\n\nfunction makePromise(promise) {\n promise[PROMISE_ID] = id++;\n promise._state = undefined;\n promise._result = undefined;\n promise._subscribers = [];\n}\n\nfunction validationError() {\n return new Error('Array Methods must be provided an Array');\n}\n\nvar Enumerator = function () {\n function Enumerator(Constructor, input) {\n this._instanceConstructor = Constructor;\n this.promise = new Constructor(noop);\n\n if (!this.promise[PROMISE_ID]) {\n makePromise(this.promise);\n }\n\n if (isArray(input)) {\n this.length = input.length;\n this._remaining = input.length;\n\n this._result = new Array(this.length);\n\n if (this.length === 0) {\n fulfill(this.promise, this._result);\n } else {\n this.length = this.length || 0;\n this._enumerate(input);\n if (this._remaining === 0) {\n fulfill(this.promise, this._result);\n }\n }\n } else {\n reject(this.promise, validationError());\n }\n }\n\n Enumerator.prototype._enumerate = function _enumerate(input) {\n for (var i = 0; this._state === PENDING && i < input.length; i++) {\n this._eachEntry(input[i], i);\n }\n };\n\n Enumerator.prototype._eachEntry = function _eachEntry(entry, i) {\n var c = this._instanceConstructor;\n var resolve$$1 = c.resolve;\n\n\n if (resolve$$1 === resolve$1) {\n var _then = void 0;\n var error = void 0;\n var didError = false;\n try {\n _then = entry.then;\n } catch (e) {\n didError = true;\n error = e;\n }\n\n if (_then === then && entry._state !== PENDING) {\n this._settledAt(entry._state, i, entry._result);\n } else if (typeof _then !== 'function') {\n this._remaining--;\n this._result[i] = entry;\n } else if (c === Promise$1) {\n var promise = new c(noop);\n if (didError) {\n reject(promise, error);\n } else {\n handleMaybeThenable(promise, entry, _then);\n }\n this._willSettleAt(promise, i);\n } else {\n this._willSettleAt(new c(function (resolve$$1) {\n return resolve$$1(entry);\n }), i);\n }\n } else {\n this._willSettleAt(resolve$$1(entry), i);\n }\n };\n\n Enumerator.prototype._settledAt = function _settledAt(state, i, value) {\n var promise = this.promise;\n\n\n if (promise._state === PENDING) {\n this._remaining--;\n\n if (state === REJECTED) {\n reject(promise, value);\n } else {\n this._result[i] = value;\n }\n }\n\n if (this._remaining === 0) {\n fulfill(promise, this._result);\n }\n };\n\n Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) {\n var enumerator = this;\n\n subscribe(promise, undefined, function (value) {\n return enumerator._settledAt(FULFILLED, i, value);\n }, function (reason) {\n return enumerator._settledAt(REJECTED, i, reason);\n });\n };\n\n return Enumerator;\n}();\n\n/**\n `Promise.all` accepts an array of promises, and returns a new promise which\n is fulfilled with an array of fulfillment values for the passed promises, or\n rejected with the reason of the first passed promise to be rejected. It casts all\n elements of the passed iterable to promises as it runs this algorithm.\n\n Example:\n\n ```javascript\n let promise1 = resolve(1);\n let promise2 = resolve(2);\n let promise3 = resolve(3);\n let promises = [ promise1, promise2, promise3 ];\n\n Promise.all(promises).then(function(array){\n // The array here would be [ 1, 2, 3 ];\n });\n ```\n\n If any of the `promises` given to `all` are rejected, the first promise\n that is rejected will be given as an argument to the returned promises's\n rejection handler. For example:\n\n Example:\n\n ```javascript\n let promise1 = resolve(1);\n let promise2 = reject(new Error(\"2\"));\n let promise3 = reject(new Error(\"3\"));\n let promises = [ promise1, promise2, promise3 ];\n\n Promise.all(promises).then(function(array){\n // Code here never runs because there are rejected promises!\n }, function(error) {\n // error.message === \"2\"\n });\n ```\n\n @method all\n @static\n @param {Array} entries array of promises\n @param {String} label optional string for labeling the promise.\n Useful for tooling.\n @return {Promise} promise that is fulfilled when all `promises` have been\n fulfilled, or rejected if any of them become rejected.\n @static\n*/\nfunction all(entries) {\n return new Enumerator(this, entries).promise;\n}\n\n/**\n `Promise.race` returns a new promise which is settled in the same way as the\n first passed promise to settle.\n\n Example:\n\n ```javascript\n let promise1 = new Promise(function(resolve, reject){\n setTimeout(function(){\n resolve('promise 1');\n }, 200);\n });\n\n let promise2 = new Promise(function(resolve, reject){\n setTimeout(function(){\n resolve('promise 2');\n }, 100);\n });\n\n Promise.race([promise1, promise2]).then(function(result){\n // result === 'promise 2' because it was resolved before promise1\n // was resolved.\n });\n ```\n\n `Promise.race` is deterministic in that only the state of the first\n settled promise matters. For example, even if other promises given to the\n `promises` array argument are resolved, but the first settled promise has\n become rejected before the other promises became fulfilled, the returned\n promise will become rejected:\n\n ```javascript\n let promise1 = new Promise(function(resolve, reject){\n setTimeout(function(){\n resolve('promise 1');\n }, 200);\n });\n\n let promise2 = new Promise(function(resolve, reject){\n setTimeout(function(){\n reject(new Error('promise 2'));\n }, 100);\n });\n\n Promise.race([promise1, promise2]).then(function(result){\n // Code here never runs\n }, function(reason){\n // reason.message === 'promise 2' because promise 2 became rejected before\n // promise 1 became fulfilled\n });\n ```\n\n An example real-world use case is implementing timeouts:\n\n ```javascript\n Promise.race([ajax('foo.json'), timeout(5000)])\n ```\n\n @method race\n @static\n @param {Array} promises array of promises to observe\n Useful for tooling.\n @return {Promise} a promise which settles in the same way as the first passed\n promise to settle.\n*/\nfunction race(entries) {\n /*jshint validthis:true */\n var Constructor = this;\n\n if (!isArray(entries)) {\n return new Constructor(function (_, reject) {\n return reject(new TypeError('You must pass an array to race.'));\n });\n } else {\n return new Constructor(function (resolve, reject) {\n var length = entries.length;\n for (var i = 0; i < length; i++) {\n Constructor.resolve(entries[i]).then(resolve, reject);\n }\n });\n }\n}\n\n/**\n `Promise.reject` returns a promise rejected with the passed `reason`.\n It is shorthand for the following:\n\n ```javascript\n let promise = new Promise(function(resolve, reject){\n reject(new Error('WHOOPS'));\n });\n\n promise.then(function(value){\n // Code here doesn't run because the promise is rejected!\n }, function(reason){\n // reason.message === 'WHOOPS'\n });\n ```\n\n Instead of writing the above, your code now simply becomes the following:\n\n ```javascript\n let promise = Promise.reject(new Error('WHOOPS'));\n\n promise.then(function(value){\n // Code here doesn't run because the promise is rejected!\n }, function(reason){\n // reason.message === 'WHOOPS'\n });\n ```\n\n @method reject\n @static\n @param {Any} reason value that the returned promise will be rejected with.\n Useful for tooling.\n @return {Promise} a promise rejected with the given `reason`.\n*/\nfunction reject$1(reason) {\n /*jshint validthis:true */\n var Constructor = this;\n var promise = new Constructor(noop);\n reject(promise, reason);\n return promise;\n}\n\nfunction needsResolver() {\n throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');\n}\n\nfunction needsNew() {\n throw new TypeError(\"Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.\");\n}\n\n/**\n Promise objects represent the eventual result of an asynchronous operation. The\n primary way of interacting with a promise is through its `then` method, which\n registers callbacks to receive either a promise's eventual value or the reason\n why the promise cannot be fulfilled.\n\n Terminology\n -----------\n\n - `promise` is an object or function with a `then` method whose behavior conforms to this specification.\n - `thenable` is an object or function that defines a `then` method.\n - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).\n - `exception` is a value that is thrown using the throw statement.\n - `reason` is a value that indicates why a promise was rejected.\n - `settled` the final resting state of a promise, fulfilled or rejected.\n\n A promise can be in one of three states: pending, fulfilled, or rejected.\n\n Promises that are fulfilled have a fulfillment value and are in the fulfilled\n state. Promises that are rejected have a rejection reason and are in the\n rejected state. A fulfillment value is never a thenable.\n\n Promises can also be said to *resolve* a value. If this value is also a\n promise, then the original promise's settled state will match the value's\n settled state. So a promise that *resolves* a promise that rejects will\n itself reject, and a promise that *resolves* a promise that fulfills will\n itself fulfill.\n\n\n Basic Usage:\n ------------\n\n ```js\n let promise = new Promise(function(resolve, reject) {\n // on success\n resolve(value);\n\n // on failure\n reject(reason);\n });\n\n promise.then(function(value) {\n // on fulfillment\n }, function(reason) {\n // on rejection\n });\n ```\n\n Advanced Usage:\n ---------------\n\n Promises shine when abstracting away asynchronous interactions such as\n `XMLHttpRequest`s.\n\n ```js\n function getJSON(url) {\n return new Promise(function(resolve, reject){\n let xhr = new XMLHttpRequest();\n\n xhr.open('GET', url);\n xhr.onreadystatechange = handler;\n xhr.responseType = 'json';\n xhr.setRequestHeader('Accept', 'application/json');\n xhr.send();\n\n function handler() {\n if (this.readyState === this.DONE) {\n if (this.status === 200) {\n resolve(this.response);\n } else {\n reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));\n }\n }\n };\n });\n }\n\n getJSON('/posts.json').then(function(json) {\n // on fulfillment\n }, function(reason) {\n // on rejection\n });\n ```\n\n Unlike callbacks, promises are great composable primitives.\n\n ```js\n Promise.all([\n getJSON('/posts'),\n getJSON('/comments')\n ]).then(function(values){\n values[0] // => postsJSON\n values[1] // => commentsJSON\n\n return values;\n });\n ```\n\n @class Promise\n @param {Function} resolver\n Useful for tooling.\n @constructor\n*/\n\nvar Promise$1 = function () {\n function Promise(resolver) {\n this[PROMISE_ID] = nextId();\n this._result = this._state = undefined;\n this._subscribers = [];\n\n if (noop !== resolver) {\n typeof resolver !== 'function' && needsResolver();\n this instanceof Promise ? initializePromise(this, resolver) : needsNew();\n }\n }\n\n /**\n The primary way of interacting with a promise is through its `then` method,\n which registers callbacks to receive either a promise's eventual value or the\n reason why the promise cannot be fulfilled.\n ```js\n findUser().then(function(user){\n // user is available\n }, function(reason){\n // user is unavailable, and you are given the reason why\n });\n ```\n Chaining\n --------\n The return value of `then` is itself a promise. This second, 'downstream'\n promise is resolved with the return value of the first promise's fulfillment\n or rejection handler, or rejected if the handler throws an exception.\n ```js\n findUser().then(function (user) {\n return user.name;\n }, function (reason) {\n return 'default name';\n }).then(function (userName) {\n // If `findUser` fulfilled, `userName` will be the user's name, otherwise it\n // will be `'default name'`\n });\n findUser().then(function (user) {\n throw new Error('Found user, but still unhappy');\n }, function (reason) {\n throw new Error('`findUser` rejected and we're unhappy');\n }).then(function (value) {\n // never reached\n }, function (reason) {\n // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.\n // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.\n });\n ```\n If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.\n ```js\n findUser().then(function (user) {\n throw new PedagogicalException('Upstream error');\n }).then(function (value) {\n // never reached\n }).then(function (value) {\n // never reached\n }, function (reason) {\n // The `PedgagocialException` is propagated all the way down to here\n });\n ```\n Assimilation\n ------------\n Sometimes the value you want to propagate to a downstream promise can only be\n retrieved asynchronously. This can be achieved by returning a promise in the\n fulfillment or rejection handler. The downstream promise will then be pending\n until the returned promise is settled. This is called *assimilation*.\n ```js\n findUser().then(function (user) {\n return findCommentsByAuthor(user);\n }).then(function (comments) {\n // The user's comments are now available\n });\n ```\n If the assimliated promise rejects, then the downstream promise will also reject.\n ```js\n findUser().then(function (user) {\n return findCommentsByAuthor(user);\n }).then(function (comments) {\n // If `findCommentsByAuthor` fulfills, we'll have the value here\n }, function (reason) {\n // If `findCommentsByAuthor` rejects, we'll have the reason here\n });\n ```\n Simple Example\n --------------\n Synchronous Example\n ```javascript\n let result;\n try {\n result = findResult();\n // success\n } catch(reason) {\n // failure\n }\n ```\n Errback Example\n ```js\n findResult(function(result, err){\n if (err) {\n // failure\n } else {\n // success\n }\n });\n ```\n Promise Example;\n ```javascript\n findResult().then(function(result){\n // success\n }, function(reason){\n // failure\n });\n ```\n Advanced Example\n --------------\n Synchronous Example\n ```javascript\n let author, books;\n try {\n author = findAuthor();\n books = findBooksByAuthor(author);\n // success\n } catch(reason) {\n // failure\n }\n ```\n Errback Example\n ```js\n function foundBooks(books) {\n }\n function failure(reason) {\n }\n findAuthor(function(author, err){\n if (err) {\n failure(err);\n // failure\n } else {\n try {\n findBoooksByAuthor(author, function(books, err) {\n if (err) {\n failure(err);\n } else {\n try {\n foundBooks(books);\n } catch(reason) {\n failure(reason);\n }\n }\n });\n } catch(error) {\n failure(err);\n }\n // success\n }\n });\n ```\n Promise Example;\n ```javascript\n findAuthor().\n then(findBooksByAuthor).\n then(function(books){\n // found books\n }).catch(function(reason){\n // something went wrong\n });\n ```\n @method then\n @param {Function} onFulfilled\n @param {Function} onRejected\n Useful for tooling.\n @return {Promise}\n */\n\n /**\n `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same\n as the catch block of a try/catch statement.\n ```js\n function findAuthor(){\n throw new Error('couldn't find that author');\n }\n // synchronous\n try {\n findAuthor();\n } catch(reason) {\n // something went wrong\n }\n // async with promises\n findAuthor().catch(function(reason){\n // something went wrong\n });\n ```\n @method catch\n @param {Function} onRejection\n Useful for tooling.\n @return {Promise}\n */\n\n\n Promise.prototype.catch = function _catch(onRejection) {\n return this.then(null, onRejection);\n };\n\n /**\n `finally` will be invoked regardless of the promise's fate just as native\n try/catch/finally behaves\n \n Synchronous example:\n \n ```js\n findAuthor() {\n if (Math.random() > 0.5) {\n throw new Error();\n }\n return new Author();\n }\n \n try {\n return findAuthor(); // succeed or fail\n } catch(error) {\n return findOtherAuther();\n } finally {\n // always runs\n // doesn't affect the return value\n }\n ```\n \n Asynchronous example:\n \n ```js\n findAuthor().catch(function(reason){\n return findOtherAuther();\n }).finally(function(){\n // author was either found, or not\n });\n ```\n \n @method finally\n @param {Function} callback\n @return {Promise}\n */\n\n\n Promise.prototype.finally = function _finally(callback) {\n var promise = this;\n var constructor = promise.constructor;\n\n if (isFunction(callback)) {\n return promise.then(function (value) {\n return constructor.resolve(callback()).then(function () {\n return value;\n });\n }, function (reason) {\n return constructor.resolve(callback()).then(function () {\n throw reason;\n });\n });\n }\n\n return promise.then(callback, callback);\n };\n\n return Promise;\n}();\n\nPromise$1.prototype.then = then;\nPromise$1.all = all;\nPromise$1.race = race;\nPromise$1.resolve = resolve$1;\nPromise$1.reject = reject$1;\nPromise$1._setScheduler = setScheduler;\nPromise$1._setAsap = setAsap;\nPromise$1._asap = asap;\n\n/*global self*/\nfunction polyfill() {\n var local = void 0;\n\n if (typeof global !== 'undefined') {\n local = global;\n } else if (typeof self !== 'undefined') {\n local = self;\n } else {\n try {\n local = Function('return this')();\n } catch (e) {\n throw new Error('polyfill failed because global object is unavailable in this environment');\n }\n }\n\n var P = local.Promise;\n\n if (P) {\n var promiseToString = null;\n try {\n promiseToString = Object.prototype.toString.call(P.resolve());\n } catch (e) {\n // silently ignored\n }\n\n if (promiseToString === '[object Promise]' && !P.cast) {\n return;\n }\n }\n\n local.Promise = Promise$1;\n}\n\n// Strange compat..\nPromise$1.polyfill = polyfill;\nPromise$1.Promise = Promise$1;\n\nreturn Promise$1;\n\n})));\n\n\n\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Log from '../utils/logger.js';\nimport LoggingControl from '../utils/logging-control.js';\nimport Polyfill from '../utils/polyfill.js';\nimport TransmuxingController from './transmuxing-controller.js';\nimport TransmuxingEvents from './transmuxing-events.js';\n\n/* post message to worker:\n data: {\n cmd: string\n param: any\n }\n\n receive message from worker:\n data: {\n msg: string,\n data: any\n }\n */\n\nlet TransmuxingWorker = function (self) {\n\n let TAG = 'TransmuxingWorker';\n let controller = null;\n let logcatListener = onLogcatCallback.bind(this);\n\n Polyfill.install();\n\n self.addEventListener('message', function (e) {\n switch (e.data.cmd) {\n case 'init':\n controller = new TransmuxingController(e.data.param[0], e.data.param[1]);\n controller.on(TransmuxingEvents.IO_ERROR, onIOError.bind(this));\n controller.on(TransmuxingEvents.DEMUX_ERROR, onDemuxError.bind(this));\n controller.on(TransmuxingEvents.INIT_SEGMENT, onInitSegment.bind(this));\n controller.on(TransmuxingEvents.MEDIA_SEGMENT, onMediaSegment.bind(this));\n controller.on(TransmuxingEvents.LOADING_COMPLETE, onLoadingComplete.bind(this));\n controller.on(TransmuxingEvents.RECOVERED_EARLY_EOF, onRecoveredEarlyEof.bind(this));\n controller.on(TransmuxingEvents.MEDIA_INFO, onMediaInfo.bind(this));\n controller.on(TransmuxingEvents.METADATA_ARRIVED, onMetaDataArrived.bind(this));\n controller.on(TransmuxingEvents.SCRIPTDATA_ARRIVED, onScriptDataArrived.bind(this));\n controller.on(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, onTimedID3MetadataArrived.bind(this));\n controller.on(TransmuxingEvents.SMPTE2038_METADATA_ARRIVED, onSMPTE2038MetadataArrived.bind(this));\n controller.on(TransmuxingEvents.SCTE35_METADATA_ARRIVED, onSCTE35MetadataArrived.bind(this));\n controller.on(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, onPESPrivateDataDescriptor.bind(this));\n controller.on(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, onPESPrivateDataArrived.bind(this));\n controller.on(TransmuxingEvents.STATISTICS_INFO, onStatisticsInfo.bind(this));\n controller.on(TransmuxingEvents.RECOMMEND_SEEKPOINT, onRecommendSeekpoint.bind(this));\n break;\n case 'destroy':\n if (controller) {\n controller.destroy();\n controller = null;\n }\n self.postMessage({msg: 'destroyed'});\n break;\n case 'start':\n controller.start();\n break;\n case 'stop':\n controller.stop();\n break;\n case 'seek':\n controller.seek(e.data.param);\n break;\n case 'pause':\n controller.pause();\n break;\n case 'resume':\n controller.resume();\n break;\n case 'logging_config': {\n let config = e.data.param;\n LoggingControl.applyConfig(config);\n\n if (config.enableCallback === true) {\n LoggingControl.addLogListener(logcatListener);\n } else {\n LoggingControl.removeLogListener(logcatListener);\n }\n break;\n }\n }\n });\n\n function onInitSegment(type, initSegment) {\n let obj = {\n msg: TransmuxingEvents.INIT_SEGMENT,\n data: {\n type: type,\n data: initSegment\n }\n };\n self.postMessage(obj, [initSegment.data]); // data: ArrayBuffer\n }\n\n function onMediaSegment(type, mediaSegment) {\n let obj = {\n msg: TransmuxingEvents.MEDIA_SEGMENT,\n data: {\n type: type,\n data: mediaSegment\n }\n };\n self.postMessage(obj, [mediaSegment.data]); // data: ArrayBuffer\n }\n\n function onLoadingComplete() {\n let obj = {\n msg: TransmuxingEvents.LOADING_COMPLETE\n };\n self.postMessage(obj);\n }\n\n function onRecoveredEarlyEof() {\n let obj = {\n msg: TransmuxingEvents.RECOVERED_EARLY_EOF\n };\n self.postMessage(obj);\n }\n\n function onMediaInfo(mediaInfo) {\n let obj = {\n msg: TransmuxingEvents.MEDIA_INFO,\n data: mediaInfo\n };\n self.postMessage(obj);\n }\n\n function onMetaDataArrived(metadata) {\n let obj = {\n msg: TransmuxingEvents.METADATA_ARRIVED,\n data: metadata\n };\n self.postMessage(obj);\n }\n\n function onScriptDataArrived(data) {\n let obj = {\n msg: TransmuxingEvents.SCRIPTDATA_ARRIVED,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onTimedID3MetadataArrived (data) {\n let obj = {\n msg: TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onSMPTE2038MetadataArrived (data) {\n let obj = {\n msg: TransmuxingEvents.SMPTE2038_METADATA_ARRIVED,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onSCTE35MetadataArrived (data) {\n let obj = {\n msg: TransmuxingEvents.SCTE35_METADATA_ARRIVED,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onPESPrivateDataDescriptor(data) {\n let obj = {\n msg: TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onPESPrivateDataArrived(data) {\n let obj = {\n msg: TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED,\n data: data\n };\n self.postMessage(obj);\n }\n\n function onStatisticsInfo(statInfo) {\n let obj = {\n msg: TransmuxingEvents.STATISTICS_INFO,\n data: statInfo\n };\n self.postMessage(obj);\n }\n\n function onIOError(type, info) {\n self.postMessage({\n msg: TransmuxingEvents.IO_ERROR,\n data: {\n type: type,\n info: info\n }\n });\n }\n\n function onDemuxError(type, info) {\n self.postMessage({\n msg: TransmuxingEvents.DEMUX_ERROR,\n data: {\n type: type,\n info: info\n }\n });\n }\n\n function onRecommendSeekpoint(milliseconds) {\n self.postMessage({\n msg: TransmuxingEvents.RECOMMEND_SEEKPOINT,\n data: milliseconds\n });\n }\n\n function onLogcatCallback(type, str) {\n self.postMessage({\n msg: 'logcat_callback',\n data: {\n type: type,\n logcat: str\n }\n });\n }\n\n};\n\nexport default TransmuxingWorker;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const defaultConfig = {\n enableWorker: false,\n enableStashBuffer: true,\n stashInitialSize: undefined,\n\n isLive: false,\n\n liveBufferLatencyChasing: false,\n liveBufferLatencyMaxLatency: 1.5,\n liveBufferLatencyMinRemain: 0.5,\n\n lazyLoad: true,\n lazyLoadMaxDuration: 3 * 60,\n lazyLoadRecoverDuration: 30,\n deferLoadAfterSourceOpen: true,\n\n // autoCleanupSourceBuffer: default as false, leave unspecified\n autoCleanupMaxBackwardDuration: 3 * 60,\n autoCleanupMinBackwardDuration: 2 * 60,\n\n statisticsInfoReportInterval: 600,\n\n fixAudioTimestampGap: true,\n\n accurateSeek: false,\n seekType: 'range', // [range, param, custom]\n seekParamStart: 'bstart',\n seekParamEnd: 'bend',\n rangeLoadZeroStart: false,\n customSeekHandler: undefined,\n reuseRedirectedURL: false,\n // referrerPolicy: leave as unspecified\n\n headers: undefined,\n customLoader: undefined\n};\n\nexport function createDefaultConfig() {\n return Object.assign({}, defaultConfig);\n}","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport IOController from '../io/io-controller.js';\nimport {createDefaultConfig} from '../config.js';\n\nclass Features {\n\n static supportMSEH264Playback() {\n return window.MediaSource &&\n window.MediaSource.isTypeSupported('video/mp4; codecs=\"avc1.42E01E,mp4a.40.2\"');\n }\n\n static supportMSEH265Playback() {\n return window.MediaSource &&\n window.MediaSource.isTypeSupported('video/mp4; codecs=\"hvc1.1.6.L93.B0\"');\n }\n\n static supportNetworkStreamIO() {\n let ioctl = new IOController({}, createDefaultConfig());\n let loaderType = ioctl.loaderType;\n ioctl.destroy();\n return loaderType == 'fetch-stream-loader' || loaderType == 'xhr-moz-chunked-loader';\n }\n\n static getNetworkLoaderTypeName() {\n let ioctl = new IOController({}, createDefaultConfig());\n let loaderType = ioctl.loaderType;\n ioctl.destroy();\n return loaderType;\n }\n\n static supportNativeMediaPlayback(mimeType) {\n if (Features.videoElement == undefined) {\n Features.videoElement = window.document.createElement('video');\n }\n let canPlay = Features.videoElement.canPlayType(mimeType);\n return canPlay === 'probably' || canPlay == 'maybe';\n }\n\n static getFeatureList() {\n let features = {\n msePlayback: false,\n mseLivePlayback: false,\n mseH265Playback: false,\n networkStreamIO: false,\n networkLoaderName: '',\n nativeMP4H264Playback: false,\n nativeMP4H265Playback: false,\n nativeWebmVP8Playback: false,\n nativeWebmVP9Playback: false\n };\n\n features.msePlayback = Features.supportMSEH264Playback();\n features.networkStreamIO = Features.supportNetworkStreamIO();\n features.networkLoaderName = Features.getNetworkLoaderTypeName();\n features.mseLivePlayback = features.msePlayback && features.networkStreamIO;\n features.mseH265Playback = Features.supportMSEH265Playback();\n features.nativeMP4H264Playback = Features.supportNativeMediaPlayback('video/mp4; codecs=\"avc1.42001E, mp4a.40.2\"');\n features.nativeMP4H265Playback = Features.supportNativeMediaPlayback('video/mp4; codecs=\"hvc1.1.6.L93.B0\"');\n features.nativeWebmVP8Playback = Features.supportNativeMediaPlayback('video/webm; codecs=\"vp8.0, vorbis\"');\n features.nativeWebmVP9Playback = Features.supportNativeMediaPlayback('video/webm; codecs=\"vp9\"');\n\n return features;\n }\n\n}\n\nexport default Features;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst PlayerEvents = {\n ERROR: 'error',\n LOADING_COMPLETE: 'loading_complete',\n RECOVERED_EARLY_EOF: 'recovered_early_eof',\n MEDIA_INFO: 'media_info',\n METADATA_ARRIVED: 'metadata_arrived',\n SCRIPTDATA_ARRIVED: 'scriptdata_arrived',\n TIMED_ID3_METADATA_ARRIVED: 'timed_id3_metadata_arrived',\n SMPTE2038_METADATA_ARRIVED: 'smpte2038_metadata_arrived',\n SCTE35_METADATA_ARRIVED: 'scte35_metadata_arrived',\n PES_PRIVATE_DATA_DESCRIPTOR: 'pes_private_data_descriptor',\n PES_PRIVATE_DATA_ARRIVED: 'pes_private_data_arrived',\n STATISTICS_INFO: 'statistics_info'\n};\n\nexport default PlayerEvents;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport work from 'webworkify-webpack';\nimport Log from '../utils/logger.js';\nimport LoggingControl from '../utils/logging-control.js';\nimport TransmuxingController from './transmuxing-controller.js';\nimport TransmuxingEvents from './transmuxing-events.js';\nimport TransmuxingWorker from './transmuxing-worker.js';\nimport MediaInfo from './media-info.js';\n\nclass Transmuxer {\n\n constructor(mediaDataSource, config) {\n this.TAG = 'Transmuxer';\n this._emitter = new EventEmitter();\n\n if (config.enableWorker && typeof (Worker) !== 'undefined') {\n try {\n this._worker = work(require.resolve('./transmuxing-worker'));\n this._workerDestroying = false;\n this._worker.addEventListener('message', this._onWorkerMessage.bind(this));\n this._worker.postMessage({cmd: 'init', param: [mediaDataSource, config]});\n this.e = {\n onLoggingConfigChanged: this._onLoggingConfigChanged.bind(this)\n };\n LoggingControl.registerListener(this.e.onLoggingConfigChanged);\n this._worker.postMessage({cmd: 'logging_config', param: LoggingControl.getConfig()});\n } catch (error) {\n Log.e(this.TAG, 'Error while initialize transmuxing worker, fallback to inline transmuxing');\n this._worker = null;\n this._controller = new TransmuxingController(mediaDataSource, config);\n }\n } else {\n this._controller = new TransmuxingController(mediaDataSource, config);\n }\n\n if (this._controller) {\n let ctl = this._controller;\n ctl.on(TransmuxingEvents.IO_ERROR, this._onIOError.bind(this));\n ctl.on(TransmuxingEvents.DEMUX_ERROR, this._onDemuxError.bind(this));\n ctl.on(TransmuxingEvents.INIT_SEGMENT, this._onInitSegment.bind(this));\n ctl.on(TransmuxingEvents.MEDIA_SEGMENT, this._onMediaSegment.bind(this));\n ctl.on(TransmuxingEvents.LOADING_COMPLETE, this._onLoadingComplete.bind(this));\n ctl.on(TransmuxingEvents.RECOVERED_EARLY_EOF, this._onRecoveredEarlyEof.bind(this));\n ctl.on(TransmuxingEvents.MEDIA_INFO, this._onMediaInfo.bind(this));\n ctl.on(TransmuxingEvents.METADATA_ARRIVED, this._onMetaDataArrived.bind(this));\n ctl.on(TransmuxingEvents.SCRIPTDATA_ARRIVED, this._onScriptDataArrived.bind(this));\n ctl.on(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, this._onTimedID3MetadataArrived.bind(this));\n ctl.on(TransmuxingEvents.SMPTE2038_METADATA_ARRIVED, this._onSMPTE2038MetadataArrived.bind(this));\n ctl.on(TransmuxingEvents.SCTE35_METADATA_ARRIVED, this._onSCTE35MetadataArrived.bind(this));\n ctl.on(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, this._onPESPrivateDataDescriptor.bind(this));\n ctl.on(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, this._onPESPrivateDataArrived.bind(this));\n ctl.on(TransmuxingEvents.STATISTICS_INFO, this._onStatisticsInfo.bind(this));\n ctl.on(TransmuxingEvents.RECOMMEND_SEEKPOINT, this._onRecommendSeekpoint.bind(this));\n }\n }\n\n destroy() {\n if (this._worker) {\n if (!this._workerDestroying) {\n this._workerDestroying = true;\n this._worker.postMessage({cmd: 'destroy'});\n LoggingControl.removeListener(this.e.onLoggingConfigChanged);\n this.e = null;\n }\n } else {\n this._controller.destroy();\n this._controller = null;\n }\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n hasWorker() {\n return this._worker != null;\n }\n\n open() {\n if (this._worker) {\n this._worker.postMessage({cmd: 'start'});\n } else {\n this._controller.start();\n }\n }\n\n close() {\n if (this._worker) {\n this._worker.postMessage({cmd: 'stop'});\n } else {\n this._controller.stop();\n }\n }\n\n seek(milliseconds) {\n if (this._worker) {\n this._worker.postMessage({cmd: 'seek', param: milliseconds});\n } else {\n this._controller.seek(milliseconds);\n }\n }\n\n pause() {\n if (this._worker) {\n this._worker.postMessage({cmd: 'pause'});\n } else {\n this._controller.pause();\n }\n }\n\n resume() {\n if (this._worker) {\n this._worker.postMessage({cmd: 'resume'});\n } else {\n this._controller.resume();\n }\n }\n\n _onInitSegment(type, initSegment) {\n // do async invoke\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.INIT_SEGMENT, type, initSegment);\n });\n }\n\n _onMediaSegment(type, mediaSegment) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.MEDIA_SEGMENT, type, mediaSegment);\n });\n }\n\n _onLoadingComplete() {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.LOADING_COMPLETE);\n });\n }\n\n _onRecoveredEarlyEof() {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.RECOVERED_EARLY_EOF);\n });\n }\n\n _onMediaInfo(mediaInfo) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.MEDIA_INFO, mediaInfo);\n });\n }\n\n _onMetaDataArrived(metadata) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.METADATA_ARRIVED, metadata);\n });\n }\n\n _onScriptDataArrived(data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.SCRIPTDATA_ARRIVED, data);\n });\n }\n\n _onTimedID3MetadataArrived (data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, data);\n })\n }\n\n _onSMPTE2038MetadataArrived (data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.SMPTE2038_METADATA_ARRIVED, data);\n })\n }\n\n _onSCTE35MetadataArrived (data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.SCTE35_METADATA_ARRIVED, data);\n })\n }\n\n _onPESPrivateDataDescriptor(data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, data);\n });\n }\n\n _onPESPrivateDataArrived(data) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, data);\n });\n }\n\n _onStatisticsInfo(statisticsInfo) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.STATISTICS_INFO, statisticsInfo);\n });\n }\n\n _onIOError(type, info) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.IO_ERROR, type, info);\n });\n }\n\n _onDemuxError(type, info) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.DEMUX_ERROR, type, info);\n });\n }\n\n _onRecommendSeekpoint(milliseconds) {\n Promise.resolve().then(() => {\n this._emitter.emit(TransmuxingEvents.RECOMMEND_SEEKPOINT, milliseconds);\n });\n }\n\n _onLoggingConfigChanged(config) {\n if (this._worker) {\n this._worker.postMessage({cmd: 'logging_config', param: config});\n }\n }\n\n _onWorkerMessage(e) {\n let message = e.data;\n let data = message.data;\n\n if (message.msg === 'destroyed' || this._workerDestroying) {\n this._workerDestroying = false;\n this._worker.terminate();\n this._worker = null;\n return;\n }\n\n switch (message.msg) {\n case TransmuxingEvents.INIT_SEGMENT:\n case TransmuxingEvents.MEDIA_SEGMENT:\n this._emitter.emit(message.msg, data.type, data.data);\n break;\n case TransmuxingEvents.LOADING_COMPLETE:\n case TransmuxingEvents.RECOVERED_EARLY_EOF:\n this._emitter.emit(message.msg);\n break;\n case TransmuxingEvents.MEDIA_INFO:\n Object.setPrototypeOf(data, MediaInfo.prototype);\n this._emitter.emit(message.msg, data);\n break;\n case TransmuxingEvents.METADATA_ARRIVED:\n case TransmuxingEvents.SCRIPTDATA_ARRIVED:\n case TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED:\n case TransmuxingEvents.SMPTE2038_METADATA_ARRIVED:\n case TransmuxingEvents.SCTE35_METADATA_ARRIVED:\n case TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR:\n case TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED:\n case TransmuxingEvents.STATISTICS_INFO:\n this._emitter.emit(message.msg, data);\n break;\n case TransmuxingEvents.IO_ERROR:\n case TransmuxingEvents.DEMUX_ERROR:\n this._emitter.emit(message.msg, data.type, data.info);\n break;\n case TransmuxingEvents.RECOMMEND_SEEKPOINT:\n this._emitter.emit(message.msg, data);\n break;\n case 'logcat_callback':\n Log.emitter.emit('log', data.type, data.logcat);\n break;\n default:\n break;\n }\n }\n\n}\n\nexport default Transmuxer;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst MSEEvents = {\n ERROR: 'error',\n SOURCE_OPEN: 'source_open',\n UPDATE_END: 'update_end',\n BUFFER_FULL: 'buffer_full'\n};\n\nexport default MSEEvents;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport Log from '../utils/logger.js';\nimport Browser from '../utils/browser.js';\nimport MSEEvents from './mse-events.js';\nimport {SampleInfo, IDRSampleList} from './media-segment-info.js';\nimport {IllegalStateException} from '../utils/exception.js';\n\n// Media Source Extensions controller\nclass MSEController {\n\n constructor(config) {\n this.TAG = 'MSEController';\n\n this._config = config;\n this._emitter = new EventEmitter();\n\n if (this._config.isLive && this._config.autoCleanupSourceBuffer == undefined) {\n // For live stream, do auto cleanup by default\n this._config.autoCleanupSourceBuffer = true;\n }\n\n this.e = {\n onSourceOpen: this._onSourceOpen.bind(this),\n onSourceEnded: this._onSourceEnded.bind(this),\n onSourceClose: this._onSourceClose.bind(this),\n onSourceBufferError: this._onSourceBufferError.bind(this),\n onSourceBufferUpdateEnd: this._onSourceBufferUpdateEnd.bind(this)\n };\n\n this._mediaSource = null;\n this._mediaSourceObjectURL = null;\n this._mediaElement = null;\n\n this._isBufferFull = false;\n this._hasPendingEos = false;\n\n this._requireSetMediaDuration = false;\n this._pendingMediaDuration = 0;\n\n this._pendingSourceBufferInit = [];\n this._mimeTypes = {\n video: null,\n audio: null\n };\n this._sourceBuffers = {\n video: null,\n audio: null\n };\n this._lastInitSegments = {\n video: null,\n audio: null\n };\n this._pendingSegments = {\n video: [],\n audio: []\n };\n this._pendingRemoveRanges = {\n video: [],\n audio: []\n };\n this._idrList = new IDRSampleList();\n }\n\n destroy() {\n if (this._mediaElement || this._mediaSource) {\n this.detachMediaElement();\n }\n this.e = null;\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n attachMediaElement(mediaElement) {\n if (this._mediaSource) {\n throw new IllegalStateException('MediaSource has been attached to an HTMLMediaElement!');\n }\n let ms = this._mediaSource = new window.MediaSource();\n ms.addEventListener('sourceopen', this.e.onSourceOpen);\n ms.addEventListener('sourceended', this.e.onSourceEnded);\n ms.addEventListener('sourceclose', this.e.onSourceClose);\n\n this._mediaElement = mediaElement;\n this._mediaSourceObjectURL = window.URL.createObjectURL(this._mediaSource);\n mediaElement.src = this._mediaSourceObjectURL;\n }\n\n detachMediaElement() {\n if (this._mediaSource) {\n let ms = this._mediaSource;\n for (let type in this._sourceBuffers) {\n // pending segments should be discard\n let ps = this._pendingSegments[type];\n ps.splice(0, ps.length);\n this._pendingSegments[type] = null;\n this._pendingRemoveRanges[type] = null;\n this._lastInitSegments[type] = null;\n\n // remove all sourcebuffers\n let sb = this._sourceBuffers[type];\n if (sb) {\n if (ms.readyState !== 'closed') {\n // ms edge can throw an error: Unexpected call to method or property access\n try {\n ms.removeSourceBuffer(sb);\n } catch (error) {\n Log.e(this.TAG, error.message);\n }\n sb.removeEventListener('error', this.e.onSourceBufferError);\n sb.removeEventListener('updateend', this.e.onSourceBufferUpdateEnd);\n }\n this._mimeTypes[type] = null;\n this._sourceBuffers[type] = null;\n }\n }\n if (ms.readyState === 'open') {\n try {\n ms.endOfStream();\n } catch (error) {\n Log.e(this.TAG, error.message);\n }\n }\n ms.removeEventListener('sourceopen', this.e.onSourceOpen);\n ms.removeEventListener('sourceended', this.e.onSourceEnded);\n ms.removeEventListener('sourceclose', this.e.onSourceClose);\n this._pendingSourceBufferInit = [];\n this._isBufferFull = false;\n this._idrList.clear();\n this._mediaSource = null;\n }\n\n if (this._mediaElement) {\n this._mediaElement.src = '';\n this._mediaElement.removeAttribute('src');\n this._mediaElement = null;\n }\n if (this._mediaSourceObjectURL) {\n window.URL.revokeObjectURL(this._mediaSourceObjectURL);\n this._mediaSourceObjectURL = null;\n }\n }\n\n appendInitSegment(initSegment, deferred) {\n if (!this._mediaSource || this._mediaSource.readyState !== 'open') {\n // sourcebuffer creation requires mediaSource.readyState === 'open'\n // so we defer the sourcebuffer creation, until sourceopen event triggered\n this._pendingSourceBufferInit.push(initSegment);\n // make sure that this InitSegment is in the front of pending segments queue\n this._pendingSegments[initSegment.type].push(initSegment);\n return;\n }\n\n let is = initSegment;\n let mimeType = `${is.container}`;\n if (is.codec && is.codec.length > 0) {\n mimeType += `;codecs=${is.codec}`;\n }\n\n let firstInitSegment = false;\n\n Log.v(this.TAG, 'Received Initialization Segment, mimeType: ' + mimeType);\n this._lastInitSegments[is.type] = is;\n\n if (mimeType !== this._mimeTypes[is.type]) {\n if (!this._mimeTypes[is.type]) { // empty, first chance create sourcebuffer\n firstInitSegment = true;\n try {\n let sb = this._sourceBuffers[is.type] = this._mediaSource.addSourceBuffer(mimeType);\n sb.addEventListener('error', this.e.onSourceBufferError);\n sb.addEventListener('updateend', this.e.onSourceBufferUpdateEnd);\n } catch (error) {\n Log.e(this.TAG, error.message);\n this._emitter.emit(MSEEvents.ERROR, {code: error.code, msg: error.message});\n return;\n }\n } else {\n Log.v(this.TAG, `Notice: ${is.type} mimeType changed, origin: ${this._mimeTypes[is.type]}, target: ${mimeType}`);\n }\n this._mimeTypes[is.type] = mimeType;\n }\n\n if (!deferred) {\n // deferred means this InitSegment has been pushed to pendingSegments queue\n this._pendingSegments[is.type].push(is);\n }\n if (!firstInitSegment) { // append immediately only if init segment in subsequence\n if (this._sourceBuffers[is.type] && !this._sourceBuffers[is.type].updating) {\n this._doAppendSegments();\n }\n }\n if (Browser.safari && is.container === 'audio/mpeg' && is.mediaDuration > 0) {\n // 'audio/mpeg' track under Safari may cause MediaElement's duration to be NaN\n // Manually correct MediaSource.duration to make progress bar seekable, and report right duration\n this._requireSetMediaDuration = true;\n this._pendingMediaDuration = is.mediaDuration / 1000; // in seconds\n this._updateMediaSourceDuration();\n }\n }\n\n appendMediaSegment(mediaSegment) {\n let ms = mediaSegment;\n this._pendingSegments[ms.type].push(ms);\n\n if (this._config.autoCleanupSourceBuffer && this._needCleanupSourceBuffer()) {\n this._doCleanupSourceBuffer();\n }\n\n let sb = this._sourceBuffers[ms.type];\n if (sb && !sb.updating && !this._hasPendingRemoveRanges()) {\n this._doAppendSegments();\n }\n }\n\n seek(seconds) {\n // remove all appended buffers\n for (let type in this._sourceBuffers) {\n if (!this._sourceBuffers[type]) {\n continue;\n }\n\n // abort current buffer append algorithm\n let sb = this._sourceBuffers[type];\n if (this._mediaSource.readyState === 'open') {\n try {\n // If range removal algorithm is running, InvalidStateError will be throwed\n // Ignore it.\n sb.abort();\n } catch (error) {\n Log.e(this.TAG, error.message);\n }\n }\n\n // IDRList should be clear\n this._idrList.clear();\n\n // pending segments should be discard\n let ps = this._pendingSegments[type];\n ps.splice(0, ps.length);\n\n if (this._mediaSource.readyState === 'closed') {\n // Parent MediaSource object has been detached from HTMLMediaElement\n continue;\n }\n\n // record ranges to be remove from SourceBuffer\n for (let i = 0; i < sb.buffered.length; i++) {\n let start = sb.buffered.start(i);\n let end = sb.buffered.end(i);\n this._pendingRemoveRanges[type].push({start, end});\n }\n\n // if sb is not updating, let's remove ranges now!\n if (!sb.updating) {\n this._doRemoveRanges();\n }\n\n // Safari 10 may get InvalidStateError in the later appendBuffer() after SourceBuffer.remove() call\n // Internal parser's state may be invalid at this time. Re-append last InitSegment to workaround.\n // Related issue: https://bugs.webkit.org/show_bug.cgi?id=159230\n if (Browser.safari) {\n let lastInitSegment = this._lastInitSegments[type];\n if (lastInitSegment) {\n this._pendingSegments[type].push(lastInitSegment);\n if (!sb.updating) {\n this._doAppendSegments();\n }\n }\n }\n }\n }\n\n endOfStream() {\n let ms = this._mediaSource;\n let sb = this._sourceBuffers;\n if (!ms || ms.readyState !== 'open') {\n if (ms && ms.readyState === 'closed' && this._hasPendingSegments()) {\n // If MediaSource hasn't turned into open state, and there're pending segments\n // Mark pending endOfStream, defer call until all pending segments appended complete\n this._hasPendingEos = true;\n }\n return;\n }\n if (sb.video && sb.video.updating || sb.audio && sb.audio.updating) {\n // If any sourcebuffer is updating, defer endOfStream operation\n // See _onSourceBufferUpdateEnd()\n this._hasPendingEos = true;\n } else {\n this._hasPendingEos = false;\n // Notify media data loading complete\n // This is helpful for correcting total duration to match last media segment\n // Otherwise MediaElement's ended event may not be triggered\n ms.endOfStream();\n }\n }\n\n getNearestKeyframe(dts) {\n return this._idrList.getLastSyncPointBeforeDts(dts);\n }\n\n _needCleanupSourceBuffer() {\n if (!this._config.autoCleanupSourceBuffer) {\n return false;\n }\n\n let currentTime = this._mediaElement.currentTime;\n\n for (let type in this._sourceBuffers) {\n let sb = this._sourceBuffers[type];\n if (sb) {\n let buffered = sb.buffered;\n if (buffered.length >= 1) {\n if (currentTime - buffered.start(0) >= this._config.autoCleanupMaxBackwardDuration) {\n return true;\n }\n }\n }\n }\n\n return false;\n }\n\n _doCleanupSourceBuffer() {\n let currentTime = this._mediaElement.currentTime;\n\n for (let type in this._sourceBuffers) {\n let sb = this._sourceBuffers[type];\n if (sb) {\n let buffered = sb.buffered;\n let doRemove = false;\n\n for (let i = 0; i < buffered.length; i++) {\n let start = buffered.start(i);\n let end = buffered.end(i);\n\n if (start <= currentTime && currentTime < end + 3) { // padding 3 seconds\n if (currentTime - start >= this._config.autoCleanupMaxBackwardDuration) {\n doRemove = true;\n let removeEnd = currentTime - this._config.autoCleanupMinBackwardDuration;\n this._pendingRemoveRanges[type].push({start: start, end: removeEnd});\n }\n } else if (end < currentTime) {\n doRemove = true;\n this._pendingRemoveRanges[type].push({start: start, end: end});\n }\n }\n\n if (doRemove && !sb.updating) {\n this._doRemoveRanges();\n }\n }\n }\n }\n\n _updateMediaSourceDuration() {\n let sb = this._sourceBuffers;\n if (this._mediaElement.readyState === 0 || this._mediaSource.readyState !== 'open') {\n return;\n }\n if ((sb.video && sb.video.updating) || (sb.audio && sb.audio.updating)) {\n return;\n }\n\n let current = this._mediaSource.duration;\n let target = this._pendingMediaDuration;\n\n if (target > 0 && (isNaN(current) || target > current)) {\n Log.v(this.TAG, `Update MediaSource duration from ${current} to ${target}`);\n this._mediaSource.duration = target;\n }\n\n this._requireSetMediaDuration = false;\n this._pendingMediaDuration = 0;\n }\n\n _doRemoveRanges() {\n for (let type in this._pendingRemoveRanges) {\n if (!this._sourceBuffers[type] || this._sourceBuffers[type].updating) {\n continue;\n }\n let sb = this._sourceBuffers[type];\n let ranges = this._pendingRemoveRanges[type];\n while (ranges.length && !sb.updating) {\n let range = ranges.shift();\n sb.remove(range.start, range.end);\n }\n }\n }\n\n _doAppendSegments() {\n let pendingSegments = this._pendingSegments;\n\n for (let type in pendingSegments) {\n if (!this._sourceBuffers[type] || this._sourceBuffers[type].updating) {\n continue;\n }\n\n if (pendingSegments[type].length > 0) {\n let segment = pendingSegments[type].shift();\n\n if (segment.timestampOffset) {\n // For MPEG audio stream in MSE, if unbuffered-seeking occurred\n // We need explicitly set timestampOffset to the desired point in timeline for mpeg SourceBuffer.\n let currentOffset = this._sourceBuffers[type].timestampOffset;\n let targetOffset = segment.timestampOffset / 1000; // in seconds\n\n let delta = Math.abs(currentOffset - targetOffset);\n if (delta > 0.1) { // If time delta > 100ms\n Log.v(this.TAG, `Update MPEG audio timestampOffset from ${currentOffset} to ${targetOffset}`);\n this._sourceBuffers[type].timestampOffset = targetOffset;\n }\n delete segment.timestampOffset;\n }\n\n if (!segment.data || segment.data.byteLength === 0) {\n // Ignore empty buffer\n continue;\n }\n\n try {\n this._sourceBuffers[type].appendBuffer(segment.data);\n this._isBufferFull = false;\n if (type === 'video' && segment.hasOwnProperty('info')) {\n this._idrList.appendArray(segment.info.syncPoints);\n }\n } catch (error) {\n this._pendingSegments[type].unshift(segment);\n if (error.code === 22) { // QuotaExceededError\n /* Notice that FireFox may not throw QuotaExceededError if SourceBuffer is full\n * Currently we can only do lazy-load to avoid SourceBuffer become scattered.\n * SourceBuffer eviction policy may be changed in future version of FireFox.\n *\n * Related issues:\n * https://bugzilla.mozilla.org/show_bug.cgi?id=1279885\n * https://bugzilla.mozilla.org/show_bug.cgi?id=1280023\n */\n\n // report buffer full, abort network IO\n if (!this._isBufferFull) {\n this._emitter.emit(MSEEvents.BUFFER_FULL);\n }\n this._isBufferFull = true;\n } else {\n Log.e(this.TAG, error.message);\n this._emitter.emit(MSEEvents.ERROR, {code: error.code, msg: error.message});\n }\n }\n }\n }\n }\n\n _onSourceOpen() {\n Log.v(this.TAG, 'MediaSource onSourceOpen');\n this._mediaSource.removeEventListener('sourceopen', this.e.onSourceOpen);\n // deferred sourcebuffer creation / initialization\n if (this._pendingSourceBufferInit.length > 0) {\n let pendings = this._pendingSourceBufferInit;\n while (pendings.length) {\n let segment = pendings.shift();\n this.appendInitSegment(segment, true);\n }\n }\n // there may be some pending media segments, append them\n if (this._hasPendingSegments()) {\n this._doAppendSegments();\n }\n this._emitter.emit(MSEEvents.SOURCE_OPEN);\n }\n\n _onSourceEnded() {\n // fired on endOfStream\n Log.v(this.TAG, 'MediaSource onSourceEnded');\n }\n\n _onSourceClose() {\n // fired on detaching from media element\n Log.v(this.TAG, 'MediaSource onSourceClose');\n if (this._mediaSource && this.e != null) {\n this._mediaSource.removeEventListener('sourceopen', this.e.onSourceOpen);\n this._mediaSource.removeEventListener('sourceended', this.e.onSourceEnded);\n this._mediaSource.removeEventListener('sourceclose', this.e.onSourceClose);\n }\n }\n\n _hasPendingSegments() {\n let ps = this._pendingSegments;\n return ps.video.length > 0 || ps.audio.length > 0;\n }\n\n _hasPendingRemoveRanges() {\n let prr = this._pendingRemoveRanges;\n return prr.video.length > 0 || prr.audio.length > 0;\n }\n\n _onSourceBufferUpdateEnd() {\n if (this._requireSetMediaDuration) {\n this._updateMediaSourceDuration();\n } else if (this._hasPendingRemoveRanges()) {\n this._doRemoveRanges();\n } else if (this._hasPendingSegments()) {\n this._doAppendSegments();\n } else if (this._hasPendingEos) {\n this.endOfStream();\n }\n this._emitter.emit(MSEEvents.UPDATE_END);\n }\n\n _onSourceBufferError(e) {\n Log.e(this.TAG, `SourceBuffer Error: ${e}`);\n // this error might not always be fatal, just ignore it\n }\n\n}\n\nexport default MSEController;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {LoaderErrors} from '../io/loader.js';\nimport DemuxErrors from '../demux/demux-errors.js';\n\nexport const ErrorTypes = {\n NETWORK_ERROR: 'NetworkError',\n MEDIA_ERROR: 'MediaError',\n OTHER_ERROR: 'OtherError'\n};\n\nexport const ErrorDetails = {\n NETWORK_EXCEPTION: LoaderErrors.EXCEPTION,\n NETWORK_STATUS_CODE_INVALID: LoaderErrors.HTTP_STATUS_CODE_INVALID,\n NETWORK_TIMEOUT: LoaderErrors.CONNECTING_TIMEOUT,\n NETWORK_UNRECOVERABLE_EARLY_EOF: LoaderErrors.UNRECOVERABLE_EARLY_EOF,\n\n MEDIA_MSE_ERROR: 'MediaMSEError',\n\n MEDIA_FORMAT_ERROR: DemuxErrors.FORMAT_ERROR,\n MEDIA_FORMAT_UNSUPPORTED: DemuxErrors.FORMAT_UNSUPPORTED,\n MEDIA_CODEC_UNSUPPORTED: DemuxErrors.CODEC_UNSUPPORTED\n};","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport Log from '../utils/logger.js';\nimport Browser from '../utils/browser.js';\nimport PlayerEvents from './player-events.js';\nimport Transmuxer from '../core/transmuxer.js';\nimport TransmuxingEvents from '../core/transmuxing-events.js';\nimport MSEController from '../core/mse-controller.js';\nimport MSEEvents from '../core/mse-events.js';\nimport {ErrorTypes, ErrorDetails} from './player-errors.js';\nimport {createDefaultConfig} from '../config.js';\nimport {InvalidArgumentException, IllegalStateException} from '../utils/exception.js';\n\nclass MSEPlayer {\n\n constructor(mediaDataSource, config) {\n this.TAG = 'MSEPlayer';\n this._type = 'MSEPlayer';\n this._emitter = new EventEmitter();\n\n this._config = createDefaultConfig();\n if (typeof config === 'object') {\n Object.assign(this._config, config);\n }\n\n let typeLowerCase = mediaDataSource.type.toLowerCase();\n if (typeLowerCase !== 'mse'\n && typeLowerCase !== 'mpegts'\n && typeLowerCase !== 'm2ts'\n && typeLowerCase !== 'flv') {\n throw new InvalidArgumentException('MSEPlayer requires an mpegts/m2ts/flv MediaDataSource input!');\n }\n\n if (mediaDataSource.isLive === true) {\n this._config.isLive = true;\n }\n\n this.e = {\n onvLoadedMetadata: this._onvLoadedMetadata.bind(this),\n onvSeeking: this._onvSeeking.bind(this),\n onvCanPlay: this._onvCanPlay.bind(this),\n onvStalled: this._onvStalled.bind(this),\n onvProgress: this._onvProgress.bind(this)\n };\n\n if (self.performance && self.performance.now) {\n this._now = self.performance.now.bind(self.performance);\n } else {\n this._now = Date.now;\n }\n\n this._pendingSeekTime = null; // in seconds\n this._requestSetTime = false;\n this._seekpointRecord = null;\n this._progressChecker = null;\n\n this._mediaDataSource = mediaDataSource;\n this._mediaElement = null;\n this._msectl = null;\n this._transmuxer = null;\n\n this._mseSourceOpened = false;\n this._hasPendingLoad = false;\n this._receivedCanPlay = false;\n\n this._mediaInfo = null;\n this._statisticsInfo = null;\n\n let chromeNeedIDRFix = (Browser.chrome &&\n (Browser.version.major < 50 ||\n (Browser.version.major === 50 && Browser.version.build < 2661)));\n this._alwaysSeekKeyframe = (chromeNeedIDRFix || Browser.msedge || Browser.msie) ? true : false;\n\n if (this._alwaysSeekKeyframe) {\n this._config.accurateSeek = false;\n }\n }\n\n destroy() {\n if (this._progressChecker != null) {\n window.clearInterval(this._progressChecker);\n this._progressChecker = null;\n }\n if (this._transmuxer) {\n this.unload();\n }\n if (this._mediaElement) {\n this.detachMediaElement();\n }\n this.e = null;\n this._mediaDataSource = null;\n\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n if (event === PlayerEvents.MEDIA_INFO) {\n if (this._mediaInfo != null) {\n Promise.resolve().then(() => {\n this._emitter.emit(PlayerEvents.MEDIA_INFO, this.mediaInfo);\n });\n }\n } else if (event === PlayerEvents.STATISTICS_INFO) {\n if (this._statisticsInfo != null) {\n Promise.resolve().then(() => {\n this._emitter.emit(PlayerEvents.STATISTICS_INFO, this.statisticsInfo);\n });\n }\n }\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n attachMediaElement(mediaElement) {\n this._mediaElement = mediaElement;\n mediaElement.addEventListener('loadedmetadata', this.e.onvLoadedMetadata);\n mediaElement.addEventListener('seeking', this.e.onvSeeking);\n mediaElement.addEventListener('canplay', this.e.onvCanPlay);\n mediaElement.addEventListener('stalled', this.e.onvStalled);\n mediaElement.addEventListener('progress', this.e.onvProgress);\n\n this._msectl = new MSEController(this._config);\n\n this._msectl.on(MSEEvents.UPDATE_END, this._onmseUpdateEnd.bind(this));\n this._msectl.on(MSEEvents.BUFFER_FULL, this._onmseBufferFull.bind(this));\n this._msectl.on(MSEEvents.SOURCE_OPEN, () => {\n this._mseSourceOpened = true;\n if (this._hasPendingLoad) {\n this._hasPendingLoad = false;\n this.load();\n }\n });\n this._msectl.on(MSEEvents.ERROR, (info) => {\n this._emitter.emit(PlayerEvents.ERROR,\n ErrorTypes.MEDIA_ERROR,\n ErrorDetails.MEDIA_MSE_ERROR,\n info\n );\n });\n\n this._msectl.attachMediaElement(mediaElement);\n\n if (this._pendingSeekTime != null) {\n try {\n mediaElement.currentTime = this._pendingSeekTime;\n this._pendingSeekTime = null;\n } catch (e) {\n // IE11 may throw InvalidStateError if readyState === 0\n // We can defer set currentTime operation after loadedmetadata\n }\n }\n }\n\n detachMediaElement() {\n if (this._mediaElement) {\n this._msectl.detachMediaElement();\n this._mediaElement.removeEventListener('loadedmetadata', this.e.onvLoadedMetadata);\n this._mediaElement.removeEventListener('seeking', this.e.onvSeeking);\n this._mediaElement.removeEventListener('canplay', this.e.onvCanPlay);\n this._mediaElement.removeEventListener('stalled', this.e.onvStalled);\n this._mediaElement.removeEventListener('progress', this.e.onvProgress);\n this._mediaElement = null;\n }\n if (this._msectl) {\n this._msectl.destroy();\n this._msectl = null;\n }\n }\n\n load() {\n if (!this._mediaElement) {\n throw new IllegalStateException('HTMLMediaElement must be attached before load()!');\n }\n if (this._transmuxer) {\n throw new IllegalStateException('MSEPlayer.load() has been called, please call unload() first!');\n }\n if (this._hasPendingLoad) {\n return;\n }\n\n if (this._config.deferLoadAfterSourceOpen && this._mseSourceOpened === false) {\n this._hasPendingLoad = true;\n return;\n }\n\n if (this._mediaElement.readyState > 0) {\n this._requestSetTime = true;\n // IE11 may throw InvalidStateError if readyState === 0\n this._mediaElement.currentTime = 0;\n }\n\n this._transmuxer = new Transmuxer(this._mediaDataSource, this._config);\n\n this._transmuxer.on(TransmuxingEvents.INIT_SEGMENT, (type, is) => {\n this._msectl.appendInitSegment(is);\n });\n this._transmuxer.on(TransmuxingEvents.MEDIA_SEGMENT, (type, ms) => {\n this._msectl.appendMediaSegment(ms);\n\n // lazyLoad check\n if (this._config.lazyLoad && !this._config.isLive) {\n let currentTime = this._mediaElement.currentTime;\n if (ms.info.endDts >= (currentTime + this._config.lazyLoadMaxDuration) * 1000) {\n if (this._progressChecker == null) {\n Log.v(this.TAG, 'Maximum buffering duration exceeded, suspend transmuxing task');\n this._suspendTransmuxer();\n }\n }\n }\n });\n this._transmuxer.on(TransmuxingEvents.LOADING_COMPLETE, () => {\n this._msectl.endOfStream();\n this._emitter.emit(PlayerEvents.LOADING_COMPLETE);\n });\n this._transmuxer.on(TransmuxingEvents.RECOVERED_EARLY_EOF, () => {\n this._emitter.emit(PlayerEvents.RECOVERED_EARLY_EOF);\n });\n this._transmuxer.on(TransmuxingEvents.IO_ERROR, (detail, info) => {\n this._emitter.emit(PlayerEvents.ERROR, ErrorTypes.NETWORK_ERROR, detail, info);\n });\n this._transmuxer.on(TransmuxingEvents.DEMUX_ERROR, (detail, info) => {\n this._emitter.emit(PlayerEvents.ERROR, ErrorTypes.MEDIA_ERROR, detail, {code: -1, msg: info});\n });\n this._transmuxer.on(TransmuxingEvents.MEDIA_INFO, (mediaInfo) => {\n this._mediaInfo = mediaInfo;\n this._emitter.emit(PlayerEvents.MEDIA_INFO, Object.assign({}, mediaInfo));\n });\n this._transmuxer.on(TransmuxingEvents.METADATA_ARRIVED, (metadata) => {\n this._emitter.emit(PlayerEvents.METADATA_ARRIVED, metadata);\n });\n this._transmuxer.on(TransmuxingEvents.SCRIPTDATA_ARRIVED, (data) => {\n this._emitter.emit(PlayerEvents.SCRIPTDATA_ARRIVED, data);\n });\n this._transmuxer.on(TransmuxingEvents.TIMED_ID3_METADATA_ARRIVED, (timed_id3_metadata) => {\n this._emitter.emit(PlayerEvents.TIMED_ID3_METADATA_ARRIVED, timed_id3_metadata);\n });\n this._transmuxer.on(TransmuxingEvents.SMPTE2038_METADATA_ARRIVED, (smpte2038_metadata) => {\n this._emitter.emit(PlayerEvents.SMPTE2038_METADATA_ARRIVED, smpte2038_metadata);\n });\n this._transmuxer.on(TransmuxingEvents.SCTE35_METADATA_ARRIVED, (scte35_metadata) => {\n this._emitter.emit(PlayerEvents.SCTE35_METADATA_ARRIVED, scte35_metadata);\n });\n this._transmuxer.on(TransmuxingEvents.PES_PRIVATE_DATA_DESCRIPTOR, (descriptor) => {\n this._emitter.emit(PlayerEvents.PES_PRIVATE_DATA_DESCRIPTOR, descriptor);\n });\n this._transmuxer.on(TransmuxingEvents.PES_PRIVATE_DATA_ARRIVED, (private_data) => {\n this._emitter.emit(PlayerEvents.PES_PRIVATE_DATA_ARRIVED, private_data);\n });\n this._transmuxer.on(TransmuxingEvents.STATISTICS_INFO, (statInfo) => {\n this._statisticsInfo = this._fillStatisticsInfo(statInfo);\n this._emitter.emit(PlayerEvents.STATISTICS_INFO, Object.assign({}, this._statisticsInfo));\n });\n this._transmuxer.on(TransmuxingEvents.RECOMMEND_SEEKPOINT, (milliseconds) => {\n if (this._mediaElement && !this._config.accurateSeek) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = milliseconds / 1000;\n }\n });\n\n this._transmuxer.open();\n }\n\n unload() {\n if (this._mediaElement) {\n this._mediaElement.pause();\n }\n if (this._msectl) {\n this._msectl.seek(0);\n }\n if (this._transmuxer) {\n this._transmuxer.close();\n this._transmuxer.destroy();\n this._transmuxer = null;\n }\n }\n\n play() {\n return this._mediaElement.play();\n }\n\n pause() {\n this._mediaElement.pause();\n }\n\n get type() {\n return this._type;\n }\n\n get buffered() {\n return this._mediaElement.buffered;\n }\n\n get duration() {\n return this._mediaElement.duration;\n }\n\n get volume() {\n return this._mediaElement.volume;\n }\n\n set volume(value) {\n this._mediaElement.volume = value;\n }\n\n get muted() {\n return this._mediaElement.muted;\n }\n\n set muted(muted) {\n this._mediaElement.muted = muted;\n }\n\n get currentTime() {\n if (this._mediaElement) {\n return this._mediaElement.currentTime;\n }\n return 0;\n }\n\n set currentTime(seconds) {\n if (this._mediaElement) {\n this._internalSeek(seconds);\n } else {\n this._pendingSeekTime = seconds;\n }\n }\n\n get mediaInfo() {\n return Object.assign({}, this._mediaInfo);\n }\n\n get statisticsInfo() {\n if (this._statisticsInfo == null) {\n this._statisticsInfo = {};\n }\n this._statisticsInfo = this._fillStatisticsInfo(this._statisticsInfo);\n return Object.assign({}, this._statisticsInfo);\n }\n\n _fillStatisticsInfo(statInfo) {\n statInfo.playerType = this._type;\n\n if (!(this._mediaElement instanceof HTMLVideoElement)) {\n return statInfo;\n }\n\n let hasQualityInfo = true;\n let decoded = 0;\n let dropped = 0;\n\n if (this._mediaElement.getVideoPlaybackQuality) {\n let quality = this._mediaElement.getVideoPlaybackQuality();\n decoded = quality.totalVideoFrames;\n dropped = quality.droppedVideoFrames;\n } else if (this._mediaElement.webkitDecodedFrameCount != undefined) {\n decoded = this._mediaElement.webkitDecodedFrameCount;\n dropped = this._mediaElement.webkitDroppedFrameCount;\n } else {\n hasQualityInfo = false;\n }\n\n if (hasQualityInfo) {\n statInfo.decodedFrames = decoded;\n statInfo.droppedFrames = dropped;\n }\n\n return statInfo;\n }\n\n _onmseUpdateEnd() {\n let buffered = this._mediaElement.buffered;\n let currentTime = this._mediaElement.currentTime;\n\n if (this._config.isLive\n && this._config.liveBufferLatencyChasing\n && buffered.length > 0\n && !this._mediaElement.paused) {\n let buffered_end = buffered.end(buffered.length - 1);\n if (buffered_end > this._config.liveBufferLatencyMaxLatency) {\n // Ensure there's enough buffered data\n if (buffered_end - currentTime > this._config.liveBufferLatencyMaxLatency) {\n // if remained data duration has larger than config.liveBufferLatencyMaxLatency\n let target_time = buffered_end - this._config.liveBufferLatencyMinRemain;\n this.currentTime = target_time;\n }\n }\n }\n\n if (!this._config.lazyLoad || this._config.isLive) {\n return;\n }\n\n let currentRangeStart = 0;\n let currentRangeEnd = 0;\n\n for (let i = 0; i < buffered.length; i++) {\n let start = buffered.start(i);\n let end = buffered.end(i);\n if (start <= currentTime && currentTime < end) {\n currentRangeStart = start;\n currentRangeEnd = end;\n break;\n }\n }\n\n if (currentRangeEnd >= currentTime + this._config.lazyLoadMaxDuration && this._progressChecker == null) {\n Log.v(this.TAG, 'Maximum buffering duration exceeded, suspend transmuxing task');\n this._suspendTransmuxer();\n }\n }\n\n _onmseBufferFull() {\n Log.v(this.TAG, 'MSE SourceBuffer is full, suspend transmuxing task');\n if (this._progressChecker == null) {\n this._suspendTransmuxer();\n }\n }\n\n _suspendTransmuxer() {\n if (this._transmuxer) {\n this._transmuxer.pause();\n\n if (this._progressChecker == null) {\n this._progressChecker = window.setInterval(this._checkProgressAndResume.bind(this), 1000);\n }\n }\n }\n\n _checkProgressAndResume() {\n let currentTime = this._mediaElement.currentTime;\n let buffered = this._mediaElement.buffered;\n\n let needResume = false;\n\n for (let i = 0; i < buffered.length; i++) {\n let from = buffered.start(i);\n let to = buffered.end(i);\n if (currentTime >= from && currentTime < to) {\n if (currentTime >= to - this._config.lazyLoadRecoverDuration) {\n needResume = true;\n }\n break;\n }\n }\n\n if (needResume) {\n window.clearInterval(this._progressChecker);\n this._progressChecker = null;\n if (needResume) {\n Log.v(this.TAG, 'Continue loading from paused position');\n this._transmuxer.resume();\n }\n }\n }\n\n _isTimepointBuffered(seconds) {\n let buffered = this._mediaElement.buffered;\n\n for (let i = 0; i < buffered.length; i++) {\n let from = buffered.start(i);\n let to = buffered.end(i);\n if (seconds >= from && seconds < to) {\n return true;\n }\n }\n return false;\n }\n\n _internalSeek(seconds) {\n let directSeek = this._isTimepointBuffered(seconds);\n\n let directSeekBegin = false;\n let directSeekBeginTime = 0;\n\n if (seconds < 1.0 && this._mediaElement.buffered.length > 0) {\n let videoBeginTime = this._mediaElement.buffered.start(0);\n if ((videoBeginTime < 1.0 && seconds < videoBeginTime) || Browser.safari) {\n directSeekBegin = true;\n // also workaround for Safari: Seek to 0 may cause video stuck, use 0.1 to avoid\n directSeekBeginTime = Browser.safari ? 0.1 : videoBeginTime;\n }\n }\n\n if (directSeekBegin) { // seek to video begin, set currentTime directly if beginPTS buffered\n this._requestSetTime = true;\n this._mediaElement.currentTime = directSeekBeginTime;\n } else if (directSeek) { // buffered position\n if (!this._alwaysSeekKeyframe) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = seconds;\n } else {\n let idr = this._msectl.getNearestKeyframe(Math.floor(seconds * 1000));\n this._requestSetTime = true;\n if (idr != null) {\n this._mediaElement.currentTime = idr.dts / 1000;\n } else {\n this._mediaElement.currentTime = seconds;\n }\n }\n if (this._progressChecker != null) {\n this._checkProgressAndResume();\n }\n } else {\n if (this._progressChecker != null) {\n window.clearInterval(this._progressChecker);\n this._progressChecker = null;\n }\n this._msectl.seek(seconds);\n this._transmuxer.seek(Math.floor(seconds * 1000)); // in milliseconds\n // no need to set mediaElement.currentTime if non-accurateSeek,\n // just wait for the recommend_seekpoint callback\n if (this._config.accurateSeek) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = seconds;\n }\n }\n }\n\n _checkAndApplyUnbufferedSeekpoint() {\n if (this._seekpointRecord) {\n if (this._seekpointRecord.recordTime <= this._now() - 100) {\n let target = this._mediaElement.currentTime;\n this._seekpointRecord = null;\n if (!this._isTimepointBuffered(target)) {\n if (this._progressChecker != null) {\n window.clearTimeout(this._progressChecker);\n this._progressChecker = null;\n }\n // .currentTime is consists with .buffered timestamp\n // Chrome/Edge use DTS, while FireFox/Safari use PTS\n this._msectl.seek(target);\n this._transmuxer.seek(Math.floor(target * 1000));\n // set currentTime if accurateSeek, or wait for recommend_seekpoint callback\n if (this._config.accurateSeek) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = target;\n }\n }\n } else {\n window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this), 50);\n }\n }\n }\n\n _checkAndResumeStuckPlayback(stalled) {\n let media = this._mediaElement;\n if (stalled || !this._receivedCanPlay || media.readyState < 2) { // HAVE_CURRENT_DATA\n let buffered = media.buffered;\n if (buffered.length > 0 && media.currentTime < buffered.start(0)) {\n Log.w(this.TAG, `Playback seems stuck at ${media.currentTime}, seek to ${buffered.start(0)}`);\n this._requestSetTime = true;\n this._mediaElement.currentTime = buffered.start(0);\n this._mediaElement.removeEventListener('progress', this.e.onvProgress);\n }\n } else {\n // Playback didn't stuck, remove progress event listener\n this._mediaElement.removeEventListener('progress', this.e.onvProgress);\n }\n }\n\n _onvLoadedMetadata(e) {\n if (this._pendingSeekTime != null) {\n this._mediaElement.currentTime = this._pendingSeekTime;\n this._pendingSeekTime = null;\n }\n }\n\n _onvSeeking(e) { // handle seeking request from browser's progress bar\n let target = this._mediaElement.currentTime;\n let buffered = this._mediaElement.buffered;\n\n if (this._requestSetTime) {\n this._requestSetTime = false;\n return;\n }\n\n if (target < 1.0 && buffered.length > 0) {\n // seek to video begin, set currentTime directly if beginPTS buffered\n let videoBeginTime = buffered.start(0);\n if ((videoBeginTime < 1.0 && target < videoBeginTime) || Browser.safari) {\n this._requestSetTime = true;\n // also workaround for Safari: Seek to 0 may cause video stuck, use 0.1 to avoid\n this._mediaElement.currentTime = Browser.safari ? 0.1 : videoBeginTime;\n return;\n }\n }\n\n if (this._isTimepointBuffered(target)) {\n if (this._alwaysSeekKeyframe) {\n let idr = this._msectl.getNearestKeyframe(Math.floor(target * 1000));\n if (idr != null) {\n this._requestSetTime = true;\n this._mediaElement.currentTime = idr.dts / 1000;\n }\n }\n if (this._progressChecker != null) {\n this._checkProgressAndResume();\n }\n return;\n }\n\n this._seekpointRecord = {\n seekPoint: target,\n recordTime: this._now()\n };\n window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this), 50);\n }\n\n _onvCanPlay(e) {\n this._receivedCanPlay = true;\n this._mediaElement.removeEventListener('canplay', this.e.onvCanPlay);\n }\n\n _onvStalled(e) {\n this._checkAndResumeStuckPlayback(true);\n }\n\n _onvProgress(e) {\n this._checkAndResumeStuckPlayback();\n }\n\n}\n\nexport default MSEPlayer;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport EventEmitter from 'events';\nimport PlayerEvents from './player-events.js';\nimport {createDefaultConfig} from '../config.js';\nimport {InvalidArgumentException, IllegalStateException} from '../utils/exception.js';\n\n// Player wrapper for browser's native player (HTMLVideoElement) without MediaSource src. \nclass NativePlayer {\n\n constructor(mediaDataSource, config) {\n this.TAG = 'NativePlayer';\n this._type = 'NativePlayer';\n this._emitter = new EventEmitter();\n\n this._config = createDefaultConfig();\n if (typeof config === 'object') {\n Object.assign(this._config, config);\n }\n\n let typeLowerCase = mediaDataSource.type.toLowerCase();\n\n if (typeLowerCase === 'mse'\n || typeLowerCase === 'mpegts'\n || typeLowerCase === 'm2ts'\n || typeLowerCase === 'flv') {\n throw new InvalidArgumentException('NativePlayer does\\'t support mse/mpegts/m2ts/flv MediaDataSource input!');\n }\n if (mediaDataSource.hasOwnProperty('segments')) {\n throw new InvalidArgumentException(`NativePlayer(${mediaDataSource.type}) doesn't support multipart playback!`);\n }\n\n this.e = {\n onvLoadedMetadata: this._onvLoadedMetadata.bind(this)\n };\n\n this._pendingSeekTime = null;\n this._statisticsReporter = null;\n\n this._mediaDataSource = mediaDataSource;\n this._mediaElement = null;\n }\n\n destroy() {\n if (this._mediaElement) {\n this.unload();\n this.detachMediaElement();\n }\n this.e = null;\n this._mediaDataSource = null;\n this._emitter.removeAllListeners();\n this._emitter = null;\n }\n\n on(event, listener) {\n if (event === PlayerEvents.MEDIA_INFO) {\n if (this._mediaElement != null && this._mediaElement.readyState !== 0) { // HAVE_NOTHING\n Promise.resolve().then(() => {\n this._emitter.emit(PlayerEvents.MEDIA_INFO, this.mediaInfo);\n });\n }\n } else if (event === PlayerEvents.STATISTICS_INFO) {\n if (this._mediaElement != null && this._mediaElement.readyState !== 0) {\n Promise.resolve().then(() => {\n this._emitter.emit(PlayerEvents.STATISTICS_INFO, this.statisticsInfo);\n });\n }\n }\n this._emitter.addListener(event, listener);\n }\n\n off(event, listener) {\n this._emitter.removeListener(event, listener);\n }\n\n attachMediaElement(mediaElement) {\n this._mediaElement = mediaElement;\n mediaElement.addEventListener('loadedmetadata', this.e.onvLoadedMetadata);\n\n if (this._pendingSeekTime != null) {\n try {\n mediaElement.currentTime = this._pendingSeekTime;\n this._pendingSeekTime = null;\n } catch (e) {\n // IE11 may throw InvalidStateError if readyState === 0\n // Defer set currentTime operation after loadedmetadata\n }\n }\n }\n\n detachMediaElement() {\n if (this._mediaElement) {\n this._mediaElement.src = '';\n this._mediaElement.removeAttribute('src');\n this._mediaElement.removeEventListener('loadedmetadata', this.e.onvLoadedMetadata);\n this._mediaElement = null;\n }\n if (this._statisticsReporter != null) {\n window.clearInterval(this._statisticsReporter);\n this._statisticsReporter = null;\n }\n }\n\n load() {\n if (!this._mediaElement) {\n throw new IllegalStateException('HTMLMediaElement must be attached before load()!');\n }\n this._mediaElement.src = this._mediaDataSource.url;\n\n if (this._mediaElement.readyState > 0) {\n this._mediaElement.currentTime = 0;\n }\n\n this._mediaElement.preload = 'auto';\n this._mediaElement.load();\n this._statisticsReporter = window.setInterval(\n this._reportStatisticsInfo.bind(this),\n this._config.statisticsInfoReportInterval);\n }\n\n unload() {\n if (this._mediaElement) {\n this._mediaElement.src = '';\n this._mediaElement.removeAttribute('src');\n }\n if (this._statisticsReporter != null) {\n window.clearInterval(this._statisticsReporter);\n this._statisticsReporter = null;\n }\n }\n\n play() {\n return this._mediaElement.play();\n }\n\n pause() {\n this._mediaElement.pause();\n }\n\n get type() {\n return this._type;\n }\n\n get buffered() {\n return this._mediaElement.buffered;\n }\n\n get duration() {\n return this._mediaElement.duration;\n }\n\n get volume() {\n return this._mediaElement.volume;\n }\n\n set volume(value) {\n this._mediaElement.volume = value;\n }\n\n get muted() {\n return this._mediaElement.muted;\n }\n\n set muted(muted) {\n this._mediaElement.muted = muted;\n }\n\n get currentTime() {\n if (this._mediaElement) {\n return this._mediaElement.currentTime;\n }\n return 0;\n }\n\n set currentTime(seconds) {\n if (this._mediaElement) {\n this._mediaElement.currentTime = seconds;\n } else {\n this._pendingSeekTime = seconds;\n }\n }\n\n get mediaInfo() {\n let mediaPrefix = (this._mediaElement instanceof HTMLAudioElement) ? 'audio/' : 'video/';\n let info = {\n mimeType: mediaPrefix + this._mediaDataSource.type\n };\n if (this._mediaElement) {\n info.duration = Math.floor(this._mediaElement.duration * 1000);\n if (this._mediaElement instanceof HTMLVideoElement) {\n info.width = this._mediaElement.videoWidth;\n info.height = this._mediaElement.videoHeight;\n }\n }\n return info;\n }\n\n get statisticsInfo() {\n let info = {\n playerType: this._type,\n url: this._mediaDataSource.url\n };\n\n if (!(this._mediaElement instanceof HTMLVideoElement)) {\n return info;\n }\n\n let hasQualityInfo = true;\n let decoded = 0;\n let dropped = 0;\n\n if (this._mediaElement.getVideoPlaybackQuality) {\n let quality = this._mediaElement.getVideoPlaybackQuality();\n decoded = quality.totalVideoFrames;\n dropped = quality.droppedVideoFrames;\n } else if (this._mediaElement.webkitDecodedFrameCount != undefined) {\n decoded = this._mediaElement.webkitDecodedFrameCount;\n dropped = this._mediaElement.webkitDroppedFrameCount;\n } else {\n hasQualityInfo = false;\n }\n\n if (hasQualityInfo) {\n info.decodedFrames = decoded;\n info.droppedFrames = dropped;\n }\n \n return info;\n }\n\n _onvLoadedMetadata(e) {\n if (this._pendingSeekTime != null) {\n this._mediaElement.currentTime = this._pendingSeekTime;\n this._pendingSeekTime = null;\n }\n this._emitter.emit(PlayerEvents.MEDIA_INFO, this.mediaInfo);\n }\n\n _reportStatisticsInfo() {\n this._emitter.emit(PlayerEvents.STATISTICS_INFO, this.statisticsInfo);\n }\n\n}\n\nexport default NativePlayer;","/*\n * Copyright (C) 2016 Bilibili. All Rights Reserved.\n *\n * @author zheng qian \n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Polyfill from './utils/polyfill.js';\nimport Features from './core/features.js';\nimport {BaseLoader, LoaderStatus, LoaderErrors} from './io/loader.js';\nimport MSEPlayer from './player/mse-player.js';\nimport NativePlayer from './player/native-player.js';\nimport PlayerEvents from './player/player-events.js';\nimport {ErrorTypes, ErrorDetails} from './player/player-errors.js';\nimport LoggingControl from './utils/logging-control.js';\nimport {InvalidArgumentException} from './utils/exception.js';\n\n// here are all the interfaces\n\n// install polyfills\nPolyfill.install();\n\n\n// factory method\nfunction createPlayer(mediaDataSource, optionalConfig) {\n let mds = mediaDataSource;\n if (mds == null || typeof mds !== 'object') {\n throw new InvalidArgumentException('MediaDataSource must be an javascript object!');\n }\n\n if (!mds.hasOwnProperty('type')) {\n throw new InvalidArgumentException('MediaDataSource must has type field to indicate video file type!');\n }\n\n switch (mds.type) {\n case 'mse':\n case 'mpegts':\n case 'm2ts':\n case 'flv':\n return new MSEPlayer(mds, optionalConfig);\n default:\n return new NativePlayer(mds, optionalConfig);\n }\n}\n\n\n// feature detection\nfunction isSupported() {\n return Features.supportMSEH264Playback();\n}\n\nfunction getFeatureList() {\n return Features.getFeatureList();\n}\n\n\n// interfaces\nlet mpegts = {};\n\nmpegts.createPlayer = createPlayer;\nmpegts.isSupported = isSupported;\nmpegts.getFeatureList = getFeatureList;\n\nmpegts.BaseLoader = BaseLoader;\nmpegts.LoaderStatus = LoaderStatus;\nmpegts.LoaderErrors = LoaderErrors;\n\nmpegts.Events = PlayerEvents;\nmpegts.ErrorTypes = ErrorTypes;\nmpegts.ErrorDetails = ErrorDetails;\n\nmpegts.MSEPlayer = MSEPlayer;\nmpegts.NativePlayer = NativePlayer;\nmpegts.LoggingControl = LoggingControl;\n\nObject.defineProperty(mpegts, 'version', {\n enumerable: true,\n get: function () {\n // replaced by webpack.DefinePlugin\n return __VERSION__;\n }\n});\n\nexport default mpegts;\n"],"sourceRoot":""}