Compare commits
58 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b37a2dea57 | |||
| 5c865e7f36 | |||
| 04d9aea8c8 | |||
| b6f52db9c3 | |||
| 99d2e40683 | |||
| 02c4ed2724 | |||
| 5f4aab8f94 | |||
| ec65901003 | |||
| 915acee88d | |||
| 300d444f71 | |||
| f37ab40c2f | |||
| 16e285d926 | |||
| f2d122a275 | |||
| bfa5a6349e | |||
| a56689aea3 | |||
| 3a5ba820cb | |||
| ec69fef36f | |||
| ff38074f55 | |||
| 85d0ce0c40 | |||
| 777129ca90 | |||
| 06156c4d68 | |||
| 1c725b9dac | |||
| f761ee52db | |||
| 05e8cfcc0a | |||
| 912925ef2c | |||
| 4deb881ec8 | |||
| f55d6308ce | |||
| 44a3a141c0 | |||
| 37b5ba004c | |||
| b774b47213 | |||
| 74dc00445e | |||
| 3b4563d5ea | |||
| 38669817b4 | |||
| 8f1d3ae04e | |||
| 74ed95871b | |||
| cc5d67616c | |||
| eed7f09e6f | |||
| e3c1d23744 | |||
| c4b1200b43 | |||
| dff09f33a3 | |||
| 1f6b1dc2fe | |||
| 3f118dae93 | |||
| 91a30ff6fe | |||
| 5102669b06 | |||
| 2e2f09be00 | |||
| c402103fe3 | |||
| 5e5df8abc8 | |||
| d125eb7b16 | |||
| a116858493 | |||
| 5f3b333e98 | |||
| 80a37855c7 | |||
| 5db1ec8ec0 | |||
| 8911c58e50 | |||
| 780a64694d | |||
| 3c5ea9c8c3 | |||
| 40d1436ce3 | |||
| dbb02acd37 | |||
| 20c4eac4ef |
+8
-13
@@ -4,15 +4,15 @@ import org.apache.tools.ant.taskdefs.condition.Os
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 26
|
compileSdkVersion 27
|
||||||
buildToolsVersion '26.0.1'
|
buildToolsVersion '27.0.1'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 26
|
targetSdkVersion 27
|
||||||
|
|
||||||
versionName "5.2"
|
versionName "5.6"
|
||||||
versionCode = 131
|
versionCode = 138
|
||||||
}
|
}
|
||||||
|
|
||||||
flavorDimensions "root"
|
flavorDimensions "root"
|
||||||
@@ -24,19 +24,11 @@ android {
|
|||||||
maxSdkVersion 25
|
maxSdkVersion 25
|
||||||
|
|
||||||
applicationId "com.limelight.root"
|
applicationId "com.limelight.root"
|
||||||
ndk {
|
|
||||||
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64", "mips", "mips64"
|
|
||||||
}
|
|
||||||
|
|
||||||
dimension "root"
|
dimension "root"
|
||||||
}
|
}
|
||||||
|
|
||||||
nonRoot {
|
nonRoot {
|
||||||
applicationId "com.limelight"
|
applicationId "com.limelight"
|
||||||
ndk {
|
|
||||||
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64", "mips", "mips64"
|
|
||||||
}
|
|
||||||
|
|
||||||
dimension "root"
|
dimension "root"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,6 +38,9 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
applicationIdSuffix ".debug"
|
||||||
|
}
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt')
|
proguardFiles getDefaultProguardFile('proguard-android.txt')
|
||||||
|
|||||||
@@ -103,7 +103,10 @@
|
|||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"
|
||||||
android:screenOrientation="sensorLandscape"
|
android:screenOrientation="sensorLandscape"
|
||||||
android:noHistory="true"
|
android:noHistory="true"
|
||||||
|
android:supportsPictureInPicture="true"
|
||||||
android:resizeableActivity="true"
|
android:resizeableActivity="true"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
android:theme="@style/StreamTheme">
|
android:theme="@style/StreamTheme">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
|||||||
@@ -235,6 +235,10 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// Assume we're in the foreground when created to avoid a race
|
||||||
|
// between binding to CMS and onResume()
|
||||||
|
inForeground = true;
|
||||||
|
|
||||||
shortcutHelper = new ShortcutHelper(this);
|
shortcutHelper = new ShortcutHelper(this);
|
||||||
|
|
||||||
UiHelper.setLocale(this);
|
UiHelper.setLocale(this);
|
||||||
@@ -300,6 +304,9 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
// Display a decoder crash notification if we've returned after a crash
|
||||||
|
UiHelper.showDecoderCrashDialog(this);
|
||||||
|
|
||||||
inForeground = true;
|
inForeground = true;
|
||||||
startComputerUpdates();
|
startComputerUpdates();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class AppViewShortcutTrampoline extends Activity {
|
|||||||
// If a game is running, we'll make the stream the top level activity
|
// If a game is running, we'll make the stream the top level activity
|
||||||
if (details.runningGameId != 0) {
|
if (details.runningGameId != 0) {
|
||||||
intentStack.add(ServerHelper.createStartIntent(AppViewShortcutTrampoline.this,
|
intentStack.add(ServerHelper.createStartIntent(AppViewShortcutTrampoline.this,
|
||||||
new NvApp("app", details.runningGameId), details, managerBinder));
|
new NvApp("app", details.runningGameId, false), details, managerBinder));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now start the activities
|
// Now start the activities
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.limelight.nvstream.http.NvApp;
|
|||||||
import com.limelight.nvstream.input.KeyboardPacket;
|
import com.limelight.nvstream.input.KeyboardPacket;
|
||||||
import com.limelight.nvstream.input.MouseButtonPacket;
|
import com.limelight.nvstream.input.MouseButtonPacket;
|
||||||
import com.limelight.nvstream.jni.MoonBridge;
|
import com.limelight.nvstream.jni.MoonBridge;
|
||||||
|
import com.limelight.preferences.GlPreferences;
|
||||||
import com.limelight.preferences.PreferenceConfiguration;
|
import com.limelight.preferences.PreferenceConfiguration;
|
||||||
import com.limelight.ui.GameGestures;
|
import com.limelight.ui.GameGestures;
|
||||||
import com.limelight.ui.StreamView;
|
import com.limelight.ui.StreamView;
|
||||||
@@ -29,7 +30,9 @@ import com.limelight.utils.SpinnerDialog;
|
|||||||
import com.limelight.utils.UiHelper;
|
import com.limelight.utils.UiHelper;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.PictureInPictureParams;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -37,6 +40,7 @@ import android.content.Intent;
|
|||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.hardware.input.InputManager;
|
import android.hardware.input.InputManager;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
@@ -46,6 +50,7 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.util.Rational;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.InputDevice;
|
import android.view.InputDevice;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -100,6 +105,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
private ShortcutHelper shortcutHelper;
|
private ShortcutHelper shortcutHelper;
|
||||||
|
|
||||||
private MediaCodecDecoderRenderer decoderRenderer;
|
private MediaCodecDecoderRenderer decoderRenderer;
|
||||||
|
private boolean reportedCrash;
|
||||||
|
|
||||||
private WifiManager.WifiLock wifiLock;
|
private WifiManager.WifiLock wifiLock;
|
||||||
|
|
||||||
@@ -125,13 +131,12 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
public static final String EXTRA_STREAMING_REMOTE = "Remote";
|
public static final String EXTRA_STREAMING_REMOTE = "Remote";
|
||||||
public static final String EXTRA_PC_UUID = "UUID";
|
public static final String EXTRA_PC_UUID = "UUID";
|
||||||
public static final String EXTRA_PC_NAME = "PcName";
|
public static final String EXTRA_PC_NAME = "PcName";
|
||||||
|
public static final String EXTRA_APP_HDR = "HDR";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
shortcutHelper = new ShortcutHelper(this);
|
|
||||||
|
|
||||||
UiHelper.setLocale(this);
|
UiHelper.setLocale(this);
|
||||||
|
|
||||||
// We don't want a title bar
|
// We don't want a title bar
|
||||||
@@ -191,7 +196,10 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Warn the user if they're on a metered connection
|
// Warn the user if they're on a metered connection
|
||||||
checkDataConnection();
|
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
if (connMgr.isActiveNetworkMetered()) {
|
||||||
|
displayTransientMessage(getResources().getString(R.string.conn_metered));
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure Wi-Fi is fully powered up
|
// Make sure Wi-Fi is fully powered up
|
||||||
WifiManager wifiMgr = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
WifiManager wifiMgr = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||||
@@ -206,6 +214,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
boolean remote = Game.this.getIntent().getBooleanExtra(EXTRA_STREAMING_REMOTE, false);
|
boolean remote = Game.this.getIntent().getBooleanExtra(EXTRA_STREAMING_REMOTE, false);
|
||||||
String uuid = Game.this.getIntent().getStringExtra(EXTRA_PC_UUID);
|
String uuid = Game.this.getIntent().getStringExtra(EXTRA_PC_UUID);
|
||||||
String pcName = Game.this.getIntent().getStringExtra(EXTRA_PC_NAME);
|
String pcName = Game.this.getIntent().getStringExtra(EXTRA_PC_NAME);
|
||||||
|
boolean willStreamHdr = Game.this.getIntent().getBooleanExtra(EXTRA_APP_HDR, false);
|
||||||
|
|
||||||
if (appId == StreamConfiguration.INVALID_APP_ID) {
|
if (appId == StreamConfiguration.INVALID_APP_ID) {
|
||||||
finish();
|
finish();
|
||||||
@@ -213,15 +222,51 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add a launcher shortcut for this PC (forced, since this is user interaction)
|
// Add a launcher shortcut for this PC (forced, since this is user interaction)
|
||||||
|
shortcutHelper = new ShortcutHelper(this);
|
||||||
shortcutHelper.createAppViewShortcut(uuid, pcName, uuid, true);
|
shortcutHelper.createAppViewShortcut(uuid, pcName, uuid, true);
|
||||||
shortcutHelper.reportShortcutUsed(uuid);
|
shortcutHelper.reportShortcutUsed(uuid);
|
||||||
|
|
||||||
// Initialize the MediaCodec helper before creating the decoder
|
// Initialize the MediaCodec helper before creating the decoder
|
||||||
MediaCodecHelper.initializeWithContext(this);
|
GlPreferences glPrefs = GlPreferences.readPreferences(this);
|
||||||
|
MediaCodecHelper.initialize(this, glPrefs.glRenderer);
|
||||||
|
|
||||||
decoderRenderer = new MediaCodecDecoderRenderer(prefConfig.videoFormat,
|
// Check if the user has enabled HDR
|
||||||
prefConfig.bitrate,
|
if (prefConfig.enableHdr) {
|
||||||
prefConfig.batterySaver,
|
// Check if the app supports it
|
||||||
|
if (!willStreamHdr) {
|
||||||
|
Toast.makeText(this, "This game does not support HDR10", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
// It does, so start our HDR checklist
|
||||||
|
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
// We already know the app supports HDR if willStreamHdr is set.
|
||||||
|
Display display = getWindowManager().getDefaultDisplay();
|
||||||
|
Display.HdrCapabilities hdrCaps = display.getHdrCapabilities();
|
||||||
|
|
||||||
|
// We must now ensure our display is compatible with HDR10
|
||||||
|
boolean foundHdr10 = false;
|
||||||
|
for (int hdrType : hdrCaps.getSupportedHdrTypes()) {
|
||||||
|
if (hdrType == Display.HdrCapabilities.HDR_TYPE_HDR10) {
|
||||||
|
LimeLog.info("Display supports HDR10");
|
||||||
|
foundHdr10 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundHdr10) {
|
||||||
|
// Nope, no HDR for us :(
|
||||||
|
willStreamHdr = false;
|
||||||
|
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();
|
||||||
|
willStreamHdr = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
willStreamHdr = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
decoderRenderer = new MediaCodecDecoderRenderer(prefConfig,
|
||||||
new CrashListener() {
|
new CrashListener() {
|
||||||
@Override
|
@Override
|
||||||
public void notifyCrash(Exception e) {
|
public void notifyCrash(Exception e) {
|
||||||
@@ -230,37 +275,38 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
|
|
||||||
// We must use commit because the app will crash when we return from this function
|
// We must use commit because the app will crash when we return from this function
|
||||||
tombstonePrefs.edit().putInt("CrashCount", tombstonePrefs.getInt("CrashCount", 0) + 1).commit();
|
tombstonePrefs.edit().putInt("CrashCount", tombstonePrefs.getInt("CrashCount", 0) + 1).commit();
|
||||||
|
reportedCrash = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tombstonePrefs.getInt("CrashCount", 0));
|
tombstonePrefs.getInt("CrashCount", 0),
|
||||||
|
connMgr.isActiveNetworkMetered(),
|
||||||
|
willStreamHdr,
|
||||||
|
glPrefs.glRenderer
|
||||||
|
);
|
||||||
|
|
||||||
|
// Don't stream HDR if the decoder can't support it
|
||||||
|
if (willStreamHdr && !decoderRenderer.isHevcMain10Hdr10Supported()) {
|
||||||
|
willStreamHdr = false;
|
||||||
|
Toast.makeText(this, "Decoder does not support HEVC Main10HDR10", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
// Display a message to the user if H.265 was forced on but we still didn't find a decoder
|
// Display a message to the user if H.265 was forced on but we still didn't find a decoder
|
||||||
if (prefConfig.videoFormat == PreferenceConfiguration.FORCE_H265_ON && !decoderRenderer.isHevcSupported()) {
|
if (prefConfig.videoFormat == PreferenceConfiguration.FORCE_H265_ON && !decoderRenderer.isHevcSupported()) {
|
||||||
Toast.makeText(this, "No H.265 decoder found.\nFalling back to H.264.", Toast.LENGTH_LONG).show();
|
Toast.makeText(this, "No H.265 decoder found.\nFalling back to H.264.", Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!decoderRenderer.isAvcSupported()) {
|
|
||||||
if (spinner != null) {
|
|
||||||
spinner.dismiss();
|
|
||||||
spinner = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we can't find an AVC decoder, we can't proceed
|
|
||||||
Dialog.displayDialog(this, getResources().getString(R.string.conn_error_title),
|
|
||||||
"This device or ROM doesn't support hardware accelerated H.264 playback.", true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
StreamConfiguration config = new StreamConfiguration.Builder()
|
StreamConfiguration config = new StreamConfiguration.Builder()
|
||||||
.setResolution(prefConfig.width, prefConfig.height)
|
.setResolution(prefConfig.width, prefConfig.height)
|
||||||
.setRefreshRate(prefConfig.fps)
|
.setRefreshRate(prefConfig.fps)
|
||||||
.setApp(new NvApp(appName, appId))
|
.setApp(new NvApp(appName, appId, willStreamHdr))
|
||||||
.setBitrate(prefConfig.bitrate * 1000)
|
.setBitrate(prefConfig.bitrate * 1000)
|
||||||
.setEnableSops(prefConfig.enableSops)
|
.setEnableSops(prefConfig.enableSops)
|
||||||
.enableLocalAudioPlayback(prefConfig.playHostAudio)
|
.enableLocalAudioPlayback(prefConfig.playHostAudio)
|
||||||
.setMaxPacketSize(remote ? 1024 : 1292)
|
.setMaxPacketSize(remote ? 1024 : 1292)
|
||||||
.setRemote(remote)
|
.setRemote(remote)
|
||||||
|
.setHevcBitratePercentageMultiplier(75)
|
||||||
.setHevcSupported(decoderRenderer.isHevcSupported())
|
.setHevcSupported(decoderRenderer.isHevcSupported())
|
||||||
|
.setEnableHdr(willStreamHdr)
|
||||||
.setAudioConfiguration(prefConfig.enable51Surround ?
|
.setAudioConfiguration(prefConfig.enable51Surround ?
|
||||||
MoonBridge.AUDIO_CONFIGURATION_51_SURROUND :
|
MoonBridge.AUDIO_CONFIGURATION_51_SURROUND :
|
||||||
MoonBridge.AUDIO_CONFIGURATION_STEREO)
|
MoonBridge.AUDIO_CONFIGURATION_STEREO)
|
||||||
@@ -303,10 +349,39 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
usbDriverServiceConnection, Service.BIND_AUTO_CREATE);
|
usbDriverServiceConnection, Service.BIND_AUTO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!decoderRenderer.isAvcSupported()) {
|
||||||
|
if (spinner != null) {
|
||||||
|
spinner.dismiss();
|
||||||
|
spinner = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we can't find an AVC decoder, we can't proceed
|
||||||
|
Dialog.displayDialog(this, getResources().getString(R.string.conn_error_title),
|
||||||
|
"This device or ROM doesn't support hardware accelerated H.264 playback.", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// The connection will be started when the surface gets created
|
// The connection will be started when the surface gets created
|
||||||
streamView.getHolder().addCallback(this);
|
streamView.getHolder().addCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUserLeaveHint() {
|
||||||
|
super.onUserLeaveHint();
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
if (prefConfig.enablePip && connected) {
|
||||||
|
enterPictureInPictureMode(
|
||||||
|
new PictureInPictureParams.Builder()
|
||||||
|
.setAspectRatio(new Rational(prefConfig.width, prefConfig.height))
|
||||||
|
.setSourceRectHint(new Rect(
|
||||||
|
streamView.getLeft(), streamView.getTop(),
|
||||||
|
streamView.getRight(), streamView.getBottom()))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWindowFocusChanged(boolean hasFocus) {
|
public void onWindowFocusChanged(boolean hasFocus) {
|
||||||
super.onWindowFocusChanged(hasFocus);
|
super.onWindowFocusChanged(hasFocus);
|
||||||
@@ -410,20 +485,18 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkDataConnection()
|
|
||||||
{
|
|
||||||
ConnectivityManager mgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
||||||
if (mgr.isActiveNetworkMetered()) {
|
|
||||||
displayTransientMessage(getResources().getString(R.string.conn_metered));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("InlinedApi")
|
@SuppressLint("InlinedApi")
|
||||||
private final Runnable hideSystemUi = new Runnable() {
|
private final Runnable hideSystemUi = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
// In multi-window mode on N+, we need to drop our layout flags or we'll
|
||||||
|
// be drawing underneath the system UI.
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isInMultiWindowMode()) {
|
||||||
|
Game.this.getWindow().getDecorView().setSystemUiVisibility(
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
||||||
|
}
|
||||||
// Use immersive mode on 4.4+ or standard low profile on previous builds
|
// Use immersive mode on 4.4+ or standard low profile on previous builds
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
|
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
Game.this.getWindow().getDecorView().setSystemUiVisibility(
|
Game.this.getWindow().getDecorView().setSystemUiVisibility(
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
||||||
@@ -448,6 +521,34 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@TargetApi(Build.VERSION_CODES.N)
|
||||||
|
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
|
||||||
|
super.onMultiWindowModeChanged(isInMultiWindowMode);
|
||||||
|
|
||||||
|
// In multi-window, we don't want to use the full-screen layout
|
||||||
|
// flag. It will cause us to collide with the system UI.
|
||||||
|
// This function will also be called for PiP so we can cover
|
||||||
|
// that case here too.
|
||||||
|
if (isInMultiWindowMode) {
|
||||||
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
|
||||||
|
// Disable performance optimizations for foreground
|
||||||
|
getWindow().setSustainedPerformanceMode(false);
|
||||||
|
decoderRenderer.notifyVideoBackground();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
|
||||||
|
// Enable performance optimizations for foreground
|
||||||
|
getWindow().setSustainedPerformanceMode(true);
|
||||||
|
decoderRenderer.notifyVideoForeground();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Correct the system UI visibility flags
|
||||||
|
hideSystemUi(50);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@@ -496,7 +597,10 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
|
|
||||||
// Add the video codec to the post-stream toast
|
// Add the video codec to the post-stream toast
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
if (videoFormat == MoonBridge.VIDEO_FORMAT_H265) {
|
if (videoFormat == MoonBridge.VIDEO_FORMAT_H265_MAIN10) {
|
||||||
|
message += " [H.265 HDR]";
|
||||||
|
}
|
||||||
|
else if (videoFormat == MoonBridge.VIDEO_FORMAT_H265) {
|
||||||
message += " [H.265]";
|
message += " [H.265]";
|
||||||
}
|
}
|
||||||
else if (videoFormat == MoonBridge.VIDEO_FORMAT_H264) {
|
else if (videoFormat == MoonBridge.VIDEO_FORMAT_H264) {
|
||||||
@@ -508,9 +612,12 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the tombstone count
|
// Clear the tombstone count if we terminated normally
|
||||||
if (tombstonePrefs.getInt("CrashCount", 0) != 0) {
|
if (!reportedCrash && tombstonePrefs.getInt("CrashCount", 0) != 0) {
|
||||||
tombstonePrefs.edit().putInt("CrashCount", 0).apply();
|
tombstonePrefs.edit()
|
||||||
|
.putInt("CrashCount", 0)
|
||||||
|
.putInt("LastNotifiedCrashCount", 0)
|
||||||
|
.apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,19 +639,19 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Returns true if the key stroke was consumed
|
// Returns true if the key stroke was consumed
|
||||||
private boolean handleSpecialKeys(short translatedKey, boolean down) {
|
private boolean handleSpecialKeys(int androidKeyCode, boolean down) {
|
||||||
int modifierMask = 0;
|
int modifierMask = 0;
|
||||||
|
|
||||||
// Mask off the high byte
|
if (androidKeyCode == KeyEvent.KEYCODE_CTRL_LEFT ||
|
||||||
translatedKey &= 0xff;
|
androidKeyCode == KeyEvent.KEYCODE_CTRL_RIGHT) {
|
||||||
|
|
||||||
if (translatedKey == KeyboardTranslator.VK_CONTROL) {
|
|
||||||
modifierMask = KeyboardPacket.MODIFIER_CTRL;
|
modifierMask = KeyboardPacket.MODIFIER_CTRL;
|
||||||
}
|
}
|
||||||
else if (translatedKey == KeyboardTranslator.VK_SHIFT) {
|
else if (androidKeyCode == KeyEvent.KEYCODE_SHIFT_LEFT ||
|
||||||
|
androidKeyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
|
||||||
modifierMask = KeyboardPacket.MODIFIER_SHIFT;
|
modifierMask = KeyboardPacket.MODIFIER_SHIFT;
|
||||||
}
|
}
|
||||||
else if (translatedKey == KeyboardTranslator.VK_ALT) {
|
else if (androidKeyCode == KeyEvent.KEYCODE_ALT_LEFT ||
|
||||||
|
androidKeyCode == KeyEvent.KEYCODE_ALT_RIGHT) {
|
||||||
modifierMask = KeyboardPacket.MODIFIER_ALT;
|
modifierMask = KeyboardPacket.MODIFIER_ALT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,7 +663,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if Ctrl+Shift+Z is pressed
|
// Check if Ctrl+Shift+Z is pressed
|
||||||
if (translatedKey == KeyboardTranslator.VK_Z &&
|
if (androidKeyCode == KeyEvent.KEYCODE_Z &&
|
||||||
(modifierFlags & (KeyboardPacket.MODIFIER_CTRL | KeyboardPacket.MODIFIER_SHIFT)) ==
|
(modifierFlags & (KeyboardPacket.MODIFIER_CTRL | KeyboardPacket.MODIFIER_SHIFT)) ==
|
||||||
(KeyboardPacket.MODIFIER_CTRL | KeyboardPacket.MODIFIER_SHIFT))
|
(KeyboardPacket.MODIFIER_CTRL | KeyboardPacket.MODIFIER_SHIFT))
|
||||||
{
|
{
|
||||||
@@ -637,7 +744,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Let this method take duplicate key down events
|
// Let this method take duplicate key down events
|
||||||
if (handleSpecialKeys(translated, true)) {
|
if (handleSpecialKeys(keyCode, true)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,7 +753,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.sendKeyboardInput(translated, KeyboardPacket.KEY_DOWN, getModifierState());
|
conn.sendKeyboardInput(translated, KeyboardPacket.KEY_DOWN, getModifierState(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -677,7 +784,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
return super.onKeyUp(keyCode, event);
|
return super.onKeyUp(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handleSpecialKeys(translated, false)) {
|
if (handleSpecialKeys(keyCode, false)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -947,7 +1054,17 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
private void stopConnection() {
|
private void stopConnection() {
|
||||||
if (connecting || connected) {
|
if (connecting || connected) {
|
||||||
connecting = connected = false;
|
connecting = connected = false;
|
||||||
conn.stop();
|
|
||||||
|
// Stop may take a few hundred ms to do some network I/O to tell
|
||||||
|
// the server we're going away and clean up. Let it run in a separate
|
||||||
|
// thread to keep things smooth for the UI. Inside moonlight-common,
|
||||||
|
// we prevent another thread from starting a connection before and
|
||||||
|
// during the process of stopping this one.
|
||||||
|
new Thread() {
|
||||||
|
public void run() {
|
||||||
|
conn.stop();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1106,7 +1223,8 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
public void keyboardEvent(boolean buttonDown, short keyCode) {
|
public void keyboardEvent(boolean buttonDown, short keyCode) {
|
||||||
short keyMap = KeyboardTranslator.translate(keyCode);
|
short keyMap = KeyboardTranslator.translate(keyCode);
|
||||||
if (keyMap != 0) {
|
if (keyMap != 0) {
|
||||||
if (handleSpecialKeys(keyMap, buttonDown)) {
|
// handleSpecialKeys() takes the Android keycode
|
||||||
|
if (handleSpecialKeys(keyCode, buttonDown)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import com.limelight.nvstream.http.PairingManager;
|
|||||||
import com.limelight.nvstream.http.PairingManager.PairState;
|
import com.limelight.nvstream.http.PairingManager.PairState;
|
||||||
import com.limelight.nvstream.wol.WakeOnLanSender;
|
import com.limelight.nvstream.wol.WakeOnLanSender;
|
||||||
import com.limelight.preferences.AddComputerManually;
|
import com.limelight.preferences.AddComputerManually;
|
||||||
|
import com.limelight.preferences.GlPreferences;
|
||||||
import com.limelight.preferences.PreferenceConfiguration;
|
import com.limelight.preferences.PreferenceConfiguration;
|
||||||
import com.limelight.preferences.StreamSettings;
|
import com.limelight.preferences.StreamSettings;
|
||||||
import com.limelight.ui.AdapterFragment;
|
import com.limelight.ui.AdapterFragment;
|
||||||
@@ -31,8 +32,9 @@ import android.app.Service;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.opengl.GLSurfaceView;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
@@ -50,12 +52,15 @@ import android.widget.RelativeLayout;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||||
|
|
||||||
|
import javax.microedition.khronos.egl.EGLConfig;
|
||||||
|
import javax.microedition.khronos.opengles.GL10;
|
||||||
|
|
||||||
public class PcView extends Activity implements AdapterFragmentCallbacks {
|
public class PcView extends Activity implements AdapterFragmentCallbacks {
|
||||||
private RelativeLayout noPcFoundLayout;
|
private RelativeLayout noPcFoundLayout;
|
||||||
private PcGridAdapter pcGridAdapter;
|
private PcGridAdapter pcGridAdapter;
|
||||||
private ShortcutHelper shortcutHelper;
|
private ShortcutHelper shortcutHelper;
|
||||||
private ComputerManagerService.ComputerManagerBinder managerBinder;
|
private ComputerManagerService.ComputerManagerBinder managerBinder;
|
||||||
private boolean freezeUpdates, runningPolling, inForeground;
|
private boolean freezeUpdates, runningPolling, inForeground, completeOnCreateCalled;
|
||||||
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
||||||
public void onServiceConnected(ComponentName className, IBinder binder) {
|
public void onServiceConnected(ComponentName className, IBinder binder) {
|
||||||
final ComputerManagerService.ComputerManagerBinder localBinder =
|
final ComputerManagerService.ComputerManagerBinder localBinder =
|
||||||
@@ -85,11 +90,19 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
|
|
||||||
// Reinitialize views just in case orientation changed
|
// Only reinitialize views if completeOnCreate() was called
|
||||||
initializeViews();
|
// before this callback. If it was not, completeOnCreate() will
|
||||||
|
// handle initializing views with the config change accounted for.
|
||||||
|
// This is not prone to races because both callbacks are invoked
|
||||||
|
// in the main thread.
|
||||||
|
if (completeOnCreateCalled) {
|
||||||
|
// Reinitialize views just in case orientation changed
|
||||||
|
initializeViews();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static int APP_LIST_ID = 1;
|
private final static int APP_LIST_ID = 1;
|
||||||
@@ -151,6 +164,52 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// Assume we're in the foreground when created to avoid a race
|
||||||
|
// between binding to CMS and onResume()
|
||||||
|
inForeground = true;
|
||||||
|
|
||||||
|
// Create a GLSurfaceView to fetch GLRenderer unless we have
|
||||||
|
// a cached result already.
|
||||||
|
final GlPreferences glPrefs = GlPreferences.readPreferences(this);
|
||||||
|
if (!glPrefs.savedFingerprint.equals(Build.FINGERPRINT) || glPrefs.glRenderer.isEmpty()) {
|
||||||
|
GLSurfaceView surfaceView = new GLSurfaceView(this);
|
||||||
|
surfaceView.setRenderer(new GLSurfaceView.Renderer() {
|
||||||
|
@Override
|
||||||
|
public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) {
|
||||||
|
// Save the GLRenderer string so we don't need to do this next time
|
||||||
|
glPrefs.glRenderer = gl10.glGetString(GL10.GL_RENDERER);
|
||||||
|
glPrefs.savedFingerprint = Build.FINGERPRINT;
|
||||||
|
glPrefs.writePreferences();
|
||||||
|
|
||||||
|
LimeLog.info("Fetched GL Renderer: " + glPrefs.glRenderer);
|
||||||
|
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
completeOnCreate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSurfaceChanged(GL10 gl10, int i, int i1) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDrawFrame(GL10 gl10) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setContentView(surfaceView);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LimeLog.info("Cached GL Renderer: " + glPrefs.glRenderer);
|
||||||
|
completeOnCreate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void completeOnCreate() {
|
||||||
|
completeOnCreateCalled = true;
|
||||||
|
|
||||||
shortcutHelper = new ShortcutHelper(this);
|
shortcutHelper = new ShortcutHelper(this);
|
||||||
|
|
||||||
UiHelper.setLocale(this);
|
UiHelper.setLocale(this);
|
||||||
@@ -164,32 +223,6 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
PreferenceConfiguration.readPreferences(this).smallIconMode);
|
PreferenceConfiguration.readPreferences(this).smallIconMode);
|
||||||
|
|
||||||
initializeViews();
|
initializeViews();
|
||||||
|
|
||||||
SharedPreferences prefs = getSharedPreferences("DecoderTombstone", 0);
|
|
||||||
int crashCount = prefs.getInt("CrashCount", 0);
|
|
||||||
int lastNotifiedCrashCount = prefs.getInt("LastNotifiedCrashCount", 0);
|
|
||||||
|
|
||||||
// Remember the last crash count we notified at, so we don't
|
|
||||||
// display the crash dialog every time the app is started until
|
|
||||||
// they stream again
|
|
||||||
if (crashCount != 0 && crashCount != lastNotifiedCrashCount) {
|
|
||||||
if (crashCount % 3 == 0) {
|
|
||||||
// At 3 consecutive crashes, we'll forcefully reset their settings
|
|
||||||
PreferenceConfiguration.resetStreamingSettings(this);
|
|
||||||
Dialog.displayDialog(this,
|
|
||||||
getResources().getString(R.string.title_decoding_reset),
|
|
||||||
getResources().getString(R.string.message_decoding_reset),
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Dialog.displayDialog(this,
|
|
||||||
getResources().getString(R.string.title_decoding_error),
|
|
||||||
getResources().getString(R.string.message_decoding_error),
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
|
|
||||||
prefs.edit().putInt("LastNotifiedCrashCount", crashCount).apply();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startComputerUpdates() {
|
private void startComputerUpdates() {
|
||||||
@@ -245,6 +278,9 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
// Display a decoder crash notification if we've returned after a crash
|
||||||
|
UiHelper.showDecoderCrashDialog(this);
|
||||||
|
|
||||||
inForeground = true;
|
inForeground = true;
|
||||||
startComputerUpdates();
|
startComputerUpdates();
|
||||||
}
|
}
|
||||||
@@ -543,7 +579,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerHelper.doStart(this, new NvApp("app", computer.details.runningGameId), computer.details, managerBinder);
|
ServerHelper.doStart(this, new NvApp("app", computer.details.runningGameId, false), computer.details, managerBinder);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case QUIT_ID:
|
case QUIT_ID:
|
||||||
@@ -558,7 +594,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
public void run() {
|
public void run() {
|
||||||
ServerHelper.doQuit(PcView.this,
|
ServerHelper.doQuit(PcView.this,
|
||||||
ServerHelper.getCurrentAddressFromComputer(computer.details),
|
ServerHelper.getCurrentAddressFromComputer(computer.details),
|
||||||
new NvApp("app", 0), managerBinder, null);
|
new NvApp("app", 0, false), managerBinder, null);
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -96,6 +96,12 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
defaultContext.rightTriggerAxis = MotionEvent.AXIS_GAS;
|
defaultContext.rightTriggerAxis = MotionEvent.AXIS_GAS;
|
||||||
defaultContext.controllerNumber = (short) 0;
|
defaultContext.controllerNumber = (short) 0;
|
||||||
defaultContext.assignedControllerNumber = true;
|
defaultContext.assignedControllerNumber = true;
|
||||||
|
|
||||||
|
// Some devices (GPD XD) have a back button which sends input events
|
||||||
|
// with device ID == 0. This hits the default context which would normally
|
||||||
|
// consume these. Instead, let's ignore them since that's probably the
|
||||||
|
// most likely case.
|
||||||
|
defaultContext.ignoreBack = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static InputDevice.MotionRange getMotionRangeForJoystickAxis(InputDevice dev, int axis) {
|
private static InputDevice.MotionRange getMotionRangeForJoystickAxis(InputDevice dev, int axis) {
|
||||||
@@ -375,7 +381,7 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
context.triggerDeadzone = 0.30f;
|
context.triggerDeadzone = 0.30f;
|
||||||
}
|
}
|
||||||
// Classify this device as a remote by name
|
// Classify this device as a remote by name
|
||||||
else if (devName.contains("Fire TV Remote") || devName.contains("Nexus Remote")) {
|
else if (devName.toLowerCase().contains("remote")) {
|
||||||
// It's only a remote if it doesn't any sticks
|
// It's only a remote if it doesn't any sticks
|
||||||
if (!context.hasJoystickAxes) {
|
if (!context.hasJoystickAxes) {
|
||||||
context.ignoreBack = true;
|
context.ignoreBack = true;
|
||||||
@@ -387,8 +393,10 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
context.rightStickDeadzoneRadius = 0.07f;
|
context.rightStickDeadzoneRadius = 0.07f;
|
||||||
}
|
}
|
||||||
// Samsung's face buttons appear as a non-virtual button so we'll explicitly ignore
|
// Samsung's face buttons appear as a non-virtual button so we'll explicitly ignore
|
||||||
// back presses on this device
|
// back presses on this device. The Goodix buttons on the Nokia 6 also appear
|
||||||
else if (devName.equals("sec_touchscreen") || devName.equals("sec_touchkey")) {
|
// non-virtual so we'll ignore those too.
|
||||||
|
else if (devName.equals("sec_touchscreen") || devName.equals("sec_touchkey") ||
|
||||||
|
devName.equals("goodix_fp")) {
|
||||||
context.ignoreBack = true;
|
context.ignoreBack = true;
|
||||||
}
|
}
|
||||||
// The Serval has a couple of unknown buttons that are start and select. It also has
|
// The Serval has a couple of unknown buttons that are start and select. It also has
|
||||||
@@ -966,9 +974,17 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
context.inputMap &= ~ControllerPacket.RS_CLK_FLAG;
|
context.inputMap &= ~ControllerPacket.RS_CLK_FLAG;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.KEYCODE_BUTTON_L2:
|
case KeyEvent.KEYCODE_BUTTON_L2:
|
||||||
|
if (context.leftTriggerAxis >= 0) {
|
||||||
|
// Suppress this digital event if an analog trigger is present
|
||||||
|
return true;
|
||||||
|
}
|
||||||
context.leftTrigger = 0;
|
context.leftTrigger = 0;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.KEYCODE_BUTTON_R2:
|
case KeyEvent.KEYCODE_BUTTON_R2:
|
||||||
|
if (context.rightTriggerAxis >= 0) {
|
||||||
|
// Suppress this digital event if an analog trigger is present
|
||||||
|
return true;
|
||||||
|
}
|
||||||
context.rightTrigger = 0;
|
context.rightTrigger = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1078,9 +1094,17 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
context.inputMap |= ControllerPacket.RS_CLK_FLAG;
|
context.inputMap |= ControllerPacket.RS_CLK_FLAG;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.KEYCODE_BUTTON_L2:
|
case KeyEvent.KEYCODE_BUTTON_L2:
|
||||||
|
if (context.leftTriggerAxis >= 0) {
|
||||||
|
// Suppress this digital event if an analog trigger is present
|
||||||
|
return true;
|
||||||
|
}
|
||||||
context.leftTrigger = (byte)0xFF;
|
context.leftTrigger = (byte)0xFF;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.KEYCODE_BUTTON_R2:
|
case KeyEvent.KEYCODE_BUTTON_R2:
|
||||||
|
if (context.rightTriggerAxis >= 0) {
|
||||||
|
// Suppress this digital event if an analog trigger is present
|
||||||
|
return true;
|
||||||
|
}
|
||||||
context.rightTrigger = (byte)0xFF;
|
context.rightTrigger = (byte)0xFF;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -18,22 +18,15 @@ public class KeyboardTranslator {
|
|||||||
public static final int VK_9 = 57;
|
public static final int VK_9 = 57;
|
||||||
public static final int VK_A = 65;
|
public static final int VK_A = 65;
|
||||||
public static final int VK_Z = 90;
|
public static final int VK_Z = 90;
|
||||||
public static final int VK_ALT = 18;
|
|
||||||
public static final int VK_NUMPAD0 = 96;
|
public static final int VK_NUMPAD0 = 96;
|
||||||
public static final int VK_BACK_SLASH = 92;
|
public static final int VK_BACK_SLASH = 92;
|
||||||
public static final int VK_CAPS_LOCK = 20;
|
public static final int VK_CAPS_LOCK = 20;
|
||||||
public static final int VK_CLEAR = 12;
|
public static final int VK_CLEAR = 12;
|
||||||
public static final int VK_COMMA = 44;
|
public static final int VK_COMMA = 44;
|
||||||
public static final int VK_CONTROL = 17;
|
|
||||||
public static final int VK_BACK_SPACE = 8;
|
public static final int VK_BACK_SPACE = 8;
|
||||||
public static final int VK_EQUALS = 61;
|
public static final int VK_EQUALS = 61;
|
||||||
public static final int VK_ESCAPE = 27;
|
public static final int VK_ESCAPE = 27;
|
||||||
public static final int VK_F1 = 112;
|
public static final int VK_F1 = 112;
|
||||||
public static final int VK_PERIOD = 46;
|
|
||||||
public static final int VK_INSERT = 155;
|
|
||||||
public static final int VK_OPEN_BRACKET = 91;
|
|
||||||
public static final int VK_WINDOWS = 524;
|
|
||||||
public static final int VK_MINUS = 45;
|
|
||||||
public static final int VK_END = 35;
|
public static final int VK_END = 35;
|
||||||
public static final int VK_HOME = 36;
|
public static final int VK_HOME = 36;
|
||||||
public static final int VK_NUM_LOCK = 144;
|
public static final int VK_NUM_LOCK = 144;
|
||||||
@@ -43,7 +36,6 @@ public class KeyboardTranslator {
|
|||||||
public static final int VK_CLOSE_BRACKET = 93;
|
public static final int VK_CLOSE_BRACKET = 93;
|
||||||
public static final int VK_SCROLL_LOCK = 145;
|
public static final int VK_SCROLL_LOCK = 145;
|
||||||
public static final int VK_SEMICOLON = 59;
|
public static final int VK_SEMICOLON = 59;
|
||||||
public static final int VK_SHIFT = 16;
|
|
||||||
public static final int VK_SLASH = 47;
|
public static final int VK_SLASH = 47;
|
||||||
public static final int VK_SPACE = 32;
|
public static final int VK_SPACE = 32;
|
||||||
public static final int VK_PRINTSCREEN = 154;
|
public static final int VK_PRINTSCREEN = 154;
|
||||||
@@ -64,10 +56,9 @@ public class KeyboardTranslator {
|
|||||||
public static short translate(int keycode) {
|
public static short translate(int keycode) {
|
||||||
int translated;
|
int translated;
|
||||||
|
|
||||||
/* There seems to be no clean mapping between Android key codes
|
// This is a poor man's mapping between Android key codes
|
||||||
* and what Nvidia sends over the wire. If someone finds one,
|
// and Windows VK_* codes. For all defined VK_ codes, see:
|
||||||
* I'll happily delete this code :)
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
|
||||||
*/
|
|
||||||
if (keycode >= KeyEvent.KEYCODE_0 &&
|
if (keycode >= KeyEvent.KEYCODE_0 &&
|
||||||
keycode <= KeyEvent.KEYCODE_9) {
|
keycode <= KeyEvent.KEYCODE_9) {
|
||||||
translated = (keycode - KeyEvent.KEYCODE_0) + VK_0;
|
translated = (keycode - KeyEvent.KEYCODE_0) + VK_0;
|
||||||
@@ -87,8 +78,11 @@ public class KeyboardTranslator {
|
|||||||
else {
|
else {
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case KeyEvent.KEYCODE_ALT_LEFT:
|
case KeyEvent.KEYCODE_ALT_LEFT:
|
||||||
|
translated = 0xA4;
|
||||||
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_ALT_RIGHT:
|
case KeyEvent.KEYCODE_ALT_RIGHT:
|
||||||
translated = VK_ALT;
|
translated = 0xA5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_BACKSLASH:
|
case KeyEvent.KEYCODE_BACKSLASH:
|
||||||
@@ -108,8 +102,11 @@ public class KeyboardTranslator {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_CTRL_LEFT:
|
case KeyEvent.KEYCODE_CTRL_LEFT:
|
||||||
|
translated = 0xA2;
|
||||||
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_CTRL_RIGHT:
|
case KeyEvent.KEYCODE_CTRL_RIGHT:
|
||||||
translated = VK_CONTROL;
|
translated = 0xA3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_DEL:
|
case KeyEvent.KEYCODE_DEL:
|
||||||
@@ -129,23 +126,25 @@ public class KeyboardTranslator {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_FORWARD_DEL:
|
case KeyEvent.KEYCODE_FORWARD_DEL:
|
||||||
// Nvidia maps period to delete
|
translated = 0x2e;
|
||||||
translated = VK_PERIOD;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_INSERT:
|
case KeyEvent.KEYCODE_INSERT:
|
||||||
translated = -1;
|
translated = 0x2d;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_LEFT_BRACKET:
|
case KeyEvent.KEYCODE_LEFT_BRACKET:
|
||||||
translated = 0xdb;
|
translated = 0xdb;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_META_LEFT:
|
case KeyEvent.KEYCODE_META_LEFT:
|
||||||
case KeyEvent.KEYCODE_META_RIGHT:
|
translated = 0x5b;
|
||||||
translated = VK_WINDOWS;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case KeyEvent.KEYCODE_META_RIGHT:
|
||||||
|
translated = 0x5c;
|
||||||
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_MINUS:
|
case KeyEvent.KEYCODE_MINUS:
|
||||||
translated = 0xbd;
|
translated = 0xbd;
|
||||||
break;
|
break;
|
||||||
@@ -187,8 +186,11 @@ public class KeyboardTranslator {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_SHIFT_LEFT:
|
case KeyEvent.KEYCODE_SHIFT_LEFT:
|
||||||
|
translated = 0xA0;
|
||||||
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_SHIFT_RIGHT:
|
case KeyEvent.KEYCODE_SHIFT_RIGHT:
|
||||||
translated = VK_SHIFT;
|
translated = 0xA1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_SLASH:
|
case KeyEvent.KEYCODE_SLASH:
|
||||||
@@ -235,6 +237,26 @@ public class KeyboardTranslator {
|
|||||||
case KeyEvent.KEYCODE_BREAK:
|
case KeyEvent.KEYCODE_BREAK:
|
||||||
translated = VK_PAUSE;
|
translated = VK_PAUSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case KeyEvent.KEYCODE_NUMPAD_DIVIDE:
|
||||||
|
translated = 0x6F;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KeyEvent.KEYCODE_NUMPAD_MULTIPLY:
|
||||||
|
translated = 0x6A;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KeyEvent.KEYCODE_NUMPAD_SUBTRACT:
|
||||||
|
translated = 0x6D;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KeyEvent.KEYCODE_NUMPAD_ADD:
|
||||||
|
translated = 0x6B;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KeyEvent.KEYCODE_NUMPAD_DOT:
|
||||||
|
translated = 0x6E;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
System.out.println("No key for "+keycode);
|
System.out.println("No key for "+keycode);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import android.hardware.usb.UsbDeviceConnection;
|
|||||||
import android.hardware.usb.UsbManager;
|
import android.hardware.usb.UsbManager;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.view.InputDevice;
|
import android.view.InputDevice;
|
||||||
|
|
||||||
@@ -72,10 +73,22 @@ public class UsbDriverService extends Service implements UsbDriverListener {
|
|||||||
|
|
||||||
// Initial attachment broadcast
|
// Initial attachment broadcast
|
||||||
if (action.equals(UsbManager.ACTION_USB_DEVICE_ATTACHED)) {
|
if (action.equals(UsbManager.ACTION_USB_DEVICE_ATTACHED)) {
|
||||||
UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
final UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
||||||
|
|
||||||
// Continue the state machine
|
// shouldClaimDevice() looks at the kernel's enumerated input
|
||||||
handleUsbDeviceState(device);
|
// devices to make its decision about whether to prompt to take
|
||||||
|
// control of the device. The kernel bringing up the input stack
|
||||||
|
// may race with this callback and cause us to prompt when the
|
||||||
|
// kernel is capable of running the device. Let's post a delayed
|
||||||
|
// message to process this state change to allow the kernel
|
||||||
|
// some time to bring up the stack.
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Continue the state machine
|
||||||
|
handleUsbDeviceState(device);
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
// Subsequent permission dialog completion intent
|
// Subsequent permission dialog completion intent
|
||||||
else if (action.equals(ACTION_USB_PERMISSION)) {
|
else if (action.equals(ACTION_USB_PERMISSION)) {
|
||||||
@@ -151,6 +164,10 @@ public class UsbDriverService extends Service implements UsbDriverListener {
|
|||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
for (int id : InputDevice.getDeviceIds()) {
|
for (int id : InputDevice.getDeviceIds()) {
|
||||||
InputDevice inputDev = InputDevice.getDevice(id);
|
InputDevice inputDev = InputDevice.getDevice(id);
|
||||||
|
if (inputDev == null) {
|
||||||
|
// Device was removed while looping
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (inputDev.getVendorId() == device.getVendorId() &&
|
if (inputDev.getVendorId() == device.getVendorId() &&
|
||||||
inputDev.getProductId() == device.getProductId()) {
|
inputDev.getProductId() == device.getProductId()) {
|
||||||
|
|||||||
+111
-90
@@ -8,6 +8,7 @@ import android.content.Context;
|
|||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
|
||||||
import com.limelight.nvstream.input.ControllerPacket;
|
import com.limelight.nvstream.input.ControllerPacket;
|
||||||
|
import com.limelight.preferences.PreferenceConfiguration;
|
||||||
|
|
||||||
public class VirtualControllerConfigurationLoader {
|
public class VirtualControllerConfigurationLoader {
|
||||||
private static final String PROFILE_PATH = "profiles";
|
private static final String PROFILE_PATH = "profiles";
|
||||||
@@ -146,110 +147,130 @@ public class VirtualControllerConfigurationLoader {
|
|||||||
public static void createDefaultLayout(final VirtualController controller, final Context context) {
|
public static void createDefaultLayout(final VirtualController controller, final Context context) {
|
||||||
|
|
||||||
DisplayMetrics screen = context.getResources().getDisplayMetrics();
|
DisplayMetrics screen = context.getResources().getDisplayMetrics();
|
||||||
|
PreferenceConfiguration config = PreferenceConfiguration.readPreferences(context);
|
||||||
|
|
||||||
// NOTE: Some of these getPercent() expressions seem like they can be combined
|
// NOTE: Some of these getPercent() expressions seem like they can be combined
|
||||||
// into a single call. Due to floating point rounding, this isn't actually possible.
|
// into a single call. Due to floating point rounding, this isn't actually possible.
|
||||||
|
|
||||||
controller.addElement(createDigitalPad(controller, context),
|
if (!config.onlyL3R3)
|
||||||
getPercent(5, screen.widthPixels),
|
{
|
||||||
getPercent(BUTTON_BASE_Y, screen.heightPixels),
|
controller.addElement(createDigitalPad(controller, context),
|
||||||
getPercent(30, screen.widthPixels),
|
getPercent(5, screen.widthPixels),
|
||||||
getPercent(40, screen.heightPixels)
|
getPercent(BUTTON_BASE_Y, screen.heightPixels),
|
||||||
);
|
getPercent(30, screen.widthPixels),
|
||||||
|
getPercent(40, screen.heightPixels)
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.addElement(createDigitalButton(
|
||||||
|
ControllerPacket.A_FLAG, 0, 1, "A", -1, controller, context),
|
||||||
|
getPercent(BUTTON_BASE_X, screen.widthPixels) + getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_BASE_Y, screen.heightPixels) + 2 * getPercent(BUTTON_HEIGHT, screen.heightPixels),
|
||||||
|
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.addElement(createDigitalButton(
|
||||||
|
ControllerPacket.B_FLAG, 0, 1, "B", -1, controller, context),
|
||||||
|
getPercent(BUTTON_BASE_X, screen.widthPixels) + 2 * getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_BASE_Y, screen.heightPixels) + getPercent(BUTTON_HEIGHT, screen.heightPixels),
|
||||||
|
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.addElement(createDigitalButton(
|
||||||
|
ControllerPacket.X_FLAG, 0, 1, "X", -1, controller, context),
|
||||||
|
getPercent(BUTTON_BASE_X, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_BASE_Y, screen.heightPixels) + getPercent(BUTTON_HEIGHT, screen.heightPixels),
|
||||||
|
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.addElement(createDigitalButton(
|
||||||
|
ControllerPacket.Y_FLAG, 0, 1, "Y", -1, controller, context),
|
||||||
|
getPercent(BUTTON_BASE_X, screen.widthPixels) + getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_BASE_Y, screen.heightPixels),
|
||||||
|
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.addElement(createLeftTrigger(
|
||||||
|
0, "LT", -1, controller, context),
|
||||||
|
getPercent(BUTTON_BASE_X, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_BASE_Y, screen.heightPixels),
|
||||||
|
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.addElement(createRightTrigger(
|
||||||
|
0, "RT", -1, controller, context),
|
||||||
|
getPercent(BUTTON_BASE_X, screen.widthPixels) + 2 * getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_BASE_Y, screen.heightPixels),
|
||||||
|
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.addElement(createDigitalButton(
|
||||||
|
ControllerPacket.LB_FLAG, 0, 1, "LB", -1, controller, context),
|
||||||
|
getPercent(BUTTON_BASE_X, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_BASE_Y, screen.heightPixels) + 2 * getPercent(BUTTON_HEIGHT, screen.heightPixels),
|
||||||
|
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.addElement(createDigitalButton(
|
||||||
|
ControllerPacket.RB_FLAG, 0, 1, "RB", -1, controller, context),
|
||||||
|
getPercent(BUTTON_BASE_X, screen.widthPixels) + 2 * getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_BASE_Y, screen.heightPixels) + 2 * getPercent(BUTTON_HEIGHT, screen.heightPixels),
|
||||||
|
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
|
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.addElement(createLeftStick(controller, context),
|
||||||
|
getPercent(5, screen.widthPixels),
|
||||||
|
getPercent(50, screen.heightPixels),
|
||||||
|
getPercent(40, screen.widthPixels),
|
||||||
|
getPercent(50, screen.heightPixels)
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.addElement(createRightStick(controller, context),
|
||||||
|
getPercent(55, screen.widthPixels),
|
||||||
|
getPercent(50, screen.heightPixels),
|
||||||
|
getPercent(40, screen.widthPixels),
|
||||||
|
getPercent(50, screen.heightPixels)
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.addElement(createDigitalButton(
|
||||||
|
ControllerPacket.BACK_FLAG, 0, 2, "BACK", -1, controller, context),
|
||||||
|
getPercent(40, screen.widthPixels),
|
||||||
|
getPercent(90, screen.heightPixels),
|
||||||
|
getPercent(10, screen.widthPixels),
|
||||||
|
getPercent(10, screen.heightPixels)
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.addElement(createDigitalButton(
|
||||||
|
ControllerPacket.PLAY_FLAG, 0, 3, "START", -1, controller, context),
|
||||||
|
getPercent(40, screen.widthPixels) + getPercent(10, screen.widthPixels),
|
||||||
|
getPercent(90, screen.heightPixels),
|
||||||
|
getPercent(10, screen.widthPixels),
|
||||||
|
getPercent(10, screen.heightPixels)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
controller.addElement(createDigitalButton(
|
controller.addElement(createDigitalButton(
|
||||||
ControllerPacket.A_FLAG, 0, 1, "A", -1, controller, context),
|
ControllerPacket.LS_CLK_FLAG, 0, 1, "L3", -1, controller, context),
|
||||||
getPercent(BUTTON_BASE_X, screen.widthPixels)+getPercent(BUTTON_WIDTH, screen.widthPixels),
|
getPercent(2, screen.widthPixels),
|
||||||
getPercent(BUTTON_BASE_Y, screen.heightPixels)+2*getPercent(BUTTON_HEIGHT, screen.heightPixels),
|
getPercent(80, screen.heightPixels),
|
||||||
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
||||||
);
|
);
|
||||||
|
|
||||||
controller.addElement(createDigitalButton(
|
controller.addElement(createDigitalButton(
|
||||||
ControllerPacket.B_FLAG, 0, 1, "B", -1, controller, context),
|
ControllerPacket.RS_CLK_FLAG, 0, 1, "R3", -1, controller, context),
|
||||||
getPercent(BUTTON_BASE_X, screen.widthPixels)+2*getPercent(BUTTON_WIDTH, screen.widthPixels),
|
getPercent(89, screen.widthPixels),
|
||||||
getPercent(BUTTON_BASE_Y, screen.heightPixels)+getPercent(BUTTON_HEIGHT, screen.heightPixels),
|
getPercent(80, screen.heightPixels),
|
||||||
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
||||||
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
||||||
);
|
);
|
||||||
|
|
||||||
controller.addElement(createDigitalButton(
|
|
||||||
ControllerPacket.X_FLAG, 0, 1, "X", -1, controller, context),
|
|
||||||
getPercent(BUTTON_BASE_X, screen.widthPixels),
|
|
||||||
getPercent(BUTTON_BASE_Y, screen.heightPixels)+getPercent(BUTTON_HEIGHT, screen.heightPixels),
|
|
||||||
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
|
||||||
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
|
||||||
);
|
|
||||||
|
|
||||||
controller.addElement(createDigitalButton(
|
|
||||||
ControllerPacket.Y_FLAG, 0, 1, "Y", -1, controller, context),
|
|
||||||
getPercent(BUTTON_BASE_X, screen.widthPixels)+getPercent(BUTTON_WIDTH, screen.widthPixels),
|
|
||||||
getPercent(BUTTON_BASE_Y, screen.heightPixels),
|
|
||||||
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
|
||||||
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
|
||||||
);
|
|
||||||
|
|
||||||
controller.addElement(createLeftTrigger(
|
|
||||||
0, "LT", -1, controller, context),
|
|
||||||
getPercent(BUTTON_BASE_X, screen.widthPixels),
|
|
||||||
getPercent(BUTTON_BASE_Y, screen.heightPixels),
|
|
||||||
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
|
||||||
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
|
||||||
);
|
|
||||||
|
|
||||||
controller.addElement(createRightTrigger(
|
|
||||||
0, "RT", -1, controller, context),
|
|
||||||
getPercent(BUTTON_BASE_X, screen.widthPixels)+2*getPercent(BUTTON_WIDTH, screen.widthPixels),
|
|
||||||
getPercent(BUTTON_BASE_Y, screen.heightPixels),
|
|
||||||
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
|
||||||
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
|
||||||
);
|
|
||||||
|
|
||||||
controller.addElement(createDigitalButton(
|
|
||||||
ControllerPacket.LB_FLAG, 0, 1, "LB", -1, controller, context),
|
|
||||||
getPercent(BUTTON_BASE_X, screen.widthPixels),
|
|
||||||
getPercent(BUTTON_BASE_Y, screen.heightPixels)+2*getPercent(BUTTON_HEIGHT, screen.heightPixels),
|
|
||||||
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
|
||||||
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
|
||||||
);
|
|
||||||
|
|
||||||
controller.addElement(createDigitalButton(
|
|
||||||
ControllerPacket.RB_FLAG, 0, 1, "RB", -1, controller, context),
|
|
||||||
getPercent(BUTTON_BASE_X, screen.widthPixels)+2*getPercent(BUTTON_WIDTH, screen.widthPixels),
|
|
||||||
getPercent(BUTTON_BASE_Y, screen.heightPixels)+2*getPercent(BUTTON_HEIGHT, screen.heightPixels),
|
|
||||||
getPercent(BUTTON_WIDTH, screen.widthPixels),
|
|
||||||
getPercent(BUTTON_HEIGHT, screen.heightPixels)
|
|
||||||
);
|
|
||||||
|
|
||||||
controller.addElement(createLeftStick(controller, context),
|
|
||||||
getPercent(5, screen.widthPixels),
|
|
||||||
getPercent(50, screen.heightPixels),
|
|
||||||
getPercent(40, screen.widthPixels),
|
|
||||||
getPercent(50, screen.heightPixels)
|
|
||||||
);
|
|
||||||
|
|
||||||
controller.addElement(createRightStick(controller, context),
|
|
||||||
getPercent(55, screen.widthPixels),
|
|
||||||
getPercent(50, screen.heightPixels),
|
|
||||||
getPercent(40, screen.widthPixels),
|
|
||||||
getPercent(50, screen.heightPixels)
|
|
||||||
);
|
|
||||||
|
|
||||||
controller.addElement(createDigitalButton(
|
|
||||||
ControllerPacket.BACK_FLAG, 0, 2, "BACK", -1, controller, context),
|
|
||||||
getPercent(40, screen.widthPixels),
|
|
||||||
getPercent(90, screen.heightPixels),
|
|
||||||
getPercent(10, screen.widthPixels),
|
|
||||||
getPercent(10, screen.heightPixels)
|
|
||||||
);
|
|
||||||
|
|
||||||
controller.addElement(createDigitalButton(
|
|
||||||
ControllerPacket.PLAY_FLAG, 0, 3, "START", -1, controller, context),
|
|
||||||
getPercent(40, screen.widthPixels)+getPercent(10, screen.widthPixels),
|
|
||||||
getPercent(90, screen.heightPixels),
|
|
||||||
getPercent(10, screen.widthPixels),
|
|
||||||
getPercent(10, screen.heightPixels)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.limelight.binding.video;
|
package com.limelight.binding.video;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.jcodec.codecs.h264.H264Utils;
|
import org.jcodec.codecs.h264.H264Utils;
|
||||||
@@ -12,13 +13,13 @@ import com.limelight.nvstream.av.video.VideoDecoderRenderer;
|
|||||||
import com.limelight.nvstream.jni.MoonBridge;
|
import com.limelight.nvstream.jni.MoonBridge;
|
||||||
import com.limelight.preferences.PreferenceConfiguration;
|
import com.limelight.preferences.PreferenceConfiguration;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.media.MediaCodec;
|
import android.media.MediaCodec;
|
||||||
import android.media.MediaCodecInfo;
|
import android.media.MediaCodecInfo;
|
||||||
import android.media.MediaFormat;
|
import android.media.MediaFormat;
|
||||||
import android.media.MediaCodec.BufferInfo;
|
import android.media.MediaCodec.BufferInfo;
|
||||||
import android.media.MediaCodec.CodecException;
|
import android.media.MediaCodec.CodecException;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.util.Range;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
|
|
||||||
public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
||||||
@@ -32,9 +33,11 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
private MediaCodecInfo avcDecoder;
|
private MediaCodecInfo avcDecoder;
|
||||||
private MediaCodecInfo hevcDecoder;
|
private MediaCodecInfo hevcDecoder;
|
||||||
|
|
||||||
// Used for HEVC only
|
|
||||||
private byte[] vpsBuffer;
|
private byte[] vpsBuffer;
|
||||||
private byte[] spsBuffer;
|
private byte[] spsBuffer;
|
||||||
|
private byte[] ppsBuffer;
|
||||||
|
private boolean submittedCsd;
|
||||||
|
private boolean submitCsdNextCall;
|
||||||
|
|
||||||
private MediaCodec videoDecoder;
|
private MediaCodec videoDecoder;
|
||||||
private Thread rendererThread;
|
private Thread rendererThread;
|
||||||
@@ -51,6 +54,8 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
private CrashListener crashListener;
|
private CrashListener crashListener;
|
||||||
private boolean reportedCrash;
|
private boolean reportedCrash;
|
||||||
private int consecutiveCrashCount;
|
private int consecutiveCrashCount;
|
||||||
|
private String glRenderer;
|
||||||
|
private boolean foreground = true;
|
||||||
|
|
||||||
private boolean needsBaselineSpsHack;
|
private boolean needsBaselineSpsHack;
|
||||||
private SeqParameterSet savedSps;
|
private SeqParameterSet savedSps;
|
||||||
@@ -62,12 +67,13 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
private long lastTimestampUs;
|
private long lastTimestampUs;
|
||||||
private long decoderTimeMs;
|
private long decoderTimeMs;
|
||||||
private long totalTimeMs;
|
private long totalTimeMs;
|
||||||
private int totalFrames;
|
private int totalFramesReceived;
|
||||||
|
private int totalFramesRendered;
|
||||||
private int frameLossEvents;
|
private int frameLossEvents;
|
||||||
private int framesLost;
|
private int framesLost;
|
||||||
private int lastFrameNumber;
|
private int lastFrameNumber;
|
||||||
private int refreshRate;
|
private int refreshRate;
|
||||||
private int bitrate;
|
private PreferenceConfiguration prefs;
|
||||||
|
|
||||||
private int numSpsIn;
|
private int numSpsIn;
|
||||||
private int numPpsIn;
|
private int numPpsIn;
|
||||||
@@ -81,9 +87,9 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
return decoder;
|
return decoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MediaCodecInfo findHevcDecoder(int videoFormat) {
|
private MediaCodecInfo findHevcDecoder(PreferenceConfiguration prefs, boolean meteredNetwork, boolean requestedHdr) {
|
||||||
// Don't return anything if H.265 is forced off
|
// Don't return anything if H.265 is forced off
|
||||||
if (videoFormat == PreferenceConfiguration.FORCE_H265_OFF) {
|
if (prefs.videoFormat == PreferenceConfiguration.FORCE_H265_OFF) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,10 +100,10 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
// for even required levels of HEVC.
|
// for even required levels of HEVC.
|
||||||
MediaCodecInfo decoderInfo = MediaCodecHelper.findProbableSafeDecoder("video/hevc", -1);
|
MediaCodecInfo decoderInfo = MediaCodecHelper.findProbableSafeDecoder("video/hevc", -1);
|
||||||
if (decoderInfo != null) {
|
if (decoderInfo != null) {
|
||||||
if (!MediaCodecHelper.decoderIsWhitelistedForHevc(decoderInfo.getName())) {
|
if (!MediaCodecHelper.decoderIsWhitelistedForHevc(decoderInfo.getName(), meteredNetwork, requestedHdr)) {
|
||||||
LimeLog.info("Found HEVC decoder, but it's not whitelisted - "+decoderInfo.getName());
|
LimeLog.info("Found HEVC decoder, but it's not whitelisted - "+decoderInfo.getName());
|
||||||
|
|
||||||
if (videoFormat == PreferenceConfiguration.FORCE_H265_ON) {
|
if (prefs.videoFormat == PreferenceConfiguration.FORCE_H265_ON) {
|
||||||
LimeLog.info("Forcing H265 enabled despite non-whitelisted decoder");
|
LimeLog.info("Forcing H265 enabled despite non-whitelisted decoder");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -113,16 +119,19 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
this.renderTarget = renderTarget;
|
this.renderTarget = renderTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MediaCodecDecoderRenderer(int videoFormat, int bitrate, boolean batterySaver,
|
public MediaCodecDecoderRenderer(PreferenceConfiguration prefs,
|
||||||
CrashListener crashListener, int consecutiveCrashCount) {
|
CrashListener crashListener, int consecutiveCrashCount,
|
||||||
|
boolean meteredData, boolean requestedHdr,
|
||||||
|
String glRenderer) {
|
||||||
//dumpDecoders();
|
//dumpDecoders();
|
||||||
|
|
||||||
this.bitrate = bitrate;
|
this.prefs = prefs;
|
||||||
this.crashListener = crashListener;
|
this.crashListener = crashListener;
|
||||||
this.consecutiveCrashCount = consecutiveCrashCount;
|
this.consecutiveCrashCount = consecutiveCrashCount;
|
||||||
|
this.glRenderer = glRenderer;
|
||||||
|
|
||||||
// Disable spinner threads in battery saver mode
|
// Disable spinner threads in battery saver mode or 4K
|
||||||
if (batterySaver) {
|
if (prefs.batterySaver || prefs.height >= 2160) {
|
||||||
spinnerThreads = new Thread[0];
|
spinnerThreads = new Thread[0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -137,7 +146,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
LimeLog.warning("No AVC decoder found");
|
LimeLog.warning("No AVC decoder found");
|
||||||
}
|
}
|
||||||
|
|
||||||
hevcDecoder = findHevcDecoder(videoFormat);
|
hevcDecoder = findHevcDecoder(prefs, meteredData, requestedHdr);
|
||||||
if (hevcDecoder != null) {
|
if (hevcDecoder != null) {
|
||||||
LimeLog.info("Selected HEVC decoder: "+hevcDecoder.getName());
|
LimeLog.info("Selected HEVC decoder: "+hevcDecoder.getName());
|
||||||
}
|
}
|
||||||
@@ -152,8 +161,8 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
// shared between AVC and HEVC decoders on the same device.
|
// shared between AVC and HEVC decoders on the same device.
|
||||||
if (avcDecoder != null) {
|
if (avcDecoder != null) {
|
||||||
directSubmit = MediaCodecHelper.decoderCanDirectSubmit(avcDecoder.getName());
|
directSubmit = MediaCodecHelper.decoderCanDirectSubmit(avcDecoder.getName());
|
||||||
adaptivePlayback = MediaCodecHelper.decoderSupportsAdaptivePlayback(avcDecoder.getName());
|
adaptivePlayback = MediaCodecHelper.decoderSupportsAdaptivePlayback(avcDecoder);
|
||||||
refFrameInvalidationAvc = MediaCodecHelper.decoderSupportsRefFrameInvalidationAvc(avcDecoder.getName());
|
refFrameInvalidationAvc = MediaCodecHelper.decoderSupportsRefFrameInvalidationAvc(avcDecoder.getName(), prefs.height);
|
||||||
refFrameInvalidationHevc = MediaCodecHelper.decoderSupportsRefFrameInvalidationHevc(avcDecoder.getName());
|
refFrameInvalidationHevc = MediaCodecHelper.decoderSupportsRefFrameInvalidationHevc(avcDecoder.getName());
|
||||||
|
|
||||||
if (directSubmit) {
|
if (directSubmit) {
|
||||||
@@ -176,6 +185,34 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
return avcDecoder != null;
|
return avcDecoder != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isHevcMain10Hdr10Supported() {
|
||||||
|
if (hevcDecoder == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (MediaCodecInfo.CodecProfileLevel profileLevel : hevcDecoder.getCapabilitiesForType("video/hevc").profileLevels) {
|
||||||
|
if (profileLevel.profile == MediaCodecInfo.CodecProfileLevel.HEVCProfileMain10HDR10) {
|
||||||
|
LimeLog.info("HEVC decoder "+hevcDecoder.getName()+" supports HEVC Main10 HDR10");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notifyVideoForeground() {
|
||||||
|
startSpinnerThreads();
|
||||||
|
foreground = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notifyVideoBackground() {
|
||||||
|
// Signal the spinner threads to stop but
|
||||||
|
// don't wait for them to terminate to avoid
|
||||||
|
// delaying the state transition
|
||||||
|
signalSpinnerStop();
|
||||||
|
foreground = false;
|
||||||
|
}
|
||||||
|
|
||||||
public int getActiveVideoFormat() {
|
public int getActiveVideoFormat() {
|
||||||
return this.videoFormat;
|
return this.videoFormat;
|
||||||
}
|
}
|
||||||
@@ -190,7 +227,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
String mimeType;
|
String mimeType;
|
||||||
String selectedDecoderName;
|
String selectedDecoderName;
|
||||||
|
|
||||||
if (videoFormat == MoonBridge.VIDEO_FORMAT_H264) {
|
if ((videoFormat & MoonBridge.VIDEO_FORMAT_MASK_H264) != 0) {
|
||||||
mimeType = "video/avc";
|
mimeType = "video/avc";
|
||||||
selectedDecoderName = avcDecoder.getName();
|
selectedDecoderName = avcDecoder.getName();
|
||||||
|
|
||||||
@@ -219,7 +256,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
|
|
||||||
refFrameInvalidationActive = refFrameInvalidationAvc;
|
refFrameInvalidationActive = refFrameInvalidationAvc;
|
||||||
}
|
}
|
||||||
else if (videoFormat == MoonBridge.VIDEO_FORMAT_H265) {
|
else if ((videoFormat & MoonBridge.VIDEO_FORMAT_MASK_H265) != 0) {
|
||||||
mimeType = "video/hevc";
|
mimeType = "video/hevc";
|
||||||
selectedDecoderName = hevcDecoder.getName();
|
selectedDecoderName = hevcDecoder.getName();
|
||||||
|
|
||||||
@@ -367,7 +404,16 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render the last buffer
|
// Render the last buffer
|
||||||
videoDecoder.releaseOutputBuffer(lastIndex, true);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && prefs.disableFrameDrop) {
|
||||||
|
// Use a PTS that will cause this frame to never be dropped if frame dropping
|
||||||
|
// is disabled
|
||||||
|
videoDecoder.releaseOutputBuffer(lastIndex, 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
videoDecoder.releaseOutputBuffer(lastIndex, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
totalFramesRendered++;
|
||||||
|
|
||||||
// Add delta time to the totals (excluding probable outliers)
|
// Add delta time to the totals (excluding probable outliers)
|
||||||
long delta = MediaCodecHelper.getMonotonicMillis() - (presentationTimeUs / 1000);
|
long delta = MediaCodecHelper.getMonotonicMillis() - (presentationTimeUs / 1000);
|
||||||
@@ -400,32 +446,76 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
rendererThread.start();
|
rendererThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startSpinnerThread(final int i) {
|
||||||
|
spinnerThreads[i] = new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// This thread exists to keep the CPU at a higher DVFS state on devices
|
||||||
|
// where the governor scales clock speed sporadically, causing dropped frames.
|
||||||
|
//
|
||||||
|
// Run until we notice our thread has been removed from the spinner threads
|
||||||
|
// array. Even if we don't notice immediately, we'll notice soon enough.
|
||||||
|
// This will also ensure we terminate even if someone has restarted spinning
|
||||||
|
// before we realized we should stop.
|
||||||
|
while (this == spinnerThreads[i]) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(0, 1);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
spinnerThreads[i].setName("Spinner-"+i);
|
||||||
|
spinnerThreads[i].setPriority(Thread.MIN_PRIORITY);
|
||||||
|
spinnerThreads[i].start();
|
||||||
|
}
|
||||||
|
|
||||||
private void startSpinnerThreads() {
|
private void startSpinnerThreads() {
|
||||||
LimeLog.info("Using "+spinnerThreads.length+" spinner threads");
|
LimeLog.info("Using "+spinnerThreads.length+" spinner threads");
|
||||||
for (int i = 0; i < spinnerThreads.length; i++) {
|
for (int i = 0; i < spinnerThreads.length; i++) {
|
||||||
spinnerThreads[i] = new Thread() {
|
if (spinnerThreads[i] != null) {
|
||||||
@Override
|
continue;
|
||||||
public void run() {
|
}
|
||||||
// This thread exists to keep the CPU at a higher DVFS state on devices
|
|
||||||
// where the governor scales clock speed sporadically, causing dropped frames.
|
startSpinnerThread(i);
|
||||||
while (!stopping) {
|
}
|
||||||
try {
|
}
|
||||||
Thread.sleep(0, 1);
|
|
||||||
} catch (InterruptedException e) {
|
private Thread[] signalSpinnerStop() {
|
||||||
break;
|
// Capture current running threads
|
||||||
}
|
Thread[] runningThreads = Arrays.copyOf(spinnerThreads, spinnerThreads.length);
|
||||||
}
|
|
||||||
}
|
// Clear the spinner threads to signal their termination
|
||||||
};
|
for (int i = 0; i < spinnerThreads.length; i++) {
|
||||||
spinnerThreads[i].setName("Spinner-"+i);
|
spinnerThreads[i] = null;
|
||||||
spinnerThreads[i].setPriority(Thread.MIN_PRIORITY);
|
}
|
||||||
spinnerThreads[i].start();
|
|
||||||
|
// Interrupt the threads
|
||||||
|
for (int i = 0; i < runningThreads.length; i++) {
|
||||||
|
if (runningThreads[i] != null) {
|
||||||
|
runningThreads[i].interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return runningThreads;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopSpinnerThreads() {
|
||||||
|
// Signal and wait for the threads to stop
|
||||||
|
Thread[] runningThreads = signalSpinnerStop();
|
||||||
|
for (int i = 0; i < runningThreads.length; i++) {
|
||||||
|
if (runningThreads[i] != null) {
|
||||||
|
try {
|
||||||
|
runningThreads[i].join();
|
||||||
|
} catch (InterruptedException ignored) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int dequeueInputBuffer() {
|
private int dequeueInputBuffer() {
|
||||||
int index = -1;
|
int index = -1;
|
||||||
long startTime, queueTime;
|
long startTime;
|
||||||
|
|
||||||
startTime = MediaCodecHelper.getMonotonicMillis();
|
startTime = MediaCodecHelper.getMonotonicMillis();
|
||||||
|
|
||||||
@@ -438,14 +528,24 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
return MediaCodec.INFO_TRY_AGAIN_LATER;
|
return MediaCodec.INFO_TRY_AGAIN_LATER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index < 0) {
|
int deltaMs = (int)(MediaCodecHelper.getMonotonicMillis() - startTime);
|
||||||
return index;
|
|
||||||
|
if (deltaMs >= 20) {
|
||||||
|
LimeLog.warning("Dequeue input buffer ran long: " + deltaMs + " ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
queueTime = MediaCodecHelper.getMonotonicMillis();
|
if (index < 0) {
|
||||||
|
// We've been hung for 5 seconds and no other exception was reported,
|
||||||
if (queueTime - startTime >= 20) {
|
// so generate a decoder hung exception
|
||||||
LimeLog.warning("Queue input buffer ran long: " + (queueTime - startTime) + " ms");
|
if (deltaMs >= 5000 && initialException == null) {
|
||||||
|
DecoderHungException decoderHungException = new DecoderHungException(deltaMs);
|
||||||
|
if (!reportedCrash) {
|
||||||
|
reportedCrash = true;
|
||||||
|
crashListener.notifyCrash(decoderHungException);
|
||||||
|
}
|
||||||
|
throw new RendererException(this, decoderHungException);
|
||||||
|
}
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
@@ -493,14 +593,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Halt the spinner threads
|
// Halt the spinner threads
|
||||||
for (Thread t : spinnerThreads) {
|
stopSpinnerThreads();
|
||||||
t.interrupt();
|
|
||||||
}
|
|
||||||
for (Thread t : spinnerThreads) {
|
|
||||||
try {
|
|
||||||
t.join();
|
|
||||||
} catch (InterruptedException ignored) { }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -562,8 +655,9 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public int submitDecodeUnit(byte[] frameData, int frameLength, int frameNumber, long receiveTimeMs) {
|
public int submitDecodeUnit(byte[] decodeUnitData, int decodeUnitLength, int decodeUnitType,
|
||||||
totalFrames++;
|
int frameNumber, long receiveTimeMs) {
|
||||||
|
totalFramesReceived++;
|
||||||
|
|
||||||
// We can receive the same "frame" multiple times if it's an IDR frame.
|
// We can receive the same "frame" multiple times if it's an IDR frame.
|
||||||
// In that case, each frame start NALU is submitted independently.
|
// In that case, each frame start NALU is submitted independently.
|
||||||
@@ -593,14 +687,12 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
lastTimestampUs = timestampUs;
|
lastTimestampUs = timestampUs;
|
||||||
|
|
||||||
int codecFlags = 0;
|
int codecFlags = 0;
|
||||||
boolean needsSpsReplay = false;
|
|
||||||
|
|
||||||
// H264 SPS
|
// H264 SPS
|
||||||
if (frameData[4] == 0x67) {
|
if (decodeUnitData[4] == 0x67) {
|
||||||
numSpsIn++;
|
numSpsIn++;
|
||||||
codecFlags |= MediaCodec.BUFFER_FLAG_CODEC_CONFIG;
|
|
||||||
|
|
||||||
ByteBuffer spsBuf = ByteBuffer.wrap(frameData);
|
ByteBuffer spsBuf = ByteBuffer.wrap(decodeUnitData);
|
||||||
|
|
||||||
// Skip to the start of the NALU data
|
// Skip to the start of the NALU data
|
||||||
spsBuf.position(5);
|
spsBuf.position(5);
|
||||||
@@ -693,102 +785,74 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
// Patch the SPS constraint flags
|
// Patch the SPS constraint flags
|
||||||
doProfileSpecificSpsPatching(sps);
|
doProfileSpecificSpsPatching(sps);
|
||||||
|
|
||||||
inputBufferIndex = dequeueInputBuffer();
|
|
||||||
if (inputBufferIndex < 0) {
|
|
||||||
// We're being torn down now
|
|
||||||
return MoonBridge.DR_NEED_IDR;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = getEmptyInputBuffer(inputBufferIndex);
|
|
||||||
if (buf == null) {
|
|
||||||
// We're being torn down now
|
|
||||||
return MoonBridge.DR_NEED_IDR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the annex B header
|
|
||||||
buf.put(frameData, 0, 5);
|
|
||||||
|
|
||||||
// The H264Utils.writeSPS function safely handles
|
// The H264Utils.writeSPS function safely handles
|
||||||
// Annex B NALUs (including NALUs with escape sequences)
|
// Annex B NALUs (including NALUs with escape sequences)
|
||||||
ByteBuffer escapedNalu = H264Utils.writeSPS(sps, frameLength);
|
ByteBuffer escapedNalu = H264Utils.writeSPS(sps, decodeUnitLength);
|
||||||
buf.put(escapedNalu);
|
|
||||||
|
|
||||||
if (queueInputBuffer(inputBufferIndex,
|
// Batch this to submit together with PPS
|
||||||
0, buf.position(),
|
spsBuffer = new byte[5 + escapedNalu.limit()];
|
||||||
timestampUs, codecFlags)) {
|
System.arraycopy(decodeUnitData, 0, spsBuffer, 0, 5);
|
||||||
return MoonBridge.DR_OK;
|
escapedNalu.get(spsBuffer, 5, escapedNalu.limit());
|
||||||
}
|
return MoonBridge.DR_OK;
|
||||||
else {
|
|
||||||
return MoonBridge.DR_NEED_IDR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// H264 PPS
|
|
||||||
} else if (frameData[4] == 0x68) {
|
|
||||||
numPpsIn++;
|
|
||||||
codecFlags |= MediaCodec.BUFFER_FLAG_CODEC_CONFIG;
|
|
||||||
|
|
||||||
inputBufferIndex = dequeueInputBuffer();
|
|
||||||
if (inputBufferIndex < 0) {
|
|
||||||
// We're being torn down now
|
|
||||||
return MoonBridge.DR_NEED_IDR;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = getEmptyInputBuffer(inputBufferIndex);
|
|
||||||
if (buf == null) {
|
|
||||||
// We're being torn down now
|
|
||||||
return MoonBridge.DR_NEED_IDR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needsBaselineSpsHack) {
|
|
||||||
LimeLog.info("Saw PPS; disabling SPS hack");
|
|
||||||
needsBaselineSpsHack = false;
|
|
||||||
|
|
||||||
// Give the decoder the SPS again with the proper profile now
|
|
||||||
needsSpsReplay = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (frameData[4] == 0x40) {
|
else if (decodeUnitType == MoonBridge.BUFFER_TYPE_VPS) {
|
||||||
numVpsIn++;
|
numVpsIn++;
|
||||||
|
|
||||||
// Batch this to submit together with SPS and PPS per AOSP docs
|
// Batch this to submit together with SPS and PPS per AOSP docs
|
||||||
vpsBuffer = new byte[frameLength];
|
vpsBuffer = new byte[decodeUnitLength];
|
||||||
System.arraycopy(frameData, 0, vpsBuffer, 0, frameLength);
|
System.arraycopy(decodeUnitData, 0, vpsBuffer, 0, decodeUnitLength);
|
||||||
return MoonBridge.DR_OK;
|
return MoonBridge.DR_OK;
|
||||||
}
|
}
|
||||||
else if (frameData[4] == 0x42) {
|
// Only the HEVC SPS hits this path (H.264 is handled above)
|
||||||
|
else if (decodeUnitType == MoonBridge.BUFFER_TYPE_SPS) {
|
||||||
numSpsIn++;
|
numSpsIn++;
|
||||||
|
|
||||||
// Batch this to submit together with VPS and PPS per AOSP docs
|
// Batch this to submit together with VPS and PPS per AOSP docs
|
||||||
spsBuffer = new byte[frameLength];
|
spsBuffer = new byte[decodeUnitLength];
|
||||||
System.arraycopy(frameData, 0, spsBuffer, 0, frameLength);
|
System.arraycopy(decodeUnitData, 0, spsBuffer, 0, decodeUnitLength);
|
||||||
return MoonBridge.DR_OK;
|
return MoonBridge.DR_OK;
|
||||||
}
|
}
|
||||||
else if (frameData[4] == 0x44) {
|
else if (decodeUnitType == MoonBridge.BUFFER_TYPE_PPS) {
|
||||||
numPpsIn++;
|
numPpsIn++;
|
||||||
|
|
||||||
inputBufferIndex = dequeueInputBuffer();
|
// If this is the first CSD blob or we aren't supporting
|
||||||
if (inputBufferIndex < 0) {
|
// adaptive playback, we will submit the CSD blob in a
|
||||||
// We're being torn down now
|
// separate input buffer.
|
||||||
return MoonBridge.DR_NEED_IDR;
|
if (!submittedCsd || !adaptivePlayback) {
|
||||||
}
|
inputBufferIndex = dequeueInputBuffer();
|
||||||
|
if (inputBufferIndex < 0) {
|
||||||
|
// We're being torn down now
|
||||||
|
return MoonBridge.DR_NEED_IDR;
|
||||||
|
}
|
||||||
|
|
||||||
buf = getEmptyInputBuffer(inputBufferIndex);
|
buf = getEmptyInputBuffer(inputBufferIndex);
|
||||||
if (buf == null) {
|
if (buf == null) {
|
||||||
// We're being torn down now
|
// We're being torn down now
|
||||||
return MoonBridge.DR_NEED_IDR;
|
return MoonBridge.DR_NEED_IDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When we get the PPS, submit the VPS and SPS together with
|
// When we get the PPS, submit the VPS and SPS together with
|
||||||
// the PPS, as required by AOSP docs on use of HEVC and MediaCodec.
|
// the PPS, as required by AOSP docs on use of MediaCodec.
|
||||||
if (vpsBuffer != null) {
|
if (vpsBuffer != null) {
|
||||||
buf.put(vpsBuffer);
|
buf.put(vpsBuffer);
|
||||||
}
|
}
|
||||||
if (spsBuffer != null) {
|
if (spsBuffer != null) {
|
||||||
buf.put(spsBuffer);
|
buf.put(spsBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the HEVC CSD blob
|
// This is the CSD blob
|
||||||
codecFlags |= MediaCodec.BUFFER_FLAG_CODEC_CONFIG;
|
codecFlags |= MediaCodec.BUFFER_FLAG_CODEC_CONFIG;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Batch this to submit together with the next I-frame
|
||||||
|
ppsBuffer = new byte[decodeUnitLength];
|
||||||
|
System.arraycopy(decodeUnitData, 0, ppsBuffer, 0, decodeUnitLength);
|
||||||
|
|
||||||
|
// Next call will be I-frame data
|
||||||
|
submitCsdNextCall = true;
|
||||||
|
|
||||||
|
return MoonBridge.DR_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
inputBufferIndex = dequeueInputBuffer();
|
inputBufferIndex = dequeueInputBuffer();
|
||||||
@@ -802,10 +866,24 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
// We're being torn down now
|
// We're being torn down now
|
||||||
return MoonBridge.DR_NEED_IDR;
|
return MoonBridge.DR_NEED_IDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (submitCsdNextCall) {
|
||||||
|
if (vpsBuffer != null) {
|
||||||
|
buf.put(vpsBuffer);
|
||||||
|
}
|
||||||
|
if (spsBuffer != null) {
|
||||||
|
buf.put(spsBuffer);
|
||||||
|
}
|
||||||
|
if (ppsBuffer != null) {
|
||||||
|
buf.put(ppsBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
submitCsdNextCall = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy data from our buffer list into the input buffer
|
// Copy data from our buffer list into the input buffer
|
||||||
buf.put(frameData, 0, frameLength);
|
buf.put(decodeUnitData, 0, decodeUnitLength);
|
||||||
|
|
||||||
if (!queueInputBuffer(inputBufferIndex,
|
if (!queueInputBuffer(inputBufferIndex,
|
||||||
0, buf.position(),
|
0, buf.position(),
|
||||||
@@ -813,12 +891,18 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
return MoonBridge.DR_NEED_IDR;
|
return MoonBridge.DR_NEED_IDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsSpsReplay) {
|
if ((codecFlags & MediaCodec.BUFFER_FLAG_CODEC_CONFIG) != 0) {
|
||||||
if (!replaySps()) {
|
submittedCsd = true;
|
||||||
return MoonBridge.DR_NEED_IDR;
|
|
||||||
}
|
|
||||||
|
|
||||||
LimeLog.info("SPS replay complete");
|
if (needsBaselineSpsHack) {
|
||||||
|
needsBaselineSpsHack = false;
|
||||||
|
|
||||||
|
if (!replaySps()) {
|
||||||
|
return MoonBridge.DR_NEED_IDR;
|
||||||
|
}
|
||||||
|
|
||||||
|
LimeLog.info("SPS replay complete");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return MoonBridge.DR_OK;
|
return MoonBridge.DR_OK;
|
||||||
@@ -883,55 +967,81 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getAverageEndToEndLatency() {
|
public int getAverageEndToEndLatency() {
|
||||||
if (totalFrames == 0) {
|
if (totalFramesReceived == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (int)(totalTimeMs / totalFrames);
|
return (int)(totalTimeMs / totalFramesReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAverageDecoderLatency() {
|
public int getAverageDecoderLatency() {
|
||||||
if (totalFrames == 0) {
|
if (totalFramesReceived == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (int)(decoderTimeMs / totalFrames);
|
return (int)(decoderTimeMs / totalFramesReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RendererException extends RuntimeException {
|
static class DecoderHungException extends RuntimeException {
|
||||||
private static final long serialVersionUID = 8985937536997012406L;
|
private int hangTimeMs;
|
||||||
|
|
||||||
private final Exception originalException;
|
DecoderHungException(int hangTimeMs) {
|
||||||
private final MediaCodecDecoderRenderer renderer;
|
this.hangTimeMs = hangTimeMs;
|
||||||
private ByteBuffer currentBuffer;
|
|
||||||
private int currentCodecFlags;
|
|
||||||
|
|
||||||
public RendererException(MediaCodecDecoderRenderer renderer, Exception e) {
|
|
||||||
this.renderer = renderer;
|
|
||||||
this.originalException = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RendererException(MediaCodecDecoderRenderer renderer, Exception e, ByteBuffer currentBuffer, int currentCodecFlags) {
|
|
||||||
this.renderer = renderer;
|
|
||||||
this.originalException = e;
|
|
||||||
this.currentBuffer = currentBuffer;
|
|
||||||
this.currentCodecFlags = currentCodecFlags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String str = "";
|
String str = "";
|
||||||
|
|
||||||
str += "Format: "+renderer.videoFormat+"\n";
|
str += "Hang time: "+hangTimeMs+" ms\n";
|
||||||
|
str += super.toString();
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class RendererException extends RuntimeException {
|
||||||
|
private static final long serialVersionUID = 8985937536997012406L;
|
||||||
|
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
RendererException(MediaCodecDecoderRenderer renderer, Exception e) {
|
||||||
|
this.text = generateText(renderer, e, null, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
RendererException(MediaCodecDecoderRenderer renderer, Exception e, ByteBuffer currentBuffer, int currentCodecFlags) {
|
||||||
|
this.text = generateText(renderer, e, currentBuffer, currentCodecFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String generateText(MediaCodecDecoderRenderer renderer, Exception originalException, ByteBuffer currentBuffer, int currentCodecFlags) {
|
||||||
|
String str = "";
|
||||||
|
|
||||||
|
str += "Format: "+String.format("%x", renderer.videoFormat)+"\n";
|
||||||
str += "AVC Decoder: "+((renderer.avcDecoder != null) ? renderer.avcDecoder.getName():"(none)")+"\n";
|
str += "AVC Decoder: "+((renderer.avcDecoder != null) ? renderer.avcDecoder.getName():"(none)")+"\n";
|
||||||
str += "HEVC Decoder: "+((renderer.hevcDecoder != null) ? renderer.hevcDecoder.getName():"(none)")+"\n";
|
str += "HEVC Decoder: "+((renderer.hevcDecoder != null) ? renderer.hevcDecoder.getName():"(none)")+"\n";
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && renderer.avcDecoder != null) {
|
||||||
|
Range<Integer> avcWidthRange = renderer.avcDecoder.getCapabilitiesForType("video/avc").getVideoCapabilities().getSupportedWidths();
|
||||||
|
str += "AVC supported width range: "+avcWidthRange.getLower()+" - "+avcWidthRange.getUpper()+"\n";
|
||||||
|
}
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && renderer.hevcDecoder != null) {
|
||||||
|
Range<Integer> hevcWidthRange = renderer.hevcDecoder.getCapabilitiesForType("video/hevc").getVideoCapabilities().getSupportedWidths();
|
||||||
|
str += "HEVC supported width range: "+hevcWidthRange.getLower()+" - "+hevcWidthRange.getUpper()+"\n";
|
||||||
|
}
|
||||||
|
str += "Adaptive playback: "+renderer.adaptivePlayback+"\n";
|
||||||
|
str += "GL Renderer: "+renderer.glRenderer+"\n";
|
||||||
str += "Build fingerprint: "+Build.FINGERPRINT+"\n";
|
str += "Build fingerprint: "+Build.FINGERPRINT+"\n";
|
||||||
|
str += "Foreground: "+renderer.foreground+"\n";
|
||||||
str += "Consecutive crashes: "+renderer.consecutiveCrashCount+"\n";
|
str += "Consecutive crashes: "+renderer.consecutiveCrashCount+"\n";
|
||||||
str += "Initial video dimensions: "+renderer.initialWidth+"x"+renderer.initialHeight+"\n";
|
str += "Video dimensions: "+renderer.initialWidth+"x"+renderer.initialHeight+"\n";
|
||||||
str += "FPS target: "+renderer.refreshRate+"\n";
|
str += "FPS target: "+renderer.refreshRate+"\n";
|
||||||
str += "Bitrate: "+renderer.bitrate+" Mbps \n";
|
str += "Bitrate: "+renderer.prefs.bitrate+" Mbps \n";
|
||||||
str += "In stats: "+renderer.numVpsIn+", "+renderer.numSpsIn+", "+renderer.numPpsIn+"\n";
|
str += "In stats: "+renderer.numVpsIn+", "+renderer.numSpsIn+", "+renderer.numPpsIn+"\n";
|
||||||
str += "Total frames: "+renderer.totalFrames+"\n";
|
str += "Total frames received: "+renderer.totalFramesReceived+"\n";
|
||||||
str += "Frame losses: "+renderer.framesLost+" in "+frameLossEvents+" loss events\n";
|
str += "Total frames rendered: "+renderer.totalFramesRendered+"\n";
|
||||||
str += "Average end-to-end client latency: "+getAverageEndToEndLatency()+"ms\n";
|
str += "Frame losses: "+renderer.framesLost+" in "+renderer.frameLossEvents+" loss events\n";
|
||||||
str += "Average hardware decoder latency: "+getAverageDecoderLatency()+"ms\n";
|
str += "Average end-to-end client latency: "+renderer.getAverageEndToEndLatency()+"ms\n";
|
||||||
|
str += "Average hardware decoder latency: "+renderer.getAverageDecoderLatency()+"ms\n";
|
||||||
|
|
||||||
if (currentBuffer != null) {
|
if (currentBuffer != null) {
|
||||||
str += "Current buffer: ";
|
str += "Current buffer: ";
|
||||||
@@ -945,6 +1055,20 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
|
|
||||||
str += "Is Exynos 4: "+renderer.isExynos4+"\n";
|
str += "Is Exynos 4: "+renderer.isExynos4+"\n";
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
if (originalException instanceof CodecException) {
|
||||||
|
CodecException ce = (CodecException) originalException;
|
||||||
|
|
||||||
|
str += "Diagnostic Info: "+ce.getDiagnosticInfo()+"\n";
|
||||||
|
str += "Recoverable: "+ce.isRecoverable()+"\n";
|
||||||
|
str += "Transient: "+ce.isTransient()+"\n";
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
str += "Codec Error Code: "+ce.getErrorCode()+"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
str += "/proc/cpuinfo:\n";
|
str += "/proc/cpuinfo:\n";
|
||||||
try {
|
try {
|
||||||
str += MediaCodecHelper.readCpuinfo();
|
str += MediaCodecHelper.readCpuinfo();
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ConfigurationInfo;
|
import android.content.pm.ConfigurationInfo;
|
||||||
@@ -27,7 +28,8 @@ public class MediaCodecHelper {
|
|||||||
|
|
||||||
private static final List<String> blacklistedDecoderPrefixes;
|
private static final List<String> blacklistedDecoderPrefixes;
|
||||||
private static final List<String> spsFixupBitstreamFixupDecoderPrefixes;
|
private static final List<String> spsFixupBitstreamFixupDecoderPrefixes;
|
||||||
private static final List<String> whitelistedAdaptiveResolutionPrefixes;
|
private static final List<String> blacklistedAdaptivePlaybackPrefixes;
|
||||||
|
private static final List<String> deprioritizedHevcDecoders;
|
||||||
private static final List<String> baselineProfileHackPrefixes;
|
private static final List<String> baselineProfileHackPrefixes;
|
||||||
private static final List<String> directSubmitPrefixes;
|
private static final List<String> directSubmitPrefixes;
|
||||||
private static final List<String> constrainedHighProfilePrefixes;
|
private static final List<String> constrainedHighProfilePrefixes;
|
||||||
@@ -35,6 +37,9 @@ public class MediaCodecHelper {
|
|||||||
private static final List<String> refFrameInvalidationAvcPrefixes;
|
private static final List<String> refFrameInvalidationAvcPrefixes;
|
||||||
private static final List<String> refFrameInvalidationHevcPrefixes;
|
private static final List<String> refFrameInvalidationHevcPrefixes;
|
||||||
|
|
||||||
|
private static boolean isLowEndSnapdragon = false;
|
||||||
|
private static boolean initialized = false;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
directSubmitPrefixes = new LinkedList<>();
|
directSubmitPrefixes = new LinkedList<>();
|
||||||
|
|
||||||
@@ -71,10 +76,8 @@ public class MediaCodecHelper {
|
|||||||
blacklistedDecoderPrefixes.add("AVCDecoder");
|
blacklistedDecoderPrefixes.add("AVCDecoder");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Without bitstream fixups, we perform horribly on NVIDIA's HEVC
|
// Never use ffmpeg decoders since they're software decoders
|
||||||
// decoder. While not strictly necessary, I'm going to fully blacklist this
|
blacklistedDecoderPrefixes.add("OMX.ffmpeg");
|
||||||
// one to avoid users getting inaccurate impressions of Tegra X1/Moonlight performance.
|
|
||||||
blacklistedDecoderPrefixes.add("OMX.Nvidia.h265.decode");
|
|
||||||
|
|
||||||
// Force these decoders disabled because:
|
// Force these decoders disabled because:
|
||||||
// 1) They are software decoders, so the performance is terrible
|
// 1) They are software decoders, so the performance is terrible
|
||||||
@@ -94,11 +97,10 @@ public class MediaCodecHelper {
|
|||||||
baselineProfileHackPrefixes = new LinkedList<>();
|
baselineProfileHackPrefixes = new LinkedList<>();
|
||||||
baselineProfileHackPrefixes.add("omx.intel");
|
baselineProfileHackPrefixes.add("omx.intel");
|
||||||
|
|
||||||
whitelistedAdaptiveResolutionPrefixes = new LinkedList<>();
|
// The Intel decoder on Lollipop on Nexus Player would increase latency badly
|
||||||
whitelistedAdaptiveResolutionPrefixes.add("omx.nvidia");
|
// if adaptive playback was enabled so let's avoid it to be safe.
|
||||||
whitelistedAdaptiveResolutionPrefixes.add("omx.qcom");
|
blacklistedAdaptivePlaybackPrefixes = new LinkedList<>();
|
||||||
whitelistedAdaptiveResolutionPrefixes.add("omx.sec");
|
blacklistedAdaptivePlaybackPrefixes.add("omx.intel");
|
||||||
whitelistedAdaptiveResolutionPrefixes.add("omx.TI");
|
|
||||||
|
|
||||||
constrainedHighProfilePrefixes = new LinkedList<>();
|
constrainedHighProfilePrefixes = new LinkedList<>();
|
||||||
constrainedHighProfilePrefixes.add("omx.intel");
|
constrainedHighProfilePrefixes.add("omx.intel");
|
||||||
@@ -115,8 +117,14 @@ public class MediaCodecHelper {
|
|||||||
// Exynos seems to be the only HEVC decoder that works reliably
|
// Exynos seems to be the only HEVC decoder that works reliably
|
||||||
whitelistedHevcDecoders.add("omx.exynos");
|
whitelistedHevcDecoders.add("omx.exynos");
|
||||||
|
|
||||||
// TODO: This needs a similar fixup to the Tegra 3 otherwise it buffers 16 frames
|
// On Darcy (Shield 2017), HEVC runs fine with no fixups required.
|
||||||
//whitelistedHevcDecoders.add("omx.nvidia");
|
// For some reason, other X1 implementations require bitstream fixups.
|
||||||
|
if (Build.DEVICE.equalsIgnoreCase("darcy")) {
|
||||||
|
whitelistedHevcDecoders.add("omx.nvidia");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// TODO: This needs a similar fixup to the Tegra 3 otherwise it buffers 16 frames
|
||||||
|
}
|
||||||
|
|
||||||
// Sony ATVs have broken MediaTek codecs (decoder hangs after rendering the first frame).
|
// Sony ATVs have broken MediaTek codecs (decoder hangs after rendering the first frame).
|
||||||
// I know the Fire TV 2 works, so I'll just whitelist Amazon devices which seem
|
// I know the Fire TV 2 works, so I'll just whitelist Amazon devices which seem
|
||||||
@@ -134,20 +142,55 @@ public class MediaCodecHelper {
|
|||||||
// during initialization to avoid SoCs with broken HEVC decoders.
|
// during initialization to avoid SoCs with broken HEVC decoders.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initializeWithContext(Context context) {
|
static {
|
||||||
|
deprioritizedHevcDecoders = new LinkedList<>();
|
||||||
|
|
||||||
|
// These are decoders that work but aren't used by default for various reasons.
|
||||||
|
|
||||||
|
// Qualcomm is currently the only decoders in this group.
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isLowEndSnapdragonRenderer(String glRenderer) {
|
||||||
|
glRenderer = glRenderer.toLowerCase().trim();
|
||||||
|
|
||||||
|
if (!glRenderer.contains("adreno")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pattern modelNumberPattern = Pattern.compile("(.*)([0-9]{3})(.*)");
|
||||||
|
|
||||||
|
Matcher matcher = modelNumberPattern.matcher(glRenderer);
|
||||||
|
if (!matcher.matches()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String modelNumber = matcher.group(2);
|
||||||
|
LimeLog.info("Found Adreno GPU: "+modelNumber);
|
||||||
|
|
||||||
|
// The current logic is to identify low-end SoCs based on a zero in the x0x place.
|
||||||
|
return modelNumber.charAt(1) == '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initialize(Context context, String glRenderer) {
|
||||||
|
if (initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ActivityManager activityManager =
|
ActivityManager activityManager =
|
||||||
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
ConfigurationInfo configInfo = activityManager.getDeviceConfigurationInfo();
|
ConfigurationInfo configInfo = activityManager.getDeviceConfigurationInfo();
|
||||||
if (configInfo.reqGlEsVersion != ConfigurationInfo.GL_ES_VERSION_UNDEFINED) {
|
if (configInfo.reqGlEsVersion != ConfigurationInfo.GL_ES_VERSION_UNDEFINED) {
|
||||||
LimeLog.info("OpenGL ES version: "+configInfo.reqGlEsVersion);
|
LimeLog.info("OpenGL ES version: "+configInfo.reqGlEsVersion);
|
||||||
|
|
||||||
|
isLowEndSnapdragon = isLowEndSnapdragonRenderer(glRenderer);
|
||||||
|
|
||||||
// Tegra K1 and later can do reference frame invalidation properly
|
// Tegra K1 and later can do reference frame invalidation properly
|
||||||
if (configInfo.reqGlEsVersion >= 0x30000) {
|
if (configInfo.reqGlEsVersion >= 0x30000) {
|
||||||
LimeLog.info("Added omx.nvidia to AVC reference frame invalidation support list");
|
LimeLog.info("Added omx.nvidia to AVC reference frame invalidation support list");
|
||||||
refFrameInvalidationAvcPrefixes.add("omx.nvidia");
|
refFrameInvalidationAvcPrefixes.add("omx.nvidia");
|
||||||
|
|
||||||
LimeLog.info("Added omx.qcom to AVC reference frame invalidation support list");
|
LimeLog.info("Added omx.qcom to AVC reference frame invalidation support list");
|
||||||
refFrameInvalidationAvcPrefixes.add("omx.qcom");
|
refFrameInvalidationAvcPrefixes.add("omx.qcom");
|
||||||
|
|
||||||
// Prior to M, we were tricking the decoder into using baseline profile, which
|
// Prior to M, we were tricking the decoder into using baseline profile, which
|
||||||
// won't support RFI properly.
|
// won't support RFI properly.
|
||||||
@@ -155,26 +198,36 @@ public class MediaCodecHelper {
|
|||||||
LimeLog.info("Added omx.intel to AVC reference frame invalidation support list");
|
LimeLog.info("Added omx.intel to AVC reference frame invalidation support list");
|
||||||
refFrameInvalidationAvcPrefixes.add("omx.intel");
|
refFrameInvalidationAvcPrefixes.add("omx.intel");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Qualcomm's early HEVC decoders break hard on our HEVC stream. The best check to
|
// Qualcomm's early HEVC decoders break hard on our HEVC stream. The best check to
|
||||||
// tell the good from the bad decoders are the generation of Adreno GPU included:
|
// tell the good from the bad decoders are the generation of Adreno GPU included:
|
||||||
// 3xx - bad
|
// 3xx - bad
|
||||||
// 4xx - good
|
// 4xx - good
|
||||||
//
|
//
|
||||||
// Unfortunately, it's not that easy to get that information here, so I'll use an
|
// Unfortunately, it's not that easy to get that information here, so I'll use an
|
||||||
// approximation by checking the GLES level (<= 3.0 is bad).
|
// approximation by checking the GLES level (<= 3.0 is bad).
|
||||||
if (configInfo.reqGlEsVersion > 0x30000) {
|
if (configInfo.reqGlEsVersion > 0x30000) {
|
||||||
// FIXME: We prefer reference frame invalidation support (which is only doable on AVC on
|
// We prefer reference frame invalidation support (which is only doable on AVC on
|
||||||
// older Qualcomm chips) vs. enabling HEVC by default. The user can override using the settings
|
// older Qualcomm chips) vs. enabling HEVC by default. The user can override using the settings
|
||||||
// to force HEVC on.
|
// to force HEVC on. If HDR or mobile data will be used, we'll override this and use
|
||||||
//LimeLog.info("Added omx.qcom to supported HEVC decoders based on GLES 3.1+ support");
|
// HEVC anyway.
|
||||||
//whitelistedHevcDecoders.add("omx.qcom");
|
LimeLog.info("Added omx.qcom to deprioritized HEVC decoders based on GLES 3.1+ support");
|
||||||
}
|
deprioritizedHevcDecoders.add("omx.qcom");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
blacklistedDecoderPrefixes.add("OMX.qcom.video.decoder.hevc");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isDecoderInList(List<String> decoderList, String decoderName) {
|
private static boolean isDecoderInList(List<String> decoderList, String decoderName) {
|
||||||
|
if (!initialized) {
|
||||||
|
throw new IllegalStateException("MediaCodecHelper must be initialized before use");
|
||||||
|
}
|
||||||
|
|
||||||
for (String badPrefix : decoderList) {
|
for (String badPrefix : decoderList) {
|
||||||
if (decoderName.length() >= badPrefix.length()) {
|
if (decoderName.length() >= badPrefix.length()) {
|
||||||
String prefix = decoderName.substring(0, badPrefix.length());
|
String prefix = decoderName.substring(0, badPrefix.length());
|
||||||
@@ -191,19 +244,14 @@ public class MediaCodecHelper {
|
|||||||
return System.nanoTime() / 1000000L;
|
return System.nanoTime() / 1000000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
public static boolean decoderSupportsAdaptivePlayback(MediaCodecInfo decoderInfo) {
|
||||||
public static boolean decoderSupportsAdaptivePlayback(String decoderName) {
|
|
||||||
/*
|
|
||||||
FIXME: Intel's decoder on Nexus Player forces the high latency path if adaptive playback is enabled
|
|
||||||
so we'll keep it off for now, since we don't know whether other devices also do the same
|
|
||||||
|
|
||||||
if (isDecoderInList(whitelistedAdaptiveResolutionPrefixes, decoderName)) {
|
|
||||||
LimeLog.info("Adaptive playback supported (whitelist)");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Possibly enable adaptive playback on KitKat and above
|
// Possibly enable adaptive playback on KitKat and above
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
|
if (isDecoderInList(blacklistedAdaptivePlaybackPrefixes, decoderInfo.getName())) {
|
||||||
|
LimeLog.info("Decoder blacklisted for adaptive playback");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (decoderInfo.getCapabilitiesForType("video/avc").
|
if (decoderInfo.getCapabilitiesForType("video/avc").
|
||||||
isFeatureSupported(CodecCapabilities.FEATURE_AdaptivePlayback))
|
isFeatureSupported(CodecCapabilities.FEATURE_AdaptivePlayback))
|
||||||
@@ -215,7 +263,7 @@ public class MediaCodecHelper {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Tolerate buggy codecs
|
// Tolerate buggy codecs
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -236,7 +284,11 @@ public class MediaCodecHelper {
|
|||||||
return isDecoderInList(baselineProfileHackPrefixes, decoderName);
|
return isDecoderInList(baselineProfileHackPrefixes, decoderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean decoderSupportsRefFrameInvalidationAvc(String decoderName) {
|
public static boolean decoderSupportsRefFrameInvalidationAvc(String decoderName, int videoHeight) {
|
||||||
|
// Reference frame invalidation is broken on low-end Snapdragon SoCs at 1080p.
|
||||||
|
if (videoHeight > 720 && isLowEndSnapdragon) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return isDecoderInList(refFrameInvalidationAvcPrefixes, decoderName);
|
return isDecoderInList(refFrameInvalidationAvcPrefixes, decoderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +296,7 @@ public class MediaCodecHelper {
|
|||||||
return isDecoderInList(refFrameInvalidationHevcPrefixes, decoderName);
|
return isDecoderInList(refFrameInvalidationHevcPrefixes, decoderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean decoderIsWhitelistedForHevc(String decoderName) {
|
public static boolean decoderIsWhitelistedForHevc(String decoderName, boolean meteredData, boolean willStreamHdr) {
|
||||||
// TODO: Shield Tablet K1/LTE?
|
// TODO: Shield Tablet K1/LTE?
|
||||||
//
|
//
|
||||||
// NVIDIA does partial HEVC acceleration on the Shield Tablet. I don't know
|
// NVIDIA does partial HEVC acceleration on the Shield Tablet. I don't know
|
||||||
@@ -276,6 +328,15 @@ public class MediaCodecHelper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some devices have HEVC decoders that we prefer not to use
|
||||||
|
// typically because it can't support reference frame invalidation.
|
||||||
|
// However, we will use it for HDR and for streaming over mobile networks
|
||||||
|
// since it works fine otherwise.
|
||||||
|
if ((meteredData || willStreamHdr) && isDecoderInList(deprioritizedHevcDecoders, decoderName)) {
|
||||||
|
LimeLog.info("Selected deprioritized decoder");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return isDecoderInList(whitelistedHevcDecoders, decoderName);
|
return isDecoderInList(whitelistedHevcDecoders, decoderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,6 +384,10 @@ public class MediaCodecHelper {
|
|||||||
// This is a different algorithm than the other findXXXDecoder functions,
|
// This is a different algorithm than the other findXXXDecoder functions,
|
||||||
// because we want to evaluate the decoders in our list's order
|
// because we want to evaluate the decoders in our list's order
|
||||||
// rather than MediaCodecList's order
|
// rather than MediaCodecList's order
|
||||||
|
|
||||||
|
if (!initialized) {
|
||||||
|
throw new IllegalStateException("MediaCodecHelper must be initialized before use");
|
||||||
|
}
|
||||||
|
|
||||||
for (String preferredDecoder : preferredDecoders) {
|
for (String preferredDecoder : preferredDecoders) {
|
||||||
for (MediaCodecInfo codecInfo : getMediaCodecList()) {
|
for (MediaCodecInfo codecInfo : getMediaCodecList()) {
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.limelight.preferences;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
public class GlPreferences {
|
||||||
|
private static final String PREF_NAME = "GlPreferences";
|
||||||
|
|
||||||
|
private static final String FINGERPRINT_PREF_STRING = "Fingerprint";
|
||||||
|
private static final String GL_RENDERER_PREF_STRING = "Renderer";
|
||||||
|
|
||||||
|
private SharedPreferences prefs;
|
||||||
|
public String glRenderer;
|
||||||
|
public String savedFingerprint;
|
||||||
|
|
||||||
|
private GlPreferences(SharedPreferences prefs) {
|
||||||
|
this.prefs = prefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GlPreferences readPreferences(Context context) {
|
||||||
|
SharedPreferences prefs = context.getSharedPreferences(PREF_NAME, 0);
|
||||||
|
GlPreferences glPrefs = new GlPreferences(prefs);
|
||||||
|
|
||||||
|
glPrefs.glRenderer = prefs.getString(GL_RENDERER_PREF_STRING, "");
|
||||||
|
glPrefs.savedFingerprint = prefs.getString(FINGERPRINT_PREF_STRING, "");
|
||||||
|
|
||||||
|
return glPrefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean writePreferences() {
|
||||||
|
return prefs.edit()
|
||||||
|
.putString(GL_RENDERER_PREF_STRING, glRenderer)
|
||||||
|
.putString(FINGERPRINT_PREF_STRING, savedFingerprint)
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,7 +22,11 @@ public class PreferenceConfiguration {
|
|||||||
private static final String USB_DRIVER_PREF_SRING = "checkbox_usb_driver";
|
private static final String USB_DRIVER_PREF_SRING = "checkbox_usb_driver";
|
||||||
private static final String VIDEO_FORMAT_PREF_STRING = "video_format";
|
private static final String VIDEO_FORMAT_PREF_STRING = "video_format";
|
||||||
private static final String ONSCREEN_CONTROLLER_PREF_STRING = "checkbox_show_onscreen_controls";
|
private static final String ONSCREEN_CONTROLLER_PREF_STRING = "checkbox_show_onscreen_controls";
|
||||||
|
private static final String ONLY_L3_R3_PREF_STRING = "checkbox_only_show_L3R3";
|
||||||
private static final String BATTERY_SAVER_PREF_STRING = "checkbox_battery_saver";
|
private static final String BATTERY_SAVER_PREF_STRING = "checkbox_battery_saver";
|
||||||
|
private static final String DISABLE_FRAME_DROP_PREF_STRING = "checkbox_disable_frame_drop";
|
||||||
|
private static final String ENABLE_HDR_PREF_STRING = "checkbox_enable_hdr";
|
||||||
|
private static final String ENABLE_PIP_PREF_STRING = "checkbox_enable_pip";
|
||||||
|
|
||||||
private static final int BITRATE_DEFAULT_720_30 = 5;
|
private static final int BITRATE_DEFAULT_720_30 = 5;
|
||||||
private static final int BITRATE_DEFAULT_720_60 = 10;
|
private static final int BITRATE_DEFAULT_720_60 = 10;
|
||||||
@@ -45,7 +49,11 @@ public class PreferenceConfiguration {
|
|||||||
private static final boolean DEFAULT_USB_DRIVER = true;
|
private static final boolean DEFAULT_USB_DRIVER = true;
|
||||||
private static final String DEFAULT_VIDEO_FORMAT = "auto";
|
private static final String DEFAULT_VIDEO_FORMAT = "auto";
|
||||||
private static final boolean ONSCREEN_CONTROLLER_DEFAULT = false;
|
private static final boolean ONSCREEN_CONTROLLER_DEFAULT = false;
|
||||||
|
private static final boolean ONLY_L3_R3_DEFAULT = false;
|
||||||
private static final boolean DEFAULT_BATTERY_SAVER = false;
|
private static final boolean DEFAULT_BATTERY_SAVER = false;
|
||||||
|
private static final boolean DEFAULT_DISABLE_FRAME_DROP = false;
|
||||||
|
private static final boolean DEFAULT_ENABLE_HDR = false;
|
||||||
|
private static final boolean DEFAULT_ENABLE_PIP = false;
|
||||||
|
|
||||||
public static final int FORCE_H265_ON = -1;
|
public static final int FORCE_H265_ON = -1;
|
||||||
public static final int AUTOSELECT_H265 = 0;
|
public static final int AUTOSELECT_H265 = 0;
|
||||||
@@ -59,7 +67,11 @@ public class PreferenceConfiguration {
|
|||||||
public String language;
|
public String language;
|
||||||
public boolean listMode, smallIconMode, multiController, enable51Surround, usbDriver;
|
public boolean listMode, smallIconMode, multiController, enable51Surround, usbDriver;
|
||||||
public boolean onscreenController;
|
public boolean onscreenController;
|
||||||
|
public boolean onlyL3R3;
|
||||||
public boolean batterySaver;
|
public boolean batterySaver;
|
||||||
|
public boolean disableFrameDrop;
|
||||||
|
public boolean enableHdr;
|
||||||
|
public boolean enablePip;
|
||||||
|
|
||||||
public static int getDefaultBitrate(String resFpsString) {
|
public static int getDefaultBitrate(String resFpsString) {
|
||||||
if (resFpsString.equals("720p30")) {
|
if (resFpsString.equals("720p30")) {
|
||||||
@@ -131,12 +143,13 @@ public class PreferenceConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void resetStreamingSettings(Context context) {
|
public static void resetStreamingSettings(Context context) {
|
||||||
// We consider resolution, FPS, bitrate, and video format as "streaming settings" here
|
// We consider resolution, FPS, bitrate, HDR, and video format as "streaming settings" here
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
prefs.edit()
|
prefs.edit()
|
||||||
.remove(BITRATE_PREF_STRING)
|
.remove(BITRATE_PREF_STRING)
|
||||||
.remove(RES_FPS_PREF_STRING)
|
.remove(RES_FPS_PREF_STRING)
|
||||||
.remove(VIDEO_FORMAT_PREF_STRING)
|
.remove(VIDEO_FORMAT_PREF_STRING)
|
||||||
|
.remove(ENABLE_HDR_PREF_STRING)
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +213,11 @@ public class PreferenceConfiguration {
|
|||||||
config.enable51Surround = prefs.getBoolean(ENABLE_51_SURROUND_PREF_STRING, DEFAULT_ENABLE_51_SURROUND);
|
config.enable51Surround = prefs.getBoolean(ENABLE_51_SURROUND_PREF_STRING, DEFAULT_ENABLE_51_SURROUND);
|
||||||
config.usbDriver = prefs.getBoolean(USB_DRIVER_PREF_SRING, DEFAULT_USB_DRIVER);
|
config.usbDriver = prefs.getBoolean(USB_DRIVER_PREF_SRING, DEFAULT_USB_DRIVER);
|
||||||
config.onscreenController = prefs.getBoolean(ONSCREEN_CONTROLLER_PREF_STRING, ONSCREEN_CONTROLLER_DEFAULT);
|
config.onscreenController = prefs.getBoolean(ONSCREEN_CONTROLLER_PREF_STRING, ONSCREEN_CONTROLLER_DEFAULT);
|
||||||
|
config.onlyL3R3 = prefs.getBoolean(ONLY_L3_R3_PREF_STRING, ONLY_L3_R3_DEFAULT);
|
||||||
config.batterySaver = prefs.getBoolean(BATTERY_SAVER_PREF_STRING, DEFAULT_BATTERY_SAVER);
|
config.batterySaver = prefs.getBoolean(BATTERY_SAVER_PREF_STRING, DEFAULT_BATTERY_SAVER);
|
||||||
|
config.disableFrameDrop = prefs.getBoolean(DISABLE_FRAME_DROP_PREF_STRING, DEFAULT_DISABLE_FRAME_DROP);
|
||||||
|
config.enableHdr = prefs.getBoolean(ENABLE_HDR_PREF_STRING, DEFAULT_ENABLE_HDR);
|
||||||
|
config.enablePip = prefs.getBoolean(ENABLE_PIP_PREF_STRING, DEFAULT_ENABLE_PIP);
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,23 @@ package com.limelight.preferences;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.media.MediaCodecInfo;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceCategory;
|
import android.preference.PreferenceCategory;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.util.Range;
|
||||||
|
import android.view.Display;
|
||||||
|
|
||||||
|
import com.limelight.LimeLog;
|
||||||
import com.limelight.PcView;
|
import com.limelight.PcView;
|
||||||
import com.limelight.R;
|
import com.limelight.R;
|
||||||
|
import com.limelight.binding.video.MediaCodecHelper;
|
||||||
import com.limelight.utils.UiHelper;
|
import com.limelight.utils.UiHelper;
|
||||||
|
|
||||||
public class StreamSettings extends Activity {
|
public class StreamSettings extends Activity {
|
||||||
@@ -50,6 +57,37 @@ public class StreamSettings extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class SettingsFragment extends PreferenceFragment {
|
public static class SettingsFragment extends PreferenceFragment {
|
||||||
|
|
||||||
|
private static void removeResolution(ListPreference pref, String prefix) {
|
||||||
|
int matchingCount = 0;
|
||||||
|
|
||||||
|
// Count the number of matching entries we'll be removing
|
||||||
|
for (CharSequence seq : pref.getEntryValues()) {
|
||||||
|
if (seq.toString().startsWith(prefix)) {
|
||||||
|
matchingCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the new arrays
|
||||||
|
CharSequence[] entries = new CharSequence[pref.getEntries().length-matchingCount];
|
||||||
|
CharSequence[] entryValues = new CharSequence[pref.getEntryValues().length-matchingCount];
|
||||||
|
int outIndex = 0;
|
||||||
|
for (int i = 0; i < pref.getEntryValues().length; i++) {
|
||||||
|
if (pref.getEntryValues()[i].toString().startsWith(prefix)) {
|
||||||
|
// Skip matching prefixes
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
entries[outIndex] = pref.getEntries()[i];
|
||||||
|
entryValues[outIndex] = pref.getEntryValues()[i];
|
||||||
|
outIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the preference with the new list
|
||||||
|
pref.setEntries(entries);
|
||||||
|
pref.setEntryValues(entryValues);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -65,6 +103,130 @@ public class StreamSettings extends Activity {
|
|||||||
screen.removePreference(category);
|
screen.removePreference(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove PiP mode on devices pre-Oreo
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||||
|
PreferenceCategory category =
|
||||||
|
(PreferenceCategory) findPreference("category_basic_settings");
|
||||||
|
category.removePreference(findPreference("checkbox_enable_pip"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide non-supported resolution/FPS combinations
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
Display display = getActivity().getWindowManager().getDefaultDisplay();
|
||||||
|
|
||||||
|
int maxSupportedResW = 0;
|
||||||
|
|
||||||
|
// Always allow resolutions that are smaller or equal to the active
|
||||||
|
// display resolution because decoders can report total non-sense to us.
|
||||||
|
// For example, a p201 device reports:
|
||||||
|
// AVC Decoder: OMX.amlogic.avc.decoder.awesome
|
||||||
|
// HEVC Decoder: OMX.amlogic.hevc.decoder.awesome
|
||||||
|
// AVC supported width range: 64 - 384
|
||||||
|
// HEVC supported width range: 64 - 544
|
||||||
|
for (Display.Mode candidate : display.getSupportedModes()) {
|
||||||
|
// Some devices report their dimensions in the portrait orientation
|
||||||
|
// where height > width. Normalize these to the conventional width > height
|
||||||
|
// arrangement before we process them.
|
||||||
|
|
||||||
|
int width = Math.max(candidate.getPhysicalWidth(), candidate.getPhysicalHeight());
|
||||||
|
int height = Math.min(candidate.getPhysicalWidth(), candidate.getPhysicalHeight());
|
||||||
|
|
||||||
|
if ((width >= 3840 || height >= 2160) && maxSupportedResW < 3840) {
|
||||||
|
maxSupportedResW = 3840;
|
||||||
|
}
|
||||||
|
else if ((width >= 1920 || height >= 1080) && maxSupportedResW < 1920) {
|
||||||
|
maxSupportedResW = 1920;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This must be called to do runtime initialization before calling functions that evaluate
|
||||||
|
// decoder lists.
|
||||||
|
MediaCodecHelper.initialize(getContext(), GlPreferences.readPreferences(getContext()).glRenderer);
|
||||||
|
|
||||||
|
MediaCodecInfo avcDecoder = MediaCodecHelper.findProbableSafeDecoder("video/avc", -1);
|
||||||
|
MediaCodecInfo hevcDecoder = MediaCodecHelper.findProbableSafeDecoder("video/hevc", -1);
|
||||||
|
|
||||||
|
if (avcDecoder != null) {
|
||||||
|
Range<Integer> avcWidthRange = avcDecoder.getCapabilitiesForType("video/avc").getVideoCapabilities().getSupportedWidths();
|
||||||
|
|
||||||
|
LimeLog.info("AVC supported width range: "+avcWidthRange.getLower()+" - "+avcWidthRange.getUpper());
|
||||||
|
|
||||||
|
// If 720p is not reported as supported, ignore all results from this API
|
||||||
|
if (avcWidthRange.contains(1280)) {
|
||||||
|
if (avcWidthRange.contains(3840) && maxSupportedResW < 3840) {
|
||||||
|
maxSupportedResW = 3840;
|
||||||
|
}
|
||||||
|
else if (avcWidthRange.contains(1920) && maxSupportedResW < 1920) {
|
||||||
|
maxSupportedResW = 1920;
|
||||||
|
}
|
||||||
|
else if (maxSupportedResW < 1280) {
|
||||||
|
maxSupportedResW = 1280;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hevcDecoder != null) {
|
||||||
|
Range<Integer> hevcWidthRange = hevcDecoder.getCapabilitiesForType("video/hevc").getVideoCapabilities().getSupportedWidths();
|
||||||
|
|
||||||
|
LimeLog.info("HEVC supported width range: "+hevcWidthRange.getLower()+" - "+hevcWidthRange.getUpper());
|
||||||
|
|
||||||
|
// If 720p is not reported as supported, ignore all results from this API
|
||||||
|
if (hevcWidthRange.contains(1280)) {
|
||||||
|
if (hevcWidthRange.contains(3840) && maxSupportedResW < 3840) {
|
||||||
|
maxSupportedResW = 3840;
|
||||||
|
}
|
||||||
|
else if (hevcWidthRange.contains(1920) && maxSupportedResW < 1920) {
|
||||||
|
maxSupportedResW = 1920;
|
||||||
|
}
|
||||||
|
else if (maxSupportedResW < 1280) {
|
||||||
|
maxSupportedResW = 1280;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LimeLog.info("Maximum resolution slot: "+maxSupportedResW);
|
||||||
|
|
||||||
|
ListPreference resPref = (ListPreference) findPreference("list_resolution_fps");
|
||||||
|
if (maxSupportedResW != 0) {
|
||||||
|
if (maxSupportedResW < 3840) {
|
||||||
|
// 4K is unsupported
|
||||||
|
removeResolution(resPref, "4K");
|
||||||
|
}
|
||||||
|
if (maxSupportedResW < 1920) {
|
||||||
|
// 1080p is unsupported
|
||||||
|
removeResolution(resPref, "1080p");
|
||||||
|
}
|
||||||
|
// Never remove 720p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove HDR preference for devices below Nougat
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||||
|
LimeLog.info("Excluding HDR toggle based on OS");
|
||||||
|
PreferenceCategory category =
|
||||||
|
(PreferenceCategory) findPreference("category_advanced_settings");
|
||||||
|
category.removePreference(findPreference("checkbox_enable_hdr"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Display display = getActivity().getWindowManager().getDefaultDisplay();
|
||||||
|
Display.HdrCapabilities hdrCaps = display.getHdrCapabilities();
|
||||||
|
|
||||||
|
// We must now ensure our display is compatible with HDR10
|
||||||
|
boolean foundHdr10 = false;
|
||||||
|
for (int hdrType : hdrCaps.getSupportedHdrTypes()) {
|
||||||
|
if (hdrType == Display.HdrCapabilities.HDR_TYPE_HDR10) {
|
||||||
|
foundHdr10 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundHdr10) {
|
||||||
|
LimeLog.info("Excluding HDR toggle based on display capabilities");
|
||||||
|
PreferenceCategory category =
|
||||||
|
(PreferenceCategory) findPreference("category_advanced_settings");
|
||||||
|
category.removePreference(findPreference("checkbox_enable_hdr"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add a listener to the FPS and resolution preference
|
// Add a listener to the FPS and resolution preference
|
||||||
// so the bitrate can be auto-adjusted
|
// so the bitrate can be auto-adjusted
|
||||||
Preference pref = findPreference(PreferenceConfiguration.RES_FPS_PREF_STRING);
|
Preference pref = findPreference(PreferenceConfiguration.RES_FPS_PREF_STRING);
|
||||||
|
|||||||
@@ -13,18 +13,18 @@ public class Dialog implements Runnable {
|
|||||||
private final String title;
|
private final String title;
|
||||||
private final String message;
|
private final String message;
|
||||||
private final Activity activity;
|
private final Activity activity;
|
||||||
private final boolean endAfterDismiss;
|
private final Runnable runOnDismiss;
|
||||||
|
|
||||||
private AlertDialog alert;
|
private AlertDialog alert;
|
||||||
|
|
||||||
private static final ArrayList<Dialog> rundownDialogs = new ArrayList<>();
|
private static final ArrayList<Dialog> rundownDialogs = new ArrayList<>();
|
||||||
|
|
||||||
private Dialog(Activity activity, String title, String message, boolean endAfterDismiss)
|
private Dialog(Activity activity, String title, String message, Runnable runOnDismiss)
|
||||||
{
|
{
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.endAfterDismiss = endAfterDismiss;
|
this.runOnDismiss = runOnDismiss;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void closeDialogs()
|
public static void closeDialogs()
|
||||||
@@ -40,9 +40,21 @@ public class Dialog implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void displayDialog(Activity activity, String title, String message, boolean endAfterDismiss)
|
public static void displayDialog(final Activity activity, String title, String message, final boolean endAfterDismiss)
|
||||||
{
|
{
|
||||||
activity.runOnUiThread(new Dialog(activity, title, message, endAfterDismiss));
|
activity.runOnUiThread(new Dialog(activity, title, message, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (endAfterDismiss) {
|
||||||
|
activity.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void displayDialog(Activity activity, String title, String message, Runnable runOnDismiss)
|
||||||
|
{
|
||||||
|
activity.runOnUiThread(new Dialog(activity, title, message, runOnDismiss));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -65,9 +77,7 @@ public class Dialog implements Runnable {
|
|||||||
alert.dismiss();
|
alert.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endAfterDismiss) {
|
runOnDismiss.run();
|
||||||
activity.finish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
alert.setButton(AlertDialog.BUTTON_NEUTRAL, activity.getResources().getText(R.string.help), new DialogInterface.OnClickListener() {
|
alert.setButton(AlertDialog.BUTTON_NEUTRAL, activity.getResources().getText(R.string.help), new DialogInterface.OnClickListener() {
|
||||||
@@ -77,9 +87,7 @@ public class Dialog implements Runnable {
|
|||||||
alert.dismiss();
|
alert.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endAfterDismiss) {
|
runOnDismiss.run();
|
||||||
activity.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
HelpLauncher.launchTroubleshooting(activity);
|
HelpLauncher.launchTroubleshooting(activity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,22 +2,42 @@ package com.limelight.utils;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
import com.limelight.HelpActivity;
|
import com.limelight.HelpActivity;
|
||||||
|
|
||||||
public class HelpLauncher {
|
public class HelpLauncher {
|
||||||
|
|
||||||
|
private static boolean isKnownBrowser(Context context, Intent i) {
|
||||||
|
ResolveInfo resolvedActivity = context.getPackageManager().resolveActivity(i, PackageManager.MATCH_DEFAULT_ONLY);
|
||||||
|
if (resolvedActivity == null) {
|
||||||
|
// No browser
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = resolvedActivity.activityInfo.name;
|
||||||
|
if (name == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
name = name.toLowerCase();
|
||||||
|
return name.contains("chrome") || name.contains("firefox");
|
||||||
|
}
|
||||||
|
|
||||||
private static void launchUrl(Context context, String url) {
|
private static void launchUrl(Context context, String url) {
|
||||||
// Try to launch the default browser
|
// Try to launch the default browser
|
||||||
try {
|
try {
|
||||||
// Fire TV devices will lie and say they do have a browser
|
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||||
// even though the OS just shows an error dialog if we
|
i.setData(Uri.parse(url));
|
||||||
// try to use it.
|
|
||||||
if (!"Amazon".equalsIgnoreCase(Build.MANUFACTURER)) {
|
// Several Android TV devices will lie and say they do have a browser
|
||||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
// even though the OS just shows an error dialog if we try to use it. We need to
|
||||||
i.setData(Uri.parse(url));
|
// be a bit more clever on these devices and detect if the browser is a legitimate
|
||||||
|
// browser or just a fake error message activity.
|
||||||
|
if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK) ||
|
||||||
|
isKnownBrowser(context, i)) {
|
||||||
context.startActivity(i);
|
context.startActivity(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class ServerHelper {
|
|||||||
intent.putExtra(Game.EXTRA_HOST, getCurrentAddressFromComputer(computer));
|
intent.putExtra(Game.EXTRA_HOST, getCurrentAddressFromComputer(computer));
|
||||||
intent.putExtra(Game.EXTRA_APP_NAME, app.getAppName());
|
intent.putExtra(Game.EXTRA_APP_NAME, app.getAppName());
|
||||||
intent.putExtra(Game.EXTRA_APP_ID, app.getAppId());
|
intent.putExtra(Game.EXTRA_APP_ID, app.getAppId());
|
||||||
|
intent.putExtra(Game.EXTRA_APP_HDR, app.isHdrSupported());
|
||||||
intent.putExtra(Game.EXTRA_UNIQUEID, managerBinder.getUniqueId());
|
intent.putExtra(Game.EXTRA_UNIQUEID, managerBinder.getUniqueId());
|
||||||
intent.putExtra(Game.EXTRA_STREAMING_REMOTE,
|
intent.putExtra(Game.EXTRA_STREAMING_REMOTE,
|
||||||
computer.reachability != ComputerDetails.Reachability.LOCAL);
|
computer.reachability != ComputerDetails.Reachability.LOCAL);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.app.AlertDialog;
|
|||||||
import android.app.UiModeManager;
|
import android.app.UiModeManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -58,6 +59,44 @@ public class UiHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showDecoderCrashDialog(Activity activity) {
|
||||||
|
final SharedPreferences prefs = activity.getSharedPreferences("DecoderTombstone", 0);
|
||||||
|
final int crashCount = prefs.getInt("CrashCount", 0);
|
||||||
|
int lastNotifiedCrashCount = prefs.getInt("LastNotifiedCrashCount", 0);
|
||||||
|
|
||||||
|
// Remember the last crash count we notified at, so we don't
|
||||||
|
// display the crash dialog every time the app is started until
|
||||||
|
// they stream again
|
||||||
|
if (crashCount != 0 && crashCount != lastNotifiedCrashCount) {
|
||||||
|
if (crashCount % 3 == 0) {
|
||||||
|
// At 3 consecutive crashes, we'll forcefully reset their settings
|
||||||
|
PreferenceConfiguration.resetStreamingSettings(activity);
|
||||||
|
Dialog.displayDialog(activity,
|
||||||
|
activity.getResources().getString(R.string.title_decoding_reset),
|
||||||
|
activity.getResources().getString(R.string.message_decoding_reset),
|
||||||
|
new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Mark notification as acknowledged on dismissal
|
||||||
|
prefs.edit().putInt("LastNotifiedCrashCount", crashCount).apply();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Dialog.displayDialog(activity,
|
||||||
|
activity.getResources().getString(R.string.title_decoding_error),
|
||||||
|
activity.getResources().getString(R.string.message_decoding_error),
|
||||||
|
new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Mark notification as acknowledged on dismissal
|
||||||
|
prefs.edit().putInt("LastNotifiedCrashCount", crashCount).apply();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void displayQuitConfirmationDialog(Activity parent, final Runnable onYes, final Runnable onNo) {
|
public static void displayQuitConfirmationDialog(Activity parent, final Runnable onYes, final Runnable onNo) {
|
||||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
# Application.mk for Limelight
|
# Application.mk for Moonlight
|
||||||
|
|
||||||
# Our minimum version is Android 4.1
|
# Our minimum version is Android 4.1
|
||||||
APP_PLATFORM := android-16
|
APP_PLATFORM := android-16
|
||||||
|
|
||||||
# Support all modern ABIs
|
|
||||||
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 mips mips64
|
|
||||||
|
|
||||||
# We want an optimized build
|
|
||||||
APP_OPTIM := release
|
|
||||||
|
|||||||
@@ -109,6 +109,8 @@
|
|||||||
<string name="category_on_screen_controls_settings">Configuración de controles en pantalla</string>
|
<string name="category_on_screen_controls_settings">Configuración de controles en pantalla</string>
|
||||||
<string name="title_checkbox_show_onscreen_controls">Mostrar controles en pantalla</string>
|
<string name="title_checkbox_show_onscreen_controls">Mostrar controles en pantalla</string>
|
||||||
<string name="summary_checkbox_show_onscreen_controls">Muestra controles virtuales superpuestos en la pantalla táctil</string>
|
<string name="summary_checkbox_show_onscreen_controls">Muestra controles virtuales superpuestos en la pantalla táctil</string>
|
||||||
|
<string name="title_only_l3r3">Solo muestra L3 y R3</string>
|
||||||
|
<string name="summary_only_l3r3">Ocultar todo excepto L3 y R3</string>
|
||||||
|
|
||||||
<string name="category_ui_settings">Configuración de la interfaz</string>
|
<string name="category_ui_settings">Configuración de la interfaz</string>
|
||||||
<string name="title_language_list">Idioma</string>
|
<string name="title_language_list">Idioma</string>
|
||||||
|
|||||||
@@ -120,6 +120,8 @@
|
|||||||
<string name="category_on_screen_controls_settings">Paramètres des contrôles à l\'écran</string>
|
<string name="category_on_screen_controls_settings">Paramètres des contrôles à l\'écran</string>
|
||||||
<string name="title_checkbox_show_onscreen_controls">Afficher les commandes à l\'écran</string>
|
<string name="title_checkbox_show_onscreen_controls">Afficher les commandes à l\'écran</string>
|
||||||
<string name="summary_checkbox_show_onscreen_controls">Afficher la superposition du contrôleur virtuel sur l\'écran tactile</string>
|
<string name="summary_checkbox_show_onscreen_controls">Afficher la superposition du contrôleur virtuel sur l\'écran tactile</string>
|
||||||
|
<string name="title_only_l3r3">Montre seulement L3 et R3</string>
|
||||||
|
<string name="summary_only_l3r3">Cacher tout sauf L3 et R3</string>
|
||||||
|
|
||||||
<string name="category_ui_settings">Paramètres de l\'interface utilisateur</string>
|
<string name="category_ui_settings">Paramètres de l\'interface utilisateur</string>
|
||||||
<string name="title_language_list">Langue</string>
|
<string name="title_language_list">Langue</string>
|
||||||
|
|||||||
@@ -110,6 +110,8 @@
|
|||||||
<string name="summary_checkbox_disable_warnings">Disable on-screen connection warning messages while streaming</string>
|
<string name="summary_checkbox_disable_warnings">Disable on-screen connection warning messages while streaming</string>
|
||||||
<string name="title_checkbox_battery_saver">Battery saver</string>
|
<string name="title_checkbox_battery_saver">Battery saver</string>
|
||||||
<string name="summary_checkbox_battery_saver">Uses less battery, but may increase stuttering</string>
|
<string name="summary_checkbox_battery_saver">Uses less battery, but may increase stuttering</string>
|
||||||
|
<string name="title_checkbox_enable_pip">Enable Picture-in-Picture observer mode</string>
|
||||||
|
<string name="summary_checkbox_enable_pip">Allows the stream to be viewed (but not controlled) while multitasking</string>
|
||||||
|
|
||||||
<string name="category_audio_settings">Audio Settings</string>
|
<string name="category_audio_settings">Audio Settings</string>
|
||||||
<string name="title_checkbox_51_surround">Enable 5.1 surround sound</string>
|
<string name="title_checkbox_51_surround">Enable 5.1 surround sound</string>
|
||||||
@@ -126,6 +128,8 @@
|
|||||||
<string name="category_on_screen_controls_settings">On-screen Controls Settings</string>
|
<string name="category_on_screen_controls_settings">On-screen Controls Settings</string>
|
||||||
<string name="title_checkbox_show_onscreen_controls">Show on-screen controls</string>
|
<string name="title_checkbox_show_onscreen_controls">Show on-screen controls</string>
|
||||||
<string name="summary_checkbox_show_onscreen_controls">Show virtual controller overlay on touchscreen</string>
|
<string name="summary_checkbox_show_onscreen_controls">Show virtual controller overlay on touchscreen</string>
|
||||||
|
<string name="title_only_l3r3">Only show L3 and R3</string>
|
||||||
|
<string name="summary_only_l3r3">Hide all virtual buttons except L3 and R3</string>
|
||||||
|
|
||||||
<string name="category_ui_settings">UI Settings</string>
|
<string name="category_ui_settings">UI Settings</string>
|
||||||
<string name="title_language_list">Language</string>
|
<string name="title_language_list">Language</string>
|
||||||
@@ -142,7 +146,11 @@
|
|||||||
<string name="summary_checkbox_host_audio">Play audio from the computer and this device</string>
|
<string name="summary_checkbox_host_audio">Play audio from the computer and this device</string>
|
||||||
|
|
||||||
<string name="category_advanced_settings">Advanced Settings</string>
|
<string name="category_advanced_settings">Advanced Settings</string>
|
||||||
|
<string name="title_disable_frame_drop">Never drop frames</string>
|
||||||
|
<string name="summary_disable_frame_drop">May reduce micro-stuttering on some devices, but can increase latency</string>
|
||||||
<string name="title_video_format">Change H.265 settings</string>
|
<string name="title_video_format">Change H.265 settings</string>
|
||||||
<string name="summary_video_format">H.265 lowers video bandwidth requirements but requires a very recent device.</string>
|
<string name="summary_video_format">H.265 lowers video bandwidth requirements but requires a very recent device</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 GTX 1000 series GPU or later.</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/category_basic_settings">
|
<PreferenceCategory android:title="@string/category_basic_settings"
|
||||||
|
android:key="category_basic_settings">
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="list_resolution_fps"
|
android:key="list_resolution_fps"
|
||||||
android:title="@string/title_resolution_list"
|
android:title="@string/title_resolution_list"
|
||||||
@@ -25,6 +26,11 @@
|
|||||||
android:title="@string/title_checkbox_battery_saver"
|
android:title="@string/title_checkbox_battery_saver"
|
||||||
android:summary="@string/summary_checkbox_battery_saver"
|
android:summary="@string/summary_checkbox_battery_saver"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="false" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="checkbox_enable_pip"
|
||||||
|
android:title="@string/title_checkbox_enable_pip"
|
||||||
|
android:summary="@string/summary_checkbox_enable_pip"
|
||||||
|
android:defaultValue="false" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/category_audio_settings">
|
<PreferenceCategory android:title="@string/category_audio_settings">
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
@@ -54,10 +60,17 @@
|
|||||||
<PreferenceCategory android:title="@string/category_on_screen_controls_settings"
|
<PreferenceCategory android:title="@string/category_on_screen_controls_settings"
|
||||||
android:key="category_onscreen_controls">
|
android:key="category_onscreen_controls">
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:defaultValue="false"
|
||||||
android:key="checkbox_show_onscreen_controls"
|
android:key="checkbox_show_onscreen_controls"
|
||||||
android:title="@string/title_checkbox_show_onscreen_controls"
|
|
||||||
android:summary="@string/summary_checkbox_show_onscreen_controls"
|
android:summary="@string/summary_checkbox_show_onscreen_controls"
|
||||||
android:defaultValue="false"/>
|
android:title="@string/title_checkbox_show_onscreen_controls" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="checkbox_only_show_L3R3"
|
||||||
|
android:summary="@string/summary_only_l3r3"
|
||||||
|
android:title="@string/title_only_l3r3" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/category_host_settings">
|
<PreferenceCategory android:title="@string/category_host_settings">
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
@@ -89,7 +102,8 @@
|
|||||||
android:summary="@string/summary_checkbox_list_mode"
|
android:summary="@string/summary_checkbox_list_mode"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="false" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/category_advanced_settings">
|
<PreferenceCategory android:title="@string/category_advanced_settings"
|
||||||
|
android:key="category_advanced_settings">
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="video_format"
|
android:key="video_format"
|
||||||
android:title="@string/title_video_format"
|
android:title="@string/title_video_format"
|
||||||
@@ -97,5 +111,15 @@
|
|||||||
android:entryValues="@array/video_format_values"
|
android:entryValues="@array/video_format_values"
|
||||||
android:summary="@string/summary_video_format"
|
android:summary="@string/summary_video_format"
|
||||||
android:defaultValue="auto" />
|
android:defaultValue="auto" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="checkbox_disable_frame_drop"
|
||||||
|
android:title="@string/title_disable_frame_drop"
|
||||||
|
android:summary="@string/summary_disable_frame_drop"
|
||||||
|
android:defaultValue="false" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="checkbox_enable_hdr"
|
||||||
|
android:title="@string/title_enable_hdr"
|
||||||
|
android:summary="@string/summary_enable_hdr"
|
||||||
|
android:defaultValue="false" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.0.0-beta5'
|
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -28,4 +28,7 @@ This file serves to document some of the decoder errata when using MediaCodec ha
|
|||||||
- Affected decoders: Intel decoder in Nexus Player (after Android 6.0)
|
- Affected decoders: Intel decoder in Nexus Player (after Android 6.0)
|
||||||
|
|
||||||
10. Some decoders actually suffer increased latency when max_dec_frame_buffering=1
|
10. Some decoders actually suffer increased latency when max_dec_frame_buffering=1
|
||||||
- Affected decoders: MediaTek decoder in Fire TV 2015
|
- Affected decoders: MediaTek decoder in Fire TV 2015
|
||||||
|
|
||||||
|
11. Attempting to use reference picture invalidation at 1080p causes the decoder to crash on low-end Snapdragon SoCs. 720p is unaffected.
|
||||||
|
- Affected decoders: Snapdragon 200, 410, 415, 430, 435, 616
|
||||||
|
|||||||
+1
-1
Submodule moonlight-common updated: ed35758291...bb75967467
Reference in New Issue
Block a user