Files
shaka-player/test/media/segment_reference_unit.js
T
Gary Katsevman 8825af7b71 feat: add an audiotrackchanged event for when label, language, or roles of an audio track change (#6913)
This piggybacks on the media quality observer to also check whether the
audio track changed and the change was in label, language, or role.

Currently, this new event is triggered is `observeQualityChanges` is
set. This could be moved to a separate config.

I do play to add a test or two to the integration tests.

For verifying the role/label, I was testing against this public test
stream
https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel-desc-aud.ism/.mpd
(though, it does seem to error out every so often). There might be other
test streams. Angel One is a great one for language.


Also, something that we noticed, but won't be part of this PR. The
timing of this event is likely incorrect if the track was switched and
safeMargin was set. We have some changes for this locally that we can
PR, but there are some issues we found around devices for it, so, it
isn't a straightforward change.
2024-06-27 08:10:37 +02:00

67 lines
2.0 KiB
JavaScript

/*! @license
* Shaka Player
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
describe('SegmentReference', () => {
it('returns in getters values from constructor parameters', () => {
const initSegmentReference = new shaka.media.InitSegmentReference(
/* getUris= */ () => ['a', 'b'],
/* startByte= */ 0,
/* endBytes= */ null);
const reference = new shaka.media.SegmentReference(
/* startTime= */ 2,
/* endTime= */ 3,
/* getUris= */ () => ['x', 'y'],
/* startByte= */ 4,
/* endByte= */ 5,
initSegmentReference,
/* timestampOffset= */ 6,
/* appendWindowStart= */ 7,
/* appendWindowEnd= */ 8);
expect(reference.getStartTime()).toBe(2);
expect(reference.getEndTime()).toBe(3);
expect(reference.getUris()).toEqual(['x', 'y']);
expect(reference.getStartByte()).toBe(4);
expect(reference.getEndByte()).toBe(5);
expect(reference.initSegmentReference).toBe(initSegmentReference);
expect(reference.timestampOffset).toBe(6);
expect(reference.appendWindowStart).toBe(7);
expect(reference.appendWindowEnd).toBe(8);
});
});
describe('InitSegmentReference', () => {
const mediaQuality = {
bandwidth: 1,
audioSamplingRate: 444000,
codecs: 'my codec',
contentType: 'video',
frameRate: 30,
height: 720,
mimeType: 'mime type',
label: null,
roles: null,
language: null,
channelsCount: 2,
pixelAspectRatio: '1:1',
width: 1280,
};
it('returns in getters values from constructor parameters', () => {
const reference = new shaka.media.InitSegmentReference(
/* getUris= */ () => ['x', 'y'],
/* startByte= */ 4,
/* endByte= */ 5,
mediaQuality);
expect(reference.getUris()).toEqual(['x', 'y']);
expect(reference.getStartByte()).toBe(4);
expect(reference.getEndByte()).toBe(5);
expect(reference.getMediaQuality()).toBe(mediaQuality);
});
});