Remove some compiler warnings
This commit is contained in:
parent
fb77e51e53
commit
ea8e5d7ac5
|
@ -1,11 +1,36 @@
|
||||||
package ctbrec.recorder.download;
|
package ctbrec.recorder.download;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
|
import ctbrec.Config;
|
||||||
|
import ctbrec.Model;
|
||||||
|
import ctbrec.Settings;
|
||||||
|
import ctbrec.UnknownModel;
|
||||||
|
import ctbrec.recorder.download.hls.CombinedSplittingStrategy;
|
||||||
|
import ctbrec.recorder.download.hls.NoopSplittingStrategy;
|
||||||
|
import ctbrec.recorder.download.hls.SizeSplittingStrategy;
|
||||||
|
import ctbrec.recorder.download.hls.TimeSplittingStrategy;
|
||||||
|
|
||||||
public abstract class AbstractDownload implements Download {
|
public abstract class AbstractDownload implements Download {
|
||||||
|
|
||||||
protected Instant startTime;
|
protected Instant startTime;
|
||||||
protected Instant rescheduleTime = Instant.now();
|
protected Instant rescheduleTime = Instant.now();
|
||||||
|
protected Model model = new UnknownModel();
|
||||||
|
|
||||||
|
protected transient Config config;
|
||||||
|
protected transient SplittingStrategy splittingStrategy;
|
||||||
|
protected transient ExecutorService downloadExecutor;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Config config, Model model, Instant startTime, ExecutorService executorService) throws IOException {
|
||||||
|
this.config = config;
|
||||||
|
this.model = model;
|
||||||
|
this.startTime = startTime;
|
||||||
|
this.downloadExecutor = executorService;
|
||||||
|
splittingStrategy = initSplittingStrategy(config.getSettings());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instant getStartTime() {
|
public Instant getStartTime() {
|
||||||
|
@ -16,4 +41,27 @@ public abstract class AbstractDownload implements Download {
|
||||||
public Instant getRescheduleTime() {
|
public Instant getRescheduleTime() {
|
||||||
return rescheduleTime;
|
return rescheduleTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected SplittingStrategy initSplittingStrategy(Settings settings) {
|
||||||
|
SplittingStrategy strategy;
|
||||||
|
switch (settings.splitStrategy) {
|
||||||
|
case TIME:
|
||||||
|
strategy = new TimeSplittingStrategy();
|
||||||
|
break;
|
||||||
|
case SIZE:
|
||||||
|
strategy = new SizeSplittingStrategy();
|
||||||
|
break;
|
||||||
|
case TIME_OR_SIZE:
|
||||||
|
SplittingStrategy timeSplittingStrategy = new TimeSplittingStrategy();
|
||||||
|
SplittingStrategy sizeSplittingStrategy = new SizeSplittingStrategy();
|
||||||
|
strategy = new CombinedSplittingStrategy(timeSplittingStrategy, sizeSplittingStrategy);
|
||||||
|
break;
|
||||||
|
case DONT:
|
||||||
|
default:
|
||||||
|
strategy = new NoopSplittingStrategy();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
strategy.init(settings);
|
||||||
|
return strategy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,7 @@ import java.math.BigInteger;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -59,12 +57,9 @@ public class DashDownload extends AbstractDownload {
|
||||||
private BigInteger lastVideoTimestamp = BigInteger.ZERO;
|
private BigInteger lastVideoTimestamp = BigInteger.ZERO;
|
||||||
private transient AtomicBoolean downloadFinished = new AtomicBoolean(false);
|
private transient AtomicBoolean downloadFinished = new AtomicBoolean(false);
|
||||||
private transient HttpClient httpClient;
|
private transient HttpClient httpClient;
|
||||||
private transient Config config;
|
|
||||||
private Model model;
|
|
||||||
private transient Path downloadDir;
|
private transient Path downloadDir;
|
||||||
private String manifestUrl;
|
private String manifestUrl;
|
||||||
private boolean running = false;
|
private boolean running = false;
|
||||||
private ZonedDateTime splitRecStartTime;
|
|
||||||
|
|
||||||
private File targetFile;
|
private File targetFile;
|
||||||
private File finalFile;
|
private File finalFile;
|
||||||
|
@ -244,7 +239,6 @@ public class DashDownload extends AbstractDownload {
|
||||||
try {
|
try {
|
||||||
Thread.currentThread().setName("Download " + model.getName());
|
Thread.currentThread().setName("Download " + model.getName());
|
||||||
running = true;
|
running = true;
|
||||||
splitRecStartTime = ZonedDateTime.now();
|
|
||||||
JAXBContext jc = JAXBContext.newInstance(MPDtype.class.getPackage().getName());
|
JAXBContext jc = JAXBContext.newInstance(MPDtype.class.getPackage().getName());
|
||||||
Unmarshaller u = jc.createUnmarshaller();
|
Unmarshaller u = jc.createUnmarshaller();
|
||||||
while (running && !Thread.currentThread().isInterrupted()) {
|
while (running && !Thread.currentThread().isInterrupted()) {
|
||||||
|
@ -279,16 +273,13 @@ public class DashDownload extends AbstractDownload {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean splitRecording() {
|
private boolean splitRecording() {
|
||||||
if (config.getSettings().splitRecordings > 0) {
|
if (splittingStrategy.splitNecessary(this)) {
|
||||||
Duration recordingDuration = Duration.between(splitRecStartTime, ZonedDateTime.now());
|
|
||||||
long seconds = recordingDuration.getSeconds();
|
|
||||||
if (seconds >= config.getSettings().splitRecordings) {
|
|
||||||
internalStop();
|
internalStop();
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void downloadManifestAndItsSegments(Unmarshaller u) throws IOException, JAXBException, ExecutionException, InterruptedException {
|
private void downloadManifestAndItsSegments(Unmarshaller u) throws IOException, JAXBException, ExecutionException, InterruptedException {
|
||||||
String manifest = getManifest(manifestUrl);
|
String manifest = getManifest(manifestUrl);
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Map.Entry;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
@ -47,8 +46,6 @@ import com.iheartradio.m3u8.data.TrackData;
|
||||||
import ctbrec.Config;
|
import ctbrec.Config;
|
||||||
import ctbrec.Model;
|
import ctbrec.Model;
|
||||||
import ctbrec.Model.State;
|
import ctbrec.Model.State;
|
||||||
import ctbrec.Settings;
|
|
||||||
import ctbrec.UnknownModel;
|
|
||||||
import ctbrec.io.BandwidthMeter;
|
import ctbrec.io.BandwidthMeter;
|
||||||
import ctbrec.io.HttpClient;
|
import ctbrec.io.HttpClient;
|
||||||
import ctbrec.io.HttpConstants;
|
import ctbrec.io.HttpConstants;
|
||||||
|
@ -57,7 +54,6 @@ import ctbrec.io.MissedSegmentsStatistics;
|
||||||
import ctbrec.recorder.PlaylistGenerator.InvalidPlaylistException;
|
import ctbrec.recorder.PlaylistGenerator.InvalidPlaylistException;
|
||||||
import ctbrec.recorder.download.AbstractDownload;
|
import ctbrec.recorder.download.AbstractDownload;
|
||||||
import ctbrec.recorder.download.HttpHeaderFactory;
|
import ctbrec.recorder.download.HttpHeaderFactory;
|
||||||
import ctbrec.recorder.download.SplittingStrategy;
|
|
||||||
import ctbrec.recorder.download.StreamSource;
|
import ctbrec.recorder.download.StreamSource;
|
||||||
import ctbrec.sites.Site;
|
import ctbrec.sites.Site;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
|
@ -72,11 +68,10 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
|
||||||
private transient NumberFormat nf = new DecimalFormat("000000");
|
private transient NumberFormat nf = new DecimalFormat("000000");
|
||||||
private transient int playlistEmptyCount = 0;
|
private transient int playlistEmptyCount = 0;
|
||||||
private transient int segmentCounter = 1;
|
private transient int segmentCounter = 1;
|
||||||
protected transient Config config;
|
|
||||||
protected transient HttpClient client;
|
protected transient HttpClient client;
|
||||||
protected transient ExecutorService downloadExecutor;
|
|
||||||
protected transient volatile boolean running = true;
|
protected transient volatile boolean running = true;
|
||||||
protected transient SplittingStrategy splittingStrategy;
|
|
||||||
protected transient int lastSegmentNumber = 0;
|
protected transient int lastSegmentNumber = 0;
|
||||||
protected transient int nextSegmentNumber = 0;
|
protected transient int nextSegmentNumber = 0;
|
||||||
protected transient String segmentPlaylistUrl;
|
protected transient String segmentPlaylistUrl;
|
||||||
|
@ -89,8 +84,6 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
|
||||||
private transient int consecutivePlaylistTimeouts = 0;
|
private transient int consecutivePlaylistTimeouts = 0;
|
||||||
private transient int consecutivePlaylistErrors = 0;
|
private transient int consecutivePlaylistErrors = 0;
|
||||||
|
|
||||||
protected Model model = new UnknownModel();
|
|
||||||
|
|
||||||
protected AbstractHlsDownload(HttpClient client) {
|
protected AbstractHlsDownload(HttpClient client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
@ -99,15 +92,6 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
|
||||||
protected void segmentDownloadFinished(SegmentDownload segmentDownload) {}
|
protected void segmentDownloadFinished(SegmentDownload segmentDownload) {}
|
||||||
protected abstract void internalStop();
|
protected abstract void internalStop();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(Config config, Model model, Instant startTime, ExecutorService executorService) throws IOException {
|
|
||||||
this.config = config;
|
|
||||||
this.model = model;
|
|
||||||
this.startTime = startTime;
|
|
||||||
this.downloadExecutor = executorService;
|
|
||||||
splittingStrategy = initSplittingStrategy(config.getSettings());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractHlsDownload call() throws Exception {
|
public AbstractHlsDownload call() throws Exception {
|
||||||
try {
|
try {
|
||||||
|
@ -329,29 +313,6 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SplittingStrategy initSplittingStrategy(Settings settings) {
|
|
||||||
SplittingStrategy strategy;
|
|
||||||
switch (settings.splitStrategy) {
|
|
||||||
case TIME:
|
|
||||||
strategy = new TimeSplittingStrategy();
|
|
||||||
break;
|
|
||||||
case SIZE:
|
|
||||||
strategy = new SizeSplittingStrategy();
|
|
||||||
break;
|
|
||||||
case TIME_OR_SIZE:
|
|
||||||
SplittingStrategy timeSplittingStrategy = new TimeSplittingStrategy();
|
|
||||||
SplittingStrategy sizeSplittingStrategy = new SizeSplittingStrategy();
|
|
||||||
strategy = new CombinedSplittingStrategy(timeSplittingStrategy, sizeSplittingStrategy);
|
|
||||||
break;
|
|
||||||
case DONT:
|
|
||||||
default:
|
|
||||||
strategy = new NoopSplittingStrategy();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
strategy.init(settings);
|
|
||||||
return strategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void enqueueNewSegments(SegmentPlaylist playlist, int nextSegmentNumber) throws IOException {
|
protected void enqueueNewSegments(SegmentPlaylist playlist, int nextSegmentNumber) throws IOException {
|
||||||
int skip = nextSegmentNumber - playlist.seq;
|
int skip = nextSegmentNumber - playlist.seq;
|
||||||
for (String segment : playlist.segments) {
|
for (String segment : playlist.segments) {
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
package ctbrec.sites.showup;
|
package ctbrec.sites.showup;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import ctbrec.io.HttpClient;
|
import ctbrec.io.HttpClient;
|
||||||
import ctbrec.recorder.download.hls.MergedFfmpegHlsDownload;
|
import ctbrec.recorder.download.hls.MergedFfmpegHlsDownload;
|
||||||
|
|
||||||
public class ShowupMergedDownload extends MergedFfmpegHlsDownload {
|
public class ShowupMergedDownload extends MergedFfmpegHlsDownload {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ShowupMergedDownload.class);
|
|
||||||
|
|
||||||
public ShowupMergedDownload(HttpClient client) {
|
public ShowupMergedDownload(HttpClient client) {
|
||||||
super(client);
|
super(client);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue