[vlma-devel] commit: Ability to set the IP address of the multicast stream manually from the web interface . (Adrien Grand )

git version control git at videolan.org
Mon Dec 22 00:33:35 CET 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Mon Dec 22 00:31:58 2008 +0100| [ee5e497f9b4c727d0e9ff4960cee5bb40496a27b] | committer: Adrien Grand 

Ability to set the IP address of the multicast stream manually from the web interface.

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

 .../src/main/java/org/videolan/vlma/DataImpl.java  |    3 ++-
 .../videolan/vlma/web/media/MediaProgramAdd.java   |   10 ++++++++++
 .../vlma/web/media/MediaProgramAddController.java  |    6 ++++++
 .../vlma/web/media/MediaProgramAddValidator.java   |   10 ++++++++++
 vlma-webapp/src/main/resources/messages.properties |    3 +++
 .../src/main/resources/messages_fr.properties      |    3 +++
 .../WEB-INF/jsp/media/mediaprogramadd_right.jsp    |   19 +++++++++++++++++++
 7 files changed, 53 insertions(+), 1 deletions(-)

diff --git a/vlma-core/src/main/java/org/videolan/vlma/DataImpl.java b/vlma-core/src/main/java/org/videolan/vlma/DataImpl.java
index fec674f..409d215 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/DataImpl.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/DataImpl.java
@@ -164,7 +164,8 @@ public class DataImpl implements Data {
         } else if (media.getProgram() != null
                 && (m.getProgram() == null
                         || !m.getProgram().getStreamingStrategy().getProtocol().equals(StreamingStrategy.Protocol.UDP_MULTICAST))
-                && media.getProgram().getStreamingStrategy().getProtocol().equals(StreamingStrategy.Protocol.UDP_MULTICAST)) {
+                && media.getProgram().getStreamingStrategy().getProtocol().equals(StreamingStrategy.Protocol.UDP_MULTICAST)
+                && media.getProgram().getIp() == null) {
             media.getProgram().setIp(ipBank.getIp());
         }
         vlmaDao.update(media);
