npolibvlc.h 10.9 KB
Newer Older
Rafaël Carré's avatar
Rafaël Carré committed
1 2 3
/*****************************************************************************
 * npolibvlc.h: official Javascript APIs
 *****************************************************************************
4
 * Copyright (C) 2002-2012 VLC authors and VideoLAN
Rafaël Carré's avatar
Rafaël Carré committed
5
 *
6 7 8
 * Authors: Rafaël Carré <funman@videolan.org>
 *          JP Dinger <jpd@videolan.org>
 *          Cyril Mathé <cmathe@actech-innovation.com>
Rafaël Carré's avatar
Rafaël Carré committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

/*
** defined runtime script objects
*/
28
#include <vlc/vlc.h>
Rafaël Carré's avatar
Rafaël Carré committed
29 30 31 32 33 34 35 36 37 38 39 40 41

#include "nporuntime.h"

class LibvlcRootNPObject: public RuntimeNPObject
{
protected:
    friend class RuntimeNPClass<LibvlcRootNPObject>;

    LibvlcRootNPObject(NPP instance, const NPClass *aClass) :
        RuntimeNPObject(instance, aClass),
    audioObj(NULL),
    inputObj(NULL),
    playlistObj(NULL),
42
    subtitleObj(NULL),
43 44
    videoObj(NULL),
    mediaDescriptionObj(NULL) { }
Rafaël Carré's avatar
Rafaël Carré committed
45 46 47 48 49 50

    virtual ~LibvlcRootNPObject();

    static const int propertyCount;
    static const NPUTF8 * const propertyNames[];

51
    InvokeResult getProperty(int index, npapi::OutVariant& result);
Rafaël Carré's avatar
Rafaël Carré committed
52 53 54 55

    static const int methodCount;
    static const NPUTF8 * const methodNames[];

56
    InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, npapi::OutVariant &result) override;
Rafaël Carré's avatar
Rafaël Carré committed
57 58 59 60 61

private:
    NPObject *audioObj;
    NPObject *inputObj;
    NPObject *playlistObj;
62
    NPObject *subtitleObj;
Rafaël Carré's avatar
Rafaël Carré committed
63
    NPObject *videoObj;
64
    NPObject *mediaDescriptionObj;
Rafaël Carré's avatar
Rafaël Carré committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78
};

class LibvlcAudioNPObject: public RuntimeNPObject
{
protected:
    LibvlcAudioNPObject(NPP instance, const NPClass *aClass) :
        RuntimeNPObject(instance, aClass) {};
    virtual ~LibvlcAudioNPObject() {};

    friend class RuntimeNPClass<LibvlcAudioNPObject>;

    static const int propertyCount;
    static const NPUTF8 * const propertyNames[];

79
    virtual InvokeResult getProperty(int index, npapi::OutVariant& result) override;
80
    virtual InvokeResult setProperty(int index, const NPVariant &value) override;
Rafaël Carré's avatar
Rafaël Carré committed
81 82 83 84

    static const int methodCount;
    static const NPUTF8 * const methodNames[];

85
    virtual InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, npapi::OutVariant &result)  override;
Rafaël Carré's avatar
Rafaël Carré committed
86 87 88 89 90 91 92 93
};

class LibvlcInputNPObject: public RuntimeNPObject
{
protected:
    friend class RuntimeNPClass<LibvlcInputNPObject>;

    LibvlcInputNPObject(NPP instance, const NPClass *aClass) :
94 95
        RuntimeNPObject(instance, aClass),
        titleObj(NULL), chapterObj(NULL) {};
Rafaël Carré's avatar
Rafaël Carré committed
96

97
    virtual ~LibvlcInputNPObject();
Rafaël Carré's avatar
Rafaël Carré committed
98 99 100 101

    static const int propertyCount;
    static const NPUTF8 * const propertyNames[];

102
    virtual InvokeResult getProperty(int index, npapi::OutVariant& result) override;
103
    virtual InvokeResult setProperty(int index, const NPVariant &value) override;
Rafaël Carré's avatar
Rafaël Carré committed
104 105 106

    static const int methodCount;
    static const NPUTF8 * const methodNames[];
107 108

    InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
109 110 111 112

private:
    NPObject *titleObj;
    NPObject *chapterObj;
Rafaël Carré's avatar
Rafaël Carré committed
113 114
};

