Use an NvApp in the StreamConfiguration so it can be directly used by NvConnection

This commit is contained in:
Cameron Gutman 2015-02-27 14:08:39 -05:00
parent fb8fc54bb1
commit fcfcce88dd
4 changed files with 40 additions and 31 deletions

View File

@ -140,26 +140,25 @@ public class NvConnection {
return false; return false;
} }
NvApp app; NvApp app = context.streamConfig.getApp();
// If the client provided an exact app ID, use that to find the app object // If the client did not provide an exact app ID, do a lookup with the applist
if (context.streamConfig.getAppId() != StreamConfiguration.INVALID_APP_ID) { if (!context.streamConfig.getApp().isInitialized()) {
app = h.getAppById(context.streamConfig.getAppId());
}
else {
LimeLog.info("Using deprecated app lookup method - Please specify an app ID in your StreamConfiguration instead"); LimeLog.info("Using deprecated app lookup method - Please specify an app ID in your StreamConfiguration instead");
app = h.getAppByName(context.streamConfig.getAppName()); app = h.getAppByName(context.streamConfig.getApp().getAppName());
if (app == null) {
context.connListener.displayMessage("The app " + context.streamConfig.getApp().getAppName() + " is not in GFE app list");
return false;
}
} }
if (app == null) { // Update the running status of the app
context.connListener.displayMessage("The app " + context.streamConfig.getAppName() + " is not in GFE app list"); app.setIsRunning(h.getCurrentGame(serverInfo) == app.getAppId());
return false;
}
// If there's a game running, resume it // If there's a game running, resume it
if (h.getCurrentGame(serverInfo) != 0) { if (h.getCurrentGame(serverInfo) != 0) {
try { try {
if (h.getCurrentGame(serverInfo) == app.getAppId()) { if (app.getIsRunning()) {
if (!h.resumeApp(context)) { if (!h.resumeApp(context)) {
context.connListener.displayMessage("Failed to resume existing session"); context.connListener.displayMessage("Failed to resume existing session");
return false; return false;
@ -276,7 +275,7 @@ public class NvConnection {
if (currentStage == NvConnectionListener.Stage.LAUNCH_APP) { if (currentStage == NvConnectionListener.Stage.LAUNCH_APP) {
// Display the app name instead of the stage name // Display the app name instead of the stage name
currentStage.setName(context.streamConfig.getAppName()); currentStage.setName(context.streamConfig.getApp().getAppName());
} }
context.connListener.stageStarting(currentStage); context.connListener.stageStarting(currentStage);

View File

@ -1,10 +1,11 @@
package com.limelight.nvstream; package com.limelight.nvstream;
import com.limelight.nvstream.http.NvApp;
public class StreamConfiguration { public class StreamConfiguration {
public static final int INVALID_APP_ID = 0; public static final int INVALID_APP_ID = 0;
private String appName; private NvApp app;
private int appId = INVALID_APP_ID;
private int width, height; private int width, height;
private int refreshRate; private int refreshRate;
private int bitrate; private int bitrate;
@ -17,13 +18,8 @@ public class StreamConfiguration {
public static class Builder { public static class Builder {
private StreamConfiguration config = new StreamConfiguration(); private StreamConfiguration config = new StreamConfiguration();
public StreamConfiguration.Builder setApp(String app) { public StreamConfiguration.Builder setApp(NvApp app) {
config.appName = app; config.app = app;
return this;
}
public StreamConfiguration.Builder setAppId(int appId) {
config.appId = appId;
return this; return this;
} }
@ -75,7 +71,7 @@ public class StreamConfiguration {
private StreamConfiguration() { private StreamConfiguration() {
// Set default attributes // Set default attributes
this.appName = "Steam"; this.app = new NvApp("Steam");
this.width = 1280; this.width = 1280;
this.height = 720; this.height = 720;
this.refreshRate = 60; this.refreshRate = 60;
@ -105,12 +101,8 @@ public class StreamConfiguration {
return maxPacketSize; return maxPacketSize;
} }
public String getAppName() { public NvApp getApp() {
return appName; return app;
}
public int getAppId() {
return appId;
} }
public boolean getSops() { public boolean getSops() {

View File

@ -8,6 +8,19 @@ public class NvApp {
private boolean isRunning; private boolean isRunning;
private boolean initialized; private boolean initialized;
public NvApp() {
}
public NvApp(String appName) {
this.appName = appName;
}
public NvApp(String appName, int appId) {
this.appName = appName;
this.appId = appId;
}
public void setAppName(String appName) { public void setAppName(String appName) {
this.appName = appName; this.appName = appName;
} }
@ -21,11 +34,16 @@ public class NvApp {
} }
} }
public void setAppId(int appId) {
this.appId = appId;
this.initialized = true;
}
public void setIsRunning(String isRunning) { public void setIsRunning(String isRunning) {
this.isRunning = isRunning.equals("1"); this.isRunning = isRunning.equals("1");
} }
public void setIsRunningBoolean(boolean isRunning) { public void setIsRunning(boolean isRunning) {
this.isRunning = isRunning; this.isRunning = isRunning;
} }

View File

@ -321,7 +321,7 @@ public class NvHTTP {
public NvApp getAppByName(String appName) throws IOException, XmlPullParserException { public NvApp getAppByName(String appName) throws IOException, XmlPullParserException {
LinkedList<NvApp> appList = getAppList(); LinkedList<NvApp> appList = getAppList();
for (NvApp appFromList : appList) { for (NvApp appFromList : appList) {
if (appFromList.getAppName().equals(appName)) { if (appFromList.getAppName().equalsIgnoreCase(appName)) {
return appFromList; return appFromList;
} }
} }