]> git.sesse.net Git - vlc/blob - projects/mozilla/vlcplugin.h
Fix mozilla toolbar button click logic.
[vlc] / projects / mozilla / vlcplugin.h
1 /*****************************************************************************
2  * vlcplugin.h: a VLC plugin for Mozilla
3  *****************************************************************************
4  * Copyright (C) 2002-2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *          Damien Fouilleul <damienf@videolan.org>
9  *         Jean-Paul Saman <jpsaman@videolan.org>
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 /*******************************************************************************
27  * Instance state information about the plugin.
28  ******************************************************************************/
29 #ifndef __VLCPLUGIN_H__
30 #define __VLCPLUGIN_H__
31
32 #include <vlc/vlc.h>
33 #include <npapi.h>
34 #include "control/nporuntime.h"
35
36 #if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
37 #define XP_UNIX 1
38 #elif defined(XP_MACOSX)
39 #undef XP_UNIX
40 #endif
41
42 #ifdef XP_WIN
43     /* Windows stuff */
44 #endif
45
46 #ifdef XP_MACOSX
47     /* Mac OS X stuff */
48 #   include <Quickdraw.h>
49 #endif
50
51 #ifdef XP_UNIX
52     /* X11 stuff */
53 #   include <X11/Xlib.h>
54 #   include <X11/Intrinsic.h>
55 #   include <X11/StringDefs.h>
56 #   include <X11/X.h>
57
58 #   ifndef __APPLE__
59 #       include <X11/xpm.h>
60 #   endif
61 #endif
62
63 #ifndef __MAX
64 #   define __MAX(a, b)   ( ((a) > (b)) ? (a) : (b) )
65 #endif
66 #ifndef __MIN
67 #   define __MIN(a, b)   ( ((a) < (b)) ? (a) : (b) )
68 #endif
69
70 typedef enum vlc_toolbar_clicked_e {
71     clicked_Unknown = 0,
72     clicked_Play,
73     clicked_Pause,
74     clicked_Stop,
75     clicked_timeline,
76     clicked_Time,
77     clicked_Fullscreen,
78     clicked_Mute,
79     clicked_Unmute
80 } vlc_toolbar_clicked_t;
81
82 class VlcPlugin
83 {
84 public:
85              VlcPlugin( NPP, uint16 );
86     virtual ~VlcPlugin();
87
88     NPError             init(int argc, char* const argn[], char* const argv[]);
89     libvlc_instance_t*  getVLC()
90                             { return libvlc_instance; };
91     NPP                 getBrowser()
92                             { return p_browser; };
93     char*               getAbsoluteURL(const char *url);
94     NPWindow&           getWindow()
95                             { return npwindow; };
96     void                setWindow(const NPWindow &window)
97                             { npwindow = window; };
98
99     NPClass*            getScriptClass()
100                             { return p_scriptClass; };
101
102     void                setLog(libvlc_log_t *log)
103                             { libvlc_log = log; };
104     libvlc_log_t*       getLog()
105                             { return libvlc_log; };
106 #if XP_WIN
107     WNDPROC             getWindowProc()
108                             { return pf_wndproc; };
109     void                setWindowProc(WNDPROC wndproc)
110                             { pf_wndproc = wndproc; };
111 #endif
112
113 #if XP_UNIX
114     int                 setSize(unsigned width, unsigned height);
115     Window              getVideoWindow()
116                             { return npvideo; };
117     void                setVideoWindow(Window window)
118                             { npvideo = window; };
119     Window              getControlWindow()
120                             { return npcontrol; };
121     void                setControlWindow(Window window)
122                             { npcontrol = window; };
123
124     void                showToolbar();
125     void                hideToolbar();
126     void                redrawToolbar();
127     void                getToolbarSize(unsigned int *width, unsigned int *height)
128                             { *width = i_tb_width; *height = i_tb_height; };
129     int                 setToolbarSize(unsigned int width, unsigned int height)
130                             { i_tb_width = width; i_tb_height = height; return 1; };
131     vlc_toolbar_clicked_t getToolbarButtonClicked( int i_xpos, int i_ypos );
132 #endif
133
134     uint16    i_npmode; /* either NP_EMBED or NP_FULL */
135
136     /* plugin properties */
137     int      b_stream;
138     int      b_autoplay;
139     int      b_toolbar;
140     char *   psz_target;
141
142 private:
143     /* VLC reference */
144     libvlc_instance_t   *libvlc_instance;
145     libvlc_log_t        *libvlc_log;
146     NPClass             *p_scriptClass;
147
148     /* browser reference */
149     NPP     p_browser;
150     char*   psz_baseURL;
151
152     /* display settings */
153     NPWindow  npwindow;
154 #if XP_WIN
155     WNDPROC   pf_wndproc;
156 #endif
157 #if XP_UNIX
158     unsigned int     i_width, i_height;
159     unsigned int     i_tb_width, i_tb_height;
160     Window           npvideo, npcontrol;
161
162     XImage *p_btnPlay;
163     XImage *p_btnPause;
164     XImage *p_btnStop;
165     XImage *p_timeline;
166     XImage *p_btnTime;
167     XImage *p_btnFullscreen;
168     XImage *p_btnMute;
169     XImage *p_btnUnmute;
170
171     int i_last_position;
172 #endif
173 };
174
175 /*******************************************************************************
176  * Plugin properties.
177  ******************************************************************************/
178 #define PLUGIN_NAME         "VLC Multimedia Plug-in"
179 #define PLUGIN_DESCRIPTION \
180     "Version %s, copyright 1996-2007 The VideoLAN Team" \
181     "<br><a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
182
183 #define PLUGIN_MIMETYPES \
184     /* MPEG-1 and MPEG-2 */ \
185     "audio/mpeg:mp2,mp3,mpga,mpega:MPEG audio;" \
186     "audio/x-mpeg:mp2,mp3,mpga,mpega:MPEG audio;" \
187     "video/mpeg:mpg,mpeg,mpe:MPEG video;" \
188     "video/x-mpeg:mpg,mpeg,mpe:MPEG video;" \
189     "video/mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \
190     "video/x-mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \
191     /* MPEG-4 */ \
192     "video/mpeg4:mp4,mpg4:MPEG-4 video;" \
193     "audio/mpeg4:mp4,mpg4:MPEG-4 audio;" \
194     "application/mpeg4-iod:mp4,mpg4:MPEG-4 video;" \
195     "application/mpeg4-muxcodetable:mp4,mpg4:MPEG-4 video;" \
196     /* AVI */ \
197     "video/x-msvideo:avi:AVI video;" \
198     /* QuickTime */ \
199     "video/quicktime:mov,qt:QuickTime video;" \
200     /* OGG */ \
201     "application/x-ogg:ogg:Ogg stream;" \
202     "application/ogg:ogg:Ogg stream;" \
203     /* VLC */ \
204     "application/x-vlc-plugin:vlc:VLC plug-in;" \
205     /* Windows Media */ \
206     "video/x-ms-asf-plugin:asf,asx:Windows Media Video;" \
207     "video/x-ms-asf:asf,asx:Windows Media Video;" \
208     "application/x-mplayer2::Windows Media;" \
209     "video/x-ms-wmv:wmv:Windows Media;" \
210     "video/x-ms-wvx:wvx:Windows Media Video;" \
211     /* Google VLC */ \
212     "application/x-google-vlc-plugin::Google VLC plug-in;" \
213     /* WAV audio */ \
214     "audio/wav:wav:WAV audio;" \
215     "audio/x-wav:wav:WAV audio;" \
216     /* 3GPP */ \
217     "audio/3gpp:3gp,3gpp:3GPP audio;" \
218     "video/3gpp:3gp,3gpp:3GPP video;" \
219     /* 3GPP2 */ \
220     "audio/3gpp2:3g2,3gpp2:3GPP2 audio;" \
221     "video/3gpp2:3g2,3gpp2:3GPP2 video;" \
222     /* DIVX */ \
223     "video/divx:divx:DivX video;" \
224     /* FLV */ \
225     "video/flv:flv:FLV video;" \
226     "video/x-flv:flv:FLV video;"
227
228
229
230 #endif