vlcshell.cpp 20.2 KB
Newer Older
1
/*****************************************************************************
2
 * vlcshell.cpp: a VLC plugin for Mozilla
3
 *****************************************************************************
4
 * Copyright (C) 2002-2013 VLC authors and VideoLAN
5
 * $Id$
6 7
 *
 * Authors: Samuel Hocevar <sam@zoy.org>
8
 *          Jean-Paul Saman <jpsaman@videolan.org>
9 10 11 12
 *          Jean-Baptiste Kempf <jb@videolan.org>
 *          Cheng Sun <chengsun9@gmail.com>
 *          Felix Paul Kühne <fkuehne # videolan.org>
 *          Damien Fouilleul <damienf@videolan.org>
13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * 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
Antoine Cellerier's avatar
Antoine Cellerier committed
26
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
27 28 29 30 31
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
32 33 34 35 36

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

37 38
#include <stdio.h>
#include <string.h>
39
#include <stdlib.h>
40

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
41
#include "common.h"
42
#include "vlcshell.h"
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
43
#include "vlcplugin.h"
44

45 46
static char mimetype[] =
    /* MPEG-1 and MPEG-2 */
47 48 49
    "audio/mp1::MPEG audio;"
    "audio/mp2::MP2 audio;"
    "audio/mp3::MPEG audio;"
50
    "audio/mpeg:mp2,mp3,mpga,mpega:MPEG audio;"
51 52 53 54
    "audio/mpg::MPEG audio;"
    "audio/x-mp1::MPEG audio;"
    "audio/x-mp2::MPEG audio;"
    "audio/x-mp3::MPEG audio;"
55
    "audio/x-mpeg:mp2,mp3,mpga,mpega:MPEG audio;"
56
    "audio/x-mpg::MPEG audio;"
57 58
    "video/mpeg:mpg,mpeg,mpe:MPEG video;"
    "video/x-mpeg:mpg,mpeg,mpe:MPEG video;"
59
    "video/mp2t::MPEG-2 transport stream;"
60 61
    "video/mpeg-system:mpg,mpeg,mpe,vob:MPEG video;"
    "video/x-mpeg-system:mpg,mpeg,mpe,vob:MPEG video;"
62
    "video/x-mpeg2::MPEG video;"
63
    /* MPEG-4 */
64 65
    "audio/aac::AAC sound;"
    "audio/x-aac::AAC sound;"
66 67
    "audio/mp4:aac,mp4,mpg4:MPEG-4 audio;"
    "audio/x-m4a:m4a:MPEG-4 audio;"
68
    "audio/m4a:m4a:MPEG-4 audio;"
69 70 71 72
    /* MPEG-4 ASP */
    "video/mp4:mp4,mpg4:MPEG-4 video;"
    "application/mpeg4-iod:mp4,mpg4:MPEG-4 video;"
    "application/mpeg4-muxcodetable:mp4,mpg4:MPEG-4 video;"
73 74
    "application/x-extension-m4a::MPEG-4 audio;"
    "application/x-extension-mp4::MPEG-4 audio;"
75
    "video/x-m4v:m4v:MPEG-4 video;"
76
    "video/mp4v-es::MPEG-4 video;"
77
    /* AVI */
78 79 80 81 82
    "audio/x-pn-windows-acm::AVI video;"
    "video/divx:divx:DivX video;"
    "video/msvideo:avi:AVI video;"
    "video/vnd.divx::DivX video;"
    "video/x-avi::AVI video;"
83 84
    "video/x-msvideo:avi:AVI video;"
    /* QuickTime */
85 86
    "application/x-quicktime-media-link::QuickTime metalink playlist;"
    "application/x-quicktimeplayer:qtl:QuickTime video;"
87
    "video/quicktime:mov,qt:QuickTime video;"
88 89 90
    /* OGG */
    "application/ogg:ogg:Ogg stream;"
    "video/ogg:ogv:Ogg video;"
91
    "audio/ogg:oga,ogg:Ogg audio;"
92
    "application/x-ogg:ogg:Ogg stream;"
93 94 95 96 97 98
    "video/x-ogm+ogg::OGM video;"
    "video/x-theora+ogg::Ogg Theora video;"
    "video/x-theora::Ogg Theora video;"
    "audio/x-vorbis+ogg::Ogg Vorbis audio;"
    "audio/x-vorbis::Ogg Vorbis audio;"
    "audio/x-speex::Speex audio;"
