]> git.sesse.net Git - vlc/blob - bindings/java/core/src/main/java/org/videolan/jvlc/VLM.java
36cde32bd08dcf14b1f58e2727a680a332bf92d1
[vlc] / bindings / java / core / src / main / java / org / videolan / jvlc / VLM.java
1 /*****************************************************************************
2  * VLM.java: VLC Java Bindings
3  *****************************************************************************
4  * Copyright (C) 1998-2008 the VideoLAN team
5  *
6  * Authors: Filippo Carone <filippo@carone.org>
7  *
8  *
9  * $Id $
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24  *****************************************************************************/
25
26 package org.videolan.jvlc;
27
28 import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
29
30
31 public class VLM
32 {
33
34     private JVLC jvlc;
35
36     private volatile boolean released;
37
38     public VLM(JVLC jvlc)
39     {
40         this.jvlc = jvlc;
41     }
42
43     public void addBroadcast(String name, String input, String output, String[] options, boolean enabled, boolean loop)
44     {
45         libvlc_exception_t exception = new libvlc_exception_t();
46         jvlc.getLibvlc().libvlc_vlm_add_broadcast(
47             jvlc.getInstance(),
48             name,
49             input,
50             output,
51             options == null ? 0 : options.length,
52             options,
53             enabled ? 1 : 0,
54             loop ? 1 : 0,
55             exception);
56     }
57
58     public void addVod(String name, String input, String[] options, boolean enabled, String muxer)
59     {
60         libvlc_exception_t exception = new libvlc_exception_t();
61         jvlc.getLibvlc().libvlc_vlm_add_vod(
62             jvlc.getInstance(),
63             name,
64             input,
65             options == null ? 0 : options.length,
66             options,
67             enabled ? 1 : 0,
68             muxer,
69             exception);
70     }
71
72     public void deleteMedia(String name)
73     {
74         libvlc_exception_t exception = new libvlc_exception_t();
75         jvlc.getLibvlc().libvlc_vlm_del_media(jvlc.getInstance(), name, exception);
76     }
77
78     public void enableMedia(String name)
79     {
80         libvlc_exception_t exception = new libvlc_exception_t();
81         jvlc.getLibvlc().libvlc_vlm_set_enabled(jvlc.getInstance(), name, 1, exception);
82     }
83
84     public void disableMedia(String name)
85     {
86         libvlc_exception_t exception = new libvlc_exception_t();
87         jvlc.getLibvlc().libvlc_vlm_set_enabled(jvlc.getInstance(), name, 0, exception);
88     }
89
90     public void setMediaOutput(String name, String output)
91     {
92         libvlc_exception_t exception = new libvlc_exception_t();
93         jvlc.getLibvlc().libvlc_vlm_set_output(jvlc.getInstance(), name, output, exception);
94     }
95
96     public void setMediaInput(String name, String input)
97     {
98         libvlc_exception_t exception = new libvlc_exception_t();
99         jvlc.getLibvlc().libvlc_vlm_set_input(jvlc.getInstance(), name, input, exception);
100     }
101
102     public void addMediaInput(String name, String input)
103     {
104         libvlc_exception_t exception = new libvlc_exception_t();
105         jvlc.getLibvlc().libvlc_vlm_add_input(jvlc.getInstance(), name, input, exception);
106     }
107
108     public void setMux(String name, String muxer)
109     {
110         libvlc_exception_t exception = new libvlc_exception_t();
111         jvlc.getLibvlc().libvlc_vlm_set_mux(jvlc.getInstance(), name, muxer, exception);
112     }
113
114     public void setMediaLoop(String media, boolean loop)
115     {
116         libvlc_exception_t exception = new libvlc_exception_t();
117         jvlc.getLibvlc().libvlc_vlm_set_loop(jvlc.getInstance(), media, loop ? 1 : 0, exception);
118     }
119
120     public void changeMedia(String name, String input, String output, String[] options, boolean enabled, boolean loop)
121     {
122         libvlc_exception_t exception = new libvlc_exception_t();
123         jvlc.getLibvlc().libvlc_vlm_change_media(
124             jvlc.getInstance(),
125             name,
126             input,
127             output,
128             options == null ? 0 : options.length,
129             options,
130             enabled ? 1 : 0,
131             loop ? 1 : 0,
132             exception);
133     }
134
135     public void playMedia(String name)
136     {
137         libvlc_exception_t exception = new libvlc_exception_t();
138         jvlc.getLibvlc().libvlc_vlm_play_media(jvlc.getInstance(), name, exception);
139     }
140
141     public void stopMedia(String name)
142     {
143         libvlc_exception_t exception = new libvlc_exception_t();
144         jvlc.getLibvlc().libvlc_vlm_stop_media(jvlc.getInstance(), name, exception);
145     }
146
147     public void pauseMedia(String name)
148     {
149         libvlc_exception_t exception = new libvlc_exception_t();
150         jvlc.getLibvlc().libvlc_vlm_pause_media(jvlc.getInstance(), name, exception);
151     }
152
153     public void seekMedia(String name, float percentage)
154     {
155         libvlc_exception_t exception = new libvlc_exception_t();
156         jvlc.getLibvlc().libvlc_vlm_seek_media(jvlc.getInstance(), name, percentage, exception);
157     }
158
159     public void showMedia(String name)
160     {
161         libvlc_exception_t exception = new libvlc_exception_t();
162         jvlc.getLibvlc().libvlc_vlm_show_media(jvlc.getInstance(), name, exception);
163     }
164
165     /**
166      * Releases native resources related to VLM.
167      */
168     public void release()
169     {
170         if (released)
171         {
172             return;
173         }
174         released = true;
175         libvlc_exception_t exception = new libvlc_exception_t();
176         jvlc.getLibvlc().libvlc_vlm_release(jvlc.getInstance(), exception);
177     }
178
179     /**
180      * {@inheritDoc}
181      */
182     @Override
183     protected void finalize() throws Throwable
184     {
185         release();
186         super.finalize();
187     }
188
189 }