]> git.sesse.net Git - vlc/blob - projects/mozilla/vlcplugin.h
Refactor mozilla toolbar code. There are still a few things wrong:
[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 #endif
115
116     uint16    i_npmode; /* either NP_EMBED or NP_FULL */
117
118     /* plugin properties */
119     int      b_stream;
120     int      b_autoplay;
121     char *   psz_target;
122
123 #if XP_UNIX
124     /* toolbar */
125     int     i_control_height;
126 #endif
127 private:
128     /* VLC reference */
129     libvlc_instance_t   *libvlc_instance;
130     libvlc_log_t        *libvlc_log;
131     NPClass             *p_scriptClass;
132
133     /* browser reference */
134     NPP     p_browser;
135     char*   psz_baseURL;
136
137     /* display settings */
138     NPWindow  npwindow;
139 #if XP_WIN
140     WNDPROC   pf_wndproc;
141 #endif
142 #if XP_UNIX
143     unsigned int     i_width, i_height;
144     Window           npvideo, npcontrol;
145
146     XImage *p_btnPlay;
147     XImage *p_btnPause;
148     XImage *p_btnStop;
149     XImage *p_timeline;
150     XImage *p_btnTime;
151     XImage *p_btnFullscreen;
152     XImage *p_btnMute;
153     XImage *p_btnUnmute;
154
155     int i_last_position;
156 #endif
157 };
158
159 /*******************************************************************************
160  * Plugin properties.
161  ******************************************************************************/
162 #define PLUGIN_NAME         "VLC Multimedia Plug-in"
163 #define PLUGIN_DESCRIPTION \
164     "Version %s, copyright 1996-2007 The VideoLAN Team" \
165     "<br><a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
166
167 #define PLUGIN_MIMETYPES \
168     /* MPEG-1 and MPEG-2 */ \
169     "audio/mpeg:mp2,mp3,mpga,mpega:MPEG audio;" \
170     "audio/x-mpeg:mp2,mp3,mpga,mpega:MPEG audio;" \
171     "video/mpeg:mpg,mpeg,mpe:MPEG video;" \
172     "video/x-mpeg:mpg,mpeg,mpe:MPEG video;" \
173     "video/mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \
174     "video/x-mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \
175     /* MPEG-4 */ \
176     "video/mpeg4:mp4,mpg4:MPEG-4 video;" \
177     "audio/mpeg4:mp4,mpg4:MPEG-4 audio;" \
178     "application/mpeg4-iod:mp4,mpg4:MPEG-4 video;" \
179     "application/mpeg4-muxcodetable:mp4,mpg4:MPEG-4 video;" \
180     /* AVI */ \
181     "video/x-msvideo:avi:AVI video;" \
182     /* QuickTime */ \
183     "video/quicktime:mov,qt:QuickTime video;" \
184     /* OGG */ \
185     "application/x-ogg:ogg:Ogg stream;" \
186     "application/ogg:ogg:Ogg stream;" \
187     /* VLC */ \
188     "application/x-vlc-plugin:vlc:VLC plug-in;" \
189     /* Windows Media */ \
190     "video/x-ms-asf-plugin:asf,asx:Windows Media Video;" \
191     "video/x-ms-asf:asf,asx:Windows Media Video;" \
192     "application/x-mplayer2::Windows Media;" \
193     "video/x-ms-wmv:wmv:Windows Media;" \
194     "video/x-ms-wvx:wvx:Windows Media Video;" \
195     /* Google VLC */ \
196     "application/x-google-vlc-plugin::Google VLC plug-in;" \
197     /* WAV audio */ \
198     "audio/wav:wav:WAV audio;" \
199     "audio/x-wav:wav:WAV audio;" \
200     /* 3GPP */ \
201     "audio/3gpp:3gp,3gpp:3GPP audio;" \
202     "video/3gpp:3gp,3gpp:3GPP video;" \
203     /* 3GPP2 */ \
204     "audio/3gpp2:3g2,3gpp2:3GPP2 audio;" \
205     "video/3gpp2:3g2,3gpp2:3GPP2 video;" \
206     /* DIVX */ \
207     "video/divx:divx:DivX video;"
208
209 #endif