99 100
    /* Opus */
    "audio/ogg;codecs=opus:opus:Opus audio;"
101
    "audio/opus::Opus audio;"
102 103 104
    /* VLC */
    "application/x-vlc-plugin::VLC plug-in;"
    /* Windows Media */
105 106 107 108 109 110
    "audio/x-ms-asf::ASF video;"
    "audio/x-ms-asx::Microsoft ASX playlist;"
    "audio/x-ms-wax:wax:Microsoft Media;"
    "video/x-ms-asf:asf,asx:ASF video;"
    "video/x-ms-asf-plugin::ASF video;"
    "video/x-ms-asx::ASF video;"
111 112 113
    "video/x-ms-asf-plugin:asf,asx:Windows Media Video;"
    "video/x-ms-asf:asf,asx:Windows Media Video;"
    "application/x-mplayer2::Windows Media;"
114
    "video/x-ms-wm:wm:Windows Media;"
115
    "video/x-ms-wmv:wmv:Windows Media;"
116
    "video/x-ms-wmx:wmx:Windows Media;"
117 118 119 120
    "video/x-ms-wvx:wvx:Windows Media Video;"
    "audio/x-ms-wma:wma:Windows Media Audio;"
    /* Google VLC */
    "application/x-google-vlc-plugin::Google VLC plug-in;"
121
    /* Audio sample format */
122 123
    "audio/wav:wav:WAV audio;"
    "audio/x-wav:wav:WAV audio;"
124 125
    "audio/x-pn-wav::WAV audio;"
    "audio/x-pn-au::Audio samples;"
126
    /* 3GPP */
127
    "video/3gp::3GPP video;"
128 129 130 131 132
    "audio/3gpp:3gp,3gpp:3GPP audio;"
    "video/3gpp:3gp,3gpp:3GPP video;"
    /* 3GPP2 */
    "audio/3gpp2:3g2,3gpp2:3GPP2 audio;"
    "video/3gpp2:3g2,3gpp2:3GPP2 video;"
133 134
    /* Autodesk animation format */
    "video/fli:fli:FLI video;"
135
    "video/flv:flv:FLV video;"
136 137
    "video/x-flc::FLV video;"
    "video/x-fli::FLI video;"
138 139 140
    "video/x-flv:flv:FLV video;"
    /* Matroska */
    "application/x-matroska:mkv:Matroska video;"
141
    "video/x-matroska:mpv,mkv:Matroska video;"
142
    "audio/x-matroska:mka:Matroska audio;"
143
    /* Playlists / text/xml list with URLs */
144
    "application/xspf+xml:xspf:Playlist xspf;"
145
    "audio/mpegurl:m3u:MPEG audio playlist;"
146
    "audio/x-mpegurl:m3u:MPEG audio;"
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
    "audio/scpls:pls:MP3 ShoutCast playlist;"
    "audio/x-scpls:pls:MP3 ShoutCast playlist;"
    "text/google-video-pointer::Google Video Pointer playlist;"
    "text/x-google-video-pointer::Google Video Pointer playlist;"
    "video/vnd.mpegurl:mxu:MPEG video (streamed);"
    "application/vnd.apple.mpegurl::HTTP Live Streaming playlist;"
    "application/vnd.ms-asf::ASF video;"
    "application/vnd.ms-wpl::WPL playlist;"
    "application/sdp::SDP multicast stream file;"
    /* Digital Video */
    "audio/dv:dif,dv:DV audio;"
    "video/dv:dif,dv:DV video;"
    /* IFF related formats */
    "audio/x-aiff:aif,aiff,aifc:AIFF/Amiga/Mac audio;"
    "audio/x-pn-aiff::AIFF audio;"
    "video/x-anim::ANIM animation;"
163 164 165 166
    /* Webm */
    "video/webm:webm:WebM video;"
    "audio/webm:webm:WebM audio;"
    /* Real Media */
167 168
    "application/ram:ram:RealMedia Metafile;"
    "application/vnd.rn-realmedia-vbr::Real Media File;"
169
    "application/vnd.rn-realmedia:rm:Real Media File;"
