[vlma-devel] commit: Fix StreamOrder and FilesOrder. (Adrien Grand )

git version control git at videolan.org
Sat Jun 28 01:46:07 CEST 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Sat Jun 28 01:43:47 2008 +0200| [6d5fc3ec4526b5d6f10093b3431b2018ed97490a]

Fix StreamOrder and FilesOrder.

It wasn't possible to stream several (stream|files) channels from the same server.

> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=6d5fc3ec4526b5d6f10093b3431b2018ed97490a
---

 .../org/videolan/vlma/model/order/FilesOrder.java  |   34 +++++++++++++-------
 .../java/org/videolan/vlma/model/order/Order.java  |   26 +++++++++------
 .../org/videolan/vlma/model/order/SatOrder.java    |    2 +-
 .../org/videolan/vlma/model/order/StreamOrder.java |   31 +++++++++++------
 .../org/videolan/vlma/model/order/TNTOrder.java    |    2 +-
 5 files changed, 59 insertions(+), 36 deletions(-)

diff --git a/vlma-model/src/main/java/org/videolan/vlma/model/order/FilesOrder.java b/vlma-model/src/main/java/org/videolan/vlma/model/order/FilesOrder.java
index c87fc24..3564cdb 100644
--- a/vlma-model/src/main/java/org/videolan/vlma/model/order/FilesOrder.java
+++ b/vlma-model/src/main/java/org/videolan/vlma/model/order/FilesOrder.java
@@ -24,24 +24,25 @@ import java.io.IOException;
 
 import org.videolan.vlma.model.StreamingStrategy;
 import org.videolan.vlma.model.media.FilesChannel;
