mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 19:42:45 +00:00
Use App IDs for app lookups and deprecate the old name-based lookup function
This commit is contained in:
parent
a4ec619e5a
commit
fb8fc54bb1
@ -139,10 +139,20 @@ public class NvConnection {
|
||||
context.connListener.displayMessage("Device not paired with computer");
|
||||
return false;
|
||||
}
|
||||
|
||||
NvApp app = h.getApp(context.streamConfig.getApp());
|
||||
|
||||
NvApp app;
|
||||
|
||||
// If the client provided an exact app ID, use that to find the app object
|
||||
if (context.streamConfig.getAppId() != StreamConfiguration.INVALID_APP_ID) {
|
||||
app = h.getAppById(context.streamConfig.getAppId());
|
||||
}
|
||||
else {
|
||||
LimeLog.info("Using deprecated app lookup method - Please specify an app ID in your StreamConfiguration instead");
|
||||
app = h.getAppByName(context.streamConfig.getAppName());
|
||||
}
|
||||
|
||||
if (app == null) {
|
||||
context.connListener.displayMessage("The app " + context.streamConfig.getApp() + " is not in GFE app list");
|
||||
context.connListener.displayMessage("The app " + context.streamConfig.getAppName() + " is not in GFE app list");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -266,7 +276,7 @@ public class NvConnection {
|
||||
|
||||
if (currentStage == NvConnectionListener.Stage.LAUNCH_APP) {
|
||||
// Display the app name instead of the stage name
|
||||
currentStage.setName(context.streamConfig.getApp());
|
||||
currentStage.setName(context.streamConfig.getAppName());
|
||||
}
|
||||
|
||||
context.connListener.stageStarting(currentStage);
|
||||
|
@ -1,7 +1,10 @@
|
||||
package com.limelight.nvstream;
|
||||
|
||||
public class StreamConfiguration {
|
||||
private String app;
|
||||
public static final int INVALID_APP_ID = 0;
|
||||
|
||||
private String appName;
|
||||
private int appId = INVALID_APP_ID;
|
||||
private int width, height;
|
||||
private int refreshRate;
|
||||
private int bitrate;
|
||||
@ -15,7 +18,12 @@ public class StreamConfiguration {
|
||||
private StreamConfiguration config = new StreamConfiguration();
|
||||
|
||||
public StreamConfiguration.Builder setApp(String app) {
|
||||
config.app = app;
|
||||
config.appName = app;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StreamConfiguration.Builder setAppId(int appId) {
|
||||
config.appId = appId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -67,7 +75,7 @@ public class StreamConfiguration {
|
||||
|
||||
private StreamConfiguration() {
|
||||
// Set default attributes
|
||||
this.app = "Steam";
|
||||
this.appName = "Steam";
|
||||
this.width = 1280;
|
||||
this.height = 720;
|
||||
this.refreshRate = 60;
|
||||
@ -97,8 +105,12 @@ public class StreamConfiguration {
|
||||
return maxPacketSize;
|
||||
}
|
||||
|
||||
public String getApp() {
|
||||
return app;
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public int getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public boolean getSops() {
|
||||
|
@ -304,11 +304,24 @@ public class NvHTTP {
|
||||
return Integer.parseInt(game);
|
||||
}
|
||||
|
||||
public NvApp getApp(String app) throws IOException,
|
||||
XmlPullParserException {
|
||||
public NvApp getAppById(int appId) throws IOException, XmlPullParserException {
|
||||
LinkedList<NvApp> appList = getAppList();
|
||||
for (NvApp appFromList : appList) {
|
||||
if (appFromList.getAppName().equals(app)) {
|
||||
if (appFromList.getAppId() == appId) {
|
||||
return appFromList;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* NOTE: Only use this function if you know what you're doing.
|
||||
* It's totally valid to have two apps named the same thing,
|
||||
* or even nothing at all! Look apps up by ID if at all possible
|
||||
* using the above function */
|
||||
public NvApp getAppByName(String appName) throws IOException, XmlPullParserException {
|
||||
LinkedList<NvApp> appList = getAppList();
|
||||
for (NvApp appFromList : appList) {
|
||||
if (appFromList.getAppName().equals(appName)) {
|
||||
return appFromList;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user