boolean fullscreen = false;
int resolution = 720;
int refresh = 60;
Integer bitrate = null;
Preferences prefs = PreferencesManager.getPreferences();
// Save preferences to preserve possibly new unique ID
PreferencesManager.writePreferences(prefs);
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-pair")) {
if (i + 1 < args.length){
host = args[i+1];
System.out.println("Trying to pair to: " + host);
String msg = pair(prefs.getUniqueId(), host);
System.out.println("Pairing: " + msg);
System.exit(0);
} else {
System.err.println("Syntax error: hostname or ip address expected after -pair");
System.exit(4);
}
} else if (args[i].equals("-host")) {
if (i + 1 < args.length) {
host = args[i+1];
i++;
} else {
System.err.println("Syntax error: hostname or ip address expected after -host");
System.exit(3);
}
} else if (args[i].equals("-bitrate")) {
if (i + 1 < args.length){
bitrate = Integer.parseInt(args[i+1]);
i++;
} else {
System.err.println("Syntax error: bitrate (in Mbps) expected after -bitrate");
System.exit(3);
}
} else if (args[i].equals("-fs")) {
fullscreen = true;
} else if (args[i].equals("-720")) {
resolution = 720;
} else if (args[i].equals("-768")) {
resolution = 768;
} else if (args[i].equals("-900")) {
resolution = 900;
} else if (args[i].equals("-1080")) {
resolution = 1080;
} else if (args[i].equals("-30fps")) {
refresh = 30;
} else if (args[i].equals("-60fps")) {
refresh = 60;
} else {
System.out.println("Syntax Error: Unrecognized argument: " + args[i]);
}
}
if (host == null) {
System.out.println("Syntax Error: You must include a host. Use -host to specifiy a hostname or ip address.");
System.exit(5);
}
Resolution streamRes = Resolution.findRes(resolution, refresh);
if (bitrate == null) {
bitrate = streamRes.defaultBitrate;
}
StreamConfiguration streamConfig = createConfiguration(streamRes, bitrate);
prefs.setResolution(streamRes);
prefs.setBitrate(bitrate);
prefs.setFullscreen(fullscreen);
Limelight limelight = new Limelight(host);
limelight.startUp(streamConfig, prefs);
COMMAND_LINE_LAUNCH = true;
}