@amazon/vinyl 3.0.1 → 3.2.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/index.cjs +1103 -1042
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +810 -739
- package/dist/index.js.map +4 -4
- package/dist/test/benchmark.js.map +2 -2
- package/dist/test/integ.es5.js +394 -388
- package/dist/test/integ.js +2626 -2032
- package/dist/test/integ.js.map +4 -4
- package/dist/test/jasmine.css +50 -3
- package/dist/test/jasmineHtml.es5.js +195 -155
- package/dist/test/jasmineHtml.js +2938 -1833
- package/dist/test/jasmineHtml.js.map +3 -3
- package/dist/types/current/ad/AdControllerImpl.d.ts.map +1 -1
- package/dist/types/current/ad/AdControllerImpl.js +4 -1
- package/dist/types/current/ad/discoverHlsInterstitials.d.ts.map +1 -1
- package/dist/types/current/ad/discoverHlsInterstitials.js +2 -2
- package/dist/types/current/drm/DrmControllerImpl.d.ts +19 -1
- package/dist/types/current/drm/DrmControllerImpl.d.ts.map +1 -1
- package/dist/types/current/drm/DrmControllerImpl.js +101 -58
- package/dist/types/current/drm/licenseProvider/defaultLicenseProvider.d.ts.map +1 -1
- package/dist/types/current/drm/licenseProvider/defaultLicenseProvider.js +2 -2
- package/dist/types/current/index.d.ts +3 -6
- package/dist/types/current/index.d.ts.map +1 -1
- package/dist/types/current/index.js +3 -6
- package/dist/types/current/playback/PlaybackControllerImpl.d.ts +15 -0
- package/dist/types/current/playback/PlaybackControllerImpl.d.ts.map +1 -1
- package/dist/types/current/playback/PlaybackControllerImpl.js +100 -9
- package/dist/types/current/playback/ReadonlyPlaybackController.d.ts +27 -1
- package/dist/types/current/playback/ReadonlyPlaybackController.d.ts.map +1 -1
- package/dist/types/current/playback/ReadonlyPlaybackController.js +16 -0
- package/dist/types/current/playback/createStallDetector.d.ts +43 -0
- package/dist/types/current/playback/createStallDetector.d.ts.map +1 -0
- package/dist/types/current/playback/createStallDetector.js +101 -0
- package/dist/types/current/playback/createStallMonitor.d.ts +45 -0
- package/dist/types/current/playback/createStallMonitor.d.ts.map +1 -0
- package/dist/types/current/playback/createStallMonitor.js +94 -0
- package/dist/types/current/streaming/AudioOptions.d.ts +27 -0
- package/dist/types/current/streaming/AudioOptions.d.ts.map +1 -1
- package/dist/types/current/streaming/AudioOptions.js +5 -1
- package/dist/types/current/streaming/ContentStream.d.ts +0 -5
- package/dist/types/current/streaming/ContentStream.d.ts.map +1 -1
- package/dist/types/current/streaming/ContentStream.js +0 -4
- package/dist/types/current/streaming/LoadMetric.d.ts +15 -1
- package/dist/types/current/streaming/LoadMetric.d.ts.map +1 -1
- package/dist/types/current/streaming/StreamingEventMap.d.ts +1 -5
- package/dist/types/current/streaming/StreamingEventMap.d.ts.map +1 -1
- package/dist/types/current/streaming/StreamingEventMap.js +0 -1
- package/dist/types/current/streaming/buffering/BufferingController.d.ts +0 -11
- package/dist/types/current/streaming/buffering/BufferingController.d.ts.map +1 -1
- package/dist/types/current/streaming/buffering/BufferingController.js +0 -13
- package/dist/types/current/streaming/createDefaultMediaTimelineTransformer.d.ts.map +1 -1
- package/dist/types/current/streaming/createDefaultMediaTimelineTransformer.js +13 -4
- package/dist/types/current/streaming/mediaTimelineFilter.d.ts +4 -2
- package/dist/types/current/streaming/mediaTimelineFilter.d.ts.map +1 -1
- package/dist/types/current/streaming/mediaTimelineFilter.js +23 -8
- package/dist/types/current/text/SidecarTextTrackLoader.d.ts.map +1 -1
- package/dist/types/current/text/SidecarTextTrackLoader.js +4 -4
- package/dist/types/current/text/TextTrack.d.ts.map +1 -1
- package/dist/types/current/track/TrackController.d.ts.map +1 -1
- package/dist/types/current/track/TrackController.js +8 -2
- package/dist/types/current/track/createSegmentDataProvider.d.ts.map +1 -1
- package/dist/types/current/track/createSegmentDataProvider.js +6 -3
- package/dist/types/current/track/dash/DashMediaQualityMetadataResolver.d.ts +10 -6
- package/dist/types/current/track/dash/DashMediaQualityMetadataResolver.d.ts.map +1 -1
- package/dist/types/current/track/dash/DashMediaQualityMetadataResolver.js +13 -8
- package/dist/types/current/track/dash/createDashFactories.d.ts +1 -1
- package/dist/types/current/track/dash/timeline/DashRepresentationSegmentProvider.d.ts.map +1 -1
- package/dist/types/current/track/dash/timeline/DashRepresentationSegmentProvider.js +71 -3
- package/dist/types/current/track/dash/urlDashManifestProvider.js +2 -2
- package/dist/types/current/track/dash/util/mpd.d.ts +6 -0
- package/dist/types/current/track/dash/util/mpd.d.ts.map +1 -1
- package/dist/types/current/track/dash/util/mpd.js +24 -3
- package/dist/types/current/track/filters/resourceTypeFilter.d.ts +4 -0
- package/dist/types/current/track/filters/resourceTypeFilter.d.ts.map +1 -1
- package/dist/types/current/track/filters/resourceTypeFilter.js +4 -0
- package/dist/types/current/track/filters/sampleRateFilter.d.ts +25 -7
- package/dist/types/current/track/filters/sampleRateFilter.d.ts.map +1 -1
- package/dist/types/current/track/filters/sampleRateFilter.js +52 -24
- package/dist/types/current/track/hls/createHlsFactories.d.ts +1 -1
- package/dist/types/current/track/hls/createUrlHlsManifestProvider.d.ts.map +1 -1
- package/dist/types/current/track/hls/createUrlHlsManifestProvider.js +3 -3
- package/dist/types/current/track/mse/MseTrack.d.ts +0 -17
- package/dist/types/current/track/mse/MseTrack.d.ts.map +1 -1
- package/dist/types/current/track/mse/MseTrack.js +1 -45
- package/dist/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/types/current/util/media/mimeType.d.ts +8 -0
- package/dist/types/current/util/media/mimeType.d.ts.map +1 -0
- package/dist/types/current/util/media/mimeType.js +13 -0
- package/dist/types/current/vinyl/VinylPlayer.d.ts +5 -0
- package/dist/types/current/vinyl/VinylPlayer.d.ts.map +1 -1
- package/dist/types/current/vinyl/VinylPlayer.js +23 -1
- package/dist/types/current/vinyl/createVinylFactories.d.ts +7 -16
- package/dist/types/current/vinyl/createVinylFactories.d.ts.map +1 -1
- package/dist/types/current/vinyl/createVinylFactories.js +2 -12
- package/dist/types/ts3.7/drm/DrmControllerImpl.d.ts +19 -1
- package/dist/types/ts3.7/index.d.ts +3 -6
- package/dist/types/ts3.7/playback/PlaybackControllerImpl.d.ts +15 -0
- package/dist/types/ts3.7/playback/ReadonlyPlaybackController.d.ts +28 -0
- package/dist/types/ts3.7/playback/createStallDetector.d.ts +43 -0
- package/dist/types/ts3.7/playback/createStallMonitor.d.ts +45 -0
- package/dist/types/ts3.7/streaming/AudioOptions.d.ts +27 -0
- package/dist/types/ts3.7/streaming/ContentStream.d.ts +0 -5
- package/dist/types/ts3.7/streaming/LoadMetric.d.ts +15 -1
- package/dist/types/ts3.7/streaming/StreamingEventMap.d.ts +0 -5
- package/dist/types/ts3.7/streaming/buffering/BufferingController.d.ts +0 -11
- package/dist/types/ts3.7/streaming/mediaTimelineFilter.d.ts +4 -2
- package/dist/types/ts3.7/track/dash/DashMediaQualityMetadataResolver.d.ts +10 -6
- package/dist/types/ts3.7/track/dash/createDashFactories.d.ts +1 -1
- package/dist/types/ts3.7/track/dash/util/mpd.d.ts +6 -0
- package/dist/types/ts3.7/track/filters/resourceTypeFilter.d.ts +4 -0
- package/dist/types/ts3.7/track/filters/sampleRateFilter.d.ts +25 -7
- package/dist/types/ts3.7/track/hls/createHlsFactories.d.ts +1 -1
- package/dist/types/ts3.7/track/mse/MseTrack.d.ts +0 -17
- package/dist/types/ts3.7/util/media/mimeType.d.ts +8 -0
- package/dist/types/ts3.7/vinyl/VinylPlayer.d.ts +5 -0
- package/dist/types/ts3.7/vinyl/createVinylFactories.d.ts +7 -16
- package/dist/types/ts4.1/drm/DrmControllerImpl.d.ts +19 -1
- package/dist/types/ts4.1/index.d.ts +3 -6
- package/dist/types/ts4.1/playback/PlaybackControllerImpl.d.ts +15 -0
- package/dist/types/ts4.1/playback/ReadonlyPlaybackController.d.ts +28 -0
- package/dist/types/ts4.1/playback/createStallDetector.d.ts +43 -0
- package/dist/types/ts4.1/playback/createStallMonitor.d.ts +45 -0
- package/dist/types/ts4.1/streaming/AudioOptions.d.ts +27 -0
- package/dist/types/ts4.1/streaming/ContentStream.d.ts +0 -5
- package/dist/types/ts4.1/streaming/LoadMetric.d.ts +15 -1
- package/dist/types/ts4.1/streaming/StreamingEventMap.d.ts +0 -5
- package/dist/types/ts4.1/streaming/buffering/BufferingController.d.ts +0 -11
- package/dist/types/ts4.1/streaming/mediaTimelineFilter.d.ts +4 -2
- package/dist/types/ts4.1/track/dash/DashMediaQualityMetadataResolver.d.ts +10 -6
- package/dist/types/ts4.1/track/dash/createDashFactories.d.ts +1 -1
- package/dist/types/ts4.1/track/dash/util/mpd.d.ts +6 -0
- package/dist/types/ts4.1/track/filters/resourceTypeFilter.d.ts +4 -0
- package/dist/types/ts4.1/track/filters/sampleRateFilter.d.ts +25 -7
- package/dist/types/ts4.1/track/hls/createHlsFactories.d.ts +1 -1
- package/dist/types/ts4.1/track/mse/MseTrack.d.ts +0 -17
- package/dist/types/ts4.1/util/media/mimeType.d.ts +8 -0
- package/dist/types/ts4.1/vinyl/VinylPlayer.d.ts +5 -0
- package/dist/types/ts4.1/vinyl/createVinylFactories.d.ts +7 -16
- package/dist/types/ts4.7/drm/DrmControllerImpl.d.ts +19 -1
- package/dist/types/ts4.7/index.d.ts +3 -6
- package/dist/types/ts4.7/playback/PlaybackControllerImpl.d.ts +15 -0
- package/dist/types/ts4.7/playback/ReadonlyPlaybackController.d.ts +28 -0
- package/dist/types/ts4.7/playback/createStallDetector.d.ts +43 -0
- package/dist/types/ts4.7/playback/createStallMonitor.d.ts +45 -0
- package/dist/types/ts4.7/streaming/AudioOptions.d.ts +27 -0
- package/dist/types/ts4.7/streaming/ContentStream.d.ts +0 -5
- package/dist/types/ts4.7/streaming/LoadMetric.d.ts +15 -1
- package/dist/types/ts4.7/streaming/StreamingEventMap.d.ts +0 -5
- package/dist/types/ts4.7/streaming/buffering/BufferingController.d.ts +0 -11
- package/dist/types/ts4.7/streaming/mediaTimelineFilter.d.ts +4 -2
- package/dist/types/ts4.7/track/dash/DashMediaQualityMetadataResolver.d.ts +10 -6
- package/dist/types/ts4.7/track/dash/createDashFactories.d.ts +1 -1
- package/dist/types/ts4.7/track/dash/util/mpd.d.ts +6 -0
- package/dist/types/ts4.7/track/filters/resourceTypeFilter.d.ts +4 -0
- package/dist/types/ts4.7/track/filters/sampleRateFilter.d.ts +25 -7
- package/dist/types/ts4.7/track/hls/createHlsFactories.d.ts +1 -1
- package/dist/types/ts4.7/track/mse/MseTrack.d.ts +0 -17
- package/dist/types/ts4.7/util/media/mimeType.d.ts +8 -0
- package/dist/types/ts4.7/vinyl/VinylPlayer.d.ts +5 -0
- package/dist/types/ts4.7/vinyl/createVinylFactories.d.ts +7 -16
- package/dist/unit/types/current/ad/AdControllerImpl.test.js +27 -1
- package/dist/unit/types/current/drm/DrmControllerImpl.test.js +146 -9
- package/dist/unit/types/current/index.d.ts +3 -4
- package/dist/unit/types/current/index.d.ts.map +1 -1
- package/dist/unit/types/current/index.js +3 -4
- package/dist/unit/types/current/playback/PlaybackControllerImpl.test.js +165 -0
- package/dist/unit/types/current/playback/createStallDetector.test.d.ts +2 -0
- package/dist/unit/types/current/playback/createStallDetector.test.d.ts.map +1 -0
- package/dist/unit/types/current/playback/createStallDetector.test.js +163 -0
- package/dist/unit/types/current/playback/createStallMonitor.test.d.ts +2 -0
- package/dist/unit/types/current/playback/createStallMonitor.test.d.ts.map +1 -0
- package/dist/unit/types/current/playback/createStallMonitor.test.js +125 -0
- package/dist/unit/types/current/streaming/ContentStream.test.js +0 -11
- package/dist/unit/types/current/streaming/MseTrack.test.js +49 -73
- package/dist/unit/types/current/streaming/abr/QualitySelectorImpl.test.js +1 -1
- package/dist/unit/types/current/streaming/buffering/BufferingController.test.js +0 -21
- package/dist/unit/types/current/streaming/createDefaultMediaTimelineTransformer.test.js +133 -0
- package/dist/unit/types/current/streaming/mediaTimelineFilter.test.js +60 -54
- package/dist/unit/types/current/track/TrackController.test.js +61 -1
- package/dist/unit/types/current/track/createSegmentDataProvider.test.js +18 -0
- package/dist/unit/types/current/track/dash/DashMediaQualityMetadataResolver.test.js +46 -14
- package/dist/unit/types/current/track/dash/createSegmentControllerFactory.test.js +1 -0
- package/dist/unit/types/current/track/dash/timeline/DashRepresentationSegmentProvider.test.js +114 -0
- package/dist/unit/types/current/track/dash/util/mpd.test.js +37 -0
- package/dist/unit/types/current/track/filters/resourceTypeFilter.test.js +7 -0
- package/dist/unit/types/current/track/filters/sampleRateFilter.test.js +211 -34
- package/dist/unit/types/current/track/source/SourceObjectTrack.test.js +1 -1
- package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/unit/types/current/util/media/mimeType.test.d.ts +2 -0
- package/dist/unit/types/current/util/media/mimeType.test.d.ts.map +1 -0
- package/dist/unit/types/current/util/media/mimeType.test.js +22 -0
- package/dist/unit/types/current/vinyl/VinylPlayer.test.js +33 -2
- package/dist/unit/types/current/vinyl/createVinylFactories.test.js +2 -36
- package/dist/vinylTestUtil/index.js +6 -4
- package/dist/vinylTestUtil/index.js.map +2 -2
- package/dist/vinylTestUtil/types/current/assets/vinylTestAssets.d.ts +1 -0
- package/dist/vinylTestUtil/types/current/assets/vinylTestAssets.d.ts.map +1 -1
- package/dist/vinylTestUtil/types/current/assets/vinylTestAssets.js +1 -0
- package/dist/vinylTestUtil/types/current/media/FrequencyAnalyzer.d.ts.map +1 -1
- package/dist/vinylTestUtil/types/current/mock/streaming/MockContentStream.d.ts +0 -1
- package/dist/vinylTestUtil/types/current/mock/streaming/MockContentStream.d.ts.map +1 -1
- package/dist/vinylTestUtil/types/current/mock/streaming/MockContentStream.js +0 -1
- package/dist/vinylTestUtil/types/current/mock/streaming/buffering/MockBufferingController.d.ts +0 -1
- package/dist/vinylTestUtil/types/current/mock/streaming/buffering/MockBufferingController.d.ts.map +1 -1
- package/dist/vinylTestUtil/types/current/mock/streaming/buffering/MockBufferingController.js +0 -1
- package/dist/vinylTestUtil/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/vinylTestUtil/types/current/util/playback/eventPromises.js +1 -1
- package/dist/vinylTestUtil/types/current/util/playback/expectTrackCanSeek.d.ts.map +1 -1
- package/dist/vinylTestUtil/types/current/util/playback/expectTrackCanSeek.js +9 -1
- package/dist/vinylTestUtil/types/ts3.7/assets/vinylTestAssets.d.ts +1 -0
- package/dist/vinylTestUtil/types/ts3.7/mock/streaming/MockContentStream.d.ts +0 -1
- package/dist/vinylTestUtil/types/ts3.7/mock/streaming/buffering/MockBufferingController.d.ts +0 -1
- package/dist/vinylTestUtil/types/ts4.1/assets/vinylTestAssets.d.ts +1 -0
- package/dist/vinylTestUtil/types/ts4.1/mock/streaming/MockContentStream.d.ts +0 -1
- package/dist/vinylTestUtil/types/ts4.1/mock/streaming/buffering/MockBufferingController.d.ts +0 -1
- package/dist/vinylTestUtil/types/ts4.7/assets/vinylTestAssets.d.ts +1 -0
- package/dist/vinylTestUtil/types/ts4.7/mock/streaming/MockContentStream.d.ts +0 -1
- package/dist/vinylTestUtil/types/ts4.7/mock/streaming/buffering/MockBufferingController.d.ts +0 -1
- package/docs/USAGE.md +29 -0
- package/package.json +11 -10
- package/dist/types/current/patch/media/HtmlMediaElementPatch.d.ts +0 -3
- package/dist/types/current/patch/media/HtmlMediaElementPatch.d.ts.map +0 -1
- package/dist/types/current/patch/media/HtmlMediaElementPatch.js +0 -5
- package/dist/types/current/patch/media/MediaElementPatchOptions.d.ts +0 -19
- package/dist/types/current/patch/media/MediaElementPatchOptions.d.ts.map +0 -1
- package/dist/types/current/patch/media/MediaElementPatchOptions.js +0 -16
- package/dist/types/current/patch/media/patchMediaElement.d.ts +0 -9
- package/dist/types/current/patch/media/patchMediaElement.d.ts.map +0 -1
- package/dist/types/current/patch/media/patchMediaElement.js +0 -15
- package/dist/types/current/patch/media/patches/createPreventStallsPatch.d.ts +0 -17
- package/dist/types/current/patch/media/patches/createPreventStallsPatch.d.ts.map +0 -1
- package/dist/types/current/patch/media/patches/createPreventStallsPatch.js +0 -55
- package/dist/types/current/patch/media/patches/createUnreliablePlaybackEventsPatch.d.ts +0 -26
- package/dist/types/current/patch/media/patches/createUnreliablePlaybackEventsPatch.d.ts.map +0 -1
- package/dist/types/current/patch/media/patches/createUnreliablePlaybackEventsPatch.js +0 -218
- package/dist/types/current/vinyl/VinylPatchOptions.d.ts +0 -10
- package/dist/types/current/vinyl/VinylPatchOptions.d.ts.map +0 -1
- package/dist/types/current/vinyl/VinylPatchOptions.js +0 -11
- package/dist/types/ts3.7/patch/media/HtmlMediaElementPatch.d.ts +0 -3
- package/dist/types/ts3.7/patch/media/MediaElementPatchOptions.d.ts +0 -19
- package/dist/types/ts3.7/patch/media/patchMediaElement.d.ts +0 -9
- package/dist/types/ts3.7/patch/media/patches/createPreventStallsPatch.d.ts +0 -17
- package/dist/types/ts3.7/patch/media/patches/createUnreliablePlaybackEventsPatch.d.ts +0 -26
- package/dist/types/ts3.7/vinyl/VinylPatchOptions.d.ts +0 -10
- package/dist/types/ts4.1/patch/media/HtmlMediaElementPatch.d.ts +0 -3
- package/dist/types/ts4.1/patch/media/MediaElementPatchOptions.d.ts +0 -19
- package/dist/types/ts4.1/patch/media/patchMediaElement.d.ts +0 -9
- package/dist/types/ts4.1/patch/media/patches/createPreventStallsPatch.d.ts +0 -17
- package/dist/types/ts4.1/patch/media/patches/createUnreliablePlaybackEventsPatch.d.ts +0 -26
- package/dist/types/ts4.1/vinyl/VinylPatchOptions.d.ts +0 -10
- package/dist/types/ts4.7/patch/media/HtmlMediaElementPatch.d.ts +0 -3
- package/dist/types/ts4.7/patch/media/MediaElementPatchOptions.d.ts +0 -19
- package/dist/types/ts4.7/patch/media/patchMediaElement.d.ts +0 -9
- package/dist/types/ts4.7/patch/media/patches/createPreventStallsPatch.d.ts +0 -17
- package/dist/types/ts4.7/patch/media/patches/createUnreliablePlaybackEventsPatch.d.ts +0 -26
- package/dist/types/ts4.7/vinyl/VinylPatchOptions.d.ts +0 -10
- package/dist/unit/types/current/patch/media/MediaElementPatchOptions.test.d.ts +0 -2
- package/dist/unit/types/current/patch/media/MediaElementPatchOptions.test.d.ts.map +0 -1
- package/dist/unit/types/current/patch/media/MediaElementPatchOptions.test.js +0 -17
- package/dist/unit/types/current/patch/media/patchMediaElement.test.d.ts +0 -2
- package/dist/unit/types/current/patch/media/patchMediaElement.test.d.ts.map +0 -1
- package/dist/unit/types/current/patch/media/patchMediaElement.test.js +0 -36
- package/dist/unit/types/current/patch/media/patches/createPreventStallsPatch.test.d.ts +0 -2
- package/dist/unit/types/current/patch/media/patches/createPreventStallsPatch.test.d.ts.map +0 -1
- package/dist/unit/types/current/patch/media/patches/createPreventStallsPatch.test.js +0 -93
- package/dist/unit/types/current/patch/media/patches/createUnreliablePlaybackEventsPatch.test.d.ts +0 -2
- package/dist/unit/types/current/patch/media/patches/createUnreliablePlaybackEventsPatch.test.d.ts.map +0 -1
- package/dist/unit/types/current/patch/media/patches/createUnreliablePlaybackEventsPatch.test.js +0 -423
|
@@ -2,56 +2,61 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { withinAudioSampleRateRange, createEmptyMediaQualityMetadata, throwSamplingRatesUnsupported, } from '@amazon/vinyl';
|
|
6
6
|
import { MockCapabilities } from '@amazon/vinyl/vinylTestUtil';
|
|
7
7
|
import { setUserAgent } from '@amazon/vinyl-util';
|
|
8
|
-
describe('
|
|
8
|
+
describe('withinAudioSampleRateRange', () => {
|
|
9
9
|
let capabilities;
|
|
10
10
|
beforeEach(() => {
|
|
11
11
|
capabilities = new MockCapabilities();
|
|
12
12
|
capabilities.sampleRate = 48_000;
|
|
13
13
|
});
|
|
14
|
+
// The filter only gates audio content types, so gated fixtures must declare
|
|
15
|
+
// contentType 'audio' (the empty metadata defaults it to null).
|
|
16
|
+
function audioQuality(rate) {
|
|
17
|
+
const quality = createEmptyMediaQualityMetadata();
|
|
18
|
+
quality.contentType = 'audio';
|
|
19
|
+
quality.audioSamplingRate = rate;
|
|
20
|
+
return quality;
|
|
21
|
+
}
|
|
14
22
|
describe('when browser is Firefox', () => {
|
|
15
23
|
beforeEach(() => {
|
|
16
24
|
setUserAgent('Firefox');
|
|
17
25
|
});
|
|
18
26
|
it('returns false when sample rate is above supported', () => {
|
|
19
|
-
const metadata =
|
|
20
|
-
metadata
|
|
21
|
-
expect(supportsAudioSamplingRate({ capabilities }, metadata, 0, [
|
|
27
|
+
const metadata = audioQuality([96_000]);
|
|
28
|
+
expect(withinAudioSampleRateRange({ capabilities }, metadata, 0, [
|
|
22
29
|
metadata,
|
|
23
30
|
])).toBe(false);
|
|
24
31
|
});
|
|
25
32
|
it('returns false when sample rate is above 48kHz even if capabilities allows it', () => {
|
|
26
33
|
capabilities.sampleRate = 96_000;
|
|
27
|
-
const metadata =
|
|
28
|
-
metadata
|
|
29
|
-
expect(supportsAudioSamplingRate({ capabilities }, metadata, 0, [
|
|
34
|
+
const metadata = audioQuality([96_000]);
|
|
35
|
+
expect(withinAudioSampleRateRange({ capabilities }, metadata, 0, [
|
|
30
36
|
metadata,
|
|
31
37
|
])).toBe(false);
|
|
32
38
|
});
|
|
33
39
|
it('returns false even when all rates are above 48kHz (no fallback to lowest)', () => {
|
|
34
|
-
const low =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
const low = audioQuality([88_200]);
|
|
41
|
+
const high = audioQuality([96_000]);
|
|
42
|
+
expect(withinAudioSampleRateRange({ capabilities }, low, 0, [
|
|
43
|
+
low,
|
|
44
|
+
high,
|
|
45
|
+
])).toBe(false);
|
|
46
|
+
expect(withinAudioSampleRateRange({ capabilities }, high, 1, [
|
|
40
47
|
low,
|
|
41
48
|
high,
|
|
42
49
|
])).toBe(false);
|
|
43
50
|
});
|
|
44
51
|
it('returns true when sample rate is at or below supported', () => {
|
|
45
|
-
const metadata =
|
|
46
|
-
metadata
|
|
47
|
-
expect(supportsAudioSamplingRate({ capabilities }, metadata, 0, [
|
|
52
|
+
const metadata = audioQuality([48_000]);
|
|
53
|
+
expect(withinAudioSampleRateRange({ capabilities }, metadata, 0, [
|
|
48
54
|
metadata,
|
|
49
55
|
])).toBe(true);
|
|
50
56
|
});
|
|
51
57
|
it('returns true when sample rate is not set', () => {
|
|
52
|
-
const metadata =
|
|
53
|
-
metadata
|
|
54
|
-
expect(supportsAudioSamplingRate({ capabilities }, metadata, 0, [
|
|
58
|
+
const metadata = audioQuality(null);
|
|
59
|
+
expect(withinAudioSampleRateRange({ capabilities }, metadata, 0, [
|
|
55
60
|
metadata,
|
|
56
61
|
])).toBe(true);
|
|
57
62
|
});
|
|
@@ -61,32 +66,81 @@ describe('supportsAudioSamplingRate', () => {
|
|
|
61
66
|
setUserAgent('Chrome');
|
|
62
67
|
});
|
|
63
68
|
it('returns true when sample rate is at or below supported', () => {
|
|
64
|
-
const metadata =
|
|
65
|
-
metadata
|
|
66
|
-
|
|
69
|
+
const metadata = audioQuality([48_000]);
|
|
70
|
+
expect(withinAudioSampleRateRange({ capabilities }, metadata, 0, [
|
|
71
|
+
metadata,
|
|
72
|
+
])).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
it('keeps everything when there is no platform max to gauge support', () => {
|
|
75
|
+
capabilities.sampleRate = null;
|
|
76
|
+
const metadata = audioQuality([96_000]);
|
|
77
|
+
expect(withinAudioSampleRateRange({ capabilities }, metadata, 0, [
|
|
67
78
|
metadata,
|
|
68
79
|
])).toBe(true);
|
|
69
80
|
});
|
|
70
81
|
it('returns false when sample rate is above supported and others are below', () => {
|
|
71
|
-
const low =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
high.audioSamplingRate = [96_000];
|
|
75
|
-
expect(supportsAudioSamplingRate({ capabilities }, high, 1, [
|
|
82
|
+
const low = audioQuality([44_100]);
|
|
83
|
+
const high = audioQuality([96_000]);
|
|
84
|
+
expect(withinAudioSampleRateRange({ capabilities }, high, 1, [
|
|
76
85
|
low,
|
|
77
86
|
high,
|
|
78
87
|
])).toBe(false);
|
|
79
88
|
});
|
|
80
89
|
it('keeps lowest sample rate when all are above supported', () => {
|
|
81
|
-
const low =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
const low = audioQuality([88_200]);
|
|
91
|
+
const high = audioQuality([96_000]);
|
|
92
|
+
expect(withinAudioSampleRateRange({ capabilities }, low, 0, [
|
|
93
|
+
low,
|
|
94
|
+
high,
|
|
95
|
+
])).toBe(true);
|
|
96
|
+
expect(withinAudioSampleRateRange({ capabilities }, high, 1, [
|
|
97
|
+
low,
|
|
98
|
+
high,
|
|
99
|
+
])).toBe(false);
|
|
100
|
+
});
|
|
101
|
+
it('an explicit maxSampleRate takes precedence — raising it keeps a higher rate', () => {
|
|
102
|
+
// AudioContext reports 48kHz, which would drop the 96kHz rendition.
|
|
103
|
+
capabilities.sampleRate = 48_000;
|
|
104
|
+
const low = audioQuality([48_000]);
|
|
105
|
+
const high = audioQuality([96_000]);
|
|
106
|
+
// Without an override, 96kHz is dropped (a 48kHz alternative exists).
|
|
107
|
+
expect(withinAudioSampleRateRange({ capabilities }, high, 1, [
|
|
87
108
|
low,
|
|
88
109
|
high,
|
|
89
110
|
])).toBe(false);
|
|
111
|
+
// With maxSampleRate = 96kHz, it is kept.
|
|
112
|
+
expect(withinAudioSampleRateRange({ capabilities, maxSampleRate: 96_000 }, high, 1, [low, high])).toBe(true);
|
|
113
|
+
});
|
|
114
|
+
it('an explicit maxSampleRate takes precedence — lowering it drops a rate the platform allows', () => {
|
|
115
|
+
// AudioContext reports 192kHz, which would keep the 96kHz rendition.
|
|
116
|
+
capabilities.sampleRate = 192_000;
|
|
117
|
+
const low = audioQuality([48_000]);
|
|
118
|
+
const high = audioQuality([96_000]);
|
|
119
|
+
expect(withinAudioSampleRateRange({ capabilities }, high, 1, [
|
|
120
|
+
low,
|
|
121
|
+
high,
|
|
122
|
+
])).toBe(true);
|
|
123
|
+
// Capping at 48kHz drops the 96kHz rendition and keeps the 48kHz one.
|
|
124
|
+
expect(withinAudioSampleRateRange({ capabilities, maxSampleRate: 48_000 }, high, 1, [low, high])).toBe(false);
|
|
125
|
+
expect(withinAudioSampleRateRange({ capabilities, maxSampleRate: 48_000 }, low, 0, [low, high])).toBe(true);
|
|
126
|
+
});
|
|
127
|
+
it('ignores non-audio qualities and keeps audio above the device rate', () => {
|
|
128
|
+
// Output device runs at 44.1kHz while the audio is standard 48kHz.
|
|
129
|
+
capabilities.sampleRate = 44_100;
|
|
130
|
+
const audio = audioQuality([48_000]);
|
|
131
|
+
// A co-present video quality is never gated and must not influence
|
|
132
|
+
// the audio keep-lowest fallback.
|
|
133
|
+
const video = createEmptyMediaQualityMetadata();
|
|
134
|
+
video.contentType = 'video';
|
|
135
|
+
video.audioSamplingRate = null;
|
|
136
|
+
expect(withinAudioSampleRateRange({ capabilities }, audio, 0, [
|
|
137
|
+
audio,
|
|
138
|
+
video,
|
|
139
|
+
])).toBe(true);
|
|
140
|
+
expect(withinAudioSampleRateRange({ capabilities }, video, 1, [
|
|
141
|
+
audio,
|
|
142
|
+
video,
|
|
143
|
+
])).toBe(true);
|
|
90
144
|
});
|
|
91
145
|
});
|
|
92
146
|
it('throws correct error', () => {
|
|
@@ -100,3 +154,126 @@ describe('supportsAudioSamplingRate', () => {
|
|
|
100
154
|
}
|
|
101
155
|
});
|
|
102
156
|
});
|
|
157
|
+
describe('withinAudioSampleRateRange minSampleRate floor', () => {
|
|
158
|
+
let capabilities;
|
|
159
|
+
beforeEach(() => {
|
|
160
|
+
capabilities = new MockCapabilities();
|
|
161
|
+
// High enough that the upper bound never interferes with these tests.
|
|
162
|
+
capabilities.sampleRate = 192_000;
|
|
163
|
+
});
|
|
164
|
+
function audioQuality(rate) {
|
|
165
|
+
const quality = createEmptyMediaQualityMetadata();
|
|
166
|
+
quality.contentType = 'audio';
|
|
167
|
+
quality.audioSamplingRate = rate;
|
|
168
|
+
return quality;
|
|
169
|
+
}
|
|
170
|
+
// minSampleRate is passed via the options arg alongside capabilities.
|
|
171
|
+
function withinMin(metadata, index, array) {
|
|
172
|
+
return withinAudioSampleRateRange({ capabilities, minSampleRate: 48_000 }, metadata, index, array);
|
|
173
|
+
}
|
|
174
|
+
it('passes through non-audio qualities', () => {
|
|
175
|
+
const video = createEmptyMediaQualityMetadata();
|
|
176
|
+
video.contentType = 'video';
|
|
177
|
+
expect(withinMin(video, 0, [video])).toBe(true);
|
|
178
|
+
});
|
|
179
|
+
it('keeps qualities with no sampling rate', () => {
|
|
180
|
+
const quality = audioQuality(null);
|
|
181
|
+
expect(withinMin(quality, 0, [quality])).toBe(true);
|
|
182
|
+
});
|
|
183
|
+
it('drops rates below the floor when a rate at or above it exists', () => {
|
|
184
|
+
const low = audioQuality([24_000]);
|
|
185
|
+
const high = audioQuality([48_000]);
|
|
186
|
+
expect(withinMin(high, 1, [low, high])).toBe(true);
|
|
187
|
+
expect(withinMin(low, 0, [low, high])).toBe(false);
|
|
188
|
+
});
|
|
189
|
+
it('keeps the highest when every rate is below the floor', () => {
|
|
190
|
+
const low = audioQuality([16_000]);
|
|
191
|
+
const mid = audioQuality([24_000]);
|
|
192
|
+
expect(withinMin(mid, 1, [low, mid])).toBe(true);
|
|
193
|
+
expect(withinMin(low, 0, [low, mid])).toBe(false);
|
|
194
|
+
});
|
|
195
|
+
it('keeps the highest when every rate (of three) is below the floor', () => {
|
|
196
|
+
const low = audioQuality([16_000]);
|
|
197
|
+
const mid = audioQuality([24_000]);
|
|
198
|
+
const high = audioQuality([32_000]);
|
|
199
|
+
expect(withinMin(high, 2, [low, mid, high])).toBe(true);
|
|
200
|
+
expect(withinMin(mid, 1, [low, mid, high])).toBe(false);
|
|
201
|
+
expect(withinMin(low, 0, [low, mid, high])).toBe(false);
|
|
202
|
+
});
|
|
203
|
+
it('keeps the highest below-floor rate when no platform max is reported', () => {
|
|
204
|
+
// No AudioContext rate, so the floor is the only bound; with every rate
|
|
205
|
+
// below it, the highest is kept as the fallback.
|
|
206
|
+
capabilities.sampleRate = null;
|
|
207
|
+
const low = audioQuality([16_000]);
|
|
208
|
+
const high = audioQuality([32_000]);
|
|
209
|
+
expect(withinMin(high, 1, [low, high])).toBe(true);
|
|
210
|
+
expect(withinMin(low, 0, [low, high])).toBe(false);
|
|
211
|
+
});
|
|
212
|
+
it('keeps a single audio rendition below the floor', () => {
|
|
213
|
+
const only = audioQuality([24_000]);
|
|
214
|
+
expect(withinMin(only, 0, [only])).toBe(true);
|
|
215
|
+
});
|
|
216
|
+
it('ignores non-audio qualities in the floor fallback', () => {
|
|
217
|
+
const audio = audioQuality([24_000]); // below the floor
|
|
218
|
+
const video = createEmptyMediaQualityMetadata();
|
|
219
|
+
video.contentType = 'video';
|
|
220
|
+
video.audioSamplingRate = null;
|
|
221
|
+
// Below the 48kHz floor but the only audio → kept; video is ignored.
|
|
222
|
+
expect(withinMin(audio, 0, [audio, video])).toBe(true);
|
|
223
|
+
expect(withinMin(video, 1, [audio, video])).toBe(true);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
// The floor and ceiling are soft together: when renditions straddle an empty
|
|
227
|
+
// band (some below the floor, some above the ceiling, none in between) neither
|
|
228
|
+
// bound alone must strand audio.
|
|
229
|
+
describe('withinAudioSampleRateRange straddling an empty band', () => {
|
|
230
|
+
let capabilities;
|
|
231
|
+
beforeEach(() => {
|
|
232
|
+
// The soft ceiling is a non-Firefox behavior; Firefox's 48kHz cap is
|
|
233
|
+
// hard (covered above), so pin a non-Firefox UA to exercise the fallback.
|
|
234
|
+
setUserAgent('Chrome');
|
|
235
|
+
capabilities = new MockCapabilities();
|
|
236
|
+
// Ceiling at 48kHz; floor at 44.1kHz → acceptable band is [44.1k, 48k].
|
|
237
|
+
capabilities.sampleRate = 48_000;
|
|
238
|
+
});
|
|
239
|
+
function audioQuality(rate) {
|
|
240
|
+
const quality = createEmptyMediaQualityMetadata();
|
|
241
|
+
quality.contentType = 'audio';
|
|
242
|
+
quality.audioSamplingRate = rate;
|
|
243
|
+
return quality;
|
|
244
|
+
}
|
|
245
|
+
function within(metadata, index, array) {
|
|
246
|
+
return withinAudioSampleRateRange({ capabilities, minSampleRate: 44_100 }, metadata, index, array);
|
|
247
|
+
}
|
|
248
|
+
it('keeps the highest decodable rate when one is below the floor and one above the ceiling', () => {
|
|
249
|
+
const low = audioQuality([22_050]); // below the 44.1kHz floor
|
|
250
|
+
const high = audioQuality([96_000]); // above the 48kHz ceiling
|
|
251
|
+
// Empty band → the below-floor rate is decodable and kept; the
|
|
252
|
+
// above-ceiling rate is dropped, so audio is never stranded.
|
|
253
|
+
expect(within(low, 0, [low, high])).toBe(true);
|
|
254
|
+
expect(within(high, 1, [low, high])).toBe(false);
|
|
255
|
+
});
|
|
256
|
+
it('keeps the below-floor rate when the ceiling matches the output device rate', () => {
|
|
257
|
+
// Output device runs at 44.1kHz, so a 48kHz rendition is above the
|
|
258
|
+
// ceiling while a 22.05kHz rendition is below the floor.
|
|
259
|
+
capabilities.sampleRate = 44_100;
|
|
260
|
+
const low = audioQuality([22_050]);
|
|
261
|
+
const high = audioQuality([48_000]);
|
|
262
|
+
expect(within(low, 0, [low, high])).toBe(true);
|
|
263
|
+
expect(within(high, 1, [low, high])).toBe(false);
|
|
264
|
+
});
|
|
265
|
+
it('still prefers an in-band rate over the straddle fallback', () => {
|
|
266
|
+
const low = audioQuality([22_050]); // below floor
|
|
267
|
+
const mid = audioQuality([44_100]); // in band
|
|
268
|
+
const high = audioQuality([96_000]); // above ceiling
|
|
269
|
+
expect(within(mid, 1, [low, mid, high])).toBe(true);
|
|
270
|
+
expect(within(low, 0, [low, mid, high])).toBe(false);
|
|
271
|
+
expect(within(high, 2, [low, mid, high])).toBe(false);
|
|
272
|
+
});
|
|
273
|
+
it('keeps the lowest when every rate is above the ceiling', () => {
|
|
274
|
+
const low = audioQuality([88_200]);
|
|
275
|
+
const high = audioQuality([96_000]);
|
|
276
|
+
expect(within(low, 0, [low, high])).toBe(true);
|
|
277
|
+
expect(within(high, 1, [low, high])).toBe(false);
|
|
278
|
+
});
|
|
279
|
+
});
|