170 171 172 173
    "audio/vnd.rn-realaudio::RealAudio document;"
    "audio/x-pn-realaudio-plugin::RealAudio plugin file;"
    "audio/x-pn-realaudio:ra,rm,ram:Real Media Audio;"
    "audio/x-real-audio::Real Media Audio;"
174
    "audio/x-realaudio:ra:Real Media Audio;"
175
    "video/vnd.rn-realvideo::Real Media Video;"
176
    /* AMR */
177 178 179
    "audio/AMR-WB::AMR-WB audio;"
    "audio/AMR::AMR audio;"
    "audio/amr-wb:awb:AMR-WB audio;"
180 181
    "audio/amr:amr:AMR audio;"
    /* FLAC */
182
    "application/x-flac:flac:FLAC audio;"
183
    "audio/x-flac:flac:FLAC audio;"
184
    "audio/flac:flac:FLAC audio;"
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
    /* Adobe Flash video */
    "application/x-flash-video::Flash video;"
    "application/x-shockwave-flash:swf,swfl:Shockwave Flash file;"
    /* Raw audio */
    "audio/ac3::Dolby Digital audio;"
    "audio/eac3::E-AC3;"
    "audio/basic:au,snd:ULAW (Sun) audio;"
    "audio/midi:mid,midi,kar:MIDI audio;"
    "audio/vnd.dts.hd::DTSHD audio;"
    "audio/vnd.dolby.heaac.1::Dolby HeAAC;"
    "audio/vnd.dolby.heaac.2::Dolby HeAAC;"
    "audio/vnd.dolby.mlp::MLP/TrueHD;"
    "audio/vnd.dts::DTS audio;"
    "audio/x-ape::Monkey's audio;"
    "audio/x-gsm:gsm:GSM 06.10 audio;"
    "audio/x-musepack::Musepack audio;"
    "audio/x-shorten::Shorten audio;"
    "audio/x-tta::TrueAudio audio;"
    "audio/x-wavpack::WavPack audio;"
    /* Modplug / GME */
    "audio/x-it::Impulse Tracker audio;"
    "audio/x-mod::Amiga SoundTracker audio;"
    "audio/x-s3m::Scream Tracker 3 audio;"
    "audio/x-xm::FastTracker II audio;"
    /* misc */
    "application/mxf:mxf:MXF video;"
    "image/vnd.rn-realpix::RealPix document;"
    "misc/ultravox::SHOUTcast 2;"
    "video/x-nsv::NullSoft video;"
214
    ;
215 216 217 218

/******************************************************************************
 * UNIX-only API calls
 *****************************************************************************/
219
NPP_GET_MIME_CONST char * NPP_GetMIMEDescription( void )
220
{
221
    return mimetype;
222 223 224 225
}

NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
{
226
    static char psz_name[] = PLUGIN_NAME;
Sam Hocevar's avatar
Sam Hocevar committed
227
    static char psz_desc[1000];
228

229
    /* plugin class variables */
230 231 232
    switch( variable )
    {
        case NPPVpluginNameString:
233
            *((char **)value) = psz_name;
234 235 236
            return NPERR_NO_ERROR;

        case NPPVpluginDescriptionString:
237
            snprintf( psz_desc, sizeof(psz_desc), PLUGIN_DESCRIPTION,
238
                      libvlc_get_version() );
Sam Hocevar's avatar
Sam Hocevar committed
239
            *((char **)value) = psz_desc;
240
            return NPERR_NO_ERROR;
Sam Hocevar's avatar
Sam Hocevar committed
241

242 243 244 245 246 247
#if defined(XP_UNIX)
        case NPPVpluginNeedsXEmbed:
            *((bool *)value) = true;
            return NPERR_NO_ERROR;
#endif

Sam Hocevar's avatar
Sam Hocevar committed
248
        default:
249
            /* move on to instance variables ... */
250
            ;
251 252 253 254 255 256 257
    }

    if( instance == NULL )
    {
        return NPERR_INVALID_INSTANCE_ERROR;
    }

258
    /* plugin instance variables */
259

260
    VlcPluginBase *p_plugin = reinterpret_cast<VlcPluginBase *>(instance->pdata);
261
    if( NULL == p_plugin )
262
    {
263
        /* plugin has not been initialized yet ! */
264 265
        return NPERR_INVALID_INSTANCE_ERROR;
    }
266

267 268
    switch( variable )
    {
269
        case NPPVpluginScriptableNPObject:
270
        {
271 272 273
            /* retrieve plugin root class */
            NPClass *scriptClass = p_plugin->getScriptClass();
            if( scriptClass )
274
            {
275 276 277
                /* create an instance and return it */
                *(NPObject**)value = NPN_CreateObject(instance, scriptClass);
                return NPERR_NO_ERROR;
278 279
            }
            break;
280
        }
281 282 283 284
#if defined(XP_MACOSX)
        case NPPVpluginCoreAnimationLayer:
        {
            if( instance )
285
                return p_plugin->get_root_layer(value);
286 287 288 289

            break;
        }
#endif
290

291
        default:
292
            ;
293
    }
294
    return NPERR_GENERIC_ERROR;
295 296
}

