>From 34d35be66fba01ebcdd11556ab40d6a930230b01 Mon Sep 17 00:00:00 2001
From: Adrien Grand <jpountz@videolan.org>
Date: Sun, 20 Jul 2008 13:53:41 +0200
Subject: [PATCH] Java bindings: Add VOD support.

---
 .../core/src/main/java/org/videolan/jvlc/VLM.java  |   24 ++++-
 .../java/org/videolan/jvlc/internal/LibVlc.java    |    7 +-
 .../src/test/java/org/videolan/jvlc/VLMTest.java   |  124 +++++++++++++++++---
 bindings/java/core/src/test/resources/sample.avi   |  Bin 0 -> 7112 bytes
 4 files changed, 135 insertions(+), 20 deletions(-)
 create mode 100644 bindings/java/core/src/test/resources/sample.avi

diff --git a/bindings/java/core/src/main/java/org/videolan/jvlc/VLM.java b/bindings/java/core/src/main/java/org/videolan/jvlc/VLM.java
index 7763726..36cde32 100644
--- a/bindings/java/core/src/main/java/org/videolan/jvlc/VLM.java
+++ b/bindings/java/core/src/main/java/org/videolan/jvlc/VLM.java
@@ -32,7 +32,7 @@ public class VLM
 {
 
     private JVLC jvlc;
-    
+
     private volatile boolean released;
 
     public VLM(JVLC jvlc)
@@ -55,6 +55,20 @@ public class VLM
             exception);
     }
 
+    public void addVod(String name, String input, String[] options, boolean enabled, String muxer)
+    {
+        libvlc_exception_t exception = new libvlc_exception_t();
+        jvlc.getLibvlc().libvlc_vlm_add_vod(
+            jvlc.getInstance(),
+            name,
+            input,
+            options == null ? 0 : options.length,
+            options,
+            enabled ? 1 : 0,
+            muxer,
+            exception);
+    }
+
     public void deleteMedia(String name)
     {
         libvlc_exception_t exception = new libvlc_exception_t();
@@ -91,6 +105,12 @@ public class VLM
         jvlc.getLibvlc().libvlc_vlm_add_input(jvlc.getInstance(), name, input, exception);
     }
 
+    public void setMux(String name, String muxer)
+    {
+        libvlc_exception_t exception = new libvlc_exception_t();
+        jvlc.getLibvlc().libvlc_vlm_set_mux(jvlc.getInstance(), name, muxer, exception);
+    }
+
     public void setMediaLoop(String media, boolean loop)
     {
         libvlc_exception_t exception = new libvlc_exception_t();
@@ -165,7 +185,5 @@ public class VLM
         release();
         super.finalize();
     }
-    
-    
 
 }
diff --git a/bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlc.java b/bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlc.java
index e4add27..c05d7d8 100644
--- a/bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlc.java
+++ b/bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlc.java
@@ -510,6 +510,9 @@ public interface LibVlc extends Library
     void libvlc_vlm_add_broadcast(LibVlcInstance p_instance, String psz_name, String psz_input, String psz_output,
         int i_options, String[] ppsz_options, int b_enabled, int b_loop, libvlc_exception_t p_e);
 
+    void libvlc_vlm_add_vod(LibVlcInstance p_instance, String psz_name, String psz_input, int i_options,
+        String[] ppsz_options, int b_enabled, String psz_mux, libvlc_exception_t p_e);
+
     void libvlc_vlm_del_media(LibVlcInstance p_instance, String psz_name, libvlc_exception_t p_e);
 
     void libvlc_vlm_set_enabled(LibVlcInstance p_instance, String psz_name, int b_enabled, libvlc_exception_t p_e);
@@ -522,6 +525,8 @@ public interface LibVlc extends Library
 
     void libvlc_vlm_set_loop(LibVlcInstance p_instance, String psz_name, int b_loop, libvlc_exception_t p_e);
 
