From 296585463ad62cea73a2ffa66862e8d1953143b6 Mon Sep 17 00:00:00 2001 From: 0xboobface <0xboobface@gmail.com> Date: Sun, 12 Jul 2020 13:32:06 +0200 Subject: [PATCH] Don't apply min/max resolution settings, if resolution is unknown --- CHANGELOG.md | 1 + .../main/java/ctbrec/recorder/download/StreamSource.java | 5 +++-- .../ctbrec/recorder/download/hls/AbstractHlsDownload.java | 8 +++++--- .../java/ctbrec/sites/mfc/HlsStreamSourceProvider.java | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d04f90d..2928127a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ "keep-alive" threads, if there was a problem with the connection * Reworked the settings tab * Fire recording finished event, if a download from the server is finished +* Ignore min/max resolution, if the resolution is unknown 3.8.1 ======================== diff --git a/common/src/main/java/ctbrec/recorder/download/StreamSource.java b/common/src/main/java/ctbrec/recorder/download/StreamSource.java index 5bd01a0c..c9ed2211 100644 --- a/common/src/main/java/ctbrec/recorder/download/StreamSource.java +++ b/common/src/main/java/ctbrec/recorder/download/StreamSource.java @@ -4,6 +4,7 @@ import java.text.DecimalFormat; public class StreamSource implements Comparable { public static final int ORIGIN = Integer.MAX_VALUE - 1; + public static final int UNKNOWN = Integer.MAX_VALUE; public int bandwidth; public int width; public int height; @@ -45,7 +46,7 @@ public class StreamSource implements Comparable { public String toString() { DecimalFormat df = new DecimalFormat("0.00"); float mbit = bandwidth / 1024.0f / 1024.0f; - if (height == Integer.MAX_VALUE) { + if (height == UNKNOWN) { return "unknown resolution (" + df.format(mbit) + " Mbit/s)"; } else if (height == ORIGIN) { return "Origin"; @@ -61,7 +62,7 @@ public class StreamSource implements Comparable { @Override public int compareTo(StreamSource o) { int heightDiff = height - o.height; - if(heightDiff != 0 && height != Integer.MAX_VALUE && o.height != Integer.MAX_VALUE) { + if(heightDiff != 0 && height != UNKNOWN && o.height != UNKNOWN) { return heightDiff; } else { return bandwidth - o.bandwidth; diff --git a/common/src/main/java/ctbrec/recorder/download/hls/AbstractHlsDownload.java b/common/src/main/java/ctbrec/recorder/download/hls/AbstractHlsDownload.java index fee4c801..d5f260cf 100644 --- a/common/src/main/java/ctbrec/recorder/download/hls/AbstractHlsDownload.java +++ b/common/src/main/java/ctbrec/recorder/download/hls/AbstractHlsDownload.java @@ -1,6 +1,8 @@ package ctbrec.recorder.download.hls; import static ctbrec.io.HttpConstants.*; +import static ctbrec.io.HttpConstants.ORIGIN; +import static ctbrec.recorder.download.StreamSource.*; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -160,12 +162,12 @@ public abstract class AbstractHlsDownload extends AbstractDownload { LOG.debug("{} selected {}", model.getName(), streamSources.get(model.getStreamUrlIndex())); url = streamSources.get(model.getStreamUrlIndex()).getMediaPlaylistUrl(); } else { - // filter out stream resolutions, which are too high + // filter out stream resolutions, which are out of range of the configured min and max int minRes = Config.getInstance().getSettings().minimumResolution; int maxRes = Config.getInstance().getSettings().maximumResolution; List filteredStreamSources = streamSources.stream() - .filter(src -> src.height == 0 || minRes <= src.height) - .filter(src -> src.height == 0 || maxRes >= src.height) + .filter(src -> src.height == 0 || src.height == UNKNOWN || minRes <= src.height) + .filter(src -> src.height == 0 || src.height == UNKNOWN || maxRes >= src.height) .collect(Collectors.toList()); if (filteredStreamSources.isEmpty()) { diff --git a/common/src/main/java/ctbrec/sites/mfc/HlsStreamSourceProvider.java b/common/src/main/java/ctbrec/sites/mfc/HlsStreamSourceProvider.java index d8a3efc5..3b1ff192 100644 --- a/common/src/main/java/ctbrec/sites/mfc/HlsStreamSourceProvider.java +++ b/common/src/main/java/ctbrec/sites/mfc/HlsStreamSourceProvider.java @@ -50,8 +50,8 @@ public class HlsStreamSourceProvider implements StreamSourceProvider { src.width = playlist.getStreamInfo().getResolution().width; src.height = playlist.getStreamInfo().getResolution().height; } else { - src.width = Integer.MAX_VALUE; - src.height = Integer.MAX_VALUE; + src.width = StreamSource.UNKNOWN; + src.height = StreamSource.UNKNOWN; } String masterUrl = streamUrl; String baseUrl = masterUrl.substring(0, masterUrl.lastIndexOf('/') + 1);