297
/*
298
 * there is some confusion in NPAPI headers regarding definition of this API
299 300 301
 * NPPVariable is wrongly defined as NPNVariable, which sounds incorrect.
 */

302
NPError NPP_SetValue( NPP, NPNVariable, void * )
303 304 305 306
{
    return NPERR_GENERIC_ERROR;
}

307 308 309 310 311
/******************************************************************************
 * General Plug-in Calls
 *****************************************************************************/
NPError NPP_Initialize( void )
{
312 313 314 315 316 317 318 319 320 321 322
#ifdef XP_UNIX
    NPError err = NPERR_NO_ERROR;
    bool supportsXEmbed = false;

    err = NPN_GetValue( NULL, NPNVSupportsXEmbedBool,
                        (void *)&supportsXEmbed );

    if ( err != NPERR_NO_ERROR || supportsXEmbed != true )
        return NPERR_INCOMPATIBLE_VERSION_ERROR;
#endif

323 324 325 326 327 328 329 330
    return NPERR_NO_ERROR;
}

void NPP_Shutdown( void )
{
    ;
}

331 332 333 334 335 336
static bool boolValue(const char *value) {
    return ( !strcmp(value, "1") ||
             !strcasecmp(value, "true") ||
             !strcasecmp(value, "yes") );
}

337
NPError NPP_New( NPMIMEType, NPP instance,
338
                 NPuint16_t mode, NPint16_t argc,
339
                 char* argn[], char* argv[], NPSavedData* )
340
{
341
    NPError status;
342
    VlcPluginBase *p_plugin;
343 344 345 346 347 348

    if( instance == NULL )
    {
        return NPERR_INVALID_INSTANCE_ERROR;
    }

349
    bool windowless = false;
350 351 352 353 354 355 356 357 358 359 360 361 362
    /* we need to tell whether the plugin will be windowless
     * before it is instantiated */
    for( int i = 0; i < argc; i++ )
    {
        if( !strcmp( argn[i], "windowless" ) )
        {
            windowless = boolValue(argv[i]);
            break;
        }
    }

    if( windowless )
    {
363
        printf( "Using Windowless mode\n" );
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
        /* set windowless flag */
        status = NPN_SetValue( instance, NPPVpluginWindowBool,
                                       (void *)false);
        if( NPERR_NO_ERROR != status )
        {
            return status;
        }
        status = NPN_SetValue( instance, NPPVpluginTransparentBool,
                                       (void *)false);
        if( NPERR_NO_ERROR != status )
        {
            return status;
        }

        p_plugin = new VlcWindowless( instance, mode );
    }
    else
    {
        p_plugin = new VlcPlugin( instance, mode );
    }
384
    if( NULL == p_plugin )
385 386 387 388
    {
        return NPERR_OUT_OF_MEMORY_ERROR;
    }

389
    status = p_plugin->init(argc, argn, argv);
390 391
    if( NPERR_NO_ERROR == status )
    {
392
        instance->pdata = reinterpret_cast<void*>(p_plugin);
393
    }
394 395
    else
    {
396 397
        delete p_plugin;
    }
398
    return status;
399 400
}

