Ejemplo n.º 1
0
static void
uninstall_md_listener( libvlc_media_list_view_t * p_mlv,
                       libvlc_media_t * p_md)
{
    libvlc_media_list_t * p_mlist;
    libvlc_exception_t ignored_exception;
    libvlc_exception_init( &ignored_exception );
    libvlc_event_detach( p_md->p_event_manager,
                         libvlc_MediaSubItemAdded,
                         media_list_subitem_added, p_mlv, &ignored_exception );
    if( libvlc_exception_raised( &ignored_exception ) )
        libvlc_exception_clear( &ignored_exception ); /* We don't care if we encounter an exception */
    if((p_mlist = libvlc_media_subitems( p_md )))
    {
        libvlc_media_list_lock( p_mlist );
        libvlc_event_detach( p_mlist->p_event_manager,
                             libvlc_MediaListItemAdded,
                             media_list_item_added, p_mlv, NULL );
        libvlc_event_detach( p_mlist->p_event_manager,
                             libvlc_MediaListItemDeleted,
                             media_list_item_removed, p_mlv, NULL );

        int i, count = libvlc_media_list_count( p_mlist, NULL );
        for( i = 0; i < count; i++)
        {
            libvlc_media_t * p_submd;
            p_submd = libvlc_media_list_item_at_index( p_mlist,i, NULL );
            uninstall_md_listener( p_mlv, p_submd );
            libvlc_media_release( p_submd );
        }
        libvlc_media_list_unlock( p_mlist );
        libvlc_media_list_release( p_mlist );
    }
}
Ejemplo n.º 2
0
void vlcExceptionRaised()
{
    if (libvlc_exception_raised(vlc_exception)) {
        qDebug() << "libvlc exception:" << libvlc_exception_get_message(vlc_exception);
        libvlc_exception_clear(vlc_exception);
    }
}
Ejemplo n.º 3
0
void checkException()
{
	if( libvlc_exception_raised( p_vlc_exception ) )
	{
		qDebug() << "libvlc exception:" << libvlc_exception_get_message( p_vlc_exception );
		libvlc_exception_clear( p_vlc_exception );
	}
}
Ejemplo n.º 4
0
int VlcPlugin::playlist_add( const char *mrl, libvlc_exception_t *ex )
{
    int item = -1;
    libvlc_media_t *p_m = libvlc_media_new(libvlc_instance,mrl,ex);
    if( libvlc_exception_raised(ex) )
        return -1;

    libvlc_media_list_lock(libvlc_media_list);
    libvlc_media_list_add_media(libvlc_media_list,p_m,ex);
    if( !libvlc_exception_raised(ex) )
        item = libvlc_media_list_count(libvlc_media_list,ex)-1;
    libvlc_media_list_unlock(libvlc_media_list);

    libvlc_media_release(p_m);

    return item;
}
Ejemplo n.º 5
0
static void catchError(libvlc_exception_t *ex) {
    if(libvlc_exception_raised(ex)) {
        fprintf(stderr, "exception: %s\n", libvlc_exception_get_message(ex));
        //exit(1);
    }

    libvlc_exception_clear(ex);
}
Ejemplo n.º 6
0
static void raise(libvlc_exception_t * ex)
{
    if (libvlc_exception_raised (ex))
    {
         fprintf (stderr, "error: %s\n", libvlc_exception_get_message(ex));
         exit (-1);
    }
}
Ejemplo n.º 7
0
static void ProcessVLCException(libvlc_exception_t* ex, VLCExceptionHandler eh)
{
    if(libvlc_exception_raised(ex) && eh)
    {
		char szErrorMsg[1024]="";
        sprintf(szErrorMsg, "%s", libvlc_exception_get_message(ex));
        libvlc_exception_clear(ex);
		eh(szErrorMsg);
    }
}
Ejemplo n.º 8
0
static bool catchVLCException( libvlc_exception_t *ex )
{
    if ( libvlc_exception_raised( ex ) )
    {
        qDebug() << libvlc_errmsg();
        libvlc_exception_clear( ex );
        return (true);
    }
    return (false);
}
Ejemplo n.º 9
0
int VlcPlugin::playlist_add_extended_untrusted( const char *mrl, const char *name,
                    int optc, const char **optv, libvlc_exception_t *ex )
{
    libvlc_media_t *p_m = libvlc_media_new(libvlc_instance, mrl,ex);
    int item = -1;
    if( libvlc_exception_raised(ex) )
        return -1;

    for( int i = 0; i < optc; ++i )
        libvlc_media_add_option_flag(p_m, optv[i], libvlc_media_option_unique);

    libvlc_media_list_lock(libvlc_media_list);
    libvlc_media_list_add_media(libvlc_media_list,p_m,ex);
    if( !libvlc_exception_raised(ex) )
        item = libvlc_media_list_count(libvlc_media_list,ex)-1;
    libvlc_media_list_unlock(libvlc_media_list);
    libvlc_media_release(p_m);

    return item;
}
Ejemplo n.º 10
0
bool VlcPlugin::playlist_select( int idx, libvlc_exception_t *ex )
{
    libvlc_media_t *p_m = NULL;

    libvlc_media_list_lock(libvlc_media_list);

    int count = libvlc_media_list_count(libvlc_media_list,ex);
    if( libvlc_exception_raised(ex) )
        goto bad_unlock;

    if( idx<0||idx>=count )
        goto bad_unlock;

    playlist_index = idx;

    p_m = libvlc_media_list_item_at_index(libvlc_media_list,playlist_index,ex);
    libvlc_media_list_unlock(libvlc_media_list);

    if( libvlc_exception_raised(ex) )
        return false;

    if( libvlc_media_player )
    {
        libvlc_media_player_release( libvlc_media_player );
        libvlc_media_player = NULL;
    }

    libvlc_media_player = libvlc_media_player_new_from_media(p_m,ex);
    if( libvlc_media_player )
        set_player_window(ex);

    libvlc_media_release( p_m );
    return !libvlc_exception_raised(ex);

bad_unlock:
    libvlc_media_list_unlock(libvlc_media_list);
    return false;
}
Ejemplo n.º 11
0
static void
clutter_vlc_catch(libvlc_exception_t* vlc_exception)
{
  /* well this is really bad. Find out another way to handle vlc exceptions
   */

  if (libvlc_exception_raised(vlc_exception))
    {
      fprintf(stderr, "exception: %s\n", libvlc_exception_get_message(vlc_exception));
      exit(1);
    }

  libvlc_exception_clear(vlc_exception);
}
Ejemplo n.º 12
0
void
VlcTagger::handleException()
{
#if LIBVLC_VERSION_INT < 0x110
    if (libvlc_exception_raised(_pException)) {
        LOGNS(Omm::Av, upnpav, error, "vlc tagger: " + std::string(libvlc_exception_get_message(_pException)));
    }
    libvlc_exception_init(_pException);
#else
    const char* errMsg = libvlc_errmsg();
    if (errMsg) {
        LOGNS(Omm::Av, upnpav, error, "vlc tagger: " + std::string(errMsg));
    }
#endif
}
Ejemplo n.º 13
0
/**************************************************************************
 *       libvlc_media_list_new (Public)
 *
 * Init an object.
 **************************************************************************/
