1 /*****************************************************************************
2 * Video.java: JVLC Video Output
3 *****************************************************************************
5 * Copyright (C) 1998-2008 the VideoLAN team
7 * Author: Filippo Carone <filippo@carone.org>
8 * Philippe Morin <phmorin@free.fr>
10 * Created on 28-feb-2006
12 * $Id: JVLC.java 20141 2007-05-16 19:31:35Z littlejohn $
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.
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.
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.
29 package org.videolan.jvlc;
31 import java.awt.Dimension;
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;
40 private final LibVlcInstance libvlcInstance;
42 private final LibVlc libvlc;
44 public Video( JVLC jvlc) {
45 this.libvlcInstance = jvlc.getInstance();
46 this.libvlc = jvlc.getLibvlc();
50 * @see org.videolan.jvlc.VideoIntf#destroyVideo()
52 public void destroyVideo(MediaPlayer media)
54 libvlc_exception_t exception = new libvlc_exception_t();
55 libvlc.libvlc_video_destroy(media.getInstance(), exception );
59 * @see org.videolan.jvlc.VideoIntf#getFullscreen()
61 public boolean getFullscreen(MediaPlayer media) {
62 libvlc_exception_t exception = new libvlc_exception_t();
63 return libvlc.libvlc_get_fullscreen(media.getInstance(), exception) == 1 ? true : false;
67 * @see org.videolan.jvlc.VideoIntf#getSnapshot(java.lang.String)
69 public void getSnapshot(MediaPlayer media, String filepath, int width, int height) {
70 libvlc_exception_t exception = new libvlc_exception_t();
71 libvlc.libvlc_video_take_snapshot(media.getInstance(), filepath, width, height, exception);
75 * @see org.videolan.jvlc.VideoIntf#getVideoHeight()
77 public int getHeight(MediaPlayer media) {
78 libvlc_exception_t exception = new libvlc_exception_t();
79 return libvlc.libvlc_video_get_height(media.getInstance(), exception);
83 * @see org.videolan.jvlc.VideoIntf#getVideoWidth()
85 public int getWidth(MediaPlayer media) {
86 libvlc_exception_t exception = new libvlc_exception_t();
87 return libvlc.libvlc_video_get_width(media.getInstance(), exception);
91 * @see org.videolan.jvlc.VideoIntf#reparentVideo(java.awt.Component)
93 public void reparent(MediaPlayer media, java.awt.Canvas canvas) {
94 libvlc_exception_t exception = new libvlc_exception_t();
95 long drawable = com.sun.jna.Native.getComponentID(canvas);
96 libvlc.libvlc_video_reparent(media.getInstance(), drawable, exception);
100 * @see org.videolan.jvlc.VideoIntf#resizeVideo(int, int)
102 public void setSize(int width, int height) {
103 libvlc_exception_t exception = new libvlc_exception_t();
104 libvlc.libvlc_video_set_size(libvlcInstance, width, height, exception);
108 * @see org.videolan.jvlc.VideoIntf#setFullscreen(boolean)
110 public void setFullscreen(MediaPlayer media, boolean fullscreen) {
111 libvlc_exception_t exception = new libvlc_exception_t();
112 libvlc.libvlc_set_fullscreen(media.getInstance(), fullscreen? 1 : 0, exception);
116 * @see org.videolan.jvlc.VideoIntf#toggleFullscreen()
118 public void toggleFullscreen(MediaPlayer media) {
119 libvlc_exception_t exception = new libvlc_exception_t();
120 libvlc.libvlc_toggle_fullscreen(media.getInstance(), exception);
124 * @see org.videolan.jvlc.VideoIntf#getSize()
126 public Dimension getSize(MediaPlayer media) {
127 return new Dimension (getWidth(media), getHeight(media));
131 * @see org.videolan.jvlc.VideoIntf#setSize(java.awt.Dimension)
133 public void setSize(Dimension d) {
134 setSize(d.width, d.height);