Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

gmarzot
Copy link

@gmarzot gmarzot commented Jan 30, 2021

This works for DASH Live and VOD. Manifest GET rate for Live will not exceed media segment duration. For DASH VOD segment GET rate is determined by segment duration.

I have not looked at HLS yet.

@gmarzot
Copy link
Author

gmarzot commented Feb 18, 2021

any interest?

@sebastianlorenzo88
Copy link

Hello, thanks for your contribution, we are going to review and test the PR as soon as possible.

Regards.

Copy link

@sebastianlorenzo88 sebastianlorenzo88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

I left you some comments, mostly regarding code style to follow the conventions of the project.

Thanks for your contribution.
Regards

@@ -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;

Choose a reason for hiding this comment

The 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 segmentDurationMillis = (long) mediaPlayback.getLastSegment().getDurationSeconds() * 1000;
long segmentDurationMillis =
(long) mediaPlayback.getLastSegment().getDurationSeconds() * 1000;

@@ -219,11 +221,9 @@ private boolean hasContents() {
return segmentBuilder != null;
}

// dynamic manifests (live) or empty segment list require manifest get (timing determined elsewhere)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again this line is too long

Suggested change
// dynamic manifests (live) or empty segment list require manifest get (timing determined elsewhere)
// dynamic manifests (live) or empty segment list require manifest get (timing determined
// elsewhere)

@@ -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;

Choose a reason for hiding this comment

The 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

private final List<MediaPeriod> periods;
private Instant playbackStartTime;
private static final Logger LOG = LoggerFactory.getLogger(Manifest.class);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static variables should be defined at the beginning of variables definition

@@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long

Suggested change
// simulating availabilityStartTime for VOD enables pacing of segment GETs according to segment duration
// simulating availabilityStartTime for VOD enables pacing of segment GETs according to
// segment duration

@@ -12,7 +12,7 @@
VideoStreamingHttpClient httpClient,
TimeMachine timeMachine, SampleResultProcessor sampleResultProcessor) {
//HLS Master Playlist must contain this .m3u8 extension in their URLs
if (url.contains(".m3u8")) {
if (url.contains(".m3u8")||url.contains("format=m3u8")) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space between OR

Suggested change
if (url.contains(".m3u8")||url.contains("format=m3u8")) {
if (url.contains(".m3u8") || url.contains("format=m3u8")) {

Comment on lines +89 to +95
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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both minUpdatePeriod & now could be inlined, due to them are only used once.

Suggested change
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);
public long getReloadTimeMillis(long segmentDurationMillis) {
// wait at least segment duration if minUpdatePeriod is 0 (or very small)
long maxIntervalTime = Math.max(mpd.getMinimumUpdatePeriod().toMillis(), segmentDurationMillis);
return Math
.max(maxIntervalTime - Duration.between(lastDownLoadTime, Instant.now()).toMillis(), 0);
}

@RicardoPoleo
Copy link

Any updates on this PR? @gmarzot

@gmarzot
Copy link
Author

gmarzot commented Dec 6, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants