Skip to content
Draft
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
110 changes: 80 additions & 30 deletions app/src/main/java/com/limelight/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,62 @@ public interface GameMenuCallbacks {
private static final int UTF8_CHUNK_SIZE = 512;
private final Queue<String> commitTextQueue = new ArrayDeque<>();
private final Handler commitTextHandler = new Handler(Looper.getMainLooper());

static boolean displaySupportsHdr10(Display.HdrCapabilities hdrCapabilities) {
if (hdrCapabilities == null) {
return false;
}

for (int hdrType : hdrCapabilities.getSupportedHdrTypes()) {
if (hdrType == Display.HdrCapabilities.HDR_TYPE_HDR10) {
return true;
}
}

return false;
}

static boolean shouldRequestHdrStream(boolean prefEnableHdr,
boolean onExternalDisplay,
int sdkInt,
boolean displaySupportsHdr10) {
if (!prefEnableHdr) {
return false;
}

if (onExternalDisplay) {
return true;
}

if (sdkInt < Build.VERSION_CODES.N) {
return false;
}

if (displaySupportsHdr10) {
return true;
}

// Explicit HDR opt-in still requests a 10-bit stream on SDR panels.
return true;
}

static boolean shouldShowSdr10BitOptInToast(boolean prefEnableHdr,
boolean onExternalDisplay,
int sdkInt,
boolean displaySupportsHdr10) {
return prefEnableHdr &&
!onExternalDisplay &&
sdkInt >= Build.VERSION_CODES.N &&
!displaySupportsHdr10;
}

static boolean shouldShowHdrRequiresAndroidNToast(boolean prefEnableHdr,
boolean onExternalDisplay,
int sdkInt) {
return prefEnableHdr &&
!onExternalDisplay &&
sdkInt < Build.VERSION_CODES.N;
}

private final Runnable flushCommitTextQueue = new Runnable() {
@Override
Expand Down Expand Up @@ -598,36 +654,30 @@ public boolean onCapturedPointer(View view, MotionEvent motionEvent) {
MediaCodecHelper.initialize(this, glPrefs.glRenderer);

// Check if the user has enabled HDR
boolean willStreamHdr = false;
if (prefConfig.enableHdr) {
if (onExternelDisplay) {
// Enforce HDR on unsupported hardware can still enable 10bit streaming for better quality
willStreamHdr = true;
} else {
// Start our HDR checklist
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Display.HdrCapabilities hdrCaps = currentDisplay.getHdrCapabilities();

// We must now ensure our display is compatible with HDR10
if (hdrCaps != null) {
// getHdrCapabilities() returns null on Lenovo Lenovo Mirage Solo (vega), Android 8.0
for (int hdrType : hdrCaps.getSupportedHdrTypes()) {
if (hdrType == Display.HdrCapabilities.HDR_TYPE_HDR10) {
willStreamHdr = true;
break;
}
}
}
boolean displaySupportsHdr10 = false;
if (!onExternelDisplay && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
displaySupportsHdr10 = displaySupportsHdr10(currentDisplay.getHdrCapabilities());
}
boolean willStreamHdr = shouldRequestHdrStream(
prefConfig.enableHdr,
onExternelDisplay,
Build.VERSION.SDK_INT,
displaySupportsHdr10
);

if (!willStreamHdr) {
// Nope, no HDR for us :(
Toast.makeText(this, "Display does not support HDR10", Toast.LENGTH_LONG).show();
}
}
else {
Toast.makeText(this, "HDR requires Android 7.0 or later", Toast.LENGTH_LONG).show();
}
}
if (shouldShowSdr10BitOptInToast(
prefConfig.enableHdr,
onExternelDisplay,
Build.VERSION.SDK_INT,
displaySupportsHdr10
)) {
Toast.makeText(this, "Display does not support HDR10. Artemis will request a 10-bit SDR stream.", Toast.LENGTH_LONG).show();
} else if (shouldShowHdrRequiresAndroidNToast(
prefConfig.enableHdr,
onExternelDisplay,
Build.VERSION.SDK_INT
)) {
Toast.makeText(this, "HDR requires Android 7.0 or later", Toast.LENGTH_LONG).show();
}

// Check if the user has enabled performance stats overlay
Expand Down Expand Up @@ -4346,4 +4396,4 @@ private SurfaceView findFirstSurfaceViewFrom(View v) {
return null;
}

}
}
25 changes: 13 additions & 12 deletions app/src/main/java/com/limelight/preferences/StreamSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,8 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
}
});

// Remove HDR preference for devices below Nougat
// Remove HDR preference for devices below Nougat.
// On SDR handheld panels running Android N+, we still expose this toggle
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
LimeLog.info("Excluding HDR toggle based on OS");
PreferenceCategory category =
Expand All @@ -650,21 +651,21 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
}
}
}
PreferenceCategory category =
(PreferenceCategory) findPreference("category_video_settings");
CheckBoxPreference hdrPref = (CheckBoxPreference) category.findPreference("checkbox_enable_hdr");

if (!foundHdr10) {
LimeLog.info("Excluding HDR toggle based on display capabilities");
PreferenceCategory category =
(PreferenceCategory) findPreference("category_video_settings");
category.removePreference(findPreference("checkbox_enable_hdr"));
if (!foundHdr10 && hdrPref != null) {
LimeLog.info("Keeping HDR toggle visible for 10-bit SDR opt-in");
hdrPref.setSummary(R.string.summary_enable_hdr_sdr_10bit);
}
else if (PreferenceConfiguration.isShieldAtvFirmwareWithBrokenHdr()) {
LimeLog.info("Disabling HDR toggle on old broken SHIELD TV firmware");
PreferenceCategory category =
(PreferenceCategory) findPreference("category_video_settings");
CheckBoxPreference hdrPref = (CheckBoxPreference) category.findPreference("checkbox_enable_hdr");
hdrPref.setEnabled(false);
hdrPref.setChecked(false);
hdrPref.setSummary("Update the firmware on your NVIDIA SHIELD Android TV to enable HDR");
if (hdrPref != null) {
hdrPref.setEnabled(false);
hdrPref.setChecked(false);
hdrPref.setSummary("Update the firmware on your NVIDIA SHIELD Android TV to enable HDR");
}
}
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@
<string name="summary_video_format">Newer codecs can lower video bandwidth requirements if your device supports them. Codec selections may be ignored if not supported by the host software or GPU.</string>
<string name="title_enable_hdr">Enable HDR (Experimental)</string>
<string name="summary_enable_hdr">Stream HDR when the game and PC GPU support it. HDR requires a GPU with HEVC Main 10 encoding support.</string>
<string name="summary_enable_hdr_sdr_10bit">Request a 10-bit stream even on SDR displays. On Devices with SDR panels Artemis will prefer a 10-bit SDR stream when the host supports Main10.</string>
<string name="title_full_range">Force full range video (Experimental)</string>
<string name="summary_full_range">This will cause loss of detail in light and dark areas if your device doesn\'t properly display full range video content.</string>
<string name="title_prevent_packet_loss">Prevent Packet Loss</string>
Expand Down