[vlma-devel] commit: Now isPlayed() function takes a Media in argument and not a Program . (Adrien Maglo )
git version control
git at videolan.org
Thu Oct 9 23:09:33 CEST 2008
vlma | branch: master | Adrien Maglo <magsoft at videolan.org> | Thu Oct 9 22:47:54 2008 +0200| [c18d4d0e24c31199b05b266d0cf27c46b8e4b801] | committer: Adrien Maglo
Now isPlayed() function takes a Media in argument and not a Program.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=c18d4d0e24c31199b05b266d0cf27c46b8e4b801
---
.../vlma/watcher/DirectMulticastStreamWatcher.java | 18 +++++++++++++++---
.../vlma/watcher/ExtremeStreamWatcher.java | 5 ++++-
.../videolan/vlma/watcher/HttpStreamWatcher.java | 5 ++++-
.../org/videolan/vlma/watcher/StreamWatcher.java | 4 ++--
.../vlma/watcher/StreamWatcherDispatcher.java | 17 +++++++++++++----
.../vlma/watcher/StreamWatcherMockImpl.java | 4 ++--
6 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/vlma-core/src/main/java/org/videolan/vlma/watcher/DirectMulticastStreamWatcher.java b/vlma-core/src/main/java/org/videolan/vlma/watcher/DirectMulticastStreamWatcher.java
index 5da1658..5dc0fc5 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/watcher/DirectMulticastStreamWatcher.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/watcher/DirectMulticastStreamWatcher.java
@@ -26,12 +26,14 @@ import java.io.Serializable;
import java.net.DatagramPacket;
import java.net.MulticastSocket;
+import org.apache.commons.configuration.Configuration;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
+import org.videolan.vlma.model.Media;
import org.videolan.vlma.model.Program;
/**
- * This Watcher direcly connects to the multicast groups to check wether some
+ * This Watcher directly connects to the multicast groups to check whether some
* data is broadcasted. If yes, it considers that the media is broadcasted.
* This class should never be used directly. Use {@link StreamWatcherDispatcher}
* instead.
@@ -44,6 +46,8 @@ public class DirectMulticastStreamWatcher implements StreamWatcher, Serializable
private static final Logger logger = Logger.getLogger(DirectMulticastStreamWatcher.class);
+ private Configuration configuration;
+
/**
* The thread used to wait.
*/
@@ -55,7 +59,7 @@ public class DirectMulticastStreamWatcher implements StreamWatcher, Serializable
private static int SOCKET_RECEIVE_TIMEOUT = 500;
/**
- * The minimal lenght of the string to consider that the media is
+ * The minimal length of the string to consider that the media is
* broadcasted
*/
private static int BUF_LENGHT_MIN = 300;
@@ -70,7 +74,9 @@ public class DirectMulticastStreamWatcher implements StreamWatcher, Serializable
*/
private boolean isReceivingData = false;
- public boolean isPlayed(Program program) {
+ public boolean isPlayed(Media media) {
+ Program program = media.getProgram();
+
if (program.getIp() == null) {
return false;
}
@@ -151,4 +157,10 @@ public class DirectMulticastStreamWatcher implements StreamWatcher, Serializable
waitThread.start();
}
+ /**
+ * @param configuration the configuration to set
+ */
+ public void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
}
diff --git a/vlma-core/src/main/java/org/videolan/vlma/watcher/ExtremeStreamWatcher.java b/vlma-core/src/main/java/org/videolan/vlma/watcher/ExtremeStreamWatcher.java
index 553374a..7331d78 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/watcher/ExtremeStreamWatcher.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/watcher/ExtremeStreamWatcher.java
@@ -32,6 +32,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.log4j.Logger;
+import org.videolan.vlma.model.Media;
import org.videolan.vlma.model.Program;
/**
@@ -81,7 +82,9 @@ public class ExtremeStreamWatcher implements StreamWatcher, Serializable {
*/
private static final String ROUTER_VLAN = "vlip-videolan";
- public boolean isPlayed(Program program) {
+ public boolean isPlayed(Media media) {
+ Program program = media.getProgram();
+
boolean result = false;
StringBuilder toParse = new StringBuilder();
logger.debug("Connect to the router to get the stream state.");
diff --git a/vlma-core/src/main/java/org/videolan/vlma/watcher/HttpStreamWatcher.java b/vlma-core/src/main/java/org/videolan/vlma/watcher/HttpStreamWatcher.java
index 168b2ba..8ae10ec 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/watcher/HttpStreamWatcher.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/watcher/HttpStreamWatcher.java
@@ -27,6 +27,7 @@ import java.net.URL;
import java.net.URLConnection;
import org.apache.commons.configuration.Configuration;
+import org.videolan.vlma.model.Media;
import org.videolan.vlma.model.Program;
/**
@@ -41,7 +42,9 @@ public class HttpStreamWatcher implements StreamWatcher, Serializable {
private Configuration configuration;
- public boolean isPlayed(Program program) {
+ public boolean isPlayed(Media media) {
+ Program program = media.getProgram();
+
if (program.getPlayer() == null) {
return false;
}
diff --git a/vlma-core/src/main/java/org/videolan/vlma/watcher/StreamWatcher.java b/vlma-core/src/main/java/org/videolan/vlma/watcher/StreamWatcher.java
index 1ae1a60..b531ff9 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/watcher/StreamWatcher.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/watcher/StreamWatcher.java
@@ -20,7 +20,7 @@
package org.videolan.vlma.watcher;
-import org.videolan.vlma.model.Program;
+import org.videolan.vlma.model.Media;
import org.videolan.vlma.monitor.OrderMonitor;
/**
@@ -37,6 +37,6 @@ public interface StreamWatcher {
*
* @return true if and only if the program is being played
*/
- boolean isPlayed(Program program);
+ boolean isPlayed(Media media);
}
diff --git a/vlma-core/src/main/java/org/videolan/vlma/watcher/StreamWatcherDispatcher.java b/vlma-core/src/main/java/org/videolan/vlma/watcher/StreamWatcherDispatcher.java
index a8fbe16..d51ce16 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/watcher/StreamWatcherDispatcher.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/watcher/StreamWatcherDispatcher.java
@@ -21,6 +21,7 @@
package org.videolan.vlma.watcher;
import org.videolan.vlma.model.Program;
+import org.videolan.vlma.model.Media;
import org.videolan.vlma.model.StreamingStrategy;
/**
@@ -33,16 +34,20 @@ public class StreamWatcherDispatcher implements StreamWatcher {
private StreamWatcher directMulticastStreamWatcher;
private StreamWatcher httpStreamWatcher;
+ private StreamWatcher vodStreamWatcher;
private StreamWatcher mockStreamWatcher;
- public boolean isPlayed(Program program) {
+ public boolean isPlayed(Media media) {
+ Program program = media.getProgram();
StreamingStrategy.Protocol protocol = program.getStreamingStrategy().getProtocol();
if (StreamingStrategy.Protocol.HTTP.equals(protocol)) {
- return httpStreamWatcher.isPlayed(program);
+ return httpStreamWatcher.isPlayed(media);
} else if (StreamingStrategy.Protocol.UDP_MULTICAST.equals(protocol)) {
- return directMulticastStreamWatcher.isPlayed(program);
+ return directMulticastStreamWatcher.isPlayed(media);
+ } else if (StreamingStrategy.Protocol.VOD.equals(protocol)) {
+ return vodStreamWatcher.isPlayed(media);
} else {
- return mockStreamWatcher.isPlayed(program);
+ return mockStreamWatcher.isPlayed(media);
}
}
@@ -54,6 +59,10 @@ public class StreamWatcherDispatcher implements StreamWatcher {
this.httpStreamWatcher = httpStreamWatcher;
}
+ public void setVodStreamWatcher(StreamWatcher vodStreamWatcher) {
+ this.vodStreamWatcher = vodStreamWatcher;
+ }
+
public void setMockStreamWatcher(StreamWatcher mockStreamWatcher) {
this.mockStreamWatcher = mockStreamWatcher;
}
diff --git a/vlma-core/src/main/java/org/videolan/vlma/watcher/StreamWatcherMockImpl.java b/vlma-core/src/main/java/org/videolan/vlma/watcher/StreamWatcherMockImpl.java
index 5f65e1f..9be6dd0 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/watcher/StreamWatcherMockImpl.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/watcher/StreamWatcherMockImpl.java
@@ -22,7 +22,7 @@ package org.videolan.vlma.watcher;
import java.io.Serializable;
-import org.videolan.vlma.model.Program;
+import org.videolan.vlma.model.Media;
/**
* This implementation always return true. It will be called by
@@ -35,7 +35,7 @@ public class StreamWatcherMockImpl implements StreamWatcher, Serializable {
private static final long serialVersionUID = -7140427768396758460L;
- public boolean isPlayed(Program program) {
+ public boolean isPlayed(Media media) {
return true;
}
More information about the vlma-devel
mailing list