Skip to content

Commit

Permalink
fix(Tizen): Adding gapPadding to gap manager to solve Tizen issue (#7331
Browse files Browse the repository at this point in the history
)

Default value for Tizen set to 2 and can be configurable Solving issue
associated to gapManager not able to pass the GAP on Tizen

Fixes #7124
  • Loading branch information
Iragne authored and avelad committed Sep 18, 2024
1 parent 3cc5c1f commit 2a4bc1d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 21 deletions.
3 changes: 3 additions & 0 deletions demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ shakaDemo.Config = class {
.addNumberInput_('Gap detection threshold',
'streaming.gapDetectionThreshold',
/* canBeDecimal= */ true)
.addNumberInput_('Gap padding',
'streaming.gapPadding',
/* canBeDecimal= */ true)
.addNumberInput_('Gap Jump Timer Time', 'streaming.gapJumpTimerTime',
/* canBeDecimal= */ true)
.addNumberInput_('Buffering Goal', 'streaming.bufferingGoal',
Expand Down
8 changes: 8 additions & 0 deletions externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,7 @@ shaka.extern.LiveSyncConfiguration;
* alwaysStreamText: boolean,
* startAtSegmentBoundary: boolean,
* gapDetectionThreshold: number,
* gapPadding: number,
* gapJumpTimerTime: number,
* durationBackoff: number,
* safeSeekOffset: number,
Expand Down Expand Up @@ -1462,6 +1463,13 @@ shaka.extern.LiveSyncConfiguration;
* @property {number} gapDetectionThreshold
* The maximum distance (in seconds) before a gap when we'll automatically
* jump. This value defaults to <code>0.5</code>.
* @property {number} gapPadding
* Padding added only for Xbox, Legacy Edge and Tizen.
* Based on our research (specific to Tizen), the gapPadding value must be
* greater than your GOP length.
* It’s crucial to verify this value according to your actual stream.
* <br>
* Defaults to <code>0.01</code> for Xbox and Legacy Edge, Tizen at 2.
* @property {number} gapJumpTimerTime
* The polling time in seconds to check for gaps in the media. This value
* defaults to <code>0.25</code>.
Expand Down
6 changes: 4 additions & 2 deletions lib/media/gap_jumping_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ shaka.media.GapJumpingController = class {
// often rounds value we want to set as currentTime and we are not able
// to jump over the gap.
if (shaka.util.Platform.isLegacyEdge() ||
shaka.util.Platform.isXboxOne()) {
jumpTo = Math.ceil((jumpTo + 0.01) * 100) / 100;
shaka.util.Platform.isXboxOne() ||
shaka.util.Platform.isTizen()) {
const gapPadding = this.config_.gapPadding;
jumpTo = Math.ceil((jumpTo + gapPadding) * 100) / 100;
}
const seekEnd = this.timeline_.getSeekRangeEnd();
if (jumpTo >= seekEnd) {
Expand Down
5 changes: 5 additions & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ shaka.util.PlayerConfiguration = class {
alwaysStreamText: false,
startAtSegmentBoundary: false,
gapDetectionThreshold: 0.5,
gapPadding: 0.01,
gapJumpTimerTime: 0.25 /* seconds */,
durationBackoff: 1,
// Offset by 5 seconds since Chromecast takes a few seconds to start
Expand Down Expand Up @@ -282,6 +283,10 @@ shaka.util.PlayerConfiguration = class {
streaming.stallSkip = 0;
}

if (shaka.util.Platform.isTizen()) {
streaming.gapPadding = 2;
}

const offline = {
// We need to set this to a throw-away implementation for now as our
// default implementation will need to reference other fields in the
Expand Down
50 changes: 31 additions & 19 deletions test/media/playhead_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ describe('Playhead', () => {
playhead.release();
});

function calculateGap(time) {
let jumpTo = time;
if (shaka.util.Platform.isLegacyEdge() ||
shaka.util.Platform.isXboxOne() ||
shaka.util.Platform.isTizen()) {
const gapPadding = shaka.util.PlayerConfiguration.createDefault()
.streaming.gapPadding;
jumpTo = Math.ceil((jumpTo + gapPadding) * 100) / 100;
}
return jumpTo;
}

function setMockDate(seconds) {
const minutes = Math.floor(seconds / 60);
seconds %= 60;
Expand Down Expand Up @@ -899,7 +911,7 @@ describe('Playhead', () => {
start: 5,
waitingAt: 10,
expectEvent: true,
expectedEndTime: 11,
expectedEndTime: calculateGap(11),
});

playingTest('won\'t skip a buffered range', {
Expand All @@ -908,7 +920,7 @@ describe('Playhead', () => {
start: 5,
waitingAt: 10,
expectEvent: true,
expectedEndTime: 11,
expectedEndTime: calculateGap(11),
});

playingTest('will jump gap into last buffer', {
Expand All @@ -917,7 +929,7 @@ describe('Playhead', () => {
start: 15,
waitingAt: 20,
expectEvent: true,
expectedEndTime: 21,
expectedEndTime: calculateGap(21),
});
}); // with small gaps

Expand All @@ -927,7 +939,7 @@ describe('Playhead', () => {
start: 5,
waitingAt: 10,
expectEvent: true,
expectedEndTime: 30,
expectedEndTime: calculateGap(30),
});

playingTest('will only jump one buffer', {
Expand All @@ -936,7 +948,7 @@ describe('Playhead', () => {
start: 5,
waitingAt: 10,
expectEvent: true,
expectedEndTime: 30,
expectedEndTime: calculateGap(30),
});

playingTest('will jump into last buffer', {
Expand All @@ -945,7 +957,7 @@ describe('Playhead', () => {
start: 24,
waitingAt: 30,
expectEvent: true,
expectedEndTime: 50,
expectedEndTime: calculateGap(50),
});
}); // with large gaps

Expand Down Expand Up @@ -1018,7 +1030,7 @@ describe('Playhead', () => {
start: 3,
seekTo: 10.4,
expectEvent: true,
expectedEndTime: 11,
expectedEndTime: calculateGap(11),
});

seekTest('won\'t jump multiple buffers', {
Expand All @@ -1027,7 +1039,7 @@ describe('Playhead', () => {
start: 3,
seekTo: 10.4,
expectEvent: true,
expectedEndTime: 11,
expectedEndTime: calculateGap(11),
});

seekTest('will jump into last range with seeking', {
Expand All @@ -1036,15 +1048,15 @@ describe('Playhead', () => {
start: 3,
seekTo: 20.5,
expectEvent: true,
expectedEndTime: 21,
expectedEndTime: calculateGap(21),
});

seekTest('treats large gaps as small if playhead near end', {
buffered: [{start: 0, end: 10}, {start: 30, end: 40}],
start: 3,
seekTo: 29.2,
expectEvent: true,
expectedEndTime: 30,
expectedEndTime: calculateGap(30),
});
}); // with small gaps

Expand All @@ -1054,7 +1066,7 @@ describe('Playhead', () => {
start: 5,
seekTo: 12,
expectEvent: true,
expectedEndTime: 30,
expectedEndTime: calculateGap(30),
});
}); // with large gaps
}); // with buffered seeks
Expand All @@ -1079,7 +1091,7 @@ describe('Playhead', () => {
start: 4,
seekTo: 0,
expectEvent: true,
expectedEndTime: 0.2,
expectedEndTime: calculateGap(0.2),
});

seekTest('will jump when seeking into gap', {
Expand All @@ -1089,7 +1101,7 @@ describe('Playhead', () => {
start: 3,
seekTo: 30.2,
expectEvent: true,
expectedEndTime: 31,
expectedEndTime: calculateGap(31),
});

seekTest('will jump when seeking to the end of a range', {
Expand All @@ -1099,7 +1111,7 @@ describe('Playhead', () => {
start: 3,
seekTo: 30,
expectEvent: true,
expectedEndTime: 31,
expectedEndTime: calculateGap(31),
});

seekTest('won\'t jump when past end', {
Expand Down Expand Up @@ -1140,7 +1152,7 @@ describe('Playhead', () => {
start: 24,
seekTo: 1.6,
expectEvent: true,
expectedEndTime: 2,
expectedEndTime: calculateGap(2),
});
}); // with small gaps

Expand All @@ -1151,7 +1163,7 @@ describe('Playhead', () => {
start: 25,
seekTo: 0,
expectEvent: true,
expectedEndTime: 20,
expectedEndTime: calculateGap(20),
});

seekTest('will jump large gaps', {
Expand All @@ -1161,7 +1173,7 @@ describe('Playhead', () => {
start: 3,
seekTo: 32,
expectEvent: true,
expectedEndTime: 40,
expectedEndTime: calculateGap(40),
});
}); // with large gaps
}); // with unbuffered seeks
Expand Down Expand Up @@ -1236,7 +1248,7 @@ describe('Playhead', () => {
jasmine.clock().tick(500);

expect(seekCount).toBe(1);
expect(currentTime).toBe(10);
expect(currentTime).toBe(calculateGap(10));
});

it('doesn\'t gap jump if paused', () => {
Expand Down Expand Up @@ -1286,7 +1298,7 @@ describe('Playhead', () => {
jasmine.clock().tick(500);

// There SHOULD have been a gap jump.
expect(video.currentTime).toBe(10);
expect(video.currentTime).toBe(calculateGap(10));
});

// Regression test for https://github.com/shaka-project/shaka-player/issues/3451
Expand Down

0 comments on commit 2a4bc1d

Please sign in to comment.