@tarojs/components 3.6.5 → 3.7.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{hls-0f2d4d85.js → hls-67cbc62d.js} +10270 -9325
- package/dist/cjs/{index-067a58c1.js → index-f9d21cc5.js} +10 -11
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/taro-ad-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-ad-custom-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-animation-video-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-animation-view-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-ar-camera-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-audio-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-aweme-data-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-block-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-button-core.cjs.entry.js +2 -2
- package/dist/cjs/taro-camera-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-canvas-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-channel-live-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-channel-video-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-checkbox-core_2.cjs.entry.js +1 -1
- package/dist/cjs/taro-comment-detail-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-comment-list-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-components.cjs.js +2 -2
- package/dist/cjs/taro-contact-button-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-cover-image-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-cover-view-core.cjs.entry.js +2 -2
- package/dist/cjs/taro-custom-wrapper-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-editor-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-follow-swan-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-form-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-functional-page-navigator-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-grid-view-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-icon-core.cjs.entry.js +2 -2
- package/dist/cjs/taro-image-core.cjs.entry.js +2 -2
- package/dist/cjs/taro-inline-payment-panel-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-input-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-keyboard-accessory-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-label-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-lifestyle-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-like-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-list-view-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-live-player-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-live-pusher-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-login-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-lottie-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-map-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-match-media-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-movable-area-core_2.cjs.entry.js +1 -1
- package/dist/cjs/taro-native-slot-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-navigation-bar-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-navigator-core.cjs.entry.js +2 -2
- package/dist/cjs/taro-official-account-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-open-data-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-page-container-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-page-meta-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-picker-core_2.cjs.entry.js +2 -2
- package/dist/cjs/taro-picker-view-column-core_2.cjs.entry.js +2 -2
- package/dist/cjs/taro-progress-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-pull-to-refresh.cjs.entry.js +2 -2
- package/dist/cjs/taro-radio-core_2.cjs.entry.js +1 -1
- package/dist/cjs/taro-rich-text-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-root-portal-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-rtc-room-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-rtc-room-item-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-scroll-view-core.cjs.entry.js +2 -2
- package/dist/cjs/taro-share-element-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-slider-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-slot-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-sticky-header-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-sticky-section-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-swiper-core_2.cjs.entry.js +16 -5
- package/dist/cjs/taro-switch-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-tab-item-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-tabbar.cjs.entry.js +2 -2
- package/dist/cjs/taro-tabs-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-text-core.cjs.entry.js +2 -2
- package/dist/cjs/taro-textarea-core.cjs.entry.js +15 -2
- package/dist/cjs/taro-video-control_3.cjs.entry.js +3 -3
- package/dist/cjs/taro-view-core.cjs.entry.js +2 -2
- package/dist/cjs/taro-voip-room-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-web-view-core.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/swiper/swiper.js +14 -3
- package/dist/collection/components/textarea/textarea.js +42 -1
- package/dist/components/hls.js +10269 -9324
- package/dist/components/index2.js +10 -11
- package/dist/components/taro-swiper-core.js +14 -3
- package/dist/components/taro-textarea-core.js +14 -1
- package/dist/esm/{hls-0e83e558.js → hls-221423a1.js} +10270 -9325
- package/dist/esm/{index-394db4c1.js → index-1d8e8acd.js} +10 -11
- package/dist/esm/loader.js +3 -3
- package/dist/esm/taro-ad-core.entry.js +1 -1
- package/dist/esm/taro-ad-custom-core.entry.js +1 -1
- package/dist/esm/taro-animation-video-core.entry.js +1 -1
- package/dist/esm/taro-animation-view-core.entry.js +1 -1
- package/dist/esm/taro-ar-camera-core.entry.js +1 -1
- package/dist/esm/taro-audio-core.entry.js +1 -1
- package/dist/esm/taro-aweme-data-core.entry.js +1 -1
- package/dist/esm/taro-block-core.entry.js +1 -1
- package/dist/esm/taro-button-core.entry.js +2 -2
- package/dist/esm/taro-camera-core.entry.js +1 -1
- package/dist/esm/taro-canvas-core.entry.js +1 -1
- package/dist/esm/taro-channel-live-core.entry.js +1 -1
- package/dist/esm/taro-channel-video-core.entry.js +1 -1
- package/dist/esm/taro-checkbox-core_2.entry.js +1 -1
- package/dist/esm/taro-comment-detail-core.entry.js +1 -1
- package/dist/esm/taro-comment-list-core.entry.js +1 -1
- package/dist/esm/taro-components.js +3 -3
- package/dist/esm/taro-contact-button-core.entry.js +1 -1
- package/dist/esm/taro-cover-image-core.entry.js +1 -1
- package/dist/esm/taro-cover-view-core.entry.js +2 -2
- package/dist/esm/taro-custom-wrapper-core.entry.js +1 -1
- package/dist/esm/taro-editor-core.entry.js +1 -1
- package/dist/esm/taro-follow-swan-core.entry.js +1 -1
- package/dist/esm/taro-form-core.entry.js +1 -1
- package/dist/esm/taro-functional-page-navigator-core.entry.js +1 -1
- package/dist/esm/taro-grid-view-core.entry.js +1 -1
- package/dist/esm/taro-icon-core.entry.js +2 -2
- package/dist/esm/taro-image-core.entry.js +2 -2
- package/dist/esm/taro-inline-payment-panel-core.entry.js +1 -1
- package/dist/esm/taro-input-core.entry.js +1 -1
- package/dist/esm/taro-keyboard-accessory-core.entry.js +1 -1
- package/dist/esm/taro-label-core.entry.js +1 -1
- package/dist/esm/taro-lifestyle-core.entry.js +1 -1
- package/dist/esm/taro-like-core.entry.js +1 -1
- package/dist/esm/taro-list-view-core.entry.js +1 -1
- package/dist/esm/taro-live-player-core.entry.js +1 -1
- package/dist/esm/taro-live-pusher-core.entry.js +1 -1
- package/dist/esm/taro-login-core.entry.js +1 -1
- package/dist/esm/taro-lottie-core.entry.js +1 -1
- package/dist/esm/taro-map-core.entry.js +1 -1
- package/dist/esm/taro-match-media-core.entry.js +1 -1
- package/dist/esm/taro-movable-area-core_2.entry.js +1 -1
- package/dist/esm/taro-native-slot-core.entry.js +1 -1
- package/dist/esm/taro-navigation-bar-core.entry.js +1 -1
- package/dist/esm/taro-navigator-core.entry.js +2 -2
- package/dist/esm/taro-official-account-core.entry.js +1 -1
- package/dist/esm/taro-open-data-core.entry.js +1 -1
- package/dist/esm/taro-page-container-core.entry.js +1 -1
- package/dist/esm/taro-page-meta-core.entry.js +1 -1
- package/dist/esm/taro-picker-core_2.entry.js +2 -2
- package/dist/esm/taro-picker-view-column-core_2.entry.js +2 -2
- package/dist/esm/taro-progress-core.entry.js +1 -1
- package/dist/esm/taro-pull-to-refresh.entry.js +2 -2
- package/dist/esm/taro-radio-core_2.entry.js +1 -1
- package/dist/esm/taro-rich-text-core.entry.js +1 -1
- package/dist/esm/taro-root-portal-core.entry.js +1 -1
- package/dist/esm/taro-rtc-room-core.entry.js +1 -1
- package/dist/esm/taro-rtc-room-item-core.entry.js +1 -1
- package/dist/esm/taro-scroll-view-core.entry.js +2 -2
- package/dist/esm/taro-share-element-core.entry.js +1 -1
- package/dist/esm/taro-slider-core.entry.js +1 -1
- package/dist/esm/taro-slot-core.entry.js +1 -1
- package/dist/esm/taro-sticky-header-core.entry.js +1 -1
- package/dist/esm/taro-sticky-section-core.entry.js +1 -1
- package/dist/esm/taro-swiper-core_2.entry.js +16 -5
- package/dist/esm/taro-switch-core.entry.js +1 -1
- package/dist/esm/taro-tab-item-core.entry.js +1 -1
- package/dist/esm/taro-tabbar.entry.js +2 -2
- package/dist/esm/taro-tabs-core.entry.js +1 -1
- package/dist/esm/taro-text-core.entry.js +2 -2
- package/dist/esm/taro-textarea-core.entry.js +15 -2
- package/dist/esm/taro-video-control_3.entry.js +3 -3
- package/dist/esm/taro-view-core.entry.js +2 -2
- package/dist/esm/taro-voip-room-core.entry.js +1 -1
- package/dist/esm/taro-web-view-core.entry.js +1 -1
- package/dist/esm-es5/hls-221423a1.js +365 -0
- package/dist/esm-es5/index-1d8e8acd.js +7 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/taro-ad-core.entry.js +1 -1
- package/dist/esm-es5/taro-ad-custom-core.entry.js +1 -1
- package/dist/esm-es5/taro-animation-video-core.entry.js +1 -1
- package/dist/esm-es5/taro-animation-view-core.entry.js +1 -1
- package/dist/esm-es5/taro-ar-camera-core.entry.js +1 -1
- package/dist/esm-es5/taro-audio-core.entry.js +1 -1
- package/dist/esm-es5/taro-aweme-data-core.entry.js +1 -1
- package/dist/esm-es5/taro-block-core.entry.js +1 -1
- package/dist/esm-es5/taro-button-core.entry.js +1 -1
- package/dist/esm-es5/taro-camera-core.entry.js +1 -1
- package/dist/esm-es5/taro-canvas-core.entry.js +1 -1
- package/dist/esm-es5/taro-channel-live-core.entry.js +1 -1
- package/dist/esm-es5/taro-channel-video-core.entry.js +1 -1
- package/dist/esm-es5/taro-checkbox-core_2.entry.js +1 -1
- package/dist/esm-es5/taro-comment-detail-core.entry.js +1 -1
- package/dist/esm-es5/taro-comment-list-core.entry.js +1 -1
- package/dist/esm-es5/taro-components.js +1 -1
- package/dist/esm-es5/taro-contact-button-core.entry.js +1 -1
- package/dist/esm-es5/taro-cover-image-core.entry.js +1 -1
- package/dist/esm-es5/taro-cover-view-core.entry.js +1 -1
- package/dist/esm-es5/taro-custom-wrapper-core.entry.js +1 -1
- package/dist/esm-es5/taro-editor-core.entry.js +1 -1
- package/dist/esm-es5/taro-follow-swan-core.entry.js +1 -1
- package/dist/esm-es5/taro-form-core.entry.js +1 -1
- package/dist/esm-es5/taro-functional-page-navigator-core.entry.js +1 -1
- package/dist/esm-es5/taro-grid-view-core.entry.js +1 -1
- package/dist/esm-es5/taro-icon-core.entry.js +1 -1
- package/dist/esm-es5/taro-image-core.entry.js +1 -1
- package/dist/esm-es5/taro-inline-payment-panel-core.entry.js +1 -1
- package/dist/esm-es5/taro-input-core.entry.js +1 -1
- package/dist/esm-es5/taro-keyboard-accessory-core.entry.js +1 -1
- package/dist/esm-es5/taro-label-core.entry.js +1 -1
- package/dist/esm-es5/taro-lifestyle-core.entry.js +1 -1
- package/dist/esm-es5/taro-like-core.entry.js +1 -1
- package/dist/esm-es5/taro-list-view-core.entry.js +1 -1
- package/dist/esm-es5/taro-live-player-core.entry.js +1 -1
- package/dist/esm-es5/taro-live-pusher-core.entry.js +1 -1
- package/dist/esm-es5/taro-login-core.entry.js +1 -1
- package/dist/esm-es5/taro-lottie-core.entry.js +1 -1
- package/dist/esm-es5/taro-map-core.entry.js +1 -1
- package/dist/esm-es5/taro-match-media-core.entry.js +1 -1
- package/dist/esm-es5/taro-movable-area-core_2.entry.js +1 -1
- package/dist/esm-es5/taro-native-slot-core.entry.js +1 -1
- package/dist/esm-es5/taro-navigation-bar-core.entry.js +1 -1
- package/dist/esm-es5/taro-navigator-core.entry.js +1 -1
- package/dist/esm-es5/taro-official-account-core.entry.js +1 -1
- package/dist/esm-es5/taro-open-data-core.entry.js +1 -1
- package/dist/esm-es5/taro-page-container-core.entry.js +1 -1
- package/dist/esm-es5/taro-page-meta-core.entry.js +1 -1
- package/dist/esm-es5/taro-picker-core_2.entry.js +1 -1
- package/dist/esm-es5/taro-picker-view-column-core_2.entry.js +1 -1
- package/dist/esm-es5/taro-progress-core.entry.js +1 -1
- package/dist/esm-es5/taro-pull-to-refresh.entry.js +1 -1
- package/dist/esm-es5/taro-radio-core_2.entry.js +1 -1
- package/dist/esm-es5/taro-rich-text-core.entry.js +1 -1
- package/dist/esm-es5/taro-root-portal-core.entry.js +1 -1
- package/dist/esm-es5/taro-rtc-room-core.entry.js +1 -1
- package/dist/esm-es5/taro-rtc-room-item-core.entry.js +1 -1
- package/dist/esm-es5/taro-scroll-view-core.entry.js +1 -1
- package/dist/esm-es5/taro-share-element-core.entry.js +1 -1
- package/dist/esm-es5/taro-slider-core.entry.js +1 -1
- package/dist/esm-es5/taro-slot-core.entry.js +1 -1
- package/dist/esm-es5/taro-sticky-header-core.entry.js +1 -1
- package/dist/esm-es5/taro-sticky-section-core.entry.js +1 -1
- package/dist/esm-es5/taro-swiper-core_2.entry.js +1 -1
- package/dist/esm-es5/taro-switch-core.entry.js +1 -1
- package/dist/esm-es5/taro-tab-item-core.entry.js +1 -1
- package/dist/esm-es5/taro-tabbar.entry.js +1 -1
- package/dist/esm-es5/taro-tabs-core.entry.js +1 -1
- package/dist/esm-es5/taro-text-core.entry.js +1 -1
- package/dist/esm-es5/taro-textarea-core.entry.js +1 -1
- package/dist/esm-es5/taro-video-control_3.entry.js +1 -1
- package/dist/esm-es5/taro-view-core.entry.js +1 -1
- package/dist/esm-es5/taro-voip-room-core.entry.js +1 -1
- package/dist/esm-es5/taro-web-view-core.entry.js +1 -1
- package/dist/taro-components/{p-ebdd350f.system.entry.js → p-02aa7366.system.entry.js} +1 -1
- package/dist/taro-components/p-0393ed55.entry.js +1 -0
- package/dist/taro-components/{p-9b6550fc.entry.js → p-05bc0fce.entry.js} +1 -1
- package/dist/taro-components/{p-8c0b740e.entry.js → p-05c757b7.entry.js} +1 -1
- package/dist/taro-components/p-07293238.entry.js +1 -0
- package/dist/taro-components/{p-e53508c1.system.entry.js → p-087bf23a.system.entry.js} +1 -1
- package/dist/taro-components/{p-052da7f0.system.entry.js → p-08bb8dfc.system.entry.js} +1 -1
- package/dist/taro-components/{p-fd7ff0f3.system.entry.js → p-0939fd26.system.entry.js} +1 -1
- package/dist/taro-components/{p-898db637.system.entry.js → p-0a165ad3.system.entry.js} +1 -1
- package/dist/taro-components/{p-9d9ede17.system.entry.js → p-0a9b984e.system.entry.js} +1 -1
- package/dist/taro-components/{p-a132ebb9.entry.js → p-0b8b3af5.entry.js} +1 -1
- package/dist/taro-components/{p-e6481671.system.entry.js → p-10be7fb5.system.entry.js} +1 -1
- package/dist/taro-components/{p-6db97374.entry.js → p-11936d9a.entry.js} +1 -1
- package/dist/taro-components/p-1249cb09.entry.js +1 -0
- package/dist/taro-components/{p-ed011ff9.entry.js → p-1385d50f.entry.js} +1 -1
- package/dist/taro-components/{p-ca3a269f.entry.js → p-1493866a.entry.js} +1 -1
- package/dist/taro-components/p-16e03200.entry.js +1 -0
- package/dist/taro-components/{p-f7927285.system.entry.js → p-17302fe9.system.entry.js} +1 -1
- package/dist/taro-components/p-1743a04b.system.js +365 -0
- package/dist/taro-components/{p-f420680c.system.entry.js → p-1941d333.system.entry.js} +1 -1
- package/dist/taro-components/{p-2a071adf.system.entry.js → p-1b501f32.system.entry.js} +1 -1
- package/dist/taro-components/{p-46b8f89b.entry.js → p-1be83ed3.entry.js} +1 -1
- package/dist/taro-components/{p-fa6c022a.system.entry.js → p-1c320250.system.entry.js} +1 -1
- package/dist/taro-components/{p-ed331c06.system.js → p-1c446c65.system.js} +1 -1
- package/dist/taro-components/{p-1404c119.entry.js → p-1e8c8ae1.entry.js} +1 -1
- package/dist/taro-components/{p-c2322741.system.entry.js → p-2024e133.system.entry.js} +1 -1
- package/dist/taro-components/p-22dc57d4.entry.js +1 -0
- package/dist/taro-components/{p-968b7c1d.entry.js → p-23cb8a7f.entry.js} +1 -1
- package/dist/taro-components/{p-81f2ad70.system.entry.js → p-26889f3c.system.entry.js} +1 -1
- package/dist/taro-components/{p-469ee343.entry.js → p-27c4878c.entry.js} +1 -1
- package/dist/taro-components/{p-ba7cb688.entry.js → p-2bac359b.entry.js} +1 -1
- package/dist/taro-components/p-2e28cb1c.entry.js +1 -0
- package/dist/taro-components/p-2f7dba29.entry.js +1 -0
- package/dist/taro-components/p-30f32fa2.system.entry.js +1 -0
- package/dist/taro-components/{p-f534057e.system.entry.js → p-30fe0e81.system.entry.js} +1 -1
- package/dist/taro-components/{p-fa0f6dab.system.entry.js → p-33223303.system.entry.js} +1 -1
- package/dist/taro-components/{p-9aeb7995.entry.js → p-369fb262.entry.js} +1 -1
- package/dist/taro-components/{p-407ca16e.entry.js → p-38a51bd2.entry.js} +1 -1
- package/dist/taro-components/{p-2af69b72.entry.js → p-38de410e.entry.js} +1 -1
- package/dist/taro-components/{p-735c2a72.system.entry.js → p-39685396.system.entry.js} +1 -1
- package/dist/taro-components/{p-c490cd45.entry.js → p-3c5ac930.entry.js} +1 -1
- package/dist/taro-components/p-3c91f59b.entry.js +1 -0
- package/dist/taro-components/p-3d60bd58.entry.js +1 -0
- package/dist/taro-components/{p-3094bda6.system.entry.js → p-4190e20b.system.entry.js} +1 -1
- package/dist/taro-components/p-429a0f99.entry.js +1 -0
- package/dist/taro-components/p-42bcb98a.entry.js +1 -0
- package/dist/taro-components/{p-0517f107.system.entry.js → p-4402972b.system.entry.js} +1 -1
- package/dist/taro-components/{p-8201ee31.system.entry.js → p-4514dc53.system.entry.js} +1 -1
- package/dist/taro-components/{p-30805bdf.entry.js → p-4542b767.entry.js} +1 -1
- package/dist/taro-components/{p-69cd1f2a.system.entry.js → p-46244579.system.entry.js} +1 -1
- package/dist/taro-components/{p-6800ccdc.system.entry.js → p-4915fdc1.system.entry.js} +1 -1
- package/dist/taro-components/{p-97f0ad72.system.entry.js → p-491c6272.system.entry.js} +1 -1
- package/dist/taro-components/{p-7e8e355b.system.entry.js → p-4d0da795.system.entry.js} +1 -1
- package/dist/taro-components/{p-88d2b41b.system.entry.js → p-4d7182f4.system.entry.js} +1 -1
- package/dist/taro-components/{p-ab2d4f12.entry.js → p-4e77bdea.entry.js} +1 -1
- package/dist/taro-components/{p-eaa370a9.system.entry.js → p-518146fd.system.entry.js} +1 -1
- package/dist/taro-components/{p-9ac947ac.system.entry.js → p-51b6fc09.system.entry.js} +1 -1
- package/dist/taro-components/{p-43720011.entry.js → p-58690684.entry.js} +1 -1
- package/dist/taro-components/{p-16336cc6.system.entry.js → p-58877ef2.system.entry.js} +1 -1
- package/dist/taro-components/{p-b027181b.entry.js → p-58b7e960.entry.js} +1 -1
- package/dist/taro-components/p-5931c82e.entry.js +1 -0
- package/dist/taro-components/{p-117633e9.system.entry.js → p-59590806.system.entry.js} +1 -1
- package/dist/taro-components/p-61f225ef.system.js +7 -0
- package/dist/taro-components/{p-cd90bead.system.entry.js → p-623b3eb6.system.entry.js} +1 -1
- package/dist/taro-components/{p-fa43177b.system.entry.js → p-651586f8.system.entry.js} +1 -1
- package/dist/taro-components/{p-18703731.system.entry.js → p-69f6784d.system.entry.js} +1 -1
- package/dist/taro-components/{p-473afc8e.system.entry.js → p-69fa7272.system.entry.js} +1 -1
- package/dist/taro-components/{p-edbb1a17.system.entry.js → p-6dae898a.system.entry.js} +1 -1
- package/dist/taro-components/p-6de6eb4e.entry.js +1 -0
- package/dist/taro-components/{p-afb3895c.system.entry.js → p-6f048097.system.entry.js} +1 -1
- package/dist/taro-components/{p-208e438c.system.entry.js → p-6f214fc3.system.entry.js} +1 -1
- package/dist/taro-components/{p-0d7a705b.system.entry.js → p-70b5e81e.system.entry.js} +1 -1
- package/dist/taro-components/{p-cc70bb7a.system.entry.js → p-736053bb.system.entry.js} +1 -1
- package/dist/taro-components/p-7377a117.entry.js +1 -0
- package/dist/taro-components/p-744a6b99.entry.js +1 -0
- package/dist/taro-components/{p-53ef8a6c.system.entry.js → p-74bf8246.system.entry.js} +1 -1
- package/dist/taro-components/p-76724e58.js +7 -0
- package/dist/taro-components/{p-3f9f3448.entry.js → p-7722f33f.entry.js} +1 -1
- package/dist/taro-components/{p-b6d4634f.system.entry.js → p-78c30850.system.entry.js} +1 -1
- package/dist/taro-components/{p-df4c2f21.entry.js → p-79c41bc2.entry.js} +1 -1
- package/dist/taro-components/{p-5c1e6b1c.system.entry.js → p-7c1fc8f5.system.entry.js} +1 -1
- package/dist/taro-components/{p-357ba712.system.entry.js → p-7dd9c8da.system.entry.js} +1 -1
- package/dist/taro-components/{p-da239b8b.system.entry.js → p-7df9de66.system.entry.js} +1 -1
- package/dist/taro-components/{p-07302165.system.entry.js → p-8027e1c6.system.entry.js} +1 -1
- package/dist/taro-components/p-80970d8f.entry.js +1 -0
- package/dist/taro-components/{p-0fe855c6.entry.js → p-80f3d88d.entry.js} +1 -1
- package/dist/taro-components/{p-1e739fcb.system.entry.js → p-88d64daa.system.entry.js} +1 -1
- package/dist/taro-components/{p-af3fa859.system.entry.js → p-895cd7c9.system.entry.js} +1 -1
- package/dist/taro-components/{p-139e6251.entry.js → p-8b8a8e39.entry.js} +1 -1
- package/dist/taro-components/{p-af8e521a.entry.js → p-8d037fc0.entry.js} +1 -1
- package/dist/taro-components/{p-e5f78321.system.entry.js → p-8d2101be.system.entry.js} +1 -1
- package/dist/taro-components/{p-79c3fde3.system.entry.js → p-8e5cc8fe.system.entry.js} +1 -1
- package/dist/taro-components/{p-dcbb7b2d.entry.js → p-8feeb7ce.entry.js} +1 -1
- package/dist/taro-components/{p-25adb80c.entry.js → p-90e4274e.entry.js} +1 -1
- package/dist/taro-components/{p-cc164fa3.entry.js → p-9318da32.entry.js} +1 -1
- package/dist/taro-components/{p-90333d0a.system.entry.js → p-95f70aea.system.entry.js} +1 -1
- package/dist/taro-components/{p-5dab46cd.system.entry.js → p-97782cdd.system.entry.js} +1 -1
- package/dist/taro-components/{p-5640e9f4.system.entry.js → p-9d4fa0d3.system.entry.js} +1 -1
- package/dist/taro-components/{p-f0340edf.entry.js → p-9df17ea6.entry.js} +1 -1
- package/dist/taro-components/{p-7c2454dd.system.entry.js → p-9e8619a6.system.entry.js} +1 -1
- package/dist/taro-components/p-a294e169.entry.js +1 -0
- package/dist/taro-components/{p-cc7b95fd.system.entry.js → p-a5afdc47.system.entry.js} +1 -1
- package/dist/taro-components/p-a6d2e81b.entry.js +1 -0
- package/dist/taro-components/p-a9b51167.entry.js +1 -0
- package/dist/taro-components/{p-a1763153.entry.js → p-acd9a9da.entry.js} +1 -1
- package/dist/taro-components/{p-b5b30493.system.entry.js → p-ae3f1ed4.system.entry.js} +1 -1
- package/dist/taro-components/p-ae8fd8c8.entry.js +1 -0
- package/dist/taro-components/{p-589293fd.entry.js → p-affb28de.entry.js} +1 -1
- package/dist/taro-components/{p-907d9d01.system.entry.js → p-b1249ebb.system.entry.js} +1 -1
- package/dist/taro-components/p-b16eddaa.entry.js +1 -0
- package/dist/taro-components/{p-6127b1b6.system.entry.js → p-b1c972e2.system.entry.js} +1 -1
- package/dist/taro-components/{p-2d1b4dcc.system.entry.js → p-b2bb02d7.system.entry.js} +1 -1
- package/dist/taro-components/{p-962f28cb.entry.js → p-b5ad2aec.entry.js} +1 -1
- package/dist/taro-components/p-b708e9fe.entry.js +1 -0
- package/dist/taro-components/{p-227e33fc.system.entry.js → p-bac3deb0.system.entry.js} +1 -1
- package/dist/taro-components/{p-6f84e936.entry.js → p-badfb3be.entry.js} +1 -1
- package/dist/taro-components/{p-6d4b7e5c.system.entry.js → p-bba8c3a7.system.entry.js} +1 -1
- package/dist/taro-components/{p-f7baa03f.system.entry.js → p-be6050fd.system.entry.js} +1 -1
- package/dist/taro-components/p-beba1657.entry.js +1 -0
- package/dist/taro-components/{p-385d8aed.entry.js → p-c2391de5.entry.js} +1 -1
- package/dist/taro-components/{p-bf0e0394.entry.js → p-c2c498d9.entry.js} +1 -1
- package/dist/taro-components/{p-e67755f0.system.entry.js → p-c33733b3.system.entry.js} +1 -1
- package/dist/taro-components/{p-5613907c.entry.js → p-c3d35ae5.entry.js} +1 -1
- package/dist/taro-components/{p-38ee526a.entry.js → p-c3d3eca2.entry.js} +1 -1
- package/dist/taro-components/{p-50902cd0.entry.js → p-c4dd85b6.entry.js} +1 -1
- package/dist/taro-components/{p-1f39576a.system.entry.js → p-c4fdb669.system.entry.js} +1 -1
- package/dist/taro-components/{p-f11c9c37.system.entry.js → p-c586a796.system.entry.js} +1 -1
- package/dist/taro-components/{p-c0ec2f41.system.entry.js → p-c6385fc2.system.entry.js} +1 -1
- package/dist/taro-components/{p-1974e52e.system.entry.js → p-c6e6dab1.system.entry.js} +1 -1
- package/dist/taro-components/{p-bcf80126.system.entry.js → p-c70dd956.system.entry.js} +1 -1
- package/dist/taro-components/{p-137531b6.entry.js → p-d42e41ff.entry.js} +1 -1
- package/dist/taro-components/p-d5234e7e.js +365 -0
- package/dist/taro-components/{p-904df510.entry.js → p-d797cdc4.entry.js} +1 -1
- package/dist/taro-components/{p-ab726c20.system.entry.js → p-da5cdbf5.system.entry.js} +1 -1
- package/dist/taro-components/p-dcb5b505.system.entry.js +1 -0
- package/dist/taro-components/{p-b235e43c.entry.js → p-dccf1ae9.entry.js} +1 -1
- package/dist/taro-components/{p-3d8c9dfb.entry.js → p-dfc405a5.entry.js} +1 -1
- package/dist/taro-components/p-e2f2fbe5.entry.js +1 -0
- package/dist/taro-components/{p-c1073ed6.system.entry.js → p-e3f8265d.system.entry.js} +1 -1
- package/dist/taro-components/{p-355e4dbc.entry.js → p-e753b776.entry.js} +1 -1
- package/dist/taro-components/p-e8b1ea64.entry.js +1 -0
- package/dist/taro-components/p-e9eeb060.entry.js +1 -0
- package/dist/taro-components/{p-85a7daeb.system.entry.js → p-ef7e7d73.system.entry.js} +1 -1
- package/dist/taro-components/p-efcfdb97.entry.js +1 -0
- package/dist/taro-components/{p-31bba7c3.entry.js → p-f44e975b.entry.js} +1 -1
- package/dist/taro-components/{p-66b0b419.system.entry.js → p-f499c0a0.system.entry.js} +1 -1
- package/dist/taro-components/{p-a8565231.entry.js → p-f671ed7d.entry.js} +1 -1
- package/dist/taro-components/{p-57b9943c.system.entry.js → p-f9ac515e.system.entry.js} +1 -1
- package/dist/taro-components/{p-b641e598.entry.js → p-f9c26678.entry.js} +1 -1
- package/dist/taro-components/{p-1b3d41d3.system.entry.js → p-fa36fe8e.system.entry.js} +1 -1
- package/dist/taro-components/p-fb585037.entry.js +1 -0
- package/dist/taro-components/{p-c43c5e89.system.entry.js → p-fcdac6ec.system.entry.js} +1 -1
- package/dist/taro-components/p-fdecdc25.entry.js +1 -0
- package/dist/taro-components/taro-components.esm.js +1 -1
- package/dist/taro-components/taro-components.js +1 -1
- package/dist/types/components/textarea/textarea.d.ts +3 -0
- package/dist/types/components.d.ts +2 -0
- package/lib/react/component-lib/index.d.ts +1 -1
- package/lib/react/components.d.ts +80 -80
- package/lib/react/index.d.ts +1 -1
- package/lib/react/react-component-lib/createComponent.d.ts +1 -1
- package/lib/react/react-component-lib/createOverlayComponent.d.ts +2 -2
- package/lib/react/react-component-lib/index.d.ts +2 -2
- package/lib/react/react-component-lib/utils/index.d.ts +3 -3
- package/lib/vue2/components.js +1 -1
- package/lib/vue2/components.js.map +1 -1
- package/lib/vue2/index.d.ts +1 -1
- package/lib/vue3/component-lib/index.d.ts +4 -4
- package/lib/vue3/components.d.ts +80 -80
- package/lib/vue3/components.js +3 -1
- package/lib/vue3/components.js.map +1 -1
- package/lib/vue3/index.d.ts +1 -1
- package/package.json +4 -4
- package/types/Input.d.ts +0 -1
- package/types/Map.d.ts +1 -0
- package/types/Picker.d.ts +4 -4
- package/types/Textarea.d.ts +1 -1
- package/dist/esm-es5/hls-0e83e558.js +0 -289
- package/dist/esm-es5/index-394db4c1.js +0 -7
- package/dist/taro-components/p-198000d8.system.js +0 -289
- package/dist/taro-components/p-1c4e3899.entry.js +0 -1
- package/dist/taro-components/p-204bd245.entry.js +0 -1
- package/dist/taro-components/p-2fad2a65.js +0 -7
- package/dist/taro-components/p-387314fa.system.js +0 -7
- package/dist/taro-components/p-3e701660.js +0 -289
- package/dist/taro-components/p-486d0ec7.entry.js +0 -1
- package/dist/taro-components/p-4e9bd4f6.entry.js +0 -1
- package/dist/taro-components/p-58b19305.system.entry.js +0 -1
- package/dist/taro-components/p-5b67a98e.entry.js +0 -1
- package/dist/taro-components/p-66f7eea6.entry.js +0 -1
- package/dist/taro-components/p-6e115968.entry.js +0 -1
- package/dist/taro-components/p-71b54f06.entry.js +0 -1
- package/dist/taro-components/p-72b118b0.entry.js +0 -1
- package/dist/taro-components/p-7b3b8057.entry.js +0 -1
- package/dist/taro-components/p-7d635413.entry.js +0 -1
- package/dist/taro-components/p-801f09b8.entry.js +0 -1
- package/dist/taro-components/p-86280254.entry.js +0 -1
- package/dist/taro-components/p-9046110a.entry.js +0 -1
- package/dist/taro-components/p-9a5fbb2e.entry.js +0 -1
- package/dist/taro-components/p-a3a1a779.entry.js +0 -1
- package/dist/taro-components/p-a940a65b.entry.js +0 -1
- package/dist/taro-components/p-af9ef8b4.entry.js +0 -1
- package/dist/taro-components/p-b4ea72ea.entry.js +0 -1
- package/dist/taro-components/p-b4f3d0ab.entry.js +0 -1
- package/dist/taro-components/p-b898d734.entry.js +0 -1
- package/dist/taro-components/p-bdc30301.entry.js +0 -1
- package/dist/taro-components/p-c11a42e0.entry.js +0 -1
- package/dist/taro-components/p-cfb01848.system.entry.js +0 -1
- package/dist/taro-components/p-d34a6c04.entry.js +0 -1
- package/dist/taro-components/p-d8831b3c.entry.js +0 -1
- package/dist/taro-components/p-e3480c4c.entry.js +0 -1
- package/dist/taro-components/p-f533bc2f.entry.js +0 -1
- package/dist/taro-components/p-f7b32c6b.entry.js +0 -1
- package/dist/taro-components/p-fb983850.entry.js +0 -1
- /package/dist/cjs/{index-e751dfe3.js → index-e1b469cd.js} +0 -0
- /package/dist/esm/{index-980f930f.js → index-c948674f.js} +0 -0
- /package/dist/esm-es5/{index-980f930f.js → index-c948674f.js} +0 -0
- /package/dist/taro-components/{p-7e6b54cb.system.js → p-1a0e1932.system.js} +0 -0
- /package/dist/taro-components/{p-9137dcab.js → p-78e3ebb9.js} +0 -0
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import{g as t,a as i,b as r}from"./p-2fad2a65.js";var n=i((function(t){var i;"undefined"!=typeof window&&(i=()=>(()=>{var t={"./src/config.ts":
|
|
2
|
-
/*!***********************!*\
|
|
3
|
-
!*** ./src/config.ts ***!
|
|
4
|
-
\***********************/(t,i,r)=>{r.r(i),r.d(i,{enableStreamingMode:()=>A,hlsDefaultConfig:()=>T,mergeConfig:()=>E});var n=r(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts"),e=r(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts"),s=r(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts"),a=r(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts"),o=r(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts"),h=r(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts"),u=r(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts"),f=r(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts"),c=r(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts"),l=r(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts"),v=r(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts"),d=r(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),m=r(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),p=r(/*! ./utils/cues */"./src/utils/cues.ts"),y=r(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),g=r(/*! ./utils/logger */"./src/utils/logger.ts");function b(){return b=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},b.apply(this,arguments)}function w(t,i){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);i&&(n=n.filter((function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable}))),r.push.apply(r,n)}return r}function k(t){for(var i=1;i<arguments.length;i++){var r=null!=arguments[i]?arguments[i]:{};i%2?w(Object(r),!0).forEach((function(i){S(t,i,r[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach((function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(r,i))}))}return t}function S(t,i,r){return(i=function(t){var i=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof i?i:String(i)}(i))in t?Object.defineProperty(t,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[i]=r,t}var T=k(k({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:d.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:n.default,bufferController:h.default,capLevelController:f.default,fpsController:c.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:y.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},{cueHandler:p.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:a.SubtitleStreamController,subtitleTrackController:o.default,timelineController:u.TimelineController,audioStreamController:e.default,audioTrackController:s.default,emeController:l.default,cmcdController:v.default});function E(t,i){if((i.liveSyncDurationCount||i.liveMaxLatencyDurationCount)&&(i.liveSyncDuration||i.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==i.liveMaxLatencyDurationCount&&(void 0===i.liveSyncDurationCount||i.liveMaxLatencyDurationCount<=i.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==i.liveMaxLatencyDuration&&(void 0===i.liveSyncDuration||i.liveMaxLatencyDuration<=i.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return b({},t,i)}function A(t){var i=t.loader;i!==m.default&&i!==d.default?(g.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):(0,m.fetchSupported)()&&(t.loader=m.default,t.progressive=!0,t.enableSoftwareAES=!0,g.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":
|
|
5
|
-
/*!******************************************!*\
|
|
6
|
-
!*** ./src/controller/abr-controller.ts ***!
|
|
7
|
-
\******************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>c});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts"),s=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../types/loader */"./src/types/loader.ts"),h=r(/*! ../utils/logger */"./src/utils/logger.ts");function u(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}var f=function(){function t(t){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;var i=t.config;this.bwEstimator=new e.default(i.abrEwmaSlowVoD,i.abrEwmaFastVoD,i.abrEwmaDefaultEstimate),this.registerListeners()}var i,r,f=t.prototype;return f.registerListeners=function(){var t=this.hls;t.on(s.Events.FRAG_LOADING,this.onFragLoading,this),t.on(s.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(s.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var t=this.hls;t.off(s.Events.FRAG_LOADING,this.onFragLoading,this),t.off(s.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(s.Events.ERROR,this.onError,this)},f.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},f.onFragLoading=function(t,i){var r,n=i.frag;n.type===o.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=n,this.partCurrent=null!=(r=i.part)?r:null,this.timer=self.setInterval(this.onCheck,100)))},f.onLevelLoaded=function(t,i){var r=this.hls.config;i.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},f._abandonRulesCheck=function(){var t=this.fragCurrent,i=this.partCurrent,r=this.hls,e=r.autoLevelEnabled,a=r.media;if(t&&a){var o=i?i.stats:t.stats,u=i?i.duration:t.duration;if(o.aborted||o.loaded&&o.loaded===o.total||0===t.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(e&&!a.paused&&a.playbackRate&&a.readyState){var f=r.mainForwardBufferInfo;if(null!==f){var c=performance.now()-o.loading.start,l=Math.abs(a.playbackRate);if(!(c<=500*u/l)){var v=o.loaded&&o.loading.first,d=this.bwEstimator.getEstimate(),m=r.levels,p=r.minAutoLevel,y=o.total||Math.max(o.loaded,Math.round(u*m[t.level].maxBitrate/8)),g=v?1e3*o.loaded/c:0,b=g?(y-o.loaded)/g:8*y/d,w=f.len/l;if(!(b<=w)){var k,S=Number.POSITIVE_INFINITY;for(k=t.level-1;k>p;k--){var T=m[k].maxBitrate;if((S=g?u*T/(6.4*g):u*T/d)<w)break}S>=b||(h.logger.warn("Fragment "+t.sn+(i?" part "+i.index:"")+" of level "+t.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+k+"\n Current BW estimate: "+((0,n.isFiniteNumber)(d)?(d/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+b.toFixed(3)+" s\n Estimated load time for the next fragment: "+S.toFixed(3)+" s\n Time to underbuffer: "+w.toFixed(3)+" s"),r.nextLoadLevel=k,v&&this.bwEstimator.sample(c,o.loaded),this.clearTimer(),(t.loader||t.keyLoader)&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),r.trigger(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:i,stats:o}))}}}}}},f.onFragLoaded=function(t,i){var r=i.frag,e=i.part;if(r.type===o.PlaylistLevelType.MAIN&&(0,n.isFiniteNumber)(r.sn)){var a=e?e.stats:r.stats,h=e?e.duration:r.duration;if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[r.level],f=(u.loaded?u.loaded.bytes:0)+a.loaded,c=(u.loaded?u.loaded.duration:0)+h;u.loaded={bytes:f,duration:c},u.realBitrate=Math.round(8*f/c)}r.bitrateTest&&this.onFragBuffered(s.Events.FRAG_BUFFERED,{stats:a,frag:r,part:e,id:r.type})}},f.onFragBuffered=function(t,i){var r=i.frag,n=i.part,e=n?n.stats:r.stats;if(!e.aborted&&r.type===o.PlaylistLevelType.MAIN&&"initSegment"!==r.sn){var s=e.parsing.end-e.loading.start;this.bwEstimator.sample(s,e.loaded),e.bwEstimate=this.bwEstimator.getEstimate(),this.bitrateTestDelay=r.bitrateTest?s/1e3:0}},f.onError=function(t,i){var r;if((null===(r=i.frag)||void 0===r?void 0:r.type)===o.PlaylistLevelType.MAIN){if(i.type===a.ErrorTypes.KEY_SYSTEM_ERROR)return void this.clearTimer();switch(i.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:this.clearTimer()}}},f.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},f.getNextABRAutoLevel=function(){var t=this.fragCurrent,i=this.partCurrent,r=this.hls,n=r.maxAutoLevel,e=r.config,s=r.minAutoLevel,a=r.media,o=i?i.duration:t?t.duration:0,u=a&&0!==a.playbackRate?Math.abs(a.playbackRate):1,f=this.bwEstimator?this.bwEstimator.getEstimate():e.abrEwmaDefaultEstimate,c=r.mainForwardBufferInfo,l=(c?c.len:0)/u,v=this.findBestLevel(f,s,n,l,e.abrBandWidthFactor,e.abrBandWidthUpFactor);if(v>=0)return v;h.logger.trace((l?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var d=o?Math.min(o,e.maxStarvationDelay):e.maxStarvationDelay,m=e.abrBandWidthFactor,p=e.abrBandWidthUpFactor;if(!l){var y=this.bitrateTestDelay;y&&(d=(o?Math.min(o,e.maxLoadingDelay):e.maxLoadingDelay)-y,h.logger.trace("bitrate test took "+Math.round(1e3*y)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*d)+" ms"),m=p=1)}return v=this.findBestLevel(f,s,n,l+d,m,p),Math.max(v,0)},f.findBestLevel=function(t,i,r,e,s,a){for(var o,u=this.fragCurrent,f=this.partCurrent,c=this.lastLoadedFragLevel,l=this.hls.levels,v=l[c],d=!(null==v||null===(o=v.details)||void 0===o||!o.live),m=null==v?void 0:v.codecSet,p=f?f.duration:u?u.duration:0,y=r;y>=i;y--){var g=l[y];if(g&&(!m||g.codecSet===m)){var b,w=g.details,k=(f?null==w?void 0:w.partTarget:null==w?void 0:w.averagetargetduration)||p,S=l[y].maxBitrate,T=S*k/(b=y<=c?s*t:a*t);if(h.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+y+"/"+Math.round(b)+"/"+S+"/"+k+"/"+e+"/"+T),b>S&&(0===T||!(0,n.isFiniteNumber)(T)||d&&!this.bitrateTestDelay||T<e))return y}}return-1},i=t,(r=[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel;if(-1!==t&&!this.bwEstimator.canEstimate())return t;var i=this.getNextABRAutoLevel();return-1!==t&&this.hls.levels[i].loadError?t:(-1!==t&&(i=Math.min(t,i)),i)},set:function(t){this._nextAutoLevel=t}}])&&u(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),t}();const c=f},"./src/controller/audio-stream-controller.ts":
|
|
8
|
-
/*!***************************************************!*\
|
|
9
|
-
!*** ./src/controller/audio-stream-controller.ts ***!
|
|
10
|
-
\***************************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>w});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),s=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),h=r(/*! ../types/level */"./src/types/level.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),f=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),c=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts"),l=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),v=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),d=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),m=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),p=r(/*! ../errors */"./src/errors.ts");function y(){return y=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},y.apply(this,arguments)}function g(t,i){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},g(t,i)}var b=function(t){var i,r;function b(i,r,n){var e;return(e=t.call(this,i,r,n,"[audio-stream-controller]")||this).videoBuffer=null,e.videoTrackCC=-1,e.waitingVideoCC=-1,e.audioSwitch=!1,e.trackId=-1,e.waitingData=null,e.mainDetails=null,e.bufferFlushed=!1,e.cachedTrackLoadedData=null,e._registerListeners(),e}r=t,(i=b).prototype=Object.create(r.prototype),i.prototype.constructor=i,g(i,r);var w=b.prototype;return w.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},w._registerListeners=function(){var t=this.hls;t.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(s.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(s.Events.ERROR,this.onError,this),t.on(s.Events.BUFFER_RESET,this.onBufferReset,this),t.on(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},w._unregisterListeners=function(){var t=this.hls;t.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(s.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(s.Events.ERROR,this.onError,this),t.off(s.Events.BUFFER_RESET,this.onBufferReset,this),t.off(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},w.onInitPtsFound=function(t,i){var r=i.frag,n=i.initPTS;if("main"===i.id){var s=r.cc;this.initPTS[r.cc]=n,this.log("InitPTS for cc: "+s+" found from main: "+n),this.videoTrackCC=s,this.state===e.State.WAITING_INIT_PTS&&this.tick()}},w.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=e.State.STOPPED);var i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,i>0&&-1===t?(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),t=i,this.state=e.State.IDLE):(this.loadedmetadata=!1,this.state=e.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},w.doTick=function(){switch(this.state){case e.State.IDLE:this.doTickIdle();break;case e.State.WAITING_TRACK:var i,r=this.levels,n=null==r||null===(i=r[this.trackId])||void 0===i?void 0:i.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=e.State.WAITING_INIT_PTS}break;case e.State.FRAG_LOADING_WAITING_RETRY:var s,o=performance.now(),h=this.retryDate;(!h||o>=h||null!==(s=this.media)&&void 0!==s&&s.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=e.State.IDLE);break;case e.State.WAITING_INIT_PTS:var u=this.waitingData;if(u){var f=u.frag,c=u.part,l=u.cache,v=u.complete;if(void 0!==this.initPTS[f.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=e.State.FRAG_LOADING;var m={frag:f,part:c,payload:l.flush(),networkDetails:null};this._handleFragmentLoadProgress(m),v&&t.prototype._handleFragmentLoadComplete.call(this,m)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+f.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var p=this.getLoadPosition(),y=a.BufferHelper.bufferInfo(this.mediaBuffer,p,this.config.maxBufferHole);(0,d.fragmentWithinToleranceTest)(y.end,this.config.maxFragLookUpTolerance,f)<0&&(this.log("Waiting fragment cc ("+f.cc+") @ "+f.start+" cancelled because another fragment at "+y.end+" is needed"),this.clearWaitingFragment())}}else this.state=e.State.IDLE}this.onTickEnd()},w.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=e.State.IDLE)},w.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},w.onTickEnd=function(){var t=this.media;t&&t.readyState&&(this.lastCurrentTime=t.currentTime)},w.doTickIdle=function(){var t=this.hls,i=this.levels,r=this.media,n=this.trackId;if(i&&i[n]&&(r||!this.startFragRequested&&t.config.startFragPrefetch)){var a=i[n].details;if(!a||a.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(a))this.state=e.State.WAITING_TRACK;else{var o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,f.ElementaryStreamTypes.AUDIO,u.PlaylistLevelType.AUDIO));var h=this.getFwdBufferInfo(o,u.PlaylistLevelType.AUDIO);if(null!==h){var c=this.audioSwitch;if(!c&&this._streamEnded(h,a))return t.trigger(s.Events.BUFFER_EOS,{type:"audio"}),void(this.state=e.State.ENDED);var l=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,u.PlaylistLevelType.MAIN);if(!(h.len>=this.getMaxBufferLength(null==l?void 0:l.len))||c){var v=a.fragments[0].start,d=h.end;if(c&&r){var m=this.getLoadPosition();d=m,a.PTSKnown&&m<v&&(h.end>v||h.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=v+.05)}if(!(l&&d>l.end+a.targetduration)&&(l&&l.len||!h.len)){var p=this.getNextFragment(d,a);p?this.loadFragment(p,a,d):this.bufferFlushed=!0}}}}}},w.getMaxBufferLength=function(i){var r=t.prototype.getMaxBufferLength.call(this);return i?Math.max(r,i):r},w.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},w.onAudioTracksUpdated=function(t,i){var r=i.audioTracks;this.resetTransmuxer(),this.levels=r.map((function(t){return new h.Level(t)}))},w.onAudioTrackSwitching=function(t,i){var r=!!i.url;this.trackId=i.id;var n=this.fragCurrent;n&&n.abortRequests(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=e.State.IDLE):this.state=e.State.STOPPED,this.tick()},w.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},w.onLevelLoaded=function(t,i){this.mainDetails=i.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(s.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},w.onAudioTrackLoaded=function(t,i){var r;if(null!=this.mainDetails){var n=this.levels,s=i.details,a=i.id;if(n){this.log("Track "+a+" loaded ["+s.startSN+","+s.endSN+"],duration:"+s.totalduration);var o=n[a],h=0;if(s.live||null!==(r=o.details)&&void 0!==r&&r.live){var u=this.mainDetails;if(s.fragments[0]||(s.deltaUpdateFailed=!0),s.deltaUpdateFailed||!u)return;!o.details&&s.hasProgramDateTime&&u.hasProgramDateTime?((0,m.alignMediaPlaylistByPDT)(s,u),h=s.fragments[0].start):h=this.alignPlaylists(s,o.details)}o.details=s,this.levelLastLoaded=a,this.startFragRequested||!this.mainDetails&&s.live||this.setStartPosition(o.details,h),this.state!==e.State.WAITING_TRACK||this.waitForCdnTuneIn(s)||(this.state=e.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+a)}else this.cachedTrackLoadedData=i},w._handleFragmentLoadProgress=function(t){var i,r=t.frag,n=t.part,s=t.payload,a=this.config,o=this.trackId,h=this.levels;if(h){var f=h[o];console.assert(f,"Audio track is defined on fragment load progress");var d=f.details;console.assert(d,"Audio track details are defined on fragment load progress");var m=a.defaultAudioCodec||f.audioCodec||"mp4a.40.2",p=this.transmuxer;p||(p=this.transmuxer=new l.default(this.hls,u.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var y=this.initPTS[r.cc],g=null===(i=r.initSegment)||void 0===i?void 0:i.data;if(void 0!==y){var b=n?n.index:-1,w=new v.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,s.byteLength,b,-1!==b);p.push(s,g,m,"",r,n,d.totalduration,!1,w,y)}else this.log("Unknown video PTS for cc "+r.cc+", waiting for video PTS before demuxing audio frag "+r.sn+" of ["+d.startSN+" ,"+d.endSN+"],track "+o),(this.waitingData=this.waitingData||{frag:r,part:n,cache:new c.default,complete:!1}).cache.push(new Uint8Array(s)),this.waitingVideoCC=this.videoTrackCC,this.state=e.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},w._handleFragmentLoadComplete=function(i){this.waitingData?this.waitingData.complete=!0:t.prototype._handleFragmentLoadComplete.call(this,i)},w.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},w.onBufferCreated=function(t,i){var r=i.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),i.tracks.video&&(this.videoBuffer=i.tracks.video.buffer||null)},w.onFragBuffered=function(t,i){var r,n=i.frag,e=i.part;n.type===u.PlaylistLevelType.AUDIO?this.fragContextChanged(n)?this.warn("Fragment "+n.sn+(e?" p: "+e.index:"")+" of level "+n.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==n.sn&&(this.fragPrevious=n,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(n,e)):this.loadedmetadata||n.type!==u.PlaylistLevelType.MAIN||null!==(r=this.videoBuffer||this.media)&&void 0!==r&&r.buffered.length&&(this.loadedmetadata=!0)},w.onError=function(i,r){if(r.type!==p.ErrorTypes.KEY_SYSTEM_ERROR)switch(r.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:case p.ErrorDetails.FRAG_PARSING_ERROR:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.AUDIO,r);break;case p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case p.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==e.State.ERROR&&this.state!==e.State.STOPPED&&(this.state=r.fatal?e.State.ERROR:e.State.IDLE,this.warn(r.details+" while loading frag, switching to "+this.state+" state"));break;case p.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===r.parent&&(this.state===e.State.PARSING||this.state===e.State.PARSED)){var n=!0,s=this.getFwdBufferInfo(this.mediaBuffer,u.PlaylistLevelType.AUDIO);s&&s.len>.5&&(n=!this.reduceMaxBufferLength(s.len)),n&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}else this.onFragmentOrKeyLoadError(u.PlaylistLevelType.AUDIO,r)},w.onBufferFlushed=function(t,i){i.type===f.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0,this.state===e.State.ENDED&&(this.state=e.State.IDLE))},w._handleTransmuxComplete=function(t){var i,r="audio",n=this.hls,a=t.remuxResult,o=t.chunkMeta,h=this.getCurrentContext(o);if(!h)return this.warn("The loading context changed while buffering fragment "+o.sn+" of level "+o.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(o.level);var u=h.frag,c=h.part,l=h.level.details,v=a.audio,d=a.text,m=a.id3,p=a.initSegment;if(!this.fragContextChanged(u)&&l){if(this.state=e.State.PARSING,this.audioSwitch&&v&&this.completeAudioSwitch(),null!=p&&p.tracks&&(this._bufferInitSegment(p.tracks,u,o),n.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:r,tracks:p.tracks})),v){var g=v.startPTS,b=v.endPTS,w=v.startDTS,k=v.endDTS;c&&(c.elementaryStreams[f.ElementaryStreamTypes.AUDIO]={startPTS:g,endPTS:b,startDTS:w,endDTS:k}),u.setElementaryStreamInfo(f.ElementaryStreamTypes.AUDIO,g,b,w,k),this.bufferFragmentData(v,u,c,o)}if(null!=m&&null!==(i=m.samples)&&void 0!==i&&i.length){var S=y({id:r,frag:u,details:l},m);n.trigger(s.Events.FRAG_PARSING_METADATA,S)}if(d){var T=y({id:r,frag:u,details:l},d);n.trigger(s.Events.FRAG_PARSING_USERDATA,T)}}},w._bufferInitSegment=function(t,i,r){if(this.state===e.State.PARSING){t.video&&delete t.video;var n=t.audio;if(n){n.levelCodec=n.codec,n.id="audio",this.log("Init audio buffer, container:"+n.container+", codecs[parsed]=["+n.codec+"]"),this.hls.trigger(s.Events.BUFFER_CODECS,t);var a=n.initSegment;null!=a&&a.byteLength&&this.hls.trigger(s.Events.BUFFER_APPENDING,{type:"audio",frag:i,part:null,chunkMeta:r,parent:i.type,data:a}),this.tick()}}},w.loadFragment=function(i,r,s){var a=this.fragmentTracker.getState(i);this.fragCurrent=i,(this.audioSwitch||a===o.FragmentState.NOT_LOADED||a===o.FragmentState.PARTIAL)&&("initSegment"===i.sn?this._loadInitSegment(i,r):r.live&&!(0,n.isFiniteNumber)(this.initPTS[i.cc])?(this.log("Waiting for video PTS in continuity counter "+i.cc+" of live stream before loading audio fragment "+i.sn+" of level "+this.trackId),this.state=e.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,i,r,s)))},w.completeAudioSwitch=function(){var i=this.hls,r=this.trackId;this.media&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,i.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:r})},b}(e.default);const w=b},"./src/controller/audio-track-controller.ts":
|
|
11
|
-
/*!**************************************************!*\
|
|
12
|
-
!*** ./src/controller/audio-track-controller.ts ***!
|
|
13
|
-
\**************************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>f});var n=r(/*! ../events */"./src/events.ts"),e=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),a=r(/*! ../types/loader */"./src/types/loader.ts");function o(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}function h(t,i){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},h(t,i)}var u=function(t){var i,r;function s(i){var r;return(r=t.call(this,i,"[audio-track-controller]")||this).tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.trackName="",r.selectDefaultTrack=!0,r.registerListeners(),r}r=t,(i=s).prototype=Object.create(r.prototype),i.prototype.constructor=i,h(i,r);var u,f,c=s.prototype;return c.registerListeners=function(){var t=this.hls;t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(n.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(n.Events.ERROR,this.onError,this)},c.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(n.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(n.Events.ERROR,this.onError,this)},c.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,t.prototype.destroy.call(this)},c.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},c.onManifestParsed=function(t,i){this.tracks=i.audioTracks||[]},c.onAudioTrackLoaded=function(t,i){var r=i.id,n=i.details,e=this.tracksInGroup[r];if(e){var s=e.details;e.details=i.details,this.log("audioTrack "+r+" loaded ["+n.startSN+"-"+n.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,i,s))}else this.warn("Invalid audio track id "+r)},c.onLevelLoading=function(t,i){this.switchLevel(i.level)},c.onLevelSwitching=function(t,i){this.switchLevel(i.level)},c.switchLevel=function(t){var i=this.hls.levels[t];if(null!=i&&i.audioGroupIds){var r=i.audioGroupIds[i.urlId];if(this.groupId!==r){this.groupId=r;var e=this.tracks.filter((function(t){return!r||t.groupId===r}));this.selectDefaultTrack&&!e.some((function(t){return t.default}))&&(this.selectDefaultTrack=!1),this.tracksInGroup=e;var s={audioTracks:e};this.log("Updating audio tracks, "+e.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(n.Events.AUDIO_TRACKS_UPDATED,s),this.selectInitialTrack()}}},c.onError=function(i,r){t.prototype.onError.call(this,i,r),!r.fatal&&r.context&&r.context.type===a.PlaylistContextType.AUDIO_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},c.setAudioTrack=function(t){var i=this.tracksInGroup;if(t<0||t>=i.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var r=i[this.trackId];this.log("Now switching to audio-track index "+t);var e=i[t],s=e.id,a=e.groupId,o=void 0===a?"":a,h=e.name,u=e.type,f=e.url;if(this.trackId=t,this.trackName=h,this.selectDefaultTrack=!1,this.hls.trigger(n.Events.AUDIO_TRACK_SWITCHING,{id:s,groupId:o,name:h,type:u,url:f}),!e.details||e.details.live){var c=this.switchParams(e.url,null==r?void 0:r.details);this.loadPlaylist(c)}}},c.selectInitialTrack=function(){console.assert(this.tracksInGroup.length,"Initial audio track should be selected when tracks are known");var t=this.findTrackId(this.trackName)||this.findTrackId();-1!==t?this.setAudioTrack(t):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(n.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},c.findTrackId=function(t){for(var i=this.tracksInGroup,r=0;r<i.length;r++){var n=i[r];if((!this.selectDefaultTrack||n.default)&&(!t||t===n.name))return n.id}return-1},c.loadPlaylist=function(i){t.prototype.loadPlaylist.call(this);var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var e=r.id,s=r.groupId,a=r.url;if(i)try{a=i.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("loading audio-track playlist for id: "+e),this.clearTimer(),this.hls.trigger(n.Events.AUDIO_TRACK_LOADING,{url:a,id:e,groupId:s,deliveryDirectives:i||null})}},u=s,(f=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}}])&&o(u.prototype,f),Object.defineProperty(u,"prototype",{writable:!1}),s}(s.default);const f=u},"./src/controller/base-playlist-controller.ts":
|
|
14
|
-
/*!****************************************************!*\
|
|
15
|
-
!*** ./src/controller/base-playlist-controller.ts ***!
|
|
16
|
-
\****************************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>o});var n=r(/*! ../types/level */"./src/types/level.ts"),e=r(/*! ./level-helper */"./src/controller/level-helper.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../errors */"./src/errors.ts"),o=function(){function t(t,i){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=s.logger.log.bind(s.logger,i+":"),this.warn=s.logger.warn.bind(s.logger,i+":"),this.hls=t}var i=t.prototype;return i.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},i.onError=function(t,i){!i.fatal||i.type!==a.ErrorTypes.NETWORK_ERROR&&i.type!==a.ErrorTypes.KEY_SYSTEM_ERROR||this.stopLoad()},i.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},i.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.requestScheduled=-1,this.loadPlaylist()},i.stopLoad=function(){this.canLoad=!1,this.clearTimer()},i.switchParams=function(t,i){var r=null==i?void 0:i.renditionReports;if(r)for(var e=0;e<r.length;e++){var a=r[e],o=void 0;try{o=new self.URL(a.URI,i.url).href}catch(t){s.logger.warn("Could not construct new URL for Rendition Report: "+t),o=a.URI||""}if(o===t.slice(-o.length)){var h=parseInt(a["LAST-MSN"])||(null==i?void 0:i.lastPartSn),u=parseInt(a["LAST-PART"])||(null==i?void 0:i.lastPartIndex);if(this.hls.config.lowLatencyMode){var f=Math.min(i.age-i.partTarget,i.targetduration);u>=0&&f>i.partTarget&&(u+=1)}return new n.HlsUrlParameters(h,u>=0?u:void 0,n.HlsSkip.No)}}},i.loadPlaylist=function(){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},i.shouldLoadTrack=function(t){return this.canLoad&&t&&!!t.url&&(!t.details||t.details.live)},i.playlistLoaded=function(t,i,r){var n=this,s=i.details,a=i.stats,o=self.performance.now(),h=a.loading.first?Math.max(0,o-a.loading.first):0;if(s.advancedDateTime=Date.now()-h,s.live||null!=r&&r.live){if(s.reloaded(r),r&&this.log("live playlist "+t+" "+(s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:"MISSED")),r&&s.fragments.length>0&&(0,e.mergeDetails)(r,s),!this.canLoad||!s.live)return;var u,f=void 0,c=void 0;if(s.canBlockReload&&s.endSN&&s.advanced){var l=this.hls.config.lowLatencyMode,v=s.lastPartSn,d=s.endSN,m=s.lastPartIndex,p=v===d;-1!==m?(f=p?d+1:v,c=p?l?0:m:m+1):f=d+1;var y=s.age,g=Math.min(y+s.ageHeader-s.partTarget,1.5*s.targetduration);if(g>0){if(r&&g>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+g+" with playlist age: "+s.age),g=0;else{var b=Math.floor(g/s.targetduration);f+=b,void 0!==c&&(c+=Math.round(g%s.targetduration/s.partTarget)),this.log("CDN Tune-in age: "+s.ageHeader+"s last advanced "+y.toFixed(2)+"s goal: "+g+" skip sn "+b+" to part "+c)}s.tuneInGoal=g}if(u=this.getDeliveryDirectives(s,i.deliveryDirectives,f,c),l||!p)return void this.loadPlaylist(u)}else u=this.getDeliveryDirectives(s,i.deliveryDirectives,f,c);var w=this.hls.mainForwardBufferInfo,k=(0,e.computeReloadInterval)(s,1e3*(s.edge-(w?w.end-w.len:0)));s.updated?o>this.requestScheduled+k&&(this.requestScheduled=a.loading.start):this.requestScheduled=-1,this.requestScheduled=void 0!==f&&s.canBlockReload?a.loading.first+k-(1e3*s.partTarget||1e3):(-1===this.requestScheduled?o:this.requestScheduled)+k;var S=this.requestScheduled-o;S=Math.max(0,S),this.log("reload live playlist "+t+" in "+Math.round(S)+" ms"),this.timer=self.setTimeout((function(){return n.loadPlaylist(u)}),S)}else this.clearTimer()},i.getDeliveryDirectives=function(t,i,r,e){var s=(0,n.getSkipValue)(t,r);return null!=i&&i.skip&&t.deltaUpdateFailed&&(r=i.msn,e=i.part,s=n.HlsSkip.No),new n.HlsUrlParameters(r,e,s)},i.retryLoadingOrFail=function(t){var i,r=this,n=this.hls.config,e=this.retryCount<n.levelLoadingMaxRetry;if(e)if(this.requestScheduled=-1,this.retryCount++,t.details.indexOf("LoadTimeOut")>-1&&null!==(i=t.context)&&void 0!==i&&i.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+t.details+'"'),this.loadPlaylist();else{var s=Math.min(Math.pow(2,this.retryCount)*n.levelLoadingRetryDelay,n.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return r.loadPlaylist()}),s),this.warn("retry playlist loading #"+this.retryCount+" in "+s+' ms after "'+t.details+'"')}else this.warn('cannot recover from error "'+t.details+'"'),this.clearTimer(),t.fatal=!0;return e},t}()},"./src/controller/base-stream-controller.ts":
|
|
17
|
-
/*!**************************************************!*\
|
|
18
|
-
!*** ./src/controller/base-stream-controller.ts ***!
|
|
19
|
-
\**************************************************/(t,i,r)=>{r.r(i),r.d(i,{State:()=>k,default:()=>S});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ../task-loop */"./src/task-loop.ts"),s=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),h=r(/*! ../events */"./src/events.ts"),u=r(/*! ../errors */"./src/errors.ts"),f=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),c=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),v=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),d=r(/*! ./level-helper */"./src/controller/level-helper.ts"),m=r(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),p=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),y=r(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts"),g=r(/*! ../types/loader */"./src/types/loader.ts");function b(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}function w(t,i){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},w(t,i)}var k={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},S=function(t){var i,r;function e(i,r,n,e){var s;return(s=t.call(this)||this).hls=void 0,s.fragPrevious=null,s.fragCurrent=null,s.fragmentTracker=void 0,s.transmuxer=null,s._state=k.STOPPED,s.media=null,s.mediaBuffer=null,s.config=void 0,s.bitrateTest=!1,s.lastCurrentTime=0,s.nextLoadPosition=0,s.startPosition=0,s.loadedmetadata=!1,s.fragLoadError=0,s.retryDate=0,s.levels=null,s.fragmentLoader=void 0,s.keyLoader=void 0,s.levelLastLoaded=null,s.startFragRequested=!1,s.decrypter=void 0,s.initPTS=[],s.onvseeking=null,s.onvended=null,s.logPrefix="",s.log=void 0,s.warn=void 0,s.logPrefix=e,s.log=o.logger.log.bind(o.logger,e+":"),s.warn=o.logger.warn.bind(o.logger,e+":"),s.hls=i,s.fragmentLoader=new m.default(i.config),s.keyLoader=n,s.fragmentTracker=r,s.config=i.config,s.decrypter=new p.default(i.config),i.on(h.Events.LEVEL_SWITCHING,s.onLevelSwitching,function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(s)),s}r=t,(i=e).prototype=Object.create(r.prototype),i.prototype.constructor=i,w(i,r);var S,T,E=e.prototype;return E.doTick=function(){this.onTickEnd()},E.onTickEnd=function(){},E.startLoad=function(){},E.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var t=this.fragCurrent;t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=k.STOPPED},E._streamEnded=function(t,i){if(i.live||t.nextStart||!t.end||!this.media)return!1;var r=i.partList;if(null!=r&&r.length){var n=r[r.length-1];return a.BufferHelper.isBuffered(this.media,n.start+n.duration/2)}return this.fragmentTracker.isEndListAppended(i.fragments[i.fragments.length-1].type)},E.getLevelDetails=function(){var t;if(this.levels&&null!==this.levelLastLoaded)return null===(t=this.levels[this.levelLastLoaded])||void 0===t?void 0:t.details},E.onMediaAttached=function(t,i){var r=this.media=this.mediaBuffer=i.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var n=this.config;this.levels&&n.autoStartLoad&&this.state===k.STOPPED&&this.startLoad(n.startPosition)},E.onMediaDetaching=function(){var t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},E.onMediaSeeking=function(){var t=this.config,i=this.fragCurrent,r=this.media,e=this.state,s=r?r.currentTime:0,o=a.BufferHelper.bufferInfo(this.mediaBuffer||r,s,t.maxBufferHole);if(this.log("media seeking to "+((0,n.isFiniteNumber)(s)?s.toFixed(3):s)+", state: "+e),this.state===k.ENDED)this.resetLoadingState();else if(i){var h=t.maxFragLookUpTolerance,u=i.start-h,f=i.start+i.duration+h;if(!o.len||f<o.start||u>o.end){var c=s>f;(s<u||c)&&(c&&i.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),i.abortRequests()),this.resetLoadingState())}}r&&(this.lastCurrentTime=s),this.loadedmetadata||o.len||(this.nextLoadPosition=this.startPosition=s),this.tickImmediate()},E.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},E.onLevelSwitching=function(){this.fragLoadError=0},E.onHandlerDestroying=function(){this.stopLoad(),t.prototype.onHandlerDestroying.call(this)},E.onHandlerDestroyed=function(){this.state=k.STOPPED,this.hls.off(h.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,t.prototype.onHandlerDestroyed.call(this)},E.loadFragment=function(t,i,r){this._loadFragForPlayback(t,i,r)},E._loadFragForPlayback=function(t,i,r){var n=this;this._doFragLoad(t,i,r,(function(i){if(n.fragContextChanged(t))return n.warn("Fragment "+t.sn+(i.part?" p: "+i.part.index:"")+" of level "+t.level+" was dropped during download."),void n.fragmentTracker.removeFragment(t);t.stats.chunkCount++,n._handleFragmentLoadProgress(i)})).then((function(i){if(i){n.fragLoadError=0;var r=n.state;n.fragContextChanged(t)?(r===k.FRAG_LOADING||!n.fragCurrent&&r===k.PARSING)&&(n.fragmentTracker.removeFragment(t),n.state=k.IDLE):("payload"in i&&(n.log("Loaded fragment "+t.sn+" of level "+t.level),n.hls.trigger(h.Events.FRAG_LOADED,i)),n._handleFragmentLoadComplete(i))}})).catch((function(i){n.state!==k.STOPPED&&n.state!==k.ERROR&&(n.warn(i),n.resetFragmentLoading(t))}))},E.flushMainBuffer=function(t,i,r){if(void 0===r&&(r=null),t-i){var n={startOffset:t,endOffset:i,type:r};this.fragLoadError=0,this.hls.trigger(h.Events.BUFFER_FLUSHING,n)}},E._loadInitSegment=function(t,i){var r=this;this._doFragLoad(t,i).then((function(i){if(!i||r.fragContextChanged(t)||!r.levels)throw new Error("init load aborted");return i})).then((function(i){var n=r.hls,e=i.payload,s=t.decryptdata;if(e&&e.byteLength>0&&s&&s.key&&s.iv&&"AES-128"===s.method){var a=self.performance.now();return r.decrypter.decrypt(new Uint8Array(e),s.key.buffer,s.iv.buffer).then((function(r){var e=self.performance.now();return n.trigger(h.Events.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:a,tdecrypt:e}}),i.payload=r,i}))}return i})).then((function(i){var n=r.fragCurrent,e=r.hls,s=r.levels;if(!s)throw new Error("init load aborted, missing levels");console.assert(s[t.level].details,"Level details are defined when init segment is loaded");var a=t.stats;r.state=k.IDLE,r.fragLoadError=0,t.data=new Uint8Array(i.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),i.frag===n&&e.trigger(h.Events.FRAG_BUFFERED,{stats:a,frag:n,part:null,id:t.type}),r.tick()})).catch((function(i){r.state!==k.STOPPED&&r.state!==k.ERROR&&(r.warn(i),r.resetFragmentLoading(t))}))},E.fragContextChanged=function(t){var i=this.fragCurrent;return!t||!i||t.level!==i.level||t.sn!==i.sn||t.urlId!==i.urlId},E.fragBufferedComplete=function(t,i){var r,n,e,s,o=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(i?" part: "+i.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level+" (frag:["+(null!=(r=t.startPTS)?r:NaN).toFixed(3)+"-"+(null!=(n=t.endPTS)?n:NaN).toFixed(3)+"] > buffer:"+(o?y.default.toString(a.BufferHelper.getBuffered(o)):"(detached)")+")"),this.state=k.IDLE,o&&(!this.loadedmetadata&&t.type==g.PlaylistLevelType.MAIN&&o.buffered.length&&(null===(e=this.fragCurrent)||void 0===e?void 0:e.sn)===(null===(s=this.fragPrevious)||void 0===s?void 0:s.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},E.seekToStartPos=function(){},E._handleFragmentLoadComplete=function(t){var i=this.transmuxer;if(i){var r=t.frag,n=t.part,e=t.partsLoaded,s=!e||0===e.length||e.some((function(t){return!t})),a=new f.ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,n?n.index:-1,!s);i.flush(a)}},E._handleFragmentLoadProgress=function(){},E._doFragLoad=function(t,i,r,e){var s,a=this;if(void 0===r&&(r=null),!this.levels)throw new Error("frag load aborted, missing levels");var o=null;if(!t.encrypted||null!==(s=t.decryptdata)&&void 0!==s&&s.key?!t.encrypted&&i.encryptedFragments.length&&this.keyLoader.loadClear(t,i.encryptedFragments):(this.log("Loading key for "+t.sn+" of ["+i.startSN+"-"+i.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level),this.state=k.KEY_LOADING,this.fragCurrent=t,o=this.keyLoader.load(t).then((function(t){if(!a.fragContextChanged(t.frag))return a.hls.trigger(h.Events.KEY_LOADED,t),a.state===k.KEY_LOADING&&(a.state=k.IDLE),t})),this.hls.trigger(h.Events.KEY_LOADING,{frag:t}),this.throwIfFragContextChanged("KEY_LOADING")),r=Math.max(t.start,r||0),this.config.lowLatencyMode&&i){var u=i.partList;if(u&&e){r>t.end&&i.fragmentHint&&(t=i.fragmentHint);var f=this.getNextPart(u,t,r);if(f>-1){var c=u[f];return this.log("Loading part sn: "+t.sn+" p: "+c.index+" cc: "+t.cc+" of playlist ["+i.startSN+"-"+i.endSN+"] parts [0-"+f+"-"+(u.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=c.start+c.duration,this.state=k.FRAG_LOADING,this.hls.trigger(h.Events.FRAG_LOADING,{frag:t,part:u[f],targetBufferTime:r}),this.throwIfFragContextChanged("FRAG_LOADING parts"),o?o.then((function(i){return!i||a.fragContextChanged(i.frag)?null:a.doFragPartsLoad(t,u,f,e)})).catch((function(t){return a.handleFragLoadError(t)})):this.doFragPartsLoad(t,u,f,e).catch((function(t){return a.handleFragLoadError(t)}))}if(!t.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(i?"of ["+i.startSN+"-"+i.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),(0,n.isFiniteNumber)(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=k.FRAG_LOADING,this.hls.trigger(h.Events.FRAG_LOADING,{frag:t,targetBufferTime:r}),this.throwIfFragContextChanged("FRAG_LOADING");var l=this.config.progressive;return l&&o?o.then((function(i){return!i||a.fragContextChanged(null==i?void 0:i.frag)?null:a.fragmentLoader.load(t,e)})).catch((function(t){return a.handleFragLoadError(t)})):Promise.all([this.fragmentLoader.load(t,l?e:void 0),o]).then((function(t){var i=t[0];return!l&&i&&e&&e(i),i})).catch((function(t){return a.handleFragLoadError(t)}))},E.throwIfFragContextChanged=function(t){if(null===this.fragCurrent)throw new Error("frag load aborted, context changed in "+t)},E.doFragPartsLoad=function(t,i,r,n){var e=this;return new Promise((function(s,a){var o=[];!function r(u){var f=i[u];e.fragmentLoader.loadPart(t,f,n).then((function(n){o[f.index]=n;var a=n.part;e.hls.trigger(h.Events.FRAG_LOADED,n);var c=i[u+1];if(!c||c.fragment!==t)return s({frag:t,part:a,partsLoaded:o});r(u+1)})).catch(a)}(r)}))},E.handleFragLoadError=function(t){if("data"in t){var i=t.data;t.data&&i.details===u.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(i.frag,i.part):this.hls.trigger(h.Events.ERROR,i)}else this.hls.trigger(h.Events.ERROR,{type:u.ErrorTypes.OTHER_ERROR,details:u.ErrorDetails.INTERNAL_EXCEPTION,err:t,fatal:!0});return null},E._handleTransmuxerFlush=function(t){var i=this.getCurrentContext(t);if(i&&this.state===k.PARSING){var r=i.frag,n=i.part,e=i.level,s=self.performance.now();r.stats.parsing.end=s,n&&(n.stats.parsing.end=s),this.updateLevelTiming(r,n,e,t.partial)}else this.fragCurrent||this.state===k.STOPPED||this.state===k.ERROR||(this.state=k.IDLE)},E.getCurrentContext=function(t){var i=this.levels,r=t.level,n=t.sn,e=t.part;if(!i||!i[r])return this.warn("Levels object was unset while buffering fragment "+n+" of level "+r+". The current chunk will not be buffered."),null;var s=i[r],a=e>-1?(0,d.getPartWith)(s,n,e):null,o=a?a.fragment:(0,d.getFragmentWithSN)(s,n,this.fragCurrent);return o?{frag:o,part:a,level:s}:null},E.bufferFragmentData=function(t,i,r,n){if(t&&this.state===k.PARSING){var e=t.data1,s=t.data2,a=e;e&&s&&(a=(0,c.appendUint8Array)(e,s)),a&&a.length&&(this.hls.trigger(h.Events.BUFFER_APPENDING,{type:t.type,frag:i,part:r,chunkMeta:n,parent:i.type,data:a}),t.dropped&&t.independent&&!r&&this.flushBufferGap(i))}},E.flushBufferGap=function(t){var i=this.media;if(i)if(a.BufferHelper.isBuffered(i,i.currentTime)){var r=i.currentTime,n=a.BufferHelper.bufferInfo(i,r,0),e=Math.min(2*this.config.maxFragLookUpTolerance,.25*t.duration),s=Math.max(Math.min(t.start-e,n.end-e),r+e);t.start-s>e&&this.flushMainBuffer(s,t.start)}else this.flushMainBuffer(0,t.start)},E.getFwdBufferInfo=function(t,i){var r=this.config,e=this.getLoadPosition();if(!(0,n.isFiniteNumber)(e))return null;var s=a.BufferHelper.bufferInfo(t,e,r.maxBufferHole);if(0===s.len&&void 0!==s.nextStart){var o=this.fragmentTracker.getBufferedFrag(e,i);if(o&&s.nextStart<o.end)return a.BufferHelper.bufferInfo(t,e,Math.max(s.nextStart,r.maxBufferHole))}return s},E.getMaxBufferLength=function(t){var i,r=this.config;return i=t?Math.max(8*r.maxBufferSize/t,r.maxBufferLength):r.maxBufferLength,Math.min(i,r.maxMaxBufferLength)},E.reduceMaxBufferLength=function(t){var i=this.config;return i.maxMaxBufferLength>=(t||i.maxBufferLength)&&(i.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+i.maxMaxBufferLength+"s"),!0)},E.getNextFragment=function(t,i){var r=i.fragments,n=r.length;if(!n)return null;var e,s=this.config,a=r[0].start;if(i.live){var o=s.initialLiveManifestSize;if(n<o)return this.warn("Not enough fragments to start playback (have: "+n+", need: "+o+")"),null;i.PTSKnown||this.startFragRequested||-1!==this.startPosition||(e=this.getInitialLiveFragment(i,r),this.startPosition=e?this.hls.liveSyncPosition||e.start:t)}else t<=a&&(e=r[0]);return e||(e=this.getFragmentAtPosition(t,s.lowLatencyMode?i.partEnd:i.fragmentEnd,i)),this.mapToInitFragWhenRequired(e)},E.mapToInitFragWhenRequired=function(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment},E.getNextPart=function(t,i,r){for(var n=-1,e=!1,s=!0,a=0,o=t.length;a<o;a++){var h=t[a];if(s=s&&!h.independent,n>-1&&r<h.start)break;var u=h.loaded;u?n=-1:(e||h.independent||s)&&h.fragment===i&&(n=a),e=u}return n},E.loadedEndOfParts=function(t,i){var r=t[t.length-1];return r&&i>r.start&&r.loaded},E.getInitialLiveFragment=function(t,i){var r=this.fragPrevious,n=null;if(r){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),n=(0,v.findFragmentByPDT)(i,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){var e=r.sn+1;if(e>=t.startSN&&e<=t.endSN){var s=i[e-t.startSN];r.cc===s.cc&&this.log("Live playlist, switching playlist, load frag with next SN: "+(n=s).sn)}n||(n=(0,v.findFragWithCC)(i,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+n.sn)}}else{var a=this.hls.liveSyncPosition;null!==a&&(n=this.getFragmentAtPosition(a,this.bitrateTest?t.fragmentEnd:t.edge,t))}return n},E.getFragmentAtPosition=function(t,i,r){var n,e=this.config,a=this.fragPrevious,o=r.fragments,h=r.endSN,u=r.fragmentHint,f=e.maxFragLookUpTolerance,c=!!(e.lowLatencyMode&&r.partList&&u);if(c&&u&&!this.bitrateTest&&(o=o.concat(u),h=u.sn),n=t<i?(0,v.findFragmentByPTS)(a,o,t,t>i-f?0:f):o[o.length-1]){var l=n.sn-r.startSN;if(this.fragmentTracker.getState(n)===s.FragmentState.OK&&(a=n),a&&n.sn===a.sn&&!c&&a&&n.level===a.level){var d=o[l+1];n.sn<h&&this.fragmentTracker.getState(d)!==s.FragmentState.OK?(this.log("SN "+n.sn+" just loaded, load next one: "+d.sn),n=d):n=null}}return n},E.synchronizeToLiveEdge=function(t){var i=this.config,r=this.media;if(r){var n=this.hls.liveSyncPosition,e=r.currentTime,s=t.edge,a=e>=t.fragments[0].start-i.maxFragLookUpTolerance&&e<=s;null!==n&&r.duration>n&&(e<n||!a)&&(!a&&r.readyState<4||e<s-(void 0!==i.liveMaxLatencyDuration?i.liveMaxLatencyDuration:i.liveMaxLatencyDurationCount*t.targetduration))&&(this.loadedmetadata||(this.nextLoadPosition=n),r.readyState&&(this.warn("Playback: "+e.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+n.toFixed(3)),r.currentTime=n))}},E.alignPlaylists=function(t,i){var r=this.levelLastLoaded,e=this.fragPrevious,s=null!==r?this.levels[r]:null,a=t.fragments.length;if(!a)return this.warn("No fragments in live playlist"),0;var o=t.fragments[0].start,h=!i,u=t.alignedSliding&&(0,n.isFiniteNumber)(o);if(h||!u&&!o){(0,l.alignStream)(e,s,t);var f=t.fragments[0].start;return this.log("Live playlist sliding: "+f.toFixed(2)+" start-sn: "+(i?i.startSN:"na")+"->"+t.startSN+" prev-sn: "+(e?e.sn:"na")+" fragments: "+a),f}return o},E.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},E.setStartPosition=function(t,i){var r=this.startPosition;if(r<i&&(r=-1),-1===r||-1===this.lastCurrentTime){var e=t.startTimeOffset;(0,n.isFiniteNumber)(e)?(r=i+e,e<0&&(r+=t.totalduration),r=Math.min(Math.max(i,r),i+t.totalduration),this.log("Start time offset "+e+" found in playlist, adjust startPosition to "+r),this.startPosition=r):t.live?r=this.hls.liveSyncPosition||i:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},E.getLoadPosition=function(){var t=this.media,i=0;return this.loadedmetadata&&t?i=t.currentTime:this.nextLoadPosition&&(i=this.nextLoadPosition),i},E.handleFragLoadAborted=function(t,i){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(i?" part"+i.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},E.resetFragmentLoading=function(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===k.FRAG_LOADING_WAITING_RETRY)||(this.state=k.IDLE)},E.onFragmentOrKeyLoadError=function(t,i){if(i.fatal)return this.stopLoad(),void(this.state=k.ERROR);var r=this.config;if(i.chunkMeta){var n=this.getCurrentContext(i.chunkMeta);n&&(i.frag=n.frag,i.levelRetry=!0,this.fragLoadError=r.fragLoadingMaxRetry)}var e=i.frag;if(e&&e.type===t){var s=this.fragCurrent;if(console.assert(s&&e.sn===s.sn&&e.level===s.level&&e.urlId===s.urlId,"Frag load error must match current frag to retry"),this.fragLoadError+1<=r.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var a=Math.min(Math.pow(2,this.fragLoadError)*r.fragLoadingRetryDelay,r.fragLoadingMaxRetryTimeout);this.warn("Fragment "+e.sn+" of "+t+" "+e.level+" failed to load, retrying in "+a+"ms"),this.retryDate=self.performance.now()+a,this.fragLoadError++,this.state=k.FRAG_LOADING_WAITING_RETRY}else i.levelRetry?(t===g.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=k.IDLE):(o.logger.error(i.details+" reaches max retry, redispatch as fatal ..."),i.fatal=!0,this.hls.stopLoad(),this.state=k.ERROR)}},E.afterBufferFlushed=function(t,i,r){if(t){var n=a.BufferHelper.getBuffered(t);this.fragmentTracker.detectEvictedFragments(i,n,r),this.state===k.ENDED&&this.resetLoadingState()}},E.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=k.IDLE},E.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var i=this.levels?this.levels[t].details:null;null!=i&&i.live?(this.startPosition=-1,this.setStartPosition(i,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},E.updateLevelTiming=function(t,i,r,n){var e=this,s=r.details;console.assert(!!s,"level.details must be defined"),Object.keys(t.elementaryStreams).reduce((function(i,a){var o=t.elementaryStreams[a];if(o){var u=o.endPTS-o.startPTS;if(u<=0)return e.warn("Could not parse fragment "+t.sn+" "+a+" duration reliably ("+u+")"),i||!1;var f=n?0:(0,d.updateFragPTSDTS)(s,t,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return e.hls.trigger(h.Events.LEVEL_PTS_UPDATED,{details:s,level:r,drift:f,type:a,frag:t,start:o.startPTS,end:o.endPTS}),!0}return i}),!1)||(this.warn("Found no media in fragment "+t.sn+" of level "+r.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=k.PARSED,this.hls.trigger(h.Events.FRAG_PARSED,{frag:t,part:i})},E.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},S=e,(T=[{key:"state",get:function(){return this._state},set:function(t){var i=this._state;i!==t&&(this._state=t,this.log(i+"->"+t))}}])&&b(S.prototype,T),Object.defineProperty(S,"prototype",{writable:!1}),e}(e.default)},"./src/controller/buffer-controller.ts":
|
|
20
|
-
/*!*********************************************!*\
|
|
21
|
-
!*** ./src/controller/buffer-controller.ts ***!
|
|
22
|
-
\*********************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>v});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),h=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),f=r(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),c=(0,h.getMediaSource)(),l=/([ha]vc.)(?:\.[^.,]+)+/,v=function(){function t(t){var i=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var t=i.media,r=i.mediaSource;s.logger.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",i._onMediaEmptied),i.updateMediaElementDuration(),i.hls.trigger(e.Events.MEDIA_ATTACHED,{media:t})),r&&r.removeEventListener("sourceopen",i._onMediaSourceOpen),i.checkPendingTracks()},this._onMediaSourceClose=function(){s.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){s.logger.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var t=i.media,r=i._objectUrl;t&&t.src!==r&&s.logger.error("Media element src was set while attaching MediaSource ("+r+" > "+t.src+")")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var i=t.prototype;return i.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},i.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},i.registerListeners=function(){var t=this.hls;t.on(e.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(e.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(e.Events.BUFFER_RESET,this.onBufferReset,this),t.on(e.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.on(e.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(e.Events.BUFFER_EOS,this.onBufferEos,this),t.on(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(e.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(e.Events.FRAG_PARSED,this.onFragParsed,this),t.on(e.Events.FRAG_CHANGED,this.onFragChanged,this)},i.unregisterListeners=function(){var t=this.hls;t.off(e.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(e.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(e.Events.BUFFER_RESET,this.onBufferReset,this),t.off(e.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.off(e.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(e.Events.BUFFER_EOS,this.onBufferEos,this),t.off(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(e.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(e.Events.FRAG_PARSED,this.onFragParsed,this),t.off(e.Events.FRAG_CHANGED,this.onFragChanged,this)},i._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new f.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},i.onManifestParsed=function(t,i){var r=2;(i.audio&&!i.video||!i.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,s.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},i.onMediaAttaching=function(t,i){var r=this.media=i.media;if(r&&c){var n=this.mediaSource=new c;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(n),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}},i.onMediaDetaching=function(){var t=this.media,i=this.mediaSource,r=this._objectUrl;if(i){if(s.logger.log("[buffer-controller]: media source detaching"),"open"===i.readyState)try{i.endOfStream()}catch(t){s.logger.warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),i.removeEventListener("sourceopen",this._onMediaSourceOpen),i.removeEventListener("sourceended",this._onMediaSourceEnded),i.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),t.src===r?(t.removeAttribute("src"),t.load()):s.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(e.Events.MEDIA_DETACHED,void 0)},i.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach((function(i){var r=t.sourceBuffer[i];try{r&&(t.removeBufferListeners(i),t.mediaSource&&t.mediaSource.removeSourceBuffer(r),t.sourceBuffer[i]=void 0)}catch(t){s.logger.warn("[buffer-controller]: Failed to reset the "+i+" buffer",t)}})),this._initSourceBuffer()},i.onBufferCodecs=function(t,i){var r=this,n=this.getSourceBufferTypes().length;Object.keys(i).forEach((function(t){if(n){var e=r.tracks[t];if(e&&"function"==typeof e.buffer.changeType){var a=i[t],o=a.id,h=a.codec,u=a.levelCodec,f=a.container,c=a.metadata,v=(e.levelCodec||e.codec).replace(l,"$1"),d=(u||h).replace(l,"$1");v!==d&&(r.appendChangeType(t,f+";codecs="+(u||h)),s.logger.log("[buffer-controller]: switching codec "+v+" to "+d),r.tracks[t]={buffer:e.buffer,codec:h,container:f,levelCodec:u,metadata:c,id:o})}}else r.pendingTracks[t]=i[t]})),n||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},i.appendChangeType=function(t,i){var r=this,n=this.operationQueue,e={execute:function(){var e=r.sourceBuffer[t];e&&(s.logger.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+i),e.changeType(i)),n.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(i){s.logger.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",i)}};n.append(e,t)},i.onBufferAppending=function(t,i){var r=this,n=this.hls,h=this.operationQueue,u=this.tracks,f=i.data,c=i.type,l=i.frag,v=i.part,d=i.chunkMeta,m=d.buffering[c],p=self.performance.now();m.start=p;var y=l.stats.buffering,g=v?v.stats.buffering:null;0===y.start&&(y.start=p),g&&0===g.start&&(g.start=p);var b=u.audio,w=!1;"audio"===c&&"audio/mpeg"===(null==b?void 0:b.container)&&(w=!this.lastMpegAudioChunk||1===d.id||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);var k=l.start,S={execute:function(){if(m.executeStart=self.performance.now(),w){var t=r.sourceBuffer[c];if(t){var i=k-t.timestampOffset;Math.abs(i)>=.1&&(s.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+k+" (delta: "+i+") sn: "+l.sn+")"),t.timestampOffset=k)}}r.appendExecutor(f,c)},onStart:function(){},onComplete:function(){var t=self.performance.now();m.executeEnd=m.end=t,0===y.first&&(y.first=t),g&&0===g.first&&(g.first=t);var i=r.sourceBuffer,n={};for(var s in i)n[s]=o.BufferHelper.getBuffered(i[s]);r.appendError=0,r.hls.trigger(e.Events.BUFFER_APPENDED,{type:c,frag:l,part:v,chunkMeta:d,parent:l.type,timeRanges:n})},onError:function(t){s.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",t);var i={type:a.ErrorTypes.MEDIA_ERROR,parent:l.type,details:a.ErrorDetails.BUFFER_APPEND_ERROR,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?i.details=a.ErrorDetails.BUFFER_FULL_ERROR:(r.appendError++,i.details=a.ErrorDetails.BUFFER_APPEND_ERROR,r.appendError>n.config.appendErrorMaxRetry&&(s.logger.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),i.fatal=!0,n.stopLoad())),n.trigger(e.Events.ERROR,i)}};h.append(S,c)},i.onBufferFlushing=function(t,i){var r=this,n=this.operationQueue,a=function(t){return{execute:r.removeExecutor.bind(r,t,i.startOffset,i.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(e.Events.BUFFER_FLUSHED,{type:t})},onError:function(i){s.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",i)}}};i.type?n.append(a(i.type),i.type):this.getSourceBufferTypes().forEach((function(t){n.append(a(t),t)}))},i.onFragParsed=function(t,i){var r=this,n=i.frag,a=i.part,o=[],h=a?a.elementaryStreams:n.elementaryStreams;h[u.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(h[u.ElementaryStreamTypes.AUDIO]&&o.push("audio"),h[u.ElementaryStreamTypes.VIDEO]&&o.push("video")),0===o.length&&s.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers((function(){var t=self.performance.now();n.stats.buffering.end=t,a&&(a.stats.buffering.end=t),r.hls.trigger(e.Events.FRAG_BUFFERED,{frag:n,part:a,stats:a?a.stats:n.stats,id:n.type})}),o)},i.onFragChanged=function(){this.flushBackBuffer()},i.onBufferEos=function(t,i){var r=this;this.getSourceBufferTypes().reduce((function(t,n){var e=r.sourceBuffer[n];return!e||i.type&&i.type!==n||(e.ending=!0,e.ended||(e.ended=!0,s.logger.log("[buffer-controller]: "+n+" sourceBuffer now EOS"))),t&&!(e&&!e.ended)}),!0)&&(s.logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){r.getSourceBufferTypes().forEach((function(t){var i=r.sourceBuffer[t];i&&(i.ending=!1)}));var t=r.mediaSource;t&&"open"===t.readyState?(s.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),t.endOfStream()):t&&s.logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+t.readyState)})))},i.onLevelUpdated=function(t,i){var r=i.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},i.flushBackBuffer=function(){var t=this.hls,i=this.details,r=this.media,a=this.sourceBuffer;if(r&&null!==i){var h=this.getSourceBufferTypes();if(h.length){var u=i.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if((0,n.isFiniteNumber)(u)&&!(u<0)){var f=r.currentTime,c=i.levelTargetDuration,l=Math.max(u,c),v=Math.floor(f/c)*c-l;h.forEach((function(r){var n=a[r];if(n){var h=o.BufferHelper.getBuffered(n);if(h.length>0&&v>h.start(0)){if(t.trigger(e.Events.BACK_BUFFER_REACHED,{bufferEnd:v}),i.live)t.trigger(e.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:v});else if(n.ended&&h.end(h.length-1)-f<2*c)return void s.logger.info("[buffer-controller]: Cannot flush "+r+" back buffer while SourceBuffer is in ended state");t.trigger(e.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:v,type:r})}}}))}}}},i.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,i=this.hls,r=this.mediaSource,e=t.fragments[0].start+t.totalduration,a=this.media.duration,o=(0,n.isFiniteNumber)(r.duration)?r.duration:0;t.live&&i.config.liveDurationInfinity?(s.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(t)):(e>o&&e>a||!(0,n.isFiniteNumber)(a))&&(s.logger.log("[buffer-controller]: Updating Media Source duration to "+e.toFixed(3)),r.duration=e)}},i.updateSeekableRange=function(t){var i=this.mediaSource,r=t.fragments;if(r.length&&t.live&&null!=i&&i.setLiveSeekableRange){var n=Math.max(0,r[0].start),e=Math.max(n,n+t.totalduration);i.setLiveSeekableRange(n,e)}},i.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,i=this.operationQueue,r=this.pendingTracks,n=Object.keys(r).length;if(n&&!t||2===n){this.createSourceBuffers(r),this.pendingTracks={};var s=this.getSourceBufferTypes();if(0===s.length)return void this.hls.trigger(e.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});s.forEach((function(t){i.executeNext(t)}))}},i.createSourceBuffers=function(t){var i=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var n=0;for(var o in t)if(!i[o]){var h=t[o];if(!h)throw Error("source buffer exists for track "+o+", however track does not");var u=h.levelCodec||h.codec,f=h.container+";codecs="+u;s.logger.log("[buffer-controller]: creating sourceBuffer("+f+")");try{var c=i[o]=r.addSourceBuffer(f),l=o;this.addBufferListener(l,"updatestart",this._onSBUpdateStart),this.addBufferListener(l,"updateend",this._onSBUpdateEnd),this.addBufferListener(l,"error",this._onSBUpdateError),this.tracks[o]={buffer:c,codec:u,container:h.container,levelCodec:h.levelCodec,metadata:h.metadata,id:h.id},n++}catch(t){s.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(e.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:f})}}n&&this.hls.trigger(e.Events.BUFFER_CREATED,{tracks:this.tracks})},i._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},i._onSBUpdateEnd=function(t){var i=this.operationQueue;i.current(t).onComplete(),i.shiftAndExecuteNext(t)},i._onSBUpdateError=function(t,i){s.logger.error("[buffer-controller]: "+t+" SourceBuffer error",i),this.hls.trigger(e.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var r=this.operationQueue.current(t);r&&r.onError(i)},i.removeExecutor=function(t,i,r){var e=this.media,a=this.mediaSource,o=this.operationQueue,h=this.sourceBuffer[t];if(!e||!a||!h)return s.logger.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(t);var u=(0,n.isFiniteNumber)(e.duration)?e.duration:1/0,f=(0,n.isFiniteNumber)(a.duration)?a.duration:1/0,c=Math.max(0,i),l=Math.min(r,u,f);l>c&&!h.ending?(h.ended=!1,s.logger.log("[buffer-controller]: Removing ["+c+","+l+"] from the "+t+" SourceBuffer"),console.assert(!h.updating,t+" sourceBuffer must not be updating"),h.remove(c,l)):o.shiftAndExecuteNext(t)},i.appendExecutor=function(t,i){var r=this.operationQueue,n=this.sourceBuffer[i];if(!n)return s.logger.warn("[buffer-controller]: Attempting to append to the "+i+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(i);n.ended=!1,console.assert(!n.updating,i+" sourceBuffer must not be updating"),n.appendBuffer(t)},i.blockBuffers=function(t,i){var r=this;if(void 0===i&&(i=this.getSourceBufferTypes()),!i.length)return s.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(t);var n=this.operationQueue,e=i.map((function(t){return n.appendBlocker(t)}));Promise.all(e).then((function(){t(),i.forEach((function(t){var i=r.sourceBuffer[t];i&&i.updating||n.shiftAndExecuteNext(t)}))}))},i.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},i.addBufferListener=function(t,i,r){var n=this.sourceBuffer[t];if(n){var e=r.bind(this,t);this.listeners[t].push({event:i,listener:e}),n.addEventListener(i,e)}},i.removeBufferListeners=function(t){var i=this.sourceBuffer[t];i&&this.listeners[t].forEach((function(t){i.removeEventListener(t.event,t.listener)}))},t}()},"./src/controller/buffer-operation-queue.ts":
|
|
23
|
-
/*!**************************************************!*\
|
|
24
|
-
!*** ./src/controller/buffer-operation-queue.ts ***!
|
|
25
|
-
\**************************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>e});var n=r(/*! ../utils/logger */"./src/utils/logger.ts"),e=function(){function t(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var i=t.prototype;return i.append=function(t,i){var r=this.queues[i];r.push(t),1===r.length&&this.buffers[i]&&this.executeNext(i)},i.insertAbort=function(t,i){this.queues[i].unshift(t),this.executeNext(i)},i.appendBlocker=function(t){var i,r=new Promise((function(t){i=t}));return this.append({execute:i,onStart:function(){},onComplete:function(){},onError:function(){}},t),r},i.executeNext=function(t){var i=this.buffers[t],r=this.queues[t];if(r.length){var e=r[0];try{e.execute()}catch(s){n.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),e.onError(s),i&&i.updating||(r.shift(),this.executeNext(t))}}},i.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},i.current=function(t){return this.queues[t][0]},t}()},"./src/controller/cap-level-controller.ts":
|
|
26
|
-
/*!************************************************!*\
|
|
27
|
-
!*** ./src/controller/cap-level-controller.ts ***!
|
|
28
|
-
\************************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>a});var n=r(/*! ../events */"./src/events.ts");function e(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}var s=function(){function t(t){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var i,r,s=t.prototype;return s.setStreamController=function(t){this.streamController=t},s.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var t=this.hls;t.on(n.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var t=this.hls;t.off(n.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(i,r){t.isLevelAllowed(r.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(r.droppedLevel)},s.onMediaAttaching=function(t,i){this.media=i.media instanceof HTMLVideoElement?i.media:null,this.clientRect=null},s.onManifestParsed=function(t,i){var r=this.hls;this.restrictedLevels=[],this.firstLevel=i.firstLevel,r.config.capLevelToPlayerSize&&i.video&&this.startCapping()},s.onBufferCodecs=function(t,i){this.hls.config.capLevelToPlayerSize&&i.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping()},s.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var t=this.hls.levels;if(t.length){var i=this.hls;i.autoLevelCapping=this.getMaxLevel(t.length-1),i.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=i.autoLevelCapping}}},s.getMaxLevel=function(i){var r=this,n=this.hls.levels;if(!n.length)return-1;var e=n.filter((function(n,e){return t.isLevelAllowed(e,r.restrictedLevels)&&e<=i}));return this.clientRect=null,t.getMaxLevelByMediaSize(e,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},s.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,i={width:0,height:0};if(t){var r=t.getBoundingClientRect();i.width=r.width,i.height=r.height,i.width||i.height||(i.width=r.right-r.left||t.width||0,i.height=r.bottom-r.top||t.height||0)}return this.clientRect=i,i},t.isLevelAllowed=function(t,i){return void 0===i&&(i=[]),-1===i.indexOf(t)},t.getMaxLevelByMediaSize=function(t,i,r){if(!t||!t.length)return-1;for(var n,e,s=t.length-1,a=0;a<t.length;a+=1){var o=t[a];if((o.width>=i||o.height>=r)&&(n=o,!(e=t[a+1])||n.width!==e.width||n.height!==e.height)){s=a;break}}return s},i=t,(r=[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(t){}return t}}])&&e(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),t}();const a=s},"./src/controller/cmcd-controller.ts":
|
|
29
|
-
/*!*******************************************!*\
|
|
30
|
-
!*** ./src/controller/cmcd-controller.ts ***!
|
|
31
|
-
\*******************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>l});var n=r(/*! ../events */"./src/events.ts"),e=r(/*! ../types/cmcd */"./src/types/cmcd.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts");function o(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}function h(t,i,r){return i&&o(t.prototype,i),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(t,i){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,i){if(t){if("string"==typeof t)return f(t,i);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(t,i){(null==i||i>t.length)&&(i=t.length);for(var r=0,n=new Array(i);r<i;r++)n[r]=t[r];return n}function c(){return c=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},c.apply(this,arguments)}var l=function(){function t(i){var r=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(t){try{r.apply(t,{ot:e.CMCDObjectType.MANIFEST,su:!r.initialized})}catch(t){a.logger.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=function(t){try{var i=t.frag,n=r.hls.levels[i.level],s=r.getObjectType(i),o={d:1e3*i.duration,ot:s};s!==e.CMCDObjectType.VIDEO&&s!==e.CMCDObjectType.AUDIO&&s!=e.CMCDObjectType.MUXED||(o.br=n.bitrate/1e3,o.tb=r.getTopBandwidth(s)/1e3,o.bl=r.getBufferLength(s)),r.apply(t,o)}catch(t){a.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=i;var n=this.config=i.config,s=n.cmcd;null!=s&&(n.pLoader=this.createPlaylistLoader(),n.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||t.uuid(),this.cid=s.contentId,this.useHeaders=!0===s.useHeaders,this.registerListeners())}var i=t.prototype;return i.registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.on(n.Events.BUFFER_CREATED,this.onBufferCreated,this)},i.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.off(n.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},i.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},i.onMediaAttached=function(t,i){this.media=i.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},i.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},i.onBufferCreated=function(t,i){var r,n;this.audioBuffer=null===(r=i.tracks.audio)||void 0===r?void 0:r.buffer,this.videoBuffer=null===(n=i.tracks.video)||void 0===n?void 0:n.buffer},i.createData=function(){var t;return{v:e.CMCDVersion,sf:e.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:null===(t=this.media)||void 0===t?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},i.apply=function(i,r){if(void 0===r&&(r={}),c(r,this.createData()),this.starved&&(r.ot===e.CMCDObjectType.INIT||r.ot===e.CMCDObjectType.VIDEO||r.ot===e.CMCDObjectType.MUXED)&&(r.bs=!0,r.su=!0,this.starved=!1),null==r.su&&(r.su=this.buffering),this.useHeaders){var n=t.toHeaders(r);if(!Object.keys(n).length)return;i.headers||(i.headers={}),c(i.headers,n)}else{var s=t.toQuery(r);if(!s)return;i.url=t.appendQueryToUri(i.url,s)}},i.getObjectType=function(t){var i=t.type;return"subtitle"===i?e.CMCDObjectType.TIMED_TEXT:"initSegment"===t.sn?e.CMCDObjectType.INIT:"audio"===i?e.CMCDObjectType.AUDIO:"main"===i?this.hls.audioTracks.length?e.CMCDObjectType.VIDEO:e.CMCDObjectType.MUXED:void 0},i.getTopBandwidth=function(t){var i,r=0,n=this.hls;if(t===e.CMCDObjectType.AUDIO)i=n.audioTracks;else{var s=n.maxAutoLevel;i=n.levels.slice(0,s>-1?s+1:n.levels.length)}for(var a,o=u(i);!(a=o()).done;){var h=a.value;h.bitrate>r&&(r=h.bitrate)}return r>0?r:NaN},i.getBufferLength=function(t){var i=this.hls.media,r=t===e.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;return r&&i?1e3*s.BufferHelper.bufferInfo(r,i.currentTime,this.config.maxBufferHole).len:NaN},i.createPlaylistLoader=function(){var t=this.applyPlaylistData,i=this.config.pLoader||this.config.loader;return function(){function r(t){this.loader=void 0,this.loader=new i(t)}var n=r.prototype;return n.destroy=function(){this.loader.destroy()},n.abort=function(){this.loader.abort()},n.load=function(i,r,n){t(i),this.loader.load(i,r,n)},h(r,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),r}()},i.createFragmentLoader=function(){var t=this.applyFragmentData,i=this.config.fLoader||this.config.loader;return function(){function r(t){this.loader=void 0,this.loader=new i(t)}var n=r.prototype;return n.destroy=function(){this.loader.destroy()},n.abort=function(){this.loader.abort()},n.load=function(i,r,n){t(i),this.loader.load(i,r,n)},h(r,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),r}()},t.uuid=function(){var t=URL.createObjectURL(new Blob),i=t.toString();return URL.revokeObjectURL(t),i.slice(i.lastIndexOf("/")+1)},t.serialize=function(t){for(var i,r=[],n=function(t){return!Number.isNaN(t)&&null!=t&&""!==t&&!1!==t},e=function(t){return Math.round(t)},s=function(t){return 100*e(t/100)},a={br:e,d:e,bl:s,dl:s,mtp:s,nor:function(t){return encodeURIComponent(t)},rtp:s,tb:e},o=u(Object.keys(t||{}).sort());!(i=o()).done;){var h=i.value,f=t[h];if(n(f)&&!("v"===h&&1===f||"pr"==h&&1===f)){var c=a[h];c&&(f=c(f));var l,v=typeof f;l="ot"===h||"sf"===h||"st"===h?h+"="+f:"boolean"===v?h:"number"===v?h+"="+f:h+"="+JSON.stringify(f),r.push(l)}}return r.join(",")},t.toHeaders=function(i){for(var r={},n=["Object","Request","Session","Status"],e=[{},{},{},{}],s={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},a=0,o=Object.keys(i);a<o.length;a++){var h=o[a];e[null!=s[h]?s[h]:1][h]=i[h]}for(var u=0;u<e.length;u++){var f=t.serialize(e[u]);f&&(r["CMCD-"+n[u]]=f)}return r},t.toQuery=function(i){return"CMCD="+encodeURIComponent(t.serialize(i))},t.appendQueryToUri=function(t,i){if(!i)return t;var r=t.includes("?")?"&":"?";return""+t+r+i},t}()},"./src/controller/eme-controller.ts":
|
|
32
|
-
/*!******************************************!*\
|
|
33
|
-
!*** ./src/controller/eme-controller.ts ***!
|
|
34
|
-
\******************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>S});var n=r(/*! ../events */"./src/events.ts"),e=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),o=r(/*! ../utils/keysystem-util */"./src/utils/keysystem-util.ts"),h=r(/*! ../utils/numeric-encoding-utils */"./src/utils/numeric-encoding-utils.ts"),u=r(/*! ../loader/level-key */"./src/loader/level-key.ts"),f=r(/*! ../utils/hex */"./src/utils/hex.ts"),c=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),v=r.n(l);function d(t){var i="function"==typeof Map?new Map:void 0;return d=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,r)}function r(){return m(t,arguments,g(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),y(r,t)},d(t)}function m(t,i,r){return m=p()?Reflect.construct.bind():function(t,i,r){var n=[null];n.push.apply(n,i);var e=new(Function.bind.apply(t,n));return r&&y(e,r.prototype),e},m.apply(null,arguments)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function y(t,i){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},y(t,i)}function g(t){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},g(t)}var b="[eme]",w=function(){function t(i){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=t.CDMCleanupPromise?[t.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=s.logger.debug.bind(s.logger,b),this.log=s.logger.log.bind(s.logger,b),this.warn=s.logger.warn.bind(s.logger,b),this.error=s.logger.error.bind(s.logger,b),this.hls=i,this.config=i.config,this.registerListeners()}var i=t.prototype;return i.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null},i.registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},i.unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},i.getLicenseServerUrl=function(t){var i=this.config,r=i.widevineLicenseUrl,n=i.drmSystems[t];if(n)return n.licenseUrl;if(t===a.KeySystems.WIDEVINE&&r)return r;throw new Error('no license server URL configured for key-system "'+t+'"')},i.getServerCertificateUrl=function(t){var i=this.config.drmSystems[t];if(i)return i.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+t+'"]')},i.attemptKeySystemAccess=function(t){var i=this,r=this.hls.levels,n=function(t,i,r){return!!t&&r.indexOf(t)===i},s=r.map((function(t){return t.audioCodec})).filter(n),a=r.map((function(t){return t.videoCodec})).filter(n);return s.length+a.length===0&&a.push("avc1.42e01e"),new Promise((function(r,n){!function t(o){var h=o.shift();i.getMediaKeysPromise(h,s,a).then((function(t){return r({keySystem:h,mediaKeys:t})})).catch((function(i){o.length?t(o):n(i instanceof k?i:new k({type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:i,fatal:!0},i.message))}))}(t)}))},i.requestMediaKeySystemAccess=function(t,i){var r=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof r){var n="Configured requestMediaKeySystemAccess is not a function "+r;return null===a.requestMediaKeySystemAccess&&"http:"===self.location.protocol&&(n="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(n))}return r(t,i)},i.getMediaKeysPromise=function(t,i,r){var n=this,e=(0,a.getSupportedMediaKeySystemConfigurations)(t,i,r,this.config.drmSystemOptions),s=this.keySystemAccessPromises[t],o=null==s?void 0:s.keySystemAccess;if(!o){this.log('Requesting encrypted media "'+t+'" key-system access with config: '+JSON.stringify(e)),o=this.requestMediaKeySystemAccess(t,e);var h=this.keySystemAccessPromises[t]={keySystemAccess:o};return o.catch((function(i){n.log('Failed to obtain access to key-system "'+t+'": '+i)})),o.then((function(i){n.log('Access for key-system "'+i.keySystem+'" obtained');var r=n.fetchServerCertificate(t);return n.log('Create media-keys for "'+t+'"'),h.mediaKeys=i.createMediaKeys().then((function(i){return n.log('Media-keys created for "'+t+'"'),r.then((function(r){return r?n.setMediaKeysServerCertificate(i,t,r):i}))})),h.mediaKeys.catch((function(i){n.error('Failed to create media-keys for "'+t+'"}: '+i)})),h.mediaKeys}))}return o.then((function(){return s.mediaKeys}))},i.createMediaKeySessionContext=function(t){var i=t.decryptdata,r=t.keySystem,n=t.mediaKeys;console.assert(!!n,"mediaKeys is defined"),this.log('Creating key-system session "'+r+'" keyId: '+f.default.hexDump(i.keyId||[]));var e=n.createSession(),s={decryptdata:i,keySystem:r,mediaKeys:n,mediaKeysSession:e,keyStatus:"status-pending"};return this.mediaKeySessions.push(s),s},i.renewKeySession=function(t){var i=t.decryptdata;if(i.pssh){var r=this.createMediaKeySessionContext(t),n=this.getKeyIdString(i);this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(r,"cenc",i.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)},i.getKeyIdString=function(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(null===t.keyId)throw new Error("keyId is null");return f.default.hexDump(t.keyId)},i.updateKeySession=function(t,i){var r,n=t.mediaKeysSession;return this.log('Updating key-session "'+n.sessionId+'" for keyID '+f.default.hexDump((null===(r=t.decryptdata)||void 0===r?void 0:r.keyId)||[])+"\n } (data length: "+(i?i.byteLength:i)+")"),n.update(i)},i.selectKeySystemFormat=function(t){var i=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+t.sn+" "+t.type+": "+t.level+") key formats "+i.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(i)),this.keyFormatPromise},i.getKeyFormatPromise=function(t){var i=this;return new Promise((function(r,n){var e=(0,a.getKeySystemsForConfig)(i.config),s=t.map(a.keySystemFormatToKeySystemDomain).filter((function(t){return!!t&&-1!==e.indexOf(t)}));return i.getKeySystemSelectionPromise(s).then((function(t){var i=t.keySystem,e=(0,a.keySystemDomainToKeySystemFormat)(i);e?r(e):n(new Error('Unable to find format for key-system "'+i+'"'))})).catch(n)}))},i.loadKey=function(t){var i=this,r=t.keyInfo.decryptdata,n=this.getKeyIdString(r),e="(keyId: "+n+' format: "'+r.keyFormat+'" method: '+r.method+" uri: "+r.uri+")";this.log("Starting session for key "+e);var s=this.keyIdToKeySessionPromise[n];return s||(s=this.keyIdToKeySessionPromise[n]=this.getKeySystemForKeyPromise(r).then((function(n){var s=n.keySystem,a=n.mediaKeys;return i.throwIfDestroyed(),i.log("Handle encrypted media sn: "+t.frag.sn+" "+t.frag.type+": "+t.frag.level+" using key "+e),i.attemptSetMediaKeys(s,a).then((function(){i.throwIfDestroyed();var t=i.createMediaKeySessionContext({keySystem:s,mediaKeys:a,decryptdata:r});return i.generateRequestWithPreferredKeySession(t,"cenc",r.pssh,"playlist-key")}))}))).catch((function(t){return i.handleError(t)})),s},i.throwIfDestroyed=function(){if(!this.hls)throw new Error("invalid state")},i.handleError=function(t){this.hls&&(this.error(t.message),this.hls.trigger(n.Events.ERROR,t instanceof k?t.data:{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))},i.getKeySystemForKeyPromise=function(t){var i=this.getKeyIdString(t),r=this.keyIdToKeySessionPromise[i];if(!r){var n=(0,a.keySystemFormatToKeySystemDomain)(t.keyFormat),e=n?[n]:(0,a.getKeySystemsForConfig)(this.config);return this.attemptKeySystemAccess(e)}return r},i.getKeySystemSelectionPromise=function(t){if(t.length||(t=(0,a.getKeySystemsForConfig)(this.config)),0===t.length)throw new k({type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(t)},i._onMediaEncrypted=function(t){var i=this,r=t.initDataType,n=t.initData;if(this.debug('"'+t.type+'" event: init data type: "'+r+'"'),null!==n){var e,s;if("sinf"===r&&this.config.drmSystems[a.KeySystems.FAIRPLAY]){var o=(0,c.bin2str)(new Uint8Array(n));try{var l=(0,h.base64Decode)(JSON.parse(o).sinf),v=(0,c.parseSinf)(new Uint8Array(l));if(!v)return;e=v.subarray(8,24),s=a.KeySystems.FAIRPLAY}catch(t){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var d=(0,c.parsePssh)(n);if(null===d)return;0===d.version&&d.systemId===a.KeySystemIds.WIDEVINE&&d.data&&(e=d.data.subarray(8,24)),s=(0,a.keySystemIdToKeySystemDomain)(d.systemId)}if(s&&e){for(var m=f.default.hexDump(e),p=this.keyIdToKeySessionPromise,y=this.mediaKeySessions,g=p[m],b=function(t){var s=y[t],a=s.decryptdata;if(a.pssh||!a.keyId)return"continue";var o=f.default.hexDump(a.keyId);return m===o||-1!==a.uri.replace(/-/g,"").indexOf(m)?(g=p[o],delete p[o],a.pssh=new Uint8Array(n),a.keyId=e,g=p[m]=g.then((function(){return i.generateRequestWithPreferredKeySession(s,r,n,"encrypted-event-key-match")})),"break"):void 0},w=0;w<y.length;w++){var k=b(w);if("continue"!==k&&"break"===k)break}g||(g=p[m]=this.getKeySystemSelectionPromise([s]).then((function(t){var s,o=t.keySystem,h=t.mediaKeys;i.throwIfDestroyed();var f=new u.LevelKey("ISO-23001-7",m,null!=(s=(0,a.keySystemDomainToKeySystemFormat)(o))?s:"");return f.pssh=new Uint8Array(n),f.keyId=e,i.attemptSetMediaKeys(o,h).then((function(){i.throwIfDestroyed();var t=i.createMediaKeySessionContext({decryptdata:f,keySystem:o,mediaKeys:h});return i.generateRequestWithPreferredKeySession(t,r,n,"encrypted-event-no-match")}))}))),g.catch((function(t){return i.handleError(t)}))}}},i._onWaitingForKey=function(t){this.log('"'+t.type+'" event')},i.attemptSetMediaKeys=function(t,i){var r=this,n=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+t+'"');var e=Promise.all(n).then((function(){if(!r.media)throw new Error("Attempted to set mediaKeys without media element attached");return r.media.setMediaKeys(i)}));return this.setMediaKeysQueue.push(e),e.then((function(){r.log('Media-keys set for "'+t+'"'),n.push(e),r.setMediaKeysQueue=r.setMediaKeysQueue.filter((function(t){return-1===n.indexOf(t)}))}))},i.generateRequestWithPreferredKeySession=function(t,i,r,n){var s,h,u=this,f=null===(s=this.config.drmSystems)||void 0===s||null===(h=s[t.keySystem])||void 0===h?void 0:h.generateRequest;if(f)try{var c=f.call(this.hls,i,r,t);if(!c)throw new Error("Invalid response from configured generateRequest filter");i=c.initDataType,r=t.decryptdata.pssh=c.initData?new Uint8Array(c.initData):null}catch(t){var l;if(this.warn(t.message),null!==(l=this.hls)&&void 0!==l&&l.config.debug)throw t}if(null===r)return this.log('Skipping key-session request for "'+n+'" (no initData)'),Promise.resolve(t);var d=this.getKeyIdString(t.decryptdata);this.log('Generating key-session request for "'+n+'": '+d+" (init data type: "+i+" length: "+(r?r.byteLength:null)+")");var m=new(v());t.mediaKeysSession.onmessage=function(i){var r=t.mediaKeysSession;if(r){var n=i.messageType,e=i.message;u.log('"'+n+'" message event for session "'+r.sessionId+'" message size: '+e.byteLength),"license-request"===n||"license-renewal"===n?u.renewLicense(t,e).catch((function(t){u.handleError(t),m.emit("error",t)})):"license-release"===n?t.keySystem===a.KeySystems.FAIRPLAY&&(u.updateKeySession(t,(0,o.strToUtf8array)("acknowledged")),u.removeSession(t)):u.warn('unhandled media key message type "'+n+'"')}else m.emit("error",new Error("invalid state"))},t.mediaKeysSession.onkeystatuseschange=function(){if(t.mediaKeysSession){u.onKeyStatusChange(t);var i=t.keyStatus;m.emit("keyStatus",i),"expired"===i&&(u.warn(t.keySystem+" expired for key "+d),u.renewKeySession(t))}else m.emit("error",new Error("invalid state"))};var p=new Promise((function(t,i){m.on("error",i),m.on("keyStatus",(function(r){r.startsWith("usable")?t():"output-restricted"===r?i(new k({type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?i(new k({type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+r+'"')):"expired"===r?i(new Error("key expired while generating request")):u.warn('unhandled key status change "'+r+'"')}))}));return t.mediaKeysSession.generateRequest(i,r).then((function(){var i;u.log('Request generated for key-session "'+(null===(i=t.mediaKeysSession)||void 0===i?void 0:i.sessionId)+'" keyId: '+d)})).catch((function(t){throw new k({type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_SESSION,error:t,fatal:!1},"Error generating key-session request: "+t)})).then((function(){return p})).catch((function(i){throw m.removeAllListeners(),u.removeSession(t),i})).then((function(){return m.removeAllListeners(),t}))},i.onKeyStatusChange=function(t){var i=this;t.mediaKeysSession.keyStatuses.forEach((function(r,n){i.log('key status change "'+r+'" for keyStatuses keyId: '+f.default.hexDump("buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n))+" session keyId: "+f.default.hexDump(new Uint8Array(t.decryptdata.keyId||[]))+" uri: "+t.decryptdata.uri),t.keyStatus=r}))},i.fetchServerCertificate=function(t){var i=this;return new Promise((function(r,n){var s=i.getServerCertificateUrl(t);if(!s)return r();i.log('Fetching serverCertificate for "'+t+'"');var a=new XMLHttpRequest;a.open("GET",s,!0),a.responseType="arraybuffer",a.onreadystatechange=function(){a.readyState===XMLHttpRequest.DONE&&(200===a.status?r(a.response):n(new k({type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a},'"'+t+'" certificate request XHR failed ('+s+"). Status: "+a.status+" ("+a.statusText+")")))},a.send()}))},i.setMediaKeysServerCertificate=function(t,i,r){var n=this;return new Promise((function(s,a){t.setServerCertificate(r).then((function(e){n.log("setServerCertificate "+(e?"success":"not supported by CDM")+" ("+(null==r?void 0:r.byteLength)+') on "'+i+'"'),s(t)})).catch((function(t){a(new k({type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:t,fatal:!0},t.message))}))}))},i.renewLicense=function(t,i){var r=this;return this.requestLicense(t,new Uint8Array(i)).then((function(i){return r.updateKeySession(t,new Uint8Array(i)).catch((function(t){throw new k({type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:t,fatal:!0},t.message)}))}))},i.setupLicenseXHR=function(t,i,r,n){var e=this,s=this.config.licenseXhrSetup;return s?Promise.resolve().then((function(){if(!r.decryptdata)throw new Error("Key removed");return s.call(e.hls,t,i,r,n)})).catch((function(a){if(!r.decryptdata)throw a;return t.open("POST",i,!0),s.call(e.hls,t,i,r,n)})).then((function(r){return t.readyState||t.open("POST",i,!0),{xhr:t,licenseChallenge:r||n}})):(t.open("POST",i,!0),Promise.resolve({xhr:t,licenseChallenge:n}))},i.requestLicense=function(t,i){var r=this;return new Promise((function(n,s){var a=r.getLicenseServerUrl(t.keySystem);r.log("Sending license request to URL: "+a);var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=function(){if(!r.hls||!t.mediaKeysSession)return s(new Error("invalid state"));if(4===o.readyState)if(200===o.status){r._requestLicenseFailureCount=0;var h=o.response;r.log("License received "+(h instanceof ArrayBuffer?h.byteLength:h));var u=r.config.licenseResponseCallback;if(u)try{h=u.call(r.hls,o,a,t)}catch(t){r.error(t)}n(h)}else r._requestLicenseFailureCount++,r._requestLicenseFailureCount>3||o.status>=400&&o.status<500?s(new k({type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o},"License Request XHR failed ("+a+"). Status: "+o.status+" ("+o.statusText+")")):(r.warn("Retrying license request, "+(3-r._requestLicenseFailureCount+1)+" attempts left"),r.requestLicense(t,i).then(n,s))},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=o,r.setupLicenseXHR(o,a,t,i).then((function(t){t.xhr.send(t.licenseChallenge)}))}))},i.onMediaAttached=function(t,i){if(this.config.emeEnabled){var r=i.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}},i.onMediaDetached=function(){var i=this,r=this.media,n=this.mediaKeySessions;r&&(r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},u.LevelKey.clearKeyUriToKeyIdMap();var e=n.length;t.CDMCleanupPromise=Promise.all(n.map((function(t){return i.removeSession(t)})).concat(null==r?void 0:r.setMediaKeys(null).catch((function(t){i.log("Could not clear media keys: "+t+". media.src: "+(null==r?void 0:r.src))})))).then((function(){e&&(i.log("finished closing key sessions and clearing media keys"),n.length=0)})).catch((function(t){i.log("Could not close sessions and clear media keys: "+t+". media.src: "+(null==r?void 0:r.src))}))},i.onManifestLoaded=function(t,i){var r=i.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var n=r.reduce((function(t,i){return-1===t.indexOf(i.keyFormat)&&t.push(i.keyFormat),t}),[]);this.log("Selecting key-system from session-keys "+n.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(n)}},i.removeSession=function(t){var i=this,r=t.mediaKeysSession,n=t.licenseXhr;if(r){this.log("Remove licenses and keys and close session "+r.sessionId),r.onmessage=null,r.onkeystatuseschange=null,n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;var e=this.mediaKeySessions.indexOf(t);return e>-1&&this.mediaKeySessions.splice(e,1),r.remove().catch((function(t){i.log("Could not remove session: "+t)})).then((function(){return r.close()})).catch((function(t){i.log("Could not close session: "+t)}))}},t}();w.CDMCleanupPromise=void 0;var k=function(t){var i,r;function n(i,r){var n;return(n=t.call(this,r)||this).data=void 0,n.data=i,i.err=i.error,n}return r=t,(i=n).prototype=Object.create(r.prototype),i.prototype.constructor=i,y(i,r),n}(d(Error));const S=w},"./src/controller/fps-controller.ts":
|
|
35
|
-
/*!******************************************!*\
|
|
36
|
-
!*** ./src/controller/fps-controller.ts ***!
|
|
37
|
-
\******************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>a});var n=r(/*! ../events */"./src/events.ts"),e=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=function(){function t(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}var i=t.prototype;return i.setStreamController=function(t){this.streamController=t},i.registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},i.unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching)},i.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},i.onMediaAttaching=function(t,i){var r=this.hls.config;if(r.capLevelOnFPSDrop){var n=i.media instanceof self.HTMLVideoElement?i.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},i.checkFPS=function(t,i,r){var s=performance.now();if(i){if(this.lastTime){var a=r-this.lastDroppedFrames,o=i-this.lastDecodedFrames,h=1e3*a/(s-this.lastTime),u=this.hls;if(u.trigger(n.Events.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),h>0&&a>u.config.fpsDroppedMonitoringThreshold*o){var f=u.currentLevel;e.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+f),f>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=f)&&(u.trigger(n.Events.FPS_DROP_LEVEL_CAPPING,{level:f-=1,droppedLevel:u.currentLevel}),u.autoLevelCapping=f,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=i}},i.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var i=t.getVideoPlaybackQuality();this.checkFPS(t,i.totalVideoFrames,i.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},t}();const a=s},"./src/controller/fragment-finders.ts":
|
|
38
|
-
/*!********************************************!*\
|
|
39
|
-
!*** ./src/controller/fragment-finders.ts ***!
|
|
40
|
-
\********************************************/(t,i,r)=>{r.r(i),r.d(i,{findFragWithCC:()=>u,findFragmentByPDT:()=>s,findFragmentByPTS:()=>a,fragmentWithinToleranceTest:()=>o,pdtWithinToleranceTest:()=>h});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function s(t,i,r){if(null===i||!Array.isArray(t)||!t.length||!(0,n.isFiniteNumber)(i))return null;if(i<(t[0].programDateTime||0))return null;if(i>=(t[t.length-1].endProgramDateTime||0))return null;r=r||0;for(var e=0;e<t.length;++e){var s=t[e];if(h(i,r,s))return s}return null}function a(t,i,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var s=null;if(t?s=i[t.sn-i[0].sn+1]||null:0===r&&0===i[0].start&&(s=i[0]),s&&0===o(r,n,s))return s;var a=e.default.search(i,o.bind(null,r,n));return!a||a===t&&s?s:a}function o(t,i,r){if(void 0===t&&(t=0),void 0===i&&(i=0),r.start<=t&&r.start+r.duration>t)return 0;var n=Math.min(i,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-n<=t?1:r.start-n>t&&r.start?-1:0}function h(t,i,r){var n=1e3*Math.min(i,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-n>t}function u(t,i){return e.default.search(t,(function(t){return t.cc<i?1:t.cc>i?-1:0}))}},"./src/controller/fragment-tracker.ts":
|
|
41
|
-
/*!********************************************!*\
|
|
42
|
-
!*** ./src/controller/fragment-tracker.ts ***!
|
|
43
|
-
\********************************************/(t,i,r)=>{r.r(i),r.d(i,{FragmentState:()=>n,FragmentTracker:()=>a});var n,e=r(/*! ../events */"./src/events.ts"),s=r(/*! ../types/loader */"./src/types/loader.ts");!function(t){t.NOT_LOADED="NOT_LOADED",t.APPENDING="APPENDING",t.PARTIAL="PARTIAL",t.OK="OK"}(n||(n={}));var a=function(){function t(t){this.activeFragment=null,this.activeParts=null,this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=t,this._registerListeners()}var i=t.prototype;return i._registerListeners=function(){var t=this.hls;t.on(e.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.on(e.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(e.Events.FRAG_LOADED,this.onFragLoaded,this)},i._unregisterListeners=function(){var t=this.hls;t.off(e.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.off(e.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(e.Events.FRAG_LOADED,this.onFragLoaded,this)},i.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.activeFragment=this.activeParts=null},i.getAppendedFrag=function(t,i){if(i===s.PlaylistLevelType.MAIN){var r=this.activeFragment,n=this.activeParts;if(!r)return null;if(n)for(var e=n.length;e--;){var a=n[e],o=a?a.end:r.appendedPTS;if(a.start<=t&&void 0!==o&&t<=o)return e>9&&(this.activeParts=n.slice(e-9)),a}else if(r.start<=t&&void 0!==r.appendedPTS&&t<=r.appendedPTS)return r}return this.getBufferedFrag(t,i)},i.getBufferedFrag=function(t,i){for(var r=this.fragments,n=Object.keys(r),e=n.length;e--;){var s=r[n[e]];if((null==s?void 0:s.body.type)===i&&s.buffered){var a=s.body;if(a.start<=t&&t<=a.end)return a}}return null},i.detectEvictedFragments=function(t,i,r){var n=this;this.timeRanges&&(this.timeRanges[t]=i),Object.keys(this.fragments).forEach((function(e){var s=n.fragments[e];if(s)if(s.buffered||s.loaded){var a=s.range[t];a&&a.time.some((function(t){var r=!n.isTimeBuffered(t.startPTS,t.endPTS,i);return r&&n.removeFragment(s.body),r}))}else s.body.type===r&&n.removeFragment(s.body)}))},i.detectPartialFragments=function(t){var i=this,r=this.timeRanges,n=t.frag,e=t.part;if(r&&"initSegment"!==n.sn){var s=h(n),a=this.fragments[s];a&&(Object.keys(r).forEach((function(t){var s=n.elementaryStreams[t];s&&(a.range[t]=i.getBufferedTimes(n,e,null!==e||!0===s.partial,r[t]))})),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,a.body.endList&&(this.endListFragments[a.body.type]=a)):this.removeFragment(a.body))}},i.fragBuffered=function(t){var i=h(t),r=this.fragments[i];r&&(r.loaded=null,r.buffered=!0)},i.getBufferedTimes=function(t,i,r,n){for(var e={time:[],partial:r},s=i?i.start:t.start,a=i?i.end:t.end,o=t.minEndPTS||a,h=t.maxStartPTS||s,u=0;u<n.length;u++){var f=n.start(u)-this.bufferPadding,c=n.end(u)+this.bufferPadding;if(h>=f&&o<=c){e.time.push({startPTS:Math.max(s,n.start(u)),endPTS:Math.min(a,n.end(u))});break}if(s<c&&a>f)e.partial=!0,e.time.push({startPTS:Math.max(s,n.start(u)),endPTS:Math.min(a,n.end(u))});else if(a<=f)break}return e},i.getPartialFragment=function(t){var i,r,n,e=null,s=0,a=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach((function(u){var f=h[u];f&&o(f)&&(n=f.body.end+a,t>=(r=f.body.start-a)&&t<=n&&(i=Math.min(t-r,n-t),s<=i&&(e=f.body,s=i)))})),e},i.isEndListAppended=function(t){var i=this.endListFragments[t];return void 0!==i&&(i.buffered||o(i))},i.getState=function(t){var i=h(t),r=this.fragments[i];return r?r.buffered?o(r)?n.PARTIAL:n.OK:n.APPENDING:n.NOT_LOADED},i.isTimeBuffered=function(t,i,r){for(var n,e,s=0;s<r.length;s++){if(n=r.start(s)-this.bufferPadding,e=r.end(s)+this.bufferPadding,t>=n&&i<=e)return!0;if(i<=n)return!1}return!1},i.onFragLoaded=function(t,i){var r=i.frag;if("initSegment"!==r.sn&&!r.bitrateTest&&!i.part){var n=h(r);this.fragments[n]={body:r,loaded:i,buffered:!1,range:Object.create(null)}}},i.onBufferAppended=function(t,i){var r=this,n=i.frag,e=i.part,a=i.timeRanges;if(n.type===s.PlaylistLevelType.MAIN)if(this.activeFragment!==n&&(this.activeFragment=n,n.appendedPTS=void 0),e){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(e)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach((function(t){var i=a[t];if(r.detectEvictedFragments(t,i),!e&&n.type===s.PlaylistLevelType.MAIN){var o=n.elementaryStreams[t];if(!o)return;for(var h=0;h<i.length;h++){var u=i.end(h);n.appendedPTS=u<=o.endPTS&&u>o.startPTS?Math.max(u,n.appendedPTS||0):o.endPTS}}}))},i.onFragBuffered=function(t,i){this.detectPartialFragments(i)},i.hasFragment=function(t){var i=h(t);return!!this.fragments[i]},i.removeFragmentsInRange=function(t,i,r){var n=this;Object.keys(this.fragments).forEach((function(e){var s=n.fragments[e];if(s&&s.buffered){var a=s.body;a.type===r&&a.start<i&&a.end>t&&n.removeFragment(a)}}))},i.removeFragment=function(t){var i=h(t);t.stats.loaded=0,t.clearElementaryStreamInfo(),t.appendedPTS=void 0,delete this.fragments[i],t.endList&&delete this.endListFragments[t.type]},i.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activeFragment=null,this.activeParts=null},t}();function o(t){var i,r;return t.buffered&&((null===(i=t.range.video)||void 0===i?void 0:i.partial)||(null===(r=t.range.audio)||void 0===r?void 0:r.partial))}function h(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}},"./src/controller/gap-controller.ts":
|
|
44
|
-
/*!******************************************!*\
|
|
45
|
-
!*** ./src/controller/gap-controller.ts ***!
|
|
46
|
-
\******************************************/(t,i,r)=>{r.r(i),r.d(i,{MAX_START_GAP_JUMP:()=>h,SKIP_BUFFER_HOLE_STEP_SECONDS:()=>u,SKIP_BUFFER_RANGE_START:()=>f,STALL_MINIMUM_DURATION_MS:()=>o,default:()=>c});var n=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),e=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=250,h=2,u=.1,f=.05,c=function(){function t(t,i,r,n){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=i,this.fragmentTracker=r,this.hls=n}var i=t.prototype;return i.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},i.poll=function(t,i){var r=this.config,e=this.media,s=this.stalled;if(null!==e){var u=e.currentTime,f=e.seeking,c=this.seeking&&!f,l=!this.seeking&&f;if(this.seeking=f,u===t){if((l||c)&&(this.stalled=null),!(e.paused&&!f||e.ended||0===e.playbackRate)&&n.BufferHelper.getBuffered(e).length){var v=n.BufferHelper.bufferInfo(e,u,0),d=v.nextStart||0;if(v.len>0||d){if(f){var m=v.len>h,p=!d||i&&i.start<=u||d-u>h&&!this.fragmentTracker.getPartialFragment(u);if(m||p)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var y,g=Math.max(d,v.start||0)-u,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,w=null==b||null===(y=b.details)||void 0===y?void 0:y.live;if(g>0&&g<=(w?2*b.details.targetduration:h))return void this._trySkipBufferHole(null)}var k=self.performance.now();if(null!==s){var S=k-s;if(f||!(S>=o)||(this._reportStall(v),this.media)){var T=n.BufferHelper.bufferInfo(e,u,r.maxBufferHole);this._tryFixBufferStall(T,S)}}else this.stalled=k}}}else if(this.moved=!0,null!==s){if(this.stallReported){var E=self.performance.now()-s;a.logger.warn("playback not stuck anymore @"+u+", after "+Math.round(E)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},i._tryFixBufferStall=function(t,i){var r=this.config,n=this.media;if(null!==n){var e=this.fragmentTracker.getPartialFragment(n.currentTime);if(e&&(this._trySkipBufferHole(e)||!this.media))return;t.len>r.maxBufferHole&&i>1e3*r.highBufferWatchdogPeriod&&(a.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},i._reportStall=function(t){var i=this.hls,r=this.media;!this.stallReported&&r&&(this.stallReported=!0,a.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(t)+")"),i.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:t.len}))},i._trySkipBufferHole=function(t){var i=this.config,r=this.hls,o=this.media;if(null===o)return 0;for(var h=o.currentTime,c=0,l=n.BufferHelper.getBuffered(o),v=0;v<l.length;v++){var d=l.start(v);if(h+i.maxBufferHole>=c&&h<d){var m=Math.max(d+f,o.currentTime+u);return a.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+m),this.moved=!0,this.stalled=null,o.currentTime=m,t&&r.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+m,frag:t}),m}c=l.end(v)}return 0},i._tryNudgeBuffer=function(){var t=this.config,i=this.hls,r=this.media,n=this.nudgeRetry;if(null!==r){var o=r.currentTime;if(this.nudgeRetry++,n<t.nudgeMaxRetry){var h=o+(n+1)*t.nudgeOffset;a.logger.warn("Nudging 'currentTime' from "+o+" to "+h),r.currentTime=h,i.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else a.logger.error("Playhead still not moving while enough data buffered @"+o+" after "+t.nudgeMaxRetry+" nudges"),i.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},t}()},"./src/controller/id3-track-controller.ts":
|
|
47
|
-
/*!************************************************!*\
|
|
48
|
-
!*** ./src/controller/id3-track-controller.ts ***!
|
|
49
|
-
\************************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>v});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ../loader/date-range */"./src/loader/date-range.ts"),h=r(/*! ../types/demuxer */"./src/types/demuxer.ts");function u(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var f=function(){var t=u();try{new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function c(t,i){return t.getTime()/1e3-i}var l=function(){function t(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}var i=t.prototype;return i.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},i._registerListeners=function(){var t=this.hls;t.on(e.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(e.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(e.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},i._unregisterListeners=function(){var t=this.hls;t.off(e.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(e.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(e.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},i.onMediaAttached=function(t,i){this.media=i.media},i.onMediaDetaching=function(){this.id3Track&&((0,s.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},i.onManifestLoading=function(){this.dateRangeCuesAppended={}},i.createTrack=function(t){var i=this.getID3Track(t.textTracks);return i.mode="hidden",i},i.getID3Track=function(t){if(this.media){for(var i=0;i<t.length;i++){var r=t[i];if("metadata"===r.kind&&"id3"===r.label)return(0,s.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},i.onFragParsingMetadata=function(t,i){if(this.media){var r=this.hls.config,n=r.enableEmsgMetadataCues,e=r.enableID3MetadataCues;if(n||e){var s=i.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var o=u(),c=0;c<s.length;c++){var l=s[c].type;if((l!==h.MetadataSchema.emsg||n)&&e){var v=a.getID3Frames(s[c].data);if(v){var d=s[c].pts,m=d+s[c].duration;m>f&&(m=f),m-d<=0&&(m=d+.25);for(var p=0;p<v.length;p++){var y=v[p];if(!a.isTimeStampFrame(y)){this.updateId3CueEnds(d);var g=new o(d,m,"");g.value=y,l&&(g.type=l),this.id3Track.addCue(g)}}}}}}}},i.updateId3CueEnds=function(t){var i,r=null===(i=this.id3Track)||void 0===i?void 0:i.cues;if(r)for(var n=r.length;n--;){var e=r[n];e.startTime<t&&e.endTime===f&&(e.endTime=t)}},i.onBufferFlushing=function(t,i){var r=i.type,n=this.id3Track,e=this.hls;if(e){var a=e.config,o=a.enableEmsgMetadataCues,u=a.enableID3MetadataCues;n&&(o||u)&&(0,s.removeCuesInRange)(n,i.startOffset,i.endOffset,"audio"===r?function(t){return t.type===h.MetadataSchema.audioId3&&u}:"video"===r?function(t){return t.type===h.MetadataSchema.emsg&&o}:function(t){return t.type===h.MetadataSchema.audioId3&&u||t.type===h.MetadataSchema.emsg&&o})}},i.onLevelUpdated=function(t,i){var r=this,e=i.details;if(this.media&&e.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var s=this.dateRangeCuesAppended,a=this.id3Track,l=e.dateRanges,v=Object.keys(l);if(a)for(var d=Object.keys(s).filter((function(t){return!v.includes(t)})),m=function(t){var i=d[t];Object.keys(s[i].cues).forEach((function(t){a.removeCue(s[i].cues[t])})),delete s[i]},p=d.length;p--;)m(p);var y=e.fragments[e.fragments.length-1];if(0!==v.length&&(0,n.isFiniteNumber)(null==y?void 0:y.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var g=y.programDateTime/1e3-y.start,b=u(),w=function(t){var i=v[t],n=l[i],e=s[i],a=(null==e?void 0:e.cues)||{},u=(null==e?void 0:e.durationKnown)||!1,d=c(n.startDate,g),m=f,p=n.endDate;if(p)m=c(p,g),u=!0;else if(n.endOnNext&&!u){var y=v.reduce((function(t,i){var r=l[i];return r.class===n.class&&r.id!==i&&r.startDate>n.startDate&&t.push(r),t}),[]).sort((function(t,i){return t.startDate.getTime()-i.startDate.getTime()}))[0];y&&(m=c(y.startDate,g),u=!0)}for(var w=Object.keys(n.attr),k=0;k<w.length;k++){var S=w[k];if(S!==o.DateRangeAttribute.ID&&S!==o.DateRangeAttribute.CLASS&&S!==o.DateRangeAttribute.START_DATE&&S!==o.DateRangeAttribute.DURATION&&S!==o.DateRangeAttribute.END_DATE&&S!==o.DateRangeAttribute.END_ON_NEXT){var T=a[S];if(T)u&&!e.durationKnown&&(T.endTime=m);else{var E=n.attr[S];T=new b(d,m,""),S!==o.DateRangeAttribute.SCTE35_OUT&&S!==o.DateRangeAttribute.SCTE35_IN||(E=Uint8Array.from(E.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),T.value={key:S,data:E},T.type=h.MetadataSchema.dateRange,r.id3Track.addCue(T),a[S]=T}}}s[i]={cues:a,dateRange:n,durationKnown:u}},k=0;k<v.length;k++)w(k)}}},t}();const v=l},"./src/controller/latency-controller.ts":
|
|
50
|
-
/*!**********************************************!*\
|
|
51
|
-
!*** ./src/controller/latency-controller.ts ***!
|
|
52
|
-
\**********************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>o});var n=r(/*! ../errors */"./src/errors.ts"),e=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts");function a(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}var o=function(){function t(t){var i=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return i.timeupdate()},this.hls=t,this.config=t.config,this.registerListeners()}var i,r,o=t.prototype;return o.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},o.registerListeners=function(){this.hls.on(e.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(e.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(e.Events.ERROR,this.onError,this)},o.unregisterListeners=function(){this.hls.off(e.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(e.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(e.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(e.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(e.Events.ERROR,this.onError)},o.onMediaAttached=function(t,i){this.media=i.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},o.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},o.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},o.onLevelUpdated=function(t,i){var r=i.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},o.onError=function(t,i){i.details===n.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,s.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},o.timeupdate=function(){var t=this.media,i=this.levelDetails;if(t&&i){this.currentTime=t.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var n=this.config,e=n.maxLiveSyncPlaybackRate;if(n.lowLatencyMode&&1!==e){var s=this.targetLatency;if(null!==s){var a=r-s,o=Math.min(this.maxLatency,s+i.targetduration);if(i.live&&a<o&&a>.05&&this.forwardBufferLength>1){var h=Math.min(2,Math.max(1,e)),u=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20;t.playbackRate=Math.min(h,Math.max(1,u))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}},o.estimateLiveEdge=function(){var t=this.levelDetails;return null===t?null:t.edge+t.age},o.computeLatency=function(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime},i=t,(r=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,i=this.levelDetails;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:i?t.liveMaxLatencyDurationCount*i.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(null===t)return null;var i=t.targetduration,r=this.config,n=r.liveSyncDuration,e=this.hls.userConfig,s=r.lowLatencyMode&&t.partHoldBack||t.holdBack;return(e.liveSyncDuration||e.liveSyncDurationCount||0===s)&&(s=void 0!==n?n:r.liveSyncDurationCount*i),s+Math.min(1*this.stallCount,i)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),i=this.targetLatency,r=this.levelDetails;if(null===t||null===i||null===r)return null;var n=r.edge,e=n-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(n-r.totalduration,t-i-this.edgeStalled),e)}},{key:"drift",get:function(){var t=this.levelDetails;return null===t?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;return null===t?0:Math.max(t.age-3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration),0)}},{key:"forwardBufferLength",get:function(){var t=this.media,i=this.levelDetails;if(!t||!i)return 0;var r=t.buffered.length;return(r?t.buffered.end(r-1):i.edge)-this.currentTime}}])&&a(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),t}()},"./src/controller/level-controller.ts":
|
|
53
|
-
/*!********************************************!*\
|
|
54
|
-
!*** ./src/controller/level-controller.ts ***!
|
|
55
|
-
\********************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>d});var n=r(/*! ../types/level */"./src/types/level.ts"),e=r(/*! ../events */"./src/events.ts"),s=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),o=r(/*! ./level-helper */"./src/controller/level-helper.ts"),h=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts");function f(){return f=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},f.apply(this,arguments)}function c(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}function l(t,i){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},l(t,i)}var v=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),d=function(t){var i,r;function h(i){var r;return(r=t.call(this,i,"[level-controller]")||this)._levels=[],r._firstLevel=-1,r._startLevel=void 0,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.onParsedComplete=void 0,r._registerListeners(),r}r=t,(i=h).prototype=Object.create(r.prototype),i.prototype.constructor=i,l(i,r);var d,m,p=h.prototype;return p._registerListeners=function(){var t=this.hls;t.on(e.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(e.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(e.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(e.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(e.Events.ERROR,this.onError,this)},p._unregisterListeners=function(){var t=this.hls;t.off(e.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(e.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(e.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(e.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(e.Events.ERROR,this.onError,this)},p.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,t.prototype.destroy.call(this)},p.startLoad=function(){this._levels.forEach((function(t){t.loadError=0})),t.prototype.startLoad.call(this)},p.onManifestLoaded=function(t,i){var r,h,u=[],f=[],c=[],l={},d=!1,m=!1,p=!1;if(i.levels.forEach((function(t){var i=t.attrs;d=d||!(!t.width||!t.height),m=m||!!t.videoCodec,p=p||!!t.audioCodec,v&&t.audioCodec&&-1!==t.audioCodec.indexOf("mp4a.40.34")&&(t.audioCodec=void 0);var r=t.bitrate+"-"+t.attrs.RESOLUTION+"-"+t.attrs.CODECS;(h=l[r])?h.url.push(t.url):(h=new n.Level(t),l[r]=h,u.push(h)),i&&(i.AUDIO&&(0,o.addGroupId)(h,"audio",i.AUDIO),i.SUBTITLES&&(0,o.addGroupId)(h,"text",i.SUBTITLES))})),(d||m)&&p&&(u=u.filter((function(t){return!!t.videoCodec||!(!t.width||!t.height)}))),u=u.filter((function(t){var i=t.audioCodec,r=t.videoCodec;return(!i||(0,a.isCodecSupportedInMp4)(i,"audio"))&&(!r||(0,a.isCodecSupportedInMp4)(r,"video"))})),i.audioTracks&&(f=i.audioTracks.filter((function(t){return!t.audioCodec||(0,a.isCodecSupportedInMp4)(t.audioCodec,"audio")})),(0,o.assignTrackIdsByGroup)(f)),i.subtitles&&(0,o.assignTrackIdsByGroup)(c=i.subtitles),u.length>0){r=u[0].bitrate,u.sort((function(t,i){return t.attrs["HDCP-LEVEL"]!==i.attrs["HDCP-LEVEL"]?(t.attrs["HDCP-LEVEL"]||"")>(i.attrs["HDCP-LEVEL"]||"")?1:-1:t.bitrate!==i.bitrate?t.bitrate-i.bitrate:t.attrs.SCORE!==i.attrs.SCORE?t.attrs.decimalFloatingPoint("SCORE")-i.attrs.decimalFloatingPoint("SCORE"):d&&t.height!==i.height?t.height-i.height:0})),this._levels=u;for(var y=0;y<u.length;y++)if(u[y].bitrate===r){this._firstLevel=y,this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+r);break}var g={levels:u,audioTracks:f,subtitleTracks:c,sessionData:i.sessionData,sessionKeys:i.sessionKeys,firstLevel:this._firstLevel,stats:i.stats,audio:p,video:m,altAudio:!(p&&!m)&&f.some((function(t){return!!t.url}))};this.hls.trigger(e.Events.MANIFEST_PARSED,g),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(e.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:i.url,reason:"no level with compatible codecs found in manifest"})},p.onError=function(i,r){var e,a;if(t.prototype.onError.call(this,i,r),!r.fatal){var o=r.context,h=this._levels[this.currentLevelIndex];if(o&&(o.type===u.PlaylistContextType.AUDIO_TRACK&&h.audioGroupIds&&o.groupId===h.audioGroupIds[h.urlId]||o.type===u.PlaylistContextType.SUBTITLE_TRACK&&h.textGroupIds&&o.groupId===h.textGroupIds[h.urlId]))this.redundantFailover(this.currentLevelIndex);else{var f,c=!1,l=!0;switch(r.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:case s.ErrorDetails.KEY_LOAD_ERROR:case s.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var v=r.frag.type===u.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,d=this._levels[v];d?(d.fragmentError++,d.fragmentError>this.hls.config.fragLoadingMaxRetry&&(f=v)):f=v}break;case s.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var m=h.attrs["HDCP-LEVEL"];m&&(this.hls.maxHdcpLevel=n.HdcpLevels[n.HdcpLevels.indexOf(m)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'));case s.ErrorDetails.FRAG_PARSING_ERROR:case s.ErrorDetails.KEY_SYSTEM_NO_SESSION:f=(null===(e=r.frag)||void 0===e?void 0:e.type)===u.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,r.levelRetry=!1;break;case s.ErrorDetails.LEVEL_LOAD_ERROR:case s.ErrorDetails.LEVEL_LOAD_TIMEOUT:o&&(o.deliveryDirectives&&(l=!1),f=o.level),c=!0;break;case s.ErrorDetails.REMUX_ALLOC_ERROR:f=null!=(a=r.level)?a:this.currentLevelIndex,c=!0}void 0!==f&&this.recoverLevel(r,f,c,l)}}},p.recoverLevel=function(t,i,r,n){var e=t.details,s=this._levels[i];if(s.loadError++,r){if(!this.retryLoadingOrFail(t))return void(this.currentLevelIndex=-1);t.levelRetry=!0}if(n){var a=s.url.length;if(a>1&&s.loadError<a)t.levelRetry=!0,this.redundantFailover(i);else if(-1===this.manualLevelIndex){for(var o=-1,h=this._levels,u=h.length;u--;){var f=(u+this.currentLevelIndex)%h.length;if(f!==this.currentLevelIndex&&0===h[f].loadError){o=f;break}}o>-1&&this.currentLevelIndex!==o?(this.warn(e+": switch to "+o),t.levelRetry=!0,this.hls.nextAutoLevel=o):!1===t.levelRetry&&(t.fatal=!0)}}},p.redundantFailover=function(t){var i=this._levels[t],r=i.url.length;if(r>1){var n=(i.urlId+1)%r;this.warn("Switching to redundant URL-id "+n),this._levels.forEach((function(t){t.urlId=n})),this.level=t}},p.onFragLoaded=function(t,i){var r=i.frag;if(void 0!==r&&r.type===u.PlaylistLevelType.MAIN){var n=this._levels[r.level];void 0!==n&&(n.fragmentError=0,n.loadError=0)}},p.onLevelLoaded=function(t,i){var r,n,e=i.level,s=i.details,a=this._levels[e];if(!a)return this.warn("Invalid level index "+e),void(null!==(n=i.deliveryDirectives)&&void 0!==n&&n.skip&&(s.deltaUpdateFailed=!0));e===this.currentLevelIndex?(0===a.fragmentError&&(a.loadError=0,this.retryCount=0),this.playlistLoaded(e,i,a.details)):null!==(r=i.deliveryDirectives)&&void 0!==r&&r.skip&&(s.deltaUpdateFailed=!0)},p.onAudioTrackSwitched=function(t,i){var r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var n=-1,e=this.hls.audioTracks[i.id].groupId,s=0;s<r.audioGroupIds.length;s++)if(r.audioGroupIds[s]===e){n=s;break}n!==r.urlId&&(r.urlId=n,this.startLoad())}},p.loadPlaylist=function(i){t.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,n=this._levels[r];if(this.canLoad&&n&&n.url.length>0){var s=n.urlId,a=n.url[s];if(i)try{a=i.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Attempt loading level index "+r+(void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+s+" "+a),this.clearTimer(),this.hls.trigger(e.Events.LEVEL_LOADING,{url:a,level:r,id:s,deliveryDirectives:i||null})}},p.removeLevel=function(t,i){var r=function(t,r){return r!==i},n=this._levels.filter((function(n,e){return e!==t||n.url.length>1&&void 0!==i&&(n.url=n.url.filter(r),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(r)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(r)),n.urlId=0,!0)})).map((function(t,i){var r=t.details;return null!=r&&r.fragments&&r.fragments.forEach((function(t){t.level=i})),t}));this._levels=n,this.hls.trigger(e.Events.LEVELS_UPDATED,{levels:n})},d=h,(m=[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var i,r=this._levels;if(0!==r.length&&(this.currentLevelIndex!==t||null===(i=r[t])||void 0===i||!i.details)){if(t<0||t>=r.length){var n=t<0;if(this.hls.trigger(e.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.LEVEL_SWITCH_ERROR,level:t,fatal:n,reason:"invalid level idx"}),n)return;t=Math.min(t,r.length-1)}this.clearTimer();var a=this.currentLevelIndex,o=r[a],h=r[t];this.log("switching to level "+t+" from "+a),this.currentLevelIndex=t;var u=f({},h,{level:t,maxBitrate:h.maxBitrate,uri:h.uri,urlId:h.urlId});delete u._urlId,this.hls.trigger(e.Events.LEVEL_SWITCHING,u);var c=h.details;if(!c||c.live){var l=this.switchParams(h.uri,null==o?void 0:o.details);this.loadPlaylist(l)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}}])&&c(d.prototype,m),Object.defineProperty(d,"prototype",{writable:!1}),h}(h.default)},"./src/controller/level-helper.ts":
|
|
56
|
-
/*!****************************************!*\
|
|
57
|
-
!*** ./src/controller/level-helper.ts ***!
|
|
58
|
-
\****************************************/(t,i,r)=>{r.r(i),r.d(i,{addGroupId:()=>o,addSliding:()=>p,adjustSliding:()=>m,assignTrackIdsByGroup:()=>h,computeReloadInterval:()=>y,getFragmentWithSN:()=>g,getPartWith:()=>b,mapFragmentIntersection:()=>d,mapPartIntersection:()=>v,mergeDetails:()=>l,updateFragPTSDTS:()=>c,updatePTS:()=>u});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../loader/date-range */"./src/loader/date-range.ts");function a(){return a=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},a.apply(this,arguments)}function o(t,i,r){switch(i){case"audio":t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds.push(r);break;case"text":t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds.push(r)}}function h(t){var i={};t.forEach((function(t){var r=t.groupId||"";t.id=i[r]=i[r]||0,i[r]++}))}function u(t,i,r){f(t[i],t[r])}function f(t,i){var r=i.startPTS;if((0,n.isFiniteNumber)(r)){var e,s=0;i.sn>t.sn?(s=r-t.start,e=t):(s=t.start-r,e=i),e.duration!==s&&(e.duration=s)}else i.start=i.sn>t.sn?t.cc===i.cc&&t.minEndPTS?t.start+(t.minEndPTS-t.start):t.start+t.duration:Math.max(t.start-i.duration,0)}function c(t,i,r,s,a,o){s-r<=0&&(e.logger.warn("Fragment should have a positive duration",i),s=r+i.duration,o=a+i.duration);var h=r,u=s,c=i.startPTS,l=i.endPTS;if((0,n.isFiniteNumber)(c)){var v=Math.abs(c-r);i.deltaPTS=(0,n.isFiniteNumber)(i.deltaPTS)?Math.max(v,i.deltaPTS):v,h=Math.max(r,c),r=Math.min(r,c),a=Math.min(a,i.startDTS),u=Math.min(s,l),s=Math.max(s,l),o=Math.max(o,i.endDTS)}i.duration=s-r;var d=r-i.start;i.start=i.startPTS=r,i.maxStartPTS=h,i.startDTS=a,i.endPTS=s,i.minEndPTS=u,i.endDTS=o;var m,p=i.sn;if(!t||p<t.startSN||p>t.endSN)return 0;var y=p-t.startSN,g=t.fragments;for(g[y]=i,m=y;m>0;m--)f(g[m],g[m-1]);for(m=y;m<g.length-1;m++)f(g[m],g[m+1]);return t.fragmentHint&&f(g[g.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,d}function l(t,i){for(var r=null,o=t.fragments,h=o.length-1;h>=0;h--){var u=o[h].initSegment;if(u){r=u;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var f,l,p,y,g=0;if(d(t,i,(function(t,e){t.relurl&&(g=t.cc-e.cc),(0,n.isFiniteNumber)(t.startPTS)&&(0,n.isFiniteNumber)(t.endPTS)&&(e.start=e.startPTS=t.startPTS,e.startDTS=t.startDTS,e.appendedPTS=t.appendedPTS,e.maxStartPTS=t.maxStartPTS,e.endPTS=t.endPTS,e.endDTS=t.endDTS,e.minEndPTS=t.minEndPTS,e.duration=t.endPTS-t.startPTS,e.duration&&(f=e),i.PTSKnown=i.alignedSliding=!0),e.elementaryStreams=t.elementaryStreams,e.loader=t.loader,e.stats=t.stats,e.urlId=t.urlId,t.initSegment&&(e.initSegment=t.initSegment,r=t.initSegment)})),r&&(i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments).forEach((function(t){var i;t.initSegment&&t.initSegment.relurl!==(null===(i=r)||void 0===i?void 0:i.relurl)||(t.initSegment=r)})),i.skippedSegments)if(i.deltaUpdateFailed=i.fragments.some((function(t){return!t})),i.deltaUpdateFailed){e.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var b=i.skippedSegments;b--;)i.fragments.shift();i.startSN=i.fragments[0].sn,i.startCC=i.fragments[0].cc}else i.canSkipDateRanges&&(i.dateRanges=(l=i.dateRanges,p=i.recentlyRemovedDateranges,y=a({},t.dateRanges),p&&p.forEach((function(t){delete y[t]})),Object.keys(l).forEach((function(t){var i=new s.DateRange(l[t].attr,y[t]);i.isValid?y[t]=i:e.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(l[t].attr)+'"')})),y));var w=i.fragments;if(g){e.logger.warn("discontinuity sliding from playlist, take drift into account");for(var k=0;k<w.length;k++)w[k].cc+=g}i.skippedSegments&&(i.startCC=i.fragments[0].cc),v(t.partList,i.partList,(function(t,i){i.elementaryStreams=t.elementaryStreams,i.stats=t.stats})),f?c(i,f,f.startPTS,f.endPTS,f.startDTS,f.endDTS):m(t,i),w.length&&(i.totalduration=i.edge-w[0].start),i.driftStartTime=t.driftStartTime,i.driftStart=t.driftStart;var S=i.advancedDateTime;if(i.advanced&&S){var T=i.edge;i.driftStart||(i.driftStartTime=S,i.driftStart=T),i.driftEndTime=S,i.driftEnd=T}else i.driftEndTime=t.driftEndTime,i.driftEnd=t.driftEnd,i.advancedDateTime=t.advancedDateTime}function v(t,i,r){if(t&&i)for(var n=0,e=0,s=t.length;e<=s;e++){var a=t[e],o=i[e+n];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?r(a,o):n--}}function d(t,i,r){for(var n=i.skippedSegments,e=Math.max(t.startSN,i.startSN)-i.startSN,s=(t.fragmentHint?1:0)+(n?i.endSN:Math.min(t.endSN,i.endSN))-i.startSN,a=i.startSN-t.startSN,o=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,h=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=e;u<=s;u++){var f=h[a+u],c=o[u];n&&!c&&u<n&&(c=i.fragments[u]=f),f&&c&&r(f,c)}}function m(t,i){var r=i.startSN+i.skippedSegments-t.startSN,n=t.fragments;r<0||r>=n.length||p(i,n[r].start)}function p(t,i){if(i){for(var r=t.fragments,n=t.skippedSegments;n<r.length;n++)r[n].start+=i;t.fragmentHint&&(t.fragmentHint.start+=i)}}function y(t,i){void 0===i&&(i=1/0);var r=1e3*t.targetduration;if(t.updated){var n=t.fragments;if(n.length&&4*r>i){var e=1e3*n[n.length-1].duration;e<r&&(r=e)}}else r/=2;return Math.round(r)}function g(t,i,r){if(!t||!t.details)return null;var n=t.details,e=n.fragments[i-n.startSN];return e||((e=n.fragmentHint)&&e.sn===i?e:i<n.startSN&&r&&r.sn===i?r:null)}function b(t,i,r){if(!t||!t.details)return null;var n=t.details.partList;if(n)for(var e=n.length;e--;){var s=n[e];if(s.index===r&&s.fragment.sn===i)return s}return null}},"./src/controller/stream-controller.ts":
|
|
59
|
-
/*!*********************************************!*\
|
|
60
|
-
!*** ./src/controller/stream-controller.ts ***!
|
|
61
|
-
\*********************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>y});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),s=r(/*! ../is-supported */"./src/is-supported.ts"),a=r(/*! ../events */"./src/events.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),h=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),f=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),c=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),l=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),v=r(/*! ./gap-controller */"./src/controller/gap-controller.ts"),d=r(/*! ../errors */"./src/errors.ts");function m(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}function p(t,i){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},p(t,i)}var y=function(t){var i,r;function y(i,r,n){var e;return(e=t.call(this,i,r,n,"[stream-controller]")||this).audioCodecSwap=!1,e.gapController=null,e.level=-1,e._forceStartLoad=!1,e.altAudio=!1,e.audioOnly=!1,e.fragPlaying=null,e.onvplaying=null,e.onvseeked=null,e.fragLastKbps=0,e.couldBacktrack=!1,e.backtrackFragment=null,e.audioCodecSwitch=!1,e.videoBuffer=null,e._registerListeners(),e}r=t,(i=y).prototype=Object.create(r.prototype),i.prototype.constructor=i,p(i,r);var g,b,w=y.prototype;return w._registerListeners=function(){var t=this.hls;t.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(a.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(a.Events.ERROR,this.onError,this),t.on(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(a.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},w._unregisterListeners=function(){var t=this.hls;t.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(a.Events.ERROR,this.onError,this),t.off(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(a.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},w.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},w.startLoad=function(t){if(this.levels){var i=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var n=r.startLevel;-1===n&&(r.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=r.nextAutoLevel),this.level=r.nextLoadLevel=n,this.loadedmetadata=!1}i>0&&-1===t&&(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),t=i),this.state=e.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=e.State.STOPPED},w.stopLoad=function(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},w.doTick=function(){switch(this.state){case e.State.IDLE:this.doTickIdle();break;case e.State.WAITING_LEVEL:var t,i=this.levels,r=null==i||null===(t=i[this.level])||void 0===t?void 0:t.details;if(r&&(!r.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(r))break;this.state=e.State.IDLE;break}break;case e.State.FRAG_LOADING_WAITING_RETRY:var n,s=self.performance.now(),a=this.retryDate;(!a||s>=a||null!==(n=this.media)&&void 0!==n&&n.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=e.State.IDLE)}this.onTickEnd()},w.onTickEnd=function(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},w.doTickIdle=function(){var t=this.hls,i=this.levels,r=t.nextLoadLevel;if(null!==this.levelLastLoaded&&(this.media||!this.startFragRequested&&t.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&i&&i[r]){var n=i[r],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){var c={};return this.altAudio&&(c.type="video"),this.hls.trigger(a.Events.BUFFER_EOS,c),void(this.state=e.State.ENDED)}this.level=t.nextLoadLevel=r;var l=n.details;if(!l||this.state===e.State.WAITING_LEVEL||l.live&&this.levelLastLoaded!==r)return this.level=r,void(this.state=e.State.WAITING_LEVEL);if(!(s.len>=this.getMaxBufferLength(n.maxBitrate))){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var v=this.backtrackFragment?this.backtrackFragment.start:s.end,d=this.getNextFragment(v,l);if(this.couldBacktrack&&!this.fragPrevious&&d&&"initSegment"!==d.sn&&this.fragmentTracker.getState(d)!==h.FragmentState.OK){var m,p=(null!=(m=this.backtrackFragment)?m:d).sn,y=l.fragments[p-l.startSN-1];y&&d.cc===y.cc&&(d=y,this.fragmentTracker.removeFragment(y))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(d&&this.fragmentTracker.getState(d)===h.FragmentState.OK&&this.nextLoadPosition>v){var g=this.audioOnly&&!this.altAudio?f.ElementaryStreamTypes.AUDIO:f.ElementaryStreamTypes.VIDEO,b=(g===f.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;b&&this.afterBufferFlushed(b,g,u.PlaylistLevelType.MAIN),d=this.getNextFragment(this.nextLoadPosition,l)}d&&(!d.initSegment||d.initSegment.data||this.bitrateTest||(d=d.initSegment),this.loadFragment(d,l,v))}}}},w.loadFragment=function(i,r,n){var e,s=this.fragmentTracker.getState(i);this.fragCurrent=i,s===h.FragmentState.NOT_LOADED?"initSegment"===i.sn?this._loadInitSegment(i,r):this.bitrateTest?(this.log("Fragment "+i.sn+" of level "+i.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(i,r)):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,i,r,n)):s===h.FragmentState.APPENDING?this.reduceMaxBufferLength(i.duration)&&this.fragmentTracker.removeFragment(i):0===(null===(e=this.media)||void 0===e?void 0:e.buffered.length)&&this.fragmentTracker.removeAllFragments()},w.getAppendedFrag=function(t){var i=this.fragmentTracker.getAppendedFrag(t,u.PlaylistLevelType.MAIN);return i&&"fragment"in i?i.fragment:i},w.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,u.PlaylistLevelType.MAIN)},w.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},w.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},w.nextLevelSwitch=function(){var t=this.levels,i=this.media;if(null!=i&&i.readyState){var r,n=this.getAppendedFrag(i.currentTime);if(n&&n.start>1&&this.flushMainBuffer(0,n.start-1),!i.paused&&t){var e=this.fragLastKbps;r=e&&this.fragCurrent?this.fragCurrent.duration*t[this.hls.nextLoadLevel].maxBitrate/(1e3*e)+1:0}else r=0;var s=this.getBufferedFrag(i.currentTime+r);if(s){var a=this.followingBufferedFrag(s);if(a){this.abortCurrentFrag();var o=a.duration,h=Math.max(s.end,(a.maxStartPTS?a.maxStartPTS:a.start)+Math.min(Math.max(o-this.config.maxFragLookUpTolerance,.5*o),.75*o));this.flushMainBuffer(h,Number.POSITIVE_INFINITY)}}}},w.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&t.abortRequests(),this.state){case e.State.KEY_LOADING:case e.State.FRAG_LOADING:case e.State.FRAG_LOADING_WAITING_RETRY:case e.State.PARSING:case e.State.PARSED:this.state=e.State.IDLE}this.nextLoadPosition=this.getLoadPosition()},w.flushMainBuffer=function(i,r){t.prototype.flushMainBuffer.call(this,i,r,this.altAudio?"video":null)},w.onMediaAttached=function(i,r){t.prototype.onMediaAttached.call(this,i,r);var n=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),n.addEventListener("playing",this.onvplaying),n.addEventListener("seeked",this.onvseeked),this.gapController=new v.default(this.config,n,this.fragmentTracker,this.hls)},w.onMediaDetaching=function(){var i=this.media;i&&this.onvplaying&&this.onvseeked&&(i.removeEventListener("playing",this.onvplaying),i.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),t.prototype.onMediaDetaching.call(this)},w.onMediaPlaying=function(){this.tick()},w.onMediaSeeked=function(){var t=this.media,i=t?t.currentTime:null;(0,n.isFiniteNumber)(i)&&this.log("Media seeked to "+i.toFixed(3)),this.tick()},w.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(a.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},w.onManifestParsed=function(t,i){var r,n=!1,e=!1;i.levels.forEach((function(t){(r=t.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(n=!0),-1!==r.indexOf("mp4a.40.5")&&(e=!0))})),this.audioCodecSwitch=n&&e&&!(0,s.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=i.levels,this.startFragRequested=!1},w.onLevelLoading=function(t,i){var r=this.levels;if(r&&this.state===e.State.IDLE){var n=r[i.level];(!n.details||n.details.live&&this.levelLastLoaded!==i.level||this.waitForCdnTuneIn(n.details))&&(this.state=e.State.WAITING_LEVEL)}},w.onLevelLoaded=function(t,i){var r,n=this.levels,s=i.level,o=i.details;if(n){this.log("Level "+s+" loaded ["+o.startSN+","+o.endSN+"], cc ["+o.startCC+", "+o.endCC+"] duration:"+o.totalduration);var h=this.fragCurrent;!h||this.state!==e.State.FRAG_LOADING&&this.state!==e.State.FRAG_LOADING_WAITING_RETRY||h.level!==i.level&&h.loader&&(this.state=e.State.IDLE,this.backtrackFragment=null,h.abortRequests());var u=n[s],f=0;if(o.live||null!==(r=u.details)&&void 0!==r&&r.live){if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed)return;f=this.alignPlaylists(o,u.details)}if(u.details=o,this.levelLastLoaded=s,this.hls.trigger(a.Events.LEVEL_UPDATED,{details:o,level:s}),this.state===e.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=e.State.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,f),this.tick()}else this.warn("Levels were reset while loading level "+s)},w._handleFragmentLoadProgress=function(t){var i,r=t.frag,n=t.part,e=t.payload,s=this.levels;if(s){var a=s[r.level],o=a.details;if(o){var h=a.videoCodec,f=o.PTSKnown||!o.live,v=null===(i=r.initSegment)||void 0===i?void 0:i.data,d=this._getAudioCodec(a),m=this.transmuxer=this.transmuxer||new c.default(this.hls,u.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=n?n.index:-1,y=new l.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,e.byteLength,p,-1!==p);m.push(e,v,d,h,r,n,o.totalduration,f,y,this.initPTS[r.cc])}else this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},w.onAudioTrackSwitching=function(t,i){var r=this.altAudio,n=i.id;if(!i.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var s=this.hls;r&&s.trigger(a.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),s.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:n})}},w.onAudioTrackSwitched=function(t,i){var r=!!this.hls.audioTracks[i.id].url;if(r){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=r,this.tick()},w.onBufferCreated=function(t,i){var r,n,e=i.tracks,s=!1;for(var a in e){var o=e[a];if("main"===o.id){if(n=a,r=o,"video"===a){var h=e[a];h&&(this.videoBuffer=h.buffer)}}else s=!0}s&&r?(this.log("Alternate track found, use "+n+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},w.onFragBuffered=function(t,i){var r=i.frag,n=i.part;if(!r||r.type===u.PlaylistLevelType.MAIN){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(n?" p: "+n.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===e.State.PARSED&&(this.state=e.State.IDLE));var s=n?n.stats:r.stats;this.fragLastKbps=Math.round(8*s.total/(s.buffering.end-s.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,n)}},w.onError=function(t,i){if(i.type!==d.ErrorTypes.KEY_SYSTEM_ERROR)switch(i.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.FRAG_PARSING_ERROR:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.MAIN,i);break;case d.ErrorDetails.LEVEL_LOAD_ERROR:case d.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==e.State.ERROR&&(i.fatal?(this.warn(""+i.details),this.state=e.State.ERROR):i.levelRetry||this.state!==e.State.WAITING_LEVEL||(this.state=e.State.IDLE));break;case d.ErrorDetails.BUFFER_FULL_ERROR:if("main"===i.parent&&(this.state===e.State.PARSING||this.state===e.State.PARSED)){var r=!0,n=this.getFwdBufferInfo(this.media,u.PlaylistLevelType.MAIN);n&&n.len>.5&&(r=!this.reduceMaxBufferLength(n.len)),r&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}else this.onFragmentOrKeyLoadError(u.PlaylistLevelType.MAIN,i)},w.checkBuffer=function(){var t=this.media,i=this.gapController;t&&i&&t.readyState&&(!this.loadedmetadata&&o.BufferHelper.getBuffered(t).length||i.poll(this.lastCurrentTime,this.state!==e.State.IDLE?this.fragCurrent:null),this.lastCurrentTime=t.currentTime)},w.onFragLoadEmergencyAborted=function(){this.state=e.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},w.onBufferFlushed=function(t,i){var r=i.type;(r!==f.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio)&&this.afterBufferFlushed((r===f.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media,r,u.PlaylistLevelType.MAIN)},w.onLevelsUpdated=function(t,i){this.levels=i.levels},w.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},w.seekToStartPos=function(){var t=this.media;if(t){var i=t.currentTime,r=this.startPosition;if(r>=0&&i<r){if(t.seeking)return void this.log("could not seek to "+r+", already seeking at "+i);var n=o.BufferHelper.getBuffered(t),e=(n.length?n.start(0):0)-r;e>0&&(e<this.config.maxBufferHole||e<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+e+" to match buffer start"),this.startPosition=r+=e),this.log("seek to target start position "+r+" from current time "+i),t.currentTime=r}}},w._getAudioCodec=function(t){var i=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&i&&(this.log("Swapping audio codec"),i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),i},w._loadBitrateTestFrag=function(t,i){var r=this;t.bitrateTest=!0,this._doFragLoad(t,i).then((function(i){var n=r.hls;if(i&&!r.fragContextChanged(t)){r.fragLoadError=0,r.state=e.State.IDLE,r.startFragRequested=!1,r.bitrateTest=!1;var s=t.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),n.trigger(a.Events.FRAG_LOADED,i),t.bitrateTest=!1}}))},w._handleTransmuxComplete=function(t){var i,r="main",s=this.hls,o=t.remuxResult,h=t.chunkMeta,u=this.getCurrentContext(h);if(!u)return this.warn("The loading context changed while buffering fragment "+h.sn+" of level "+h.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(h.level);var c=u.frag,l=u.part,v=u.level,d=o.video,m=o.text,p=o.id3,y=o.initSegment,g=v.details,b=this.altAudio?void 0:o.audio;if(!this.fragContextChanged(c)){if(this.state=e.State.PARSING,y){y.tracks&&(this._bufferInitSegment(v,y.tracks,c,h),s.trigger(a.Events.FRAG_PARSING_INIT_SEGMENT,{frag:c,id:r,tracks:y.tracks}));var w=y.initPTS,k=y.timescale;(0,n.isFiniteNumber)(w)&&(this.initPTS[c.cc]=w,s.trigger(a.Events.INIT_PTS_FOUND,{frag:c,id:r,initPTS:w,timescale:k}))}if(d&&!1!==o.independent){if(g){var S=d.startPTS,T=d.endPTS,E=d.startDTS,A=d.endDTS;if(l)l.elementaryStreams[d.type]={startPTS:S,endPTS:T,startDTS:E,endDTS:A};else if(d.firstKeyFrame&&d.independent&&1===h.id&&(this.couldBacktrack=!0),d.dropped&&d.independent){var M=this.getMainFwdBufferInfo();if((M?M.end:this.getLoadPosition())+this.config.maxBufferHole<(d.firstKeyFramePTS?d.firstKeyFramePTS:S)-this.config.maxBufferHole)return void this.backtrack(c);c.setElementaryStreamInfo(d.type,c.start,T,c.start,A,!0)}c.setElementaryStreamInfo(d.type,S,T,E,A),this.backtrackFragment&&(this.backtrackFragment=c),this.bufferFragmentData(d,c,l,h)}}else if(!1===o.independent)return void this.backtrack(c);if(b){var x=b.startPTS,O=b.endPTS,D=b.startDTS,I=b.endDTS;l&&(l.elementaryStreams[f.ElementaryStreamTypes.AUDIO]={startPTS:x,endPTS:O,startDTS:D,endDTS:I}),c.setElementaryStreamInfo(f.ElementaryStreamTypes.AUDIO,x,O,D,I),this.bufferFragmentData(b,c,l,h)}g&&null!=p&&null!==(i=p.samples)&&void 0!==i&&i.length&&s.trigger(a.Events.FRAG_PARSING_METADATA,{id:r,frag:c,details:g,samples:p.samples}),g&&m&&s.trigger(a.Events.FRAG_PARSING_USERDATA,{id:r,frag:c,details:g,samples:m.samples})}},w._bufferInitSegment=function(t,i,r,n){var s=this;if(this.state===e.State.PARSING){this.audioOnly=!!i.audio&&!i.video,this.altAudio&&!this.audioOnly&&delete i.audio;var o=i.audio,h=i.video,u=i.audiovideo;if(o){var f=t.audioCodec,c=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(f&&(f=-1!==f.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==o.metadata.channelCount&&-1===c.indexOf("firefox")&&(f="mp4a.40.5")),-1!==c.indexOf("android")&&"audio/mpeg"!==o.container&&this.log("Android: force audio codec to "+(f="mp4a.40.2")),t.audioCodec&&t.audioCodec!==f&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+f+'"'),o.levelCodec=f,o.id="main",this.log("Init audio buffer, container:"+o.container+", codecs[selected/level/parsed]=["+(f||"")+"/"+(t.audioCodec||"")+"/"+o.codec+"]")}h&&(h.levelCodec=t.videoCodec,h.id="main",this.log("Init video buffer, container:"+h.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+h.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+u.codec+"]"),this.hls.trigger(a.Events.BUFFER_CODECS,i),Object.keys(i).forEach((function(t){var e=i[t].initSegment;null!=e&&e.byteLength&&s.hls.trigger(a.Events.BUFFER_APPENDING,{type:t,data:e,frag:r,part:null,chunkMeta:n,parent:r.type})})),this.tick()}},w.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,u.PlaylistLevelType.MAIN)},w.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=e.State.IDLE},w.checkFragmentChanged=function(){var t=this.media,i=null;if(t&&t.readyState>1&&!1===t.seeking){var r=t.currentTime;if(o.BufferHelper.isBuffered(t,r)?i=this.getAppendedFrag(r):o.BufferHelper.isBuffered(t,r+.1)&&(i=this.getAppendedFrag(r+.1)),i){this.backtrackFragment=null;var n=this.fragPlaying,e=i.level;n&&i.sn===n.sn&&n.level===e&&i.urlId===n.urlId||(this.fragPlaying=i,this.hls.trigger(a.Events.FRAG_CHANGED,{frag:i}),n&&n.level===e||this.hls.trigger(a.Events.LEVEL_SWITCHED,{level:e}))}}},g=y,(b=[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var i=t.currentTime,r=this.currentFrag;if(r&&(0,n.isFiniteNumber)(i)&&(0,n.isFiniteNumber)(r.programDateTime))return new Date(r.programDateTime+1e3*(i-r.start))}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&m(g.prototype,b),Object.defineProperty(g,"prototype",{writable:!1}),y}(e.default)},"./src/controller/subtitle-stream-controller.ts":
|
|
62
|
-
/*!******************************************************!*\
|
|
63
|
-
!*** ./src/controller/subtitle-stream-controller.ts ***!
|
|
64
|
-
\******************************************************/(t,i,r)=>{r.r(i),r.d(i,{SubtitleStreamController:()=>d});var n=r(/*! ../events */"./src/events.ts"),e=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),a=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),o=r(/*! ./level-helper */"./src/controller/level-helper.ts"),h=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),f=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../types/level */"./src/types/level.ts");function l(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}function v(t,i){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},v(t,i)}var d=function(t){var i,r;function d(i,r,n){var e;return(e=t.call(this,i,r,n,"[subtitle-stream-controller]")||this).levels=[],e.currentTrackId=-1,e.tracksBuffered=[],e.mainDetails=null,e._registerListeners(),e}r=t,(i=d).prototype=Object.create(r.prototype),i.prototype.constructor=i,v(i,r);var p,y,g=d.prototype;return g.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},g._registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(n.Events.ERROR,this.onError,this),t.on(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(n.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(n.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(n.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g._unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(n.Events.ERROR,this.onError,this),t.off(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(n.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(n.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(n.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g.startLoad=function(t){this.stopLoad(),this.state=u.State.IDLE,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},g.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},g.onLevelLoaded=function(t,i){this.mainDetails=i.details},g.onSubtitleFragProcessed=function(t,i){var r=i.frag,n=i.success;if(this.fragPrevious=r,this.state=u.State.IDLE,n){var e=this.tracksBuffered[this.currentTrackId];if(e){for(var s,a=r.start,o=0;o<e.length;o++)if(a>=e[o].start&&a<=e[o].end){s=e[o];break}var h=r.start+r.duration;s?s.end=h:e.push(s={start:a,end:h}),this.fragmentTracker.fragBuffered(r)}}},g.onBufferFlushing=function(t,i){var r=i.startOffset,n=i.endOffset;if(0===r&&n!==Number.POSITIVE_INFINITY){var e=this.currentTrackId,s=this.levels;if(!s.length||!s[e]||!s[e].details)return;var a=n-s[e].details.targetduration;if(a<=0)return;i.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach((function(t){for(var i=0;i<t.length;)if(t[i].end<=a)t.shift();else{if(!(t[i].start<a))break;t[i].start=a,i++}})),this.fragmentTracker.removeFragmentsInRange(r,a,f.PlaylistLevelType.SUBTITLE)}},g.onFragBuffered=function(t,i){var r;this.loadedmetadata||i.frag.type!==f.PlaylistLevelType.MAIN||null!==(r=this.media)&&void 0!==r&&r.buffered.length&&(this.loadedmetadata=!0)},g.onError=function(t,i){var r=i.frag;r&&r.type===f.PlaylistLevelType.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state=u.State.IDLE)},g.onSubtitleTracksUpdated=function(t,i){var r=this,n=i.subtitleTracks;this.tracksBuffered=[],this.levels=n.map((function(t){return new c.Level(t)})),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach((function(t){r.tracksBuffered[t.id]=[]})),this.mediaBuffer=null},g.onSubtitleTrackSwitch=function(t,i){if(this.currentTrackId=i.id,this.levels.length&&-1!==this.currentTrackId){var r=this.levels[this.currentTrackId];this.mediaBuffer=null!=r&&r.details?this.mediaBufferTimeRanges:null,r&&this.setInterval(500)}else this.clearInterval()},g.onSubtitleTrackLoaded=function(t,i){var r,n=i.details,e=i.id,h=this.currentTrackId,f=this.levels;if(f.length){var c=f[h];if(!(e>=f.length||e!==h)&&c){this.mediaBuffer=this.mediaBufferTimeRanges;var l=0;if(n.live||null!==(r=c.details)&&void 0!==r&&r.live){var v=this.mainDetails;if(n.deltaUpdateFailed||!v)return;var d=v.fragments[0];c.details?0===(l=this.alignPlaylists(n,c.details))&&d&&(0,o.addSliding)(n,l=d.start):n.hasProgramDateTime&&v.hasProgramDateTime?((0,a.alignMediaPlaylistByPDT)(n,v),l=n.fragments[0].start):d&&(0,o.addSliding)(n,l=d.start)}c.details=n,this.levelLastLoaded=e,this.startFragRequested||!this.mainDetails&&n.live||this.setStartPosition(c.details,l),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===u.State.IDLE&&((0,s.findFragmentByPTS)(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),c.details=void 0))}}},g._handleFragmentLoadComplete=function(t){var i=this,r=t.frag,e=t.payload,s=r.decryptdata,a=this.hls;if(!this.fragContextChanged(r)&&e&&e.byteLength>0&&s&&s.key&&s.iv&&"AES-128"===s.method){var o=performance.now();this.decrypter.decrypt(new Uint8Array(e),s.key.buffer,s.iv.buffer).then((function(t){var i=performance.now();a.trigger(n.Events.FRAG_DECRYPTED,{frag:r,payload:t,stats:{tstart:o,tdecrypt:i}})})).catch((function(t){i.warn(t.name+": "+t.message),i.state=u.State.IDLE}))}},g.doTick=function(){if(this.media){if(this.state===u.State.IDLE){var t=this.currentTrackId,i=this.levels;if(!i.length||!i[t]||!i[t].details)return;var r=i[t].details,n=r.targetduration,a=this.config,o=this.getLoadPosition(),c=e.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o-n,a.maxBufferHole),l=c.end,v=c.len,d=this.getFwdBufferInfo(this.media,f.PlaylistLevelType.MAIN);if(v>this.getMaxBufferLength(null==d?void 0:d.len)+n)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var m=r.fragments,p=m.length,y=null,g=this.fragPrevious;if(l<r.edge){var b=a.maxFragLookUpTolerance;!(y=(0,s.findFragmentByPTS)(g,m,Math.max(m[0].start,l),b))&&g&&g.start<m[0].start&&(y=m[0])}else y=m[p-1];if(!y)return;y=this.mapToInitFragWhenRequired(y),this.fragmentTracker.getState(y)===h.FragmentState.NOT_LOADED&&this.loadFragment(y,r,l)}}else this.state=u.State.IDLE},g.getMaxBufferLength=function(i){var r=t.prototype.getMaxBufferLength.call(this);return i?Math.max(r,i):r},g.loadFragment=function(i,r,n){this.fragCurrent=i,"initSegment"===i.sn?this._loadInitSegment(i,r):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,i,r,n))},p=d,(y=[{key:"mediaBufferTimeRanges",get:function(){return new m(this.tracksBuffered[this.currentTrackId]||[])}}])&&l(p.prototype,y),Object.defineProperty(p,"prototype",{writable:!1}),d}(u.default),m=function(t){this.buffered=void 0;var i=function(i,r,n){if((r>>>=0)>n-1)throw new DOMException("Failed to execute '"+i+"' on 'TimeRanges': The index provided ("+r+") is greater than the maximum bound ("+n+")");return t[r][i]};this.buffered={get length(){return t.length},end:function(r){return i("end",r,t.length)},start:function(r){return i("start",r,t.length)}}}},"./src/controller/subtitle-track-controller.ts":
|
|
65
|
-
/*!*****************************************************!*\
|
|
66
|
-
!*** ./src/controller/subtitle-track-controller.ts ***!
|
|
67
|
-
\*****************************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>c});var n=r(/*! ../events */"./src/events.ts"),e=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),s=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),a=r(/*! ../types/loader */"./src/types/loader.ts");function o(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}function h(t,i){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},h(t,i)}var u=function(t){var i,r;function s(i){var r;return(r=t.call(this,i,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r._subtitleDisplay=!0,r.registerListeners(),r}r=t,(i=s).prototype=Object.create(r.prototype),i.prototype.constructor=i,h(i,r);var u,c,l=s.prototype;return l.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,t.prototype.destroy.call(this)},l.registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(n.Events.ERROR,this.onError,this)},l.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(n.Events.ERROR,this.onError,this)},l.onMediaAttached=function(t,i){this.media=i.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},l.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},l.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),f(this.media.textTracks).forEach((function(t){(0,e.clearCurrentCues)(t)})),this.subtitleTrack=-1,this.media=null)},l.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},l.onManifestParsed=function(t,i){this.tracks=i.subtitleTracks},l.onSubtitleTrackLoaded=function(t,i){var r=i.id,n=i.details,e=this.tracksInGroup[this.trackId];if(e){var s=e.details;e.details=i.details,this.log("subtitle track "+r+" loaded ["+n.startSN+"-"+n.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,i,s))}else this.warn("Invalid subtitle track id "+r)},l.onLevelLoading=function(t,i){this.switchLevel(i.level)},l.onLevelSwitching=function(t,i){this.switchLevel(i.level)},l.switchLevel=function(t){var i=this.hls.levels[t];if(null!=i&&i.textGroupIds){var r=i.textGroupIds[i.urlId];if(this.groupId!==r){var e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,s=this.tracks.filter((function(t){return!r||t.groupId===r}));this.tracksInGroup=s;var a=this.findTrackId(null==e?void 0:e.name)||this.findTrackId();this.groupId=r;var o={subtitleTracks:s};this.log("Updating subtitle tracks, "+s.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(n.Events.SUBTITLE_TRACKS_UPDATED,o),-1!==a&&this.setSubtitleTrack(a,e)}}},l.findTrackId=function(t){for(var i=this.tracksInGroup,r=0;r<i.length;r++){var n=i[r];if((!this.selectDefaultTrack||n.default)&&(!t||t===n.name))return n.id}return-1},l.onError=function(i,r){t.prototype.onError.call(this,i,r),!r.fatal&&r.context&&r.context.type===a.PlaylistContextType.SUBTITLE_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},l.loadPlaylist=function(i){t.prototype.loadPlaylist.call(this);var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var e=r.id,s=r.groupId,a=r.url;if(i)try{a=i.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+e),this.hls.trigger(n.Events.SUBTITLE_TRACK_LOADING,{url:a,id:e,groupId:s,deliveryDirectives:i||null})}},l.toggleTrackModes=function(t){var i=this,r=this.media,n=this.trackId;if(r){var e=f(r.textTracks),s=e.filter((function(t){return t.groupId===i.groupId}));if(-1===t)[].slice.call(e).forEach((function(t){t.mode="disabled"}));else{var a=s[n];a&&(a.mode="disabled")}var o=s[t];o&&(o.mode=this.subtitleDisplay?"showing":"hidden")}},l.setSubtitleTrack=function(t,i){var r,e=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(-1===t||null!==(r=e[t])&&void 0!==r&&r.details)||t<-1||t>=e.length)){this.clearTimer();var s=e[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,s){var a=s.groupId;this.hls.trigger(n.Events.SUBTITLE_TRACK_SWITCH,{id:s.id,groupId:void 0===a?"":a,name:s.name,type:s.type,url:s.url});var o=this.switchParams(s.url,null==i?void 0:i.details);this.loadPlaylist(o)}else this.hls.trigger(n.Events.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},l.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,i=f(this.media.textTracks),r=0;r<i.length;r++)if("hidden"===i[r].mode)t=r;else if("showing"===i[r].mode){t=r;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},u=s,(c=[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setSubtitleTrack(t,this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0)}}])&&o(u.prototype,c),Object.defineProperty(u,"prototype",{writable:!1}),s}(s.default);function f(t){for(var i=[],r=0;r<t.length;r++){var n=t[r];"subtitles"!==n.kind&&"captions"!==n.kind||!n.label||i.push(t[r])}return i}const c=u},"./src/controller/timeline-controller.ts":
|
|
68
|
-
/*!***********************************************!*\
|
|
69
|
-
!*** ./src/controller/timeline-controller.ts ***!
|
|
70
|
-
\***********************************************/(t,i,r)=>{r.r(i),r.d(i,{TimelineController:()=>v});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts"),a=r(/*! ../utils/output-filter */"./src/utils/output-filter.ts"),o=r(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts"),h=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),u=r(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts"),f=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),c=r(/*! ../types/loader */"./src/types/loader.ts"),l=r(/*! ../utils/logger */"./src/utils/logger.ts"),v=function(){function t(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var i=new a.default(this,"textTrack1"),r=new a.default(this,"textTrack2"),n=new a.default(this,"textTrack3"),o=new a.default(this,"textTrack4");this.cea608Parser1=new s.default(1,i,r),this.cea608Parser2=new s.default(3,n,o)}t.on(e.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(e.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(e.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(e.Events.FRAG_LOADING,this.onFragLoading,this),t.on(e.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(e.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(e.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(e.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(e.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var i=t.prototype;return i.destroy=function(){var t=this.hls;t.off(e.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(e.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(e.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(e.Events.FRAG_LOADING,this.onFragLoading,this),t.off(e.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(e.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(e.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(e.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(e.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},i.addCues=function(t,i,r,n,s){for(var a,o,h=!1,u=s.length;u--;){var f=s[u],c=(a=f[0],o=i,Math.min(f[1],r)-Math.max(a,o));if(c>=0&&(f[0]=Math.min(f[0],i),f[1]=Math.max(f[1],r),h=!0,c/(r-i)>.5))return}if(h||s.push([i,r]),this.config.renderTextTracksNatively)this.Cues.newCue(this.captionsTracks[t],i,r,n);else{var l=this.Cues.newCue(null,i,r,n);this.hls.trigger(e.Events.CUES_PARSED,{type:"captions",cues:l,track:t})}},i.onInitPtsFound=function(t,i){var r=this,n=i.frag,s=i.timescale,a=this.unparsedVttFrags;"main"===i.id&&(this.initPTS[n.cc]=i.initPTS,this.timescale[n.cc]=s),a.length&&(this.unparsedVttFrags=[],a.forEach((function(t){r.onFragLoaded(e.Events.FRAG_LOADED,t)})))},i.getExistingTrack=function(t){var i=this.media;if(i)for(var r=0;r<i.textTracks.length;r++){var n=i.textTracks[r];if(n[t])return n}return null},i.createCaptionsTrack=function(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)},i.createNativeTrack=function(t){if(!this.captionsTracks[t]){var i=this.captionsTracks,r=this.media,n=this.captionsProperties[t],e=n.label,s=n.languageCode,a=this.getExistingTrack(t);if(a)i[t]=a,(0,h.clearCurrentCues)(i[t]),(0,h.sendAddTrackEvent)(i[t],r);else{var o=this.createTextTrack("captions",e,s);o&&(o[t]=!0,i[t]=o)}}},i.createNonNativeTrack=function(t){if(!this.nonNativeCaptionsTracks[t]){var i=this.captionsProperties[t];if(i){var r={_id:t,label:i.label,kind:"captions",default:!!i.media&&!!i.media.default,closedCaptions:i.media};this.nonNativeCaptionsTracks[t]=r,this.hls.trigger(e.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},i.createTextTrack=function(t,i,r){var n=this.media;if(n)return n.addTextTrack(t,i,r)},i.onMediaAttaching=function(t,i){this.media=i.media,this._cleanTracks()},i.onMediaDetaching=function(){var t=this.captionsTracks;Object.keys(t).forEach((function(i){(0,h.clearCurrentCues)(t[i]),delete t[i]})),this.nonNativeCaptionsTracks={}},i.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},i._cleanTracks=function(){var t=this.media;if(t){var i=t.textTracks;if(i)for(var r=0;r<i.length;r++)(0,h.clearCurrentCues)(i[r])}},i.onSubtitleTracksUpdated=function(t,i){var r=this;this.textTracks=[];var n=i.subtitleTracks||[],s=n.some((function(t){return t.textCodec===u.IMSC1_CODEC}));if(this.config.enableWebVTT||s&&this.config.enableIMSC1){var a=this.tracks&&n&&this.tracks.length===n.length;if(this.tracks=n||[],this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:[];this.tracks.forEach((function(t,i){var n;if(i<o.length){for(var e=null,s=0;s<o.length;s++)if(d(o[s],t)){e=o[s];break}e&&(n=e)}if(n)(0,h.clearCurrentCues)(n);else{var a=r._captionsOrSubtitlesFromCharacteristics(t);(n=r.createTextTrack(a,t.name,t.lang))&&(n.mode="disabled")}n&&(n.groupId=t.groupId,r.textTracks.push(n))}))}else if(!a&&this.tracks&&this.tracks.length){var f=this.tracks.map((function(t){return{label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}}));this.hls.trigger(e.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:f})}}},i._captionsOrSubtitlesFromCharacteristics=function(t){var i;if(null!==(i=t.attrs)&&void 0!==i&&i.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),n=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(r&&n)return"captions"}return"subtitles"},i.onManifestLoaded=function(t,i){var r=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach((function(t){var i=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(i){var n=r.captionsProperties["textTrack"+i[1]];n&&(n.label=t.name,t.lang&&(n.languageCode=t.lang),n.media=t)}}))},i.closedCaptionsForLevel=function(t){var i=this.hls.levels[t.level];return null==i?void 0:i.attrs["CLOSED-CAPTIONS"]},i.onFragLoading=function(t,i){var r=this.cea608Parser1,n=this.cea608Parser2,e=this.lastSn;if(this.enabled&&r&&n&&i.frag.type===c.PlaylistLevelType.MAIN){var s,a,o=i.frag.sn,h=null!=(s=null==i||null===(a=i.part)||void 0===a?void 0:a.index)?s:-1;o===e+1||o===e&&h===this.lastPartIndex+1||(r.reset(),n.reset()),this.lastSn=o,this.lastPartIndex=h}},i.onFragLoaded=function(t,i){var r=i.frag,s=i.payload,a=this.initPTS,o=this.unparsedVttFrags;if(r.type===c.PlaylistLevelType.SUBTITLE)if(s.byteLength){if(!(0,n.isFiniteNumber)(a[r.cc]))return o.push(i),void(a.length&&this.hls.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")}));var h=r.decryptdata;if(null==h||!h.encrypted||"stats"in i){var f=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),f&&f.textCodec===u.IMSC1_CODEC?this._parseIMSC1(r,s):this._parseVTTs(r,s,l)}}else this.hls.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},i._parseIMSC1=function(t,i){var r=this,n=this.hls;(0,u.parseIMSC1)(i,this.initPTS[t.cc],this.timescale[t.cc],(function(i){r._appendCues(i,t.level),n.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(i){l.logger.log("Failed to parse IMSC1: "+i),n.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:i})}))},i._parseVTTs=function(t,i,r){var n,s=this,a=this.hls,h=null!==(n=t.initSegment)&&void 0!==n&&n.data?(0,f.appendUint8Array)(t.initSegment.data,new Uint8Array(i)):i;(0,o.parseWebVTT)(h,this.initPTS[t.cc],this.timescale[t.cc],r,t.cc,t.start,(function(i){s._appendCues(i,t.level),a.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(r){s._fallbackToIMSC1(t,i),l.logger.log("Failed to parse VTT cue: "+r),a.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:r})}))},i._fallbackToIMSC1=function(t,i){var r=this,n=this.tracks[t.level];n.textCodec||(0,u.parseIMSC1)(i,this.initPTS[t.cc],this.timescale[t.cc],(function(){n.textCodec=u.IMSC1_CODEC,r._parseIMSC1(t,i)}),(function(){n.textCodec="wvtt"}))},i._appendCues=function(t,i){var r=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[i];if(!n||"disabled"===n.mode)return;t.forEach((function(t){return(0,h.addCueToTrack)(n,t)}))}else{var s=this.tracks[i];if(!s)return;r.trigger(e.Events.CUES_PARSED,{type:"subtitles",cues:t,track:s.default?"default":"subtitles"+i})}},i.onFragDecrypted=function(t,i){var r=i.frag;if(r.type===c.PlaylistLevelType.SUBTITLE){if(!(0,n.isFiniteNumber)(this.initPTS[r.cc]))return void this.unparsedVttFrags.push(i);this.onFragLoaded(e.Events.FRAG_LOADED,i)}},i.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},i.onFragParsingUserdata=function(t,i){var r=this.cea608Parser1,n=this.cea608Parser2;if(this.enabled&&r&&n){var e=i.frag,s=i.samples;if(e.type!==c.PlaylistLevelType.MAIN||"NONE"!==this.closedCaptionsForLevel(e))for(var a=0;a<s.length;a++){var o=s[a].bytes;if(o){var h=this.extractCea608Data(o);r.addData(s[a].pts,h[0]),n.addData(s[a].pts,h[1])}}}},i.onBufferFlushing=function(t,i){var r=i.startOffset,n=i.endOffset,e=i.endOffsetSubtitles,s=i.type,a=this.media;if(a&&!(a.currentTime<n)){if(!s||"video"===s){var o=this.captionsTracks;Object.keys(o).forEach((function(t){return(0,h.removeCuesInRange)(o[t],r,n)}))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==e){var u=this.textTracks;Object.keys(u).forEach((function(t){return(0,h.removeCuesInRange)(u[t],r,e)}))}}},i.extractCea608Data=function(t){for(var i=[[],[]],r=31&t[0],n=2,e=0;e<r;e++){var s=t[n++],a=127&t[n++],o=127&t[n++];if((0!==a||0!==o)&&0!=(4&s)){var h=3&s;0!==h&&1!==h||(i[h].push(a),i[h].push(o))}}return i},t}();function d(t,i){return t&&t.label===i.name&&!(t.textTrack1||t.textTrack2)}},"./src/crypt/aes-crypto.ts":
|
|
71
|
-
/*!*********************************!*\
|
|
72
|
-
!*** ./src/crypt/aes-crypto.ts ***!
|
|
73
|
-
\*********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>n});var n=function(){function t(t,i){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=i}return t.prototype.decrypt=function(t,i){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},i,t)},t}()},"./src/crypt/aes-decryptor.ts":
|
|
74
|
-
/*!************************************!*\
|
|
75
|
-
!*** ./src/crypt/aes-decryptor.ts ***!
|
|
76
|
-
\************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>s,removePadding:()=>e});var n=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function e(t){var i=t.byteLength,r=i&&new DataView(t.buffer).getUint8(i-1);return r?(0,n.sliceUint8)(t,0,i-r):t}var s=function(){function t(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var i=t.prototype;return i.uint8ArrayToUint32Array_=function(t){for(var i=new DataView(t),r=new Uint32Array(4),n=0;n<4;n++)r[n]=i.getUint32(4*n);return r},i.initTable=function(){var t=this.sBox,i=this.invSBox,r=this.subMix,n=r[0],e=r[1],s=r[2],a=r[3],o=this.invSubMix,h=o[0],u=o[1],f=o[2],c=o[3],l=new Uint32Array(256),v=0,d=0,m=0;for(m=0;m<256;m++)l[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){var p=d^d<<1^d<<2^d<<3^d<<4;t[v]=p=p>>>8^255&p^99,i[p]=v;var y=l[v],g=l[y],b=l[g],w=257*l[p]^16843008*p;n[v]=w<<24|w>>>8,e[v]=w<<16|w>>>16,s[v]=w<<8|w>>>24,a[v]=w,h[p]=(w=16843009*b^65537*g^257*y^16843008*v)<<24|w>>>8,u[p]=w<<16|w>>>16,f[p]=w<<8|w>>>24,c[p]=w,v?(v=y^l[l[l[b^y]]],d^=l[l[d]]):v=d=1}},i.expandKey=function(t){for(var i=this.uint8ArrayToUint32Array_(t),r=!0,n=0;n<i.length&&r;)r=i[n]===this.key[n],n++;if(!r){this.key=i;var e=this.keySize=i.length;if(4!==e&&6!==e&&8!==e)throw new Error("Invalid aes key size="+e);var s,a,o,h,u=this.ksRows=4*(e+6+1),f=this.keySchedule=new Uint32Array(u),c=this.invKeySchedule=new Uint32Array(u),l=this.sBox,v=this.rcon,d=this.invSubMix,m=d[0],p=d[1],y=d[2],g=d[3];for(s=0;s<u;s++)s<e?o=f[s]=i[s]:(h=o,s%e==0?(h=l[(h=h<<8|h>>>24)>>>24]<<24|l[h>>>16&255]<<16|l[h>>>8&255]<<8|l[255&h],h^=v[s/e|0]<<24):e>6&&s%e==4&&(h=l[h>>>24]<<24|l[h>>>16&255]<<16|l[h>>>8&255]<<8|l[255&h]),f[s]=o=(f[s-e]^h)>>>0);for(a=0;a<u;a++)s=u-a,h=3&a?f[s]:f[s-4],c[a]=a<4||s<=4?h:m[l[h>>>24]]^p[l[h>>>16&255]]^y[l[h>>>8&255]]^g[l[255&h]],c[a]=c[a]>>>0}},i.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},i.decrypt=function(t,i,r){for(var n,e,s,a,o,h,u,f,c,l,v,d,m,p=this.keySize+6,y=this.invKeySchedule,g=this.invSBox,b=this.invSubMix,w=b[0],k=b[1],S=b[2],T=b[3],E=this.uint8ArrayToUint32Array_(r),A=E[0],M=E[1],x=E[2],O=E[3],D=new Int32Array(t),I=new Int32Array(D.length),C=this.networkToHostOrderSwap;i<D.length;){for(f=C(D[i]),c=C(D[i+1]),l=C(D[i+2]),v=C(D[i+3]),a=f^y[0],o=v^y[1],h=l^y[2],u=c^y[3],d=4,m=1;m<p;m++)n=w[o>>>24]^k[h>>16&255]^S[u>>8&255]^T[255&a]^y[d+1],e=w[h>>>24]^k[u>>16&255]^S[a>>8&255]^T[255&o]^y[d+2],s=w[u>>>24]^k[a>>16&255]^S[o>>8&255]^T[255&h]^y[d+3],a=w[a>>>24]^k[o>>16&255]^S[h>>8&255]^T[255&u]^y[d],o=n,h=e,u=s,d+=4;n=g[o>>>24]<<24^g[h>>16&255]<<16^g[u>>8&255]<<8^g[255&a]^y[d+1],e=g[h>>>24]<<24^g[u>>16&255]<<16^g[a>>8&255]<<8^g[255&o]^y[d+2],s=g[u>>>24]<<24^g[a>>16&255]<<16^g[o>>8&255]<<8^g[255&h]^y[d+3],I[i]=C(g[a>>>24]<<24^g[o>>16&255]<<16^g[h>>8&255]<<8^g[255&u]^y[d]^A),I[i+1]=C(s^M),I[i+2]=C(e^x),I[i+3]=C(n^O),A=f,M=c,x=l,O=v,i+=4}return I.buffer},t}()},"./src/crypt/decrypter.ts":
|
|
77
|
-
/*!********************************!*\
|
|
78
|
-
!*** ./src/crypt/decrypter.ts ***!
|
|
79
|
-
\********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>u});var n=r(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts"),e=r(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts"),s=r(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),u=function(){function t(t,i){var r=(void 0===i?{}:i).removePKCS7Padding,n=void 0===r||r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=n,n)try{var e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(t){}null===this.subtle&&(this.useSoftware=!0)}var i=t.prototype;return i.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},i.isSync=function(){return this.useSoftware},i.flush=function(){var t=this.currentResult;if(!t||this.remainderData)return this.reset(),null;var i=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?(0,s.removePadding)(i):i},i.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},i.decrypt=function(t,i,r){var n=this;return this.useSoftware?new Promise((function(e,s){n.softwareDecrypt(new Uint8Array(t),i,r);var a=n.flush();a?e(a.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(t),i,r)},i.softwareDecrypt=function(t,i,r){var n=this.currentIV,e=this.currentResult,a=this.remainderData;this.logOnce("JS AES decrypt"),a&&(t=(0,o.appendUint8Array)(a,t),this.remainderData=null);var u=this.getValidChunk(t);if(!u.length)return null;n&&(r=n);var f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new s.default),f.expandKey(i);var c=e;return this.currentResult=f.decrypt(u.buffer,0,r),this.currentIV=(0,h.sliceUint8)(u,-16).buffer,c||null},i.webCryptoDecrypt=function(t,i,r){var s=this,o=this.subtle;return this.key===i&&this.fastAesKey||(this.key=i,this.fastAesKey=new e.default(o,i)),this.fastAesKey.expandKey().then((function(i){return o?(s.logOnce("WebCrypto AES decrypt"),new n.default(o,new Uint8Array(r)).decrypt(t.buffer,i)):Promise.reject(new Error("web crypto not initialized"))})).catch((function(n){return a.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+n.name+": "+n.message),s.onWebCryptoError(t,i,r)}))},i.onWebCryptoError=function(t,i,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,i,r);var n=this.flush();if(n)return n.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},i.getValidChunk=function(t){var i=t,r=t.length-t.length%16;return r!==t.length&&(i=(0,h.sliceUint8)(t,0,r),this.remainderData=(0,h.sliceUint8)(t,r)),i},i.logOnce=function(t){this.logEnabled&&(a.logger.log("[decrypter]: "+t),this.logEnabled=!1)},t}()},"./src/crypt/fast-aes-key.ts":
|
|
80
|
-
/*!***********************************!*\
|
|
81
|
-
!*** ./src/crypt/fast-aes-key.ts ***!
|
|
82
|
-
\***********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>n});var n=function(){function t(t,i){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=i}return t.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}()},"./src/demux/aacdemuxer.ts":
|
|
83
|
-
/*!*********************************!*\
|
|
84
|
-
!*** ./src/demux/aacdemuxer.ts ***!
|
|
85
|
-
\*********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>h});var n=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),e=r(/*! ./adts */"./src/demux/adts.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts");function o(t,i){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},o(t,i)}const h=function(t){var i,r;function n(i,r){var n;return(n=t.call(this)||this).observer=void 0,n.config=void 0,n.observer=i,n.config=r,n}r=t,(i=n).prototype=Object.create(r.prototype),i.prototype.constructor=i,o(i,r);var h=n.prototype;return h.resetInitSegment=function(i,r,n,e){t.prototype.resetInitSegment.call(this,i,r,n,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:e,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var i=(a.getID3Data(t,0)||[]).length,r=t.length;i<r;i++)if(e.probe(t,i))return s.logger.log("ADTS sync word found !"),!0;return!1},h.canParse=function(t,i){return e.canParse(t,i)},h.appendFrame=function(t,i,r){e.initTrackConfig(t,this.observer,i,r,t.manifestCodec);var n=e.appendFrame(t,i,r,this.basePTS,this.frameIndex);if(n&&0===n.missing)return n},n}(n.default)},"./src/demux/adts.ts":
|
|
86
|
-
/*!***************************!*\
|
|
87
|
-
!*** ./src/demux/adts.ts ***!
|
|
88
|
-
\***************************/(t,i,r)=>{r.r(i),r.d(i,{appendFrame:()=>y,canGetFrameLength:()=>f,canParse:()=>l,getAudioConfig:()=>a,getFrameDuration:()=>m,getFullFrameLength:()=>u,getHeaderLength:()=>h,initTrackConfig:()=>d,isHeader:()=>c,isHeaderPattern:()=>o,parseFrameHeader:()=>p,probe:()=>v});var n=r(/*! ../utils/logger */"./src/utils/logger.ts"),e=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../events */"./src/events.ts");function a(t,i,r,a){var o,h,u,f,c=navigator.userAgent.toLowerCase(),l=a,v=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=1+((192&i[r+2])>>>6);var d=(60&i[r+2])>>>2;if(!(d>v.length-1))return u=(1&i[r+2])<<2,u|=(192&i[r+3])>>>6,n.logger.log("manifest codec:"+a+", ADTS type:"+o+", samplingIndex:"+d),/firefox/i.test(c)?d>=6?(o=5,f=new Array(4),h=d-3):(o=2,f=new Array(2),h=d):-1!==c.indexOf("android")?(o=2,f=new Array(2),h=d):(o=5,f=new Array(4),a&&(-1!==a.indexOf("mp4a.40.29")||-1!==a.indexOf("mp4a.40.5"))||!a&&d>=6?h=d-3:((a&&-1!==a.indexOf("mp4a.40.2")&&(d>=6&&1===u||/vivaldi/i.test(c))||!a&&1===u)&&(o=2,f=new Array(2)),h=d)),f[0]=o<<3,f[0]|=(14&d)>>1,f[1]|=(1&d)<<7,f[1]|=u<<3,5===o&&(f[1]|=(14&h)>>1,f[2]=(1&h)<<7,f[2]|=8,f[3]=0),{config:f,samplerate:v[d],channelCount:u,codec:"mp4a.40."+o,manifestCodec:l};t.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d})}function o(t,i){return 255===t[i]&&240==(246&t[i+1])}function h(t,i){return 1&t[i+1]?7:9}function u(t,i){return(3&t[i+3])<<11|t[i+4]<<3|(224&t[i+5])>>>5}function f(t,i){return i+5<t.length}function c(t,i){return i+1<t.length&&o(t,i)}function l(t,i){return f(t,i)&&o(t,i)&&u(t,i)<=t.length-i}function v(t,i){if(c(t,i)){var r=h(t,i);if(i+r>=t.length)return!1;var n=u(t,i);if(n<=r)return!1;var e=i+n;return e===t.length||c(t,e)}return!1}function d(t,i,r,e,s){if(!t.samplerate){var o=a(i,r,e,s);if(!o)return;t.config=o.config,t.samplerate=o.samplerate,t.channelCount=o.channelCount,t.codec=o.codec,t.manifestCodec=o.manifestCodec,n.logger.log("parsed codec:"+t.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function m(t){return 9216e4/t}function p(t,i){var r=h(t,i);if(i+r<=t.length){var n=u(t,i)-r;if(n>0)return{headerLength:r,frameLength:n}}}function y(t,i,r,n,e){var s,a=n+e*m(t.samplerate),o=p(i,r);if(o){var h=o.headerLength,u=h+o.frameLength,f=Math.max(0,r+u-i.length);f?(s=new Uint8Array(u-h)).set(i.subarray(r+h,i.length),0):s=i.subarray(r+h,r+u);var c={unit:s,pts:a};return f||t.samples.push(c),{sample:c,length:u,missing:f}}var l=i.length-r;return(s=new Uint8Array(l)).set(i.subarray(r,i.length),0),{sample:{unit:s,pts:a},length:l,missing:-1}}},"./src/demux/base-audio-demuxer.ts":
|
|
89
|
-
/*!*****************************************!*\
|
|
90
|
-
!*** ./src/demux/base-audio-demuxer.ts ***!
|
|
91
|
-
\*****************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>c,initPTSFn:()=>f});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=r(/*! ../types/demuxer */"./src/types/demuxer.ts"),a=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),u=function(){function t(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var i=t.prototype;return i.resetInitSegment=function(){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},i.resetTimeStamp=function(t){this.initPTS=t,this.resetContiguity()},i.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},i.canParse=function(){return!1},i.appendFrame=function(){},i.demux=function(t,i){this.cachedData&&(t=(0,o.appendUint8Array)(this.cachedData,t),this.cachedData=null);var r,u=e.getID3Data(t,0),c=u?u.length:0,l=this._audioTrack,v=this._id3Track,d=u?e.getTimeStamp(u):void 0,m=t.length;for((null===this.basePTS||0===this.frameIndex&&(0,n.isFiniteNumber)(d))&&(this.basePTS=f(d,i,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),u&&u.length>0&&v.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:u,type:s.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});c<m;){if(this.canParse(t,c)){var p=this.appendFrame(l,t,c);p?(this.frameIndex++,this.lastPTS=p.sample.pts,r=c+=p.length):c=m}else e.canParse(t,c)?(u=e.getID3Data(t,c),v.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:u,type:s.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),r=c+=u.length):c++;if(c===m&&r!==m){var y=(0,h.sliceUint8)(t,r);this.cachedData=this.cachedData?(0,o.appendUint8Array)(this.cachedData,y):y}}return{audioTrack:l,videoTrack:(0,a.dummyTrack)(),id3Track:v,textTrack:(0,a.dummyTrack)()}},i.demuxSampleAes=function(){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},i.flush=function(){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:(0,a.dummyTrack)(),id3Track:this._id3Track,textTrack:(0,a.dummyTrack)()}},i.destroy=function(){},t}(),f=function(t,i,r){return(0,n.isFiniteNumber)(t)?90*t:9e4*i+(r||0)};const c=u},"./src/demux/chunk-cache.ts":
|
|
92
|
-
/*!**********************************!*\
|
|
93
|
-
!*** ./src/demux/chunk-cache.ts ***!
|
|
94
|
-
\**********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>n});var n=function(){function t(){this.chunks=[],this.dataLength=0}var i=t.prototype;return i.push=function(t){this.chunks.push(t),this.dataLength+=t.length},i.flush=function(){var t,i=this.chunks;return i.length?(t=1===i.length?i[0]:function(t,i){for(var r=new Uint8Array(i),n=0,e=0;e<t.length;e++){var s=t[e];r.set(s,n),n+=s.length}return r}(i,this.dataLength),this.reset(),t):new Uint8Array(0)},i.reset=function(){this.chunks.length=0,this.dataLength=0},t}()},"./src/demux/dummy-demuxed-track.ts":
|
|
95
|
-
/*!******************************************!*\
|
|
96
|
-
!*** ./src/demux/dummy-demuxed-track.ts ***!
|
|
97
|
-
\******************************************/(t,i,r)=>{function n(t,i){return void 0===t&&(t=""),void 0===i&&(i=9e4),{type:t,id:-1,pid:-1,inputTimeScale:i,sequenceNumber:-1,samples:[],dropped:0}}r.r(i),r.d(i,{dummyTrack:()=>n})},"./src/demux/exp-golomb.ts":
|
|
98
|
-
/*!*********************************!*\
|
|
99
|
-
!*** ./src/demux/exp-golomb.ts ***!
|
|
100
|
-
\*********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>e});var n=r(/*! ../utils/logger */"./src/utils/logger.ts");const e=function(){function t(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}var i=t.prototype;return i.loadWord=function(){var t=this.data,i=this.bytesAvailable,r=t.byteLength-i,n=new Uint8Array(4),e=Math.min(4,i);if(0===e)throw new Error("no bytes available");n.set(t.subarray(r,r+e)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*e,this.bytesAvailable-=e},i.skipBits=function(t){var i;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,t-=(i=t>>3)<<3,this.bytesAvailable-=i,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},i.readBits=function(t){var i=Math.min(this.bitsAvailable,t),r=this.word>>>32-i;if(t>32&&n.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=i,this.bitsAvailable>0)this.word<<=i;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(i=t-i)>0&&this.bitsAvailable?r<<i|this.readBits(i):r},i.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if(0!=(this.word&2147483648>>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},i.skipUEG=function(){this.skipBits(1+this.skipLZ())},i.skipEG=function(){this.skipBits(1+this.skipLZ())},i.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},i.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},i.readBoolean=function(){return 1===this.readBits(1)},i.readUByte=function(){return this.readBits(8)},i.readUShort=function(){return this.readBits(16)},i.readUInt=function(){return this.readBits(32)},i.skipScalingList=function(t){for(var i=8,r=8,n=0;n<t;n++)0!==r&&(r=(i+this.readEG()+256)%256),i=0===r?i:r},i.readSPS=function(){var t,i,r,n=0,e=0,s=0,a=0,o=this.readUByte.bind(this),h=this.readBits.bind(this),u=this.readUEG.bind(this),f=this.readBoolean.bind(this),c=this.skipBits.bind(this),l=this.skipEG.bind(this),v=this.skipUEG.bind(this),d=this.skipScalingList.bind(this);o();var m=o();if(h(5),c(3),o(),v(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){var p=u();if(3===p&&c(1),v(),v(),c(1),f())for(i=3!==p?8:12,r=0;r<i;r++)f()&&d(r<6?16:64)}v();var y=u();if(0===y)u();else if(1===y)for(c(1),l(),l(),t=u(),r=0;r<t;r++)l();v(),c(1);var g=u(),b=u(),w=h(1);0===w&&c(1),c(1),f()&&(n=u(),e=u(),s=u(),a=u());var k=[1,1];if(f()&&f())switch(o()){case 1:k=[1,1];break;case 2:k=[12,11];break;case 3:k=[10,11];break;case 4:k=[16,11];break;case 5:k=[40,33];break;case 6:k=[24,11];break;case 7:k=[20,11];break;case 8:k=[32,11];break;case 9:k=[80,33];break;case 10:k=[18,11];break;case 11:k=[15,11];break;case 12:k=[64,33];break;case 13:k=[160,99];break;case 14:k=[4,3];break;case 15:k=[3,2];break;case 16:k=[2,1];break;case 255:k=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(g+1)-2*n-2*e),height:(2-w)*(b+1)*16-(w?2:4)*(s+a),pixelRatio:k}},i.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},t}()},"./src/demux/id3.ts":
|
|
101
|
-
/*!**************************!*\
|
|
102
|
-
!*** ./src/demux/id3.ts ***!
|
|
103
|
-
\**************************/(t,i,r)=>{r.r(i),r.d(i,{canParse:()=>h,decodeFrame:()=>v,getID3Data:()=>a,getID3Frames:()=>l,getTimeStamp:()=>u,isFooter:()=>s,isHeader:()=>e,isTimeStampFrame:()=>f,testables:()=>b,utf8ArrayToStr:()=>g});var n,e=function(t,i){return i+10<=t.length&&73===t[i]&&68===t[i+1]&&51===t[i+2]&&t[i+3]<255&&t[i+4]<255&&t[i+6]<128&&t[i+7]<128&&t[i+8]<128&&t[i+9]<128},s=function(t,i){return i+10<=t.length&&51===t[i]&&68===t[i+1]&&73===t[i+2]&&t[i+3]<255&&t[i+4]<255&&t[i+6]<128&&t[i+7]<128&&t[i+8]<128&&t[i+9]<128},a=function(t,i){for(var r=i,n=0;e(t,i);)n+=10,n+=o(t,i+6),s(t,i+10)&&(n+=10),i+=n;if(n>0)return t.subarray(r,r+n)},o=function(t,i){var r=0;return r=(127&t[i])<<21,r|=(127&t[i+1])<<14,(r|=(127&t[i+2])<<7)|127&t[i+3]},h=function(t,i){return e(t,i)&&o(t,i+6)+10<=t.length-i},u=function(t){for(var i=l(t),r=0;r<i.length;r++){var n=i[r];if(f(n))return y(n)}},f=function(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info},c=function(t){var i=String.fromCharCode(t[0],t[1],t[2],t[3]),r=o(t,4);return{type:i,size:r,data:t.subarray(10,10+r)}},l=function(t){for(var i=0,r=[];e(t,i);){for(var n=o(t,i+6),a=(i+=10)+n;i+8<a;){var h=c(t.subarray(i)),u=v(h);u&&r.push(u),i+=h.size+10}s(t,i)&&(i+=10)}return r},v=function(t){return"PRIV"===t.type?d(t):"W"===t.type[0]?p(t):m(t)},d=function(t){if(!(t.size<2)){var i=g(t.data,!0),r=new Uint8Array(t.data.subarray(i.length+1));return{key:t.type,info:i,data:r.buffer}}},m=function(t){if(!(t.size<2)){if("TXXX"===t.type){var i=1,r=g(t.data.subarray(i),!0),n=g(t.data.subarray(i+=r.length+1));return{key:t.type,info:r,data:n}}var e=g(t.data.subarray(1));return{key:t.type,data:e}}},p=function(t){if("WXXX"===t.type){if(t.size<2)return;var i=1,r=g(t.data.subarray(i),!0),n=g(t.data.subarray(i+=r.length+1));return{key:t.type,info:r,data:n}}var e=g(t.data);return{key:t.type,data:e}},y=function(t){if(8===t.data.byteLength){var i=new Uint8Array(t.data),r=(i[4]<<23)+(i[5]<<15)+(i[6]<<7)+i[7];return r/=45,1&i[3]&&(r+=47721858.84),Math.round(r)}},g=function(t,i){void 0===i&&(i=!1);var r=w();if(r){var n=r.decode(t);if(i){var e=n.indexOf("\0");return-1!==e?n.substring(0,e):n}return n.replace(/\0/g,"")}for(var s,a,o,h=t.length,u="",f=0;f<h;){if(0===(s=t[f++])&&i)return u;if(0!==s&&3!==s)switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(s);break;case 12:case 13:a=t[f++],u+=String.fromCharCode((31&s)<<6|63&a);break;case 14:a=t[f++],o=t[f++],u+=String.fromCharCode((15&s)<<12|(63&a)<<6|(63&o)<<0)}}return u},b={decodeTextFrame:m};function w(){return n||void 0===self.TextDecoder||(n=new self.TextDecoder("utf-8")),n}},"./src/demux/mp3demuxer.ts":
|
|
104
|
-
/*!*********************************!*\
|
|
105
|
-
!*** ./src/demux/mp3demuxer.ts ***!
|
|
106
|
-
\*********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>u});var n=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),e=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function o(t,i){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},o(t,i)}var h=function(t){var i,r;function n(){return t.apply(this,arguments)||this}r=t,(i=n).prototype=Object.create(r.prototype),i.prototype.constructor=i,o(i,r);var h=n.prototype;return h.resetInitSegment=function(i,r,n,e){t.prototype.resetInitSegment.call(this,i,r,n,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:e,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var i=(e.getID3Data(t,0)||[]).length,r=t.length;i<r;i++)if(a.probe(t,i))return s.logger.log("MPEG Audio sync word found !"),!0;return!1},h.canParse=function(t,i){return a.canParse(t,i)},h.appendFrame=function(t,i,r){if(null!==this.basePTS)return a.appendFrame(t,i,r,this.basePTS,this.frameIndex)},n}(n.default);const u=h},"./src/demux/mp4demuxer.ts":
|
|
107
|
-
/*!*********************************!*\
|
|
108
|
-
!*** ./src/demux/mp4demuxer.ts ***!
|
|
109
|
-
\*********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>h});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ../types/demuxer */"./src/types/demuxer.ts"),s=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),a=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),o=/\/emsg[-/]ID3/i;const h=function(){function t(t,i){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=i}var i=t.prototype;return i.resetTimeStamp=function(){},i.resetInitSegment=function(t,i,r,n){var e=this.videoTrack=(0,a.dummyTrack)("video",1),o=this.audioTrack=(0,a.dummyTrack)("audio",1),h=this.txtTrack=(0,a.dummyTrack)("text",1);if(this.id3Track=(0,a.dummyTrack)("id3",1),this.timeOffset=0,t&&t.byteLength){var u=(0,s.parseInitSegment)(t);if(u.video){var f=u.video,c=f.timescale,l=f.codec;e.id=f.id,e.timescale=h.timescale=c,e.codec=l}if(u.audio){var v=u.audio,d=v.timescale,m=v.codec;o.id=v.id,o.timescale=d,o.codec=m}h.id=s.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=o.duration=n}},i.resetContiguity=function(){},t.probe=function(t){return t=t.length>16384?t.subarray(0,16384):t,(0,s.findBox)(t,["moof"]).length>0},i.demux=function(t,i){this.timeOffset=i;var r=t,n=this.videoTrack,e=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=(0,s.appendUint8Array)(this.remainderData,t));var a=(0,s.segmentValidRange)(r);this.remainderData=a.remainder,n.samples=a.valid||new Uint8Array}else n.samples=r;var o=this.extractID3Track(n,i);return e.samples=(0,s.parseSamples)(i,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},i.flush=function(){var t=this.timeOffset,i=this.videoTrack,r=this.txtTrack;i.samples=this.remainderData||new Uint8Array,this.remainderData=null;var n=this.extractID3Track(i,this.timeOffset);return r.samples=(0,s.parseSamples)(t,i),{videoTrack:i,audioTrack:(0,a.dummyTrack)(),id3Track:n,textTrack:(0,a.dummyTrack)()}},i.extractID3Track=function(t,i){var r=this.id3Track;if(t.samples.length){var a=(0,s.findBox)(t.samples,["emsg"]);a&&a.forEach((function(t){var a=(0,s.parseEmsg)(t);if(o.test(a.schemeIdUri)){var h=(0,n.isFiniteNumber)(a.presentationTime)?a.presentationTime/a.timeScale:i+a.presentationTimeDelta/a.timeScale,u=4294967295===a.eventDuration?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;u<=.001&&(u=Number.POSITIVE_INFINITY);var f=a.payload;r.samples.push({data:f,len:f.byteLength,dts:h,pts:h,type:e.MetadataSchema.emsg,duration:u})}}))}return r},i.demuxSampleAes=function(){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},i.destroy=function(){},t}()},"./src/demux/mpegaudio.ts":
|
|
110
|
-
/*!********************************!*\
|
|
111
|
-
!*** ./src/demux/mpegaudio.ts ***!
|
|
112
|
-
\********************************/(t,i,r)=>{r.r(i),r.d(i,{appendFrame:()=>h,canParse:()=>l,isHeader:()=>c,isHeaderPattern:()=>f,parseHeader:()=>u,probe:()=>v});var n=null,e=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],s=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],a=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],o=[0,1,1,4];function h(t,i,r,n,e){if(!(r+24>i.length)){var s=u(i,r);if(s&&r+s.frameLength<=i.length){var a=n+e*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:i.subarray(r,r+s.frameLength),pts:a,dts:a};return t.config=[],t.channelCount=s.channelCount,t.samplerate=s.sampleRate,t.samples.push(o),{sample:o,length:s.frameLength,missing:0}}}}function u(t,i){var r=t[i+1]>>3&3,h=t[i+1]>>1&3,u=t[i+2]>>4&15,f=t[i+2]>>2&3;if(1!==r&&0!==u&&15!==u&&3!==f){var c=t[i+3]>>6,l=1e3*e[14*(3===r?3-h:3===h?3:4)+u-1],v=s[3*(3===r?0:2===r?1:2)+f],d=3===c?1:2,m=a[r][h],p=o[h],y=8*m*p,g=Math.floor(m*l/v+(t[i+2]>>1&1))*p;if(null===n){var b=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);n=b?parseInt(b[1]):0}return!!n&&n<=87&&2===h&&l>=224e3&&0===c&&(t[i+3]=128|t[i+3]),{sampleRate:v,channelCount:d,frameLength:g,samplesPerFrame:y}}}function f(t,i){return 255===t[i]&&224==(224&t[i+1])&&0!=(6&t[i+1])}function c(t,i){return i+1<t.length&&f(t,i)}function l(t,i){return f(t,i)&&4<=t.length-i}function v(t,i){if(i+1<t.length&&f(t,i)){var r=u(t,i),n=4;null!=r&&r.frameLength&&(n=r.frameLength);var e=i+n;return e===t.length||c(t,e)}return!1}},"./src/demux/sample-aes.ts":
|
|
113
|
-
/*!*********************************!*\
|
|
114
|
-
!*** ./src/demux/sample-aes.ts ***!
|
|
115
|
-
\*********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>s});var n=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),e=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");const s=function(){function t(t,i,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new n.default(i,{removePKCS7Padding:!1})}var i=t.prototype;return i.decryptBuffer=function(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)},i.decryptAacSample=function(t,i,r){var n=this,e=t[i].unit;if(!(e.length<=16)){var s=e.subarray(16,e.length-e.length%16),a=s.buffer.slice(s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(a).then((function(s){var a=new Uint8Array(s);e.set(a,16),n.decrypter.isSync()||n.decryptAacSamples(t,i+1,r)}))}},i.decryptAacSamples=function(t,i,r){for(;;i++){if(i>=t.length)return void r();if(!(t[i].unit.length<32||(this.decryptAacSample(t,i,r),this.decrypter.isSync())))return}},i.getAvcEncryptedData=function(t){for(var i=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(i),n=0,e=32;e<t.length-16;e+=160,n+=16)r.set(t.subarray(e,e+16),n);return r},i.getAvcDecryptedUnit=function(t,i){for(var r=new Uint8Array(i),n=0,e=32;e<t.length-16;e+=160,n+=16)t.set(r.subarray(n,n+16),e);return t},i.decryptAvcSample=function(t,i,r,n,s){var a=this,o=(0,e.discardEPB)(s.data),h=this.getAvcEncryptedData(o);this.decryptBuffer(h.buffer).then((function(e){s.data=a.getAvcDecryptedUnit(o,e),a.decrypter.isSync()||a.decryptAvcSamples(t,i,r+1,n)}))},i.decryptAvcSamples=function(t,i,r,n){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;i++,r=0){if(i>=t.length)return void n();for(var e=t[i].units;!(r>=e.length);r++){var s=e[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type||(this.decryptAvcSample(t,i,r,n,s),this.decrypter.isSync())))return}}},t}()},"./src/demux/transmuxer-interface.ts":
|
|
116
|
-
/*!*******************************************!*\
|
|
117
|
-
!*** ./src/demux/transmuxer-interface.ts ***!
|
|
118
|
-
\*******************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>c});var n=r(/*! ./webworkify-webpack */"./src/demux/webworkify-webpack.js"),e=r(/*! ../events */"./src/events.ts"),s=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../errors */"./src/errors.ts"),h=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),f=(0,h.getMediaSource)()||{isTypeSupported:function(){return!1}},c=function(){function t(t,i,r,h){var c=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var l=t.config;this.hls=t,this.id=i,this.useWorker=!!l.enableWorker,this.onTransmuxComplete=r,this.onFlush=h;var v=function(t,i){(i=i||{}).frag=c.frag,i.id=c.id,c.hls.trigger(t,i)};this.observer=new u.EventEmitter,this.observer.on(e.Events.FRAG_DECRYPTED,v),this.observer.on(e.Events.ERROR,v);var d={mp4:f.isTypeSupported("video/mp4"),mpeg:f.isTypeSupported("audio/mpeg"),mp3:f.isTypeSupported('audio/mp4; codecs="mp3"')},m=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker){var p;a.logger.log("demuxing in webworker");try{p=this.worker=(0,n.default)(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),p.addEventListener("message",this.onwmsg),p.onerror=function(t){c.useWorker=!1,a.logger.warn("Exception in webworker, fallback to inline"),c.hls.trigger(e.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:new Error(t.message+" ("+t.filename+":"+t.lineno+")")})},p.postMessage({cmd:"init",typeSupported:d,vendor:m,id:i,config:JSON.stringify(l)})}catch(t){a.logger.warn("Error in worker:",t),a.logger.error("Error while initializing DemuxerWorker, fallback to inline"),p&&self.URL.revokeObjectURL(p.objectURL),this.transmuxer=new s.default(this.observer,d,l,m,i),this.worker=null}}else this.transmuxer=new s.default(this.observer,d,l,m,i)}var i=t.prototype;return i.destroy=function(){var t=this.worker;if(t)t.removeEventListener("message",this.onwmsg),t.terminate(),this.worker=null,this.onwmsg=void 0;else{var i=this.transmuxer;i&&(i.destroy(),this.transmuxer=null)}var r=this.observer;r&&r.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},i.push=function(t,i,r,n,e,o,h,u,f,c){var l,v,d=this;f.transmuxing.start=self.performance.now();var m=this.transmuxer,p=this.worker,y=o?o.start:e.start,g=e.decryptdata,b=this.frag,w=!(b&&e.cc===b.cc),k=!(b&&f.level===b.level),S=b?f.sn-b.sn:-1,T=this.part?f.part-this.part.index:-1,E=!k&&(1===S||0===S&&(1===T||0===S&&f.id>1&&f.id===(null==b?void 0:b.stats.chunkCount)&&T<=0)),A=self.performance.now();(k||S||0===e.stats.parsing.start)&&(e.stats.parsing.start=A),!o||!T&&E||(o.stats.parsing.start=A);var M=!(b&&(null===(l=e.initSegment)||void 0===l?void 0:l.url)===(null===(v=b.initSegment)||void 0===v?void 0:v.url)),x=new s.TransmuxState(w,E,u,k,y,M);if(!E||w||M){a.logger.log("[transmuxer-interface, "+e.type+"]: Starting new transmux session for sn: "+f.sn+" p: "+f.part+" level: "+f.level+" id: "+f.id+"\n discontinuity: "+w+"\n trackSwitch: "+k+"\n contiguous: "+E+"\n accurateTimeOffset: "+u+"\n timeOffset: "+y+"\n initSegmentChange: "+M);var O=new s.TransmuxConfig(r,n,i,h,c);this.configureTransmuxer(O)}if(this.frag=e,this.part=o,p)p.postMessage({cmd:"demux",data:t,decryptdata:g,chunkMeta:f,state:x},t instanceof ArrayBuffer?[t]:[]);else if(m){var D=m.push(t,g,f,x);(0,s.isPromise)(D)?(m.async=!0,D.then((function(t){d.handleTransmuxComplete(t)})).catch((function(t){d.transmuxerError(t,f,"transmuxer-interface push error")}))):(m.async=!1,this.handleTransmuxComplete(D))}},i.flush=function(t){var i=this;t.transmuxing.start=self.performance.now();var r=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:t});else if(r){var e=r.flush(t);(0,s.isPromise)(e)||r.async?((0,s.isPromise)(e)||(e=Promise.resolve(e)),e.then((function(r){i.handleFlushResult(r,t)})).catch((function(r){i.transmuxerError(r,t,"transmuxer-interface flush error")}))):this.handleFlushResult(e,t)}},i.transmuxerError=function(t,i,r){this.hls&&this.hls.trigger(e.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:i,fatal:!1,error:t,err:t,reason:r})},i.handleFlushResult=function(t,i){var r=this;t.forEach((function(t){r.handleTransmuxComplete(t)})),this.onFlush(i)},i.onWorkerMessage=function(t){var i=t.data,r=this.hls;switch(i.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(i.data);break;case"flush":this.onFlush(i.data);break;case"workerLog":a.logger[i.data.logType]&&a.logger[i.data.logType](i.data.message);break;default:i.data=i.data||{},i.data.frag=this.frag,i.data.id=this.id,r.trigger(i.event,i.data)}},i.configureTransmuxer=function(t){var i=this.worker,r=this.transmuxer;i?i.postMessage({cmd:"configure",config:t}):r&&r.configure(t)},i.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},t}()},"./src/demux/transmuxer-worker.ts":
|
|
119
|
-
/*!****************************************!*\
|
|
120
|
-
!*** ./src/demux/transmuxer-worker.ts ***!
|
|
121
|
-
\****************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>h});var n=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),e=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),o=r(/*! ../errors */"./src/errors.ts");function h(t){var i=new a.EventEmitter,r=function(i,r){t.postMessage({event:i,data:r})};i.on(e.Events.FRAG_DECRYPTED,r),i.on(e.Events.ERROR,r),t.addEventListener("message",(function(a){var h=a.data;switch(h.cmd){case"init":var f=JSON.parse(h.config);t.transmuxer=new n.default(i,h.typeSupported,f,h.vendor,h.id),(0,s.enableLogs)(f.debug,h.id),function(){var t=function(t){s.logger[t]=function(i){r("workerLog",{logType:t,message:i})}};for(var i in s.logger)t(i)}(),r("init",null);break;case"configure":t.transmuxer.configure(h.config);break;case"demux":var l=t.transmuxer.push(h.data,h.decryptdata,h.chunkMeta,h.state);(0,n.isPromise)(l)?(t.transmuxer.async=!0,l.then((function(i){u(t,i)})).catch((function(t){r(e.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:h.chunkMeta,fatal:!1,error:t,err:t,reason:"transmuxer-worker push error"})}))):(t.transmuxer.async=!1,u(t,l));break;case"flush":var v=h.chunkMeta,d=t.transmuxer.flush(v);(0,n.isPromise)(d)||t.transmuxer.async?((0,n.isPromise)(d)||(d=Promise.resolve(d)),d.then((function(i){c(t,i,v)})).catch((function(t){r(e.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:h.chunkMeta,fatal:!1,error:t,err:t,reason:"transmuxer-worker flush error"})}))):c(t,d,v)}}))}function u(t,i){if(!((r=i.remuxResult).audio||r.video||r.text||r.id3||r.initSegment))return!1;var r,n=[],e=i.remuxResult,s=e.audio,a=e.video;return s&&f(n,s),a&&f(n,a),t.postMessage({event:"transmuxComplete",data:i},n),!0}function f(t,i){i.data1&&t.push(i.data1.buffer),i.data2&&t.push(i.data2.buffer)}function c(t,i,r){i.reduce((function(i,r){return u(t,r)||i}),!1)||t.postMessage({event:"transmuxComplete",data:i[0]}),t.postMessage({event:"flush",data:r})}},"./src/demux/transmuxer.ts":
|
|
122
|
-
/*!*********************************!*\
|
|
123
|
-
!*** ./src/demux/transmuxer.ts ***!
|
|
124
|
-
\*********************************/(t,i,r)=>{r.r(i),r.d(i,{TransmuxConfig:()=>g,TransmuxState:()=>b,default:()=>m,isPromise:()=>y});var n,e=r(/*! ../events */"./src/events.ts"),s=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),o=r(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts"),h=r(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts"),u=r(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts"),f=r(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts"),c=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),l=r(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts"),v=r(/*! ../utils/logger */"./src/utils/logger.ts");try{n=self.performance.now.bind(self.performance)}catch(t){v.logger.debug("Unable to use Performance API on this environment"),n=self.Date.now}var d=[{demux:h.default,remux:l.default},{demux:u.default,remux:c.default},{demux:o.default,remux:c.default},{demux:f.default,remux:c.default}],m=function(){function t(t,i,r,n,e){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=i,this.config=r,this.vendor=n,this.id=e}var i=t.prototype;return i.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},i.push=function(t,i,r,e){var s=this,a=r.transmuxing;a.executeStart=n();var o=new Uint8Array(t),h=this.currentTransmuxState,u=this.transmuxConfig;e&&(this.currentTransmuxState=e);var f=e||h,c=f.contiguous,l=f.discontinuity,v=f.trackSwitch,d=f.accurateTimeOffset,m=f.timeOffset,y=f.initSegmentChange,g=u.audioCodec,b=u.videoCodec,w=u.defaultInitPts,k=u.duration,S=u.initSegmentData,T=function(t,i){var r=null;return t.byteLength>0&&null!=i&&null!=i.key&&null!==i.iv&&null!=i.method&&(r=i),r}(o,i);if(T&&"AES-128"===T.method){var E=this.getDecrypter();if(!E.isSync())return this.decryptionPromise=E.webCryptoDecrypt(o,T.key.buffer,T.iv.buffer).then((function(t){var i=s.push(t,null,r);return s.decryptionPromise=null,i})),this.decryptionPromise;var A=E.softwareDecrypt(o,T.key.buffer,T.iv.buffer);if(r.part>-1&&(A=E.flush()),!A)return a.executeEnd=n(),p(r);o=new Uint8Array(A)}var M=this.needsProbing(l,v);M&&this.configureTransmuxer(o),(l||v||y||M)&&this.resetInitSegment(S,g,b,k,i),(l||y||M)&&this.resetInitialTimestamp(w),c||this.resetContiguity();var x=this.transmux(o,T,m,d,r),O=this.currentTransmuxState;return O.contiguous=!0,O.discontinuity=!1,O.trackSwitch=!1,a.executeEnd=n(),x},i.flush=function(t){var i=this,r=t.transmuxing;r.executeStart=n();var a=this.decrypter,o=this.currentTransmuxState,h=this.decryptionPromise;if(h)return h.then((function(){return i.flush(t)}));var u=[],f=o.timeOffset;if(a){var c=a.flush();c&&u.push(this.push(c,null,t))}var l=this.demuxer;if(!l||!this.remuxer)return this.observer.emit(e.Events.ERROR,e.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),r.executeEnd=n(),[p(t)];var v=l.flush(f);return y(v)?v.then((function(r){return i.flushRemux(u,r,t),u})):(this.flushRemux(u,v,t),u)},i.flushRemux=function(t,i,r){var e=i.audioTrack,s=i.videoTrack,a=i.id3Track,o=i.textTrack,h=this.currentTransmuxState,u=h.accurateTimeOffset,f=h.timeOffset;v.logger.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var c=this.remuxer.remux(e,s,a,o,f,u,!0,this.id);t.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=n()},i.resetInitialTimestamp=function(t){var i=this.demuxer,r=this.remuxer;i&&r&&(i.resetTimeStamp(t),r.resetTimeStamp(t))},i.resetContiguity=function(){var t=this.demuxer,i=this.remuxer;t&&i&&(t.resetContiguity(),i.resetNextTimestamp())},i.resetInitSegment=function(t,i,r,n,e){var s=this.demuxer,a=this.remuxer;s&&a&&(s.resetInitSegment(t,i,r,n),a.resetInitSegment(t,i,r,e))},i.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},i.transmux=function(t,i,r,n,e){return i&&"SAMPLE-AES"===i.method?this.transmuxSampleAes(t,i,r,n,e):this.transmuxUnencrypted(t,r,n,e)},i.transmuxUnencrypted=function(t,i,r,n){var e=this.demuxer.demux(t,i,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,r,!1,this.id),chunkMeta:n}},i.transmuxSampleAes=function(t,i,r,n,e){var s=this;return this.demuxer.demuxSampleAes(t,i,r).then((function(t){return{remuxResult:s.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,r,n,!1,s.id),chunkMeta:e}}))},i.configureTransmuxer=function(t){for(var i,r=this.config,n=this.observer,e=this.typeSupported,s=this.vendor,a=0,o=d.length;a<o;a++)if(d[a].demux.probe(t)){i=d[a];break}i||(v.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),i={demux:h.default,remux:l.default});var u=this.demuxer,f=this.remuxer,c=i.remux,m=i.demux;f&&f instanceof c||(this.remuxer=new c(n,r,e,s)),u&&u instanceof m||(this.demuxer=new m(n,r,e),this.probe=m.probe)},i.needsProbing=function(t,i){return!this.demuxer||!this.remuxer||t||i},i.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new a.default(this.config)),t},t}(),p=function(t){return{remuxResult:{},chunkMeta:t}};function y(t){return"then"in t&&t.then instanceof Function}var g=function(t,i,r,n,e){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=i,this.initSegmentData=r,this.duration=n,this.defaultInitPts=e},b=function(t,i,r,n,e,s){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=i,this.accurateTimeOffset=r,this.trackSwitch=n,this.timeOffset=e,this.initSegmentChange=s}},"./src/demux/tsdemuxer.ts":
|
|
125
|
-
/*!********************************!*\
|
|
126
|
-
!*** ./src/demux/tsdemuxer.ts ***!
|
|
127
|
-
\********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>w});var n=r(/*! ./adts */"./src/demux/adts.ts"),e=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts"),s=r(/*! ./exp-golomb */"./src/demux/exp-golomb.ts"),a=r(/*! ./sample-aes */"./src/demux/sample-aes.ts"),o=r(/*! ../events */"./src/events.ts"),h=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),u=r(/*! ../utils/logger */"./src/utils/logger.ts"),f=r(/*! ../errors */"./src/errors.ts"),c=r(/*! ../types/demuxer */"./src/types/demuxer.ts");function l(){return l=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},l.apply(this,arguments)}var v=188;function d(t,i,r,n){return{key:t,frame:!1,pts:i,dts:r,units:[],debug:n,length:0}}function m(t,i){return((31&t[i+1])<<8)+t[i+2]}function p(t,i){return(31&t[i+10])<<8|t[i+11]}function y(t,i,r,n){var e={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},s=i+3+((15&t[i+1])<<8|t[i+2])-4;for(i+=12+((15&t[i+10])<<8|t[i+11]);i<s;){var a=m(t,i);switch(t[i]){case 207:if(!n){u.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===e.audio&&(e.audio=a);break;case 21:-1===e.id3&&(e.id3=a);break;case 219:if(!n){u.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===e.avc&&(e.avc=a);break;case 3:case 4:!0!==r.mpeg&&!0!==r.mp3?u.logger.log("MPEG audio found, not supported in this browser"):-1===e.audio&&(e.audio=a,e.segmentCodec="mp3");break;case 36:u.logger.warn("Unsupported HEVC stream type found")}i+=5+((15&t[i+3])<<8|t[i+4])}return e}function g(t){var i,r,n,e,s,a=0,o=t.data;if(!t||0===t.size)return null;for(;o[0].length<19&&o.length>1;){var h=new Uint8Array(o[0].length+o[1].length);h.set(o[0]),h.set(o[1],o[0].length),o[0]=h,o.splice(1,1)}if(1===((i=o[0])[0]<<16)+(i[1]<<8)+i[2]){if((r=(i[4]<<8)+i[5])&&r>t.size-6)return null;var f=i[7];192&f&&(e=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&f?e-(s=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2)>54e5&&(u.logger.warn(Math.round((e-s)/9e4)+"s delta between PTS and DTS, align them"),e=s):s=e);var c=(n=i[8])+9;if(t.size<=c)return null;t.size-=c;for(var l=new Uint8Array(t.size),v=0,d=o.length;v<d;v++){var m=(i=o[v]).byteLength;if(c){if(c>m){c-=m;continue}i=i.subarray(c),m-=c,c=0}l.set(i,a),a+=m}return r&&(r-=n+3),{data:l,pts:e,dts:s,len:r}}return null}function b(t,i){if(t.units.length&&t.frame){if(void 0===t.pts){var r=i.samples,n=r.length;if(!n)return void i.dropped++;var e=r[n-1];t.pts=e.pts,t.dts=e.dts}i.samples.push(t)}t.debug.length&&u.logger.log(t.pts+"/"+t.dts+":"+t.debug)}const w=function(){function t(t,i,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=i,this.typeSupported=r}t.probe=function(i){var r=t.syncOffset(i);return r>0&&u.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},t.syncOffset=function(t){for(var i=t.length,r=Math.min(940,t.length-v)+1,n=0;n<r;){for(var e=!1,s=n;s<i&&71===t[s];s+=v)if(e||0!==m(t,s)||(e=!0),e&&s+v>r)return n;n++}return-1},t.createTrack=function(t,i){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:h.RemuxerTrackIdConfig[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?i:void 0}};var i=t.prototype;return i.resetInitSegment=function(i,r,n,e){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=t.createTrack("video"),this._audioTrack=t.createTrack("audio",e),this._id3Track=t.createTrack("id3"),this._txtTrack=t.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=n,this._duration=e},i.resetTimeStamp=function(){},i.resetContiguity=function(){var t=this._audioTrack,i=this._avcTrack,r=this._id3Track;t&&(t.pesData=null),i&&(i.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},i.demux=function(i,r,n,e){var s;void 0===n&&(n=!1),void 0===e&&(e=!1),n||(this.sampleAes=null);var a=this._avcTrack,c=this._audioTrack,l=this._id3Track,d=this._txtTrack,b=a.pid,w=a.pesData,k=c.pid,S=l.pid,T=c.pesData,E=l.pesData,A=null,M=this.pmtParsed,x=this._pmtId,O=i.length;if(this.remainderData&&(O=(i=(0,h.appendUint8Array)(this.remainderData,i)).length,this.remainderData=null),O<v&&!e)return this.remainderData=i,{audioTrack:c,videoTrack:a,id3Track:l,textTrack:d};var D=Math.max(0,t.syncOffset(i));(O-=(O-D)%v)<i.byteLength&&!e&&(this.remainderData=new Uint8Array(i.buffer,O,i.buffer.byteLength-O));for(var I=0,C=D;C<O;C+=v)if(71===i[C]){var L=!!(64&i[C+1]),P=m(i,C),j=void 0;if((48&i[C+3])>>4>1){if((j=C+5+i[C+4])===C+v)continue}else j=C+4;switch(P){case b:L&&(w&&(s=g(w))&&this.parseAVCPES(a,d,s,!1),w={data:[],size:0}),w&&(w.data.push(i.subarray(j,C+v)),w.size+=C+v-j);break;case k:if(L){if(T&&(s=g(T)))switch(c.segmentCodec){case"aac":this.parseAACPES(c,s);break;case"mp3":this.parseMPEGPES(c,s)}T={data:[],size:0}}T&&(T.data.push(i.subarray(j,C+v)),T.size+=C+v-j);break;case S:L&&(E&&(s=g(E))&&this.parseID3PES(l,s),E={data:[],size:0}),E&&(E.data.push(i.subarray(j,C+v)),E.size+=C+v-j);break;case 0:L&&(j+=i[j]+1),x=this._pmtId=p(i,j);break;case x:L&&(j+=i[j]+1);var R=y(i,j,this.typeSupported,n);(b=R.avc)>0&&(a.pid=b),(k=R.audio)>0&&(c.pid=k,c.segmentCodec=R.segmentCodec),(S=R.id3)>0&&(l.pid=S),null===A||M||(u.logger.warn("MPEG-TS PMT found at "+C+" after unknown PID '"+A+"'. Backtracking to sync byte @"+D+" to parse all TS packets."),A=null,C=D-188),M=this.pmtParsed=!0;break;case 17:case 8191:break;default:A=P}}else I++;I>0&&this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+I+" TS packet/s that do not start with 0x47"}),a.pesData=w,c.pesData=T,l.pesData=E;var U={audioTrack:c,videoTrack:a,id3Track:l,textTrack:d};return e&&this.extractRemainingSamples(U),U},i.flush=function(){var t,i=this.remainderData;return this.remainderData=null,t=i?this.demux(i,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},i.extractRemainingSamples=function(t){var i,r=t.audioTrack,n=t.videoTrack,e=t.id3Track,s=t.textTrack,a=n.pesData,o=r.pesData,h=e.pesData;if(a&&(i=g(a))?(this.parseAVCPES(n,s,i,!0),n.pesData=null):n.pesData=a,o&&(i=g(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,i);break;case"mp3":this.parseMPEGPES(r,i)}r.pesData=null}else null!=o&&o.size&&u.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;h&&(i=g(h))?(this.parseID3PES(e,i),e.pesData=null):e.pesData=h},i.demuxSampleAes=function(t,i,r){var n=this.demux(t,r,!0,!this.config.progressive),e=this.sampleAes=new a.default(this.observer,this.config,i);return this.decrypt(n,e)},i.decrypt=function(t,i){return new Promise((function(r){var n=t.audioTrack,e=t.videoTrack;n.samples&&"aac"===n.segmentCodec?i.decryptAacSamples(n.samples,0,(function(){e.samples?i.decryptAvcSamples(e.samples,0,0,(function(){r(t)})):r(t)})):e.samples&&i.decryptAvcSamples(e.samples,0,0,(function(){r(t)}))}))},i.destroy=function(){this._duration=0},i.parseAVCPES=function(t,i,r,n){var e,a=this,o=this.parseAVCNALu(t,r.data),u=this.avcSample,f=!1;r.data=null,u&&o.length&&!t.audFound&&(b(u,t),u=this.avcSample=d(!1,r.pts,r.dts,"")),o.forEach((function(n){switch(n.type){case 1:e=!0,u||(u=a.avcSample=d(!0,r.pts,r.dts,"")),u.frame=!0;var o=n.data;if(f&&o.length>4){var c=new s.default(o).readSliceType();2!==c&&4!==c&&7!==c&&9!==c||(u.key=!0)}break;case 5:e=!0,u||(u=a.avcSample=d(!0,r.pts,r.dts,"")),u.key=!0,u.frame=!0;break;case 6:e=!0,(0,h.parseSEIMessageFromNALu)(n.data,1,r.pts,i.samples);break;case 7:if(e=!0,f=!0,!t.sps){var l=new s.default(n.data).readSPS();t.width=l.width,t.height=l.height,t.pixelRatio=l.pixelRatio,t.sps=[n.data],t.duration=a._duration;for(var v=n.data.subarray(1,4),m="avc1.",p=0;p<3;p++){var y=v[p].toString(16);y.length<2&&(y="0"+y),m+=y}t.codec=m}break;case 8:e=!0,t.pps||(t.pps=[n.data]);break;case 9:e=!1,t.audFound=!0,u&&b(u,t),u=a.avcSample=d(!1,r.pts,r.dts,"");break;case 12:e=!0;break;default:e=!1,u&&(u.debug+="unknown NAL "+n.type+" ")}u&&e&&u.units.push(n)})),n&&u&&(b(u,t),this.avcSample=null)},i.getLastNalUnit=function(t){var i,r,n=this.avcSample;if(n&&0!==n.units.length||(n=t[t.length-1]),null!==(i=n)&&void 0!==i&&i.units){var e=n.units;r=e[e.length-1]}return r},i.parseAVCNALu=function(t,i){var r,n,e=i.byteLength,s=t.naluState||0,a=s,o=[],h=0,u=-1,f=0;for(-1===s&&(u=0,f=31&i[0],s=0,h=1);h<e;)if(r=i[h++],s)if(1!==s)if(r)if(1===r){if(u>=0){var c={data:i.subarray(u,h-s-1),type:f};o.push(c)}else{var l=this.getLastNalUnit(t.samples);if(l&&(a&&h<=4-a&&l.state&&(l.data=l.data.subarray(0,l.data.byteLength-a)),(n=h-s-1)>0)){var v=new Uint8Array(l.data.byteLength+n);v.set(l.data,0),v.set(i.subarray(0,n),l.data.byteLength),l.data=v,l.state=0}}h<e?(u=h,f=31&i[h],s=0):s=-1}else s=0;else s=3;else s=r?0:2;else s=r?0:1;if(u>=0&&s>=0){var d={data:i.subarray(u,e),type:f,state:s};o.push(d)}if(0===o.length){var m=this.getLastNalUnit(t.samples);if(m){var p=new Uint8Array(m.data.byteLength+i.byteLength);p.set(m.data,0),p.set(i,m.data.byteLength),m.data=p}}return t.naluState=s,o},i.parseAACPES=function(t,i){var r,e,s,a,h,c=0,l=this.aacOverFlow,v=i.data;if(l){this.aacOverFlow=null;var d=l.missing,m=l.sample.unit.byteLength;if(-1===d){var p=new Uint8Array(m+v.byteLength);p.set(l.sample.unit,0),p.set(v,m),v=p}else{var y=m-d;l.sample.unit.set(v.subarray(0,d),y),t.samples.push(l.sample),c=l.missing}}for(r=c,e=v.length;r<e-1&&!n.isHeader(v,r);r++);if(r===c||(r<e-1?(s="AAC PES did not start with ADTS header,offset:"+r,a=!1):(s="no ADTS header found in AAC PES",a=!0),u.logger.warn("parsing error:"+s),this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.FRAG_PARSING_ERROR,fatal:a,reason:s}),!a)){if(n.initTrackConfig(t,this.observer,v,r,this.audioCodec),void 0!==i.pts)h=i.pts;else{if(!l)return void u.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var g=n.getFrameDuration(t.samplerate);h=l.sample.pts+g}for(var b,w=0;r<e;){if(r+=(b=n.appendFrame(t,v,r,h,w)).length,b.missing){this.aacOverFlow=b;break}for(w++;r<e-1&&!n.isHeader(v,r);r++);}}},i.parseMPEGPES=function(t,i){var r=i.data,n=r.length,s=0,a=0,o=i.pts;if(void 0!==o)for(;a<n;)if(e.isHeader(r,a)){var h=e.appendFrame(t,r,a,o,s);if(!h)break;a+=h.length,s++}else a++;else u.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},i.parseID3PES=function(t,i){if(void 0!==i.pts){var r=l({},i,{type:this._avcTrack?c.MetadataSchema.emsg:c.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(r)}else u.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},t}()},"./src/demux/webworkify-webpack.js":
|
|
128
|
-
/*!*****************************************!*\
|
|
129
|
-
!*** ./src/demux/webworkify-webpack.js ***!
|
|
130
|
-
\*****************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>f});var n=function(){var t=ENTRY_MODULE,i={},r=function r(n){var e=i[n];if(void 0!==e)return e.exports;var s=i[n]={exports:{}};return t[n].call(s.exports,s,s.exports,r),s.exports};r.m=t,r.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(i,{a:i}),i},r.d=function(t,i){for(var n in i)r.o(i,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})},r.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n=r(ENTRY_MODULE);return n.default||n}.toString().split("ENTRY_MODULE"),e="[\\.|\\-|\\+|\\w|/|@]+",s="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+e+").*?\\)";function a(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(t,i,n){var o={};o[n]=[];var h=i.toString().replace(/^"[^"]+"/,"function"),u=h.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||h.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!u)return o;for(var f,c=u[1],l=new RegExp("(\\\\n|\\W)"+a(c)+s,"g");f=l.exec(h);)"dll-reference"!==f[3]&&o[n].push(f[3]);for(l=new RegExp("\\("+a(c)+'\\("(dll-reference\\s('+e+'))"\\)\\)'+s,"g");f=l.exec(h);)t[f[2]]||(o[n].push(f[1]),t[f[2]]=r(f[1]).m),o[f[2]]=o[f[2]]||[],o[f[2]].push(f[4]);for(var v=Object.keys(o),d=0;d<v.length;d++)for(var m=0;m<o[v[d]].length;m++)isNaN(1*o[v[d]][m])||(o[v[d]][m]=1*o[v[d]][m]);return o}function h(t){return Object.keys(t).reduce((function(i,r){return i||t[r].length>0}),!1)}function u(t,i,r,e){var s=t[e].map((function(t){return'"'+t+'": '+i[e][t].toString().replace(/^"[^"]+"/,"function")})).join(",");return n[0]+"{"+s+"}"+n[1]+'"'+r+'"'+n[2]}function f(t,i){var n={main:r.m},e=(i=i||{}).all?{main:Object.keys(n.main)}:function(t,i){for(var r={main:[i]},n={main:[]},e={main:{}};h(r);)for(var s=Object.keys(r),a=0;a<s.length;a++){var u=s[a],f=r[u].pop();if(e[u]=e[u]||{},!e[u][f]&&t[u][f]){e[u][f]=!0,n[u]=n[u]||[],n[u].push(f);for(var c=o(t,t[u][f],u),l=Object.keys(c),v=0;v<l.length;v++)r[l[v]]=r[l[v]]||[],r[l[v]]=r[l[v]].concat(c[l[v]])}}return n}(n,t),s="";Object.keys(e).filter((function(t){return"main"!==t})).forEach((function(t){for(var i=0;e[t][i];)i++;e[t].push(i),n[t][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",s=s+"var "+t+" = ("+u(e,n,i,modules)+")();\n"})),s=s+"new (("+u(e,n,t,"main")+")())(self);";var a=new window.Blob([s],{type:"text/javascript"}),f=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(a),c=new window.Worker(f);return c.objectURL=f,c}},"./src/errors.ts":
|
|
131
|
-
/*!***********************!*\
|
|
132
|
-
!*** ./src/errors.ts ***!
|
|
133
|
-
\***********************/(t,i,r)=>{var n,e;r.r(i),r.d(i,{ErrorDetails:()=>e,ErrorTypes:()=>n}),function(t){t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError"}(n||(n={})),function(t){t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",t.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",t.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown"}(e||(e={}))},"./src/events.ts":
|
|
134
|
-
/*!***********************!*\
|
|
135
|
-
!*** ./src/events.ts ***!
|
|
136
|
-
\***********************/(t,i,r)=>{var n;r.r(i),r.d(i,{Events:()=>n}),function(t){t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached"}(n||(n={}))},"./src/hls.ts":
|
|
137
|
-
/*!********************!*\
|
|
138
|
-
!*** ./src/hls.ts ***!
|
|
139
|
-
\********************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>b});var n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),e=r(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts"),s=r(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts"),a=r(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts"),o=r(/*! ./controller/level-controller */"./src/controller/level-controller.ts"),h=r(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ./loader/key-loader */"./src/loader/key-loader.ts"),f=r(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts"),c=r(/*! ./is-supported */"./src/is-supported.ts"),l=r(/*! ./utils/logger */"./src/utils/logger.ts"),v=r(/*! ./config */"./src/config.ts"),d=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),m=r(/*! ./events */"./src/events.ts"),p=r(/*! ./errors */"./src/errors.ts"),y=r(/*! ./types/level */"./src/types/level.ts");function g(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}var b=function(){function t(i){void 0===i&&(i={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new d.EventEmitter,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var r=this.config=(0,v.mergeConfig)(t.DefaultConfig,i);this.userConfig=i,(0,l.enableLogs)(r.debug,"Hls instance"),this._autoLevelCapping=-1,r.progressive&&(0,v.enableStreamingMode)(r);var n=r.bufferController,c=r.capLevelController,m=r.fpsController,p=this.abrController=new(0,r.abrController)(this),y=this.bufferController=new n(this),g=this.capLevelController=new c(this),b=new m(this),w=new e.default(this),k=new s.default(this),S=this.levelController=new o.default(this),T=new h.FragmentTracker(this),E=new u.default(this.config),A=this.streamController=new f.default(this,T,E);g.setStreamController(A),b.setStreamController(A);var M=[w,S,A];this.networkControllers=M;var x=[p,y,g,b,k,T];this.audioTrackController=this.createController(r.audioTrackController,M);var O=r.audioStreamController;O&&M.push(new O(this,T,E)),this.subtitleTrackController=this.createController(r.subtitleTrackController,M);var D=r.subtitleStreamController;D&&M.push(new D(this,T,E)),this.createController(r.timelineController,x),E.emeController=this.emeController=this.createController(r.emeController,x),this.cmcdController=this.createController(r.cmcdController,x),this.latencyController=this.createController(a.default,x),this.coreComponents=x}t.isSupported=function(){return(0,c.isSupported)()};var i,r,b,w=t.prototype;return w.createController=function(t,i){if(t){var r=new t(this);return i&&i.push(r),r}return null},w.on=function(t,i,r){void 0===r&&(r=this),this._emitter.on(t,i,r)},w.once=function(t,i,r){void 0===r&&(r=this),this._emitter.once(t,i,r)},w.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},w.off=function(t,i,r,n){void 0===r&&(r=this),this._emitter.off(t,i,r,n)},w.listeners=function(t){return this._emitter.listeners(t)},w.emit=function(t,i,r){return this._emitter.emit(t,i,r)},w.trigger=function(t,i){if(this.config.debug)return this.emit(t,t,i);try{return this.emit(t,t,i)}catch(i){l.logger.error("An internal error happened while handling event "+t+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(m.Events.ERROR,{type:p.ErrorTypes.OTHER_ERROR,details:p.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1},w.listenerCount=function(t){return this._emitter.listenerCount(t)},w.destroy=function(){l.logger.log("destroy"),this.trigger(m.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(t){return t.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(t){return t.destroy()})),this.coreComponents.length=0},w.attachMedia=function(t){l.logger.log("attachMedia"),this._media=t,this.trigger(m.Events.MEDIA_ATTACHING,{media:t})},w.detachMedia=function(){l.logger.log("detachMedia"),this.trigger(m.Events.MEDIA_DETACHING,void 0),this._media=null},w.loadSource=function(t){this.stopLoad();var i=this.media,r=this.url,e=this.url=n.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});l.logger.log("loadSource:"+e),i&&r&&r!==e&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(i)),this.trigger(m.Events.MANIFEST_LOADING,{url:t})},w.startLoad=function(t){void 0===t&&(t=-1),l.logger.log("startLoad("+t+")"),this.networkControllers.forEach((function(i){i.startLoad(t)}))},w.stopLoad=function(){l.logger.log("stopLoad"),this.networkControllers.forEach((function(t){t.stopLoad()}))},w.swapAudioCodec=function(){l.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},w.recoverMediaError=function(){l.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},w.removeLevel=function(t,i){void 0===i&&(i=0),this.levelController.removeLevel(t,i)},i=t,b=[{key:"version",get:function(){return"1.3.5"}},{key:"Events",get:function(){return m.Events}},{key:"ErrorTypes",get:function(){return p.ErrorTypes}},{key:"ErrorDetails",get:function(){return p.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:v.hlsDefaultConfig},set:function(i){t.defaultConfig=i}}],(r=[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){l.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){l.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){l.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){l.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){l.logger.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var i=!!t;i!==this.config.capLevelToPlayerSize&&(i?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=i)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(l.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(t){y.HdcpLevels.indexOf(t)>-1&&(this._maxHdcpLevel=t)}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,i=this.config.minAutoBitrate;if(!t)return 0;for(var r=t.length,n=0;n<r;n++)if(t[n].maxBitrate>=i)return n;return 0}},{key:"maxAutoLevel",get:function(){var t,i=this.levels,r=this.autoLevelCapping,n=this.maxHdcpLevel;if(t=-1===r&&i&&i.length?i.length-1:r,n)for(var e=t;e--;){var s=i[e].attrs["HDCP-LEVEL"];if(s&&s<=n)return e}return t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var i=this.audioTrackController;i&&(i.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var i=this.subtitleTrackController;i&&(i.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var i=this.subtitleTrackController;i&&(i.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&g(i.prototype,r),b&&g(i,b),Object.defineProperty(i,"prototype",{writable:!1}),t}();b.defaultConfig=void 0},"./src/is-supported.ts":
|
|
140
|
-
/*!*****************************!*\
|
|
141
|
-
!*** ./src/is-supported.ts ***!
|
|
142
|
-
\*****************************/(t,i,r)=>{r.r(i),r.d(i,{changeTypeSupported:()=>a,isSupported:()=>s});var n=r(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function e(){return self.SourceBuffer||self.WebKitSourceBuffer}function s(){var t=(0,n.getMediaSource)();if(!t)return!1;var i=e();return!(!t||"function"!=typeof t.isTypeSupported||!t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')||i&&(!i.prototype||"function"!=typeof i.prototype.appendBuffer||"function"!=typeof i.prototype.remove))}function a(){var t,i=e();return"function"==typeof(null==i||null===(t=i.prototype)||void 0===t?void 0:t.changeType)}},"./src/loader/date-range.ts":
|
|
143
|
-
/*!**********************************!*\
|
|
144
|
-
!*** ./src/loader/date-range.ts ***!
|
|
145
|
-
\**********************************/(t,i,r)=>{r.r(i),r.d(i,{DateRange:()=>u,DateRangeAttribute:()=>n});var n,e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),s=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts");function o(){return o=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o.apply(this,arguments)}function h(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}!function(t){t.ID="ID",t.CLASS="CLASS",t.START_DATE="START-DATE",t.DURATION="DURATION",t.END_DATE="END-DATE",t.END_ON_NEXT="END-ON-NEXT",t.PLANNED_DURATION="PLANNED-DURATION",t.SCTE35_OUT="SCTE35-OUT",t.SCTE35_IN="SCTE35-IN"}(n||(n={}));var u=function(){function t(t,i){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,i){var r=i.attr;for(var h in r)if(Object.prototype.hasOwnProperty.call(t,h)&&t[h]!==r[h]){a.logger.warn('DATERANGE tag attribute: "'+h+'" does not match for tags with ID: "'+t.ID+'"'),this._badValueForSameId=h;break}t=o(new s.AttrList({}),r,t)}if(this.attr=t,this._startDate=new Date(t[n.START_DATE]),n.END_DATE in this.attr){var u=new Date(this.attr[n.END_DATE]);(0,e.isFiniteNumber)(u.getTime())&&(this._endDate=u)}}var i,r;return i=t,(r=[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var t=this.duration;return null!==t?new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if(n.DURATION in this.attr){var t=this.attr.decimalFloatingPoint(n.DURATION);if((0,e.isFiniteNumber)(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return n.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(n.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(n.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,e.isFiniteNumber)(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}])&&h(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),t}()},"./src/loader/fragment-loader.ts":
|
|
146
|
-
/*!***************************************!*\
|
|
147
|
-
!*** ./src/loader/fragment-loader.ts ***!
|
|
148
|
-
\***************************************/(t,i,r)=>{r.r(i),r.d(i,{LoadError:()=>v,default:()=>c});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ../errors */"./src/errors.ts");function s(t){var i="function"==typeof Map?new Map:void 0;return s=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,r)}function r(){return a(t,arguments,u(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,t)},s(t)}function a(t,i,r){return a=o()?Reflect.construct.bind():function(t,i,r){var n=[null];n.push.apply(n,i);var e=new(Function.bind.apply(t,n));return r&&h(e,r.prototype),e},a.apply(null,arguments)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function h(t,i){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},h(t,i)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}var f=Math.pow(2,17),c=function(){function t(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var i=t.prototype;return i.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},i.abort=function(){this.loader&&this.loader.abort()},i.load=function(t,i){var r=this,n=t.url;if(!n)return Promise.reject(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,networkDetails:null},"Fragment does not have a "+(n?"part list":"url")));this.abort();var s=this.config,a=s.fLoader,o=s.loader;return new Promise((function(n,h){r.loader&&r.loader.destroy();var u=r.loader=t.loader=a?new a(s):new o(s),c=l(t),d={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:"initSegment"===t.sn?1/0:f};t.stats=u.stats,u.load(c,d,{onSuccess:function(i,e,s,a){r.resetLoader(t,u);var o=i.data;s.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(o.slice(0,16)),o=o.slice(16)),n({frag:t,part:null,payload:o,networkDetails:a})},onError:function(i,n,s){r.resetLoader(t,u),h(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:i,networkDetails:s}))},onAbort:function(i,n,s){r.resetLoader(t,u),h(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,networkDetails:s}))},onTimeout:function(i,n,s){r.resetLoader(t,u),h(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,networkDetails:s}))},onProgress:function(r,n,e,s){i&&i({frag:t,part:null,payload:e,networkDetails:s})}})}))},i.loadPart=function(t,i,r){var n=this;this.abort();var s=this.config,a=s.fLoader,o=s.loader;return new Promise((function(h,u){n.loader&&n.loader.destroy();var c=n.loader=t.loader=a?new a(s):new o(s),d=l(t,i),m={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:f};i.stats=c.stats,c.load(d,m,{onSuccess:function(e,s,a,o){n.resetLoader(t,c),n.updateStatsFromPart(t,i);var u={frag:t,part:i,payload:e.data,networkDetails:o};r(u),h(u)},onError:function(r,s,a){n.resetLoader(t,c),u(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:i,response:r,networkDetails:a}))},onAbort:function(r,s,a){t.stats.aborted=i.stats.aborted,n.resetLoader(t,c),u(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,part:i,networkDetails:a}))},onTimeout:function(r,s,a){n.resetLoader(t,c),u(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:i,networkDetails:a}))}})}))},i.updateStatsFromPart=function(t,i){var r=t.stats,n=i.stats,e=n.total;if(r.loaded+=n.loaded,e){var s=Math.round(t.duration/i.duration),a=Math.min(Math.round(r.loaded/e),s),o=(s-a)*Math.round(r.loaded/a);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var h=r.loading,u=n.loading;h.start?h.first+=u.first-u.start:(h.start=u.start,h.first=u.first),h.end=u.end},i.resetLoader=function(t,i){t.loader=null,this.loader===i&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),i.destroy()},t}();function l(t,i){void 0===i&&(i=null);var r=i||t,e={frag:t,part:i,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},s=r.byteRangeStartOffset,a=r.byteRangeEndOffset;if((0,n.isFiniteNumber)(s)&&(0,n.isFiniteNumber)(a)){var o,h=s,u=a;if("initSegment"===t.sn&&"AES-128"===(null===(o=t.decryptdata)||void 0===o?void 0:o.method)){var f=a-s;f%16&&(u=a+(16-f%16)),0!==s&&(e.resetIV=!0,h=s-16)}e.rangeStart=h,e.rangeEnd=u}return e}var v=function(t){var i,r;function n(i){for(var r,n=arguments.length,e=new Array(n>1?n-1:0),s=1;s<n;s++)e[s-1]=arguments[s];return(r=t.call.apply(t,[this].concat(e))||this).data=void 0,r.data=i,r}return r=t,(i=n).prototype=Object.create(r.prototype),i.prototype.constructor=i,h(i,r),n}(s(Error))},"./src/loader/fragment.ts":
|
|
149
|
-
/*!********************************!*\
|
|
150
|
-
!*** ./src/loader/fragment.ts ***!
|
|
151
|
-
\********************************/(t,i,r)=>{r.r(i),r.d(i,{BaseSegment:()=>c,ElementaryStreamTypes:()=>n,Fragment:()=>l,Part:()=>v});var n,e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),s=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),a=r(/*! ./load-stats */"./src/loader/load-stats.ts");function o(t,i){t.prototype=Object.create(i.prototype),t.prototype.constructor=t,h(t,i)}function h(t,i){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},h(t,i)}function u(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}function f(t,i,r){return i&&u(t.prototype,i),r&&u(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}!function(t){t.AUDIO="audio",t.VIDEO="video",t.AUDIOVIDEO="audiovideo"}(n||(n={}));var c=function(){function t(t){var i;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((i={})[n.AUDIO]=null,i[n.VIDEO]=null,i[n.AUDIOVIDEO]=null,i),this.baseurl=t}return t.prototype.setByteRange=function(t,i){var r=t.split("@",2),n=[];n[0]=1===r.length?i?i.byteRangeEndOffset:0:parseInt(r[1]),n[1]=parseInt(r[0])+n[0],this._byteRange=n},f(t,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=(0,s.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),t}(),l=function(t){function i(i,r){var n;return(n=t.call(this,r)||this)._decryptdata=null,n.rawProgramDateTime=null,n.programDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkeys=void 0,n.type=void 0,n.loader=null,n.keyLoader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.appendedPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.stats=new a.LoadStats,n.urlId=0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.endList=void 0,n.type=i,n}o(i,t);var r=i.prototype;return r.setKeyFormat=function(t){if(this.levelkeys){var i=this.levelkeys[t];i&&!this._decryptdata&&(this._decryptdata=i.getDecryptData(this.sn))}},r.abortRequests=function(){var t,i;null===(t=this.loader)||void 0===t||t.abort(),null===(i=this.keyLoader)||void 0===i||i.abort()},r.setElementaryStreamInfo=function(t,i,r,n,e,s){void 0===s&&(s=!1);var a=this.elementaryStreams,o=a[t];o?(o.startPTS=Math.min(o.startPTS,i),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,n),o.endDTS=Math.max(o.endDTS,e)):a[t]={startPTS:i,endPTS:r,startDTS:n,endDTS:e,partial:s}},r.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[n.AUDIO]=null,t[n.VIDEO]=null,t[n.AUDIOVIDEO]=null},f(i,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{var i=Object.keys(this.levelkeys);if(1===i.length)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!(0,e.isFiniteNumber)(this.programDateTime))return null;var t=(0,e.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;if(null!==(t=this._decryptdata)&&void 0!==t&&t.encrypted)return!0;if(this.levelkeys){var i=Object.keys(this.levelkeys),r=i.length;if(r>1||1===r&&this.levelkeys[i[0]].encrypted)return!0}return!1}}]),i}(c),v=function(t){function i(i,r,n,e,s){var o;(o=t.call(this,n)||this).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.stats=new a.LoadStats,o.duration=i.decimalFloatingPoint("DURATION"),o.gap=i.bool("GAP"),o.independent=i.bool("INDEPENDENT"),o.relurl=i.enumeratedString("URI"),o.fragment=r,o.index=e;var h=i.enumeratedString("BYTERANGE");return h&&o.setByteRange(h,s),s&&(o.fragOffset=s.fragOffset+s.duration),o}return o(i,t),f(i,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}]),i}(c)},"./src/loader/key-loader.ts":
|
|
152
|
-
/*!**********************************!*\
|
|
153
|
-
!*** ./src/loader/key-loader.ts ***!
|
|
154
|
-
\**********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>s});var n=r(/*! ../errors */"./src/errors.ts"),e=r(/*! ./fragment-loader */"./src/loader/fragment-loader.ts"),s=function(){function t(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}var i=t.prototype;return i.abort=function(){for(var t in this.keyUriToKeyInfo){var i=this.keyUriToKeyInfo[t].loader;i&&i.abort()}},i.detach=function(){for(var t in this.keyUriToKeyInfo){var i=this.keyUriToKeyInfo[t];(i.mediaKeySessionContext||i.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},i.destroy=function(){for(var t in this.detach(),this.keyUriToKeyInfo){var i=this.keyUriToKeyInfo[t].loader;i&&i.destroy()}this.keyUriToKeyInfo={}},i.createKeyLoadError=function(t,i,r){return void 0===i&&(i=n.ErrorDetails.KEY_LOAD_ERROR),new e.LoadError({type:n.ErrorTypes.NETWORK_ERROR,details:i,fatal:!1,frag:t,networkDetails:r})},i.loadClear=function(t,i){var r=this;if(this.emeController&&this.config.emeEnabled)for(var n=t.sn,e=t.cc,s=function(t){var s=i[t];if(e<=s.cc&&("initSegment"===n||n<s.sn))return r.emeController.selectKeySystemFormat(s).then((function(t){s.setKeyFormat(t)})),"break"},a=0;a<i.length&&"break"!==s(a);a++);},i.load=function(t){var i=this;return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then((function(r){return i.loadInternal(t,r)})):this.loadInternal(t)},i.loadInternal=function(t,i){var r,e;i&&t.setKeyFormat(i);var s=t.decryptdata;if(!s)return Promise.reject(this.createKeyLoadError(t,n.ErrorDetails.KEY_LOAD_ERROR,null,i?"Expected frag.decryptdata to be defined after setting format "+i:"Missing decryption data on fragment in onKeyLoading"));var a=s.uri;if(!a)return Promise.reject(this.createKeyLoadError(t,n.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+a+'"'));var o,h=this.keyUriToKeyInfo[a];if(null!==(r=h)&&void 0!==r&&r.decryptdata.key)return s.key=h.decryptdata.key,Promise.resolve({frag:t,keyInfo:h});if(null!==(e=h)&&void 0!==e&&e.keyLoadPromise)switch(null===(o=h.mediaKeySessionContext)||void 0===o?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return h.keyLoadPromise.then((function(i){return s.key=i.keyInfo.decryptdata.key,{frag:t,keyInfo:h}}))}switch(h=this.keyUriToKeyInfo[a]={decryptdata:s,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},s.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===s.keyFormat?this.loadKeyHTTP(h,t):this.loadKeyEME(h,t);case"AES-128":return this.loadKeyHTTP(h,t);default:return Promise.reject(this.createKeyLoadError(t,n.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+s.method+'"'))}},i.loadKeyEME=function(t,i){var r={frag:i,keyInfo:t};if(this.emeController&&this.config.emeEnabled){var n=this.emeController.loadKey(r);if(n)return(t.keyLoadPromise=n.then((function(i){return t.mediaKeySessionContext=i,r}))).catch((function(i){throw t.keyLoadPromise=null,i}))}return Promise.resolve(r)},i.loadKeyHTTP=function(t,i){var r=this,e=this.config,s=new(0,e.loader)(e);return i.keyLoader=t.loader=s,t.keyLoadPromise=new Promise((function(a,o){var h={onSuccess:function(t,i,e,s){var h=e.frag,u=e.keyInfo;if(!h.decryptdata||u!==r.keyUriToKeyInfo[e.url])return o(r.createKeyLoadError(h,n.ErrorDetails.KEY_LOAD_ERROR,s,"after key load, decryptdata unset or changed"));u.decryptdata.key=h.decryptdata.key=new Uint8Array(t.data),h.keyLoader=null,u.loader=null,a({frag:h,keyInfo:u})},onError:function(t,e,s){r.resetLoader(e),o(r.createKeyLoadError(i,n.ErrorDetails.KEY_LOAD_ERROR,s))},onTimeout:function(t,e,s){r.resetLoader(e),o(r.createKeyLoadError(i,n.ErrorDetails.KEY_LOAD_TIMEOUT,s))},onAbort:function(t,e,s){r.resetLoader(e),o(r.createKeyLoadError(i,n.ErrorDetails.INTERNAL_ABORTED,s))}};s.load({keyInfo:t,frag:i,responseType:"arraybuffer",url:t.decryptdata.uri},{timeout:e.fragLoadingTimeOut,maxRetry:0,retryDelay:e.fragLoadingRetryDelay,maxRetryDelay:e.fragLoadingMaxRetryTimeout,highWaterMark:0},h)}))},i.resetLoader=function(t){var i=t.frag,r=t.keyInfo,n=t.url,e=r.loader;i.keyLoader===e&&(i.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[n],e&&e.destroy()},t}()},"./src/loader/level-details.ts":
|
|
155
|
-
/*!*************************************!*\
|
|
156
|
-
!*** ./src/loader/level-details.ts ***!
|
|
157
|
-
\*************************************/(t,i,r)=>{r.r(i),r.d(i,{LevelDetails:()=>s});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function e(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}var s=function(){function t(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}var i,r;return t.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var i=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!i,this.advanced=this.endSN>t.endSN||i>0||0===i&&r>0,this.misses=this.updated||this.advanced?Math.floor(.6*t.misses):t.misses+1,this.availabilityDelay=t.availabilityDelay},i=t,(r=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&(0,n.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return null!==(t=this.fragments)&&void 0!==t&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&e(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),t}()},"./src/loader/level-key.ts":
|
|
158
|
-
/*!*********************************!*\
|
|
159
|
-
!*** ./src/loader/level-key.ts ***!
|
|
160
|
-
\*********************************/(t,i,r)=>{r.r(i),r.d(i,{LevelKey:()=>u});var n=r(/*! ../utils/keysystem-util */"./src/utils/keysystem-util.ts"),e=r(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),s=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/numeric-encoding-utils */"./src/utils/numeric-encoding-utils.ts"),h={},u=function(){function t(t,i,r,n,e){void 0===n&&(n=[1]),void 0===e&&(e=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=i,this.keyFormat=r,this.keyFormatVersions=n,this.iv=e,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&"AES-128"!==t}t.clearKeyUriToKeyIdMap=function(){h={}};var i=t.prototype;return i.isSupported=function(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;switch(this.keyFormat){case"identity":return"SAMPLE-AES"===this.method;case e.KeySystemFormats.FAIRPLAY:case e.KeySystemFormats.WIDEVINE:case e.KeySystemFormats.PLAYREADY:case e.KeySystemFormats.CLEARKEY:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1},i.getDecryptData=function(i){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof i&&("AES-128"!==this.method||this.iv||a.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),i=0);var r=function(t){for(var i=new Uint8Array(16),r=12;r<16;r++)i[r]=t>>8*(15-r)&255;return i}(i);return new t(this.method,this.uri,"identity",this.keyFormatVersions,r)}var u=(0,n.convertDataUriToArrayBytes)(this.uri);if(u)switch(this.keyFormat){case e.KeySystemFormats.WIDEVINE:this.pssh=u,u.length>=22&&(this.keyId=u.subarray(u.length-22,u.length-6));break;case e.KeySystemFormats.PLAYREADY:var f=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,s.mp4pssh)(f,null,u);var c=new Uint16Array(u.buffer,u.byteOffset,u.byteLength/2),l=String.fromCharCode.apply(null,Array.from(c)),v=l.substring(l.indexOf("<"),l.length),d=(new DOMParser).parseFromString(v,"text/xml").getElementsByTagName("KID")[0];if(d){var m=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(m){var p=(0,o.base64Decode)(m).subarray(0,16);(0,n.changeEndianness)(p),this.keyId=p}}break;default:var y=u.subarray(0,16);if(16!==y.length){var g=new Uint8Array(16);g.set(y,16-y.length),y=g}this.keyId=y}if(!this.keyId||16!==this.keyId.byteLength){var b=h[this.uri];if(!b){var w=Object.keys(h).length%Number.MAX_SAFE_INTEGER;b=new Uint8Array(16),new DataView(b.buffer,12,4).setUint32(0,w),h[this.uri]=b}this.keyId=b}return this},t}()},"./src/loader/load-stats.ts":
|
|
161
|
-
/*!**********************************!*\
|
|
162
|
-
!*** ./src/loader/load-stats.ts ***!
|
|
163
|
-
\**********************************/(t,i,r)=>{r.r(i),r.d(i,{LoadStats:()=>n});var n=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":
|
|
164
|
-
/*!***********************************!*\
|
|
165
|
-
!*** ./src/loader/m3u8-parser.ts ***!
|
|
166
|
-
\***********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>y});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),s=r(/*! ./date-range */"./src/loader/date-range.ts"),a=r(/*! ./fragment */"./src/loader/fragment.ts"),o=r(/*! ./level-details */"./src/loader/level-details.ts"),h=r(/*! ./level-key */"./src/loader/level-key.ts"),u=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),f=r(/*! ../utils/logger */"./src/utils/logger.ts"),c=r(/*! ../utils/codecs */"./src/utils/codecs.ts");function l(){return l=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},l.apply(this,arguments)}var v=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+|#EXT-X-SESSION-KEY:([^\n\r]*)[\r\n]+/g,d=/#EXT-X-MEDIA:(.*)/g,m=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),p=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),y=function(){function t(){}return t.findGroup=function(t,i){for(var r=0;r<t.length;r++){var n=t[r];if(n.id===i)return n}},t.convertAVC1ToAVCOTI=function(t){var i=t.split(".");if(i.length>2){var r=i.shift()+".";return(r+=parseInt(i.shift()).toString(16))+("000"+parseInt(i.shift()).toString(16)).slice(-4)}return t},t.resolve=function(t,i){return(0,e.buildAbsoluteURL)(i,t,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(i,r){var n,e=[],s=[],a={},o=[],h=!1;for(v.lastIndex=0;null!=(n=v.exec(i));)if(n[1]){var c,l=new u.AttrList(n[1]),d={attrs:l,bitrate:l.decimalInteger("AVERAGE-BANDWIDTH")||l.decimalInteger("BANDWIDTH"),name:l.NAME,url:t.resolve(n[2],r)},m=l.decimalResolution("RESOLUTION");m&&(d.width=m.width,d.height=m.height),b((l.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),d),d.videoCodec&&-1!==d.videoCodec.indexOf("avc1")&&(d.videoCodec=t.convertAVC1ToAVCOTI(d.videoCodec)),null!==(c=d.unknownCodecs)&&void 0!==c&&c.length||s.push(d),e.push(d)}else if(n[3]){var p=new u.AttrList(n[3]);p["DATA-ID"]&&(h=!0,a[p["DATA-ID"]]=p)}else if(n[4]){var y=n[4],w=g(y,r);w.encrypted&&w.isSupported()?o.push(w):f.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+y+'"')}return{levels:s.length>0&&s.length<e.length?s:e,sessionData:h?a:null,sessionKeys:o.length?o:null}},t.parseMasterPlaylistMedia=function(i,r,n,e){var s;void 0===e&&(e=[]);var a=[],o=0;for(d.lastIndex=0;null!==(s=d.exec(i));){var h=new u.AttrList(s[1]);if(h.TYPE===n){var f={attrs:h,bitrate:0,id:o++,groupId:h["GROUP-ID"],instreamId:h["INSTREAM-ID"],name:h.NAME||h.LANGUAGE||"",type:n,default:h.bool("DEFAULT"),autoselect:h.bool("AUTOSELECT"),forced:h.bool("FORCED"),lang:h.LANGUAGE,url:h.URI?t.resolve(h.URI,r):""};if(e.length){var c=t.findGroup(e,f.groupId)||e[0];w(f,c,"audioCodec"),w(f,c,"textCodec")}a.push(f)}}return a},t.parseLevelPlaylist=function(t,i,r,e,h){var c,v,d,y=new o.LevelDetails(i),b=y.fragments,w=null,E=0,A=0,M=0,x=0,O=null,D=new a.Fragment(e,i),I=-1,C=!1;for(m.lastIndex=0,y.m3u8=t;null!==(c=m.exec(t));){C&&(C=!1,(D=new a.Fragment(e,i)).start=M,D.sn=E,D.cc=x,D.level=r,w&&(D.initSegment=w,D.rawProgramDateTime=w.rawProgramDateTime,w.rawProgramDateTime=null));var L=c[1];if(L){D.duration=parseFloat(L);var P=(" "+c[2]).slice(1);D.title=P||null,D.tagList.push(P?["INF",L,P]:["INF",L])}else if(c[3])(0,n.isFiniteNumber)(D.duration)&&(D.start=M,d&&T(D,d,y),D.sn=E,D.level=r,D.cc=x,D.urlId=h,b.push(D),D.relurl=(" "+c[3]).slice(1),k(D,O),O=D,M+=D.duration,E++,A=0,C=!0);else if(c[4]){var j=(" "+c[4]).slice(1);O?D.setByteRange(j,O):D.setByteRange(j)}else if(c[5])D.rawProgramDateTime=(" "+c[5]).slice(1),D.tagList.push(["PROGRAM-DATE-TIME",D.rawProgramDateTime]),-1===I&&(I=b.length);else{if(!(c=c[0].match(p))){f.logger.warn("No matches on slow regex match for level playlist!");continue}for(v=1;v<c.length&&void 0===c[v];v++);var R=(" "+c[v]).slice(1),U=(" "+c[v+1]).slice(1),N=c[v+2]?(" "+c[v+2]).slice(1):"";switch(R){case"PLAYLIST-TYPE":y.type=U.toUpperCase();break;case"MEDIA-SEQUENCE":E=y.startSN=parseInt(U);break;case"SKIP":var F=new u.AttrList(U),B=F.decimalInteger("SKIPPED-SEGMENTS");if((0,n.isFiniteNumber)(B)){y.skippedSegments=B;for(var _=B;_--;)b.unshift(null);E+=B}var G=F.enumeratedString("RECENTLY-REMOVED-DATERANGES");G&&(y.recentlyRemovedDateranges=G.split("\t"));break;case"TARGETDURATION":y.targetduration=parseFloat(U);break;case"VERSION":y.version=parseInt(U);break;case"EXTM3U":break;case"ENDLIST":y.live=!1;break;case"#":(U||N)&&D.tagList.push(N?[U,N]:[U]);break;case"DISCONTINUITY":x++,D.tagList.push(["DIS"]);break;case"GAP":D.tagList.push([R]);break;case"BITRATE":D.tagList.push([R,U]);break;case"DATERANGE":var K=new u.AttrList(U),X=new s.DateRange(K,y.dateRanges[K.ID]);X.isValid||y.skippedSegments?y.dateRanges[X.id]=X:f.logger.warn('Ignoring invalid DATERANGE tag: "'+U+'"'),D.tagList.push(["EXT-X-DATERANGE",U]);break;case"DISCONTINUITY-SEQUENCE":x=parseInt(U);break;case"KEY":var H=g(U,i);if(H.isSupported()){if("NONE"===H.method){d=void 0;break}d||(d={}),d[H.keyFormat]&&(d=l({},d)),d[H.keyFormat]=H}else f.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+U+'"');break;case"START":var V=new u.AttrList(U).decimalFloatingPoint("TIME-OFFSET");(0,n.isFiniteNumber)(V)&&(y.startTimeOffset=V);break;case"MAP":var W=new u.AttrList(U);if(D.duration){var q=new a.Fragment(e,i);S(q,W,r,d),D.initSegment=w=q,w.rawProgramDateTime&&!D.rawProgramDateTime&&(D.rawProgramDateTime=w.rawProgramDateTime)}else S(D,W,r,d),w=D,C=!0;break;case"SERVER-CONTROL":var Y=new u.AttrList(U);y.canBlockReload=Y.bool("CAN-BLOCK-RELOAD"),y.canSkipUntil=Y.optionalFloat("CAN-SKIP-UNTIL",0),y.canSkipDateRanges=y.canSkipUntil>0&&Y.bool("CAN-SKIP-DATERANGES"),y.partHoldBack=Y.optionalFloat("PART-HOLD-BACK",0),y.holdBack=Y.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var z=new u.AttrList(U);y.partTarget=z.decimalFloatingPoint("PART-TARGET");break;case"PART":var $=y.partList;$||($=y.partList=[]);var J=A>0?$[$.length-1]:void 0,Q=A++,Z=new a.Part(new u.AttrList(U),D,i,Q,J);$.push(Z),D.duration+=Z.duration;break;case"PRELOAD-HINT":var tt=new u.AttrList(U);y.preloadHint=tt;break;case"RENDITION-REPORT":var it=new u.AttrList(U);y.renditionReports=y.renditionReports||[],y.renditionReports.push(it);break;default:f.logger.warn("line parsed but not handled: "+c)}}}O&&!O.relurl?(b.pop(),M-=O.duration,y.partList&&(y.fragmentHint=O)):y.partList&&(k(D,O),D.cc=x,y.fragmentHint=D,d&&T(D,d,y));var rt=b.length,nt=b[0],et=b[rt-1];if((M+=y.skippedSegments*y.targetduration)>0&&rt&&et){y.averagetargetduration=M/rt;var st=et.sn;y.endSN="initSegment"!==st?st:0,y.live||(et.endList=!0),nt&&(y.startCC=nt.cc)}else y.endSN=0,y.startCC=0;return y.fragmentHint&&(M+=y.fragmentHint.duration),y.totalduration=M,y.endCC=x,I>0&&function(t,i){for(var r=t[i],n=i;n--;){var e=t[n];if(!e)return;e.programDateTime=r.programDateTime-1e3*e.duration,r=e}}(b,I),y},t}();function g(t,i){var r,n,e=new u.AttrList(t),s=null!=(r=e.enumeratedString("METHOD"))?r:"",a=e.URI,o=e.hexadecimalInteger("IV"),c=e.enumeratedString("KEYFORMATVERSIONS"),l=null!=(n=e.enumeratedString("KEYFORMAT"))?n:"identity";a&&e.IV&&!o&&f.logger.error("Invalid IV: "+e.IV);var v=a?y.resolve(a,i):"",d=(c||"1").split("/").map(Number).filter(Number.isFinite);return new h.LevelKey(s,v,l,d,o)}function b(t,i){["video","audio","text"].forEach((function(r){var n=t.filter((function(t){return(0,c.isCodecType)(t,r)}));if(n.length){var e=n.filter((function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)}));i[r+"Codec"]=e.length>0?e[0]:n[0],t=t.filter((function(t){return-1===n.indexOf(t)}))}})),i.unknownCodecs=t}function w(t,i,r){var n=i[r];n&&(t[r]=n)}function k(t,i){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=i&&i.programDateTime&&(t.programDateTime=i.endProgramDateTime),(0,n.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function S(t,i,r,n){t.relurl=i.URI,i.BYTERANGE&&t.setByteRange(i.BYTERANGE),t.level=r,t.sn="initSegment",n&&(t.levelkeys=n),t.initSegment=null}function T(t,i,r){t.levelkeys=i;var n=r.encryptedFragments;n.length&&n[n.length-1].levelkeys===i||!Object.keys(i).some((function(t){return i[t].isCommonEncryption}))||n.push(t)}},"./src/loader/playlist-loader.ts":
|
|
167
|
-
/*!***************************************!*\
|
|
168
|
-
!*** ./src/loader/playlist-loader.ts ***!
|
|
169
|
-
\***************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>l});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ../events */"./src/events.ts"),s=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts"),h=r(/*! ../types/loader */"./src/types/loader.ts"),u=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function f(t,i){var r=t.url;return void 0!==r&&0!==r.indexOf("data:")||(r=i.url),r}var c=function(){function t(t){this.hls=void 0,this.loaders=Object.create(null),this.hls=t,this.registerListeners()}var i=t.prototype;return i.startLoad=function(){},i.stopLoad=function(){this.destroyInternalLoaders()},i.registerListeners=function(){var t=this.hls;t.on(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(e.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(e.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(e.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},i.unregisterListeners=function(){var t=this.hls;t.off(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(e.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(e.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(e.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},i.createInternalLoader=function(t){var i=this.hls.config,r=new(i.pLoader||i.loader)(i);return t.loader=r,this.loaders[t.type]=r,r},i.getInternalLoader=function(t){return this.loaders[t.type]},i.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},i.destroyInternalLoaders=function(){for(var t in this.loaders){var i=this.loaders[t];i&&i.destroy(),this.resetInternalLoader(t)}},i.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},i.onManifestLoading=function(t,i){this.load({id:null,groupId:null,level:0,responseType:"text",type:h.PlaylistContextType.MANIFEST,url:i.url,deliveryDirectives:null})},i.onLevelLoading=function(t,i){this.load({id:i.id,groupId:null,level:i.level,responseType:"text",type:h.PlaylistContextType.LEVEL,url:i.url,deliveryDirectives:i.deliveryDirectives})},i.onAudioTrackLoading=function(t,i){this.load({id:i.id,groupId:i.groupId,level:null,responseType:"text",type:h.PlaylistContextType.AUDIO_TRACK,url:i.url,deliveryDirectives:i.deliveryDirectives})},i.onSubtitleTrackLoading=function(t,i){this.load({id:i.id,groupId:i.groupId,level:null,responseType:"text",type:h.PlaylistContextType.SUBTITLE_TRACK,url:i.url,deliveryDirectives:i.deliveryDirectives})},i.load=function(t){var i,r,n,e,s,o,u=this.hls.config,f=this.getInternalLoader(t);if(f){var c=f.context;if(c&&c.url===t.url)return void a.logger.trace("[playlist-loader]: playlist request ongoing");a.logger.log("[playlist-loader]: aborting previous loader for type: "+t.type),f.abort()}switch(t.type){case h.PlaylistContextType.MANIFEST:r=u.manifestLoadingMaxRetry,n=u.manifestLoadingTimeOut,e=u.manifestLoadingRetryDelay,s=u.manifestLoadingMaxRetryTimeout;break;case h.PlaylistContextType.LEVEL:case h.PlaylistContextType.AUDIO_TRACK:case h.PlaylistContextType.SUBTITLE_TRACK:r=0,n=u.levelLoadingTimeOut;break;default:r=u.levelLoadingMaxRetry,n=u.levelLoadingTimeOut,e=u.levelLoadingRetryDelay,s=u.levelLoadingMaxRetryTimeout}if(f=this.createInternalLoader(t),null!==(i=t.deliveryDirectives)&&void 0!==i&&i.part&&(t.type===h.PlaylistContextType.LEVEL&&null!==t.level?o=this.hls.levels[t.level].details:t.type===h.PlaylistContextType.AUDIO_TRACK&&null!==t.id?o=this.hls.audioTracks[t.id].details:t.type===h.PlaylistContextType.SUBTITLE_TRACK&&null!==t.id&&(o=this.hls.subtitleTracks[t.id].details),o)){var l=o.partTarget,v=o.targetduration;l&&v&&(n=Math.min(1e3*Math.max(3*l,.8*v),n))}var d={timeout:n,maxRetry:r,retryDelay:e,maxRetryDelay:s,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};f.load(t,d,m)},i.loadsuccess=function(t,i,r,n){void 0===n&&(n=null),this.resetInternalLoader(r.type);var e=t.data;0===e.indexOf("#EXTM3U")?(i.parsing.start=performance.now(),e.indexOf("#EXTINF:")>0||e.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(t,i,r,n):this.handleMasterPlaylist(t,i,r,n)):this.handleManifestParsingError(t,r,"no EXTM3U delimiter",n)},i.loaderror=function(t,i,r){void 0===r&&(r=null),this.handleNetworkError(i,r,!1,t)},i.loadtimeout=function(t,i,r){void 0===r&&(r=null),this.handleNetworkError(i,r,!0)},i.handleMasterPlaylist=function(t,i,r,n){var s=this.hls,h=t.data,c=f(t,r),l=o.default.parseMasterPlaylist(h,c),v=l.levels,d=l.sessionData,m=l.sessionKeys;if(v.length){var p=v.map((function(t){return{id:t.attrs.AUDIO,audioCodec:t.audioCodec}})),y=v.map((function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}})),g=o.default.parseMasterPlaylistMedia(h,c,"AUDIO",p),b=o.default.parseMasterPlaylistMedia(h,c,"SUBTITLES",y),w=o.default.parseMasterPlaylistMedia(h,c,"CLOSED-CAPTIONS");g.length&&(g.some((function(t){return!t.url}))||!v[0].audioCodec||v[0].attrs.AUDIO||(a.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new u.AttrList({}),bitrate:0,url:""}))),s.trigger(e.Events.MANIFEST_LOADED,{levels:v,audioTracks:g,subtitles:b,captions:w,url:c,stats:i,networkDetails:n,sessionData:d,sessionKeys:m})}else this.handleManifestParsingError(t,r,"no level found in manifest",n)},i.handleTrackOrLevelPlaylist=function(t,i,r,a){var c=this.hls,l=r.id,v=r.level,d=r.type,m=f(t,r),p=(0,n.isFiniteNumber)(l)?l:0,y=(0,n.isFiniteNumber)(v)?v:p,g=function(t){switch(t.type){case h.PlaylistContextType.AUDIO_TRACK:return h.PlaylistLevelType.AUDIO;case h.PlaylistContextType.SUBTITLE_TRACK:return h.PlaylistLevelType.SUBTITLE;default:return h.PlaylistLevelType.MAIN}}(r),b=o.default.parseLevelPlaylist(t.data,m,y,g,p);if(b.fragments.length){if(d===h.PlaylistContextType.MANIFEST){var w={attrs:new u.AttrList({}),bitrate:0,details:b,name:"",url:m};c.trigger(e.Events.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:m,stats:i,networkDetails:a,sessionData:null,sessionKeys:null})}i.parsing.end=performance.now(),r.levelDetails=b,this.handlePlaylistLoaded(t,i,r,a)}else c.trigger(e.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:m,reason:"no fragments found in level",level:"number"==typeof r.level?r.level:void 0})},i.handleManifestParsingError=function(t,i,r,n){this.hls.trigger(e.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:i.type===h.PlaylistContextType.MANIFEST,url:t.url,reason:r,response:t,context:i,networkDetails:n})},i.handleNetworkError=function(t,i,r,n){void 0===r&&(r=!1),a.logger.warn("[playlist-loader]: A network "+(r?"timeout":"error")+" occurred while loading "+t.type+" level: "+t.level+" id: "+t.id+' group-id: "'+t.groupId+'"');var o=s.ErrorDetails.UNKNOWN,u=!1,f=this.getInternalLoader(t);switch(t.type){case h.PlaylistContextType.MANIFEST:o=r?s.ErrorDetails.MANIFEST_LOAD_TIMEOUT:s.ErrorDetails.MANIFEST_LOAD_ERROR,u=!0;break;case h.PlaylistContextType.LEVEL:o=r?s.ErrorDetails.LEVEL_LOAD_TIMEOUT:s.ErrorDetails.LEVEL_LOAD_ERROR,u=!1;break;case h.PlaylistContextType.AUDIO_TRACK:o=r?s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case h.PlaylistContextType.SUBTITLE_TRACK:o=r?s.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:s.ErrorDetails.SUBTITLE_LOAD_ERROR,u=!1}f&&this.resetInternalLoader(t.type);var c={type:s.ErrorTypes.NETWORK_ERROR,details:o,fatal:u,url:t.url,loader:f,context:t,networkDetails:i};n&&(c.response=n),this.hls.trigger(e.Events.ERROR,c)},i.handlePlaylistLoaded=function(t,i,r,n){var s=r.type,a=r.level,o=r.id,u=r.groupId,f=r.loader,c=r.levelDetails,l=r.deliveryDirectives;if(null!=c&&c.targetduration){if(f)switch(c.live&&(f.getCacheAge&&(c.ageHeader=f.getCacheAge()||0),f.getCacheAge&&!isNaN(c.ageHeader)||(c.ageHeader=0)),s){case h.PlaylistContextType.MANIFEST:case h.PlaylistContextType.LEVEL:this.hls.trigger(e.Events.LEVEL_LOADED,{details:c,level:a||0,id:o||0,stats:i,networkDetails:n,deliveryDirectives:l});break;case h.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(e.Events.AUDIO_TRACK_LOADED,{details:c,id:o||0,groupId:u||"",stats:i,networkDetails:n,deliveryDirectives:l});break;case h.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(e.Events.SUBTITLE_TRACK_LOADED,{details:c,id:o||0,groupId:u||"",stats:i,networkDetails:n,deliveryDirectives:l})}}else this.handleManifestParsingError(t,r,"invalid target duration",n)},t}();const l=c},"./src/polyfills/number.ts":
|
|
170
|
-
/*!*********************************!*\
|
|
171
|
-
!*** ./src/polyfills/number.ts ***!
|
|
172
|
-
\*********************************/(t,i,r)=>{r.r(i),r.d(i,{MAX_SAFE_INTEGER:()=>e,isFiniteNumber:()=>n});var n=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},e=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":
|
|
173
|
-
/*!*********************************!*\
|
|
174
|
-
!*** ./src/remux/aac-helper.ts ***!
|
|
175
|
-
\*********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>n});const n=function(){function t(){}return t.getSilentFrame=function(t,i){if("mp4a.40.2"===t){if(1===i)return new Uint8Array([0,200,0,128,35,128]);if(2===i)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===i)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===i)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===i)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===i)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===i)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===i)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===i)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},t}()},"./src/remux/mp4-generator.ts":
|
|
176
|
-
/*!************************************!*\
|
|
177
|
-
!*** ./src/remux/mp4-generator.ts ***!
|
|
178
|
-
\************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>s});var n=Math.pow(2,32)-1,e=function(){function t(){}return t.init=function(){var i;for(i in t.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]})t.types.hasOwnProperty(i)&&(t.types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);t.HDLR_TYPES={video:r,audio:n};var e=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);t.STTS=t.STSC=t.STCO=s,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),h=new Uint8Array([0,0,0,1]);t.FTYP=t.box(t.types.ftyp,a,h,a,o),t.DINF=t.box(t.types.dinf,t.box(t.types.dref,e))},t.box=function(t){for(var i=8,r=arguments.length,n=new Array(r>1?r-1:0),e=1;e<r;e++)n[e-1]=arguments[e];for(var s=n.length,a=s;s--;)i+=n[s].byteLength;var o=new Uint8Array(i);for(o[0]=i>>24&255,o[1]=i>>16&255,o[2]=i>>8&255,o[3]=255&i,o.set(t,4),s=0,i=8;s<a;s++)o.set(n[s],i),i+=n[s].byteLength;return o},t.hdlr=function(i){return t.box(t.types.hdlr,t.HDLR_TYPES[i])},t.mdat=function(i){return t.box(t.types.mdat,i)},t.mdhd=function(i,r){r*=i;var e=Math.floor(r/(n+1)),s=Math.floor(r%(n+1));return t.box(t.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,e>>24,e>>16&255,e>>8&255,255&e,s>>24,s>>16&255,s>>8&255,255&s,85,196,0,0]))},t.mdia=function(i){return t.box(t.types.mdia,t.mdhd(i.timescale,i.duration),t.hdlr(i.type),t.minf(i))},t.mfhd=function(i){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i]))},t.minf=function(i){return t.box(t.types.minf,"audio"===i.type?t.box(t.types.smhd,t.SMHD):t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(i))},t.moof=function(i,r,n){return t.box(t.types.moof,t.mfhd(i),t.traf(n,r))},t.moov=function(i){for(var r=i.length,n=[];r--;)n[r]=t.trak(i[r]);return t.box.apply(null,[t.types.moov,t.mvhd(i[0].timescale,i[0].duration)].concat(n).concat(t.mvex(i)))},t.mvex=function(i){for(var r=i.length,n=[];r--;)n[r]=t.trex(i[r]);return t.box.apply(null,[t.types.mvex].concat(n))},t.mvhd=function(i,r){r*=i;var e=Math.floor(r/(n+1)),s=Math.floor(r%(n+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,e>>24,e>>16&255,e>>8&255,255&e,s>>24,s>>16&255,s>>8&255,255&s,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return t.box(t.types.mvhd,a)},t.sdtp=function(i){var r,n,e=i.samples||[],s=new Uint8Array(4+e.length);for(r=0;r<e.length;r++)s[r+4]=(n=e[r].flags).dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return t.box(t.types.sdtp,s)},t.stbl=function(i){return t.box(t.types.stbl,t.stsd(i),t.box(t.types.stts,t.STTS),t.box(t.types.stsc,t.STSC),t.box(t.types.stsz,t.STSZ),t.box(t.types.stco,t.STCO))},t.avc1=function(i){var r,n,e,s=[],a=[];for(r=0;r<i.sps.length;r++)s.push((e=(n=i.sps[r]).byteLength)>>>8&255),s.push(255&e),s=s.concat(Array.prototype.slice.call(n));for(r=0;r<i.pps.length;r++)a.push((e=(n=i.pps[r]).byteLength)>>>8&255),a.push(255&e),a=a.concat(Array.prototype.slice.call(n));var o=t.box(t.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|i.sps.length].concat(s).concat([i.pps.length]).concat(a))),h=i.width,u=i.height,f=i.pixelRatio[0],c=i.pixelRatio[1];return t.box(t.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,h>>8&255,255&h,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,255&f,c>>24,c>>16&255,c>>8&255,255&c])))},t.esds=function(t){var i=t.config.length;return new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(t.config).concat([6,1,2]))},t.mp4a=function(i){var r=i.samplerate;return t.box(t.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),t.box(t.types.esds,t.esds(i)))},t.mp3=function(i){var r=i.samplerate;return t.box(t.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},t.stsd=function(i){return t.box(t.types.stsd,t.STSD,"audio"===i.type?"mp3"===i.segmentCodec&&"mp3"===i.codec?t.mp3(i):t.mp4a(i):t.avc1(i))},t.tkhd=function(i){var r=i.id,e=i.duration*i.timescale,s=i.width,a=i.height,o=Math.floor(e/(n+1)),h=Math.floor(e%(n+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,h>>24,h>>16&255,h>>8&255,255&h,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,255&s,0,0,a>>8&255,255&a,0,0]))},t.traf=function(i,r){var e=t.sdtp(i),s=i.id,a=Math.floor(r/(n+1)),o=Math.floor(r%(n+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o])),t.trun(i,e.length+16+20+8+16+8+8),e)},t.trak=function(i){return i.duration=i.duration||4294967295,t.box(t.types.trak,t.tkhd(i),t.mdia(i))},t.trex=function(i){var r=i.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function(i,r){var n,e,s,a,o,h,u=i.samples||[],f=u.length,c=12+16*f,l=new Uint8Array(c);for(l.set(["video"===i.type?1:0,0,15,1,f>>>24&255,f>>>16&255,f>>>8&255,255&f,(r+=8+c)>>>24&255,r>>>16&255,r>>>8&255,255&r],0),n=0;n<f;n++)l.set([(s=(e=u[n]).duration)>>>24&255,s>>>16&255,s>>>8&255,255&s,(a=e.size)>>>24&255,a>>>16&255,a>>>8&255,255&a,(o=e.flags).isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,(h=e.cts)>>>24&255,h>>>16&255,h>>>8&255,255&h],12+16*n);return t.box(t.types.trun,l)},t.initSegment=function(i){t.types||t.init();var r=t.moov(i),n=new Uint8Array(t.FTYP.byteLength+r.byteLength);return n.set(t.FTYP),n.set(r,t.FTYP.byteLength),n},t}();e.types=void 0,e.HDLR_TYPES=void 0,e.STTS=void 0,e.STSC=void 0,e.STCO=void 0,e.STSZ=void 0,e.VMHD=void 0,e.SMHD=void 0,e.STSD=void 0,e.FTYP=void 0,e.DINF=void 0;const s=e},"./src/remux/mp4-remuxer.ts":
|
|
179
|
-
/*!**********************************!*\
|
|
180
|
-
!*** ./src/remux/mp4-remuxer.ts ***!
|
|
181
|
-
\**********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>d,flushTextTrackMetadataCueSamples:()=>p,flushTextTrackUserdataCueSamples:()=>y,normalizePts:()=>m});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ./aac-helper */"./src/remux/aac-helper.ts"),s=r(/*! ./mp4-generator */"./src/remux/mp4-generator.ts"),a=r(/*! ../events */"./src/events.ts"),o=r(/*! ../errors */"./src/errors.ts"),h=r(/*! ../utils/logger */"./src/utils/logger.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),f=r(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function c(){return c=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},c.apply(this,arguments)}var l=null,v=null,d=function(){function t(t,i,r){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=i,this.typeSupported=r,this.ISGenerated=!1,null===l){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);l=n?parseInt(n[1]):0}if(null===v){var e=navigator.userAgent.match(/Safari\/(\d+)/i);v=e?parseInt(e[1]):0}}var i=t.prototype;return i.destroy=function(){},i.resetTimeStamp=function(t){h.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},i.resetNextTimestamp=function(){h.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},i.resetInitSegment=function(){h.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},i.getVideoStartPts=function(t){var i=!1,r=t.reduce((function(t,r){var n=r.pts-t;return n<-4294967296?(i=!0,m(t,r.pts)):n>0?t:r.pts}),t[0].pts);return i&&h.logger.debug("PTS rollover detected"),r},i.remux=function(t,i,r,n,e,s,a,o){var f,c,l,v,d,g,b=e,w=e,k=i.pid>-1,S=i.samples.length,T=t.samples.length>0,E=a&&S>0||S>1;if((!(t.pid>-1)||T)&&(!k||E)||this.ISGenerated||a){this.ISGenerated||(l=this.generateIS(t,i,e));var A,M=this.isVideoContiguous,x=-1;if(E&&(x=function(t){for(var i=0;i<t.length;i++)if(t[i].key)return i;return-1}(i.samples),!M&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,x>0){h.logger.warn("[mp4-remuxer]: Dropped "+x+" out of "+S+" video samples due to a missing keyframe");var O=this.getVideoStartPts(i.samples);i.samples=i.samples.slice(x),i.dropped+=x,A=w+=(i.samples[0].pts-O)/i.inputTimeScale}else-1===x&&(h.logger.warn("[mp4-remuxer]: No keyframe found out of "+S+" video samples"),g=!1);if(this.ISGenerated){if(T&&E){var D=this.getVideoStartPts(i.samples),I=(m(t.samples[0].pts,D)-D)/i.inputTimeScale;b+=Math.max(0,I),w+=Math.max(0,-I)}if(T){if(t.samplerate||(h.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),l=this.generateIS(t,i,e)),c=this.remuxAudio(t,b,this.isAudioContiguous,s,k||E||o===u.PlaylistLevelType.AUDIO?w:void 0),E){var C=c?c.endPTS-c.startPTS:0;i.inputTimeScale||(h.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),l=this.generateIS(t,i,e)),f=this.remuxVideo(i,w,M,C)}}else E&&(f=this.remuxVideo(i,w,M,0));f&&(f.firstKeyFrame=x,f.independent=-1!==x,f.firstKeyFramePTS=A)}}return this.ISGenerated&&(r.samples.length&&(d=p(r,e,this._initPTS,this._initDTS)),n.samples.length&&(v=y(n,e,this._initPTS))),{audio:c,video:f,initSegment:l,independent:g,text:v,id3:d}},i.generateIS=function(t,i,r){var e,a,o,h=t.samples,u=i.samples,f=this.typeSupported,c={},l=!(0,n.isFiniteNumber)(this._initPTS),v="audio/mp4";if(l&&(e=a=1/0),t.config&&h.length&&(t.timescale=t.samplerate,"mp3"===t.segmentCodec&&(f.mpeg?(v="audio/mpeg",t.codec=""):f.mp3&&(t.codec="mp3")),c.audio={id:"audio",container:v,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&f.mpeg?new Uint8Array(0):s.default.initSegment([t]),metadata:{channelCount:t.channelCount}},l&&(o=t.inputTimeScale,e=a=h[0].pts-Math.round(o*r))),i.sps&&i.pps&&u.length&&(i.timescale=i.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:i.codec,initSegment:s.default.initSegment([i]),metadata:{width:i.width,height:i.height}},l)){o=i.inputTimeScale;var d=this.getVideoStartPts(u),p=Math.round(o*r);a=Math.min(a,m(u[0].dts,d)-p),e=Math.min(e,d-p)}if(Object.keys(c).length)return this.ISGenerated=!0,l&&(this._initPTS=e,this._initDTS=a),{tracks:c,initPTS:e,timescale:o}},i.remuxVideo=function(t,i,r,n){var e,u,d=t.inputTimeScale,p=t.samples,y=[],b=p.length,w=this._initPTS,k=this.nextAvcDts,S=8,T=this.videoSampleDuration,E=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,M=!1;r&&null!==k||(k=i*d-(p[0].pts-m(p[0].dts,p[0].pts)));for(var x=0;x<b;x++){var O=p[x];O.pts=m(O.pts-w,k),O.dts=m(O.dts-w,k),O.dts<p[x>0?x-1:x].dts&&(M=!0)}M&&p.sort((function(t,i){return t.dts-i.dts||t.pts-i.pts}));var D=p[p.length-1].dts-(e=p[0].dts),I=D?Math.round(D/(b-1)):T||t.inputTimeScale/30;if(r){var C=e-k,L=C>I,P=C<-1;if((L||P)&&(h.logger.warn(L?"AVC: "+(0,f.toMsFromMpegTsClock)(C,!0)+" ms ("+C+"dts) hole between fragments detected, filling it":"AVC: "+(0,f.toMsFromMpegTsClock)(-C,!0)+" ms ("+C+"dts) overlapping between fragments detected"),!P||k>p[0].pts)){var j=p[0].pts-C;p[0].dts=e=k,p[0].pts=j,h.logger.log("Video: First PTS/DTS adjusted: "+(0,f.toMsFromMpegTsClock)(j,!0)+"/"+(0,f.toMsFromMpegTsClock)(e,!0)+", delta: "+(0,f.toMsFromMpegTsClock)(C,!0)+" ms")}}e=Math.max(0,e);for(var R=0,U=0,N=0;N<b;N++){for(var F=p[N],B=F.units,_=B.length,G=0,K=0;K<_;K++)G+=B[K].data.length;U+=G,R+=_,F.length=G,F.dts=Math.max(F.dts,e),E=Math.min(F.pts,E),A=Math.max(F.pts,A)}u=p[b-1].dts;var X,H=U+4*R+8;try{X=new Uint8Array(H)}catch(t){return void this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:H,reason:"fail allocating video mdat "+H})}var V=new DataView(X.buffer);V.setUint32(0,H),X.set(s.default.types.mdat,4);for(var W=!1,q=Number.POSITIVE_INFINITY,Y=Number.POSITIVE_INFINITY,z=Number.NEGATIVE_INFINITY,$=Number.NEGATIVE_INFINITY,J=0;J<b;J++){for(var Q=p[J],Z=Q.units,tt=0,it=0,rt=Z.length;it<rt;it++){var nt=Z[it],et=nt.data,st=nt.data.byteLength;V.setUint32(S,st),X.set(et,S+=4),S+=st,tt+=4+st}var at=void 0;if(J<b-1)T=p[J+1].dts-Q.dts,at=p[J+1].pts-Q.pts;else{var ot=this.config,ht=J>0?Q.dts-p[J-1].dts:I;if(at=J>0?Q.pts-p[J-1].pts:I,ot.stretchShortVideoTrack&&null!==this.nextAudioPts){var ut=Math.floor(ot.maxBufferHole*d),ft=(n?E+n*d:this.nextAudioPts)-Q.pts;ft>ut?((T=ft-ht)<0?T=ht:W=!0,h.logger.log("[mp4-remuxer]: It is approximately "+ft/90+" ms to the next segment; using duration "+T/90+" ms for the last video frame.")):T=ht}else T=ht}var ct=Math.round(Q.pts-Q.dts);q=Math.min(q,T),z=Math.max(z,T),Y=Math.min(Y,at),$=Math.max($,at),y.push(new g(Q.key,T,tt,ct))}if(y.length)if(l){if(l<70){var lt=y[0].flags;lt.dependsOn=2,lt.isNonSync=0}}else if(v&&$-Y<z-q&&I/z<.025&&0===y[0].cts){h.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var vt=e,dt=0,mt=y.length;dt<mt;dt++){var pt=vt+y[dt].duration;y[dt].duration=dt<mt-1?pt+y[dt+1].cts-(vt+y[dt].cts):dt?y[dt-1].duration:I,y[dt].cts=0,vt=pt}}console.assert(null!==T,"mp4SampleDuration must be computed"),this.nextAvcDts=k=u+(T=W||!T?I:T),this.videoSampleDuration=T,this.isVideoContiguous=!0;var yt={data1:s.default.moof(t.sequenceNumber++,e,c({},t,{samples:y})),data2:X,startPTS:E/d,endPTS:(A+T)/d,startDTS:e/d,endDTS:k/d,type:"video",hasAudio:!1,hasVideo:!0,nb:y.length,dropped:t.dropped};return t.samples=[],t.dropped=0,console.assert(X.length,"MDAT length must not be zero"),yt},i.remuxAudio=function(t,i,r,n,u){var f=t.inputTimeScale,l=f/(t.samplerate?t.samplerate:f),v="aac"===t.segmentCodec?1024:1152,d=v*l,p=this._initPTS,y="mp3"===t.segmentCodec&&this.typeSupported.mpeg,b=[],w=void 0!==u,k=t.samples,S=y?0:8,T=this.nextAudioPts||-1,E=i*f;if(this.isAudioContiguous=r=r||k.length&&T>0&&(n&&Math.abs(E-T)<9e3||Math.abs(m(k[0].pts-p,E)-T)<20*d),k.forEach((function(t){t.pts=m(t.pts-p,E)})),!r||T<0){if(k=k.filter((function(t){return t.pts>=0})),!k.length)return;T=0===u?0:n&&!w?Math.max(0,E):k[0].pts}if("aac"===t.segmentCodec)for(var A=this.config.maxAudioFramesDrift,M=0,x=T;M<k.length;M++){var O=k[M],D=O.pts,I=D-x,C=Math.abs(1e3*I/f);if(I<=-A*d&&w)0===M&&(h.logger.warn("Audio frame @ "+(D/f).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*I/f)+" ms."),this.nextAudioPts=T=x=D);else if(I>=A*d&&C<1e4&&w){var L=Math.round(I/d);(x=D-L*d)<0&&(L--,x+=d),0===M&&(this.nextAudioPts=T=x),h.logger.warn("[mp4-remuxer]: Injecting "+L+" audio frame @ "+(x/f).toFixed(3)+"s due to "+Math.round(1e3*I/f)+" ms gap.");for(var P=0;P<L;P++){var j=Math.max(x,0),R=e.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);R||(h.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),R=O.unit.subarray()),k.splice(M,0,{unit:R,pts:j}),x+=d,M++}}O.pts=x,x+=d}for(var U,N=null,F=null,B=0,_=k.length;_--;)B+=k[_].unit.byteLength;for(var G=0,K=k.length;G<K;G++){var X=k[G],H=X.unit,V=X.pts;if(null!==F)b[G-1].duration=Math.round((V-F)/l);else{if(r&&"aac"===t.segmentCodec&&(V=T),N=V,!(B>0))return;B+=S;try{U=new Uint8Array(B)}catch(t){return void this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:B,reason:"fail allocating audio mdat "+B})}y||(new DataView(U.buffer).setUint32(0,B),U.set(s.default.types.mdat,4))}U.set(H,S);var W=H.byteLength;S+=W,b.push(new g(!0,v,W,0)),F=V}var q=b.length;if(q){this.nextAudioPts=T=F+l*b[b.length-1].duration;var Y=y?new Uint8Array(0):s.default.moof(t.sequenceNumber++,N/l,c({},t,{samples:b}));t.samples=[];var z=N/f,$=T/f,J={data1:Y,data2:U,startPTS:z,endPTS:$,startDTS:z,endDTS:$,type:"audio",hasAudio:!0,hasVideo:!1,nb:q};return this.isAudioContiguous=!0,console.assert(U.length,"MDAT length must not be zero"),J}},i.remuxEmptyAudio=function(t,i,r,n){var s=t.inputTimeScale,a=this.nextAudioPts,o=(null!==a?a:n.startDTS*s)+this._initDTS,u=s/(t.samplerate?t.samplerate:s)*1024,f=Math.ceil((n.endDTS*s+this._initDTS-o)/u),c=e.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(h.logger.warn("[mp4-remuxer]: remux empty Audio"),c){for(var l=[],v=0;v<f;v++){var d=o+v*u;l.push({unit:c,pts:d,dts:d})}return t.samples=l,this.remuxAudio(t,i,r,!1)}h.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},t}();function m(t,i){var r;if(null===i)return t;for(r=i<t?-8589934592:8589934592;Math.abs(t-i)>4294967296;)t+=r;return t}function p(t,i,r,n){var e=t.samples.length;if(e){for(var s=t.inputTimeScale,a=0;a<e;a++){var o=t.samples[a];o.pts=m(o.pts-r,i*s)/s,o.dts=m(o.dts-n,i*s)/s}var h=t.samples;return t.samples=[],{samples:h}}}function y(t,i,r){var n=t.samples.length;if(n){for(var e=t.inputTimeScale,s=0;s<n;s++){var a=t.samples[s];a.pts=m(a.pts-r,i*e)/e}t.samples.sort((function(t,i){return t.pts-i.pts}));var o=t.samples;return t.samples=[],{samples:o}}}var g=function(t,i,r,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=r,this.cts=n,this.flags=new b(t)},b=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}},"./src/remux/passthrough-remuxer.ts":
|
|
182
|
-
/*!******************************************!*\
|
|
183
|
-
!*** ./src/remux/passthrough-remuxer.ts ***!
|
|
184
|
-
\******************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>u});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ./mp4-remuxer */"./src/remux/mp4-remuxer.ts"),s=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),a=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts");function h(t,i){var r=null==t?void 0:t.codec;return r&&r.length>4?r:"hvc1"===r||"hev1"===r?"hvc1.1.c.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||i===a.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}const u=function(){function t(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var i=t.prototype;return i.destroy=function(){},i.resetTimeStamp=function(t){this.initPTS=t,this.lastEndTime=null},i.resetNextTimestamp=function(){this.lastEndTime=null},i.resetInitSegment=function(t,i,r,n){this.audioCodec=i,this.videoCodec=r,this.generateInitSegment((0,s.patchEncyptionData)(t,n)),this.emitInitSegment=!0},i.generateInitSegment=function(t){var i=this.audioCodec,r=this.videoCodec;if(!t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var n=this.initData=(0,s.parseInitSegment)(t);i||(i=h(n.audio,a.ElementaryStreamTypes.AUDIO)),r||(r=h(n.video,a.ElementaryStreamTypes.VIDEO));var e={};n.audio&&n.video?e.audiovideo={container:"video/mp4",codec:i+","+r,initSegment:t,id:"main"}:n.audio?e.audio={container:"audio/mp4",codec:i,initSegment:t,id:"audio"}:n.video?e.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:o.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},i.remux=function(t,i,r,a,h){var u,f=this.initPTS,c=this.lastEndTime,l={audio:void 0,video:void 0,text:a,id3:r,initSegment:void 0};(0,n.isFiniteNumber)(c)||(c=this.lastEndTime=h||0);var v=i.samples;if(!v||!v.length)return l;var d={initPTS:void 0,timescale:1},m=this.initData;if(m&&m.length||(this.generateInitSegment(v),m=this.initData),!m||!m.length)return o.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),l;this.emitInitSegment&&(d.tracks=this.initTracks,this.emitInitSegment=!1);var p=(0,s.getStartDTS)(m,v);(0,n.isFiniteNumber)(f)||(this.initPTS=d.initPTS=f=p-h);var y=(0,s.getDuration)(v,m),g=t?p-f:c,b=g+y;(0,s.offsetStartDTS)(m,v,f),y>0?this.lastEndTime=b:(o.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var w=!!m.audio,k=!!m.video,S="";w&&(S+="audio"),k&&(S+="video");var T={data1:v,startPTS:g,startDTS:g,endPTS:b,endDTS:b,type:S,hasAudio:w,hasVideo:k,nb:1,dropped:0};l.audio="audio"===T.type?T:void 0,l.video="audio"!==T.type?T:void 0,l.initSegment=d;var E=null!=(u=this.initPTS)?u:0;return l.id3=(0,e.flushTextTrackMetadataCueSamples)(r,h,E,E),a.samples.length&&(l.text=(0,e.flushTextTrackUserdataCueSamples)(a,h,E)),l},t}()},"./src/task-loop.ts":
|
|
185
|
-
/*!**************************!*\
|
|
186
|
-
!*** ./src/task-loop.ts ***!
|
|
187
|
-
\**************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>n});var n=function(){function t(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var i=t.prototype;return i.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},i.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},i.onHandlerDestroyed=function(){},i.hasInterval=function(){return!!this._tickInterval},i.hasNextTick=function(){return!!this._tickTimer},i.setInterval=function(t){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,t),!0)},i.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},i.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},i.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},i.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},i.doTick=function(){},t}()},"./src/types/cmcd.ts":
|
|
188
|
-
/*!***************************!*\
|
|
189
|
-
!*** ./src/types/cmcd.ts ***!
|
|
190
|
-
\***************************/(t,i,r)=>{r.r(i),r.d(i,{CMCDObjectType:()=>n,CMCDStreamType:()=>s,CMCDStreamingFormat:()=>e,CMCDVersion:()=>a});var n,e,s,a=1;!function(t){t.MANIFEST="m",t.AUDIO="a",t.VIDEO="v",t.MUXED="av",t.INIT="i",t.CAPTION="c",t.TIMED_TEXT="tt",t.KEY="k",t.OTHER="o"}(n||(n={})),function(t){t.DASH="d",t.HLS="h",t.SMOOTH="s",t.OTHER="o"}(e||(e={})),function(t){t.VOD="v",t.LIVE="l"}(s||(s={}))},"./src/types/demuxer.ts":
|
|
191
|
-
/*!******************************!*\
|
|
192
|
-
!*** ./src/types/demuxer.ts ***!
|
|
193
|
-
\******************************/(t,i,r)=>{var n;r.r(i),r.d(i,{MetadataSchema:()=>n}),function(t){t.audioId3="org.id3",t.dateRange="com.apple.quicktime.HLS",t.emsg="https://aomedia.org/emsg/ID3"}(n||(n={}))},"./src/types/level.ts":
|
|
194
|
-
/*!****************************!*\
|
|
195
|
-
!*** ./src/types/level.ts ***!
|
|
196
|
-
\****************************/(t,i,r)=>{function n(t,i){for(var r=0;r<i.length;r++){var n=i[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(e=function(t){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?e:String(e)),n)}var e}r.r(i),r.d(i,{HdcpLevels:()=>s,HlsSkip:()=>e,HlsUrlParameters:()=>o,Level:()=>h,getSkipValue:()=>a});var e,s=["NONE","TYPE-0","TYPE-1","TYPE-2",null];function a(t,i){var r=t.canSkipUntil;return r&&(void 0!==i?i-t.endSN:0)<r?t.canSkipDateRanges?e.v2:e.Yes:e.No}!function(t){t.No="",t.Yes="YES",t.v2="v2"}(e||(e={}));var o=function(){function t(t,i,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=i,this.skip=r}return t.prototype.addDirectives=function(t){var i=new self.URL(t);return void 0!==this.msn&&i.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&i.searchParams.set("_HLS_part",this.part.toString()),this.skip&&i.searchParams.set("_HLS_skip",this.skip),i.href},t}(),h=function(){function t(t){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this.attrs=t.attrs,this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter((function(t){return t})).join(",").replace(/\.[^.,]+/g,"")}var i,r;return i=t,(r=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(t){var i=t%this.url.length;this._urlId!==i&&(this.details=void 0,this._urlId=i)}}])&&n(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),t}()},"./src/types/loader.ts":
|
|
197
|
-
/*!*****************************!*\
|
|
198
|
-
!*** ./src/types/loader.ts ***!
|
|
199
|
-
\*****************************/(t,i,r)=>{var n,e;r.r(i),r.d(i,{PlaylistContextType:()=>n,PlaylistLevelType:()=>e}),function(t){t.MANIFEST="manifest",t.LEVEL="level",t.AUDIO_TRACK="audioTrack",t.SUBTITLE_TRACK="subtitleTrack"}(n||(n={})),function(t){t.MAIN="main",t.AUDIO="audio",t.SUBTITLE="subtitle"}(e||(e={}))},"./src/types/transmuxer.ts":
|
|
200
|
-
/*!*********************************!*\
|
|
201
|
-
!*** ./src/types/transmuxer.ts ***!
|
|
202
|
-
\*********************************/(t,i,r)=>{r.r(i),r.d(i,{ChunkMetadata:()=>n});var n=function(t,i,r,n,e,s){void 0===n&&(n=0),void 0===e&&(e=-1),void 0===s&&(s=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=i,this.id=r,this.size=n,this.part=e,this.partial=s}},"./src/utils/attr-list.ts":
|
|
203
|
-
/*!********************************!*\
|
|
204
|
-
!*** ./src/utils/attr-list.ts ***!
|
|
205
|
-
\********************************/(t,i,r)=>{r.r(i),r.d(i,{AttrList:()=>s});var n=/^(\d+)x(\d+)$/,e=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,s=function(){function t(i){for(var r in"string"==typeof i&&(i=t.parseAttrList(i)),i)i.hasOwnProperty(r)&&(this[r]=i[r])}var i=t.prototype;return i.decimalInteger=function(t){var i=parseInt(this[t],10);return i>Number.MAX_SAFE_INTEGER?1/0:i},i.hexadecimalInteger=function(t){if(this[t]){var i=(this[t]||"0x").slice(2);i=(1&i.length?"0":"")+i;for(var r=new Uint8Array(i.length/2),n=0;n<i.length/2;n++)r[n]=parseInt(i.slice(2*n,2*n+2),16);return r}return null},i.hexadecimalIntegerAsNumber=function(t){var i=parseInt(this[t],16);return i>Number.MAX_SAFE_INTEGER?1/0:i},i.decimalFloatingPoint=function(t){return parseFloat(this[t])},i.optionalFloat=function(t,i){var r=this[t];return r?parseFloat(r):i},i.enumeratedString=function(t){return this[t]},i.bool=function(t){return"YES"===this[t]},i.decimalResolution=function(t){var i=n.exec(this[t]);if(null!==i)return{width:parseInt(i[1],10),height:parseInt(i[2],10)}},t.parseAttrList=function(t){var i,r={};for(e.lastIndex=0;null!==(i=e.exec(t));){var n=i[2];0===n.indexOf('"')&&n.lastIndexOf('"')===n.length-1&&(n=n.slice(1,-1)),r[i[1]]=n}return r},t}()},"./src/utils/binary-search.ts":
|
|
206
|
-
/*!************************************!*\
|
|
207
|
-
!*** ./src/utils/binary-search.ts ***!
|
|
208
|
-
\************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>n});const n={search:function(t,i){for(var r=0,n=t.length-1,e=null,s=null;r<=n;){var a=i(s=t[e=(r+n)/2|0]);if(a>0)r=e+1;else{if(!(a<0))return s;n=e-1}}return null}}},"./src/utils/buffer-helper.ts":
|
|
209
|
-
/*!************************************!*\
|
|
210
|
-
!*** ./src/utils/buffer-helper.ts ***!
|
|
211
|
-
\************************************/(t,i,r)=>{r.r(i),r.d(i,{BufferHelper:()=>s});var n=r(/*! ./logger */"./src/utils/logger.ts"),e={length:0,start:function(){return 0},end:function(){return 0}},s=function(){function t(){}return t.isBuffered=function(i,r){try{if(i)for(var n=t.getBuffered(i),e=0;e<n.length;e++)if(r>=n.start(e)&&r<=n.end(e))return!0}catch(t){}return!1},t.bufferInfo=function(i,r,n){try{if(i){var e,s=t.getBuffered(i),a=[];for(e=0;e<s.length;e++)a.push({start:s.start(e),end:s.end(e)});return this.bufferedInfo(a,r,n)}}catch(t){}return{len:0,start:r,end:r,nextStart:void 0}},t.bufferedInfo=function(t,i,r){i=Math.max(0,i),t.sort((function(t,i){return t.start-i.start||i.end-t.end}));var n=[];if(r)for(var e=0;e<t.length;e++){var s=n.length;if(s){var a=n[s-1].end;t[e].start-a<r?t[e].end>a&&(n[s-1].end=t[e].end):n.push(t[e])}else n.push(t[e])}else n=t;for(var o,h=0,u=i,f=i,c=0;c<n.length;c++){var l=n[c].start,v=n[c].end;if(i+r>=l&&i<v)u=l,h=(f=v)-i;else if(i+r<l){o=l;break}}return{len:h,start:u||0,end:f||0,nextStart:o}},t.getBuffered=function(t){try{return t.buffered}catch(t){return n.logger.log("failed to get media.buffered",t),e}},t}()},"./src/utils/cea-608-parser.ts":
|
|
212
|
-
/*!*************************************!*\
|
|
213
|
-
!*** ./src/utils/cea-608-parser.ts ***!
|
|
214
|
-
\*************************************/(t,i,r)=>{r.r(i),r.d(i,{CaptionScreen:()=>b,Row:()=>g,default:()=>T});var n,e=r(/*! ../utils/logger */"./src/utils/logger.ts"),s={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},a=function(t){var i=t;return s.hasOwnProperty(t)&&(i=s[t]),String.fromCharCode(i)},o=15,h=100,u={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},f={17:2,18:4,21:6,22:8,23:10,19:13,20:15},c={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},l={25:2,26:4,29:6,30:8,31:10,27:13,28:15},v=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];!function(t){t[t.ERROR=0]="ERROR",t[t.TEXT=1]="TEXT",t[t.WARNING=2]="WARNING",t[t.INFO=2]="INFO",t[t.DEBUG=3]="DEBUG",t[t.DATA=3]="DATA"}(n||(n={}));var d=function(){function t(){this.time=null,this.verboseLevel=n.ERROR}return t.prototype.log=function(t,i){if(this.verboseLevel>=t){var r="function"==typeof i?i():i;e.logger.log(this.time+" ["+t+"] "+r)}},t}(),m=function(t){for(var i=[],r=0;r<t.length;r++)i.push(t[r].toString(16));return i},p=function(){function t(t,i,r,n,e){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=i||!1,this.italics=r||!1,this.background=n||"black",this.flash=e||!1}var i=t.prototype;return i.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},i.setStyles=function(t){for(var i=["foreground","underline","italics","background","flash"],r=0;r<i.length;r++){var n=i[r];t.hasOwnProperty(n)&&(this[n]=t[n])}},i.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},i.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},i.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},i.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),y=function(){function t(t,i,r,n,e,s){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new p(i,r,n,e,s)}var i=t.prototype;return i.reset=function(){this.uchar=" ",this.penState.reset()},i.setChar=function(t,i){this.uchar=t,this.penState.copy(i)},i.setPenState=function(t){this.penState.copy(t)},i.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},i.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},i.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},t}(),g=function(){function t(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var i=0;i<h;i++)this.chars.push(new y);this.logger=t,this.pos=0,this.currPenState=new p}var i=t.prototype;return i.equals=function(t){for(var i=!0,r=0;r<h;r++)if(!this.chars[r].equals(t.chars[r])){i=!1;break}return i},i.copy=function(t){for(var i=0;i<h;i++)this.chars[i].copy(t.chars[i])},i.isEmpty=function(){for(var t=!0,i=0;i<h;i++)if(!this.chars[i].isEmpty()){t=!1;break}return t},i.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(n.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>h&&(this.logger.log(n.DEBUG,"Too large cursor position "+this.pos),this.pos=h)},i.moveCursor=function(t){var i=this.pos+t;if(t>1)for(var r=this.pos+1;r<i+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(i)},i.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},i.insertChar=function(t){var i=this;t>=144&&this.backSpace();var r=a(t);this.pos>=h?this.logger.log(n.ERROR,(function(){return"Cannot insert "+t.toString(16)+" ("+r+") at position "+i.pos+". Skipping it!"})):(this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1))},i.clearFromPos=function(t){var i;for(i=t;i<h;i++)this.chars[i].reset()},i.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},i.clearToEndOfRow=function(){this.clearFromPos(this.pos)},i.getTextString=function(){for(var t=[],i=!0,r=0;r<h;r++){var n=this.chars[r].uchar;" "!==n&&(i=!1),t.push(n)}return i?"":t.join("")},i.setPenStyles=function(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)},t}(),b=function(){function t(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var i=0;i<o;i++)this.rows.push(new g(t));this.logger=t,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var i=t.prototype;return i.reset=function(){for(var t=0;t<o;t++)this.rows[t].clear();this.currRow=14},i.equals=function(t){for(var i=!0,r=0;r<o;r++)if(!this.rows[r].equals(t.rows[r])){i=!1;break}return i},i.copy=function(t){for(var i=0;i<o;i++)this.rows[i].copy(t.rows[i])},i.isEmpty=function(){for(var t=!0,i=0;i<o;i++)if(!this.rows[i].isEmpty()){t=!1;break}return t},i.backSpace=function(){this.rows[this.currRow].backSpace()},i.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},i.insertChar=function(t){this.rows[this.currRow].insertChar(t)},i.setPen=function(t){this.rows[this.currRow].setPenStyles(t)},i.moveCursor=function(t){this.rows[this.currRow].moveCursor(t)},i.setCursor=function(t){this.logger.log(n.INFO,"setCursor: "+t),this.rows[this.currRow].setCursor(t)},i.setPAC=function(t){this.logger.log(n.INFO,(function(){return"pacData = "+JSON.stringify(t)}));var i=t.row-1;if(this.nrRollUpRows&&i<this.nrRollUpRows-1&&(i=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==i){for(var r=0;r<o;r++)this.rows[r].clear();var e=this.currRow+1-this.nrRollUpRows,s=this.lastOutputScreen;if(s){var a=s.rows[e].cueStartTime,h=this.logger.time;if(a&&null!==h&&a<h)for(var u=0;u<this.nrRollUpRows;u++)this.rows[i-this.nrRollUpRows+u+1].copy(s.rows[e+u])}}this.currRow=i;var f=this.rows[this.currRow];if(null!==t.indent){var c=Math.max(t.indent-1,0);f.setCursor(t.indent),t.color=f.chars[c].penState.foreground}this.setPen({foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1})},i.setBkgData=function(t){this.logger.log(n.INFO,(function(){return"bkgData = "+JSON.stringify(t)})),this.backSpace(),this.setPen(t),this.insertChar(32)},i.setRollUpRows=function(t){this.nrRollUpRows=t},i.rollUp=function(){var t=this;if(null!==this.nrRollUpRows){this.logger.log(n.TEXT,(function(){return t.getDisplayText()}));var i=this.rows.splice(this.currRow+1-this.nrRollUpRows,1)[0];i.clear(),this.rows.splice(this.currRow,0,i),this.logger.log(n.INFO,"Rolling up")}else this.logger.log(n.DEBUG,"roll_up but nrRollUpRows not set yet")},i.getDisplayText=function(t){t=t||!1;for(var i=[],r="",n=0;n<o;n++){var e=this.rows[n].getTextString();e&&i.push(t?"Row "+(n+1)+": '"+e+"'":e.trim())}return i.length>0&&(r=t?"["+i.join(" | ")+"]":i.join("\n")),r},i.getTextAndFormat=function(){return this.rows},t}(),w=function(){function t(t,i,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=i,this.mode=null,this.verbose=0,this.displayedMemory=new b(r),this.nonDisplayedMemory=new b(r),this.lastOutputScreen=new b(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var i=t.prototype;return i.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},i.getHandler=function(){return this.outputFilter},i.setHandler=function(t){this.outputFilter=t},i.setPAC=function(t){this.writeScreen.setPAC(t)},i.setBkgData=function(t){this.writeScreen.setBkgData(t)},i.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(n.INFO,(function(){return"MODE="+t})),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},i.insertChars=function(t){for(var i=this,r=0;r<t.length;r++)this.writeScreen.insertChar(t[r]);var e=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(n.INFO,(function(){return e+": "+i.writeScreen.getDisplayText(!0)})),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(n.TEXT,(function(){return"DISPLAYED: "+i.displayedMemory.getDisplayText(!0)})),this.outputDataUpdate())},i.ccRCL=function(){this.logger.log(n.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},i.ccBS=function(){this.logger.log(n.INFO,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},i.ccAOF=function(){},i.ccAON=function(){},i.ccDER=function(){this.logger.log(n.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},i.ccRU=function(t){this.logger.log(n.INFO,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},i.ccFON=function(){this.logger.log(n.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},i.ccRDC=function(){this.logger.log(n.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},i.ccTR=function(){this.logger.log(n.INFO,"TR"),this.setMode("MODE_TEXT")},i.ccRTD=function(){this.logger.log(n.INFO,"RTD"),this.setMode("MODE_TEXT")},i.ccEDM=function(){this.logger.log(n.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},i.ccCR=function(){this.logger.log(n.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},i.ccENM=function(){this.logger.log(n.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},i.ccEOC=function(){var t=this;if(this.logger.log(n.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var i=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=i,this.writeScreen=this.nonDisplayedMemory,this.logger.log(n.TEXT,(function(){return"DISP: "+t.displayedMemory.getDisplayText()}))}this.outputDataUpdate(!0)},i.ccTO=function(t){this.logger.log(n.INFO,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},i.ccMIDROW=function(t){var i={flash:!1};if(i.underline=t%2==1,i.italics=t>=46,i.italics)i.foreground="white";else{var r=Math.floor(t/2)-16;i.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(n.INFO,"MIDROW: "+JSON.stringify(i)),this.writeScreen.setPen(i)},i.outputDataUpdate=function(t){void 0===t&&(t=!1);var i=this.logger.time;null!==i&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,i,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:i):this.cueStartTime=i,this.lastOutputScreen.copy(this.displayedMemory))},i.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},t}();function k(t,i,r){r.a=t,r.b=i}function S(t,i,r){return r.a===t&&r.b===i}const T=function(){function t(t,i,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var n=new d;this.channels=[null,new w(t,i,n),new w(t+1,r,n)],this.cmdHistory={a:null,b:null},this.logger=n}var i=t.prototype;return i.getHandler=function(t){return this.channels[t].getHandler()},i.setHandler=function(t,i){this.channels[t].setHandler(i)},i.addData=function(t,i){var r,e,s,a=!1;this.logger.time=t;for(var o=0;o<i.length;o+=2)if(s=127&i[o+1],0!=(e=127&i[o])||0!==s){if(this.logger.log(n.DATA,"["+m([i[o],i[o+1]])+"] -> ("+m([e,s])+")"),(r=this.parseCmd(e,s))||(r=this.parseMidrow(e,s)),r||(r=this.parsePAC(e,s)),r||(r=this.parseBackgroundAttributes(e,s)),!r&&(a=this.parseChars(e,s))){var h=this.currentChannel;h&&h>0?this.channels[h].insertChars(a):this.logger.log(n.WARNING,"No channel found yet. TEXT-MODE?")}r||a||this.logger.log(n.WARNING,"Couldn't parse cleaned data "+m([e,s])+" orig: "+m([i[o],i[o+1]]))}},i.parseCmd=function(t,i){var r=this.cmdHistory;if(!((20===t||28===t||21===t||29===t)&&i>=32&&i<=47||(23===t||31===t)&&i>=33&&i<=35))return!1;if(S(t,i,r))return k(null,null,r),this.logger.log(n.DEBUG,"Repeated command ("+m([t,i])+") is dropped"),!0;var e=20===t||21===t||23===t?1:2,s=this.channels[e];return 20===t||21===t||28===t||29===t?32===i?s.ccRCL():33===i?s.ccBS():34===i?s.ccAOF():35===i?s.ccAON():36===i?s.ccDER():37===i?s.ccRU(2):38===i?s.ccRU(3):39===i?s.ccRU(4):40===i?s.ccFON():41===i?s.ccRDC():42===i?s.ccTR():43===i?s.ccRTD():44===i?s.ccEDM():45===i?s.ccCR():46===i?s.ccENM():47===i&&s.ccEOC():s.ccTO(i-32),k(t,i,r),this.currentChannel=e,!0},i.parseMidrow=function(t,i){var r=0;if((17===t||25===t)&&i>=32&&i<=47){if((r=17===t?1:2)!==this.currentChannel)return this.logger.log(n.ERROR,"Mismatch channel in midrow parsing"),!1;var e=this.channels[r];return!!e&&(e.ccMIDROW(i),this.logger.log(n.DEBUG,"MIDROW ("+m([t,i])+")"),!0)}return!1},i.parsePAC=function(t,i){var r=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&i>=64&&i<=127||(16===t||24===t)&&i>=64&&i<=95))return!1;if(S(t,i,r))return k(null,null,r),!0;var n=t<=23?1:2,e=this.channels[n];return!!e&&(e.setPAC(this.interpretPAC(i>=64&&i<=95?1===n?u[t]:c[t]:1===n?f[t]:l[t],i)),k(t,i,r),this.currentChannel=n,!0)},i.interpretPAC=function(t,i){var r,n={color:null,italics:!1,indent:null,underline:!1,row:t};return n.underline=1==(1&(r=i>95?i-96:i-64)),r<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((r-16)/2),n},i.parseChars=function(t,i){var r,e,s=null,o=null;if(t>=25?(r=2,o=t-8):(r=1,o=t),o>=17&&o<=19?(this.logger.log(n.INFO,"Special char '"+a(e=17===o?i+80:18===o?i+112:i+144)+"' in channel "+r),s=[e]):t>=32&&t<=127&&(s=0===i?[t]:[t,i]),s){var h=m(s);this.logger.log(n.DEBUG,"Char codes = "+h.join(",")),k(t,i,this.cmdHistory)}return s},i.parseBackgroundAttributes=function(t,i){var r;if(!((16===t||24===t)&&i>=32&&i<=47||(23===t||31===t)&&i>=45&&i<=47))return!1;var n={};return 16===t||24===t?(r=Math.floor((i-32)/2),n.background=v[r],i%2==1&&(n.background=n.background+"_semi")):45===i?n.background="transparent":(n.foreground="black",47===i&&(n.underline=!0)),this.channels[t<=23?1:2].setBkgData(n),k(t,i,this.cmdHistory),!0},i.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var i=this.channels[t];i&&i.reset()}this.cmdHistory={a:null,b:null}},i.cueSplitAtTime=function(t){for(var i=0;i<this.channels.length;i++){var r=this.channels[i];r&&r.cueSplitAtTime(t)}},t}()},"./src/utils/codecs.ts":
|
|
215
|
-
/*!*****************************!*\
|
|
216
|
-
!*** ./src/utils/codecs.ts ***!
|
|
217
|
-
\*****************************/(t,i,r)=>{r.r(i),r.d(i,{isCodecSupportedInMp4:()=>s,isCodecType:()=>e});var n={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function e(t,i){var r=n[i];return!!r&&!0===r[t.slice(0,4)]}function s(t,i){return MediaSource.isTypeSupported((i||"video")+'/mp4;codecs="'+t+'"')}},"./src/utils/cues.ts":
|
|
218
|
-
/*!***************************!*\
|
|
219
|
-
!*** ./src/utils/cues.ts ***!
|
|
220
|
-
\***************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>o});var n=r(/*! ./vttparser */"./src/utils/vttparser.ts"),e=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts"),s=r(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts"),a=/\s/;const o={newCue:function(t,i,r,o){for(var h,u,f,c,l,v=[],d=self.VTTCue||self.TextTrackCue,m=0;m<o.rows.length;m++)if(f=!0,c=0,l="",!(h=o.rows[m]).isEmpty()){for(var p=0;p<h.chars.length;p++)a.test(h.chars[p].uchar)&&f?c++:(l+=h.chars[p].uchar,f=!1);h.cueStartTime=i,i===r&&(r+=1e-4),c>=16?c--:c++;var y=(0,n.fixLineBreaks)(l.trim()),g=(0,e.generateCueId)(i,r,y);t&&t.cues&&t.cues.getCueById(g)||((u=new d(i,r,y)).id=g,u.line=m+1,u.align="left",u.position=10+Math.min(80,10*Math.floor(8*c/32)),v.push(u))}return t&&v.length&&(v.sort((function(t,i){return"auto"===t.line||"auto"===i.line?0:t.line>8&&i.line>8?i.line-t.line:t.line-i.line})),v.forEach((function(i){return(0,s.addCueToTrack)(t,i)}))),v}}},"./src/utils/discontinuities.ts":
|
|
221
|
-
/*!**************************************!*\
|
|
222
|
-
!*** ./src/utils/discontinuities.ts ***!
|
|
223
|
-
\**************************************/(t,i,r)=>{r.r(i),r.d(i,{adjustSlidingStart:()=>f,alignMediaPlaylistByPDT:()=>v,alignPDT:()=>l,alignStream:()=>c,findDiscontinuousReferenceFrag:()=>h,findFirstFragWithCC:()=>a,shouldAlignOnDiscontinuities:()=>o});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ./logger */"./src/utils/logger.ts"),s=r(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function a(t,i){for(var r=null,n=0,e=t.length;n<e;n++){var s=t[n];if(s&&s.cc===i){r=s;break}}return r}function o(t,i,r){return!(!i.details||!(r.endCC>r.startCC||t&&t.cc<r.startCC))}function h(t,i){var r=t.fragments,n=i.fragments;if(n.length&&r.length){var s=a(r,n[0].cc);if(s&&(!s||s.startPTS))return s;e.logger.log("No frag in previous level to align on")}else e.logger.log("No fragments to align")}function u(t,i){if(t){var r=t.start+i;t.start=t.startPTS=r,t.endPTS=r+t.duration}}function f(t,i){for(var r=i.fragments,n=0,e=r.length;n<e;n++)u(r[n],t);i.fragmentHint&&u(i.fragmentHint,t),i.alignedSliding=!0}function c(t,i,r){i&&(function(t,i,r){if(o(t,r,i)){var s=h(r.details,i);s&&(0,n.isFiniteNumber)(s.start)&&(e.logger.log("Adjusting PTS using last level due to CC increase within current level "+i.url),f(s.start,i))}}(t,r,i),!r.alignedSliding&&i.details&&l(r,i.details),r.alignedSliding||!i.details||r.skippedSegments||(0,s.adjustSliding)(i.details,r))}function l(t,i){if(i.fragments.length&&t.hasProgramDateTime&&i.hasProgramDateTime){var r=i.fragments[0].programDateTime,s=t.fragments[0].programDateTime,a=(s-r)/1e3+i.fragments[0].start;a&&(0,n.isFiniteNumber)(a)&&(e.logger.log("Adjusting PTS using programDateTime delta "+(s-r)+"ms, sliding:"+a.toFixed(3)+" "+t.url+" "),f(a,t))}}function v(t,i){if(t.hasProgramDateTime&&i.hasProgramDateTime){var r=t.fragments,n=i.fragments;if(r.length&&n.length){var e=n[Math.round(n.length/2)-1],s=a(r,e.cc)||r[Math.round(r.length/2)-1],o=e.programDateTime,h=s.programDateTime;null!==o&&null!==h&&f((h-o)/1e3-(s.start-e.start),t)}}}},"./src/utils/ewma-bandwidth-estimator.ts":
|
|
224
|
-
/*!***********************************************!*\
|
|
225
|
-
!*** ./src/utils/ewma-bandwidth-estimator.ts ***!
|
|
226
|
-
\***********************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>e});var n=r(/*! ../utils/ewma */"./src/utils/ewma.ts");const e=function(){function t(t,i,r){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new n.default(t),this.fast_=new n.default(i)}var i=t.prototype;return i.update=function(t,i){var r=this.slow_,e=this.fast_;this.slow_.halfLife!==t&&(this.slow_=new n.default(t,r.getEstimate(),r.getTotalWeight())),this.fast_.halfLife!==i&&(this.fast_=new n.default(i,e.getEstimate(),e.getTotalWeight()))},i.sample=function(t,i){var r=(t=Math.max(t,this.minDelayMs_))/1e3,n=8*i/r;this.fast_.sample(r,n),this.slow_.sample(r,n)},i.canEstimate=function(){var t=this.fast_;return t&&t.getTotalWeight()>=this.minWeight_},i.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},i.destroy=function(){},t}()},"./src/utils/ewma.ts":
|
|
227
|
-
/*!***************************!*\
|
|
228
|
-
!*** ./src/utils/ewma.ts ***!
|
|
229
|
-
\***************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>n});const n=function(){function t(t,i,r){void 0===i&&(i=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=i,this.totalWeight_=r}var i=t.prototype;return i.sample=function(t,i){var r=Math.pow(this.alpha_,t);this.estimate_=i*(1-r)+r*this.estimate_,this.totalWeight_+=t},i.getTotalWeight=function(){return this.totalWeight_},i.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},t}()},"./src/utils/fetch-loader.ts":
|
|
230
|
-
/*!***********************************!*\
|
|
231
|
-
!*** ./src/utils/fetch-loader.ts ***!
|
|
232
|
-
\***********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>p,fetchSupported:()=>l});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function a(t){var i="function"==typeof Map?new Map:void 0;return a=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,r)}function r(){return o(t,arguments,f(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),u(r,t)},a(t)}function o(t,i,r){return o=h()?Reflect.construct.bind():function(t,i,r){var n=[null];n.push.apply(n,i);var e=new(Function.bind.apply(t,n));return r&&u(e,r.prototype),e},o.apply(null,arguments)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,i){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},u(t,i)}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function c(){return c=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},c.apply(this,arguments)}function l(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}var v=function(){function t(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||d,this.controller=new self.AbortController,this.stats=new e.LoadStats}var i=t.prototype;return i.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},i.abortInternal=function(){var t=this.response;t&&t.ok||(this.stats.aborted=!0,this.controller.abort())},i.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},i.load=function(t,i,r){var e=this,s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();var a=function(t,i){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:i,headers:new self.Headers(c({},t.headers))};return t.rangeEnd&&r.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),r}(t,this.controller.signal),o=r.onProgress,h="arraybuffer"===t.responseType,u=h?"byteLength":"length";this.context=t,this.config=i,this.callbacks=r,this.request=this.fetchSetup(t,a),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout((function(){e.abortInternal(),r.onTimeout(s,t,e.response)}),i.timeout),self.fetch(this.request).then((function(r){if(e.response=e.loader=r,!r.ok)throw new m(r.statusText||"fetch, bad network response",r.status,r);return s.loading.first=Math.max(self.performance.now(),s.loading.start),s.total=parseInt(r.headers.get("Content-Length")||"0"),o&&(0,n.isFiniteNumber)(i.highWaterMark)?e.loadProgressively(r,s,t,i.highWaterMark,o):h?r.arrayBuffer():r.text()})).then((function(a){var h=e.response;self.clearTimeout(e.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);var f=a[u];f&&(s.loaded=s.total=f);var c={url:h.url,data:a};o&&!(0,n.isFiniteNumber)(i.highWaterMark)&&o(s,t,a,h),r.onSuccess(c,s,t,h)})).catch((function(i){self.clearTimeout(e.requestTimeout),s.aborted||r.onError({code:i&&i.code||0,text:i?i.message:null},t,i?i.details:null)}))},i.getCacheAge=function(){var t=null;if(this.response){var i=this.response.headers.get("age");t=i?parseFloat(i):null}return t},i.loadProgressively=function(t,i,r,n,e){void 0===n&&(n=0);var a=new s.default,o=t.body.getReader();return function s(){return o.read().then((function(o){if(o.done)return a.dataLength&&e(i,r,a.flush(),t),Promise.resolve(new ArrayBuffer(0));var h=o.value,u=h.length;return i.loaded+=u,u<n||a.dataLength?(a.push(h),a.dataLength>=n&&e(i,r,a.flush(),t)):e(i,r,h,t),s()})).catch((function(){return Promise.reject()}))}()},t}();function d(t,i){return new self.Request(t.url,i)}var m=function(t){var i,r;function n(i,r,n){var e;return(e=t.call(this,i)||this).code=void 0,e.details=void 0,e.code=r,e.details=n,e}return r=t,(i=n).prototype=Object.create(r.prototype),i.prototype.constructor=i,u(i,r),n}(a(Error));const p=v},"./src/utils/hex.ts":
|
|
233
|
-
/*!**************************!*\
|
|
234
|
-
!*** ./src/utils/hex.ts ***!
|
|
235
|
-
\**************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>n});const n={hexDump:function(t){for(var i="",r=0;r<t.length;r++){var n=t[r].toString(16);n.length<2&&(n="0"+n),i+=n}return i}}},"./src/utils/imsc1-ttml-parser.ts":
|
|
236
|
-
/*!****************************************!*\
|
|
237
|
-
!*** ./src/utils/imsc1-ttml-parser.ts ***!
|
|
238
|
-
\****************************************/(t,i,r)=>{r.r(i),r.d(i,{IMSC1_CODEC:()=>f,parseIMSC1:()=>d});var n=r(/*! ./mp4-tools */"./src/utils/mp4-tools.ts"),e=r(/*! ./vttparser */"./src/utils/vttparser.ts"),s=r(/*! ./vttcue */"./src/utils/vttcue.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),h=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function u(){return u=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},u.apply(this,arguments)}var f="stpp.ttml.im1t",c=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,l=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,v={left:"start",center:"center",right:"end",start:"start",end:"end"};function d(t,i,r,e,f){var c=(0,n.findBox)(new Uint8Array(t),["mdat"]);if(0!==c.length){var l=c.map((function(t){return(0,a.utf8ArrayToStr)(t)})),d=(0,o.toTimescaleFromScale)(i,1,r);try{l.forEach((function(t){return e(function(t,i){var r=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");var n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},e=Object.keys(n).reduce((function(t,i){return t[i]=r.getAttribute("ttp:"+i)||n[i],t}),{}),a="preserve"!==r.getAttribute("xml:space"),o=p(m(r,"styling","style")),f=p(m(r,"layout","region")),c=m(r,"body","[begin]");return[].map.call(c,(function(t){var r=y(t,a);if(!r||!t.hasAttribute("begin"))return null;var n=w(t.getAttribute("begin"),e),c=w(t.getAttribute("dur"),e),l=w(t.getAttribute("end"),e);if(null===n)throw b(t);if(null===l){if(null===c)throw b(t);l=n+c}var d=new s.default(n-i,l-i,r);d.id=(0,h.generateCueId)(d.startTime,d.endTime,d.text);var m=function(t,i,r){var n="http://www.w3.org/ns/ttml#styling",e=null,s=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;return s&&r.hasOwnProperty(s)&&(e=r[s]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(r,s){var a=g(i,n,s)||g(t,n,s)||g(e,n,s);return a&&(r[s]=a),r}),{})}(f[t.getAttribute("region")],o[t.getAttribute("style")],o),p=m.textAlign;if(p){var k=v[p];k&&(d.lineAlign=k),d.align=p}return u(d,m),d})).filter((function(t){return null!==t}))}(t,d))}))}catch(t){f(t)}}else f(new Error("Could not parse IMSC1 mdat"))}function m(t,i,r){var n=t.getElementsByTagName(i)[0];return n?[].slice.call(n.querySelectorAll(r)):[]}function p(t){return t.reduce((function(t,i){var r=i.getAttribute("xml:id");return r&&(t[r]=i),t}),{})}function y(t,i){return[].slice.call(t.childNodes).reduce((function(t,r,n){var e;return"br"===r.nodeName&&n?t+"\n":null!==(e=r.childNodes)&&void 0!==e&&e.length?y(r,i):i?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent}),"")}function g(t,i,r){return t&&t.hasAttributeNS(i,r)?t.getAttributeNS(i,r):null}function b(t){return new Error("Could not parse ttml timestamp "+t)}function w(t,i){if(!t)return null;var r=(0,e.parseTimeStamp)(t);return null===r&&(c.test(t)?r=function(t,i){var r=c.exec(t);return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+((0|r[4])+(0|r[5])/i.subFrameRate)/i.frameRate}(t,i):l.test(t)&&(r=function(t,i){var r=l.exec(t),n=Number(r[1]);switch(r[2]){case"h":return 3600*n;case"m":return 60*n;case"ms":return 1e3*n;case"f":return n/i.frameRate;case"t":return n/i.tickRate}return n}(t,i))),r}},"./src/utils/keysystem-util.ts":
|
|
239
|
-
/*!*************************************!*\
|
|
240
|
-
!*** ./src/utils/keysystem-util.ts ***!
|
|
241
|
-
\*************************************/(t,i,r)=>{r.r(i),r.d(i,{changeEndianness:()=>e,convertDataUriToArrayBytes:()=>s,strToUtf8array:()=>a});var n=r(/*! ./numeric-encoding-utils */"./src/utils/numeric-encoding-utils.ts");function e(t){var i=function(t,i,r){var n=t[i];t[i]=t[r],t[r]=n};i(t,0,3),i(t,1,2),i(t,4,5),i(t,6,7)}function s(t){var i,r,e=t.split(":"),s=null;if("data"===e[0]&&2===e.length){var o=e[1].split(";"),h=o[o.length-1].split(",");if(2===h.length){var u=h[1];"base64"===h[0]?(o.splice(-1,1),s=(0,n.base64Decode)(u)):(i=a(u).subarray(0,16),(r=new Uint8Array(16)).set(i,16-i.length),s=r)}}return s}function a(t){return Uint8Array.from(unescape(encodeURIComponent(t)),(function(t){return t.charCodeAt(0)}))}},"./src/utils/logger.ts":
|
|
242
|
-
/*!*****************************!*\
|
|
243
|
-
!*** ./src/utils/logger.ts ***!
|
|
244
|
-
\*****************************/(t,i,r)=>{r.r(i),r.d(i,{enableLogs:()=>o,logger:()=>h});var n=function(){},e={trace:n,debug:n,log:n,warn:n,info:n,error:n},s=e;function a(t){var i=self.console[t];return i?i.bind(self.console,"["+t+"] >"):n}function o(t,i){if(self.console&&!0===t||"object"==typeof t){!function(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;n<i;n++)r[n-1]=arguments[n];r.forEach((function(i){s[i]=t[i]?t[i].bind(t):a(i)}))}(t,"debug","log","info","warn","error");try{s.log('Debug logs enabled for "'+i+'"')}catch(t){s=e}}else s=e}var h=e},"./src/utils/mediakeys-helper.ts":
|
|
245
|
-
/*!***************************************!*\
|
|
246
|
-
!*** ./src/utils/mediakeys-helper.ts ***!
|
|
247
|
-
\***************************************/(t,i,r)=>{var n,e,s;function a(t){switch(t){case e.FAIRPLAY:return n.FAIRPLAY;case e.PLAYREADY:return n.PLAYREADY;case e.WIDEVINE:return n.WIDEVINE;case e.CLEARKEY:return n.CLEARKEY}}function o(t){if(t===s.WIDEVINE)return n.WIDEVINE}function h(t){switch(t){case n.FAIRPLAY:return e.FAIRPLAY;case n.PLAYREADY:return e.PLAYREADY;case n.WIDEVINE:return e.WIDEVINE;case n.CLEARKEY:return e.CLEARKEY}}function u(t){var i=t.drmSystems,r=t.widevineLicenseUrl,e=i?[n.FAIRPLAY,n.WIDEVINE,n.PLAYREADY,n.CLEARKEY].filter((function(t){return!!i[t]})):[];return!e[n.WIDEVINE]&&r&&e.push(n.WIDEVINE),e}r.r(i),r.d(i,{KeySystemFormats:()=>e,KeySystemIds:()=>s,KeySystems:()=>n,getKeySystemsForConfig:()=>u,getSupportedMediaKeySystemConfigurations:()=>c,keySystemDomainToKeySystemFormat:()=>h,keySystemFormatToKeySystemDomain:()=>a,keySystemIdToKeySystemDomain:()=>o,requestMediaKeySystemAccess:()=>f}),function(t){t.CLEARKEY="org.w3.clearkey",t.FAIRPLAY="com.apple.fps",t.PLAYREADY="com.microsoft.playready",t.WIDEVINE="com.widevine.alpha"}(n||(n={})),function(t){t.CLEARKEY="org.w3.clearkey",t.FAIRPLAY="com.apple.streamingkeydelivery",t.PLAYREADY="com.microsoft.playready",t.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"}(e||(e={})),function(t){t.WIDEVINE="edef8ba979d64acea3c827dcd51d21ed"}(s||(s={}));var f="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function c(t,i,r,e){var s;switch(t){case n.FAIRPLAY:s=["cenc","sinf"];break;case n.WIDEVINE:case n.PLAYREADY:s=["cenc"];break;case n.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+t)}return function(t,i,r,n){return[{initDataTypes:t,persistentState:n.persistentState||"not-allowed",distinctiveIdentifier:n.distinctiveIdentifier||"not-allowed",sessionTypes:n.sessionTypes||[n.sessionType||"temporary"],audioCapabilities:i.map((function(t){return{contentType:'audio/mp4; codecs="'+t+'"',robustness:n.audioRobustness||"",encryptionScheme:n.audioEncryptionScheme||null}})),videoCapabilities:r.map((function(t){return{contentType:'video/mp4; codecs="'+t+'"',robustness:n.videoRobustness||"",encryptionScheme:n.videoEncryptionScheme||null}}))}]}(s,i,r,e)}},"./src/utils/mediasource-helper.ts":
|
|
248
|
-
/*!*****************************************!*\
|
|
249
|
-
!*** ./src/utils/mediasource-helper.ts ***!
|
|
250
|
-
\*****************************************/(t,i,r)=>{function n(){return self.MediaSource||self.WebKitMediaSource}r.r(i),r.d(i,{getMediaSource:()=>n})},"./src/utils/mp4-tools.ts":
|
|
251
|
-
/*!********************************!*\
|
|
252
|
-
!*** ./src/utils/mp4-tools.ts ***!
|
|
253
|
-
\********************************/(t,i,r)=>{r.r(i),r.d(i,{RemuxerTrackIdConfig:()=>f,appendUint8Array:()=>M,bin2str:()=>c,computeRawDurationFromSamples:()=>T,discardEPB:()=>I,findBox:()=>p,getDuration:()=>S,getStartDTS:()=>k,mp4Box:()=>L,mp4pssh:()=>P,offsetStartDTS:()=>E,parseEmsg:()=>C,parseInitSegment:()=>g,parsePssh:()=>j,parseSEIMessageFromNALu:()=>D,parseSamples:()=>x,parseSegmentIndex:()=>y,parseSinf:()=>w,patchEncyptionData:()=>b,readSint32:()=>d,readUint16:()=>l,readUint32:()=>v,segmentValidRange:()=>A,writeUint32:()=>m});var n=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),e=r(/*! ./typed-array */"./src/utils/typed-array.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ./hex */"./src/utils/hex.ts"),h=Math.pow(2,32)-1,u=[].push,f={video:1,audio:2,id3:3,text:4};function c(t){return String.fromCharCode.apply(null,t)}function l(t,i){var r=t[i]<<8|t[i+1];return r<0?65536+r:r}function v(t,i){var r=d(t,i);return r<0?4294967296+r:r}function d(t,i){return t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3]}function m(t,i,r){t[i]=r>>24,t[i+1]=r>>16&255,t[i+2]=r>>8&255,t[i+3]=255&r}function p(t,i){var r=[];if(!i.length)return r;for(var n=t.byteLength,e=0;e<n;){var s=v(t,e),a=s>1?e+s:n;if(c(t.subarray(e+4,e+8))===i[0])if(1===i.length)r.push(t.subarray(e+8,a));else{var o=p(t.subarray(e+8,a),i.slice(1));o.length&&u.apply(r,o)}e=a}return r}function y(t){var i=[],r=t[0],n=8,e=v(t,n);n+=4,n+=0===r?8:16;var s=t.length+0,a=l(t,n+=2);n+=2;for(var o=0;o<a;o++){var h=n,u=v(t,h);h+=4;var f=2147483647&u;if(1==(2147483648&u)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var c=v(t,h);h+=4,i.push({referenceSize:f,subsegmentDuration:c,info:{duration:c/e,start:s,end:s+f-1}}),s+=f,n=h+=4}return{earliestPresentationTime:0,timescale:e,version:r,referencesCount:a,references:i}}function g(t){for(var i=[],r=p(t,["moov","trak"]),e=0;e<r.length;e++){var s=r[e],a=p(s,["tkhd"])[0];if(a){var o=a[0],h=0===o?12:20,u=v(a,h),f=p(s,["mdia","mdhd"])[0];if(f){var l=v(f,h=0===(o=f[0])?12:20),d=p(s,["mdia","hdlr"])[0];if(d){var m=c(d.subarray(8,12)),y={soun:n.ElementaryStreamTypes.AUDIO,vide:n.ElementaryStreamTypes.VIDEO}[m];if(y){var g=p(s,["mdia","minf","stbl","stsd"])[0],b=void 0;g&&(b=c(g.subarray(12,16))),i[u]={timescale:l,type:y},i[y]={timescale:l,id:u,codec:b}}}}}}return p(t,["moov","mvex","trex"]).forEach((function(t){var r=v(t,4),n=i[r];n&&(n.default={duration:v(t,12),flags:v(t,20)})})),i}function b(t,i){if(!t||!i)return t;var r=i.keyId;return r&&i.isCommonEncryption&&p(t,["moov","trak"]).forEach((function(t){var i=p(t,["mdia","minf","stbl","stsd"])[0].subarray(8),n=p(i,["enca"]),e=n.length>0;e||(n=p(i,["encv"])),n.forEach((function(t){p(t.subarray(e?28:78),["sinf"]).forEach((function(t){var i=w(t);if(i){var n=i.subarray(8,24);n.some((function(t){return 0!==t}))||(a.logger.log("[eme] Patching keyId in 'enc"+(e?"a":"v")+">sinf>>tenc' box: "+o.default.hexDump(n)+" -> "+o.default.hexDump(r)),i.set(r,8))}}))}))})),t}function w(t){var i=p(t,["schm"])[0];if(i){var r=c(i.subarray(4,8));if("cbcs"===r||"cenc"===r)return p(t,["schi","tenc"])[0]}return a.logger.error("[eme] missing 'schm' box"),null}function k(t,i){return p(i,["moof","traf"]).reduce((function(i,r){var n=p(r,["tfdt"])[0],e=n[0],s=p(r,["tfhd"]).reduce((function(i,r){var s=v(r,4),a=t[s];if(a){var o=v(n,4);1===e&&(o*=Math.pow(2,32),o+=v(n,8));var h=o/(a.timescale||9e4);if(isFinite(h)&&(null===i||h<i))return h}return i}),null);return null!==s&&isFinite(s)&&(null===i||s<i)?s:i}),null)||0}function S(t,i){for(var r=0,e=0,s=0,a=p(t,["moof","traf"]),o=0;o<a.length;o++){var h=a[o],u=p(h,["tfhd"])[0],f=i[v(u,4)];if(f){var c=f.default,l=v(u,0)|(null==c?void 0:c.flags),d=null==c?void 0:c.duration;8&l&&(d=v(u,2&l?12:8));for(var m=f.timescale||9e4,g=p(h,["trun"]),b=0;b<g.length;b++)!(r=T(g[b]))&&d&&(r=d*v(g[b],4)),f.type===n.ElementaryStreamTypes.VIDEO?e+=r/m:f.type===n.ElementaryStreamTypes.AUDIO&&(s+=r/m)}}if(0===e&&0===s){for(var w=0,k=p(t,["sidx"]),S=0;S<k.length;S++){var E=y(k[S]);null!=E&&E.references&&(w+=E.references.reduce((function(t,i){return t+i.info.duration||0}),0))}return w}return e||s}function T(t){var i=v(t,0),r=8;1&i&&(r+=4),4&i&&(r+=4);for(var n=0,e=v(t,4),s=0;s<e;s++)256&i&&(n+=v(t,r),r+=4),512&i&&(r+=4),1024&i&&(r+=4),2048&i&&(r+=4);return n}function E(t,i,r){p(i,["moof","traf"]).forEach((function(i){p(i,["tfhd"]).forEach((function(n){var e=v(n,4),s=t[e];if(s){var a=s.timescale||9e4;p(i,["tfdt"]).forEach((function(t){var i=t[0],n=v(t,4);if(0===i)n-=r*a,m(t,4,n=Math.max(n,0));else{n*=Math.pow(2,32),n+=v(t,8),n-=r*a,n=Math.max(n,0);var e=Math.floor(n/(h+1)),s=Math.floor(n%(h+1));m(t,4,e),m(t,8,s)}}))}}))}))}function A(t){var i={valid:null,remainder:null},r=p(t,["moof"]);if(!r)return i;if(r.length<2)return i.remainder=t,i;var n=r[r.length-1];return i.valid=(0,e.sliceUint8)(t,0,n.byteOffset-8),i.remainder=(0,e.sliceUint8)(t,n.byteOffset-8),i}function M(t,i){var r=new Uint8Array(t.length+i.length);return r.set(t),r.set(i,t.length),r}function x(t,i){var r=[],e=i.samples,s=i.timescale,a=i.id,o=!1;return p(e,["moof"]).map((function(h){var u=h.byteOffset-8;p(h,["traf"]).map((function(h){var f=p(h,["tfdt"]).map((function(t){var i=t[0],r=v(t,4);return 1===i&&(r*=Math.pow(2,32),r+=v(t,8)),r/s}))[0];return void 0!==f&&(t=f),p(h,["tfhd"]).map((function(f){var c=v(f,4),l=16777215&v(f,0),m=0,y=0!=(16&l),g=0,b=0!=(32&l),w=8;c===a&&(0!=(1&l)&&(w+=8),0!=(2&l)&&(w+=4),0!=(8&l)&&(m=v(f,w),w+=4),y&&(g=v(f,w),w+=4),b&&(w+=4),"video"===i.type&&(o=function(t){if(!t)return!1;var i=t.indexOf("."),r=i<0?t:t.substring(0,i);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(i.codec)),p(h,["trun"]).map((function(a){var h=a[0],f=16777215&v(a,0),c=0!=(1&f),l=0,p=0!=(4&f),y=0!=(256&f),b=0,w=0!=(512&f),k=0,S=0!=(1024&f),T=0!=(2048&f),E=0,A=v(a,4),M=8;c&&(l=v(a,M),M+=4),p&&(M+=4);for(var x=l+u,I=0;I<A;I++){if(y?(b=v(a,M),M+=4):b=m,w?(k=v(a,M),M+=4):k=g,S&&(M+=4),T&&(E=0===h?v(a,M):d(a,M),M+=4),i.type===n.ElementaryStreamTypes.VIDEO)for(var C=0;C<k;){var L=v(e,x);O(o,e[x+=4])&&D(e.subarray(x,x+L),o?2:1,t+E/s,r),x+=L,C+=L+4}t+=b/s}})))}))}))})),r}function O(t,i){if(t){var r=i>>1&63;return 39===r||40===r}return 6==(31&i)}function D(t,i,r,n){var e=I(t),a=0;a+=i;for(var o=0,h=0,u=!1,f=0;a<e.length;){o=0;do{if(a>=e.length)break;o+=f=e[a++]}while(255===f);h=0;do{if(a>=e.length)break;h+=f=e[a++]}while(255===f);var c=e.length-a;if(!u&&4===o&&a<e.length){if(u=!0,181===e[a++]){var d=l(e,a);if(a+=2,49===d){var m=v(e,a);if(a+=4,1195456820===m){var p=e[a++];if(3===p){var y=e[a++],g=64&y,b=g?2+3*(31&y):0,w=new Uint8Array(b);if(g){w[0]=y;for(var k=1;k<b;k++)w[k]=e[a++]}n.push({type:p,payloadType:o,pts:r,bytes:w})}}}}}else if(5===o&&h<c){if(u=!0,h>16){for(var S=[],T=0;T<16;T++){var E=e[a++].toString(16);S.push(1==E.length?"0"+E:E),3!==T&&5!==T&&7!==T&&9!==T||S.push("-")}for(var A=h-16,M=new Uint8Array(A),x=0;x<A;x++)M[x]=e[a++];n.push({payloadType:o,pts:r,uuid:S.join(""),userData:(0,s.utf8ArrayToStr)(M),userDataBytes:M})}}else if(h<c)a+=h;else if(h>c)break}}function I(t){for(var i=t.byteLength,r=[],n=1;n<i-2;)0===t[n]&&0===t[n+1]&&3===t[n+2]?(r.push(n+2),n+=2):n++;if(0===r.length)return t;var e=i-r.length,s=new Uint8Array(e),a=0;for(n=0;n<e;a++,n++)a===r[0]&&(a++,r.shift()),s[n]=t[a];return s}function C(t){var i=t[0],r="",n="",e=0,s=0,a=0,o=0,h=0,u=0;if(0===i){for(;"\0"!==c(t.subarray(u,u+1));)r+=c(t.subarray(u,u+1)),u+=1;for(r+=c(t.subarray(u,u+1)),u+=1;"\0"!==c(t.subarray(u,u+1));)n+=c(t.subarray(u,u+1)),u+=1;n+=c(t.subarray(u,u+1)),u+=1,e=v(t,12),s=v(t,16),o=v(t,20),h=v(t,24),u=28}else if(1===i){e=v(t,u+=4);var f=v(t,u+=4),l=v(t,u+=4);for(u+=4,a=Math.pow(2,32)*f+l,Number.isSafeInteger(a)||(a=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=v(t,u),h=v(t,u+=4),u+=4;"\0"!==c(t.subarray(u,u+1));)r+=c(t.subarray(u,u+1)),u+=1;for(r+=c(t.subarray(u,u+1)),u+=1;"\0"!==c(t.subarray(u,u+1));)n+=c(t.subarray(u,u+1)),u+=1;n+=c(t.subarray(u,u+1)),u+=1}return{schemeIdUri:r,value:n,timeScale:e,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:h,payload:t.subarray(u,t.byteLength)}}function L(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;n<i;n++)r[n-1]=arguments[n];for(var e=r.length,s=8,a=e;a--;)s+=r[a].byteLength;var o=new Uint8Array(s);for(o[0]=s>>24&255,o[1]=s>>16&255,o[2]=s>>8&255,o[3]=255&s,o.set(t,4),a=0,s=8;a<e;a++)o.set(r[a],s),s+=r[a].byteLength;return o}function P(t,i,r){if(16!==t.byteLength)throw new RangeError("Invalid system id");var n,e,s;if(i){n=1,e=new Uint8Array(16*i.length);for(var a=0;a<i.length;a++){var o=i[a];if(16!==o.byteLength)throw new RangeError("Invalid key");e.set(o,16*a)}}else n=0,e=new Uint8Array;n>0?(s=new Uint8Array(4),i.length>0&&new DataView(s.buffer).setUint32(0,i.length,!1)):s=new Uint8Array;var h=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(h.buffer).setUint32(0,r.byteLength,!1),L([112,115,115,104],new Uint8Array([n,0,0,0]),t,s,e,h,r||new Uint8Array)}function j(t){if(!(t instanceof ArrayBuffer)||t.byteLength<32)return null;var i={version:0,systemId:"",kids:null,data:null},r=new DataView(t),n=r.getUint32(0);if(t.byteLength!==n&&n>44)return null;if(1886614376!==r.getUint32(4))return null;if(i.version=r.getUint32(8)>>>24,i.version>1)return null;i.systemId=o.default.hexDump(new Uint8Array(t,12,16));var e=r.getUint32(28);if(0===i.version){if(n-32<e)return null;i.data=new Uint8Array(t,32,e)}else if(1===i.version){i.kids=[];for(var s=0;s<e;s++)i.kids.push(new Uint8Array(t,32+16*s,16))}return i}},"./src/utils/numeric-encoding-utils.ts":
|
|
254
|
-
/*!*********************************************!*\
|
|
255
|
-
!*** ./src/utils/numeric-encoding-utils.ts ***!
|
|
256
|
-
\*********************************************/(t,i,r)=>{function n(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function e(t){return btoa(t)}function s(t){return atob(t)}function a(t){return btoa(String.fromCharCode.apply(String,t))}function o(t){return n(a(t))}function h(t){return Uint8Array.from(atob(t),(function(t){return t.charCodeAt(0)}))}r.r(i),r.d(i,{base64Decode:()=>h,base64DecodeToStr:()=>s,base64Encode:()=>a,base64ToBase64Url:()=>n,base64UrlEncode:()=>o,strToBase64Encode:()=>e})},"./src/utils/output-filter.ts":
|
|
257
|
-
/*!************************************!*\
|
|
258
|
-
!*** ./src/utils/output-filter.ts ***!
|
|
259
|
-
\************************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>n});var n=function(){function t(t,i){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=i}var i=t.prototype;return i.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},i.newCue=function(t,i,r){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=i,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},i.reset=function(){this.cueRanges=[],this.startTime=null},t}()},"./src/utils/texttrack-utils.ts":
|
|
260
|
-
/*!**************************************!*\
|
|
261
|
-
!*** ./src/utils/texttrack-utils.ts ***!
|
|
262
|
-
\**************************************/(t,i,r)=>{r.r(i),r.d(i,{addCueToTrack:()=>s,clearCurrentCues:()=>a,getCuesInRange:()=>h,removeCuesInRange:()=>o,sendAddTrackEvent:()=>e});var n=r(/*! ./logger */"./src/utils/logger.ts");function e(t,i){var r;try{r=new Event("addtrack")}catch(t){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=t,i.dispatchEvent(r)}function s(t,i){var r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(i.id))try{if(t.addCue(i),!t.cues.getCueById(i.id))throw new Error("addCue is failed for: "+i)}catch(r){n.logger.debug("[texttrack-utils]: "+r);var e=new self.TextTrackCue(i.startTime,i.endTime,i.text);e.id=i.id,t.addCue(e)}"disabled"===r&&(t.mode=r)}function a(t){var i=t.mode;if("disabled"===i&&(t.mode="hidden"),t.cues)for(var r=t.cues.length;r--;)t.removeCue(t.cues[r]);"disabled"===i&&(t.mode=i)}function o(t,i,r,n){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues&&t.cues.length>0)for(var s=h(t.cues,i,r),a=0;a<s.length;a++)n&&!n(s[a])||t.removeCue(s[a]);"disabled"===e&&(t.mode=e)}function h(t,i,r){var n=[],e=function(t,i){if(i<t[0].startTime)return 0;var r=t.length-1;if(i>t[r].endTime)return-1;for(var n=0,e=r;n<=e;){var s=Math.floor((e+n)/2);if(i<t[s].startTime)e=s-1;else{if(!(i>t[s].startTime&&n<r))return s;n=s+1}}return t[n].startTime-i<i-t[e].startTime?n:e}(t,i);if(e>-1)for(var s=e,a=t.length;s<a;s++){var o=t[s];if(o.startTime>=i&&o.endTime<=r)n.push(o);else if(o.startTime>r)return n}return n}},"./src/utils/time-ranges.ts":
|
|
263
|
-
/*!**********************************!*\
|
|
264
|
-
!*** ./src/utils/time-ranges.ts ***!
|
|
265
|
-
\**********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>n});const n={toString:function(t){for(var i="",r=t.length,n=0;n<r;n++)i+="["+t.start(n).toFixed(3)+"-"+t.end(n).toFixed(3)+"]";return i}}},"./src/utils/timescale-conversion.ts":
|
|
266
|
-
/*!*******************************************!*\
|
|
267
|
-
!*** ./src/utils/timescale-conversion.ts ***!
|
|
268
|
-
\*******************************************/(t,i,r)=>{function n(t,i,r,n){void 0===r&&(r=1),void 0===n&&(n=!1);var e=t*i*r;return n?Math.round(e):e}function e(t,i,r,e){return void 0===r&&(r=1),void 0===e&&(e=!1),n(t,i,1/r,e)}function s(t,i){return void 0===i&&(i=!1),n(t,1e3,1/9e4,i)}function a(t,i){return void 0===i&&(i=1),n(t,9e4,1/i)}r.r(i),r.d(i,{toMpegTsClockFromTimescale:()=>a,toMsFromMpegTsClock:()=>s,toTimescaleFromBase:()=>n,toTimescaleFromScale:()=>e})},"./src/utils/typed-array.ts":
|
|
269
|
-
/*!**********************************!*\
|
|
270
|
-
!*** ./src/utils/typed-array.ts ***!
|
|
271
|
-
\**********************************/(t,i,r)=>{function n(t,i,r){return Uint8Array.prototype.slice?t.slice(i,r):new Uint8Array(Array.prototype.slice.call(t,i,r))}r.r(i),r.d(i,{sliceUint8:()=>n})},"./src/utils/vttcue.ts":
|
|
272
|
-
/*!*****************************!*\
|
|
273
|
-
!*** ./src/utils/vttcue.ts ***!
|
|
274
|
-
\*****************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>n});const n=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var t=["","lr","rl"],i=["start","middle","end","left","right"];function r(t,i){if("string"!=typeof i)return!1;if(!Array.isArray(t))return!1;var r=i.toLowerCase();return!!~t.indexOf(r)&&r}function n(t){return r(i,t)}function e(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;n<i;n++)r[n-1]=arguments[n];for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var a in s)t[a]=s[a]}return t}function s(i,s,a){var o=this,h={enumerable:!0};o.hasBeenReset=!1;var u="",f=!1,c=i,l=s,v=a,d=null,m="",p=!0,y="auto",g="start",b=50,w="middle",k=50,S="middle";Object.defineProperty(o,"id",e({},h,{get:function(){return u},set:function(t){u=""+t}})),Object.defineProperty(o,"pauseOnExit",e({},h,{get:function(){return f},set:function(t){f=!!t}})),Object.defineProperty(o,"startTime",e({},h,{get:function(){return c},set:function(t){if("number"!=typeof t)throw new TypeError("Start time must be set to a number.");c=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",e({},h,{get:function(){return l},set:function(t){if("number"!=typeof t)throw new TypeError("End time must be set to a number.");l=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",e({},h,{get:function(){return v},set:function(t){v=""+t,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",e({},h,{get:function(){return d},set:function(t){d=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",e({},h,{get:function(){return m},set:function(i){var n=function(i){return r(t,i)}(i);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");m=n,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",e({},h,{get:function(){return p},set:function(t){p=!!t,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",e({},h,{get:function(){return y},set:function(t){if("number"!=typeof t&&"auto"!==t)throw new SyntaxError("An invalid number or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",e({},h,{get:function(){return g},set:function(t){var i=n(t);if(!i)throw new SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",e({},h,{get:function(){return b},set:function(t){if(t<0||t>100)throw new Error("Position must be between 0 and 100.");b=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",e({},h,{get:function(){return w},set:function(t){var i=n(t);if(!i)throw new SyntaxError("An invalid or illegal string was specified.");w=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",e({},h,{get:function(){return k},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");k=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",e({},h,{get:function(){return S},set:function(t){var i=n(t);if(!i)throw new SyntaxError("An invalid or illegal string was specified.");S=i,this.hasBeenReset=!0}})),o.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}()},"./src/utils/vttparser.ts":
|
|
275
|
-
/*!********************************!*\
|
|
276
|
-
!*** ./src/utils/vttparser.ts ***!
|
|
277
|
-
\********************************/(t,i,r)=>{r.r(i),r.d(i,{VTTParser:()=>l,fixLineBreaks:()=>c,parseTimeStamp:()=>s});var n=r(/*! ./vttcue */"./src/utils/vttcue.ts"),e=function(){function t(){}return t.prototype.decode=function(t){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))},t}();function s(t){function i(t,i,r,n){return 3600*(0|t)+60*(0|i)+(0|r)+parseFloat(n||0)}var r=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?i(r[2],r[3],0,r[4]):i(r[1],r[2],r[3],r[4]):null}var a=function(){function t(){this.values=Object.create(null)}var i=t.prototype;return i.set=function(t,i){this.get(t)||""===i||(this.values[t]=i)},i.get=function(t,i,r){return r?this.has(t)?this.values[t]:i[r]:this.has(t)?this.values[t]:i},i.has=function(t){return t in this.values},i.alt=function(t,i,r){for(var n=0;n<r.length;++n)if(i===r[n]){this.set(t,i);break}},i.integer=function(t,i){/^-?\d+$/.test(i)&&this.set(t,parseInt(i,10))},i.percent=function(t,i){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(i)){var r=parseFloat(i);if(r>=0&&r<=100)return this.set(t,r),!0}return!1},t}();function o(t,i,r,n){var e=n?t.split(n):[t];for(var s in e)if("string"==typeof e[s]){var a=e[s].split(r);2===a.length&&i(a[0],a[1])}}var h=new n.default(0,0,""),u="middle"===h.align?"middle":"center";function f(t,i,r){var n=t;function e(){var i=s(t);if(null===i)throw new Error("Malformed timestamp: "+n);return t=t.replace(/^[^\sa-zA-Z-]+/,""),i}function f(){t=t.replace(/^\s+/,"")}if(f(),i.startTime=e(),f(),"--\x3e"!==t.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+n);t=t.slice(3),f(),i.endTime=e(),f(),function(t,i){var n=new a;o(t,(function(t,i){var e;switch(t){case"region":for(var s=r.length-1;s>=0;s--)if(r[s].id===i){n.set(t,r[s].region);break}break;case"vertical":n.alt(t,i,["rl","lr"]);break;case"line":e=i.split(","),n.integer(t,e[0]),n.percent(t,e[0])&&n.set("snapToLines",!1),n.alt(t,e[0],["auto"]),2===e.length&&n.alt("lineAlign",e[1],["start",u,"end"]);break;case"position":e=i.split(","),n.percent(t,e[0]),2===e.length&&n.alt("positionAlign",e[1],["start",u,"end","line-left","line-right","auto"]);break;case"size":n.percent(t,i);break;case"align":n.alt(t,i,["start",u,"end","left","right"])}}),/:/,/\s/),i.region=n.get("region",null),i.vertical=n.get("vertical","");var e=n.get("line","auto");"auto"===e&&-1===h.line&&(e=-1),i.line=e,i.lineAlign=n.get("lineAlign","start"),i.snapToLines=n.get("snapToLines",!0),i.size=n.get("size",100),i.align=n.get("align",u);var s=n.get("position","auto");"auto"===s&&50===h.position&&(s="start"===i.align||"left"===i.align?0:"end"===i.align||"right"===i.align?100:50),i.position=s}(t,i)}function c(t){return t.replace(/<br(?: \/)?>/gi,"\n")}var l=function(){function t(){this.state="INITIAL",this.buffer="",this.decoder=new e,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var i=t.prototype;return i.parse=function(t){var i=this;function r(){var t=i.buffer,r=0;for(t=c(t);r<t.length&&"\r"!==t[r]&&"\n"!==t[r];)++r;var n=t.slice(0,r);return"\r"===t[r]&&++r,"\n"===t[r]&&++r,i.buffer=t.slice(r),n}t&&(i.buffer+=i.decoder.decode(t,{stream:!0}));try{var e="";if("INITIAL"===i.state){if(!/\r\n|\n/.test(i.buffer))return this;var s=(e=r()).match(/^()?WEBVTT([ \t].*)?$/);if(!s||!s[0])throw new Error("Malformed WebVTT signature.");i.state="HEADER"}for(var a=!1;i.buffer;){if(!/\r\n|\n/.test(i.buffer))return this;switch(a?a=!1:e=r(),i.state){case"HEADER":/:/.test(e)?o(e,(function(){}),/:/):e||(i.state="ID");continue;case"NOTE":e||(i.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){i.state="NOTE";break}if(!e)continue;if(i.cue=new n.default(0,0,""),i.state="CUE",-1===e.indexOf("--\x3e")){i.cue.id=e;continue}case"CUE":if(!i.cue){i.state="BADCUE";continue}try{f(e,i.cue,i.regionList)}catch(t){i.cue=null,i.state="BADCUE";continue}i.state="CUETEXT";continue;case"CUETEXT":var h=-1!==e.indexOf("--\x3e");if(!e||h&&(a=!0)){i.oncue&&i.cue&&i.oncue(i.cue),i.cue=null,i.state="ID";continue}if(null===i.cue)continue;i.cue.text&&(i.cue.text+="\n"),i.cue.text+=e;continue;case"BADCUE":e||(i.state="ID")}}}catch(t){"CUETEXT"===i.state&&i.cue&&i.oncue&&i.oncue(i.cue),i.cue=null,i.state="INITIAL"===i.state?"BADWEBVTT":"BADCUE"}return this},i.flush=function(){var t=this;try{if((t.cue||"HEADER"===t.state)&&(t.buffer+="\n\n",t.parse()),"INITIAL"===t.state||"BADWEBVTT"===t.state)throw new Error("Malformed WebVTT signature.")}catch(i){t.onparsingerror&&t.onparsingerror(i)}return t.onflush&&t.onflush(),this},t}()},"./src/utils/webvtt-parser.ts":
|
|
278
|
-
/*!************************************!*\
|
|
279
|
-
!*** ./src/utils/webvtt-parser.ts ***!
|
|
280
|
-
\************************************/(t,i,r)=>{r.r(i),r.d(i,{generateCueId:()=>c,parseWebVTT:()=>l});var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=r(/*! ./vttparser */"./src/utils/vttparser.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),o=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),h=/\r\n|\n\r|\n|\r/g,u=function(t,i,r){return void 0===r&&(r=0),t.slice(r,r+i.length)===i},f=function(t){for(var i=5381,r=t.length;r;)i=33*i^t.charCodeAt(--r);return(i>>>0).toString()};function c(t,i,r){return f(t.toString())+f(i.toString())+f(r)}function l(t,i,r,f,l,v,d,m){var p,y=new e.VTTParser,g=(0,s.utf8ArrayToStr)(new Uint8Array(t)).trim().replace(h,"\n").split("\n"),b=[],w=(0,a.toMpegTsClockFromTimescale)(i,r),k="00:00.000",S=0,T=0,E=!0;y.oncue=function(t){var i=f[l],r=f.ccOffset,n=(S-w)/9e4;null!=i&&i.new&&(void 0!==T?r=f.ccOffset=i.start:function(t,i,r){var n=t[i],e=t[n.prevCC];if(!e||!e.new&&n.new)return t.ccOffset=t.presentationOffset=n.start,void(n.new=!1);for(;null!==(s=e)&&void 0!==s&&s.new;){var s;t.ccOffset+=n.start-e.start,n.new=!1,e=t[(n=e).prevCC]}t.presentationOffset=r}(f,l,n)),n&&(r=n-f.presentationOffset);var e=t.endTime-t.startTime,s=(0,o.normalizePts)(9e4*(t.startTime+r-T),9e4*v)/9e4;t.startTime=Math.max(s,0),t.endTime=Math.max(s+e,0);var a=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(a)),t.id||(t.id=c(t.startTime,t.endTime,a)),t.endTime>0&&b.push(t)},y.onparsingerror=function(t){p=t},y.onflush=function(){p?m(p):d(b)},g.forEach((function(t){if(E){if(u(t,"X-TIMESTAMP-MAP=")){E=!1,t.slice(16).split(",").forEach((function(t){u(t,"LOCAL:")?k=t.slice(6):u(t,"MPEGTS:")&&(S=parseInt(t.slice(7)))}));try{T=function(t){var i=parseInt(t.slice(-3)),r=parseInt(t.slice(-6,-4)),e=parseInt(t.slice(-9,-7)),s=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!((0,n.isFiniteNumber)(i)&&(0,n.isFiniteNumber)(r)&&(0,n.isFiniteNumber)(e)&&(0,n.isFiniteNumber)(s)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+t);return i+=1e3*r,(i+=6e4*e)+36e5*s}(k)/1e3}catch(t){p=t}return}""===t&&(E=!1)}y.parse(t+"\n")})),y.flush()}},"./src/utils/xhr-loader.ts":
|
|
281
|
-
/*!*********************************!*\
|
|
282
|
-
!*** ./src/utils/xhr-loader.ts ***!
|
|
283
|
-
\*********************************/(t,i,r)=>{r.r(i),r.d(i,{default:()=>a});var n=r(/*! ../utils/logger */"./src/utils/logger.ts"),e=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m;const a=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t?t.xhrSetup:null,this.stats=new e.LoadStats,this.retryDelay=0}var i=t.prototype;return i.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},i.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},i.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},i.load=function(t,i,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=i,this.callbacks=r,this.retryDelay=i.retryDelay,this.loadInternal()},i.loadInternal=function(){var t=this.config,i=this.context;if(t){var r=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0;var e=this.xhrSetup;try{if(e)try{e(r,i.url)}catch(t){r.open("GET",i.url,!0),e(r,i.url)}r.readyState||r.open("GET",i.url,!0);var s=this.context.headers;if(s)for(var a in s)r.setRequestHeader(a,s[a])}catch(t){return void this.callbacks.onError({code:r.status,text:t.message},i,r)}i.rangeEnd&&r.setRequestHeader("Range","bytes="+i.rangeStart+"-"+(i.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=i.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),r.send()}},i.readystatechange=function(){var t=this.context,i=this.loader,r=this.stats;if(t&&i){var e=i.readyState,s=this.config;if(!r.aborted&&e>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===e){i.onreadystatechange=null,i.onprogress=null;var a=i.status,o="arraybuffer"===i.responseType;if(a>=200&&a<300&&(o&&i.response||null!==i.responseText)){var h,u;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),u=o?(h=i.response).byteLength:(h=i.responseText).length,r.loaded=r.total=u,!this.callbacks)return;var f=this.callbacks.onProgress;if(f&&f(r,t,h,i),!this.callbacks)return;this.callbacks.onSuccess({url:i.responseURL,data:h},r,t,i)}else r.retry>=s.maxRetry||a>=400&&a<499?(n.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:i.statusText},t,i)):(n.logger.warn(a+" while loading "+t.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}},i.loadtimeout=function(){n.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},i.loadprogress=function(t){var i=this.stats;i.loaded=t.loaded,t.lengthComputable&&(i.total=t.total)},i.getCacheAge=function(){var t=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var i=this.loader.getResponseHeader("age");t=i?parseFloat(i):null}return t},t}()},"./node_modules/eventemitter3/index.js":
|
|
284
|
-
/*!*********************************************!*\
|
|
285
|
-
!*** ./node_modules/eventemitter3/index.js ***!
|
|
286
|
-
\*********************************************/t=>{var i=Object.prototype.hasOwnProperty,r="~";function n(){}function e(t,i,r){this.fn=t,this.context=i,this.once=r||!1}function s(t,i,n,s,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new e(n,s||t,a),h=r?r+i:i;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],o]:t._events[h].push(o):(t._events[h]=o,t._eventsCount++),t}function a(t,i){0==--t._eventsCount?t._events=new n:delete t._events[i]}function o(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),o.prototype.eventNames=function(){var t,n,e=[];if(0===this._eventsCount)return e;for(n in t=this._events)i.call(t,n)&&e.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},o.prototype.listeners=function(t){var i=this._events[r?r+t:t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,e=i.length,s=new Array(e);n<e;n++)s[n]=i[n].fn;return s},o.prototype.listenerCount=function(t){var i=this._events[r?r+t:t];return i?i.fn?1:i.length:0},o.prototype.emit=function(t,i,n,e,s,a){var o=r?r+t:t;if(!this._events[o])return!1;var h,u,f=this._events[o],c=arguments.length;if(f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),c){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,i),!0;case 3:return f.fn.call(f.context,i,n),!0;case 4:return f.fn.call(f.context,i,n,e),!0;case 5:return f.fn.call(f.context,i,n,e,s),!0;case 6:return f.fn.call(f.context,i,n,e,s,a),!0}for(u=1,h=new Array(c-1);u<c;u++)h[u-1]=arguments[u];f.fn.apply(f.context,h)}else{var l,v=f.length;for(u=0;u<v;u++)switch(f[u].once&&this.removeListener(t,f[u].fn,void 0,!0),c){case 1:f[u].fn.call(f[u].context);break;case 2:f[u].fn.call(f[u].context,i);break;case 3:f[u].fn.call(f[u].context,i,n);break;case 4:f[u].fn.call(f[u].context,i,n,e);break;default:if(!h)for(l=1,h=new Array(c-1);l<c;l++)h[l-1]=arguments[l];f[u].fn.apply(f[u].context,h)}}return!0},o.prototype.on=function(t,i,r){return s(this,t,i,r,!1)},o.prototype.once=function(t,i,r){return s(this,t,i,r,!0)},o.prototype.removeListener=function(t,i,n,e){var s=r?r+t:t;if(!this._events[s])return this;if(!i)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==i||e&&!o.once||n&&o.context!==n||a(this,s);else{for(var h=0,u=[],f=o.length;h<f;h++)(o[h].fn!==i||e&&!o[h].once||n&&o[h].context!==n)&&u.push(o[h]);u.length?this._events[s]=1===u.length?u[0]:u:a(this,s)}return this},o.prototype.removeAllListeners=function(t){var i;return t?this._events[i=r?r+t:t]&&a(this,i):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,t.exports=o},"./node_modules/url-toolkit/src/url-toolkit.js":
|
|
287
|
-
/*!*****************************************************!*\
|
|
288
|
-
!*** ./node_modules/url-toolkit/src/url-toolkit.js ***!
|
|
289
|
-
\*****************************************************/function(t){var i,r,n,e,s;i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,e=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,t.exports=s={buildAbsoluteURL:function(t,i,n){if(n=n||{},t=t.trim(),!(i=i.trim())){if(!n.alwaysNormalize)return t;var e=s.parseURL(t);if(!e)throw new Error("Error trying to parse base URL.");return e.path=s.normalizePath(e.path),s.buildURLFromParts(e)}var a=s.parseURL(i);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return n.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):i;var o=s.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var h=r.exec(o.path);o.netLoc=h[1],o.path=h[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var f=o.path,c=f.substring(0,f.lastIndexOf("/")+1)+a.path;u.path=s.normalizePath(c)}else u.path=o.path,a.params||(u.params=o.params,a.query||(u.query=o.query));return null===u.path&&(u.path=n.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(u)},parseURL:function(t){var r=i.exec(t);return r?{scheme:r[1]||"",netLoc:r[2]||"",path:r[3]||"",params:r[4]||"",query:r[5]||"",fragment:r[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(n,"");t.length!==(t=t.replace(e,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}}}},i={};function r(n){var e=i[n];if(void 0!==e)return e.exports;var s=i[n]={exports:{}};return t[n].call(s.exports,s,s.exports,r),s.exports}r.m=t,r.n=t=>{var i=t&&t.__esModule?()=>t.default:()=>t;return r.d(i,{a:i}),i},r.d=(t,i)=>{for(var n in i)r.o(i,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})},r.o=(t,i)=>Object.prototype.hasOwnProperty.call(t,i),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n=r("./src/hls.ts");return n.default})(),t.exports=i())}));const e=t(n),s=Object.freeze(Object.assign(Object.create(null),n,{default:e}));export{s as h}
|