Skip to content

Commit

Permalink
Improve codec info
Browse files Browse the repository at this point in the history
  • Loading branch information
mohd-akram authored and nielsvanvelzen committed Jul 18, 2023
1 parent 4cb8b58 commit c69df82
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
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());
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()) {
case "dca": codec = "DTS"; break;
case "eac3": codec = "DD+"; break;
case "ac3": codec = "DD"; break;
default: codec = stream.getCodec().toUpperCase();
}
}
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

0 comments on commit c69df82

Please sign in to comment.