401
NPError NPP_Destroy( NPP instance, NPSavedData** )
402
{
403
    if( NULL == instance )
404 405
        return NPERR_INVALID_INSTANCE_ERROR;

406
    VlcPluginBase *p_plugin = reinterpret_cast<VlcPluginBase *>(instance->pdata);
407 408 409 410
    if( NULL == p_plugin )
        return NPERR_NO_ERROR;

    instance->pdata = NULL;
411

412 413
    p_plugin->destroy_windows();

414
    delete p_plugin;
415 416 417 418 419 420

    return NPERR_NO_ERROR;
}

NPError NPP_SetWindow( NPP instance, NPWindow* window )
{
421
    if( ! instance )
422 423 424 425
    {
        return NPERR_INVALID_INSTANCE_ERROR;
    }

426
    /* NPP_SetWindow may be called before NPP_New (Opera) */
427
    VlcPluginBase *p_plugin = reinterpret_cast<VlcPluginBase *>(instance->pdata);
428
    if( NULL == p_plugin )
429 430 431 432
    {
        /* we should probably show a splash screen here */
        return NPERR_NO_ERROR;
    }
Jean-Paul Saman's avatar
Jean-Paul Saman committed
433

434 435 436 437 438 439 440 441
    /*
     * PLUGIN DEVELOPERS:
     *  Before setting window to point to the
     *  new window, you may wish to compare the new window
     *  info to the previous window (if any) to note window
     *  size changes, etc.
     */

442
    /* retrieve current window */
443
    NPWindow& curr_window = p_plugin->getWindow();
444

445
    if (window/* && window->window */) {
446 447
        if (!curr_window.window) {
            /* we've just been created */
448
            p_plugin->setWindow(*window);
449 450
            p_plugin->create_windows();
            p_plugin->resize_windows();
451
            p_plugin->set_player_window();
452 453

            /* now set plugin state to that requested in parameters */
454 455
            bool show_toolbar = p_plugin->get_options().get_show_toolbar();
            p_plugin->set_toolbar_visible( show_toolbar );
456 457 458 459 460 461

            /* handle streams properly */
            if( !p_plugin->b_stream )
            {
                if( p_plugin->psz_target )
                {
462
                    if( p_plugin->player().add_item( p_plugin->psz_target ) != -1 )
463
                    {
464
                        if( p_plugin->get_options().get_autoplay() )
465
                        {
466
                            p_plugin->player().play();
467 468 469 470 471
                        }
                    }
                    p_plugin->b_stream = true;
                }
            }
472 473

            p_plugin->update_controls();
474 475 476
        } else {
            if (window->window == curr_window.window) {
                /* resize / move notification */
477
                p_plugin->setWindow(*window);
478 479
                p_plugin->resize_windows();
            } else {
480
                /* plugin parent window was changed, notify plugin about it */
481 482 483 484
                p_plugin->destroy_windows();
                p_plugin->setWindow(*window);
                p_plugin->create_windows();
                p_plugin->resize_windows();
485
            }
486
        }
487
    } else {
488 489
        /* NOTE: on Windows, Opera does not call NPP_SetWindow
         * on window destruction. */
490 491 492 493
        if (curr_window.window) {
            /* we've been destroyed */
            p_plugin->destroy_windows();
        }
494
    }
495 496 497
    return NPERR_NO_ERROR;
}

498 499
NPError NPP_NewStream( NPP instance, NPMIMEType, NPStream *stream,
                       NPBool, NPuint16_t *stype )
500
{
501
    if( NULL == instance  )
502 503 504 505
    {
        return NPERR_INVALID_INSTANCE_ERROR;
    }

506
    VlcPluginBase *p_plugin = reinterpret_cast<VlcPluginBase *>(instance->pdata);
507 508 509 510
    if( NULL == p_plugin )
    {
        return NPERR_INVALID_INSTANCE_ERROR;
    }
511

512 513 514 515 516 517 518 519
   /*
   ** Firefox/Mozilla may decide to open a stream from the URL specified
   ** in the SRC parameter of the EMBED tag and pass it to us
   **
   ** since VLC will open the SRC URL as well, we're not interested in
   ** that stream. Otherwise, we'll take it and queue it up in the playlist
   */
    if( !p_plugin->psz_target || strcmp(stream->url, p_plugin->psz_target) )
520
    {
521 522 523
        /* TODO: use pipes !!!! */
        *stype = NP_ASFILEONLY;
        return NPERR_NO_ERROR;
524
    }
525
    return NPERR_GENERIC_ERROR;
526 527
}

