Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve codec info #2893

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [Niels van Velzen](https://github.com/nielsvanvelzen)
- [GodTamIt](https://github.com/GodTamIt)
- [sparky3387](https://github.com/sparky3387)
- [mohd-akram](https://github.com/mohd-akram)

# Emby Contributors

Expand Down
47 changes: 36 additions & 11 deletions app/src/main/java/org/jellyfin/androidtv/util/InfoLayoutHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,17 +335,23 @@ private static void addRatingAndRes(Context context, BaseItemDto item, int media
addSpacer(context, layout, " ");
}

if (Utils.isTrue(item.getHasSubtitles())) {
addBlockText(context, layout, "CC");
addSpacer(context, layout, " ");
}

MediaStream videoStream = StreamHelper.getFirstVideoStream(item, mediaSourceIndex);

if (videoStream != null && videoStream.getWidth() != null && videoStream.getHeight() != null) {
int width = videoStream.getWidth();
int height = videoStream.getHeight();
Boolean isInterlaced = videoStream.isInterlaced();
if (width <= 960 && height <= 576) {
addBlockText(context, layout, context.getString(R.string.lbl_sd));
} else if (width <= 1280 && height <= 962) {
addBlockText(context, layout, "720");
addBlockText(context, layout, "720" + (isInterlaced == null || !isInterlaced ? "p" : "i"));
} else if (width <= 1920 && height <= 1440) {
addBlockText(context, layout, "1080");
addBlockText(context, layout, "1080" + (isInterlaced == null || !isInterlaced ? "p" : "i"));
} else if (width <= 4096 && height <= 3072) {
addBlockText(context, layout, "4K");
} else {
Expand All @@ -356,11 +362,6 @@ private static void addRatingAndRes(Context context, BaseItemDto item, int media

addVideoCodecDetails(context, layout, videoStream);
}
if (Utils.isTrue(item.getHasSubtitles())) {
addBlockText(context, layout, "CC");
addSpacer(context, layout, " ");

}
}

private static void addSeriesStatus(Context context, BaseItemDto item, LinearLayout layout) {
Expand All @@ -374,7 +375,13 @@ private static void addSeriesStatus(Context context, BaseItemDto item, LinearLay

private static void addVideoCodecDetails(Context context, LinearLayout layout, MediaStream stream) {
if (stream != null) {
if (stream.getCodec() != null && stream.getCodec().trim().length() > 0) {
if (stream.getVideoDoViTitle() != null && stream.getVideoDoViTitle().trim().length() > 0) {
addBlockText(context, layout, "VISION");
addSpacer(context, layout, " ");
} else if (stream.getVideoRangeType() != null && !stream.getVideoRangeType().equals("SDR")) {
addBlockText(context, layout, stream.getVideoRangeType().toUpperCase());

Check warning

Code scanning / Android Lint

Implied default locale in case conversion

Implicitly using the default locale is a common source of bugs: Use toUpperCase(Locale) instead. For strings meant to be internal use Locale.ROOT, otherwise Locale.getDefault().
addSpacer(context, layout, " ");
} else if (stream.getCodec() != null && stream.getCodec().trim().length() > 0) {
String codec = stream.getCodec().toUpperCase();
addBlockText(context, layout, codec);
addSpacer(context, layout, " ");
Expand All @@ -385,10 +392,28 @@ private static void addVideoCodecDetails(Context context, LinearLayout layout, M
private static void addMediaDetails(Context context, MediaStream stream, LinearLayout layout) {

if (stream != null) {
if (stream.getCodec() != null && stream.getCodec().trim().length() > 0) {
String codec = stream.getCodec().equals("dca") || stream.getCodec().equals("DCA") ? "DTS" : stream.getCodec().equals("ac3") || stream.getCodec().equals("AC3") ? "Dolby" : stream.getCodec().toUpperCase();
addBlockText(context, layout, codec);
if (stream.getProfile() != null && stream.getProfile().contains("Dolby Atmos")) {
addBlockText(context, layout, "ATMOS");
addSpacer(context, layout, " ");
} else if (stream.getProfile() != null && stream.getProfile().contains("DTS:X")) {
addBlockText(context, layout, "DTS:X");
addSpacer(context, layout, " ");
} else {
String codec = null;
if (stream.getProfile() != null && stream.getProfile().contains("DTS-HD")) {
codec = "DTS-HD";
} else if (stream.getCodec() != null && stream.getCodec().trim().length() > 0) {
switch (stream.getCodec().toLowerCase()) {

Check warning

Code scanning / Android Lint

Implied default locale in case conversion

Implicitly using the default locale is a common source of bugs: Use toLowerCase(Locale) instead. For strings meant to be internal use Locale.ROOT, otherwise Locale.getDefault().
case "dca": codec = "DTS"; break;
case "eac3": codec = "DD+"; break;
case "ac3": codec = "DD"; break;
default: codec = stream.getCodec().toUpperCase();

Check warning

Code scanning / Android Lint

Implied default locale in case conversion

Implicitly using the default locale is a common source of bugs: Use toUpperCase(Locale) instead. For strings meant to be internal use Locale.ROOT, otherwise Locale.getDefault().
}
}
if (codec != null) {
addBlockText(context, layout, codec);
addSpacer(context, layout, " ");
}
}
if (stream.getChannelLayout() != null && stream.getChannelLayout().trim().length() > 0) {
addBlockText(context, layout, stream.getChannelLayout().toUpperCase());
Expand Down