115 116 117 118 119 120 121 122 123 124 125
class LibvlcMediaDescriptionNPObject: public RuntimeNPObject
{
protected:
    friend class RuntimeNPClass<LibvlcMediaDescriptionNPObject>;
    LibvlcMediaDescriptionNPObject(NPP instance, const NPClass *aClass) :
        RuntimeNPObject(instance, aClass) {};
    virtual ~LibvlcMediaDescriptionNPObject() {};

    static const int propertyCount;
    static const NPUTF8 * const propertyNames[];

126
    virtual InvokeResult getProperty(int index, npapi::OutVariant& result) override;
127

128 129 130 131
    static const int methodCount;
    static const NPUTF8 * const methodNames[];
};

Rafaël Carré's avatar
Rafaël Carré committed
132 133 134 135 136 137 138 139 140 141 142 143
class LibvlcPlaylistItemsNPObject: public RuntimeNPObject
{
protected:
    friend class RuntimeNPClass<LibvlcPlaylistItemsNPObject>;

    LibvlcPlaylistItemsNPObject(NPP instance, const NPClass *aClass) :
        RuntimeNPObject(instance, aClass) {};
    virtual ~LibvlcPlaylistItemsNPObject() {};

    static const int propertyCount;
    static const NPUTF8 * const propertyNames[];

144
    virtual InvokeResult getProperty(int index, npapi::OutVariant& result) override;
Rafaël Carré's avatar
Rafaël Carré committed
145 146 147 148

    static const int methodCount;
    static const NPUTF8 * const methodNames[];

149
    virtual InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, npapi::OutVariant &result) override;
Rafaël Carré's avatar
Rafaël Carré committed
150 151 152 153 154 155 156 157 158 159
};

class LibvlcPlaylistNPObject: public RuntimeNPObject
{
protected:
    friend class RuntimeNPClass<LibvlcPlaylistNPObject>;

    LibvlcPlaylistNPObject(NPP instance, const NPClass *aClass) :
    RuntimeNPObject(instance, aClass),
    playlistItemsObj(NULL) {};
160

Rafaël Carré's avatar
Rafaël Carré committed
161 162 163 164 165
    virtual ~LibvlcPlaylistNPObject();

    static const int propertyCount;
    static const NPUTF8 * const propertyNames[];

166
    virtual InvokeResult getProperty(int index, npapi::OutVariant& result) override;
Rafaël Carré's avatar
Rafaël Carré committed
167 168 169 170

    static const int methodCount;
    static const NPUTF8 * const methodNames[];

171
    virtual InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, npapi::OutVariant &result) override;
Rafaël Carré's avatar
Rafaël Carré committed
172

173
    void parseOptions(const NPString& s, int *i_options, char*** ppsz_options);
Rafaël Carré's avatar
Rafaël Carré committed
174 175 176 177 178 179
    void parseOptions(NPObject *obj, int *i_options, char*** ppsz_options);

private:
    NPObject*  playlistItemsObj;
};

180 181 182 183 184 185 186 187 188 189 190 191
class LibvlcSubtitleNPObject: public RuntimeNPObject
{
protected:
    friend class RuntimeNPClass<LibvlcSubtitleNPObject>;

    LibvlcSubtitleNPObject(NPP instance, const NPClass *aClass) :
        RuntimeNPObject(instance, aClass) {};
    virtual ~LibvlcSubtitleNPObject() {};

    static const int propertyCount;
    static const NPUTF8 * const propertyNames[];

192
    virtual InvokeResult getProperty(int index, npapi::OutVariant& result) override;
193
    virtual InvokeResult setProperty(int index, const NPVariant &value) override;
194 195 196 197

    static const int methodCount;
    static const NPUTF8 * const methodNames[];

198
    virtual InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, npapi::OutVariant &result) override;
199 200 201
};


Rafaël Carré's avatar
Rafaël Carré committed
202 203 204 205 206 207
class LibvlcVideoNPObject: public RuntimeNPObject
{
protected:
    friend class RuntimeNPClass<LibvlcVideoNPObject>;

    LibvlcVideoNPObject(NPP instance, const NPClass *aClass) :
208
        RuntimeNPObject(instance, aClass),
209
        marqueeObj(NULL), logoObj(NULL), deintObj(NULL) { }
210
    virtual ~LibvlcVideoNPObject();
Rafaël Carré's avatar
Rafaël Carré committed
211 212 213 214