528
NPint32_t NPP_WriteReady( NPP, NPStream *)
529
{
530 531
    /* TODO */
    return 8*1024;
532 533
}

534 535
NPint32_t NPP_Write( NPP, NPStream *, NPint32_t,
                 NPint32_t len, void * )
536
{
537 538
    /* TODO */
    return len;
539 540
}

541
NPError NPP_DestroyStream( NPP instance, NPStream *, NPError )
542 543 544 545 546 547 548 549
{
    if( instance == NULL )
    {
        return NPERR_INVALID_INSTANCE_ERROR;
    }
    return NPERR_NO_ERROR;
}

550
void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* )
551 552 553 554 555 556
{
    if( instance == NULL )
    {
        return;
    }

557
    VlcPluginBase *p_plugin = reinterpret_cast<VlcPluginBase *>(instance->pdata);
558 559 560 561
    if( NULL == p_plugin )
    {
        return;
    }
562

563
    if( p_plugin->player().add_item( stream->url ) != -1 )
564
    {
565
        if( p_plugin->get_options().get_autoplay() )
566
        {
567
            p_plugin->player().play();
568 569
        }
    }
570
}
571

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
572
void NPP_URLNotify( NPP, const char* ,
573
                    NPReason, void* )
574 575 576 577 578 579 580 581 582 583
{
    /***** Insert NPP_URLNotify code here *****\
    PluginInstance* p_plugin;
    if (instance != NULL)
        p_plugin = (PluginInstance*) instance->pdata;
    \*********************************************/
}

void NPP_Print( NPP instance, NPPrint* printInfo )
{
584 585
    if( printInfo == NULL )
    {
586
        return;
587
    }
588

589 590 591
    if( instance != NULL )
    {
        /***** Insert NPP_Print code here *****\
592
        PluginInstance* p_plugin = (PluginInstance*) instance->pdata;
593
        \**************************************/
594

595 596
        if( printInfo->mode == NP_FULL )
        {
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
            /*
             * PLUGIN DEVELOPERS:
             *  If your plugin would like to take over
             *  printing completely when it is in full-screen mode,
             *  set printInfo->pluginPrinted to TRUE and print your
             *  plugin as you see fit.  If your plugin wants Netscape
             *  to handle printing in this case, set
             *  printInfo->pluginPrinted to FALSE (the default) and
             *  do nothing.  If you do want to handle printing
             *  yourself, printOne is true if the print button
             *  (as opposed to the print menu) was clicked.
             *  On the Macintosh, platformPrint is a THPrint; on
             *  Windows, platformPrint is a structure
             *  (defined in npapi.h) containing the printer name, port,
             *  etc.
             */

614
            /***** Insert NPP_Print code here *****\
615 616 617 618
            void* platformPrint =
                printInfo->print.fullPrint.platformPrint;
            NPBool printOne =
                printInfo->print.fullPrint.printOne;
619
            \**************************************/
620 621

            /* Do the default*/
622
            printInfo->print.fullPrint.pluginPrinted = false;
623
        }
624 625 626
        else
        {
            /* If not fullscreen, we must be embedded */
627 628 629 630 631 632 633 634 635 636 637 638
            /*
             * PLUGIN DEVELOPERS:
             *  If your plugin is embedded, or is full-screen
             *  but you returned false in pluginPrinted above, NPP_Print
             *  will be called with mode == NP_EMBED.  The NPWindow
             *  in the printInfo gives the location and dimensions of
             *  the embedded plugin on the printed page.  On the
             *  Macintosh, platformPrint is the printer port; on
             *  Windows, platformPrint is the handle to the printing
             *  device context.
             */

639
            /***** Insert NPP_Print code here *****\
640 641 642 643
            NPWindow* printWindow =
                &(printInfo->print.embedPrint.window);
            void* platformPrint =
                printInfo->print.embedPrint.platformPrint;
644
            \**************************************/
645 646 647
        }
    }
}
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664

int16_t NPP_HandleEvent( NPP instance, void * event )
{
    if( instance == NULL )
    {
        return false;
    }

    VlcPluginBase *p_plugin = reinterpret_cast<VlcPluginBase *>(instance->pdata);
    if( p_plugin == NULL )
    {
        return false;
    }

    return p_plugin->handle_event(event);

}