mirror of
https://github.com/yuliskov/SmartTube.git
synced 2026-01-06 05:50:31 -06:00
track selection fix
This commit is contained in:
@@ -413,6 +413,10 @@ public class TrackSelectorManager implements TrackSelectorCallback {
|
||||
result = mediaTrack;
|
||||
}
|
||||
}
|
||||
|
||||
if (result.format != null && TrackSelectorUtil.codecEquals(result.format.codecs, track.format.codecs)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,4 +119,12 @@ public class TrackSelectorUtil {
|
||||
playbackState == Player.STATE_IDLE ? "STATE_IDLE" :
|
||||
"STATE_ENDED";
|
||||
}
|
||||
|
||||
public static boolean codecEquals(String codecs1, String codecs2) {
|
||||
if (codecs1 == null || codecs2 == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Helpers.equals(TrackSelectorUtil.codecNameShort(codecs1), TrackSelectorUtil.codecNameShort(codecs2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,39 @@ public class VideoTrack extends MediaTrack {
|
||||
return track.format.frameRate == -1;
|
||||
}
|
||||
|
||||
//@Override
|
||||
//public int compare(MediaTrack track2) {
|
||||
// if (track2.format == null) {
|
||||
// return 1;
|
||||
// }
|
||||
//
|
||||
// int result = -1;
|
||||
//
|
||||
// if (Helpers.equals(format.id, track2.format.id)) {
|
||||
// result = 0;
|
||||
// } else if (codecEquals(format.codecs, track2.format.codecs)) {
|
||||
// if (fpsLessOrEquals(track2.format.frameRate, format.frameRate)) {
|
||||
// if (heightEquals(format.height, track2.format.height)) {
|
||||
// if (TrackSelectorUtil.isHdrCodec(format.codecs) == TrackSelectorUtil.isHdrCodec(track2.format.codecs)) {
|
||||
// result = 0;
|
||||
// } else {
|
||||
// result = 1;
|
||||
// }
|
||||
// } else if (heightLessOrEquals(track2.format.height, format.height)) {
|
||||
// result = 1;
|
||||
// }
|
||||
// }
|
||||
// } else if (fpsLessOrEquals(track2.format.frameRate, format.frameRate)) {
|
||||
// if (heightEquals(format.height, track2.format.height)) {
|
||||
// result = 2;
|
||||
// } else if (heightLessOrEquals(track2.format.height, format.height)) {
|
||||
// result = 2;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
//}
|
||||
|
||||
@Override
|
||||
public int compare(MediaTrack track2) {
|
||||
if (track2.format == null) {
|
||||
@@ -64,17 +97,19 @@ public class VideoTrack extends MediaTrack {
|
||||
|
||||
if (Helpers.equals(format.id, track2.format.id)) {
|
||||
result = 0;
|
||||
} else if (codecEquals(format.codecs, track2.format.codecs) || isLive(track2)) {
|
||||
if (fpsLessOrEquals(track2.format.frameRate, format.frameRate)) {
|
||||
if (heightEquals(format.height, track2.format.height)) {
|
||||
} if (fpsLessOrEquals(track2.format.frameRate, format.frameRate)) {
|
||||
if (heightEquals(format.height, track2.format.height)) {
|
||||
if (codecEquals(format.codecs, track2.format.codecs)) {
|
||||
if (TrackSelectorUtil.isHdrCodec(format.codecs) == TrackSelectorUtil.isHdrCodec(track2.format.codecs)) {
|
||||
result = 0;
|
||||
} else {
|
||||
result = 1;
|
||||
}
|
||||
} else if (heightLessOrEquals(track2.format.height, format.height)) {
|
||||
} else {
|
||||
result = 1;
|
||||
}
|
||||
} else if (heightLessOrEquals(track2.format.height, format.height)) {
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user