diff --git a/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAdd.java b/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAdd.java
index e90bb60..6d29579 100644
--- a/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAdd.java
+++ b/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAdd.java
@@ -34,6 +34,8 @@ public class MediaProgramAdd {
     private String sap;
     private String group;
 
+    private String ip;
+
     private String priority;
 
     private Type type;
@@ -97,6 +99,14 @@ public class MediaProgramAdd {
         this.group = group;
     }
 
+    public String getIp() {
+        return ip;
+    }
+
+    public void setIp(String ip) {
+        this.ip = ip.trim();
+    }
+
     public int getMediaId() {
         return mediaId;
     }
diff --git a/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAddController.java b/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAddController.java
index 0a73995..29fdefd 100644
--- a/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAddController.java
+++ b/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAddController.java
@@ -21,6 +21,7 @@
 package org.videolan.vlma.web.media;
 
 import java.io.IOException;
+import java.net.InetAddress;
 import java.net.MalformedURLException;
 import java.util.HashMap;
 import java.util.Map;
@@ -110,6 +111,10 @@ public class MediaProgramAddController extends SimpleFormController {
         program.getStreamingStrategy().setProtocol(mediasProgramAdd.getProtocol());
         program.getStreamingStrategy().setEncapsulation(mediasProgramAdd.getMux());
         program.getStreamingStrategy().setAnnouncements(mediasProgramAdd.getAnnouncements());
+        String ip = mediasProgramAdd.getIp();
+        if (ip != null && ip.length() > 0) {
+            program.setIp(InetAddress.getByName(ip));
+        }
         media.setProgram(program);
         data.update(media);
 
@@ -185,6 +190,7 @@ public class MediaProgramAddController extends SimpleFormController {
             mediasProgramAdd.setGroup(data.getString(sapGroupId));
         else
             mediasProgramAdd.setGroup("");
+        mediasProgramAdd.setIp("");
         mediasProgramAdd.setMediaId(mediaId);
         mediasProgramAdd.setType(program.getStreamingStrategy().getType());
         mediasProgramAdd.setProtocol(program.getStreamingStrategy().getProtocol());
diff --git a/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAddValidator.java b/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAddValidator.java
index 8b34aa0..c7b696f 100644
--- a/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAddValidator.java
+++ b/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAddValidator.java
@@ -20,6 +20,8 @@
 
 package org.videolan.vlma.web.media;
 
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.rmi.RemoteException;
 
 import org.springframework.validation.Errors;
@@ -63,6 +65,14 @@ public class MediaProgramAddValidator implements Validator {
                 arg1.rejectValue("priority",
                         "medias.program.add.error.invalidpriority");
             }
+            String ip = mediasProgramAdd.getIp();
+            if (ip!= null && ip.length() > 0) {
+                try {
+                    InetAddress.getByName(ip);
+                } catch (UnknownHostException e) {
+                    arg1.rejectValue("ip", "medias.program.add.error.invalidip");
+                }
+            }
         }
 
     }
diff --git a/vlma-webapp/src/main/resources/messages.properties b/vlma-webapp/src/main/resources/messages.properties
index d6126db..450ac57 100644
--- a/vlma-webapp/src/main/resources/messages.properties
+++ b/vlma-webapp/src/main/resources/messages.properties
@@ -238,8 +238,11 @@ medias.program.add.protocol = Protocol:
 medias.program.add.mux = Encapsulation:
 medias.program.add.announcements = Announcements:
 medias.program.add.run = Program
+medias.program.add.ip = IP address (optional)
+medias.program.add.ip.help = If you don't provide any IP address, VLMa will take one in the IP pool.
 medias.program.add.error.not-specified = Can't program the media with those parameters.
 medias.program.add.error.invalidsap = Not valid.
+medias.program.add.error.invalidip = Unknown host
 medias.program.add.error.nonexisting = The media does not exist.
 medias.program.add.error.invalidpriority = Not correct priority value.
 medias.program.add.error.fix = Please correct those mistakes to continue.
diff --git a/vlma-webapp/src/main/resources/messages_fr.properties b/vlma-webapp/src/main/resources/messages_fr.properties
index 953d636..5b2adaa 100644
--- a/vlma-webapp/src/main/resources/messages_fr.properties
+++ b/vlma-webapp/src/main/resources/messages_fr.properties
@@ -235,8 +235,11 @@ medias.program.add.protocol = Protocole :
 medias.program.add.mux = Encapsulation :
 medias.program.add.announcements = Annonces :
 medias.program.add.run = Programmer
+medias.program.add.ip = Adresse IP (optionnel)
+medias.program.add.ip.help = Si vous ne fournissez pas d'adresse IP, VLMa en prendra une dans la banque des IP disponibles.
 medias.program.add.error.not-specified = Impossible de programmer le média avec ces paramètres.
 medias.program.add.error.invalidsap = Nom invalide.
+medias.program.add.error.invalidip = IP invalide
 medias.program.add.error.nonexisting = Le média n'existe pas.
 medias.program.add.error.invalidpriority = Valeur de priorité incorrecte.
 medias.program.add.error.fix = Veuillez corriger les erreurs pour continuer.
diff --git a/vlma-webapp/src/main/webapp/WEB-INF/jsp/media/mediaprogramadd_right.jsp b/vlma-webapp/src/main/webapp/WEB-INF/jsp/media/mediaprogramadd_right.jsp
index 0a76a43..a953cc0 100644
--- a/vlma-webapp/src/main/webapp/WEB-INF/jsp/media/mediaprogramadd_right.jsp
+++ b/vlma-webapp/src/main/webapp/WEB-INF/jsp/media/mediaprogramadd_right.jsp
@@ -62,6 +62,13 @@
             <td><span class="error"><c:out value="${status.errorMessage}" /></span></td>
         </spring:bind>
     </tr>
+    <tr id="ipTr">
+        <td align="right"><fmt:message key="medias.program.add.ip" /></td>
+        <spring:bind path="mediaProgramAdd.ip">
+            <td><input type="text" name="ip" value="<c:out value="${status.value}" />" /></td>
+            <td><span class="error"><c:out value="${status.errorMessage}" /></span></td>
+        </spring:bind>
+    </tr>
     <tr>
         <td align="right"><fmt:message key="medias.program.add.mux" /></td>
         <spring:bind path="mediaProgramAdd.mux">
@@ -94,6 +101,14 @@
 <input type="submit" value="<fmt:message key="medias.program.add.run" />">
 </form>
 
+<div id="ipHelp">
+<table><tr><td style="width: 30px">
+<img src="<c:url value="/img/help.png" />" alt="Help" />
+</td><td>
+<fmt:message key="medias.program.add.ip.help" />
+</td></tr></table>
+</div>
+
 <script type="text/javascript">
 
 /**
@@ -142,7 +157,11 @@ function onProtocolUpdate() {
     var protocol = select.options[select.selectedIndex].value;
     if(protocol == "UDP_MULTICAST") {
         document.getElementById("announcements_SAP").disabled = false;
+        document.getElementById("ipTr").style.display = "table-row";
+        document.getElementById("ipHelp").style.display = "block";
     } else {
+        document.getElementById("ipTr").style.display = "none";
+        document.getElementById("ipHelp").style.display = "none";
         var input = document.getElementById("announcements_SAP");
         input.checked = false;
         input.disabled = true;



More information about the vlma-devel mailing list