Skip to content

Commit 1751297

Browse files
committed
enhancing new unit test #3, Preselection now gets removed if it refers to non-existing AdaptationSet
1 parent 8ab7004 commit 1751297

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/streaming/utils/CapabilitiesFilter.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function CapabilitiesFilter() {
7878
}
7979

8080
_removeMultiRepresentationPreselections(manifest);
81+
_removePreselectionWithNoAdaptationSet(manifest);
8182

8283
return _applyCustomFilters(manifest);
8384
})
@@ -534,6 +535,22 @@ function CapabilitiesFilter() {
534535
});
535536
}
536537

538+
function _removePreselectionWithNoAdaptationSet(manifest) {
539+
if (!manifest || !manifest.Period || manifest.Period.length === 0) {
540+
return;
541+
}
542+
543+
manifest.Period.forEach((period) => {
544+
if (period.Preselection) {
545+
period.Preselection = period.Preselection.filter((prsl) => {
546+
const prslComponents = String(prsl.preselectionComponents).split(' ');
547+
const adaptationSetIds = period.AdaptationSet.map(as => {return as.id});
548+
return prslComponents.every(c => {return adaptationSetIds.includes(c)});
549+
});
550+
}
551+
});
552+
}
553+
537554
function _applyCustomFilters(manifest) {
538555
if (!manifest || !manifest.Period || manifest.Period.length === 0) {
539556
return Promise.resolve();

test/unit/test/streaming/streaming.utils.CapabilitiesFilter.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ describe('CapabilitiesFilter', function () {
671671

672672
});
673673

674-
it.only('should filter AdaptationSets, channels with preselection override - 1', function (done) {
674+
it('should filter AdaptationSets, channels with preselection override', function (done) {
675675
const manifest = {
676676
Period: [{
677677
Preselection: [
@@ -754,7 +754,7 @@ describe('CapabilitiesFilter', function () {
754754

755755
});
756756

757-
it.only('should filter AdaptationSets, channels with preselection override - 2', function (done) {
757+
it('should filter AdaptationSets and Preselections, channels with preselection override', function (done) {
758758
const manifest = {
759759
Period: [{
760760
Preselection: [
@@ -828,9 +828,8 @@ describe('CapabilitiesFilter', function () {
828828

829829
capabilitiesFilter.filterUnsupportedFeatures(manifest)
830830
.then(() => {
831-
expect(manifest.Period[0].Preselection).to.have.lengthOf(2);
832-
expect(manifest.Period[0].Preselection[0].id).to.be.equal('10');
833-
expect(manifest.Period[0].Preselection[1].id).to.be.equal('11');
831+
expect(manifest.Period[0].Preselection).to.have.lengthOf(1);
832+
expect(manifest.Period[0].Preselection[0].id).to.be.equal('11');
834833
expect(manifest.Period[0].AdaptationSet).to.have.lengthOf(1);
835834
expect(manifest.Period[0].AdaptationSet[0].id).to.be.equal('2');
836835
done();

0 commit comments

Comments
 (0)