Skip to content

Commit

Permalink
test: update for independant subtitle deltatimes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nfrederiksen committed Nov 21, 2023
1 parent bdced21 commit d4d8cd0
Show file tree
Hide file tree
Showing 6 changed files with 979 additions and 6 deletions.
2 changes: 1 addition & 1 deletion spec/hlsvod_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2352,7 +2352,7 @@ describe("HLSVod serializing", () => {
return megabytes.toFixed(2);
}
const expectedJSONSizeInMBFull = "5.29";
const expectedJSONSizeInMBPartial = "0.39";
const expectedJSONSizeInMBPartial = "0.38";
const expectedJSONSizeInMBFullAgain = expectedJSONSizeInMBFull;
const expectedMseqCountFull = 146;
const expectedMseqCountPartial = 0;
Expand Down
56 changes: 51 additions & 5 deletions spec/hlsvod_subtitles_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("HLSVod with subtitles", () => {
sequenceAlwaysContainNewSegments: true
}

describe("", () => {
describe("can handle", () => {
let mockMasterManifestLongSegments;
let mockMediaManifestLongSegments;
let mockAudioManifestLongSegments;
Expand All @@ -49,6 +49,8 @@ describe("HLSVod with subtitles", () => {
let mockMediaPlaylistUnevenSubVideoSegments;
let mockSubtitlePlaylistUnevenSubVideoSegments;

let mockHlsDemuxWithPreroll;

beforeEach(() => {
mockMasterManifestLongSegments = function () {
return fs.createReadStream("testvectors/hls_subs/master.m3u8");
Expand Down Expand Up @@ -123,6 +125,21 @@ describe("HLSVod with subtitles", () => {
return fs.createReadStream(`testvectors/hls_subs3/subs/sub.m3u8`);
};

mockHlsDemuxWithPreroll = {
master: () => {
return fs.createReadStream("testvectors/hls_subs7_demux/master.m3u8");
},
media: (bw) => {
return fs.createReadStream(`testvectors/hls_subs7_demux/media7070700.m3u8`);
},
audio: (g, l) => {
return fs.createReadStream(`testvectors/hls_subs7_demux/audio.m3u8`);
},
subtitle: (g, l) => {
return fs.createReadStream(`testvectors/hls_subs7_demux/subtitle.m3u8`);
},
};

});

it("returns the correct number of bandwidths", (done) => {
Expand Down Expand Up @@ -272,10 +289,10 @@ describe("HLSVod with subtitles", () => {
const m3u8_2 = mockVod2.getLiveMediaSubtitleSequences(0, "textstream", "sv", 1);
const subStrings = m3u8.split("\n")
const subStrings2 = m3u8_2.split("\n")
expect(subStrings[33]).toEqual("https://vod.streaming.a2d.tv/3e542405-583b-4edc-93ab-eca86427d148/ab92a690-62de-11ed-aa51-c96fb4f9434f_20337209.ism/hls/ab92a690-62de-11ed-aa51-c96fb4f9434f_20337209-textstream_swe=1000-693.webvtt");
expect(subStrings2[32]).toEqual("#EXT-X-DISCONTINUITY")
expect(subStrings2[33]).toEqual("#EXTINF:3.000,");
expect(subStrings2[34]).toEqual("https://d3t8zrj2x5ol3r.cloudfront.net/u/file~text_vtt~dummy.vtt/1/s/webvtt.vtt");
expect(subStrings[35]).toEqual("https://vod.streaming.a2d.tv/3e542405-583b-4edc-93ab-eca86427d148/ab92a690-62de-11ed-aa51-c96fb4f9434f_20337209.ism/hls/ab92a690-62de-11ed-aa51-c96fb4f9434f_20337209-textstream_swe=1000-693.webvtt");
expect(subStrings2[34]).toEqual("#EXT-X-DISCONTINUITY")
expect(subStrings2[35]).toEqual("#EXTINF:3.000,");
expect(subStrings2[36]).toEqual("https://d3t8zrj2x5ol3r.cloudfront.net/u/file~text_vtt~dummy.vtt/1/s/webvtt.vtt");
done();
});
});
Expand Down Expand Up @@ -358,6 +375,35 @@ describe("HLSVod with subtitles", () => {
done();
});
});
it("deltaTimes and playheadPos, for audio- and subtitletracks with alwaysNewSegments(true)", (done) => {
const bool = 1;
mockVod = new HLSVod("http://mock.com/mock.m3u8", null, 0, 0*1000, null, {
dummySubtitleEndpoint: "/dummysubs.vtt",
subtitleSliceEndpoint: "/subtitlevtt.vtt",
shouldContainSubtitles: true,
expectedSubtitleTracks: [ { language: "fr", name: "french" }, { language: "sv", name: "Swedish" }
],//subtitleTracks,
sequenceAlwaysContainNewSegments: true,
forcedDemuxMode: true
});
mockVod.load(mockHlsDemuxWithPreroll.master, mockHlsDemuxWithPreroll.media, mockHlsDemuxWithPreroll.audio, mockHlsDemuxWithPreroll.subtitle, )
.then(() => {
const deltaV = mockVod.getDeltaTimes()
const deltaS = mockVod.getDeltaTimes("subtitle")
const deltaA = mockVod.getDeltaTimes("audio")
const playheadPosV = mockVod.getPlayheadPositions()
const playheadPosS = mockVod.getPlayheadPositions("subtitle")
const playheadPosA = mockVod.getPlayheadPositions("audio")
expect(deltaV).not.toEqual(deltaS);
expect(deltaA.length).toBeGreaterThan(deltaS.length);
expect(deltaA.slice(0, 132)).toEqual(deltaS.slice(0, 132)); // Last 2 segments are expected to be different
expect(deltaA.slice(132)).not.toEqual(deltaS.slice(132));
expect(playheadPosV).not.toEqual(playheadPosS);
expect(playheadPosA.slice(0, 132)).toEqual(playheadPosS.slice(0, 132));
expect(playheadPosA.slice(132)).not.toEqual(playheadPosS.slice(132));
done();
});
});
it("deltaTimes and playheadPos, alwaysNewSegments(true)", (done) => {
const bool = 1;
mockVod = new HLSVod("http://mock.com/mock.m3u8", null, 0, 0, null, hlsOptsAlwaysNewSegmentsTrue);
Expand Down

0 comments on commit d4d8cd0

Please sign in to comment.