-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix DASH VOD and Live manifest and segment pacing #21
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -67,7 +67,9 @@ public MediaRepresentation findMatchingVariant(List<MediaRepresentation> variant | |||||||
boolean initialLoop = true; | ||||||||
while (!mediaPlayback.hasEnded()) { | ||||||||
if (mediaPlayback.needsManifestUpdate() && !initialLoop) { | ||||||||
long awaitMillis = manifest.getReloadTimeMillis(timeMachine.now()); | ||||||||
long segmentDurationMillis = (long) mediaPlayback.getLastSegment().getDurationSeconds() * 1000; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is too long, does not fit with code style
Suggested change
|
||||||||
long awaitMillis = manifest.getReloadTimeMillis(segmentDurationMillis); | ||||||||
|
||||||||
if (awaitMillis > 0) { | ||||||||
timeMachine.awaitMillis(awaitMillis); | ||||||||
} | ||||||||
|
@@ -187,7 +189,7 @@ private void awaitSegmentAvailable(DashMediaSegment segment) throws InterruptedE | |||||||
Instant availabilityTime = segment.getStartAvailabilityTime(); | ||||||||
Instant now = timeMachine.now(); | ||||||||
if (availabilityTime.isAfter(now)) { | ||||||||
timeMachine.awaitMillis(Duration.between(availabilityTime, now).toMillis()); | ||||||||
timeMachine.awaitMillis(Duration.between(now, availabilityTime).toMillis()); | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
|
@@ -219,11 +221,9 @@ private boolean hasContents() { | |||||||
return segmentBuilder != null; | ||||||||
} | ||||||||
|
||||||||
// dynamic manifests (live) or empty segment list require manifest get (timing determined elsewhere) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again this line is too long
Suggested change
|
||||||||
private boolean needsManifestUpdate() { | ||||||||
return manifest.isDynamic() | ||||||||
&& manifest.getMinimumUpdatePeriod() != null | ||||||||
&& (manifest.getReloadTimeMillis(timeMachine.now()) <= 0 | ||||||||
|| !segmentBuilder.hasNext() && !periods.hasNext()); | ||||||||
return manifest.isDynamic() || !segmentBuilder.hasNext() && !periods.hasNext(); | ||||||||
} | ||||||||
|
||||||||
} | ||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,6 +6,9 @@ | |||||||||||||||||||||||||||
import io.lindstrom.mpd.data.MPD; | ||||||||||||||||||||||||||||
import io.lindstrom.mpd.data.Period; | ||||||||||||||||||||||||||||
import io.lindstrom.mpd.data.PresentationType; | ||||||||||||||||||||||||||||
import org.slf4j.Logger; | ||||||||||||||||||||||||||||
import org.slf4j.LoggerFactory; | ||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. according to the project code style, the imports should be in alphabetical order |
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
import java.net.URI; | ||||||||||||||||||||||||||||
import java.time.Duration; | ||||||||||||||||||||||||||||
import java.time.Instant; | ||||||||||||||||||||||||||||
|
@@ -17,13 +20,15 @@ public class Manifest { | |||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
private final URI uri; | ||||||||||||||||||||||||||||
private final MPD mpd; | ||||||||||||||||||||||||||||
private final Instant downloadTime; | ||||||||||||||||||||||||||||
private final Instant lastDownLoadTime; | ||||||||||||||||||||||||||||
private final List<MediaPeriod> periods; | ||||||||||||||||||||||||||||
private Instant playbackStartTime; | ||||||||||||||||||||||||||||
private static final Logger LOG = LoggerFactory.getLogger(Manifest.class); | ||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. static variables should be defined at the beginning of variables definition |
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
private Manifest(URI uri, MPD mpd, Instant timestamp) { | ||||||||||||||||||||||||||||
this.uri = uri; | ||||||||||||||||||||||||||||
this.mpd = mpd; | ||||||||||||||||||||||||||||
this.downloadTime = timestamp; | ||||||||||||||||||||||||||||
this.lastDownLoadTime = timestamp; | ||||||||||||||||||||||||||||
this.periods = buildPeriods(mpd); | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
|
@@ -81,9 +86,13 @@ public Duration getMinimumUpdatePeriod() { | |||||||||||||||||||||||||||
return mpd.getMinimumUpdatePeriod(); | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
public long getReloadTimeMillis(Instant now) { | ||||||||||||||||||||||||||||
return Math | ||||||||||||||||||||||||||||
.max(mpd.getMinimumUpdatePeriod().minus(Duration.between(downloadTime, now)).toMillis(), 0); | ||||||||||||||||||||||||||||
public long getReloadTimeMillis(long segmentDurationMillis) { | ||||||||||||||||||||||||||||
Duration minUpdatePeriod = mpd.getMinimumUpdatePeriod(); | ||||||||||||||||||||||||||||
// wait at least segment duration if minUpdatePeriod is 0 (or very small) | ||||||||||||||||||||||||||||
long maxIntervalTime = Math.max(minUpdatePeriod.toMillis(), segmentDurationMillis); | ||||||||||||||||||||||||||||
Instant now = Instant.now(); | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
return Math.max(maxIntervalTime - Duration.between(lastDownLoadTime, now).toMillis(), 0); | ||||||||||||||||||||||||||||
Comment on lines
+89
to
+95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both
Suggested change
|
||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
public Duration getBufferStartTime() { | ||||||||||||||||||||||||||||
|
@@ -97,7 +106,12 @@ public Duration getBufferStartTime() { | |||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
public Instant getAvailabilityStartTime() { | ||||||||||||||||||||||||||||
OffsetDateTime time = mpd.getAvailabilityStartTime(); | ||||||||||||||||||||||||||||
return time != null ? time.toInstant() : Instant.MIN; | ||||||||||||||||||||||||||||
// simulating availabilityStartTime for VOD enables pacing of segment GETs according to segment duration | ||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long
Suggested change
|
||||||||||||||||||||||||||||
if (time == null && playbackStartTime == null) { | ||||||||||||||||||||||||||||
LOG.info("setting playbackStartTime to now()"); | ||||||||||||||||||||||||||||
playbackStartTime = Instant.now(); | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
return time != null ? time.toInstant() : playbackStartTime; | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space between OR