From fbef465ca8a0a0fd004a7db0c7306d62881643c0 Mon Sep 17 00:00:00 2001 From: Nicola Verbeeck Date: Thu, 19 Jul 2018 10:58:58 +0200 Subject: [PATCH 1/5] Allow specifying the default live presentation delay instead of using hardcoded constant --- .../source/dash/DashMediaSource.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java index 8ef7bd13f1..12c755ab6f 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java @@ -79,6 +79,7 @@ public final class DashMediaSource extends BaseMediaSource { private CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory; private int minLoadableRetryCount; private long livePresentationDelayMs; + private long defaultLivePresentationDelayMs; private boolean isCreateCalled; private @Nullable Object tag; @@ -98,6 +99,7 @@ public final class DashMediaSource extends BaseMediaSource { this.manifestDataSourceFactory = manifestDataSourceFactory; minLoadableRetryCount = DEFAULT_MIN_LOADABLE_RETRY_COUNT; livePresentationDelayMs = DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS; + defaultLivePresentationDelayMs = DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS; compositeSequenceableLoaderFactory = new DefaultCompositeSequenceableLoaderFactory(); } @@ -147,6 +149,23 @@ public final class DashMediaSource extends BaseMediaSource { this.livePresentationDelayMs = livePresentationDelayMs; return this; } + + /** + * Sets the duration in milliseconds by which the default start position should precede the end + * of the live window for live playbacks if the value is not present in the manifest. The default value is {@link + * #DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS}. + * + * @param defaultLivePresentationDelayMs For live playbacks, the duration in milliseconds by which the + * default start position should precede the end of the live window if the duration is not specifed in the manifest + * or overwritten using @{link setLivePresentationDelayMs). + * @return This factory, for convenience. + * @throws IllegalStateException If one of the {@code create} methods has already been called. + */ + public Factory setDefaultLivePresentationDelayMs(long defaultLivePresentationDelayMs) { + Assertions.checkState(!isCreateCalled); + this.defaultLivePresentationDelayMs = defaultLivePresentationDelayMs; + return this + } /** * Sets the manifest parser to parse loaded manifest data when loading a manifest URI. @@ -885,7 +904,7 @@ public final class DashMediaSource extends BaseMediaSource { long presentationDelayForManifestMs = livePresentationDelayMs; if (presentationDelayForManifestMs == DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS) { presentationDelayForManifestMs = manifest.suggestedPresentationDelayMs != C.TIME_UNSET - ? manifest.suggestedPresentationDelayMs : DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS; + ? manifest.suggestedPresentationDelayMs : defaultLivePresentationDelayMs; } // Snap the default position to the start of the segment containing it. windowDefaultStartPositionUs = windowDurationUs - C.msToUs(presentationDelayForManifestMs); From e6d32d3fb53b90651ed7675fb6d75007e9847907 Mon Sep 17 00:00:00 2001 From: Nicola Verbeeck Date: Thu, 19 Jul 2018 11:04:28 +0200 Subject: [PATCH 2/5] Updated formatting --- .../android/exoplayer2/source/dash/DashMediaSource.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java index 12c755ab6f..687a379b46 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java @@ -162,9 +162,9 @@ public final class DashMediaSource extends BaseMediaSource { * @throws IllegalStateException If one of the {@code create} methods has already been called. */ public Factory setDefaultLivePresentationDelayMs(long defaultLivePresentationDelayMs) { - Assertions.checkState(!isCreateCalled); - this.defaultLivePresentationDelayMs = defaultLivePresentationDelayMs; - return this + Assertions.checkState(!isCreateCalled); + this.defaultLivePresentationDelayMs = defaultLivePresentationDelayMs; + return this; } /** From fbc0db965a0a70890deb785852315528d7129bd9 Mon Sep 17 00:00:00 2001 From: Nicola Verbeeck Date: Thu, 19 Jul 2018 11:20:18 +0200 Subject: [PATCH 3/5] Updated formatting Added constructor and field in source itself --- .../exoplayer2/source/dash/DashMediaSource.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java index 687a379b46..cb91bd72cd 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java @@ -153,11 +153,12 @@ public final class DashMediaSource extends BaseMediaSource { /** * Sets the duration in milliseconds by which the default start position should precede the end * of the live window for live playbacks if the value is not present in the manifest. The default value is {@link - * #DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS}. + * #DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS}. This value is only used when {@link setLivePresentationDelayMs) has not + * overwritten the presentation delay to a value other than #DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS * * @param defaultLivePresentationDelayMs For live playbacks, the duration in milliseconds by which the * default start position should precede the end of the live window if the duration is not specifed in the manifest - * or overwritten using @{link setLivePresentationDelayMs). + * or overwritten using {@link setLivePresentationDelayMs). * @return This factory, for convenience. * @throws IllegalStateException If one of the {@code create} methods has already been called. */ @@ -220,6 +221,7 @@ public final class DashMediaSource extends BaseMediaSource { compositeSequenceableLoaderFactory, minLoadableRetryCount, livePresentationDelayMs, + defaultLivePresentationDelayMs, tag); } @@ -260,6 +262,7 @@ public final class DashMediaSource extends BaseMediaSource { compositeSequenceableLoaderFactory, minLoadableRetryCount, livePresentationDelayMs, + defaultLivePresentationDelayMs, tag); } @@ -321,6 +324,7 @@ public final class DashMediaSource extends BaseMediaSource { private final CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory; private final int minLoadableRetryCount; private final long livePresentationDelayMs; + private final long defaultLivePresentationDelayMs; private final EventDispatcher manifestEventDispatcher; private final ParsingLoadable.Parser manifestParser; private final ManifestCallback manifestCallback; @@ -398,6 +402,7 @@ public final class DashMediaSource extends BaseMediaSource { new DefaultCompositeSequenceableLoaderFactory(), minLoadableRetryCount, DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS, + DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS, /* tag= */ null); if (eventHandler != null && eventListener != null) { addEventListener(eventHandler, eventListener); @@ -495,6 +500,7 @@ public final class DashMediaSource extends BaseMediaSource { new DefaultCompositeSequenceableLoaderFactory(), minLoadableRetryCount, livePresentationDelayMs, + DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS, /* tag= */ null); if (eventHandler != null && eventListener != null) { addEventListener(eventHandler, eventListener); @@ -510,6 +516,7 @@ public final class DashMediaSource extends BaseMediaSource { CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory, int minLoadableRetryCount, long livePresentationDelayMs, + long defaultLivePresentationDelayMs, @Nullable Object tag) { this.initialManifestUri = manifestUri; this.manifest = manifest; @@ -519,6 +526,7 @@ public final class DashMediaSource extends BaseMediaSource { this.chunkSourceFactory = chunkSourceFactory; this.minLoadableRetryCount = minLoadableRetryCount; this.livePresentationDelayMs = livePresentationDelayMs; + this.defaultLivePresentationDelayMs = defaultLivePresentationDelayMs; this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory; this.tag = tag; sideloadedManifest = manifest != null; From 26a7516b55d835bc37c8abbbae7d53b5db42e5e4 Mon Sep 17 00:00:00 2001 From: Nicola Verbeeck Date: Thu, 19 Jul 2018 11:22:03 +0200 Subject: [PATCH 4/5] Updated formatting --- .../exoplayer2/source/dash/DashMediaSource.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java index cb91bd72cd..2184c9cd06 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java @@ -152,13 +152,15 @@ public final class DashMediaSource extends BaseMediaSource { /** * Sets the duration in milliseconds by which the default start position should precede the end - * of the live window for live playbacks if the value is not present in the manifest. The default value is {@link - * #DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS}. This value is only used when {@link setLivePresentationDelayMs) has not - * overwritten the presentation delay to a value other than #DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS + * of the live window for live playbacks if the value is not present in the manifest. + * The default value is {@link #DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS}. This value is only + * used when {@link setLivePresentationDelayMs) has not overwritten the presentation delay to a + * value other than #DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS * - * @param defaultLivePresentationDelayMs For live playbacks, the duration in milliseconds by which the - * default start position should precede the end of the live window if the duration is not specifed in the manifest - * or overwritten using {@link setLivePresentationDelayMs). + * @param defaultLivePresentationDelayMs For live playbacks, the duration in milliseconds by + * which the default start position should precede the end of the live window if the + * duration is not specifed in the manifest or overwritten using + * {@link setLivePresentationDelayMs). * @return This factory, for convenience. * @throws IllegalStateException If one of the {@code create} methods has already been called. */ From cf99963aab4e5107df3a5e84e7b3b5395133d1b2 Mon Sep 17 00:00:00 2001 From: Nicola Verbeeck Date: Thu, 19 Jul 2018 11:53:42 +0200 Subject: [PATCH 5/5] Typo in docs --- .../android/exoplayer2/source/dash/DashMediaSource.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java index 2184c9cd06..143c70ebb3 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java @@ -154,13 +154,13 @@ public final class DashMediaSource extends BaseMediaSource { * Sets the duration in milliseconds by which the default start position should precede the end * of the live window for live playbacks if the value is not present in the manifest. * The default value is {@link #DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS}. This value is only - * used when {@link setLivePresentationDelayMs) has not overwritten the presentation delay to a + * used when {@link setLivePresentationDelayMs} has not overwritten the presentation delay to a * value other than #DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS * * @param defaultLivePresentationDelayMs For live playbacks, the duration in milliseconds by * which the default start position should precede the end of the live window if the * duration is not specifed in the manifest or overwritten using - * {@link setLivePresentationDelayMs). + * {@link setLivePresentationDelayMs}. * @return This factory, for convenience. * @throws IllegalStateException If one of the {@code create} methods has already been called. */