]> git.sesse.net Git - vlc/blob - mozilla/control/npolibvlc.h
- added log APIs to javascript for mozilla
[vlc] / mozilla / control / npolibvlc.h
1 /*****************************************************************************\r
2  * npolibvlc.h: official Javascript APIs\r
3  *****************************************************************************\r
4  * Copyright (C) 2002-2006 the VideoLAN team\r
5  *\r
6  * Authors: Damien Fouilleul <damien.fouilleul@laposte.net>\r
7  *\r
8  * This program is free software; you can redistribute it and/or modify\r
9  * it under the terms of the GNU General Public License as published by\r
10  * the Free Software Foundation; either version 2 of the License, or\r
11  * (at your option) any later version.\r
12  *\r
13  * This program is distributed in the hope that it will be useful,\r
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
16  * GNU General Public License for more details.\r
17  *\r
18  * You should have received a copy of the GNU General Public License\r
19  * along with this program; if not, write to the Free Software\r
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.\r
21  *****************************************************************************/\r
22 \r
23 /*\r
24 ** defined runtime script objects\r
25 */\r
26 #include <vlc/libvlc.h>\r
27 \r
28 #include "nporuntime.h"\r
29 \r
30 class LibvlcRootNPObject: public RuntimeNPObject\r
31 {\r
32 protected:\r
33     friend class RuntimeNPClass<LibvlcRootNPObject>;\r
34 \r
35     LibvlcRootNPObject(NPP instance, const NPClass *aClass);\r
36     virtual ~LibvlcRootNPObject();\r
37 \r
38     static const int propertyCount;\r
39     static const NPUTF8 * const propertyNames[];\r
40 \r
41     InvokeResult getProperty(int index, NPVariant &result);\r
42 \r
43     static const int methodCount;\r
44     static const NPUTF8 * const methodNames[];\r
45 \r
46     NPObject *audioObj;\r
47     NPObject *inputObj;\r
48     NPObject *logObj;\r
49     NPObject *playlistObj;\r
50     NPObject *videoObj;\r
51 };\r
52 \r
53 class LibvlcAudioNPObject: public RuntimeNPObject\r
54 {\r
55 protected:\r
56     LibvlcAudioNPObject(NPP instance, const NPClass *aClass) :\r
57         RuntimeNPObject(instance, aClass) {};\r
58     virtual ~LibvlcAudioNPObject() {};\r
59 \r
60     friend class RuntimeNPClass<LibvlcAudioNPObject>;\r
61 \r
62     static const int propertyCount;\r
63     static const NPUTF8 * const propertyNames[];\r
64 \r
65     InvokeResult getProperty(int index, NPVariant &result);\r
66     InvokeResult setProperty(int index, const NPVariant &value);\r
67 \r
68     static const int methodCount;\r
69     static const NPUTF8 * const methodNames[];\r
70 \r
71     InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);\r
72 };\r
73 \r
74 class LibvlcInputNPObject: public RuntimeNPObject\r
75 {\r
76 protected:\r
77     friend class RuntimeNPClass<LibvlcInputNPObject>;\r
78 \r
79     LibvlcInputNPObject(NPP instance, const NPClass *aClass) :\r
80         RuntimeNPObject(instance, aClass) {};\r
81         \r
82     virtual ~LibvlcInputNPObject() {};\r
83 \r
84     static const int propertyCount;\r
85     static const NPUTF8 * const propertyNames[];\r
86 \r
87     InvokeResult getProperty(int index, NPVariant &result);\r
88     InvokeResult setProperty(int index, const NPVariant &value);\r
89 \r
90     static const int methodCount;\r
91     static const NPUTF8 * const methodNames[];\r
92 };\r
93 \r
94 class LibvlcMessageNPObject: public RuntimeNPObject\r
95 {\r
96 public:\r
97     void setMessage(struct libvlc_log_message_t &msg)\r
98     {\r
99         _msg = msg;\r
100     };\r
101 \r
102 protected:\r
103     friend class RuntimeNPClass<LibvlcMessageNPObject>;\r
104 \r
105     LibvlcMessageNPObject(NPP instance, const NPClass *aClass) :\r
106         RuntimeNPObject(instance, aClass) {};\r
107         \r
108     virtual ~LibvlcMessageNPObject() {};\r
109 \r
110     static const int propertyCount;\r
111     static const NPUTF8 * const propertyNames[];\r
112 \r
113     InvokeResult getProperty(int index, NPVariant &result);\r
114 \r
115     static const int methodCount;\r
116     static const NPUTF8 * const methodNames[];\r
117 \r
118 private:\r
119     struct libvlc_log_message_t _msg;\r
120 };\r
121 \r
122 class LibvlcLogNPObject;\r
123 \r
124 class LibvlcMessageIteratorNPObject: public RuntimeNPObject\r
125 {\r
126 public:\r
127     void setLog(LibvlcLogNPObject* p_vlclog);\r
128 \r
129 protected:\r
130     friend class RuntimeNPClass<LibvlcMessageIteratorNPObject>;\r
131 \r
132     LibvlcMessageIteratorNPObject(NPP instance, const NPClass *aClass) :\r
133         RuntimeNPObject(instance, aClass) {};\r
134         \r
135     virtual ~LibvlcMessageIteratorNPObject() {};\r
136 \r
137     static const int propertyCount;\r
138     static const NPUTF8 * const propertyNames[];\r
139 \r
140     InvokeResult getProperty(int index, NPVariant &result);\r
141 \r
142     static const int methodCount;\r
143     static const NPUTF8 * const methodNames[];\r
144 \r
145     InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);\r
146 \r
147 private:\r
148     LibvlcLogNPObject*      _p_vlclog;\r
149     libvlc_log_iterator_t*  _p_iter;\r
150 };\r
151 \r
152 class LibvlcMessagesNPObject: public RuntimeNPObject\r
153 {\r
154 public:\r
155     void setLog(LibvlcLogNPObject *p_log)\r
156     {\r
157         _p_vlclog = p_log;\r
158     }\r
159     \r
160 protected:\r
161     friend class RuntimeNPClass<LibvlcMessagesNPObject>;\r
162 \r
163     LibvlcMessagesNPObject(NPP instance, const NPClass *aClass) :\r
164         _p_vlclog(NULL),\r
165         RuntimeNPObject(instance, aClass) {};\r
166         \r
167     virtual ~LibvlcMessagesNPObject() {};\r
168 \r
169     static const int propertyCount;\r
170     static const NPUTF8 * const propertyNames[];\r
171 \r
172     InvokeResult getProperty(int index, NPVariant &result);\r
173 \r
174     static const int methodCount;\r
175     static const NPUTF8 * const methodNames[];\r
176 \r
177     InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);\r
178 \r
179 private:\r
180     LibvlcLogNPObject* _p_vlclog;\r
181 };\r
182 \r
183 class LibvlcLogNPObject: public RuntimeNPObject\r
184 {\r
185 protected:\r
186     friend class RuntimeNPClass<LibvlcLogNPObject>;\r
187     friend class LibvlcMessagesNPObject;\r
188     friend class LibvlcMessageIteratorNPObject;\r
189 \r
190     libvlc_log_t    *_p_log;\r
191 \r
192     LibvlcLogNPObject(NPP instance, const NPClass *aClass) :\r
193         RuntimeNPObject(instance, aClass),\r
194         _p_log(NULL)\r
195     {\r
196         _p_vlcmessages = static_cast<LibvlcMessagesNPObject*>(NPN_CreateObject(instance, RuntimeNPClass<LibvlcMessagesNPObject>::getClass()));\r
197         _p_vlcmessages->setLog(this);\r
198     };\r
199         \r
200     virtual ~LibvlcLogNPObject()\r
201     {\r
202         NPN_ReleaseObject(_p_vlcmessages);\r
203     };\r
204 \r
205     static const int propertyCount;\r
206     static const NPUTF8 * const propertyNames[];\r
207 \r
208     InvokeResult getProperty(int index, NPVariant &result);\r
209     InvokeResult setProperty(int index, const NPVariant &value);\r
210 \r
211     static const int methodCount;\r
212     static const NPUTF8 * const methodNames[];\r
213 \r
214 private:\r
215     LibvlcMessagesNPObject* _p_vlcmessages;\r
216 };\r
217 \r
218 class LibvlcPlaylistNPObject: public RuntimeNPObject\r
219 {\r
220 protected:\r
221     friend class RuntimeNPClass<LibvlcPlaylistNPObject>;\r
222 \r
223     LibvlcPlaylistNPObject(NPP instance, const NPClass *aClass) :\r
224         RuntimeNPObject(instance, aClass) {};\r
225     virtual ~LibvlcPlaylistNPObject() {};\r
226 \r
227     static const int propertyCount;\r
228     static const NPUTF8 * const propertyNames[];\r
229 \r
230     InvokeResult getProperty(int index, NPVariant &result);\r
231 \r
232     static const int methodCount;\r
233     static const NPUTF8 * const methodNames[];\r
234 \r
235     InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);\r
236 \r
237     void parseOptions(const NPString &s, int *i_options, char*** ppsz_options);\r
238     void parseOptions(NPObject *obj, int *i_options, char*** ppsz_options);\r
239 };\r
240 \r
241 class LibvlcVideoNPObject: public RuntimeNPObject\r
242 {\r
243 protected:\r
244     friend class RuntimeNPClass<LibvlcVideoNPObject>;\r
245 \r
246     LibvlcVideoNPObject(NPP instance, const NPClass *aClass) :\r
247         RuntimeNPObject(instance, aClass) {};\r
248     virtual ~LibvlcVideoNPObject() {};\r
249 \r
250     static const int propertyCount;\r
251     static const NPUTF8 * const propertyNames[];\r
252 \r
253     InvokeResult getProperty(int index, NPVariant &result);\r
254     InvokeResult setProperty(int index, const NPVariant &value);\r
255 \r
256     static const int methodCount;\r
257     static const NPUTF8 * const methodNames[];\r
258 \r
259     InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);\r
260 };\r
261 \r