Skip to content

Commit

Permalink
Fix test case, more debug msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
gzsombor committed Aug 13, 2022
1 parent e47cb85 commit 94f77fa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
12 changes: 9 additions & 3 deletions app/src/main/java/free/rm/skytube/app/StreamSelectionPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,15 +77,31 @@ private void test(StreamSelectionPolicy policy, MediaFormat expectedFormat, Medi
private StreamInfo createStreams(MediaFormat... mediaFormats) {
List<VideoStream> 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);
}

private StreamInfo createStreams(String... resolutions) {
List<VideoStream> 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);
}
Expand Down

0 comments on commit 94f77fa

Please sign in to comment.