mirror of
https://github.com/samsonjs/media.git
synced 2026-04-17 13:15:47 +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 Uri manifestUri;
|
||||
private long manifestLoadTimestamp;
|
||||
private long manifestLoadStartTimestamp;
|
||||
private long manifestLoadEndTimestamp;
|
||||
private MediaPresentationDescription manifest;
|
||||
|
||||
private boolean prepared;
|
||||
|
|
@ -173,7 +174,7 @@ public final class DashSampleSource implements SampleSource {
|
|||
minUpdatePeriod = 5000;
|
||||
}
|
||||
if (!loader.isLoading()
|
||||
&& SystemClock.elapsedRealtime() > manifestLoadTimestamp + minUpdatePeriod) {
|
||||
&& SystemClock.elapsedRealtime() > manifestLoadStartTimestamp + minUpdatePeriod) {
|
||||
startLoadingManifest();
|
||||
}
|
||||
}
|
||||
|
|
@ -226,9 +227,11 @@ public final class DashSampleSource implements SampleSource {
|
|||
|
||||
// Loadable callbacks.
|
||||
|
||||
/* package */ void onManifestLoadCompleted(MediaPresentationDescription manifest) {
|
||||
/* package */ void onManifestLoadCompleted(MediaPresentationDescription manifest,
|
||||
long elapsedMs) {
|
||||
this.manifest = manifest;
|
||||
manifestLoadTimestamp = SystemClock.elapsedRealtime();
|
||||
manifestLoadEndTimestamp = SystemClock.elapsedRealtime();
|
||||
manifestLoadStartTimestamp = manifestLoadEndTimestamp - elapsedMs;
|
||||
if (manifest.location != null) {
|
||||
manifestUri = manifest.location;
|
||||
}
|
||||
|
|
@ -283,7 +286,7 @@ public final class DashSampleSource implements SampleSource {
|
|||
private void resolveUtcTimingElementDirect(UtcTimingElement timingElement) {
|
||||
try {
|
||||
long utcTimestamp = Util.parseXsDateTime(timingElement.value);
|
||||
long elapsedRealtimeOffset = utcTimestamp - manifestLoadTimestamp;
|
||||
long elapsedRealtimeOffset = utcTimestamp - manifestLoadEndTimestamp;
|
||||
onUtcTimestampLoadCompleted(elapsedRealtimeOffset);
|
||||
} catch (ParseException e) {
|
||||
onUtcTimestampLoadError(new ParserException(e));
|
||||
|
|
@ -353,7 +356,7 @@ public final class DashSampleSource implements SampleSource {
|
|||
@Override
|
||||
public void onLoadCompleted(UriLoadable<MediaPresentationDescription> loadable,
|
||||
long elapsedMs) {
|
||||
onManifestLoadCompleted(loadable.getResult());
|
||||
onManifestLoadCompleted(loadable.getResult(), elapsedMs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public final class SmoothStreamingSampleSource implements SampleSource,
|
|||
private final DataSource manifestDataSource;
|
||||
private final SmoothStreamingManifestParser manifestParser;
|
||||
|
||||
private long manifestLoadTimestamp;
|
||||
private long manifestLoadStartTimestamp;
|
||||
private SmoothStreamingManifest manifest;
|
||||
|
||||
private boolean prepared;
|
||||
|
|
@ -157,7 +157,7 @@ public final class SmoothStreamingSampleSource implements SampleSource,
|
|||
public void continueBuffering(long positionUs) {
|
||||
if (manifest.isLive) {
|
||||
if (!manifestLoader.isLoading() && SystemClock.elapsedRealtime()
|
||||
> manifestLoadTimestamp + MINIMUM_MANIFEST_REFRESH_PERIOD_MS) {
|
||||
> manifestLoadStartTimestamp + MINIMUM_MANIFEST_REFRESH_PERIOD_MS) {
|
||||
for (ChunkTrackStream<SmoothStreamingChunkSource> trackStream : trackStreams) {
|
||||
if (trackStream.getChunkSource().needManifestRefresh()) {
|
||||
startLoadingManifest();
|
||||
|
|
@ -218,7 +218,7 @@ public final class SmoothStreamingSampleSource implements SampleSource,
|
|||
@Override
|
||||
public void onLoadCompleted(UriLoadable<SmoothStreamingManifest> loadable, long elapsedMs) {
|
||||
manifest = loadable.getResult();
|
||||
manifestLoadTimestamp = SystemClock.elapsedRealtime();
|
||||
manifestLoadStartTimestamp = SystemClock.elapsedRealtime() - elapsedMs;
|
||||
if (!prepared) {
|
||||
durationUs = manifest.durationUs;
|
||||
buildTrackGroups(manifest);
|
||||
|
|
|
|||
Loading…
Reference in a new issue