diff --git a/app/src/main/java/free/rm/skytube/app/StreamSelectionPolicy.java b/app/src/main/java/free/rm/skytube/app/StreamSelectionPolicy.java index fc95ada53d..2af1710513 100644 --- a/app/src/main/java/free/rm/skytube/app/StreamSelectionPolicy.java +++ b/app/src/main/java/free/rm/skytube/app/StreamSelectionPolicy.java @@ -58,7 +58,7 @@ public StreamSelectionPolicy withAllowVideoOnly(boolean newValue) { public StreamSelection select(StreamInfo streamInfo) { VideoStreamWithResolution videoStreamWithResolution = pickVideo(streamInfo); if (videoStreamWithResolution != null) { - if (videoStreamWithResolution.videoStream.isVideoOnly) { + if (videoStreamWithResolution.videoStream.isVideoOnly()) { AudioStream audioStream = pickAudio(streamInfo); if (audioStream != null) { return new StreamSelection(videoStreamWithResolution.videoStream, videoStreamWithResolution.resolution, audioStream); @@ -119,7 +119,7 @@ private AudioStream pickAudio(StreamInfo streamInfo) { } private static String toHumanReadable(AudioStream as) { - return as != null ? "AudioStream(" + as.getAverageBitrate() + ", " + as.getFormat() + ", codec=" + as.getCodec() + ", q=" + as.getQuality() + ", isUrl=" + as.isUrl() + ")" : "NULL"; + return as != null ? "AudioStream(" + as.getAverageBitrate() + ", " + as.getFormat() + ", codec=" + as.getCodec() + ", q=" + as.getQuality() + ", isUrl=" + as.isUrl() + ",delivery=" + as.getDeliveryMethod() + ")" : "NULL"; } private boolean isBetter(AudioStream best, AudioStream other) { @@ -226,7 +226,13 @@ boolean isLessNetworkUsageThan(VideoStreamWithResolution other) { } private String toHumanReadable() { - return "VideoStream(" + resolution.name() + ", format=" + videoStream.getFormat() + ", codec=" + videoStream.getCodec() + ", quality=" + videoStream.getQuality() + ",videoOnly=" + videoStream.isVideoOnly() + ",isUrl=" + videoStream.isUrl() + ")"; + return "VideoStream(" + resolution.name() + + ", format=" + videoStream.getFormat() + + ", codec=" + videoStream.getCodec() + + ", quality=" + videoStream.getQuality() + + ",videoOnly=" + videoStream.isVideoOnly() + + ",isUrl=" + videoStream.isUrl() + + ",delivery=" + videoStream.getDeliveryMethod() + ")"; } private static String toHumanReadable(VideoStreamWithResolution v) { diff --git a/app/src/test/java/free/rm/skytube/app/StreamSelectionPolicyTest.java b/app/src/test/java/free/rm/skytube/app/StreamSelectionPolicyTest.java index ee47d22960..c057d09d1a 100644 --- a/app/src/test/java/free/rm/skytube/app/StreamSelectionPolicyTest.java +++ b/app/src/test/java/free/rm/skytube/app/StreamSelectionPolicyTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.schabi.newpipe.extractor.MediaFormat; +import org.schabi.newpipe.extractor.stream.DeliveryMethod; import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.StreamType; import org.schabi.newpipe.extractor.stream.VideoStream; @@ -76,7 +77,15 @@ private void test(StreamSelectionPolicy policy, MediaFormat expectedFormat, Medi private StreamInfo createStreams(MediaFormat... mediaFormats) { List streams = new ArrayList<>(); for (MediaFormat mediaFormat : mediaFormats) { - streams.add(new VideoStream("url/" + mediaFormat, mediaFormat, "1080P")); + streams.add( + new VideoStream.Builder() + .setId("id-"+mediaFormat.hashCode()) + .setContent("url/" + mediaFormat, true) + .setMediaFormat(mediaFormat) + .setResolution("1080P") + .setDeliveryMethod(DeliveryMethod.PROGRESSIVE_HTTP) + .setIsVideoOnly(false) + .build()); } return createStreams(streams); } @@ -84,7 +93,15 @@ private StreamInfo createStreams(MediaFormat... mediaFormats) { private StreamInfo createStreams(String... resolutions) { List streams = new ArrayList<>(); for (String resolution : resolutions) { - streams.add(new VideoStream("url/" + resolution, MediaFormat.WEBM, resolution)); + streams.add( + new VideoStream.Builder() + .setId("id-"+resolution.hashCode()) + .setContent("url/" + resolution, true) + .setMediaFormat(MediaFormat.WEBM) + .setResolution(resolution) + .setIsVideoOnly(false) + .setDeliveryMethod(DeliveryMethod.DASH) + .build()); } return createStreams(streams); }