[vlma-devel] commit: Support of HTTP streaming. (Adrien Grand )

git version control git at videolan.org
Wed Jun 25 19:38:05 CEST 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Wed Jun 25 16:40:37 2008 +0200| [42999ed18db62689075611a0b7bc4479b2378384]

Support of HTTP streaming.

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

 .../org/videolan/vlma/model/StreamingStrategy.java |    2 +-
 .../org/videolan/vlma/model/order/FilesOrder.java  |    2 +-
 .../java/org/videolan/vlma/model/order/Order.java  |   30 ++++++++++++++++++++
 .../org/videolan/vlma/model/order/SatOrder.java    |    4 +-
 .../org/videolan/vlma/model/order/StreamOrder.java |    2 +-
 .../org/videolan/vlma/model/order/TNTOrder.java    |    4 +-
 6 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/vlma-model/src/main/java/org/videolan/vlma/model/StreamingStrategy.java b/vlma-model/src/main/java/org/videolan/vlma/model/StreamingStrategy.java
index 51a57bc..5e6b6de 100644
--- a/vlma-model/src/main/java/org/videolan/vlma/model/StreamingStrategy.java
+++ b/vlma-model/src/main/java/org/videolan/vlma/model/StreamingStrategy.java
@@ -28,7 +28,7 @@ package org.videolan.vlma.model;
 public class StreamingStrategy {
 
     public enum Protocol {
-        UDP
+        UDP, HTTP
     }
 
     public enum Announcement {
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 c9745a8..0333622 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
@@ -45,7 +45,7 @@ public class FilesOrder extends Order {
             }
 
             StringBuffer output = new StringBuffer();
-            output.append(String.format("#standard{mux=ts,access=udp,dst=%s", ch.getProgram().getIp().getHostAddress()));
+            output.append(String.format("#standard{mux=ts,access=%s,dst=%s", getAccess(), getDst(ch)));
             if (streamingStrategy.getAnnouncement().equals(StreamingStrategy.Announcement.SAP)) {
                 output.append(String.format(",sap,name=\"%s\",group=\"%s\")", ch.getProgram().getSapName(), ch.getProgram().getSapGroup()));
             }
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 4d011d4..3aa74bb 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
@@ -31,6 +31,7 @@ import org.apache.log4j.Logger;
 import org.videolan.vlma.VLMa;
 import org.videolan.vlma.model.StreamingStrategy;
 import org.videolan.vlma.model.adapter.Adapter;
+import org.videolan.vlma.model.media.Media;
 import org.videolan.vlma.model.media.MediaGroup;
 
 /**
@@ -197,6 +198,35 @@ public abstract class Order {
     public abstract void start() throws IOException;
 
     /**
+     * Gets the access method of the stream.
+     *
+     * @return the access method
+     */
+    public String getAccess() {
+        if (streamingStrategy.getProtocol().equals(StreamingStrategy.Protocol.UDP)) {
+            return "udp";
+        } else if (streamingStrategy.getProtocol().equals(StreamingStrategy.Protocol.HTTP)) {
+            return "http";
+        }
+        return null;
+    }
+
+    /**
+     * Gets the destination of the output.
+     *
+     * @param channel the media to stream
+     * @return the destionation of the output
+     */
+    public String getDst(Media channel) {
+        if (streamingStrategy.getProtocol().equals(StreamingStrategy.Protocol.UDP)) {
+            return channel.getProgram().getIp().getHostAddress();
+        } else if (streamingStrategy.getProtocol().equals(StreamingStrategy.Protocol.HTTP)) {
+            return channel.getProgram().getPlayer().getHostAddress() + ":8081/" + channel.hashCode();
+        }
+        return null;
+    }
+
+    /**
      * Orders a server to stop streaming.
      *
      * @throws IOException
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 7b18c5f..895d20a 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
@@ -66,8 +66,8 @@ public class SatOrder extends Order {
                 if (command != "") {
                     command += ",";
                 }
-                command += String.format("dst=standard{mux=ts,access=udp,dst=%s",
-                        ch.getProgram().getIp().getHostAddress());
+                command += String.format("dst=standard{mux=ts,access=%s,dst=%s",
+                        getAccess(), getDst(ch));
                 if (streamingStrategy.getAnnouncement().equals(StreamingStrategy.Announcement.SAP)) {
                     command += String.format(",sap,name=\"%s\",group=\"%s\"",
                             ch.getProgram().getSapName(), ch.getProgram().getSapGroup());
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 85b5451..c782375 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
@@ -43,7 +43,7 @@ public class StreamOrder extends Order {
                     " input \"" + ch.getStreamURL() + "\"");
 
             StringBuffer output = new StringBuffer();
-            output.append(String.format("#standard{mux=ts,access=udp,dst=%s", ch.getProgram().getIp().getHostAddress()));
+            output.append(String.format("#standard{mux=ts,access=%s,dst=%s", getAccess(), getDst(ch)));
             if (streamingStrategy.getAnnouncement().equals(StreamingStrategy.Announcement.SAP)) {
                 output.append(String.format(",sap,name=\"%s\",group=\"%s\")", ch.getProgram().getSapName(), ch.getProgram().getSapGroup()));
             }
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 3eee772..d086cad 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
@@ -56,8 +56,8 @@ public class TNTOrder extends Order {
                 if (command != "") {
                     command += ",";
                 }
-                command += String.format("dst=standard{mux=ts,access=udp,dst=%s",
-                        ch.getProgram().getIp().getHostAddress());
+                command += String.format("dst=standard{mux=ts,access=%s,dst=%s",
+                        getAccess(), getDst(ch));
                 if (streamingStrategy.getAnnouncement().equals(StreamingStrategy.Announcement.SAP)) {
                     command += String.format(",sap,name=\"%s\",group=\"%s\"",
                             ch.getProgram().getSapName(), ch.getProgram().getSapGroup());



More information about the vlma-devel mailing list