libvlc_media_list_t *
libvlc_media_list_new( libvlc_instance_t * p_inst,
                       libvlc_exception_t * p_e )
{
    libvlc_media_list_t * p_mlist;

    p_mlist = malloc(sizeof(libvlc_media_list_t));
    if( !p_mlist )
        return NULL;

    p_mlist->p_libvlc_instance = p_inst;
    p_mlist->p_event_manager = libvlc_event_manager_new( p_mlist, p_inst, p_e );

    /* Code for that one should be handled in flat_media_list.c */
    p_mlist->p_flat_mlist = NULL;
    p_mlist->b_read_only = false;

    libvlc_event_manager_register_event_type( p_mlist->p_event_manager,
            libvlc_MediaListItemAdded, p_e );
    libvlc_event_manager_register_event_type( p_mlist->p_event_manager,
            libvlc_MediaListWillAddItem, p_e );
    libvlc_event_manager_register_event_type( p_mlist->p_event_manager,
            libvlc_MediaListItemDeleted, p_e );
    libvlc_event_manager_register_event_type( p_mlist->p_event_manager,
            libvlc_MediaListWillDeleteItem, p_e );

    if( libvlc_exception_raised( p_e ) )
    {
        libvlc_event_manager_release( p_mlist->p_event_manager );
        free( p_mlist );
        return NULL;
    }

    vlc_mutex_init( &p_mlist->object_lock );
    vlc_mutex_init( &p_mlist->refcount_lock ); // FIXME: spinlock?

    vlc_array_init( &p_mlist->items );
    p_mlist->i_refcount = 1;
    p_mlist->p_md = NULL;

    return p_mlist;
}
Ejemplo n.º 14
0
/**************************************************************************
 *       add_file_content (Public)
 **************************************************************************/
