Skip to content

Commit

Permalink
Revert "fix: Fix exception with streaming.startAtSegmentBoundary (sha…
Browse files Browse the repository at this point in the history
…ka-project#4216)"

This reverts commit 24eac2c.
  • Loading branch information
nyanmisaka committed Oct 6, 2022
1 parent a1256d8 commit caee130
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 63 deletions.
3 changes: 1 addition & 2 deletions lib/player.js
Expand Up @@ -5010,8 +5010,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
}

await stream.createSegmentIndex();
const iter = stream.segmentIndex.getIteratorForTime(time);
const ref = iter ? iter.next().value : null;
const ref = stream.segmentIndex[Symbol.iterator]().seek(time);
if (!ref) {
return null;
}
Expand Down
53 changes: 1 addition & 52 deletions test/player_unit.js
Expand Up @@ -124,13 +124,7 @@ describe('Player', () => {

player.createDrmEngine = () => drmEngine;
player.createNetworkingEngine = () => networkingEngine;
player.createPlayhead = (startTime) => {
const callableSetStartTime =
shaka.test.Util.spyFunc(playhead.setStartTime);
callableSetStartTime(startTime);
playhead.setStartTime.calls.reset();
return playhead;
};
player.createPlayhead = () => playhead;
player.createMediaSourceEngine = () => mediaSourceEngine;
player.createStreamingEngine = () => streamingEngine;
}
Expand Down Expand Up @@ -3716,51 +3710,6 @@ describe('Player', () => {
});
});

describe('config streaming.startAtSegmentBoundary', () => {
// Test for https://github.com/shaka-project/shaka-player/issues/4188
// In that issue, using streaming.startAtSegmentBoundary in v4.0.0 caused
// an exception due to the use of a removed method.
it('adjusts start time', async () => {
player.configure('streaming.startAtSegmentBoundary', true);

// In order to adjust the start time to a segment boundary, we need
// segment descriptions in the segment index. So create a non-default
// fake manifest.
const timeline = new shaka.media.PresentationTimeline(300, 0);
timeline.setStatic(true);
// This duration is used by useSegmentTemplate below to decide how many
// references to generate.
timeline.setDuration(300);
manifest = shaka.test.ManifestGenerator.generate((manifest) => {
manifest.presentationTimeline = timeline;
manifest.addVariant(0, (variant) => {
variant.addVideo(1, (stream) => {
stream.useSegmentTemplate(
'$Number$.mp4', /* segmentDuration= */ 10);
});
});
});

await player.load(fakeManifestUri, 12, fakeMimeType);

expect(playhead.setStartTime).toHaveBeenCalledWith(10);
});

it('does not fail with no segments', async () => {
player.configure('streaming.startAtSegmentBoundary', true);

// Without useSegmentTemplate in the fake manifest, the call to
// getIteratorForTime() in Player produces a null iterator. Using the
// default fake manifest should cover that case. But just to make sure,
// verify that we have no segments before calling load().
const variant = manifest.variants[0];
expect(variant.video.segmentIndex.getIteratorForTime(0)).toBeNull();
expect(variant.audio.segmentIndex.getIteratorForTime(0)).toBeNull();

await player.load(fakeManifestUri, 0, fakeMimeType);
});
});

/**
* Gets the currently active variant track.
* @return {shaka.extern.Track}
Expand Down
11 changes: 2 additions & 9 deletions test/test/util/simple_fakes.js
Expand Up @@ -308,18 +308,11 @@ shaka.test.FakePlayhead = class {
/** @type {!jasmine.Spy} */
this.setRebufferingGoal = jasmine.createSpy('setRebufferingGoal');

/** @private {number} */
this.startTime_ = 0;

/** @type {!jasmine.Spy} */
this.setStartTime = jasmine.createSpy('setStartTime')
.and.callFake((value) => {
this.startTime_ = value;
});
this.setStartTime = jasmine.createSpy('setStartTime');

/** @type {!jasmine.Spy} */
this.getTime = jasmine.createSpy('getTime')
.and.callFake(() => this.startTime_);
this.getTime = jasmine.createSpy('getTime').and.returnValue(0);

/** @type {!jasmine.Spy} */
this.setBuffering = jasmine.createSpy('setBuffering');
Expand Down

0 comments on commit caee130

Please sign in to comment.