]> git.sesse.net Git - vlc/blob - bindings/java/org/videolan/jvlc/Video.java
402083081a2a6bf2d32c9ee1a4e62828c858beda
[vlc] / bindings / java / org / videolan / jvlc / Video.java
1 /*****************************************************************************
2  * Video.java: JVLC Video Output
3  *****************************************************************************
4  *
5  * Copyright (C) 1998-2008 the VideoLAN team
6  * 
7  * Author: Filippo Carone <filippo@carone.org>
8  *         Philippe Morin <phmorin@free.fr>
9  *
10  * Created on 28-feb-2006
11  *
12  * $Id: JVLC.java 20141 2007-05-16 19:31:35Z littlejohn $
13  *
14  * This program is free software; you can redistribute it
15  * and/or modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2 of the
17  * License, or (at your option) any later version.
18  * 
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22  * General Public License for more details.
23  * 
24  * You should have received a copy of the GNU General Public
25  * License along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
27  * 
28  */
29 package org.videolan.jvlc;
30
31 import java.awt.Dimension;
32
33 import org.videolan.jvlc.internal.LibVlc;
34 import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
35 import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
36
37 public class Video
38 {
39         
40         private final LibVlcInstance libvlcInstance;
41         
42     private final LibVlc libvlc;
43     
44         public Video( JVLC jvlc) {
45                 this.libvlcInstance = jvlc.getInstance();
46                 this.libvlc = jvlc.getLibvlc();
47         }
48
49         /* (non-Javadoc)
50          * @see org.videolan.jvlc.VideoIntf#destroyVideo()
51          */
52         public void destroyVideo(MediaInstance media)
53         {
54                 libvlc_exception_t exception = new libvlc_exception_t();
55         libvlc.libvlc_video_destroy(media.getInstance(), exception );
56                 
57         }
58
59         /* (non-Javadoc)
60          * @see org.videolan.jvlc.VideoIntf#getFullscreen()
61          */
62         public boolean getFullscreen(MediaInstance media)  {
63             libvlc_exception_t exception = new libvlc_exception_t();
64             return libvlc.libvlc_get_fullscreen(media.getInstance(), exception) == 1 ? true : false;
65         }
66
67         /* (non-Javadoc)
68          * @see org.videolan.jvlc.VideoIntf#getSnapshot(java.lang.String)
69          */
70         public void getSnapshot(MediaInstance media, String filepath, int width, int height)  {
71             libvlc_exception_t exception = new libvlc_exception_t();
72             libvlc.libvlc_video_take_snapshot(media.getInstance(), filepath, width, height, exception);
73         }
74
75         /* (non-Javadoc)
76          * @see org.videolan.jvlc.VideoIntf#getVideoHeight()
77          */
78         public int getHeight(MediaInstance media)  {
79             libvlc_exception_t exception = new libvlc_exception_t();
80             return libvlc.libvlc_video_get_height(media.getInstance(), exception);
81         }
82
83         /* (non-Javadoc)
84          * @see org.videolan.jvlc.VideoIntf#getVideoWidth()
85          */
86         public int getWidth(MediaInstance media)  {
87         libvlc_exception_t exception = new libvlc_exception_t();
88         return libvlc.libvlc_video_get_height(media.getInstance(), exception);
89         }
90
91         /* (non-Javadoc)
92          * @see org.videolan.jvlc.VideoIntf#reparentVideo(java.awt.Component)
93          */
94         public void reparent(MediaInstance media, java.awt.Canvas canvas)  {
95             libvlc_exception_t exception = new libvlc_exception_t();
96         long drawable = com.sun.jna.Native.getComponentID(canvas);
97             libvlc.libvlc_video_reparent(media.getInstance(), drawable, exception);
98         }
99
100         /* (non-Javadoc)
101          * @see org.videolan.jvlc.VideoIntf#resizeVideo(int, int)
102          */
103         public void setSize(int width, int height)  {
104         libvlc_exception_t exception = new libvlc_exception_t();
105         libvlc.libvlc_video_set_size(libvlcInstance, width, height, exception);
106         }
107
108         /* (non-Javadoc)
109          * @see org.videolan.jvlc.VideoIntf#setFullscreen(boolean)
110          */
111         public void setFullscreen(MediaInstance media, boolean fullscreen)  {
112             libvlc_exception_t exception = new libvlc_exception_t();
113             libvlc.libvlc_set_fullscreen(media.getInstance(), fullscreen? 1 : 0, exception);
114         }
115
116         /* (non-Javadoc)
117          * @see org.videolan.jvlc.VideoIntf#toggleFullscreen()
118          */
119         public void toggleFullscreen(MediaInstance media)  {
120         libvlc_exception_t exception = new libvlc_exception_t();
121         libvlc.libvlc_toggle_fullscreen(media.getInstance(), exception);
122         }
123         
124         /* (non-Javadoc)
125          * @see org.videolan.jvlc.VideoIntf#getSize()
126          */
127         public Dimension getSize(MediaInstance media)  {
128                 return new Dimension (getWidth(media), getHeight(media));
129         }
130
131         /* (non-Javadoc)
132          * @see org.videolan.jvlc.VideoIntf#setSize(java.awt.Dimension)
133          */
134         public void setSize(Dimension d)  {
135                 setSize(d.width, d.height);
136         }
137 }