diff --git a/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java b/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java index 8cbbec10..27ddccb2 100644 --- a/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java +++ b/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java @@ -56,12 +56,12 @@ public class DashDownload extends AbstractDownload { private boolean audioInitLoaded = false; private BigInteger lastAudioTimestamp = BigInteger.ZERO; private BigInteger lastVideoTimestamp = BigInteger.ZERO; - private Object downloadFinished = new Object(); - private HttpClient httpClient; - private Config config; + private transient Object downloadFinished = new Object(); + private transient HttpClient httpClient; + private transient Config config; private Model model; private Instant endTime; - private Path downloadDir; + private transient Path downloadDir; private String manifestUrl; private boolean running = false; private ZonedDateTime splitRecStartTime; @@ -74,7 +74,7 @@ public class DashDownload extends AbstractDownload { this.manifestUrl = manifestUrl; } - private String getManifest(String url) throws IOException { + private String getManifest(String url) throws IOException, ExecutionException, InterruptedException { // @formatter:off Request request = new Request.Builder() .url(url) @@ -92,11 +92,15 @@ public class DashDownload extends AbstractDownload { return response.body().string(); } else { HttpException httpException = new HttpException(response.code(), "Couldn't load manifest: " + response.message()); - if (tries == 10) { - throw httpException; + if (model.isOnline(true)) { + if (tries == 10) { + throw httpException; + } else { + LOG.debug("Couldn't load manifest", httpException); + waitSomeTime(100 * tries); + } } else { - LOG.debug("Couldn't load manifest", httpException); - waitSomeTime(100 * tries); + internalStop(); } } } @@ -195,11 +199,10 @@ public class DashDownload extends AbstractDownload { .header(CONNECTION, KEEP_ALIVE) .build(); // @formatter:on int tries = 1; - while (tries <= 10) { + for (tries = 1; tries <= 10; tries++) { try (Response response = httpClient.execute(request)) { if (!response.isSuccessful()) { LOG.trace("Loading segment failed, try {}, {} size:{} {}", tries, response.code(), response.headers().values(CONTENT_LENGTH), url); - tries++; waitSomeTime(tries * 80); } else { InputStream in = response.body().byteStream(); @@ -285,7 +288,7 @@ public class DashDownload extends AbstractDownload { 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); LOG.trace("Manifest: {}", manifest); @SuppressWarnings("unchecked")