/**
* @license
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
describe('DashParser SegmentList', function() {
var Dash;
beforeAll(function() {
Dash = shaka.test.Dash;
});
shaka.test.Dash.makeTimelineTests('SegmentList', '', [
'',
'',
'',
'',
''
]);
it('truncates segments when lengths don\'t match', function(done) {
var source = Dash.makeSimpleManifestText([
'',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
''
], 65 /* duration */);
var references = [
Dash.makeReference('s1.mp4', 1, 50, 60),
Dash.makeReference('s2.mp4', 2, 60, 65)
];
Dash.testSegmentIndex(done, source, references);
});
it('supports single segment', function(done) {
var source = Dash.makeSimpleManifestText([
'',
' ',
''
], 30 /* duration */);
var references = [Dash.makeReference('s1.mp4', 1, 0, 30)];
Dash.testSegmentIndex(done, source, references);
});
describe('duration', function() {
it('basic support', function(done) {
var source = Dash.makeSimpleManifestText([
'',
' ',
' ',
' ',
' ',
''
]);
var references = [
Dash.makeReference('s1.mp4', 1, 0, 10),
Dash.makeReference('s2.mp4', 2, 10, 20),
Dash.makeReference('s3.mp4', 3, 20, 30),
Dash.makeReference('s4.mp4', 4, 30, 40)
];
Dash.testSegmentIndex(done, source, references);
});
it('uses @startNumber correctly', function(done) {
var source = Dash.makeSimpleManifestText([
'',
' ',
' ',
' ',
' ',
''
]);
var references = [
Dash.makeReference('s1.mp4', 5, 40, 50),
Dash.makeReference('s2.mp4', 6, 50, 60),
Dash.makeReference('s3.mp4', 7, 60, 70),
Dash.makeReference('s4.mp4', 8, 70, 80)
];
Dash.testSegmentIndex(done, source, references);
});
it('supports @startNumber=0', function(done) {
var source = Dash.makeSimpleManifestText([
'',
' ',
' ',
''
]);
var references = [
Dash.makeReference('s1.mp4', 1, 0, 10),
Dash.makeReference('s2.mp4', 2, 10, 20)
];
Dash.testSegmentIndex(done, source, references);
});
it('supports @timescale', function(done) {
var source = Dash.makeSimpleManifestText([
'',
' ',
' ',
' ',
' ',
''
]);
var references = [
Dash.makeReference('s1.mp4', 1, 0, 2),
Dash.makeReference('s2.mp4', 2, 2, 4),
Dash.makeReference('s3.mp4', 3, 4, 6),
Dash.makeReference('s4.mp4', 4, 6, 8)
];
Dash.testSegmentIndex(done, source, references);
});
});
describe('rejects streams with', function() {
it('no @duration or SegmentTimeline', function(done) {
var source = Dash.makeSimpleManifestText([
'',
' ',
' ',
' ',
''
]);
var error = new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);
Dash.testFails(done, source, error);
});
it('one segment and no durations', function(done) {
var source = Dash.makeSimpleManifestText([
'',
' ',
''
]);
var error = new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);
Dash.testFails(done, source, error);
});
it('empty SegmentTimeline', function(done) {
var source = Dash.makeSimpleManifestText([
'',
' ',
' ',
' ',
''
]);
var error = new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);
Dash.testFails(done, source, error);
});
});
describe('inherits', function() {
it('attributes', function(done) {
var source = [
'',
' ',
' ',
' ',
' ',
' ',
' http://example.com',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
''
].join('\n');
var references = [
Dash.makeReference('s1.mp4', 1, 0, 50),
Dash.makeReference('s2.mp4', 2, 50, 100),
Dash.makeReference('s3.mp4', 3, 100, 150),
Dash.makeReference('s4.mp4', 4, 150, 200)
];
Dash.testSegmentIndex(done, source, references);
});
it('SegmentTimeline', function(done) {
var source = [
'',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' http://example.com',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
''
].join('\n');
var references = [
Dash.makeReference('s1.mp4', 1, 50, 60),
Dash.makeReference('s2.mp4', 2, 60, 65),
Dash.makeReference('s3.mp4', 3, 65, 73)
];
Dash.testSegmentIndex(done, source, references);
});
it('SegmentURL', function(done) {
var source = [
'',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' http://example.com',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
''
].join('\n');
var references = [
Dash.makeReference('s1.mp4', 1, 50, 60),
Dash.makeReference('s2.mp4', 2, 60, 65),
Dash.makeReference('s3.mp4', 3, 65, 73)
];
Dash.testSegmentIndex(done, source, references);
});
});
describe('Segment start', function() {
it('shoud be adjusted with presentationTimeOffset', function(done) {
var source = [
'',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' http://example.com',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
''
].join('\n');
var references = [
Dash.makeReference('s1.mp4', 1, 40, 50),
Dash.makeReference('s2.mp4', 2, 50, 55),
Dash.makeReference('s3.mp4', 3, 55, 63),
Dash.makeReference('s4.mp4', 4, 63, 70)
];
Dash.testSegmentIndex(done, source, references);
});
});
});