mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Use manifest load start time to dictate refresh period.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=123734239
This commit is contained in:
parent
7f70ee911b
commit
53b50a61fe
2 changed files with 12 additions and 9 deletions
|
|
@ -82,7 +82,8 @@ public final class DashSampleSource implements SampleSource {
|
||||||
private final ManifestCallback manifestCallback;
|
private final ManifestCallback manifestCallback;
|
||||||
|
|
||||||
private Uri manifestUri;
|
private Uri manifestUri;
|
||||||
private long manifestLoadTimestamp;
|
private long manifestLoadStartTimestamp;
|
||||||
|
private long manifestLoadEndTimestamp;
|
||||||
private MediaPresentationDescription manifest;
|
private MediaPresentationDescription manifest;
|
||||||
|
|
||||||
private boolean prepared;
|
private boolean prepared;
|
||||||
|
|
@ -173,7 +174,7 @@ public final class DashSampleSource implements SampleSource {
|
||||||
minUpdatePeriod = 5000;
|
minUpdatePeriod = 5000;
|
||||||
}
|
}
|
||||||
if (!loader.isLoading()
|
if (!loader.isLoading()
|
||||||
&& SystemClock.elapsedRealtime() > manifestLoadTimestamp + minUpdatePeriod) {
|
&& SystemClock.elapsedRealtime() > manifestLoadStartTimestamp + minUpdatePeriod) {
|
||||||
startLoadingManifest();
|
startLoadingManifest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -226,9 +227,11 @@ public final class DashSampleSource implements SampleSource {
|
||||||
|
|
||||||
// Loadable callbacks.
|
// Loadable callbacks.
|
||||||
|
|
||||||
/* package */ void onManifestLoadCompleted(MediaPresentationDescription manifest) {
|
/* package */ void onManifestLoadCompleted(MediaPresentationDescription manifest,
|
||||||
|
long elapsedMs) {
|
||||||
this.manifest = manifest;
|
this.manifest = manifest;
|
||||||
manifestLoadTimestamp = SystemClock.elapsedRealtime();
|
manifestLoadEndTimestamp = SystemClock.elapsedRealtime();
|
||||||
|
manifestLoadStartTimestamp = manifestLoadEndTimestamp - elapsedMs;
|
||||||
if (manifest.location != null) {
|
if (manifest.location != null) {
|
||||||
manifestUri = manifest.location;
|
manifestUri = manifest.location;
|
||||||
}
|
}
|
||||||
|
|
@ -283,7 +286,7 @@ public final class DashSampleSource implements SampleSource {
|
||||||
private void resolveUtcTimingElementDirect(UtcTimingElement timingElement) {
|
private void resolveUtcTimingElementDirect(UtcTimingElement timingElement) {
|
||||||
try {
|
try {
|
||||||
long utcTimestamp = Util.parseXsDateTime(timingElement.value);
|
long utcTimestamp = Util.parseXsDateTime(timingElement.value);
|
||||||
long elapsedRealtimeOffset = utcTimestamp - manifestLoadTimestamp;
|
long elapsedRealtimeOffset = utcTimestamp - manifestLoadEndTimestamp;
|
||||||
onUtcTimestampLoadCompleted(elapsedRealtimeOffset);
|
onUtcTimestampLoadCompleted(elapsedRealtimeOffset);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
onUtcTimestampLoadError(new ParserException(e));
|
onUtcTimestampLoadError(new ParserException(e));
|
||||||
|
|
@ -353,7 +356,7 @@ public final class DashSampleSource implements SampleSource {
|
||||||
@Override
|
@Override
|
||||||
public void onLoadCompleted(UriLoadable<MediaPresentationDescription> loadable,
|
public void onLoadCompleted(UriLoadable<MediaPresentationDescription> loadable,
|
||||||
long elapsedMs) {
|
long elapsedMs) {
|
||||||
onManifestLoadCompleted(loadable.getResult());
|
onManifestLoadCompleted(loadable.getResult(), elapsedMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public final class SmoothStreamingSampleSource implements SampleSource,
|
||||||
private final DataSource manifestDataSource;
|
private final DataSource manifestDataSource;
|
||||||
private final SmoothStreamingManifestParser manifestParser;
|
private final SmoothStreamingManifestParser manifestParser;
|
||||||
|
|
||||||
private long manifestLoadTimestamp;
|
private long manifestLoadStartTimestamp;
|
||||||
private SmoothStreamingManifest manifest;
|
private SmoothStreamingManifest manifest;
|
||||||
|
|
||||||
private boolean prepared;
|
private boolean prepared;
|
||||||
|
|
@ -157,7 +157,7 @@ public final class SmoothStreamingSampleSource implements SampleSource,
|
||||||
public void continueBuffering(long positionUs) {
|
public void continueBuffering(long positionUs) {
|
||||||
if (manifest.isLive) {
|
if (manifest.isLive) {
|
||||||
if (!manifestLoader.isLoading() && SystemClock.elapsedRealtime()
|
if (!manifestLoader.isLoading() && SystemClock.elapsedRealtime()
|
||||||
> manifestLoadTimestamp + MINIMUM_MANIFEST_REFRESH_PERIOD_MS) {
|
> manifestLoadStartTimestamp + MINIMUM_MANIFEST_REFRESH_PERIOD_MS) {
|
||||||
for (ChunkTrackStream<SmoothStreamingChunkSource> trackStream : trackStreams) {
|
for (ChunkTrackStream<SmoothStreamingChunkSource> trackStream : trackStreams) {
|
||||||
if (trackStream.getChunkSource().needManifestRefresh()) {
|
if (trackStream.getChunkSource().needManifestRefresh()) {
|
||||||
startLoadingManifest();
|
startLoadingManifest();
|
||||||
|
|
@ -218,7 +218,7 @@ public final class SmoothStreamingSampleSource implements SampleSource,
|
||||||
@Override
|
@Override
|
||||||
public void onLoadCompleted(UriLoadable<SmoothStreamingManifest> loadable, long elapsedMs) {
|
public void onLoadCompleted(UriLoadable<SmoothStreamingManifest> loadable, long elapsedMs) {
|
||||||
manifest = loadable.getResult();
|
manifest = loadable.getResult();
|
||||||
manifestLoadTimestamp = SystemClock.elapsedRealtime();
|
manifestLoadStartTimestamp = SystemClock.elapsedRealtime() - elapsedMs;
|
||||||
if (!prepared) {
|
if (!prepared) {
|
||||||
durationUs = manifest.durationUs;
|
durationUs = manifest.durationUs;
|
||||||
buildTrackGroups(manifest);
|
buildTrackGroups(manifest);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue