summaryrefslogtreecommitdiff
path: root/src/YalpOutputs/YalpVlcTelnetOutput/VlcStreamer.java
diff options
context:
space:
mode:
authorguest <guest@f059d3a0-6783-47b7-97ff-1fe0bbf25129>2008-09-23 21:29:27 +0000
committerguest <guest@f059d3a0-6783-47b7-97ff-1fe0bbf25129>2008-09-23 21:29:27 +0000
commitd6fa96b4cd67cf4fa18b5b9b6739f9bc2494a9f4 (patch)
tree00aa9a27acb6b4c8d9868795a5295e9231f1eb20 /src/YalpOutputs/YalpVlcTelnetOutput/VlcStreamer.java
initial import
git-svn-id: http://manut.eu/svn/yalp/trunk@1 f059d3a0-6783-47b7-97ff-1fe0bbf25129
Diffstat (limited to 'src/YalpOutputs/YalpVlcTelnetOutput/VlcStreamer.java')
-rw-r--r--src/YalpOutputs/YalpVlcTelnetOutput/VlcStreamer.java145
1 files changed, 145 insertions, 0 deletions
diff --git a/src/YalpOutputs/YalpVlcTelnetOutput/VlcStreamer.java b/src/YalpOutputs/YalpVlcTelnetOutput/VlcStreamer.java
new file mode 100644
index 0000000..568bfb8
--- /dev/null
+++ b/src/YalpOutputs/YalpVlcTelnetOutput/VlcStreamer.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2006 Manuel Traut and Volker Dahnke
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors: Manuel Traut and Volker Dahnke
+ */
+
+package YalpOutputs.YalpVlcTelnetOutput;
+
+import YalpInterfaces.*;
+
+import java.io.*;
+import java.util.LinkedList;
+
+import org.omg.CosNaming.*;
+import org.omg.CosNaming.NamingContextPackage.*;
+import org.omg.CORBA.*;
+import org.omg.PortableServer.*;
+import org.omg.PortableServer.POA;
+
+/*
+ *
+ * Class VlcStreamer
+ *
+ * <em>Controlling Streams on a high level</em>
+ *
+ * @author Volker Dahnke / Manuel Traut
+ *
+ * @version 0.6 04-12-2005<br>
+ *
+ * @see InitServer
+ */
+public class VlcStreamer {
+
+ private static ORB orb;
+ private static POA poa;
+ private static YalpOutputPluginImpl streamer;
+ private static OutputPluginInterface outputPlugin;
+ private static ServerControlInterface srvCon;
+ private static PluginInfo pluginInfo;
+/*
+ * starts a vlc player in a new process
+ *
+ * @param serverIP
+ * where vlcStreamer is running
+ * @param startport
+ * first port used for streaming
+ * @param vlcCmd
+ * path and name of vlc player executable
+ * @param args
+ * from cmd line
+ */
+ public VlcStreamer(String serverIP, int startport, String vlcCmd,
+ String[] argv) {
+
+ pluginInfo = new PluginInfo();
+ pluginInfo.name = "VLC Telnet Streamer";
+ pluginInfo.description = "creates streams via VLC players telnet interface";
+ pluginInfo.type = PluginType.OUTPUT_PLUGIN;
+ pluginInfo.supportedTypes = new MediaType[0];
+ pluginInfo.access = new AccessInfo();
+ pluginInfo.access.name = "stream provided by vlc player";
+ pluginInfo.access.description = "streams can be displayed with vlc player";
+ pluginInfo.access.executable = "vlc";
+ pluginInfo.access.params = "";
+ pluginInfo.access.type = AccessType.STREAM;
+
+ try {
+ this.orb = ORB.init(argv, null);
+ org.omg.CORBA.Object objRef =
+ orb.resolve_initial_references("NameService");
+ NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
+ poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
+ } catch(Exception e) {
+ /* t.b.d. error handling */
+ System.out.println("couldn't host plugin implementation");
+ }
+
+ try {
+ poa.the_POAManager().activate();
+ } catch(org.omg.PortableServer.POAManagerPackage.AdapterInactive e) {
+ /* t.b.d. error handling */
+ System.out.println("poa inactive");
+ }
+/*
+ YalpError error = new YalpError();
+ error.msg = "";
+ error.descr = "";
+ error.code = YalpErrorCode.OK;
+ error.level= YalpErrorLevel.ERROR_LEVEL_INFO;
+ */
+ YalpErrorHolder err = new YalpErrorHolder(/*error*/);
+
+ try {
+ /* only start vlc player if it isn't currently running */
+ org.omg.CORBA.Object objRef =
+ orb.resolve_initial_references("NameService");
+
+ NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
+ String name = "YALP_Server";
+ srvCon = ServerControlInterfaceHelper.narrow(ncRef.resolve_str(name));
+ } catch (Exception e) {
+ System.out.println("Couldn't connect to YALP Server");
+ System.exit(0);
+ }
+
+ streamer = new YalpOutputPluginImpl();
+ streamer.setORB(orb);
+
+ try {
+ poa.activate_object(streamer);
+ org.omg.CORBA.Object ref = poa.servant_to_reference(streamer);
+ outputPlugin = OutputPluginInterfaceHelper.narrow(ref);
+
+ org.omg.CORBA.Object objRef =
+ orb.resolve_initial_references("NameService");
+
+ NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
+ String name = "YALP_Vlc_Telnet_Streamer_Output";
+ NameComponent path[] = ncRef.to_name(name);
+ ncRef.rebind(path, outputPlugin);
+
+ PluginInfoHolder tmp = new PluginInfoHolder(pluginInfo);
+ srvCon.ping(err);
+ System.out.println(err.value.descr);
+ srvCon.registerOutputPlugin(outputPlugin, tmp, err );
+ pluginInfo = tmp.value;
+
+ if(err.value.code != YalpErrorCode.OK)
+ System.out.println("registring outputplugin failed");
+ else
+ System.out.println("output plugin registered");
+
+ orb.run();
+
+ } catch (Exception e) {
+ System.out.println("binding plugin failed 1");
+ e.printStackTrace();
+ System.exit(0);
+ }
+ }
+}