From ffe9a72945e73c8f74b6c68db4e243406a1d9670 Mon Sep 17 00:00:00 2001 From: Yuriy Liskov Date: Sun, 14 Aug 2022 02:37:26 +0300 Subject: [PATCH] player: dash live improvements --- .../common/exoplayer/LiveDashManifestParser.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/LiveDashManifestParser.java b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/LiveDashManifestParser.java index 68056723d..dfc097915 100644 --- a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/LiveDashManifestParser.java +++ b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/LiveDashManifestParser.java @@ -33,7 +33,7 @@ public class LiveDashManifestParser extends DashManifestParser { private static final String TAG = LiveDashManifestParser.class.getSimpleName(); // Usually gaming streams. 12 hours max. private static final long MAX_PAST_STREAM_LENGTH_MS = 12 * 60 * 60 * 1_000; - // Should be zero for non seekable streams (Record Drum'n'Bass). Higher values may produce 'url not working' error. + // Should be zero for non seekable streams (Record Radio). Higher values may produce 'url not working' error. private static final long MAX_LIVE_STREAM_LENGTH_MS = 0 * 60 * 60 * 1_000; private DashManifest mOldManifest; private long mOldSegmentNum; @@ -216,9 +216,6 @@ public class LiveDashManifestParser extends DashManifestParser { } private static void recreateRepresentation(Representation oldRepresentation, long segmentCount, long minUpdatePeriodMs) { - long presentationTimeOffsetUs = oldRepresentation.presentationTimeOffsetUs; - Helpers.setField(oldRepresentation, "presentationTimeOffsetUs", presentationTimeOffsetUs - (segmentCount * minUpdatePeriodMs * 1_000)); - MultiSegmentRepresentation oldMultiRepresentation = (MultiSegmentRepresentation) oldRepresentation; SegmentList oldSegmentList = (SegmentList) Helpers.getField(oldMultiRepresentation, "segmentBase"); @@ -239,10 +236,14 @@ public class LiveDashManifestParser extends DashManifestParser { long secondSegmentLimit = Helpers.parseLong(secondSegmentQuery.get("lmt")); long limitDiff = secondSegmentLimit - firstSegmentLimit; - if (firstSegmentNum <= 0) { + // Skip variable segment limit (huge limit diff values) + if (firstSegmentNum <= 0 || limitDiff > 100) { return; } + long presentationTimeOffsetUs = oldRepresentation.presentationTimeOffsetUs; + Helpers.setField(oldRepresentation, "presentationTimeOffsetUs", presentationTimeOffsetUs - (segmentCount * minUpdatePeriodMs * 1_000)); + long currentSegmentNum = firstSegmentNum - 1; long currentSegmentLimit = firstSegmentLimit - limitDiff;