+    void libvlc_vlm_set_mux(LibVlcInstance p_instance, String psz_name, String psz_mux, libvlc_exception_t p_e);
+
     void libvlc_vlm_change_media(LibVlcInstance p_instance, String psz_name, String psz_input, String psz_output,
         int i_options, String[] ppsz_options, int b_enabled, int b_loop, libvlc_exception_t p_e);
 
@@ -536,7 +541,7 @@ public interface LibVlc extends Library
     String libvlc_vlm_show_media(LibVlcInstance p_instance, String psz_name, libvlc_exception_t p_e);
 
     void libvlc_vlm_release(LibVlcInstance p_instance, libvlc_exception_t p_e);
-    
+
     // event manager
 
     public static interface LibVlcCallback extends Callback
diff --git a/bindings/java/core/src/test/java/org/videolan/jvlc/VLMTest.java b/bindings/java/core/src/test/java/org/videolan/jvlc/VLMTest.java
index c3938ae..0ea38f1 100644
--- a/bindings/java/core/src/test/java/org/videolan/jvlc/VLMTest.java
+++ b/bindings/java/core/src/test/java/org/videolan/jvlc/VLMTest.java
@@ -36,14 +36,14 @@ public class VLMTest
 {
     private JVLC jvlc;
     
-    private String mrl = getClass().getResource("/raffa_voice.ogg").getFile();
+    private String mrl = getClass().getResource("/sample.avi").getFile();
     
     private String mediaName = "test";
     
     @Before
     public void setup()
     {
-        jvlc = new JVLC("-I dummy --aout=dummy --vout=dummy");
+        jvlc = new JVLC("-I dummy --aout=dummy --vout=dummy --rtsp-host 127.0.0.1:5554");
         jvlc.setLogVerbosity(LoggerVerbosityLevel.INFO);
     }
 
@@ -66,9 +66,16 @@ public class VLMTest
         VLM vlm = jvlc.getVLM();
         vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
     }
+
+    @Test
+    public void testAddVod()
+    {
+        VLM vlm = jvlc.getVLM();
+        vlm.addVod(mediaName, "file://" + mrl, null, true, null);
+    }
     
     @Test
-    public void testShowMedia()
+    public void testShowBroadcastMedia()
     {
         VLM vlm = jvlc.getVLM();
         vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
@@ -76,23 +83,49 @@ public class VLMTest
     }
     
     @Test
-    public void testDisableMedia()
+    public void testShowVodMedia()
+    {
+        VLM vlm = jvlc.getVLM();
+        vlm.addVod(mediaName, "file://" + mrl, null, true, null);
+        vlm.showMedia(mediaName);
+    }
+
+    @Test
+    public void testDisableBroadcastMedia()
     {
         VLM vlm = jvlc.getVLM();
         vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
         vlm.disableMedia(mediaName);
     }
-    
+
+    @Test
+    public void testDisableVodMedia()
+    {
+        VLM vlm = jvlc.getVLM();
+        vlm.addVod(mediaName, "file://" + mrl, null, true, null);
+        vlm.disableMedia(mediaName);
+    }
+
+
     @Test
-    public void testPlayMedia()
+    public void testPlayBroadcastMedia()
     {
         VLM vlm = jvlc.getVLM();
         vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
         vlm.playMedia(mediaName);
     }
-    
+
+    @Test
+    public void testPlayVodMedia()
+    {
+        VLM vlm = jvlc.getVLM();
+        vlm.addVod(mediaName, "file://" + mrl, null, true, null);
+        vlm.playMedia(mediaName);
+    }
+
+
     @Test
-    public void testPauseMedia()
+    public void testPauseBroadcastMedia()
     {
         VLM vlm = jvlc.getVLM();
         vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
@@ -101,7 +134,16 @@ public class VLMTest
     }
 
     @Test
