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
* 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
========================

View File

@ -4,6 +4,7 @@ import java.text.DecimalFormat;
public class StreamSource implements Comparable<StreamSource> {
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<StreamSource> {
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<StreamSource> {
@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;

View File

@ -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<StreamSource> 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()) {

View File

@ -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);