    static const int propertyCount;
    static const NPUTF8 * const propertyNames[];

215
    virtual InvokeResult getProperty(int index, npapi::OutVariant& result) override;
216
    virtual InvokeResult setProperty(int index, const NPVariant &value) override;
Rafaël Carré's avatar
Rafaël Carré committed
217 218 219 220

    static const int methodCount;
    static const NPUTF8 * const methodNames[];

221
    virtual InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, npapi::OutVariant &result) override;
222 223 224

private:
    NPObject *marqueeObj;
225
    NPObject *logoObj;
226
    NPObject *deintObj;
227 228 229 230 231 232 233 234 235 236 237 238 239 240
};

class LibvlcMarqueeNPObject: public RuntimeNPObject
{
protected:
    friend class RuntimeNPClass<LibvlcMarqueeNPObject>;

    LibvlcMarqueeNPObject(NPP instance, const NPClass *aClass) :
        RuntimeNPObject(instance, aClass) {};
    virtual ~LibvlcMarqueeNPObject() {};

    static const int propertyCount;
    static const NPUTF8 * const propertyNames[];

241
    virtual InvokeResult getProperty(int index, npapi::OutVariant& result) override;
242
    virtual InvokeResult setProperty(int index, const NPVariant &value) override;
243 244 245 246

    static const int methodCount;
    static const NPUTF8 * const methodNames[];

247
    virtual InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, npapi::OutVariant &result) override;
Rafaël Carré's avatar
Rafaël Carré committed
248
};
249 250 251 252 253 254 255 256 257 258 259 260 261

class LibvlcLogoNPObject: public RuntimeNPObject
{
protected:
    friend class RuntimeNPClass<LibvlcLogoNPObject>;

    LibvlcLogoNPObject(NPP instance, const NPClass *aClass) :
        RuntimeNPObject(instance, aClass) { }
    virtual ~LibvlcLogoNPObject() { }

    static const int propertyCount;
    static const NPUTF8 * const propertyNames[];

262
    virtual InvokeResult getProperty(int index, npapi::OutVariant& result) override;
263
    virtual InvokeResult setProperty(int index, const NPVariant &value) override;
264 265 266 267

    static const int methodCount;
    static const NPUTF8 * const methodNames[];

268
    virtual InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, npapi::OutVariant& result) override;
269
};
270 271 272 273 274 275 276 277 278 279 280 281 282

class LibvlcDeinterlaceNPObject: public RuntimeNPObject
{
protected:
    friend class RuntimeNPClass<LibvlcDeinterlaceNPObject>;

    LibvlcDeinterlaceNPObject(NPP instance, const NPClass *aClass) :
        RuntimeNPObject(instance, aClass) { }
    virtual ~LibvlcDeinterlaceNPObject() { }

    static const int propertyCount;
    static const NPUTF8 * const propertyNames[];

283
    virtual InvokeResult getProperty(int index, npapi::OutVariant& result) override;
284
    virtual InvokeResult setProperty(int index, const NPVariant &value) override;
285 286 287 288

    static const int methodCount;
    static const NPUTF8 * const methodNames[];

289
    virtual InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, npapi::OutVariant &result) override;
290
};
291

292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
class LibvlcTitleNPObject: public RuntimeNPObject
{
protected:
    friend class RuntimeNPClass<LibvlcTitleNPObject>;

    LibvlcTitleNPObject(NPP instance, const NPClass *aClass) :
        RuntimeNPObject(instance, aClass) { }
    virtual ~LibvlcTitleNPObject() { }

    static const int propertyCount;
    static const NPUTF8 * const propertyNames[];

    virtual InvokeResult getProperty(int index, npapi::OutVariant& result) override;
    virtual InvokeResult setProperty(int index, const NPVariant &value) override;

    static const int methodCount;
    static const NPUTF8 * const methodNames[];

    virtual InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, npapi::OutVariant &result) override;
};

class LibvlcChapterNPObject: public RuntimeNPObject
{
protected:
    friend class RuntimeNPClass<LibvlcChapterNPObject>;

    LibvlcChapterNPObject(NPP instance, const NPClass *aClass) :
        RuntimeNPObject(instance, aClass) { }
    virtual ~LibvlcChapterNPObject() { }

    static const int propertyCount;
    static const NPUTF8 * const propertyNames[];

    virtual InvokeResult getProperty(int index, npapi::OutVariant& result) override;
    virtual InvokeResult setProperty(int index, const NPVariant &value) override;

    static const int methodCount;
    static const NPUTF8 * const methodNames[];

    virtual InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, npapi::OutVariant &result) override;
};