Exemple #1
0
static int vlc_sd_probe_Open (vlc_object_t *obj)
{
    vlc_probe_t *probe = (vlc_probe_t *)obj;

    struct udev *udev = udev_new ();
    if (udev == NULL)
        return VLC_PROBE_CONTINUE;

    struct udev_monitor *mon = udev_monitor_new_from_netlink (udev, "udev");
    if (mon != NULL)
    {
        vlc_sd_probe_Add (probe, "v4l{longname=\"Video capture\"}",
                          N_("Video capture"), SD_CAT_DEVICES);
#ifdef HAVE_ALSA
        if (!module_exists ("pulselist"))
            vlc_sd_probe_Add (probe, "alsa{longname=\"Audio capture\"}",
                              N_("Audio capture"), SD_CAT_DEVICES);
#endif
        vlc_sd_probe_Add (probe, "disc{longname=\"Discs\"}", N_("Discs"),
                          SD_CAT_DEVICES);
        udev_monitor_unref (mon);
    }
    udev_unref (udev);
    return VLC_PROBE_CONTINUE;
}
Exemple #2
0
static int vlc_sd_probe_Open( vlc_object_t *obj )
{
    vlc_probe_t *probe = (vlc_probe_t *)obj;

    vlc_sd_probe_Add( probe, "video_dir", N_("My Videos"), SD_CAT_MYCOMPUTER );
    vlc_sd_probe_Add( probe, "audio_dir", N_("My Music"), SD_CAT_MYCOMPUTER );
    vlc_sd_probe_Add( probe, "picture_dir", N_("My Pictures"),
                      SD_CAT_MYCOMPUTER );
    return VLC_PROBE_CONTINUE;
}
Exemple #3
0
int bdsm_sd_probe_Open (vlc_object_t *p_this)
{
    vlc_probe_t *p_probe = (vlc_probe_t *)p_this;

    vlc_sd_probe_Add( p_probe, "dsm{longname=\"Windows networks\"}",
                      N_( "Windows networks" ), SD_CAT_LAN );

    return VLC_PROBE_CONTINUE;
}
Exemple #4
0
int vlclua_probe_sd( vlc_object_t *obj, const char *name )
{
    vlc_probe_t *probe = (vlc_probe_t *)obj;

    char *filename = vlclua_find_file( "sd", name );
    if( filename == NULL )
    {
        // File suddenly disappeared - maybe a race condition, no problem
        msg_Err( probe, "Couldn't probe lua services discovery script \"%s\".",
                 name );
        return VLC_PROBE_CONTINUE;
    }

    lua_State *L = luaL_newstate();
    if( !L )
    {
        msg_Err( probe, "Could not create new Lua State" );
        free( filename );
        return VLC_ENOMEM;
    }
    luaL_openlibs( L );
    if( vlclua_add_modules_path( L, filename ) )
    {
        msg_Err( probe, "Error while setting the module search path for %s",
                 filename );
        lua_close( L );
        free( filename );
        return VLC_ENOMEM;
    }
    if( vlclua_dofile( obj, L, filename ) )
    {
        msg_Err( probe, "Error loading script %s: %s", filename,
                 lua_tostring( L, -1 ) );
        lua_close( L );
        free( filename );
        return VLC_PROBE_CONTINUE;
    }
    const char *description = vlclua_sd_description( obj, L, filename );
    if( description == NULL )
        description = name;

    int r = VLC_ENOMEM;
    char *name_esc = config_StringEscape( name );
    char *chain;
    if( asprintf( &chain, "lua{sd='%s'}", name_esc ) != -1 )
    {
        r = vlc_sd_probe_Add( probe, chain, description, SD_CAT_INTERNET );
        free( chain );
    }
    free( name_esc );

    lua_close( L );
    free( filename );
    return r;
}
Exemple #5
0
static int vlc_sd_probe_Open (vlc_object_t *obj)
{
    vlc_probe_t *probe = (vlc_probe_t *)obj;

    char *display = var_InheritString (obj, "x11-display");
    xcb_connection_t *conn = xcb_connect (display, NULL);
    free (display);
    if (xcb_connection_has_error (conn))
        return VLC_PROBE_CONTINUE;
    xcb_disconnect (conn);
    return vlc_sd_probe_Add (probe, "xcb_apps",
                             N_("Screen capture"), SD_CAT_DEVICES);
}
Exemple #6
0
static int vlc_sd_probe_Open( vlc_object_t *obj )
{
    vlc_probe_t *probe = (vlc_probe_t *)obj;
    char **ppsz_filelist = NULL;
    char **ppsz_fileend  = NULL;
    char **ppsz_file;
    char *psz_name;
    char **ppsz_dir_list = NULL;
    char **ppsz_dir;
    lua_State *L = NULL;
    vlclua_dir_list( obj, "sd", &ppsz_dir_list );
    for( ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
    {
        int i_files;
        if( ppsz_filelist )
        {
            for( ppsz_file = ppsz_filelist; ppsz_file < ppsz_fileend;
                 ppsz_file++ )
                free( *ppsz_file );
            free( ppsz_filelist );
            ppsz_filelist = NULL;
        }
        i_files = vlc_scandir( *ppsz_dir, &ppsz_filelist, file_select,
                                file_compare );
        if( i_files < 1 ) continue;
        ppsz_fileend = ppsz_filelist + i_files;
        for( ppsz_file = ppsz_filelist; ppsz_file < ppsz_fileend; ppsz_file++ )
        {
            char  *psz_filename;
            if( asprintf( &psz_filename,
                          "%s" DIR_SEP "%s", *ppsz_dir, *ppsz_file ) < 0 )
            {
                goto error;
            }
            L = luaL_newstate();
            if( !L )
            {
                msg_Err( probe, "Could not create new Lua State" );
                free( psz_filename );
                goto error;
            }
            luaL_openlibs( L );
            if( vlclua_add_modules_path( probe, L, psz_filename ) )
            {
                msg_Err( probe, "Error while setting the module search path for %s",
                          psz_filename );
                free( psz_filename );
                goto error;
            }
            if( luaL_dofile( L, psz_filename ) )
            {

                msg_Err( probe, "Error loading script %s: %s", psz_filename,
                          lua_tostring( L, lua_gettop( L ) ) );
                lua_pop( L, 1 );
                free( psz_filename );
                lua_close( L );
                continue;
            }
            char *psz_longname;
            char *temp = strchr( *ppsz_file, '.' );
            if( temp )
                *temp = '\0';
            lua_getglobal( L, "descriptor" );
            if( !lua_isfunction( L, lua_gettop( L ) ) || lua_pcall( L, 0, 1, 0 ) )
            {
                msg_Warn( probe, "No 'descriptor' function in '%s'", psz_filename );
                lua_pop( L, 1 );
                if( !( psz_longname = strdup( *ppsz_file ) ) )
                {
                    free( psz_filename );
                    goto error;
                }
            }
            else
            {
                lua_getfield( L, -1, "title" );
                if( !lua_isstring( L, -1 ) ||
                    !( psz_longname = strdup( lua_tostring( L, -1 ) ) ) )
                {
                    free( psz_filename );
                    goto error;
                }
            }

            char *psz_file_esc = config_StringEscape( *ppsz_file );
            char *psz_longname_esc = config_StringEscape( psz_longname );
            if( asprintf( &psz_name, "lua{sd='%s',longname='%s'}",
                          psz_file_esc, psz_longname_esc ) < 0 )
            {
                free( psz_file_esc );
                free( psz_longname_esc );
                free( psz_filename );
                free( psz_longname );
                goto error;
            }
            free( psz_file_esc );
            free( psz_longname_esc );
            vlc_sd_probe_Add( probe, psz_name, psz_longname, SD_CAT_INTERNET );
            free( psz_name );
            free( psz_longname );
            free( psz_filename );
            lua_close( L );
        }
    }
    if( ppsz_filelist )
    {
        for( ppsz_file = ppsz_filelist; ppsz_file < ppsz_fileend;
             ppsz_file++ )
            free( *ppsz_file );
        free( ppsz_filelist );
    }
    vlclua_dir_list_free( ppsz_dir_list );
    return VLC_PROBE_CONTINUE;
error:
    if( ppsz_filelist )
    {
        for( ppsz_file = ppsz_filelist; ppsz_file < ppsz_fileend;
             ppsz_file++ )
            free( *ppsz_file );
        free( ppsz_filelist );
    }
    if( L )
        lua_close( L );
    vlclua_dir_list_free( ppsz_dir_list );
    return VLC_ENOMEM;
}