Skip to content

Commit

Permalink
Restore addPartialStream method.
Browse files Browse the repository at this point in the history
This method was removed during the Variants refactoring.  This method
uses jasmine's asymmetric matchers to only match some of the fields.
This is important for tests so they only test the relevant fields.

This also removes implicit reuse of stream IDs.  Stream IDs must be
unique and there is a new method for cases where the intent is to
use duplicate streams.

Change-Id: I185df5f0beb018169ff537abb952ee4ebbf49be6
  • Loading branch information
TheModMaker committed Aug 16, 2018
1 parent 68cdd83 commit 6c49ddc
Show file tree
Hide file tree
Showing 6 changed files with 407 additions and 534 deletions.
46 changes: 23 additions & 23 deletions test/abr/simple_abr_manager_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@ describe('SimpleAbrManager', function() {
// Keep unsorted.
manifest = new shaka.test.ManifestGenerator()
.addPeriod(0)
.addVariant(0).bandwidth(4e5) // 400 kbps
.addVariant(100).bandwidth(4e5) // 400 kbps
.addAudio(0)
.addVideo(1)
.addVariant(1).bandwidth(1e6) // 1000 kbps
.addVariant(101).bandwidth(1e6) // 1000 kbps
.addAudio(2)
.addVideo(3)
.addVariant(2).bandwidth(5e5) // 500 kbps
.addAudio(12)
.addVideo(4)
.addVariant(3).bandwidth(2e6)
.addAudio(5)
.addVideo(6)
.addVariant(4).bandwidth(2e6) // Identical on purpose.
.addAudio(7)
.addVideo(6)
.addVariant(5).bandwidth(6e5)
.addVariant(102).bandwidth(5e5) // 500 kbps
.addAudio(4)
.addVideo(5)
.addVariant(103).bandwidth(2e6)
.addAudio(6)
.addVideo(7)
.addVariant(104).bandwidth(2e6) // Identical on purpose.
.addAudio(8)
.addVideo(9)
.addTextStream(10)
.addTextStream(11)
.addVariant(105).bandwidth(6e5)
.addAudio(10)
.addVideo(11)
.addTextStream(20)
.addTextStream(21)
.build();

config = {
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('SimpleAbrManager', function() {
config.defaultBandwidthEstimate = 3e6;
abrManager.configure(config);
let chosen = abrManager.chooseVariant();
expect(chosen.id).toBe(4);
expect(chosen.id).toBe(104);
});

it('can handle empty variants', function() {
Expand Down Expand Up @@ -344,41 +344,41 @@ describe('SimpleAbrManager', function() {
it('will respect restrictions', function() {
manifest = new shaka.test.ManifestGenerator()
.addPeriod(0)
.addVariant(0).bandwidth(1e5)
.addVariant(10).bandwidth(1e5)
.addVideo(0).size(50, 50)
.addVariant(1).bandwidth(2e5)
.addVariant(11).bandwidth(2e5)
.addVideo(1).size(200, 200)
.build();

abrManager.setVariants(manifest.periods[0].variants);
let chosen = abrManager.chooseVariant();
expect(chosen.id).toBe(1);
expect(chosen.id).toBe(11);

config.restrictions.maxWidth = 100;
abrManager.configure(config);

chosen = abrManager.chooseVariant();
expect(chosen.id).toBe(0);
expect(chosen.id).toBe(10);
});

it('uses lowest-bandwidth variant when restrictions cannot be met', () => {
manifest = new shaka.test.ManifestGenerator()
.addPeriod(0)
.addVariant(0).bandwidth(1e5)
.addVariant(10).bandwidth(1e5)
.addVideo(0).size(50, 50)
.addVariant(1).bandwidth(2e5)
.addVariant(11).bandwidth(2e5)
.addVideo(1).size(200, 200)
.build();

abrManager.setVariants(manifest.periods[0].variants);
let chosen = abrManager.chooseVariant();
expect(chosen.id).toBe(1);
expect(chosen.id).toBe(11);

// This restriction cannot be met, but we shouldn't fail.
config.restrictions.maxWidth = 1;
abrManager.configure(config);

chosen = abrManager.chooseVariant();
expect(chosen.id).toBe(0);
expect(chosen.id).toBe(10);
});
});
25 changes: 8 additions & 17 deletions test/dash/dash_parser_manifest_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

// Test basic manifest parsing functionality.
describe('DashParser Manifest', function() {
const ContentType = shaka.util.ManifestParserUtils.ContentType;
const Dash = shaka.test.Dash;

/** @type {!shaka.test.FakeNetworkingEngine} */
Expand Down Expand Up @@ -136,52 +137,42 @@ describe('DashParser Manifest', function() {
.anyTimeline()
.minBufferTime(75)
.addPeriod(jasmine.any(Number))
.addVariant(jasmine.any(Number))
.addPartialVariant()
.language('en')
.bandwidth(200)
.primary()
.addVideo(jasmine.any(Number))
.anySegmentFunctions()
.anyInitSegment()
.addPartialStream(ContentType.VIDEO)
.presentationTimeOffset(0)
.mime('video/mp4', 'avc1.4d401f')
.bandwidth(100)
.frameRate(1000000 / 42000)
.size(768, 576)
.addAudio(jasmine.any(Number))
.anySegmentFunctions()
.anyInitSegment()
.addPartialStream(ContentType.AUDIO)
.bandwidth(100)
.presentationTimeOffset(0)
.mime('audio/mp4', 'mp4a.40.29')
.primary()
.roles(['main'])
.addVariant(jasmine.any(Number))
.addPartialVariant()
.language('en')
.bandwidth(150)
.primary()
.addVideo(jasmine.any(Number))
.anySegmentFunctions()
.anyInitSegment()
.addPartialStream(ContentType.VIDEO)
.presentationTimeOffset(0)
.mime('video/mp4', 'avc1.4d401f')
.bandwidth(50)
.frameRate(1000000 / 42000)
.size(576, 432)
.addAudio(jasmine.any(Number))
.anySegmentFunctions()
.anyInitSegment()
.addPartialStream(ContentType.AUDIO)
.bandwidth(100)
.presentationTimeOffset(0)
.mime('audio/mp4', 'mp4a.40.29')
.primary()
.roles(['main'])
.addTextStream(jasmine.any(Number))
.addPartialStream(ContentType.TEXT)
.language('es')
.label('spanish')
.primary()
.anySegmentFunctions()
.anyInitSegment()
.presentationTimeOffset(0)
.mime('text/vtt')
.bandwidth(100)
Expand Down
Loading

0 comments on commit 6c49ddc

Please sign in to comment.