void
libvlc_media_list_add_file_content( libvlc_media_list_t * p_mlist,
                                    const char * psz_uri,
                                    libvlc_exception_t * p_e )
{
    input_item_t * p_input_item;
    libvlc_media_t * p_md;

    p_input_item = input_item_NewExt(
                           p_mlist->p_libvlc_instance->p_libvlc_int, psz_uri,
                                         _("Media Library"), 0, NULL, 0, -1 );

    if( !p_input_item )
    {
        libvlc_exception_raise( p_e );
        libvlc_printerr( "Not enough memory" );
        return;
    }

    p_md = libvlc_media_new_from_input_item(
            p_mlist->p_libvlc_instance,
            p_input_item, p_e );

    if( !p_md )
    {
        vlc_gc_decref( p_input_item );
        return;
    }

    libvlc_media_list_add_media( p_mlist, p_md, p_e );
    if( libvlc_exception_raised( p_e ) )
        return;

    input_Read( p_mlist->p_libvlc_instance->p_libvlc_int, p_input_item );

    return;
}
Ejemplo n.º 15
0
/*****************************************************************************
 * main: parse command line, start interface and spawn threads.
 *****************************************************************************/
int main( int i_argc, const char *ppsz_argv[] )
{
#ifdef __APPLE__
    /* The so-called POSIX-compliant MacOS X is not. 
     * SIGPIPE fires even when it is blocked in all threads! */
    signal (SIGPIPE, SIG_IGN);
#endif

#ifndef ALLOW_RUN_AS_ROOT
    if (geteuid () == 0)
    {
        fprintf (stderr, "VLC is not supposed to be run as root. Sorry.\n"
        "If you need to use real-time priorities and/or privileged TCP ports\n"
        "you can use %s-wrapper (make sure it is Set-UID root and\n"
        "cannot be run by non-trusted users first).\n", ppsz_argv[0]);
        return 1;
    }
#endif

    setlocale (LC_ALL, "");

#ifndef __APPLE__
    /* This clutters OSX GUI error logs */
    fprintf( stderr, "VLC media player %s\n", libvlc_get_version() );
#endif

#ifdef HAVE_PUTENV
#   ifndef NDEBUG
    /* Activate malloc checking routines to detect heap corruptions. */
    putenv( (char*)"MALLOC_CHECK_=2" );

    /* Disable the ugly Gnome crash dialog so that we properly segfault */
    putenv( (char *)"GNOME_DISABLE_CRASH_DIALOG=1" );
#   endif
#endif

    /* Synchronously intercepted POSIX signals.
     *
     * In a threaded program such as VLC, the only sane way to handle signals
     * is to block them in all thread but one - this is the only way to
     * predict which thread will receive them. If any piece of code depends
     * on delivery of one of this signal it is intrinsically not thread-safe
     * and MUST NOT be used in VLC, whether we like it or not.
     * There is only one exception: if the signal is raised with
     * pthread_kill() - we do not use this in LibVLC but some pthread
     * implementations use them internally. You should really use conditions
     * for thread synchronization anyway.
     *
     * Signal that request a clean shutdown, and force an unclean shutdown
     * if they are triggered again 2+ seconds later.
     * We have to handle SIGTERM cleanly because of daemon mode.
     * Note that we set the signals after the vlc_create call. */
    static const int sigs[] = {
        SIGINT, SIGHUP, SIGQUIT, SIGTERM,
    /* Signals that cause a no-op:
     * - SIGPIPE might happen with sockets and would crash VLC. It MUST be
     *   blocked by any LibVLC-dependent application, not just VLC.
     * - SIGCHLD comes after exec*() (such as httpd CGI support) and must
     *   be dequeued to cleanup zombie processes.
     */
        SIGPIPE, SIGCHLD
    };

    sigset_t set;
    sigemptyset (&set);
    for (unsigned i = 0; i < sizeof (sigs) / sizeof (sigs[0]); i++)
        sigaddset (&set, sigs[i]);

    /* Block all these signals */
    pthread_sigmask (SIG_BLOCK, &set, NULL);
    sigdelset (&set, SIGPIPE);
    sigdelset (&set, SIGCHLD);

    /* Note that FromLocale() can be used before libvlc is initialized */
    const char *argv[i_argc + 3];
    int argc = 0;

    argv[argc++] = "--no-ignore-config";
#ifdef TOP_BUILDDIR
    argv[argc++] = FromLocale ("--plugin-path="TOP_BUILDDIR"/modules");
#endif
#ifdef TOP_SRCDIR
# ifdef ENABLE_HTTPD
    argv[argc++] = FromLocale ("--http-src="TOP_SRCDIR"/share/http");
# endif
#endif

    for (int i = 1; i < i_argc; i++)
        if ((argv[argc++] = FromLocale (ppsz_argv[i])) == NULL)
            return 1; // BOOM!
    argv[argc] = NULL;

    libvlc_exception_t ex, dummy;
    libvlc_exception_init (&ex);
    libvlc_exception_init (&dummy);

    /* Initialize libvlc */
    libvlc_instance_t *vlc = libvlc_new (argc, argv, &ex);

    if (vlc != NULL)
    {
        libvlc_add_intf (vlc, "signals", &ex);
        if (libvlc_exception_raised (&ex))
        {
            libvlc_exception_clear (&ex);
            pthread_sigmask (SIG_UNBLOCK, &set, NULL);
        }
#if !defined (HAVE_MAEMO)
        libvlc_add_intf (vlc, "globalhotkeys,none", &ex);
#endif
        libvlc_exception_clear (&ex);
        libvlc_add_intf (vlc, NULL, &ex);
        libvlc_playlist_play (vlc, -1, 0, NULL, &dummy);
        libvlc_wait (vlc);

        if (libvlc_exception_raised (&ex))
            fprintf( stderr, "%s\n", libvlc_errmsg() );
        libvlc_release (vlc);
    }

    for (int i = 1; i < argc; i++)
        LocaleFree (argv[i]);

    return vlc == NULL || libvlc_exception_raised (&ex);
}
Ejemplo n.º 16
0
RuntimeNPObject::InvokeResult
LibvlcInputNPObject::getProperty(int index, NPVariant &result)
{
    /* is plugin still running */
    if( isPluginRunning() )
    {
        VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
        libvlc_exception_t ex;
        libvlc_exception_init(&ex);

        libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
        if( libvlc_exception_raised(&ex) )
        {
            if( index != ID_input_state )
            {
                NPN_SetException(this, libvlc_exception_get_message(&ex));
                libvlc_exception_clear(&ex);
                return INVOKERESULT_GENERIC_ERROR;
            }
            else
            {
                /* for input state, return CLOSED rather than an exception */
                INT32_TO_NPVARIANT(0, result);
                libvlc_exception_clear(&ex);
                return INVOKERESULT_NO_ERROR;
            }
        }

        switch( index )
        {
            case ID_input_length:
            {
                double val = (double)libvlc_media_player_get_length(p_md, &ex);
                RETURN_ON_EXCEPTION(this,ex);
                DOUBLE_TO_NPVARIANT(val, result);
                return INVOKERESULT_NO_ERROR;
            }
            case ID_input_position:
            {
                double val = libvlc_media_player_get_position(p_md, &ex);
                RETURN_ON_EXCEPTION(this,ex);
                DOUBLE_TO_NPVARIANT(val, result);
                return INVOKERESULT_NO_ERROR;
            }
            case ID_input_time:
            {
                double val = (double)libvlc_media_player_get_time(p_md, &ex);
                RETURN_ON_EXCEPTION(this,ex);
                DOUBLE_TO_NPVARIANT(val, result);
                return INVOKERESULT_NO_ERROR;
            }
            case ID_input_state:
            {
                int val = libvlc_media_player_get_state(p_md, &ex);
                RETURN_ON_EXCEPTION(this,ex);
                INT32_TO_NPVARIANT(val, result);
                return INVOKERESULT_NO_ERROR;
            }
            case ID_input_rate:
            {
                float val = libvlc_media_player_get_rate(p_md, &ex);
                RETURN_ON_EXCEPTION(this,ex);
                DOUBLE_TO_NPVARIANT(val, result);
                return INVOKERESULT_NO_ERROR;
            }
            case ID_input_fps:
            {
                double val = libvlc_media_player_get_fps(p_md, &ex);
                RETURN_ON_EXCEPTION(this,ex);
                DOUBLE_TO_NPVARIANT(val, result);
                return INVOKERESULT_NO_ERROR;
            }
            case ID_input_hasvout:
            {
                bool val = p_plugin->player_has_vout(&ex);
                RETURN_ON_EXCEPTION(this,ex);
                BOOLEAN_TO_NPVARIANT(val, result);
                return INVOKERESULT_NO_ERROR;
            }
            default:
                ;
        }
    }
    return INVOKERESULT_GENERIC_ERROR;
}
Ejemplo n.º 17
0
mediacontrol_StreamInformation *
mediacontrol_get_stream_information( mediacontrol_Instance *self,
                                     mediacontrol_PositionKey a_key,
                                     mediacontrol_Exception *exception )
{
    (void)a_key;
    mediacontrol_StreamInformation *retval = NULL;
    libvlc_media_t * p_media;
    libvlc_exception_t ex;

    libvlc_exception_init( &ex );

    retval = ( mediacontrol_StreamInformation* )
                            malloc( sizeof( mediacontrol_StreamInformation ) );
    if( ! retval )
    {
        RAISE( mediacontrol_InternalException, "Out of memory" );
        return NULL;
    }

    p_media = libvlc_media_player_get_media( self->p_media_player, &ex );
    HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
    if( ! p_media )
    {
        /* No p_media defined */
        retval->streamstatus = mediacontrol_UndefinedStatus;
        retval->url          = strdup( "" );
        retval->position     = 0;
        retval->length       = 0;
    }
    else
    {
        libvlc_state_t state;
        state = libvlc_media_player_get_state( self->p_media_player, &ex );
        HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
        switch( state )
        {
        case libvlc_NothingSpecial:
            retval->streamstatus = mediacontrol_UndefinedStatus;
            break;
        case libvlc_Opening :
            retval->streamstatus = mediacontrol_InitStatus;
            break;
        case libvlc_Buffering:
            retval->streamstatus = mediacontrol_BufferingStatus;
            break;
        case libvlc_Playing:
            retval->streamstatus = mediacontrol_PlayingStatus;
            break;
        case libvlc_Paused:
            retval->streamstatus = mediacontrol_PauseStatus;
            break;
        case libvlc_Stopped:
            retval->streamstatus = mediacontrol_StopStatus;
            break;
        case libvlc_Forward:
            retval->streamstatus = mediacontrol_ForwardStatus;
            break;
        case libvlc_Backward:
            retval->streamstatus = mediacontrol_BackwardStatus;
            break;
        case libvlc_Ended:
            retval->streamstatus = mediacontrol_EndStatus;
            break;
        case libvlc_Error:
            retval->streamstatus = mediacontrol_ErrorStatus;
            break;
        default :
            retval->streamstatus = mediacontrol_UndefinedStatus;
            break;
        }

        retval->url = libvlc_media_get_mrl( p_media, &ex );
	
        retval->position = libvlc_media_player_get_time( self->p_media_player, &ex );
        if( libvlc_exception_raised( &ex ) )
        {
            libvlc_exception_clear( &ex );
            retval->position = 0;
        }

        retval->length = libvlc_media_player_get_length( self->p_media_player, &ex );
        if( libvlc_exception_raised( &ex ) )
        {
            libvlc_exception_clear( &ex );
            retval->length = 0;
        }

    }
    return retval;
}
Ejemplo n.º 18
0
NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
{
    /* prepare VLC command line */
    const char *ppsz_argv[32];
    int ppsz_argc = 0;

#ifndef NDEBUG
    ppsz_argv[ppsz_argc++] = "--no-plugins-cache";
#endif

    /* locate VLC module path */
#ifdef XP_MACOSX
    ppsz_argv[ppsz_argc++] = "--plugin-path=/Library/Internet\\ Plug-Ins/VLC\\ Plugin.plugin/Contents/MacOS/modules";
    ppsz_argv[ppsz_argc++] = "--vout=minimal_macosx";
#elif defined(XP_WIN)
    HKEY h_key;
    DWORD i_type, i_data = MAX_PATH + 1;
    char p_data[MAX_PATH + 1];
    if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
                      0, KEY_READ, &h_key ) == ERROR_SUCCESS )
    {
         if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
                              (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
         {
             if( i_type == REG_SZ )
             {
                 strcat( p_data, "\\plugins" );
                 ppsz_argv[ppsz_argc++] = "--plugin-path";
                 ppsz_argv[ppsz_argc++] = p_data;
             }
         }
         RegCloseKey( h_key );
    }
    ppsz_argv[ppsz_argc++] = "--no-one-instance";

#endif /* XP_MACOSX */

    /* common settings */
    ppsz_argv[ppsz_argc++] = "-vv";
    ppsz_argv[ppsz_argc++] = "--no-stats";
    ppsz_argv[ppsz_argc++] = "--no-media-library";
    ppsz_argv[ppsz_argc++] = "--intf=dummy";
    ppsz_argv[ppsz_argc++] = "--no-video-title-show";

    const char *progid = NULL;

    /* parse plugin arguments */
    for( int i = 0; (i < argc) && (ppsz_argc < 32); i++ )
    {
       /* fprintf(stderr, "argn=%s, argv=%s\n", argn[i], argv[i]); */

        if( !strcmp( argn[i], "target" )
         || !strcmp( argn[i], "mrl")
         || !strcmp( argn[i], "filename")
         || !strcmp( argn[i], "src") )
        {
            psz_target = argv[i];
        }
        else if( !strcmp( argn[i], "text" ) )
        {
            free( psz_text );
            psz_text = strdup( argv[i] );
        }
        else if( !strcmp( argn[i], "autoplay")
              || !strcmp( argn[i], "autostart") )
        {
            b_autoplay = boolValue(argv[i]);
        }
        else if( !strcmp( argn[i], "fullscreen" ) )
        {
            if( boolValue(argv[i]) )
            {
                ppsz_argv[ppsz_argc++] = "--fullscreen";
            }
            else
            {
                ppsz_argv[ppsz_argc++] = "--no-fullscreen";
            }
        }
        else if( !strcmp( argn[i], "mute" ) )
        {
            if( boolValue(argv[i]) )
            {
                ppsz_argv[ppsz_argc++] = "--volume=0";
            }
        }
        else if( !strcmp( argn[i], "loop")
              || !strcmp( argn[i], "autoloop") )
        {
            if( boolValue(argv[i]) )
            {
                ppsz_argv[ppsz_argc++] = "--loop";
            }
            else
            {
                ppsz_argv[ppsz_argc++] = "--no-loop";
            }
        }
        else if( !strcmp( argn[i], "version")
              || !strcmp( argn[i], "progid") )
        {
            progid = argv[i];
        }
        else if( !strcmp( argn[i], "toolbar" ) )
        {
/* FIXME: Remove this when toolbar functionality has been implemented on
 * MacOS X and Win32 for Firefox/Mozilla/Safari. */
#ifdef XP_UNIX
            b_toolbar = boolValue(argv[i]);
#endif
        }
    }

    libvlc_exception_t ex;
    libvlc_exception_init(&ex);

    libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv, &ex);
    if( libvlc_exception_raised(&ex) )
    {
        libvlc_exception_clear(&ex);
        return NPERR_GENERIC_ERROR;
    }

    libvlc_media_list = libvlc_media_list_new(libvlc_instance,&ex);
    if( libvlc_exception_raised(&ex) )
    {
        libvlc_exception_clear(&ex);
        return NPERR_GENERIC_ERROR;
    }

    /*
    ** fetch plugin base URL, which is the URL of the page containing the plugin
    ** this URL is used for making absolute URL from relative URL that may be
    ** passed as an MRL argument
    */
    NPObject *plugin = NULL;

    if( NPERR_NO_ERROR == NPN_GetValue(p_browser, NPNVWindowNPObject, &plugin) )
    {
        /*
        ** is there a better way to get that info ?
        */
        static const char docLocHref[] = "document.location.href";
        NPString script;
        NPVariant result;

        script.utf8characters = docLocHref;
        script.utf8length = sizeof(docLocHref)-1;

        if( NPN_Evaluate(p_browser, plugin, &script, &result) )
        {
            if( NPVARIANT_IS_STRING(result) )
            {
                NPString &location = NPVARIANT_TO_STRING(result);

                psz_baseURL = (char *) malloc(location.utf8length+1);
                if( psz_baseURL )
                {
                    strncpy(psz_baseURL, location.utf8characters, location.utf8length);
                    psz_baseURL[location.utf8length] = '\0';
                }
            }
            NPN_ReleaseVariantValue(&result);
        }
        NPN_ReleaseObject(plugin);
    }

    if( psz_target )
    {
        // get absolute URL from src
        char *psz_absurl = getAbsoluteURL(psz_target);
        psz_target = psz_absurl ? psz_absurl : strdup(psz_target);
    }

    /* assign plugin script root class */
    /* new APIs */
    p_scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass();

    return NPERR_NO_ERROR;
}