2015-11-06 18:15:26 +01:00
|
|
|
package com.ixab.StreamHandling;
|
|
|
|
|
|
|
|
|
|
import com.ixab.ConfigHandling.Config;
|
2015-11-09 20:09:55 +01:00
|
|
|
import com.ixab.GUI.MainWindow;
|
2015-11-30 17:34:20 +01:00
|
|
|
import com.ixab.Logging.Logger;
|
2015-11-06 18:15:26 +01:00
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
|
|
|
|
|
public class StreamOpener extends Thread {
|
|
|
|
|
private Config c;
|
2015-11-09 20:09:55 +01:00
|
|
|
private String streamName;
|
2015-11-06 18:15:26 +01:00
|
|
|
private String quality;
|
|
|
|
|
public StreamOpener(Config c, int streamIndex, String quality) {
|
|
|
|
|
this.c = c;
|
2015-11-09 20:09:55 +01:00
|
|
|
this.streamName = c.getStreamName(streamIndex);
|
2015-11-06 18:15:26 +01:00
|
|
|
this.quality = quality;
|
|
|
|
|
}
|
|
|
|
|
public void run() {
|
|
|
|
|
try {
|
2015-12-01 18:33:09 +01:00
|
|
|
Logger.print("Starting stream livestreamer for "+this.streamName+" at "+this.quality+" quality");
|
2015-11-06 18:15:26 +01:00
|
|
|
Runtime rt = Runtime.getRuntime();
|
2015-11-09 20:09:55 +01:00
|
|
|
Process pr = rt.exec(this.c.getLSPath()+" twitch.tv/"+this.streamName+" "+this.quality);
|
2015-11-06 18:15:26 +01:00
|
|
|
|
|
|
|
|
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
|
|
|
|
|
|
|
|
|
|
String line=null;
|
|
|
|
|
|
|
|
|
|
while((line=input.readLine()) != null) {
|
2015-11-30 17:34:20 +01:00
|
|
|
Logger.print(line, this);
|
2015-11-09 20:09:55 +01:00
|
|
|
// TODO: analyze livestreamer output and inform gui on errors
|
2015-11-06 18:15:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int exitVal = pr.waitFor();
|
2015-11-30 17:34:20 +01:00
|
|
|
Logger.print("Exited with error code " + exitVal, this);
|
2015-11-06 18:15:26 +01:00
|
|
|
|
|
|
|
|
} catch(Exception e) {
|
2015-11-30 17:34:20 +01:00
|
|
|
Logger.print(e.toString(), this);
|
2015-11-06 18:15:26 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|