]> git.sesse.net Git - vlc/blob - projects/mozilla/vlcplugin.h
Cleanup and fix crash when plugin wasn't playing.
[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 #endif
57
58 class VlcPlugin
59 {
60 public:
61              VlcPlugin( NPP, uint16 );
62     virtual ~VlcPlugin();
63
64     NPError             init(int argc, char* const argn[], char* const argv[]);
65     libvlc_instance_t*  getVLC()
66                             { return libvlc_instance; };
67     NPP                 getBrowser()
68                             { return p_browser; };
69     char*               getAbsoluteURL(const char *url);
70     NPWindow&           getWindow()
71                             { return npwindow; };
72     void                setWindow(const NPWindow &window)
73                             { npwindow = window; };
74
75     NPClass*            getScriptClass()
76                             { return p_scriptClass; };
77
78     void                setLog(libvlc_log_t *log)
79                             { libvlc_log = log; };
80     libvlc_log_t*       getLog()
81                             { return libvlc_log; };
82 #if XP_WIN
83     WNDPROC             getWindowProc()
84                             { return pf_wndproc; };
85     void                setWindowProc(WNDPROC wndproc)
86                             { pf_wndproc = wndproc; };
87 #endif
88
89 #if XP_UNIX
90     int                 setSize(unsigned width, unsigned height);
91     Window              getVideoWindow()
92                             { return npvideo; };
93     void                setVideoWindow(Window window)
94                             { npvideo = window; };
95     Window              getControlWindow()
96                             { return npcontrol; };
97     void                setControlWindow(Window window)
98                             { npcontrol = window; };
99 #endif
100
101     uint16    i_npmode; /* either NP_EMBED or NP_FULL */
102
103     /* plugin properties */
104     int      b_stream;
105     int      b_autoplay;
106     char *   psz_target;
107
108 #if XP_UNIX
109     /* toolbar */
110     int     i_control_height;
111 #endif
112 private:
113     /* VLC reference */
114     libvlc_instance_t   *libvlc_instance;
115     libvlc_log_t        *libvlc_log;
116     NPClass             *p_scriptClass;
117
118     /* browser reference */
119     NPP     p_browser;
120     char*   psz_baseURL;
121
122     /* display settings */
123     NPWindow  npwindow;
124 #if XP_WIN
125     WNDPROC   pf_wndproc;
126 #endif
127 #if XP_UNIX
128     unsigned int     i_width, i_height;
129     Window           npvideo, npcontrol;
130
131 #endif
132 };
133
134 /*******************************************************************************
135  * Plugin properties.
136  ******************************************************************************/
137 #define PLUGIN_NAME         "VLC Multimedia Plug-in"
138 #define PLUGIN_DESCRIPTION \
139     "Version %s, copyright 1996-2007 The VideoLAN Team" \
140     "<br><a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
141
142 #define PLUGIN_MIMETYPES \
143     /* MPEG-1 and MPEG-2 */ \
144     "audio/mpeg:mp2,mp3,mpga,mpega:MPEG audio;" \
145     "audio/x-mpeg:mp2,mp3,mpga,mpega:MPEG audio;" \
146     "video/mpeg:mpg,mpeg,mpe:MPEG video;" \
147     "video/x-mpeg:mpg,mpeg,mpe:MPEG video;" \
148     "video/mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \
149     "video/x-mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \
150     /* MPEG-4 */ \
151     "video/mpeg4:mp4,mpg4:MPEG-4 video;" \
152     "audio/mpeg4:mp4,mpg4:MPEG-4 audio;" \
153     "application/mpeg4-iod:mp4,mpg4:MPEG-4 video;" \
154     "application/mpeg4-muxcodetable:mp4,mpg4:MPEG-4 video;" \
155     /* AVI */ \
156     "video/x-msvideo:avi:AVI video;" \
157     /* QuickTime */ \
158     "video/quicktime:mov,qt:QuickTime video;" \
159     /* OGG */ \
160     "application/x-ogg:ogg:Ogg stream;" \
161     "application/ogg:ogg:Ogg stream;" \
162     /* VLC */ \
163     "application/x-vlc-plugin:vlc:VLC plug-in;" \
164     /* Windows Media */ \
165     "video/x-ms-asf-plugin:asf,asx:Windows Media Video;" \
166     "video/x-ms-asf:asf,asx:Windows Media Video;" \
167     "application/x-mplayer2::Windows Media;" \
168     "video/x-ms-wmv:wmv:Windows Media;" \
169     "video/x-ms-wvx:wvx:Windows Media Video;" \
170     /* Google VLC */ \
171     "application/x-google-vlc-plugin::Google VLC plug-in;" \
172     /* WAV audio */ \
173     "audio/wav:wav:WAV audio;" \
174     "audio/x-wav:wav:WAV audio;" \
175     /* 3GPP */ \
176     "audio/3gpp:3gp,3gpp:3GPP audio;" \
177     "video/3gpp:3gp,3gpp:3GPP video;" \
178     /* 3GPP2 */ \
179     "audio/3gpp2:3g2,3gpp2:3GPP2 audio;" \
180     "video/3gpp2:3g2,3gpp2:3GPP2 video;" \
181     /* DIVX */ \
182     "video/divx:divx:DivX video;"
183
184 #endif