Stop immediately, if the manifest download fails and the model is
offline
This commit is contained in:
parent
678a6e5513
commit
672d7c23ec
|
@ -56,12 +56,12 @@ public class DashDownload extends AbstractDownload {
|
||||||
private boolean audioInitLoaded = false;
|
private boolean audioInitLoaded = false;
|
||||||
private BigInteger lastAudioTimestamp = BigInteger.ZERO;
|
private BigInteger lastAudioTimestamp = BigInteger.ZERO;
|
||||||
private BigInteger lastVideoTimestamp = BigInteger.ZERO;
|
private BigInteger lastVideoTimestamp = BigInteger.ZERO;
|
||||||
private Object downloadFinished = new Object();
|
private transient Object downloadFinished = new Object();
|
||||||
private HttpClient httpClient;
|
private transient HttpClient httpClient;
|
||||||
private Config config;
|
private transient Config config;
|
||||||
private Model model;
|
private Model model;
|
||||||
private Instant endTime;
|
private Instant endTime;
|
||||||
private Path downloadDir;
|
private transient Path downloadDir;
|
||||||
private String manifestUrl;
|
private String manifestUrl;
|
||||||
private boolean running = false;
|
private boolean running = false;
|
||||||
private ZonedDateTime splitRecStartTime;
|
private ZonedDateTime splitRecStartTime;
|
||||||
|
@ -74,7 +74,7 @@ public class DashDownload extends AbstractDownload {
|
||||||
this.manifestUrl = manifestUrl;
|
this.manifestUrl = manifestUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getManifest(String url) throws IOException {
|
private String getManifest(String url) throws IOException, ExecutionException, InterruptedException {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
|
@ -92,12 +92,16 @@ public class DashDownload extends AbstractDownload {
|
||||||
return response.body().string();
|
return response.body().string();
|
||||||
} else {
|
} else {
|
||||||
HttpException httpException = new HttpException(response.code(), "Couldn't load manifest: " + response.message());
|
HttpException httpException = new HttpException(response.code(), "Couldn't load manifest: " + response.message());
|
||||||
|
if (model.isOnline(true)) {
|
||||||
if (tries == 10) {
|
if (tries == 10) {
|
||||||
throw httpException;
|
throw httpException;
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("Couldn't load manifest", httpException);
|
LOG.debug("Couldn't load manifest", httpException);
|
||||||
waitSomeTime(100 * tries);
|
waitSomeTime(100 * tries);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
internalStop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,11 +199,10 @@ public class DashDownload extends AbstractDownload {
|
||||||
.header(CONNECTION, KEEP_ALIVE)
|
.header(CONNECTION, KEEP_ALIVE)
|
||||||
.build(); // @formatter:on
|
.build(); // @formatter:on
|
||||||
int tries = 1;
|
int tries = 1;
|
||||||
while (tries <= 10) {
|
for (tries = 1; tries <= 10; tries++) {
|
||||||
try (Response response = httpClient.execute(request)) {
|
try (Response response = httpClient.execute(request)) {
|
||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
LOG.trace("Loading segment failed, try {}, {} size:{} {}", tries, response.code(), response.headers().values(CONTENT_LENGTH), url);
|
LOG.trace("Loading segment failed, try {}, {} size:{} {}", tries, response.code(), response.headers().values(CONTENT_LENGTH), url);
|
||||||
tries++;
|
|
||||||
waitSomeTime(tries * 80);
|
waitSomeTime(tries * 80);
|
||||||
} else {
|
} else {
|
||||||
InputStream in = response.body().byteStream();
|
InputStream in = response.body().byteStream();
|
||||||
|
@ -285,7 +288,7 @@ public class DashDownload extends AbstractDownload {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadManifestAndItsSegments(Unmarshaller u) throws IOException, JAXBException, ExecutionException {
|
private void downloadManifestAndItsSegments(Unmarshaller u) throws IOException, JAXBException, ExecutionException, InterruptedException {
|
||||||
String manifest = getManifest(manifestUrl);
|
String manifest = getManifest(manifestUrl);
|
||||||
LOG.trace("Manifest: {}", manifest);
|
LOG.trace("Manifest: {}", manifest);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
Loading…
Reference in New Issue