/** * @license * Copyright 2015 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.SegmentBase', function() { var Dash; beforeAll(function() { Dash = shaka.test.Dash; }); it('requests init data for WebM', function(done) { var source = [ '', ' ', ' ', ' ', ' http://example.com', ' ', ' ', ' ', ' ', ' ', ' ', ''].join('\n'); var engine = new dashFakeNetEngine(source); var parser = new shaka.dash.DashParser(engine, {}, function() {}); parser.start('') .then(function(manifest) { expect(manifest).toEqual( Dash.makeManifestFromInit('init.webm', 201, 300)); return Dash.callCreateSegmentIndex(manifest); }) .then(function() { expect(engine.request.calls.count()).toBe(3); engine.expectRangeRequest('http://example.com', 100, 200); engine.expectRangeRequest('http://example.com/init.webm', 201, 300); }) .catch(fail) .then(done); }); it('inherits from Period', function(done) { var source = [ '', ' ', ' http://example.com', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ''].join('\n'); var engine = new dashFakeNetEngine(source); var parser = new shaka.dash.DashParser(engine, {}, function() {}); parser.start('') .then(function(manifest) { expect(manifest).toEqual( Dash.makeManifestFromInit('init.mp4', 201, 300)); return Dash.callCreateSegmentIndex(manifest); }) .then(function() { expect(engine.request.calls.count()).toBe(2); engine.expectRangeRequest('http://example.com', 100, 200); }) .catch(fail) .then(done); }); it('inherits from AdaptationSet', function(done) { var source = [ '', ' ', ' ', ' http://example.com', ' ', ' ', ' ', ' ', ' ', ' ', ''].join('\n'); var engine = new dashFakeNetEngine(source); var parser = new shaka.dash.DashParser(engine, {}, function() {}); parser.start('') .then(function(manifest) { expect(manifest).toEqual( Dash.makeManifestFromInit('init.mp4', 201, 300)); return Dash.callCreateSegmentIndex(manifest); }) .then(function() { expect(engine.request.calls.count()).toBe(2); engine.expectRangeRequest('http://example.com', 100, 200); }) .catch(fail) .then(done); }); it('merges across levels', function(done) { var source = [ '', ' ', ' http://example.com', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ''].join('\n'); var engine = new dashFakeNetEngine(source); var parser = new shaka.dash.DashParser(engine, {}, function() {}); parser.start('') .then(function(manifest) { expect(manifest).toEqual( Dash.makeManifestFromInit('init.mp4', 201, 300, 10)); return Dash.callCreateSegmentIndex(manifest); }) .then(function() { expect(engine.request.calls.count()).toBe(2); engine.expectRangeRequest('http://example.com/index.mp4', 5, 2000); }) .catch(fail) .then(done); }); it('merges and overrides across levels', function(done) { var source = [ '', ' ', ' http://example.com', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ''].join('\n'); var engine = new dashFakeNetEngine(source); var parser = new shaka.dash.DashParser(engine, {}, function() {}); parser.start('') .then(function(manifest) { expect(manifest).toEqual( Dash.makeManifestFromInit('special.mp4', 0, null, 20)); return Dash.callCreateSegmentIndex(manifest); }) .then(function() { expect(engine.request.calls.count()).toBe(2); engine.expectRangeRequest('http://example.com', 30, 900); }) .catch(fail) .then(done); }); describe('fails for', function() { it('unsupported container', function(done) { var source = [ '', ' ', ' http://example.com', ' ', ' ', ' ', ' ', ' ', ' ', '' ].join('\n'); var error = new shaka.util.Error( shaka.util.Error.Category.MANIFEST, shaka.util.Error.Code.DASH_UNSUPPORTED_CONTAINER); Dash.testFails(done, source, error); }); it('missing init segment for WebM', function(done) { var source = [ '', ' ', ' http://example.com', ' ', ' ', ' ', ' ', ' ', ' ', '' ].join('\n'); var error = new shaka.util.Error( shaka.util.Error.Category.MANIFEST, shaka.util.Error.Code.DASH_WEBM_MISSING_INIT); Dash.testFails(done, source, error); }); it('no @indexRange nor RepresentationIndex', function(done) { var source = [ '', ' ', ' http://example.com', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '' ].join('\n'); var error = new shaka.util.Error( shaka.util.Error.Category.MANIFEST, shaka.util.Error.Code.DASH_NO_SEGMENT_INFO); Dash.testFails(done, source, error); }); }); });