[vlma-devel] commit: Choose the stream watcher implementation to use depending on the streaming strategy . (Adrien Grand )

git version control git at videolan.org
Wed Jun 25 23:52:26 CEST 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Wed Jun 25 23:53:46 2008 +0200| [8430b9b38132c318cc3d5c90d714d6957d1f8c5c]

Choose the stream watcher implementation to use depending on the streaming strategy.

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

 .../org/videolan/vlma/monitor/OrderMonitor.java    |   30 ++++++++++++-------
 .../main/java/org/videolan/vlma/daemon/VLMad.java  |    5 ++-
 vlma-daemon/src/main/resources/daemon.xml          |    4 +--
 3 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java b/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
index daa6fe7..93e554e 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
@@ -28,17 +28,20 @@ import org.apache.log4j.Logger;
 import org.jrobin.core.Util;
 import org.videolan.vlma.OrderGiver;
 import org.videolan.vlma.VLMaService;
+import org.videolan.vlma.model.StreamingStrategy;
 import org.videolan.vlma.model.media.Media;
 import org.videolan.vlma.model.order.Order;
 import org.videolan.vlma.model.program.Program;
+import org.videolan.vlma.watcher.DirectMulticastStreamWatcher;
+import org.videolan.vlma.watcher.HttpStreamWatcher;
 import org.videolan.vlma.watcher.StreamWatcher;
+import org.videolan.vlma.watcher.StreamWatcherMockImpl;
 
 /**
  * This class is an orders monitoring daemon. It connects to the router and
  * checks that the orders are correctly executed.
  *
  * @author SylV
- * @version 1.0
  */
 public class OrderMonitor implements Monitor {
 
@@ -48,6 +51,10 @@ public class OrderMonitor implements Monitor {
 
     private OrderGiver orderGiver;
 
+    private StreamingStrategy streamingStrategy;
+
+    private StreamWatcher streamWatcher = new StreamWatcherMockImpl();
+
     private Thread orderMonitorThread;
 
     private Thread orderMonitorDaemonThread;
@@ -65,11 +72,6 @@ public class OrderMonitor implements Monitor {
      */
     private static final int RRD_INTERVAL = 60;
 
-    /**
-     * The object which will give the multicast streams list.
-     */
-    private StreamWatcher streamWatcher;
-
 
     private Runnable orderMonitor = new Runnable() {
         public void run() {
@@ -174,6 +176,14 @@ public class OrderMonitor implements Monitor {
         }
     }
 
+    public void updateStreamWatcher() {
+        if (streamingStrategy.getProtocol().equals(StreamingStrategy.Protocol.UDP)) {
+            streamWatcher = new DirectMulticastStreamWatcher();
+        } else if (streamingStrategy.getProtocol().equals(StreamingStrategy.Protocol.HTTP)) {
+            streamWatcher = new HttpStreamWatcher();
+        }
+    }
+
     /**
      * Sets the VLMa service.
      *
@@ -193,12 +203,10 @@ public class OrderMonitor implements Monitor {
     }
 
     /**
-     * Sets the stream watcher implementation to use.
-     *
-     * @param streamWatcher the watcher to set
+     * @param streamingStrategy the streamingStrategy to set
      */
-    public void setStreamWatcher(StreamWatcher streamWatcher) {
-        this.streamWatcher = streamWatcher;
+    public void setStreamingStrategy(StreamingStrategy streamingStrategy) {
+        this.streamingStrategy = streamingStrategy;
     }
 
 }
diff --git a/vlma-daemon/src/main/java/org/videolan/vlma/daemon/VLMad.java b/vlma-daemon/src/main/java/org/videolan/vlma/daemon/VLMad.java
index f566731..fcacef2 100644
--- a/vlma-daemon/src/main/java/org/videolan/vlma/daemon/VLMad.java
+++ b/vlma-daemon/src/main/java/org/videolan/vlma/daemon/VLMad.java
@@ -33,6 +33,7 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.videolan.vlma.VLMa;
 import org.videolan.vlma.model.StreamingStrategy;
+import org.videolan.vlma.monitor.OrderMonitor;
 
 /**
  * The VLMa daemon launcher. This class contains the boot process of VLMA
@@ -89,9 +90,11 @@ public class VLMad {
         StreamingStrategy streamingStrategy = (StreamingStrategy) ac.getBean("streamingStrategy");
         String announcement = VLMa.getInstance().getString("vlma.announcement.protocol");
         String protocol = VLMa.getInstance().getString("vlma.streaming.protocol");
-        logger.debug("Initializing straming strategy");
+        logger.debug("Initializing streaming strategy");
         streamingStrategy.setAnnouncement(StreamingStrategy.Announcement.valueOf(announcement));
         streamingStrategy.setProtocol(StreamingStrategy.Protocol.valueOf(protocol));
+        OrderMonitor orderMonitor = (OrderMonitor) ac.getBean("orderMonitor");
+        orderMonitor.updateStreamWatcher();
         Daemon daemon = (Daemon) ac.getBean("daemon");
         daemon.setIpsDevel(IPsDevelvalue);
         daemon.run();
diff --git a/vlma-daemon/src/main/resources/daemon.xml b/vlma-daemon/src/main/resources/daemon.xml
index 1b58d46..231dcb8 100644
--- a/vlma-daemon/src/main/resources/daemon.xml
+++ b/vlma-daemon/src/main/resources/daemon.xml
@@ -85,7 +85,7 @@
     <bean id="orderMonitor" class="org.videolan.vlma.monitor.OrderMonitor">
         <property name="vlmaService" ref="vlmaService" />
         <property name="orderGiver" ref="orderGiver" />
-        <property name="streamWatcher" ref="streamWatcher" />
+        <property name="streamingStrategy" ref="streamingStrategy" />
     </bean>
 
     <bean id="serverMonitor" class="org.videolan.vlma.monitor.ServerMonitor">
@@ -94,6 +94,4 @@
 
     <bean id="streamingStrategy" class="org.videolan.vlma.model.StreamingStrategy" />
 
-    <bean id="streamWatcher" class="org.videolan.vlma.watcher.DirectMulticastStreamWatcher" />
-
 </beans>



More information about the vlma-devel mailing list