summaryrefslogtreecommitdiff
path: root/src/YalpOutputs/YalpVlcTelnetOutput/YalpOutputPluginImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/YalpOutputs/YalpVlcTelnetOutput/YalpOutputPluginImpl.java')
-rw-r--r--src/YalpOutputs/YalpVlcTelnetOutput/YalpOutputPluginImpl.java460
1 files changed, 240 insertions, 220 deletions
diff --git a/src/YalpOutputs/YalpVlcTelnetOutput/YalpOutputPluginImpl.java b/src/YalpOutputs/YalpVlcTelnetOutput/YalpOutputPluginImpl.java
index 50bdaa4..fee8de5 100644
--- a/src/YalpOutputs/YalpVlcTelnetOutput/YalpOutputPluginImpl.java
+++ b/src/YalpOutputs/YalpVlcTelnetOutput/YalpOutputPluginImpl.java
@@ -19,6 +19,9 @@ import org.omg.CORBA.*;
import java.util.*;
import java.io.IOException;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+
/*
* Class YalpOutputPluginImpl
*
@@ -39,6 +42,17 @@ public class YalpOutputPluginImpl extends OutputPluginInterfacePOA {
private ServerControlInterface srvCon;
private PluginInfo pluginInfo;
+ private String log4jFile = "log4j_output_plugin.conf";
+
+ private static Logger logger =
+ Logger.getLogger("Yalp.OutputPlugins.VlcTelnetOutput.YalpOutputPluginImpl");
+
+ public YalpOutputPluginImpl()
+ {
+ PropertyConfigurator.configureAndWatch(log4jFile);
+ logger.debug("YalpOutputPluginImpl()");
+ }
+
/*
* starts a vlc player in a new process
*
@@ -53,6 +67,9 @@ public class YalpOutputPluginImpl extends OutputPluginInterfacePOA {
* @throws ClassNotFoundException
*/
public void setORB(ORB _orb) {
+
+ logger.debug("setORB()");
+
orb = _orb;
pluginInfo = new PluginInfo();
@@ -82,6 +99,7 @@ public class YalpOutputPluginImpl extends OutputPluginInterfacePOA {
}
public void shutdown() {
+ logger.debug("shutdown()");
/* t.b.d. */
}
@@ -93,6 +111,20 @@ public class YalpOutputPluginImpl extends OutputPluginInterfacePOA {
*/
public void control(OutputHolder howtoStream, YalpErrorHolder err) {
+ logger.debug("control(howtoStream.value.id: "+howtoStream.value.id+")");
+
+ YalpError error = new YalpError();
+ error.descr = "";
+ error.msg = "";
+ error.code = YalpErrorCode.OK;
+ error.level = YalpErrorLevel.ERROR_LEVEL_DEBUG;
+
+ err.value = error;
+
+ Output output = new Output();
+ output = howtoStream.value;
+ howtoStream.value = output;
+
switch( howtoStream.value.outputAction.value() ) {
case Action._START:
@@ -134,6 +166,7 @@ public class YalpOutputPluginImpl extends OutputPluginInterfacePOA {
*/
public void getInfo(PluginInfoHolder info, YalpErrorHolder err)
{
+ logger.debug("getInfo()");
info = new PluginInfoHolder();
err = new YalpErrorHolder();
err.value.code = YalpErrorCode.OK;
@@ -141,6 +174,35 @@ public class YalpOutputPluginImpl extends OutputPluginInterfacePOA {
}
/*
+ * register Stream at vlcPlayer
+ * @param howtoStream
+ */
+ private void add(Output howtoStream){
+
+ logger.debug("add()");
+
+ String input = "";
+ TelnetInterface telnet = new TelnetInterface(hostIP, 4212, "admin");
+
+ input += "new "+howtoStream.info.name+" broadcast";
+
+ for(int i=0; i < howtoStream.playlist.length; i++){
+ input += " input ";
+ input += howtoStream.playlist[i].path + "/";
+ input += howtoStream.playlist[i].fileName;
+ }
+ telnet.exec(input);
+
+ input = "setup " + howtoStream.info.name + " enabled";
+ telnet.exec(input);
+
+ input = "setup " + howtoStream.info.name + " loop";
+ telnet.exec(input);
+
+ telnet.close();
+}
+
+/*
* request Streaming of submitted Output
*
* @param stream
@@ -148,224 +210,182 @@ public class YalpOutputPluginImpl extends OutputPluginInterfacePOA {
* @return Output
* extends Information "how to receive" of submitted Output
*/
- public Output request(Output stream) {
- //stream.setIP(hostIP); for UDP
- stream.info.name = streamName();
- stream.info.params = new Integer(++startPort).toString();
- currentStreams.add(stream);
- return stream;
- }
-
-
- /**
- * starts streaming of submitted streamInfo
- * @param howtoStream
- */
- private void start(Output howtoStream){
- /*
- String newString, setup2;
- this.streamCounter.actualStreams++;
- this.streamCounter.allStreams++;
-
- switch (howtoStream.info.type.value()){
- case AccessType._VOD:
- newString = "new "+howtoStream.info.name+" vod enabled";
- break;
- case AccessType._BROADCAST:
- newString = "new "+howtoStream.info.name+" broadcast enabled";
- break;
- default:
- newString ="";
- System.out.println("server.VlcStreamer.start: unsupported Type");
- break;
- }
-
- String comp = "#transcode{vcodec=mp2v,vb=1024,scale=1,acodec=mpga,ab=192,channels=2}:duplicate{dst=";
-
- setup2 = "setup "+howtoStream.info.name+" output "+comp+"std{";
-
- switch (howtoStream.access_type.value()){
- case Access._STREAM:
- setup2 += "access=http,";
- break;
- case Access._UDP:
- setup2 += "access=udp,";
- break;
- default:
- System.out.println("server.VlcStreamer.start: unsupported Accesstype");
- break;
- }
-
- switch (howtoStream.mux_type.value()){
- case Mux._TS:
- setup2 += "mux=ts,url="+howtoStream.ip+":"+howtoStream.port+"}";
- break;
- case Mux._ES:
- setup2 += "mux=es,url="+howtoStream.ip+":"+howtoStream.port+"}";
- break;
- case Mux._OGG:
- setup2 += "mux=ogg,url="+howtoStream.ip+":"+howtoStream.port+"}";
- break;
- default:
- System.out.println("server.VlcStreamer.start: unsupported Muxer");
- break;
- }
-
- // DEBUG COMP
- setup2 += "}";
-
- String control = "control "+howtoStream.info.name+" play";
-
- // telnet connection
- TelnetInterface telnet = new TelnetInterface(hostIP, 4212, "admin");
-
- // execute telnet commands
- telnet.exec(newString);
-
- // Playlist
- String input = "";
- for(int i=0; i < howtoStream.list.length; i++){
- input = "setup "+howtoStream.info.name+" ";
- String fileItem = howtoStream.list[i];
- fileItem.replace(" ", "\\ ");
- input += fileItem;
- telnet.exec(input);
- }
-
- telnet.exec(setup2);
- telnet.exec(control);
-
- // close telnet connection
- telnet.close();
- */
- }
-
- /**
- * plays submitted streamInfo
- * @param howtoStream
- */
- private void play(Output howtoStream){
-
- String control = "control "+howtoStream.info.name+" play";
-
- // telnet connection
- TelnetInterface telnet = new TelnetInterface(hostIP, 4212, "admin");
-
- telnet.exec(control);
-
- // close telnet connection
- telnet.close();
- }
-
- /**
- * pause submitted streamInfo
- * @param howtoStream
- */
- private void pause(Output howtoStream){
-
- String control = "control "+howtoStream.info.name+" pause";
-
- // DEBUG
- System.out.println("client.VlcStreamer: Telnetcmd: ");
- System.out.println(control);
-
- // telnet connection
- TelnetInterface telnet = new TelnetInterface(hostIP, 4212, "admin");
-
- telnet.exec(control);
-
- // close telnet connection
- telnet.close();
- }
-
- /**
- * go to next file in playlist
- *
- * @param howtoStream
- */
- private void next(Output howtoStream){
-
- String control = "control "+howtoStream.info.name+" seek 100";
-
- // DEBUG
- System.out.println("client.VlcStreamer: Telnetcmd: ");
- System.out.println(control);
-
- // telnet connection
- TelnetInterface telnet = new TelnetInterface(hostIP, 4212, "admin");
-
- telnet.exec(control);
-
- // close telnet connection
- telnet.close();
- }
-
- /**
- * stop streaming, delete stream
- *
- * @param howtoStream
- */
- private void stop(Output howtoStream){
-
- String del = "del "+howtoStream.info.name;
- this.streamCounter.actualStreams--;
-
- // telnet connection
- TelnetInterface telnet = new TelnetInterface(hostIP, 4212, "admin");
-
- telnet.exec(del);
-
- // close telnet connection
- telnet.close();
-
- currentStreams.remove(howtoStream);
- }
-
- /**
- * register Stream at vlcPlayer
- * @param howtoStream
- */
- private void add(Output howtoStream){
-
- String input = "";
-
- // telnet connection
- TelnetInterface telnet = new TelnetInterface(hostIP, 4212, "admin");
-
- for(int i=0; i < howtoStream.playlist.length; i++){
- input += "setup "+howtoStream.info.name+" ";
- input += howtoStream.playlist[i];
- telnet.exec(input);
- input = "";
- }
- telnet.close();
- }
-
- /**
- * calculates streamName
- * @return String streamName
- */
-
- private String streamName(){
- String streamName = "stream";
- streamName += streamCounter.allStreams;
- return streamName;
- }
-
- /**
- * stops the streaming server
- *
- */
-
- public void quit(){
- vlcPlayer.destroy();
- }
-
- /**
- * returns the streamcounter
- * @return StreamCounter
- */
- public StreamCounter getStreamCounter(){
- return this.streamCounter;
- }
+ public Output request(Output stream) {
+
+ logger.debug("request()");
+
+ //stream.setIP(hostIP); for UDP
+ stream.info.name = streamName();
+ stream.info.params = new Integer(++startPort).toString();
+ currentStreams.add(stream);
+ return stream;
+ }
+
+
+/*
+ * starts streaming of submitted streamInfo
+ * @param howtoStream
+ */
+ private void start(Output howtoStream) {
+
+ logger.debug("start()");
+
+ String newString, setup2;
+ streamCounter.actualStreams++;
+ streamCounter.allStreams++;
+
+ switch (howtoStream.info.type.value()) {
+ case AccessType._STREAM:
+ newString = "control "+howtoStream.info.name+" vod enabled";
+ break;
+ /*
+ case AccessType._BROADCAST:
+ newString = "new "+howtoStream.info.name+" broadcast enabled";
+ break;
+ */
+ default:
+ newString ="";
+ System.out.println("server.VlcStreamer.start: unsupported Type");
+ break;
+ }
+
+ String comp = "#transcode{vcodec=mp2v,vb=1024,scale=1,acodec=mpga,ab=192,channels=2}:duplicate{dst=";
+
+ setup2 = "setup "+howtoStream.info.name+" output "+comp+"std{";
+/*
+ switch (howtoStream.access_type.value()){
+ case Access._STREAM:
+ setup2 += "access=http,";
+ break;
+ case Access._UDP:
+*/
+ setup2 += "access=udp,";
+/*
+ break;
+ default:
+ System.out.println("server.VlcStreamer.start: unsupported Accesstype");
+ break;
+ }
+
+ switch (howtoStream.mux_type.value()){
+ case Mux._TS:
+*/
+ setup2 += "mux=es,url=" + howtoStream.destIp + ":";
+ setup2 += /*howtoStream.info.params +*/ "9993}";
+/* break;
+ case Mux._ES:
+ setup2 += "mux=es,url="+howtoStream.ip+":"+howtoStream.port+"}";
+ break;
+ case Mux._OGG:
+ setup2 += "mux=ogg,url="+howtoStream.ip+":"+howtoStream.port+"}";
+ break;
+ default:
+ System.out.println("server.VlcStreamer.start: unsupported Muxer");
+ break;
+ }
+*/
+ setup2 += "}";
+
+ String control = "control "+howtoStream.info.name+" play";
+ TelnetInterface telnet = new TelnetInterface(hostIP, 4212, "admin");
+ telnet.exec(newString);
+ telnet.exec(setup2);
+ telnet.exec(control);
+ telnet.close();
+ }
+
+/*
+ * plays submitted streamInfo
+ * @param howtoStream
+ */
+ private void play(Output howtoStream){
+
+ logger.debug("play()");
+
+ String control = "control "+howtoStream.info.name+" play";
+ // telnet connection
+ TelnetInterface telnet = new TelnetInterface(hostIP, 4212, "admin");
+ telnet.exec(control);
+ // close telnet connection
+ telnet.close();
+ }
+
+/*
+ * pause submitted streamInfo
+ * @param howtoStream
+ */
+ private void pause(Output howtoStream){
+
+ logger.debug("pause()");
+
+ String control = "control "+howtoStream.info.name+" pause";
+ logger.debug("client.VlcStreamer: Telnetcmd: " + control);
+
+ TelnetInterface telnet = new TelnetInterface(hostIP, 4212, "admin");
+ telnet.exec(control);
+ telnet.close();
+ }
+
+/*
+ * go to next file in playlist
+ *
+ * @param howtoStream
+ */
+ private void next(Output howtoStream){
+
+ logger.debug("next()");
+
+ String control = "control "+howtoStream.info.name+" seek 100";
+ logger.debug("client.VlcStreamer: Telnetcmd: " + control);
+ TelnetInterface telnet = new TelnetInterface(hostIP, 4212, "admin");
+ telnet.exec(control);
+ telnet.close();
+ }
+
+/*
+ * stop streaming, delete stream
+ *
+ * @param howtoStream
+ */
+ private void stop(Output howtoStream){
+
+ logger.debug("stop()");
+
+ String del = "del "+howtoStream.info.name;
+ this.streamCounter.actualStreams--;
+ TelnetInterface telnet = new TelnetInterface(hostIP, 4212, "admin");
+ telnet.exec(del);
+ telnet.close();
+ currentStreams.remove(howtoStream);
+ }
+
+/*
+ * calculates streamName
+ * @return String streamName
+ */
+ private String streamName(){
+ logger.debug("streamName()");
+ String streamName = "stream";
+ streamName += streamCounter.allStreams;
+ return streamName;
+ }
+
+/*
+ * stops the streaming server
+ *
+ */
+ public void quit(){
+ logger.debug("quit()");
+ vlcPlayer.destroy();
+ }
+
+/*
+ * returns the streamcounter
+ * @return StreamCounter
+ */
+ public StreamCounter getStreamCounter(){
+ logger.debug("getStreamCounter()");
+ return this.streamCounter;
+ }
+
}