mirror of
https://github.com/androidx/media.git
synced 2025-05-04 06:00:37 +08:00
Add time unit and javadocs to fields in DashManifest
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=176335667
This commit is contained in:
parent
dc425a942c
commit
2ad87f4f5b
@ -129,13 +129,13 @@ public class DashManifestTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void assertManifestEquals(DashManifest expected, DashManifest actual) {
|
private static void assertManifestEquals(DashManifest expected, DashManifest actual) {
|
||||||
assertEquals(expected.availabilityStartTime, actual.availabilityStartTime);
|
assertEquals(expected.availabilityStartTimeMs, actual.availabilityStartTimeMs);
|
||||||
assertEquals(expected.duration, actual.duration);
|
assertEquals(expected.durationMs, actual.durationMs);
|
||||||
assertEquals(expected.minBufferTime, actual.minBufferTime);
|
assertEquals(expected.minBufferTimeMs, actual.minBufferTimeMs);
|
||||||
assertEquals(expected.dynamic, actual.dynamic);
|
assertEquals(expected.dynamic, actual.dynamic);
|
||||||
assertEquals(expected.minUpdatePeriod, actual.minUpdatePeriod);
|
assertEquals(expected.minUpdatePeriodMs, actual.minUpdatePeriodMs);
|
||||||
assertEquals(expected.timeShiftBufferDepth, actual.timeShiftBufferDepth);
|
assertEquals(expected.timeShiftBufferDepthMs, actual.timeShiftBufferDepthMs);
|
||||||
assertEquals(expected.suggestedPresentationDelay, actual.suggestedPresentationDelay);
|
assertEquals(expected.suggestedPresentationDelayMs, actual.suggestedPresentationDelayMs);
|
||||||
assertEquals(expected.utcTiming, actual.utcTiming);
|
assertEquals(expected.utcTiming, actual.utcTiming);
|
||||||
assertEquals(expected.location, actual.location);
|
assertEquals(expected.location, actual.location);
|
||||||
assertEquals(expected.getPeriodCount(), actual.getPeriodCount());
|
assertEquals(expected.getPeriodCount(), actual.getPeriodCount());
|
||||||
|
@ -199,7 +199,7 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT = 3;
|
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT = 3;
|
||||||
/**
|
/**
|
||||||
* A constant indicating that the presentation delay for live streams should be set to
|
* A constant indicating that the presentation delay for live streams should be set to
|
||||||
* {@link DashManifest#suggestedPresentationDelay} if specified by the manifest, or
|
* {@link DashManifest#suggestedPresentationDelayMs} if specified by the manifest, or
|
||||||
* {@link #DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS} otherwise. The presentation delay is the
|
* {@link #DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS} otherwise. The presentation delay is the
|
||||||
* duration by which the default start position precedes the end of the live window.
|
* duration by which the default start position precedes the end of the live window.
|
||||||
*/
|
*/
|
||||||
@ -626,12 +626,12 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
if (manifest.dynamic && !lastPeriodSeekInfo.isIndexExplicit) {
|
if (manifest.dynamic && !lastPeriodSeekInfo.isIndexExplicit) {
|
||||||
// The manifest describes an incomplete live stream. Update the start/end times to reflect the
|
// The manifest describes an incomplete live stream. Update the start/end times to reflect the
|
||||||
// live stream duration and the manifest's time shift buffer depth.
|
// live stream duration and the manifest's time shift buffer depth.
|
||||||
long liveStreamDurationUs = getNowUnixTimeUs() - C.msToUs(manifest.availabilityStartTime);
|
long liveStreamDurationUs = getNowUnixTimeUs() - C.msToUs(manifest.availabilityStartTimeMs);
|
||||||
long liveStreamEndPositionInLastPeriodUs = liveStreamDurationUs
|
long liveStreamEndPositionInLastPeriodUs = liveStreamDurationUs
|
||||||
- C.msToUs(manifest.getPeriod(lastPeriodIndex).startMs);
|
- C.msToUs(manifest.getPeriod(lastPeriodIndex).startMs);
|
||||||
currentEndTimeUs = Math.min(liveStreamEndPositionInLastPeriodUs, currentEndTimeUs);
|
currentEndTimeUs = Math.min(liveStreamEndPositionInLastPeriodUs, currentEndTimeUs);
|
||||||
if (manifest.timeShiftBufferDepth != C.TIME_UNSET) {
|
if (manifest.timeShiftBufferDepthMs != C.TIME_UNSET) {
|
||||||
long timeShiftBufferDepthUs = C.msToUs(manifest.timeShiftBufferDepth);
|
long timeShiftBufferDepthUs = C.msToUs(manifest.timeShiftBufferDepthMs);
|
||||||
long offsetInPeriodUs = currentEndTimeUs - timeShiftBufferDepthUs;
|
long offsetInPeriodUs = currentEndTimeUs - timeShiftBufferDepthUs;
|
||||||
int periodIndex = lastPeriodIndex;
|
int periodIndex = lastPeriodIndex;
|
||||||
while (offsetInPeriodUs < 0 && periodIndex > 0) {
|
while (offsetInPeriodUs < 0 && periodIndex > 0) {
|
||||||
@ -655,8 +655,8 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
if (manifest.dynamic) {
|
if (manifest.dynamic) {
|
||||||
long presentationDelayForManifestMs = livePresentationDelayMs;
|
long presentationDelayForManifestMs = livePresentationDelayMs;
|
||||||
if (presentationDelayForManifestMs == DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS) {
|
if (presentationDelayForManifestMs == DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS) {
|
||||||
presentationDelayForManifestMs = manifest.suggestedPresentationDelay != C.TIME_UNSET
|
presentationDelayForManifestMs = manifest.suggestedPresentationDelayMs != C.TIME_UNSET
|
||||||
? manifest.suggestedPresentationDelay : DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS;
|
? manifest.suggestedPresentationDelayMs : DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS;
|
||||||
}
|
}
|
||||||
// Snap the default position to the start of the segment containing it.
|
// Snap the default position to the start of the segment containing it.
|
||||||
windowDefaultStartPositionUs = windowDurationUs - C.msToUs(presentationDelayForManifestMs);
|
windowDefaultStartPositionUs = windowDurationUs - C.msToUs(presentationDelayForManifestMs);
|
||||||
@ -668,9 +668,9 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
windowDurationUs / 2);
|
windowDurationUs / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long windowStartTimeMs = manifest.availabilityStartTime
|
long windowStartTimeMs = manifest.availabilityStartTimeMs
|
||||||
+ manifest.getPeriod(0).startMs + C.usToMs(currentStartTimeUs);
|
+ manifest.getPeriod(0).startMs + C.usToMs(currentStartTimeUs);
|
||||||
DashTimeline timeline = new DashTimeline(manifest.availabilityStartTime, windowStartTimeMs,
|
DashTimeline timeline = new DashTimeline(manifest.availabilityStartTimeMs, windowStartTimeMs,
|
||||||
firstPeriodId, currentStartTimeUs, windowDurationUs, windowDefaultStartPositionUs,
|
firstPeriodId, currentStartTimeUs, windowDurationUs, windowDefaultStartPositionUs,
|
||||||
manifest);
|
manifest);
|
||||||
sourceListener.onSourceInfoRefreshed(this, timeline, manifest);
|
sourceListener.onSourceInfoRefreshed(this, timeline, manifest);
|
||||||
@ -693,15 +693,15 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
if (!manifest.dynamic) {
|
if (!manifest.dynamic) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long minUpdatePeriod = manifest.minUpdatePeriod;
|
long minUpdatePeriodMs = manifest.minUpdatePeriodMs;
|
||||||
if (minUpdatePeriod == 0) {
|
if (minUpdatePeriodMs == 0) {
|
||||||
// TODO: This is a temporary hack to avoid constantly refreshing the MPD in cases where
|
// TODO: This is a temporary hack to avoid constantly refreshing the MPD in cases where
|
||||||
// minUpdatePeriod is set to 0. In such cases we shouldn't refresh unless there is explicit
|
// minimumUpdatePeriod is set to 0. In such cases we shouldn't refresh unless there is
|
||||||
// signaling in the stream, according to:
|
// explicit signaling in the stream, according to:
|
||||||
// http://azure.microsoft.com/blog/2014/09/13/dash-live-streaming-with-azure-media-service/
|
// http://azure.microsoft.com/blog/2014/09/13/dash-live-streaming-with-azure-media-service/
|
||||||
minUpdatePeriod = 5000;
|
minUpdatePeriodMs = 5000;
|
||||||
}
|
}
|
||||||
long nextLoadTimestamp = manifestLoadStartTimestamp + minUpdatePeriod;
|
long nextLoadTimestamp = manifestLoadStartTimestamp + minUpdatePeriodMs;
|
||||||
long delayUntilNextLoad = Math.max(0, nextLoadTimestamp - SystemClock.elapsedRealtime());
|
long delayUntilNextLoad = Math.max(0, nextLoadTimestamp - SystemClock.elapsedRealtime());
|
||||||
handler.postDelayed(refreshManifestRunnable, delayUntilNextLoad);
|
handler.postDelayed(refreshManifestRunnable, delayUntilNextLoad);
|
||||||
}
|
}
|
||||||
|
@ -220,11 +220,11 @@ public class DefaultDashChunkSource implements DashChunkSource {
|
|||||||
if (availableSegmentCount == DashSegmentIndex.INDEX_UNBOUNDED) {
|
if (availableSegmentCount == DashSegmentIndex.INDEX_UNBOUNDED) {
|
||||||
// The index is itself unbounded. We need to use the current time to calculate the range of
|
// The index is itself unbounded. We need to use the current time to calculate the range of
|
||||||
// available segments.
|
// available segments.
|
||||||
long liveEdgeTimeUs = getNowUnixTimeUs() - C.msToUs(manifest.availabilityStartTime);
|
long liveEdgeTimeUs = getNowUnixTimeUs() - C.msToUs(manifest.availabilityStartTimeMs);
|
||||||
long periodStartUs = C.msToUs(manifest.getPeriod(periodIndex).startMs);
|
long periodStartUs = C.msToUs(manifest.getPeriod(periodIndex).startMs);
|
||||||
long liveEdgeTimeInPeriodUs = liveEdgeTimeUs - periodStartUs;
|
long liveEdgeTimeInPeriodUs = liveEdgeTimeUs - periodStartUs;
|
||||||
if (manifest.timeShiftBufferDepth != C.TIME_UNSET) {
|
if (manifest.timeShiftBufferDepthMs != C.TIME_UNSET) {
|
||||||
long bufferDepthUs = C.msToUs(manifest.timeShiftBufferDepth);
|
long bufferDepthUs = C.msToUs(manifest.timeShiftBufferDepthMs);
|
||||||
firstAvailableSegmentNum = Math.max(firstAvailableSegmentNum,
|
firstAvailableSegmentNum = Math.max(firstAvailableSegmentNum,
|
||||||
representationHolder.getSegmentNum(liveEdgeTimeInPeriodUs - bufferDepthUs));
|
representationHolder.getSegmentNum(liveEdgeTimeInPeriodUs - bufferDepthUs));
|
||||||
}
|
}
|
||||||
|
@ -23,41 +23,74 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a DASH media presentation description (mpd).
|
* Represents a DASH media presentation description (mpd), as defined by ISO/IEC 23009-1:2014
|
||||||
|
* Section 5.3.1.2.
|
||||||
*/
|
*/
|
||||||
public class DashManifest {
|
public class DashManifest {
|
||||||
|
|
||||||
public final long availabilityStartTime;
|
/**
|
||||||
|
* The {@code availabilityStartTime} value in milliseconds since epoch, or {@link C#TIME_UNSET} if
|
||||||
|
* not present.
|
||||||
|
*/
|
||||||
|
public final long availabilityStartTimeMs;
|
||||||
|
|
||||||
public final long duration;
|
/**
|
||||||
|
* The duration of the presentation in milliseconds, or {@link C#TIME_UNSET} if not applicable.
|
||||||
|
*/
|
||||||
|
public final long durationMs;
|
||||||
|
|
||||||
public final long minBufferTime;
|
/**
|
||||||
|
* The {@code minBufferTime} value in milliseconds, or {@link C#TIME_UNSET} if not present.
|
||||||
|
*/
|
||||||
|
public final long minBufferTimeMs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the manifest has value "dynamic" for the {@code type} attribute.
|
||||||
|
*/
|
||||||
public final boolean dynamic;
|
public final boolean dynamic;
|
||||||
|
|
||||||
public final long minUpdatePeriod;
|
/**
|
||||||
|
* The {@code minimumUpdatePeriod} value in milliseconds, or {@link C#TIME_UNSET} if not
|
||||||
|
* applicable.
|
||||||
|
*/
|
||||||
|
public final long minUpdatePeriodMs;
|
||||||
|
|
||||||
public final long timeShiftBufferDepth;
|
/**
|
||||||
|
* The {@code timeShiftBufferDepth} value in milliseconds, or {@link C#TIME_UNSET} if not
|
||||||
|
* present.
|
||||||
|
*/
|
||||||
|
public final long timeShiftBufferDepthMs;
|
||||||
|
|
||||||
public final long suggestedPresentationDelay;
|
/**
|
||||||
|
* The {@code suggestedPresentationDelay} value in milliseconds, or {@link C#TIME_UNSET} if not
|
||||||
|
* present.
|
||||||
|
*/
|
||||||
|
public final long suggestedPresentationDelayMs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link UtcTimingElement}, or null if not present. Defined in DVB A168:7/2016, Section
|
||||||
|
* 4.7.2.
|
||||||
|
*/
|
||||||
public final UtcTimingElement utcTiming;
|
public final UtcTimingElement utcTiming;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The location of this manifest.
|
||||||
|
*/
|
||||||
public final Uri location;
|
public final Uri location;
|
||||||
|
|
||||||
private final List<Period> periods;
|
private final List<Period> periods;
|
||||||
|
|
||||||
public DashManifest(long availabilityStartTime, long duration, long minBufferTime,
|
public DashManifest(long availabilityStartTimeMs, long durationMs, long minBufferTimeMs,
|
||||||
boolean dynamic, long minUpdatePeriod, long timeShiftBufferDepth,
|
boolean dynamic, long minUpdatePeriodMs, long timeShiftBufferDepthMs,
|
||||||
long suggestedPresentationDelay, UtcTimingElement utcTiming, Uri location,
|
long suggestedPresentationDelayMs, UtcTimingElement utcTiming, Uri location,
|
||||||
List<Period> periods) {
|
List<Period> periods) {
|
||||||
this.availabilityStartTime = availabilityStartTime;
|
this.availabilityStartTimeMs = availabilityStartTimeMs;
|
||||||
this.duration = duration;
|
this.durationMs = durationMs;
|
||||||
this.minBufferTime = minBufferTime;
|
this.minBufferTimeMs = minBufferTimeMs;
|
||||||
this.dynamic = dynamic;
|
this.dynamic = dynamic;
|
||||||
this.minUpdatePeriod = minUpdatePeriod;
|
this.minUpdatePeriodMs = minUpdatePeriodMs;
|
||||||
this.timeShiftBufferDepth = timeShiftBufferDepth;
|
this.timeShiftBufferDepthMs = timeShiftBufferDepthMs;
|
||||||
this.suggestedPresentationDelay = suggestedPresentationDelay;
|
this.suggestedPresentationDelayMs = suggestedPresentationDelayMs;
|
||||||
this.utcTiming = utcTiming;
|
this.utcTiming = utcTiming;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.periods = periods == null ? Collections.<Period>emptyList() : periods;
|
this.periods = periods == null ? Collections.<Period>emptyList() : periods;
|
||||||
@ -73,7 +106,7 @@ public class DashManifest {
|
|||||||
|
|
||||||
public final long getPeriodDurationMs(int index) {
|
public final long getPeriodDurationMs(int index) {
|
||||||
return index == periods.size() - 1
|
return index == periods.size() - 1
|
||||||
? (duration == C.TIME_UNSET ? C.TIME_UNSET : (duration - periods.get(index).startMs))
|
? (durationMs == C.TIME_UNSET ? C.TIME_UNSET : (durationMs - periods.get(index).startMs))
|
||||||
: (periods.get(index + 1).startMs - periods.get(index).startMs);
|
: (periods.get(index + 1).startMs - periods.get(index).startMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,10 +143,10 @@ public class DashManifest {
|
|||||||
copyPeriods.add(new Period(period.id, period.startMs - shiftMs, copyAdaptationSets));
|
copyPeriods.add(new Period(period.id, period.startMs - shiftMs, copyAdaptationSets));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long newDuration = duration != C.TIME_UNSET ? duration - shiftMs : C.TIME_UNSET;
|
long newDuration = durationMs != C.TIME_UNSET ? durationMs - shiftMs : C.TIME_UNSET;
|
||||||
return new DashManifest(availabilityStartTime, newDuration, minBufferTime, dynamic,
|
return new DashManifest(availabilityStartTimeMs, newDuration, minBufferTimeMs, dynamic,
|
||||||
minUpdatePeriod, timeShiftBufferDepth, suggestedPresentationDelay, utcTiming, location,
|
minUpdatePeriodMs, timeShiftBufferDepthMs, suggestedPresentationDelayMs, utcTiming,
|
||||||
copyPeriods);
|
location, copyPeriods);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<AdaptationSet> copyAdaptationSets(
|
private static ArrayList<AdaptationSet> copyAdaptationSets(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user