]> git.sesse.net Git - vlc/blob - projects/mozilla/vlcplugin.h
Refactor toolbar sizing.
[vlc] / projects / mozilla / vlcplugin.h
1 /*****************************************************************************
2  * vlcplugin.h: a VLC plugin for Mozilla
3  *****************************************************************************
4  * Copyright (C) 2002-2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8             Damien Fouilleul <damienf@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*******************************************************************************
26  * Instance state information about the plugin.
27  ******************************************************************************/
28 #ifndef __VLCPLUGIN_H__
29 #define __VLCPLUGIN_H__
30
31 #include <vlc/libvlc.h>
32 #include <npapi.h>
33 #include "control/nporuntime.h"
34
35 #if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
36 #define XP_UNIX 1
37 #elif defined(XP_MACOSX)
38 #undef XP_UNIX
39 #endif
40
41 #ifdef XP_WIN
42     /* Windows stuff */
43 #endif
44
45 #ifdef XP_MACOSX
46     /* Mac OS X stuff */
47 #   include <Quickdraw.h>
48 #endif
49
50 #ifdef XP_UNIX
51     /* X11 stuff */
52 #   include <X11/Xlib.h>
53 #   include <X11/Intrinsic.h>
54 #   include <X11/StringDefs.h>
55 #   include <X11/X.h>
56
57 #   ifndef __APPLE__
58 #       include <X11/xpm.h>
59 #   endif
60 #endif
61
62 #ifndef __MAX
63 #   define __MAX(a, b)   ( ((a) > (b)) ? (a) : (b) )
64 #endif
65 #ifndef __MIN
66 #   define __MIN(a, b)   ( ((a) < (b)) ? (a) : (b) )
67 #endif
68
69 class VlcPlugin
70 {
71 public:
72              VlcPlugin( NPP, uint16 );
73     virtual ~VlcPlugin();
74
75     NPError             init(int argc, char* const argn[], char* const argv[]);
76     libvlc_instance_t*  getVLC()
77                             { return libvlc_instance; };
78     NPP                 getBrowser()
79                             { return p_browser; };
80     char*               getAbsoluteURL(const char *url);
81     NPWindow&           getWindow()
82                             { return npwindow; };
83     void                setWindow(const NPWindow &window)
84                             { npwindow = window; };
85
86     NPClass*            getScriptClass()
87                             { return p_scriptClass; };
88
89     void                setLog(libvlc_log_t *log)
90                             { libvlc_log = log; };
91     libvlc_log_t*       getLog()
92                             { return libvlc_log; };
93 #if XP_WIN
94     WNDPROC             getWindowProc()
95                             { return pf_wndproc; };
96     void                setWindowProc(WNDPROC wndproc)
97                             { pf_wndproc = wndproc; };
98 #endif
99
100 #if XP_UNIX
101     int                 setSize(unsigned width, unsigned height);
102     Window              getVideoWindow()
103                             { return npvideo; };
104     void                setVideoWindow(Window window)
105                             { npvideo = window; };
106     Window              getControlWindow()
107                             { return npcontrol; };
108     void                setControlWindow(Window window)
109                             { npcontrol = window; };
110
111     void                showToolbar();
112     void                hideToolbar();
113     void                redrawToolbar();
114     void                getToolbarSize(unsigned int *width, unsigned int *height)
115                             { *width = i_tb_width; *height = i_tb_height; };
116     int                 setToolbarSize(unsigned int width, unsigned int height)
117                             { i_tb_width = width; i_tb_height = height; return 1; };
118 #endif
119
120     uint16    i_npmode; /* either NP_EMBED or NP_FULL */
121
122     /* plugin properties */
123     int      b_stream;
124     int      b_autoplay;
125     int      b_toolbar;
126     char *   psz_target;
127
128 private:
129     /* VLC reference */
130     libvlc_instance_t   *libvlc_instance;
131     libvlc_log_t        *libvlc_log;
132     NPClass             *p_scriptClass;
133
134     /* browser reference */
135     NPP     p_browser;
136     char*   psz_baseURL;
137
138     /* display settings */
139     NPWindow  npwindow;
140 #if XP_WIN
141     WNDPROC   pf_wndproc;
142 #endif
143 #if XP_UNIX
144     unsigned int     i_width, i_height;
145     unsigned int     i_tb_width, i_tb_height;
146     Window           npvideo, npcontrol;
147
148     XImage *p_btnPlay;
149     XImage *p_btnPause;
150     XImage *p_btnStop;
151     XImage *p_timeline;
152     XImage *p_btnTime;
153     XImage *p_btnFullscreen;
154     XImage *p_btnMute;
155     XImage *p_btnUnmute;
156
157     int i_last_position;
158 #endif
159 };
160
161 /*******************************************************************************
162  * Plugin properties.
163  ******************************************************************************/
164 #define PLUGIN_NAME         "VLC Multimedia Plug-in"
165 #define PLUGIN_DESCRIPTION \
166     "Version %s, copyright 1996-2007 The VideoLAN Team" \
167     "<br><a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
168
169 #define PLUGIN_MIMETYPES \
170     /* MPEG-1 and MPEG-2 */ \
171     "audio/mpeg:mp2,mp3,mpga,mpega:MPEG audio;" \
172     "audio/x-mpeg:mp2,mp3,mpga,mpega:MPEG audio;" \
173     "video/mpeg:mpg,mpeg,mpe:MPEG video;" \
174     "video/x-mpeg:mpg,mpeg,mpe:MPEG video;" \
175     "video/mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \
176     "video/x-mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \
177     /* MPEG-4 */ \
178     "video/mpeg4:mp4,mpg4:MPEG-4 video;" \
179     "audio/mpeg4:mp4,mpg4:MPEG-4 audio;" \
180     "application/mpeg4-iod:mp4,mpg4:MPEG-4 video;" \
181     "application/mpeg4-muxcodetable:mp4,mpg4:MPEG-4 video;" \
182     /* AVI */ \
183     "video/x-msvideo:avi:AVI video;" \
184     /* QuickTime */ \
185     "video/quicktime:mov,qt:QuickTime video;" \
186     /* OGG */ \
187     "application/x-ogg:ogg:Ogg stream;" \
188     "application/ogg:ogg:Ogg stream;" \
189     /* VLC */ \
190     "application/x-vlc-plugin:vlc:VLC plug-in;" \
191     /* Windows Media */ \
192     "video/x-ms-asf-plugin:asf,asx:Windows Media Video;" \
193     "video/x-ms-asf:asf,asx:Windows Media Video;" \
194     "application/x-mplayer2::Windows Media;" \
195     "video/x-ms-wmv:wmv:Windows Media;" \
196     "video/x-ms-wvx:wvx:Windows Media Video;" \
197     /* Google VLC */ \
198     "application/x-google-vlc-plugin::Google VLC plug-in;" \
199     /* WAV audio */ \
200     "audio/wav:wav:WAV audio;" \
201     "audio/x-wav:wav:WAV audio;" \
202     /* 3GPP */ \
203     "audio/3gpp:3gp,3gpp:3GPP audio;" \
204     "video/3gpp:3gp,3gpp:3GPP video;" \
205     /* 3GPP2 */ \
206     "audio/3gpp2:3g2,3gpp2:3GPP2 audio;" \
207     "video/3gpp2:3g2,3gpp2:3GPP2 video;" \
208     /* DIVX */ \
209     "video/divx:divx:DivX video;" \
210     /* FLV */ \
211     "video/flv:flv:FLV video;" \
212     "video/x-flv:flv:FLV video;"
213
214
215
216 #endif