mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 11:33:06 +00:00
Use a builder for StreamConfiguration to avoid further breaking changes to the constructor. Add support for local audio playback mode.
This commit is contained in:
parent
ae79f03e61
commit
b0169b0edf
@ -170,9 +170,7 @@ public class NvConnection {
|
|||||||
private boolean launchNotRunningApp(NvHTTP h, NvApp app)
|
private boolean launchNotRunningApp(NvHTTP h, NvApp app)
|
||||||
throws IOException, XmlPullParserException {
|
throws IOException, XmlPullParserException {
|
||||||
// Launch the app since it's not running
|
// Launch the app since it's not running
|
||||||
int gameSessionId = h.launchApp(app.getAppId(), config.getWidth(),
|
int gameSessionId = h.launchApp(app.getAppId(), riKey, riKeyId, config);
|
||||||
config.getHeight(), config.getRefreshRate(), riKey, config.getSops(),
|
|
||||||
riKeyId);
|
|
||||||
if (gameSessionId == 0) {
|
if (gameSessionId == 0) {
|
||||||
listener.displayMessage("Failed to launch application");
|
listener.displayMessage("Failed to launch application");
|
||||||
return false;
|
return false;
|
||||||
|
@ -7,25 +7,61 @@ public class StreamConfiguration {
|
|||||||
private int bitrate;
|
private int bitrate;
|
||||||
private boolean sops;
|
private boolean sops;
|
||||||
private boolean enableAdaptiveResolution;
|
private boolean enableAdaptiveResolution;
|
||||||
|
private boolean playLocalAudio;
|
||||||
|
|
||||||
public StreamConfiguration(String app, int width, int height, int refreshRate, int bitrate) {
|
public static class Builder {
|
||||||
this.app = app;
|
private StreamConfiguration config = new StreamConfiguration();
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
public StreamConfiguration.Builder setApp(String app) {
|
||||||
this.refreshRate = refreshRate;
|
config.app = app;
|
||||||
this.bitrate = bitrate;
|
return this;
|
||||||
this.sops = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamConfiguration(String app, int width, int height, int refreshRate, int bitrate, boolean sops,
|
public StreamConfiguration.Builder setResolution(int width, int height) {
|
||||||
boolean enableAdaptiveResolution) {
|
config.width = width;
|
||||||
this.app = app;
|
config.height = height;
|
||||||
this.width = width;
|
return this;
|
||||||
this.height = height;
|
}
|
||||||
this.refreshRate = refreshRate;
|
|
||||||
this.bitrate = bitrate;
|
public StreamConfiguration.Builder setRefreshRate(int refreshRate) {
|
||||||
this.sops = sops;
|
config.refreshRate = refreshRate;
|
||||||
this.enableAdaptiveResolution = enableAdaptiveResolution;
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StreamConfiguration.Builder setBitrate(int bitrate) {
|
||||||
|
config.bitrate = bitrate;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StreamConfiguration.Builder setEnableSops(boolean enable) {
|
||||||
|
config.sops = enable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StreamConfiguration.Builder enableAdaptiveResolution(boolean enable) {
|
||||||
|
config.enableAdaptiveResolution = enable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StreamConfiguration.Builder enableLocalAudioPlayback(boolean enable) {
|
||||||
|
config.playLocalAudio = enable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StreamConfiguration build() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private StreamConfiguration() {
|
||||||
|
// Set default attributes
|
||||||
|
this.app = "Steam";
|
||||||
|
this.width = 1280;
|
||||||
|
this.height = 720;
|
||||||
|
this.refreshRate = 60;
|
||||||
|
this.bitrate = 10000;
|
||||||
|
this.sops = true;
|
||||||
|
this.enableAdaptiveResolution = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
@ -59,4 +95,8 @@ public class StreamConfiguration {
|
|||||||
public boolean getAdaptiveResolutionEnabled() {
|
public boolean getAdaptiveResolutionEnabled() {
|
||||||
return enableAdaptiveResolution;
|
return enableAdaptiveResolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getPlayLocalAudio() {
|
||||||
|
return playLocalAudio;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
import org.xmlpull.v1.XmlPullParserFactory;
|
||||||
|
|
||||||
|
import com.limelight.nvstream.StreamConfiguration;
|
||||||
import com.limelight.nvstream.http.PairingManager.PairState;
|
import com.limelight.nvstream.http.PairingManager.PairState;
|
||||||
|
|
||||||
|
|
||||||
@ -278,14 +279,15 @@ public class NvHTTP {
|
|||||||
return new String(hexChars);
|
return new String(hexChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int launchApp(int appId, int width, int height, int refreshRate, SecretKey inputKey, boolean sops, int riKeyId) throws IOException, XmlPullParserException {
|
public int launchApp(int appId, SecretKey inputKey, int riKeyId, StreamConfiguration config) throws IOException, XmlPullParserException {
|
||||||
InputStream in = openHttpConnection(baseUrl +
|
InputStream in = openHttpConnection(baseUrl +
|
||||||
"/launch?uniqueid=" + uniqueId +
|
"/launch?uniqueid=" + uniqueId +
|
||||||
"&appid=" + appId +
|
"&appid=" + appId +
|
||||||
"&mode=" + width + "x" + height + "x" + refreshRate +
|
"&mode=" + config.getWidth() + "x" + config.getHeight() + "x" + config.getRefreshRate() +
|
||||||
"&additionalStates=1&sops=" + (sops ? 1 : 0) +
|
"&additionalStates=1&sops=" + (config.getSops() ? 1 : 0) +
|
||||||
"&rikey="+bytesToHex(inputKey.getEncoded()) +
|
"&rikey="+bytesToHex(inputKey.getEncoded()) +
|
||||||
"&rikeyid="+riKeyId, false);
|
"&rikeyid="+riKeyId +
|
||||||
|
"&localAudioPlayMode=" + (config.getPlayLocalAudio() ? 1 : 0), false);
|
||||||
String gameSession = getXmlString(in, "gamesession");
|
String gameSession = getXmlString(in, "gamesession");
|
||||||
return Integer.parseInt(gameSession);
|
return Integer.parseInt(gameSession);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user