-    public void testStopMedia()
+    public void testPauseVodMedia()
+    {
+        VLM vlm = jvlc.getVLM();
+        vlm.addVod(mediaName, "file://" + mrl, null, true, null);
+        vlm.playMedia(mediaName);
+        vlm.pauseMedia(mediaName);
+    }
+
+    @Test
+    public void testStopBroadcastMedia()
     {
         VLM vlm = jvlc.getVLM();
         vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
@@ -110,38 +152,81 @@ public class VLMTest
     }
 
     @Test
-    public void testSeekMedia()
+    public void testStopVodMedia()
+    {
+        VLM vlm = jvlc.getVLM();
+        vlm.addVod(mediaName, "file://" + mrl, null, true, null);
+        vlm.playMedia(mediaName);
+        vlm.stopMedia(mediaName);
+    }
+
+
+    @Test
+    public void testSeekBroadcastMedia()
     {
         VLM vlm = jvlc.getVLM();
         vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
         vlm.playMedia(mediaName);
         vlm.seekMedia(mediaName, 0.3f);
     }
-    
+
+    @Test
+    public void testSeekVodMedia()
+    {
+        VLM vlm = jvlc.getVLM();
+        vlm.addVod(mediaName, "file://" + mrl, null, true, null);
+        vlm.playMedia(mediaName);
+        vlm.seekMedia(mediaName, 0.3f);
+    }
+
     @Test
-    public void testAddMediaInput()
+    public void testAddMediaInputToBroadcast()
     {
         VLM vlm = jvlc.getVLM();
         vlm.addBroadcast(mediaName, "file://" + mrl, "", null, true, false);
         vlm.addMediaInput(mediaName, "file://" + mrl);
     }
-    
+
     @Test
-    public void testEnableMedia()
+    public void testAddMediaInputToVod()
+    {
+        VLM vlm = jvlc.getVLM();
+        vlm.addVod(mediaName, "file://" + mrl, null, true, null);
+        vlm.addMediaInput(mediaName, "file://" + mrl);
+    }
+
+    @Test
+    public void testEnableBroadcastMedia()
     {
         VLM vlm = jvlc.getVLM();
         vlm.addBroadcast(mediaName, "file://" + mrl, "", null, false, false);
         vlm.enableMedia(mediaName);
     }
+
+    @Test
+    public void testEnableVodMedia()
+    {
+        VLM vlm = jvlc.getVLM();
+        vlm.addVod(mediaName, "file://" + mrl, null, true, null);
+        vlm.enableMedia(mediaName);
+    }
     
     @Test
-    public void testDeleteMedia()
+    public void testDeleteBroadcastMedia()
     {
         VLM vlm = jvlc.getVLM();
         vlm.addBroadcast(mediaName, "file://" + mrl, "", null, false, false);
         vlm.deleteMedia(mediaName);
     }
-    
+
+    @Test
+    public void testDeleteVodMedia()
+    {
+        VLM vlm = jvlc.getVLM();
+        vlm.addVod(mediaName, "file://" + mrl, null, true, null);
+        vlm.deleteMedia(mediaName);
+    }
+
     @Test
     public void testMediaLoop()
     {
@@ -149,4 +234,11 @@ public class VLMTest
         vlm.addBroadcast(mediaName, "file://" + mrl, "", null, false, false);
         vlm.setMediaLoop(mediaName, true);
     }
+
+    @Test
+    public void testSetMux() {
+        VLM vlm = jvlc.getVLM();
+        vlm.addVod(mediaName, "file://" + mrl, null, true, null);
+        vlm.setMux(mediaName, "ts");
+    }
 }
diff --git a/bindings/java/core/src/test/resources/sample.avi b/bindings/java/core/src/test/resources/sample.avi
new file mode 100644
index 0000000000000000000000000000000000000000..b8b6d795070cd16b81a5144879c24050438e4edb
GIT binary patch
-- 
1.5.6.2

