Don't apply min/max resolution settings, if resolution is unknown

This commit is contained in:
0xboobface 2020-07-12 13:32:06 +02:00
parent ed26228d7b
commit 296585463a
4 changed files with 11 additions and 7 deletions

View File

@ -9,6 +9,7 @@
"keep-alive" threads, if there was a problem with the connection "keep-alive" threads, if there was a problem with the connection
* Reworked the settings tab * Reworked the settings tab
* Fire recording finished event, if a download from the server is finished * Fire recording finished event, if a download from the server is finished
* Ignore min/max resolution, if the resolution is unknown
3.8.1 3.8.1
======================== ========================

View File

@ -4,6 +4,7 @@ import java.text.DecimalFormat;
public class StreamSource implements Comparable<StreamSource> { public class StreamSource implements Comparable<StreamSource> {
public static final int ORIGIN = Integer.MAX_VALUE - 1; public static final int ORIGIN = Integer.MAX_VALUE - 1;
public static final int UNKNOWN = Integer.MAX_VALUE;
public int bandwidth; public int bandwidth;
public int width; public int width;
public int height; public int height;
@ -45,7 +46,7 @@ public class StreamSource implements Comparable<StreamSource> {
public String toString() { public String toString() {
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
float mbit = bandwidth / 1024.0f / 1024.0f; float mbit = bandwidth / 1024.0f / 1024.0f;
if (height == Integer.MAX_VALUE) { if (height == UNKNOWN) {
return "unknown resolution (" + df.format(mbit) + " Mbit/s)"; return "unknown resolution (" + df.format(mbit) + " Mbit/s)";
} else if (height == ORIGIN) { } else if (height == ORIGIN) {
return "Origin"; return "Origin";
@ -61,7 +62,7 @@ public class StreamSource implements Comparable<StreamSource> {
@Override @Override
public int compareTo(StreamSource o) { public int compareTo(StreamSource o) {
int heightDiff = height - o.height; 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; return heightDiff;
} else { } else {
return bandwidth - o.bandwidth; return bandwidth - o.bandwidth;

View File

@ -1,6 +1,8 @@
package ctbrec.recorder.download.hls; package ctbrec.recorder.download.hls;
import static ctbrec.io.HttpConstants.*; import static ctbrec.io.HttpConstants.*;
import static ctbrec.io.HttpConstants.ORIGIN;
import static ctbrec.recorder.download.StreamSource.*;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
@ -160,12 +162,12 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
LOG.debug("{} selected {}", model.getName(), streamSources.get(model.getStreamUrlIndex())); LOG.debug("{} selected {}", model.getName(), streamSources.get(model.getStreamUrlIndex()));
url = streamSources.get(model.getStreamUrlIndex()).getMediaPlaylistUrl(); url = streamSources.get(model.getStreamUrlIndex()).getMediaPlaylistUrl();
} else { } 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 minRes = Config.getInstance().getSettings().minimumResolution;
int maxRes = Config.getInstance().getSettings().maximumResolution; int maxRes = Config.getInstance().getSettings().maximumResolution;
List<StreamSource> filteredStreamSources = streamSources.stream() List<StreamSource> filteredStreamSources = streamSources.stream()
.filter(src -> src.height == 0 || minRes <= src.height) .filter(src -> src.height == 0 || src.height == UNKNOWN || minRes <= src.height)
.filter(src -> src.height == 0 || maxRes >= src.height) .filter(src -> src.height == 0 || src.height == UNKNOWN || maxRes >= src.height)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (filteredStreamSources.isEmpty()) { if (filteredStreamSources.isEmpty()) {

View File

@ -50,8 +50,8 @@ public class HlsStreamSourceProvider implements StreamSourceProvider {
src.width = playlist.getStreamInfo().getResolution().width; src.width = playlist.getStreamInfo().getResolution().width;
src.height = playlist.getStreamInfo().getResolution().height; src.height = playlist.getStreamInfo().getResolution().height;
} else { } else {
src.width = Integer.MAX_VALUE; src.width = StreamSource.UNKNOWN;
src.height = Integer.MAX_VALUE; src.height = StreamSource.UNKNOWN;
} }
String masterUrl = streamUrl; String masterUrl = streamUrl;
String baseUrl = masterUrl.substring(0, masterUrl.lastIndexOf('/') + 1); String baseUrl = masterUrl.substring(0, masterUrl.lastIndexOf('/') + 1);