[vlma-devel] commit: A new watcher for HTTP streams. (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 19:37:22 2008 +0200| [19a4d19f9d21289bf0669812d1eccf0a80e063c8]
A new watcher for HTTP streams.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=19a4d19f9d21289bf0669812d1eccf0a80e063c8
---
.../videolan/vlma/watcher/HttpStreamWatcher.java | 54 ++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
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
new file mode 100644
index 0000000..d208fde
--- /dev/null
+++ b/vlma-core/src/main/java/org/videolan/vlma/watcher/HttpStreamWatcher.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2006-2008 the VideoLAN team
+ *
+ * This file is part of VLMa.
+ *
+ * VLMa is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * VLMa is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VLMa. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package org.videolan.vlma.watcher;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import org.apache.log4j.Logger;
+import org.videolan.vlma.model.program.Program;
+
+/**
+ * This class monitors HTTP streams.
+ *
+ * @author jpountz
+ */
+public class HttpStreamWatcher implements StreamWatcher {
+
+ private static final Logger logger = Logger.getLogger(HttpStreamWatcher.class);
+
+ public boolean isPlayed(Program program) {
+ if (program.getPlayer() == null) {
+ return false;
+ }
+ boolean isPlayed = false;
+ try {
+ Socket socket = new Socket(program.getPlayer(), 8081);
+ socket.close();
+ // TODO Also check that you do not encounter a 404 error
+ isPlayed = true;
+ } catch (IOException e) {
+ logger.error("Cannot connect to " + program.getIp() + " on port 8081", e);
+ }
+ return isPlayed;
+ }
+
+}
More information about the vlma-devel
mailing list