]> git.sesse.net Git - vlc/blob - projects/mozilla/vlcplugin.h
Try to correctly guess which button has been clicked in the mozilla toolbar.
[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/vlc.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 typedef enum vlc_toolbar_clicked_e {
70     clicked_Unknown = 0,
71     clicked_Play,
72     clicked_Pause,
73     clicked_Stop,
74     clicked_timeline,
75     clicked_Time,
76     clicked_Fullscreen,
77     clicked_Mute,
78     clicked_Unmute
79 } vlc_toolbar_clicked_t;
80
81 class VlcPlugin
82 {
83 public:
84              VlcPlugin( NPP, uint16 );
85     virtual ~VlcPlugin();
86
87     NPError             init(int argc, char* const argn[], char* const argv[]);
88     libvlc_instance_t*  getVLC()
89                             { return libvlc_instance; };
90     NPP                 getBrowser()
91                             { return p_browser; };
92     char*               getAbsoluteURL(const char *url);
93     NPWindow&           getWindow()
94                             { return npwindow; };
95     void                setWindow(const NPWindow &window)
96                             { npwindow = window; };
97
98     NPClass*            getScriptClass()
99                             { return p_scriptClass; };
100
101     void                setLog(libvlc_log_t *log)
102                             { libvlc_log = log; };
103     libvlc_log_t*       getLog()
104                             { return libvlc_log; };
105 #if XP_WIN
106     WNDPROC             getWindowProc()
107                             { return pf_wndproc; };
108     void                setWindowProc(WNDPROC wndproc)
109                             { pf_wndproc = wndproc; };
110 #endif
111
112 #if XP_UNIX
113     int                 setSize(unsigned width, unsigned height);
114     Window              getVideoWindow()
115                             { return npvideo; };
116     void                setVideoWindow(Window window)
117                             { npvideo = window; };
118     Window              getControlWindow()
119                             { return npcontrol; };
120     void                setControlWindow(Window window)
121                             { npcontrol = window; };
122
123     void                showToolbar();
124     void                hideToolbar();
125     void                redrawToolbar();
126     void                getToolbarSize(unsigned int *width, unsigned int *height)
127                             { *width = i_tb_width; *height = i_tb_height; };
128     int                 setToolbarSize(unsigned int width, unsigned int height)
129                             { i_tb_width = width; i_tb_height = height; return 1; };
130     vlc_toolbar_clicked_t getToolbarButtonClicked( int i_xpos, int i_ypos );
131 #endif
132
133     uint16    i_npmode; /* either NP_EMBED or NP_FULL */
134
135     /* plugin properties */
136     int      b_stream;
137     int      b_autoplay;
138     int      b_toolbar;
139     char *   psz_target;
140
141 private:
142     /* VLC reference */
143     libvlc_instance_t   *libvlc_instance;
144     libvlc_log_t        *libvlc_log;
145     NPClass             *p_scriptClass;
146
147     /* browser reference */
148     NPP     p_browser;
149     char*   psz_baseURL;
150
151     /* display settings */
152     NPWindow  npwindow;
153 #if XP_WIN
154     WNDPROC   pf_wndproc;
155 #endif
156 #if XP_UNIX
157     unsigned int     i_width, i_height;
158     unsigned int     i_tb_width, i_tb_height;
159     Window           npvideo, npcontrol;
160
161     XImage *p_btnPlay;
162     XImage *p_btnPause;
163     XImage *p_btnStop;
164     XImage *p_timeline;
165     XImage *p_btnTime;
166     XImage *p_btnFullscreen;
167     XImage *p_btnMute;
168     XImage *p_btnUnmute;
169
170     int i_last_position;
171 #endif
172 };
173
174 /*******************************************************************************
175  * Plugin properties.
176  ******************************************************************************/
177 #define PLUGIN_NAME         "VLC Multimedia Plug-in"
178 #define PLUGIN_DESCRIPTION \
179     "Version %s, copyright 1996-2007 The VideoLAN Team" \
180     "<br><a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
181
182 #define PLUGIN_MIMETYPES \
183     /* MPEG-1 and MPEG-2 */ \
184     "audio/mpeg:mp2,mp3,mpga,mpega:MPEG audio;" \
185     "audio/x-mpeg:mp2,mp3,mpga,mpega:MPEG audio;" \
186     "video/mpeg:mpg,mpeg,mpe:MPEG video;" \
187     "video/x-mpeg:mpg,mpeg,mpe:MPEG video;" \
188     "video/mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \
189     "video/x-mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \
190     /* MPEG-4 */ \
191     "video/mpeg4:mp4,mpg4:MPEG-4 video;" \
192     "audio/mpeg4:mp4,mpg4:MPEG-4 audio;" \
193     "application/mpeg4-iod:mp4,mpg4:MPEG-4 video;" \
194     "application/mpeg4-muxcodetable:mp4,mpg4:MPEG-4 video;" \
195     /* AVI */ \
196     "video/x-msvideo:avi:AVI video;" \
197     /* QuickTime */ \
198     "video/quicktime:mov,qt:QuickTime video;" \
199     /* OGG */ \
200     "application/x-ogg:ogg:Ogg stream;" \
201     "application/ogg:ogg:Ogg stream;" \
202     /* VLC */ \
203     "application/x-vlc-plugin:vlc:VLC plug-in;" \
204     /* Windows Media */ \
205     "video/x-ms-asf-plugin:asf,asx:Windows Media Video;" \
206     "video/x-ms-asf:asf,asx:Windows Media Video;" \
207     "application/x-mplayer2::Windows Media;" \
208     "video/x-ms-wmv:wmv:Windows Media;" \
209     "video/x-ms-wvx:wvx:Windows Media Video;" \
210     /* Google VLC */ \
211     "application/x-google-vlc-plugin::Google VLC plug-in;" \
212     /* WAV audio */ \
213     "audio/wav:wav:WAV audio;" \
214     "audio/x-wav:wav:WAV audio;" \
215     /* 3GPP */ \
216     "audio/3gpp:3gp,3gpp:3GPP audio;" \
217     "video/3gpp:3gp,3gpp:3GPP video;" \
218     /* 3GPP2 */ \
219     "audio/3gpp2:3g2,3gpp2:3GPP2 audio;" \
220     "video/3gpp2:3g2,3gpp2:3GPP2 video;" \
221     /* DIVX */ \
222     "video/divx:divx:DivX video;" \
223     /* FLV */ \
224     "video/flv:flv:FLV video;" \
225     "video/x-flv:flv:FLV video;"
226
227
228
229 #endif