Patch by Frans van Veen and Jasper Alias with modifications by me.
[vlc.git] / 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 private:
109     /* VLC reference */
110     libvlc_instance_t   *libvlc_instance;
111     libvlc_log_t        *libvlc_log;
112     NPClass             *p_scriptClass;
113
114     /* browser reference */
115     NPP     p_browser;
116     char*   psz_baseURL;
117
118     /* display settings */
119     NPWindow  npwindow;
120 #if XP_WIN
121     WNDPROC   pf_wndproc;
122 #endif
123 #if XP_UNIX
124     unsigned int     i_width, i_height;
125     Window           npvideo, npcontrol;
126 #endif
127 };
128
129 /*******************************************************************************
130  * Plugin properties.
131  ******************************************************************************/
132 #define PLUGIN_NAME         "VLC Multimedia Plugin"
133 #define PLUGIN_DESCRIPTION \
134     "Version %s, copyright 1996-2007 The VideoLAN Team" \
135     "<br><a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
136
137 #define PLUGIN_MIMETYPES \
138     /* MPEG-1 and MPEG-2 */ \
139     "audio/mpeg:mp2,mp3,mpga,mpega:MPEG audio;" \
140     "audio/x-mpeg:mp2,mp3,mpga,mpega:MPEG audio;" \
141     "video/mpeg:mpg,mpeg,mpe:MPEG video;" \
142     "video/x-mpeg:mpg,mpeg,mpe:MPEG video;" \
143     "video/mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \
144     "video/x-mpeg-system:mpg,mpeg,mpe,vob:MPEG video;" \
145     /* MPEG-4 */ \
146     "video/mpeg4:mp4,mpg4:MPEG-4 video;" \
147     "audio/mpeg4:mp4,mpg4:MPEG-4 audio;" \
148     "application/mpeg4-iod:mp4,mpg4:MPEG-4 video;" \
149     "application/mpeg4-muxcodetable:mp4,mpg4:MPEG-4 video;" \
150     /* AVI */ \
151     "video/x-msvideo:avi:AVI video;" \
152     /* QuickTime */ \
153     "video/quicktime:mov,qt:QuickTime video;" \
154     /* OGG */ \
155     "application/x-ogg:ogg:Ogg stream;" \
156     "application/ogg:ogg:Ogg stream;" \
157     /* VLC */ \
158     "application/x-vlc-plugin:vlc:VLC plugin;" \
159     /* Windows Media */ \
160     "video/x-ms-asf-plugin:asf,asx:Windows Media Video;" \
161     "video/x-ms-asf:asf,asx:Windows Media Video;" \
162     "application/x-mplayer2::Windows Media;" \
163     "video/x-ms-wmv:wmv:Windows Media;" \
164     "video/x-ms-wvx:wvx:Windows Media Video;" \
165     /* Google VLC */ \
166     "application/x-google-vlc-plugin::Google VLC plugin;" \
167     /* WAV audio */ \
168     "audio/wav:wav:WAV audio;" \
169     "audio/x-wav:wav:WAV audio;" \
170     /* 3GPP */ \
171     "audio/3gpp:3gp,3gpp:3GPP audio;" \
172     "video/3gpp:3gp,3gpp:3GPP video;" \
173     /* 3GPP2 */ \
174     "audio/3gpp2:3g2,3gpp2:3GPP2 audio;" \
175     "video/3gpp2:3g2,3gpp2:3GPP2 video;" \
176     /* DIVX */ \
177     "video/divx:divx:DivX video;"
178
179 #endif