+import org.videolan.vlma.model.media.Media;
 
 public class FilesOrder extends Order {
 
     @Override
     public void start() throws IOException {
         telnetConnect();
-        init();
-        if (!medias.medias.isEmpty()) {
-            FilesChannel ch = (FilesChannel) medias.medias.get(0);
-    
-            telnetCommand("setup " + getVLMCommandName()
-                    + " loop");
-            telnetCommand("setup " + getVLMCommandName()
-                    + " option sout-keep");
+        for (Media m : medias.medias) {
+            FilesChannel ch = (FilesChannel) m;
+
+            String commandName = getVLMCommandName() + ch.hashCode();
+
+            init(commandName);
+            telnetCommand("setup " + commandName + " loop");
+            telnetCommand("setup " + commandName + " option sout-keep");
 
             // Set the input with the file list
             for (String file_path : ch.getFiles()) {
-                telnetCommand("setup " + getVLMCommandName() + " input \"" + file_path + "\"");
+                telnetCommand("setup " + commandName + " input \"" + file_path + "\"");
             }
 
             StringBuffer output = new StringBuffer();
@@ -51,11 +52,20 @@ public class FilesOrder extends Order {
             }
             output.append("}");
 
-            telnetCommand("setup " + getVLMCommandName() + " output " + output.toString());
-            telnetCommand("setup " + getVLMCommandName() + " enabled");
-            telnetCommand("control " + getVLMCommandName() + " play");
+            telnetCommand("setup " + commandName + " output " + output.toString());
+            telnetCommand("setup " + commandName + " enabled");
+            telnetCommand("control " + commandName + " play");
         }
         telnetClose();
     }
 
+    @Override
+    public void stop() throws IOException {
+        telnetConnect();
+        for (Media m : medias.medias) {
+            FilesChannel ch = (FilesChannel) m;
+            stopCommand(getVLMCommandName() + ch.hashCode());
+        }
+        telnetClose();
+    }
 }
diff --git a/vlma-model/src/main/java/org/videolan/vlma/model/order/Order.java b/vlma-model/src/main/java/org/videolan/vlma/model/order/Order.java
index bafe621..9b89998 100644
--- a/vlma-model/src/main/java/org/videolan/vlma/model/order/Order.java
+++ b/vlma-model/src/main/java/org/videolan/vlma/model/order/Order.java
@@ -159,17 +159,17 @@ public abstract class Order {
      *
      * @throws IOException Operation aborted
      */
-    protected void init() throws IOException {
+    protected void init(String commandName) throws IOException {
         // Remove the stream if there is one
-        telnetCommand("setup " + getVLMCommandName() + " disabled");
-        telnetCommand("control " + getVLMCommandName() + " stop");
-        telnetCommand("del " + getVLMCommandName());
+        telnetCommand("setup " + commandName + " disabled");
+        telnetCommand("control " + commandName + " stop");
+        telnetCommand("del " + commandName);
         // Create a multicast diffusion program
-        telnetCommand("new " + getVLMCommandName() + " broadcast");
+        telnetCommand("new " + commandName + " broadcast");
         // Verbose mode using colors
-        telnetCommand("setup " + getVLMCommandName() + " option vvv");
-        telnetCommand("setup " + getVLMCommandName() + " option color");
-        telnetCommand("setup " + getVLMCommandName() + " option ttl="
+        telnetCommand("setup " + commandName + " option vvv");
+        telnetCommand("setup " + commandName + " option color");
+        telnetCommand("setup " + commandName + " option ttl="
                 + Integer.toString(VLMa.getInstance()
                         .getInt("vlc.stream.ttl")));
     }
@@ -214,6 +214,12 @@ public abstract class Order {
         return null;
     }
 
+    protected void stopCommand(String commandName) throws IOException {
+        telnetCommand("control " + commandName + " disabled");
+        telnetCommand("control " + commandName + " stop");
+        telnetCommand("del " + commandName);
+    }
+
     /**
      * Orders a server to stop streaming.
      *
@@ -221,9 +227,7 @@ public abstract class Order {
      */
     public void stop() throws IOException {
         telnetConnect();
-        telnetCommand("control " + getVLMCommandName() + " disabled");
-        telnetCommand("control " + getVLMCommandName() + " stop");
-        telnetCommand("del " + getVLMCommandName());
+        stopCommand(getVLMCommandName());
         telnetClose();
     }
 
diff --git a/vlma-model/src/main/java/org/videolan/vlma/model/order/SatOrder.java b/vlma-model/src/main/java/org/videolan/vlma/model/order/SatOrder.java
index bffd927..a03502e 100644
--- a/vlma-model/src/main/java/org/videolan/vlma/model/order/SatOrder.java
+++ b/vlma-model/src/main/java/org/videolan/vlma/model/order/SatOrder.java
@@ -32,7 +32,7 @@ public class SatOrder extends Order {
     @Override
     public void start() throws IOException {
         telnetConnect();
-        init();
+        init(getVLMCommandName());
         if (!medias.medias.isEmpty()) {
             SatChannel ch = (SatChannel) medias.medias.get(0);
             telnetCommand("setup " + getVLMCommandName() + " input dvb://");
diff --git a/vlma-model/src/main/java/org/videolan/vlma/model/order/StreamOrder.java b/vlma-model/src/main/java/org/videolan/vlma/model/order/StreamOrder.java
index 5b58eb6..67ba2ea 100755
--- a/vlma-model/src/main/java/org/videolan/vlma/model/order/StreamOrder.java
+++ b/vlma-model/src/main/java/org/videolan/vlma/model/order/StreamOrder.java
@@ -23,6 +23,7 @@ package org.videolan.vlma.model.order;
 import java.io.IOException;
 
 import org.videolan.vlma.model.StreamingStrategy;
+import org.videolan.vlma.model.media.Media;
 import org.videolan.vlma.model.media.StreamChannel;
 
 public class StreamOrder extends Order {
@@ -30,16 +31,15 @@ public class StreamOrder extends Order {
     @Override
     public void start() throws IOException {
         telnetConnect();
-        init();
-        if (!medias.medias.isEmpty()) {
-            StreamChannel ch = (StreamChannel) medias.medias.get(0);
+        for (Media m : medias.medias) {
+            StreamChannel ch = (StreamChannel) m;
 
-            telnetCommand("setup " + getVLMCommandName()
-                    + " loop");
-            telnetCommand("setup " + getVLMCommandName()
-                    + " option sout-keep");
+            String commandName = getVLMCommandName() + ch.hashCode();
 
-            telnetCommand("setup " + getVLMCommandName() +
+            init(commandName);
+            telnetCommand("setup " + commandName + " loop");
+            telnetCommand("setup " + commandName + " option sout-keep");
+            telnetCommand("setup " + commandName +
                     " input \"" + ch.getStreamURL() + "\"");
 
             StringBuffer output = new StringBuffer();
@@ -49,11 +49,20 @@ public class StreamOrder extends Order {
             }
             output.append("}");
 
-            telnetCommand("setup " + getVLMCommandName() + " output " + output.toString());
-            telnetCommand("setup " + getVLMCommandName() + " enabled");
-            telnetCommand("control " + getVLMCommandName() + " play");
+            telnetCommand("setup " + commandName + " output " + output.toString());
+            telnetCommand("setup " + commandName + " enabled");
+            telnetCommand("control " + commandName + " play");
         }
         telnetClose();
     }
 
+    @Override
+    public void stop() throws IOException {
+        telnetConnect();
+        for (Media m : medias.medias) {
+            StreamChannel ch = (StreamChannel) m;
+            stopCommand(getVLMCommandName() + ch.hashCode());
+        }
+        telnetClose();
+    }
 }
diff --git a/vlma-model/src/main/java/org/videolan/vlma/model/order/TNTOrder.java b/vlma-model/src/main/java/org/videolan/vlma/model/order/TNTOrder.java
index 9d531cb..b91bb7d 100644
--- a/vlma-model/src/main/java/org/videolan/vlma/model/order/TNTOrder.java
+++ b/vlma-model/src/main/java/org/videolan/vlma/model/order/TNTOrder.java
@@ -32,7 +32,7 @@ public class TNTOrder extends Order {
     @Override
     public void start() throws IOException {
         telnetConnect();
-        init();
+        init(getVLMCommandName());
         if (!medias.medias.isEmpty()) {
             TNTChannel ch = (TNTChannel) medias.medias.get(0);
             telnetCommand("setup " + getVLMCommandName() + " input dvb://");



More information about the vlma-devel mailing list