[vlma-devel] commit: Remove unused watcher. (Adrien Grand )
git version control
git at videolan.org
Sun Oct 12 11:59:13 CEST 2008
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Sun Oct 12 11:57:22 2008 +0200| [c4c259d67900d3afc5443533ec29d32d27660a3e] | committer: Adrien Grand
Remove unused watcher.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=c4c259d67900d3afc5443533ec29d32d27660a3e
---
.../vlma/watcher/ExtremeStreamWatcher.java | 142 --------------------
1 files changed, 0 insertions(+), 142 deletions(-)
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
deleted file mode 100644
index 7331d78..0000000
--- a/vlma-core/src/main/java/org/videolan/vlma/watcher/ExtremeStreamWatcher.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * 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.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
-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;
-
-/**
- * This class can get the streams which are received by an Extreme router.
- *
- * @see StreamWatcher
- * @author Sylvain Cadilhac <sylv at videolan.org>
- */
-public class ExtremeStreamWatcher implements StreamWatcher, Serializable {
-
- private static final long serialVersionUID = -9218318159140960961L;
-
- private static final Logger logger = Logger.getLogger(ExtremeStreamWatcher.class);
-
- /**
- * Wait step time for telnet connections.
- */
- private static final int TELNET_DEFAULT_WAIT = 100;
-
- /**
- * Overall wait time for telnet connections.
- */
- private static final int TELNET_DEFAULT_DELAY = 1000;
-
- /**
- * Router's ip to be asked.
- */
- private static final String ROUTER_HOST = "138.195.131.126";
-
- /**
- * Router's port on which to connect.
- */
- private static final int ROUTER_PORT = 23;
-
- /**
- * Username for the connection to the router.
- */
- private static final String ROUTER_USER = "user";
-
- /**
- * Password for the connection to the router.
- */
- private static final String ROUTER_PASSWORD = "via";
-
- /**
- * The VLAN to be checked.
- */
- private static final String ROUTER_VLAN = "vlip-videolan";
-
- 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.");
- try {
- // Create socket and connection
- Socket socket = new Socket(ROUTER_HOST, ROUTER_PORT);
- PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
- BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
- // Print login and password
- out.println(ROUTER_USER);
- out.println(ROUTER_PASSWORD);
- // Send command and get response
- out.println("show igmp snooping " + ROUTER_VLAN);
- out.println(" ");
- Thread.sleep(TELNET_DEFAULT_WAIT);
- int m = TELNET_DEFAULT_DELAY;
- while ((!in.ready()) && ((m -= TELNET_DEFAULT_WAIT) > 0)) {
- Thread.sleep(TELNET_DEFAULT_WAIT);
- }
- while (in.ready()) {
- toParse.append((char) in.read());
- }
- // Close connection
- out.close();
- in.close();
- socket.close();
- } catch (UnknownHostException e) {
- logger.error("Error while querying the router.", e);
- } catch (IOException e) {
- logger.error("Error while querying the router.", e);
- } catch (InterruptedException e) {
- logger.error("Thread has been interrupted.", e);
- }
-
- // Parse data
- Matcher m = Pattern.compile("\\s+\\w+\\s+(\\d+\\.\\d+\\.\\d+\\.\\d+)\\s+(\\d+\\.\\d+\\.\\d+\\.\\d+)").matcher(toParse);
- while (m.find()) {
- try {
- InetAddress ip1 = InetAddress.getByName(m.group(1));
- InetAddress ip2 = InetAddress.getByName(m.group(2));
- if ((ip1.isMulticastAddress()) && (!ip2.isMulticastAddress())) {
- if (ip2.equals(program.getIp())) {
- result = true;
- break;
- }
- logger.debug("Server " + ip2.getHostName() + " streams " + ip1.getHostName());
- }
- } catch (UnknownHostException e) {
- logger.error("Name resolution error.", e);
- }
- }
- return result;
- }
-
-}
More information about the vlma-devel
mailing list