Exemplo n.º 1
0
static int Demux( demux_t *p_demux )
{
    xml_reader_t *p_xml_reader = NULL;
    const char *node;
    int i_ret = -1;
    input_item_t *p_current_input = GetCurrentItem(p_demux);
    input_item_node_t *p_input_node = NULL;

    p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s );
    if( !p_xml_reader )
        goto error;

    /* check root node */
    if( xml_ReaderNextNode( p_xml_reader, &node ) != XML_READER_STARTELEM )
    {
        msg_Err( p_demux, "invalid file (no root node)" );
        goto error;
    }

    if( strcmp( node, "genrelist" ) && strcmp( node, "stationlist" ) )
    {
        msg_Err( p_demux, "invalid root node <%s>", node );
        goto error;
    }

    p_input_node = input_item_node_Create( p_current_input );

    if( !strcmp( node, "genrelist" ) )
    {
        /* we're reading a genre list */
        if( DemuxGenre( p_demux, p_xml_reader, p_input_node ) )
            goto error;
    }
    else
    {
        /* we're reading a station list */
        if( DemuxStation( p_demux, p_xml_reader, p_input_node,
                var_InheritBool( p_demux, "shoutcast-show-adult" ) ) )
            goto error;
    }

    input_item_node_PostAndDelete( p_input_node );
    p_input_node = NULL;

    i_ret = 0; /* Needed for correct operation of go back */

error:
    if( p_xml_reader )
        xml_ReaderDelete( p_xml_reader );
    if( p_input_node ) input_item_node_Delete( p_input_node );
    vlc_gc_decref(p_current_input);
    return i_ret;
}
Exemplo n.º 2
0
static void ParseRequest( services_discovery_t *p_sd )
{
    services_discovery_sys_t *p_sys = p_sd->p_sys;

    char *psz_request = p_sys->psz_request;

    int i;

    char *psz_tok = strchr( psz_request, ':' );
    if( !psz_tok ) return;
    *psz_tok = '\0';
    if( !strcmp( psz_request, "ADD" ) )
    {
        psz_request = psz_tok + 1;
        for( i = 0; i<p_sys->i_urls; i++ )
            if( !strcmp(p_sys->ppsz_urls[i],psz_request) )
              break;
        if( i == p_sys->i_urls )
        {
            INSERT_ELEM( p_sys->ppsz_urls, p_sys->i_urls, p_sys->i_urls,
              strdup( psz_request ) );

            input_item_t *p_input;
            p_input = input_item_New( p_sd, psz_request, psz_request );
            input_item_AddOption( p_input, "demux=podcast", VLC_INPUT_OPTION_TRUSTED );

            INSERT_ELEM( p_sys->pp_items, p_sys->i_items, p_sys->i_items, p_input );
            services_discovery_AddItem( p_sd, p_input, NULL /* no cat */ );

            INSERT_ELEM( p_sys->pp_input, p_sys->i_input, p_sys->i_input,
                         input_CreateAndStart( p_sd, p_input, NULL ) );
            SaveUrls( p_sd );
        }
    }
    else if ( !strcmp( psz_request, "RM" ) )
    {
        psz_request = psz_tok + 1;
        for( i = 0; i<p_sys->i_urls; i++ )
          if( !strcmp(p_sys->ppsz_urls[i],psz_request) )
            break;
        if( i != p_sys->i_urls )
        {
            services_discovery_RemoveItem( p_sd, p_sys->pp_items[i] );
            vlc_gc_decref( p_sys->pp_items[i] );
            REMOVE_ELEM( p_sys->ppsz_urls, p_sys->i_urls, i );
            REMOVE_ELEM( p_sys->pp_items, p_sys->i_items, i );
        }
        SaveUrls( p_sd );
    }

    free( p_sys->psz_request );
    p_sys->psz_request = NULL;
}
Exemplo n.º 3
0
/**
 * \brief demuxer function for XSPF parsing
 */
int Demux( demux_t *p_demux )
{
    int i_ret = -1;
    xml_reader_t *p_xml_reader = NULL;
    const char *name = NULL;
    input_item_t *p_current_input = GetCurrentItem(p_demux);
    p_demux->p_sys->pp_tracklist = NULL;
    p_demux->p_sys->i_tracklist_entries = 0;
    p_demux->p_sys->i_track_id = -1;
    p_demux->p_sys->psz_base = NULL;

    /* create new xml parser from stream */
    p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s );
    if( !p_xml_reader )
        goto end;

    /* locating the root node */
    if( xml_ReaderNextNode( p_xml_reader, &name ) != XML_READER_STARTELEM )
    {
        msg_Err( p_demux, "can't read xml stream" );
        goto end;
    }

    /* checking root node name */
    if( strcmp( name, "playlist" ) )
    {
        msg_Err( p_demux, "invalid root node name <%s>", name );
        goto end;
    }

    input_item_node_t *p_subitems =
        input_item_node_Create( p_current_input );

    i_ret = parse_playlist_node( p_demux, p_subitems,
                                 p_xml_reader, "playlist" ) ? 0 : -1;

    for( int i = 0 ; i < p_demux->p_sys->i_tracklist_entries ; i++ )
    {
        input_item_t *p_new_input = p_demux->p_sys->pp_tracklist[i];
        if( p_new_input )
        {
            input_item_node_AppendItem( p_subitems, p_new_input );
        }
    }

    input_item_node_PostAndDelete( p_subitems );

end:
    vlc_gc_decref(p_current_input);
    if( p_xml_reader )
        xml_ReaderDelete( p_xml_reader );
    return i_ret; /* Needed for correct operation of go back */
}
/** Parses the whole channels.conf file */
static int Demux(demux_t *demux)
{
    input_item_t *input = GetCurrentItem(demux);
    input_item_node_t *subitems = input_item_node_Create(input);
    char *line;

    while ((line = stream_ReadLine(demux->s)) != NULL)
    {
        input_item_t *item = ParseLine(line);
        if (item == NULL)
            continue;

        input_item_node_AppendItem(subitems, item);
        vlc_gc_decref(item);
    }

    input_item_node_PostAndDelete(subitems);
    vlc_gc_decref(input);

    return 0; /* Needed for correct operation of go back */
}
Exemplo n.º 5
0
static int vlclua_sd_add_item( lua_State *L )
{
    services_discovery_t *p_sd = (services_discovery_t *)vlclua_get_this( L );
    if( lua_istable( L, -1 ) )
    {
        lua_getfield( L, -1, "path" );
        if( lua_isstring( L, -1 ) )
        {
            char **ppsz_options = NULL;
            int i_options = 0;
            const char *psz_path = lua_tostring( L, -1 );
            vlclua_read_options( p_sd, L, &i_options, &ppsz_options );
            input_item_t *p_input = input_item_NewExt( p_sd, psz_path, psz_path,
                                                       i_options,
                                                       (const char **)ppsz_options,
                                                       VLC_INPUT_OPTION_TRUSTED, -1 );
            lua_pop( L, 1 );

            if( p_input )
            {
                vlclua_read_meta_data( p_sd, L, p_input );
                /* This one is to be tested... */
                vlclua_read_custom_meta_data( p_sd, L, p_input );
                /* The duration is given in seconds, convert to microseconds */
                lua_getfield( L, -1, "duration" );
                if( lua_isnumber( L, -1 ) )
                   input_item_SetDuration( p_input, (lua_tonumber( L, -1 )*1e6) );
                else if( !lua_isnil( L, -1 ) )
                    msg_Warn( p_sd, "Item duration should be a number (in seconds)." );
                lua_pop( L, 1 );
                services_discovery_AddItem( p_sd, p_input, NULL );
                input_item_t **udata = (input_item_t **)
                                       lua_newuserdata( L, sizeof( input_item_t * ) );
                *udata = p_input;
                if( luaL_newmetatable( L, "input_item_t" ) )
                {
                    lua_pushliteral( L, "none of your business" );
                    lua_setfield( L, -2, "__metatable" );
                }
                lua_setmetatable( L, -2 );
                vlc_gc_decref( p_input );
            }
            while( i_options > 0 )
                free( ppsz_options[--i_options] );
            free( ppsz_options );
        }
        else
            msg_Err( p_sd, "vlc.sd.add_item: the \"path\" parameter can't be empty" );
    }
    else
        msg_Err( p_sd, "Error parsing add_item arguments" );
    return 1;
}
Exemplo n.º 6
0
Arquivo: ifo.c Projeto: CivilPol/vlc
static int Demux( demux_t *p_demux )
{
    char *psz_url, *psz_dir;

    psz_dir = strrchr( p_demux->psz_location, '/' );
    if( psz_dir != NULL )
        psz_dir[1] = '\0';

    if( asprintf( &psz_url, "dvd://%s", p_demux->psz_location ) == -1 )
        return 0;

    input_item_t *p_current_input = GetCurrentItem(p_demux);
    input_item_t *p_input = input_item_New( psz_url, psz_url );
    input_item_PostSubItem( p_current_input, p_input );
    vlc_gc_decref( p_input );

    vlc_gc_decref(p_current_input);
    free( psz_url );

    return 0; /* Needed for correct operation of go back */
}
Exemplo n.º 7
0
Arquivo: ifo.c Projeto: cobr123/qtVlc
static int Demux( demux_t *p_demux )
{
    size_t len = strlen( "dvd://" ) + strlen( p_demux->psz_path )
               - strlen( "VIDEO_TS.IFO" );
    char *psz_url;

    psz_url = malloc( len+1 );
    if( !psz_url )
        return 0;
    snprintf( psz_url, len+1, "dvd://%s", p_demux->psz_path );

    input_item_t *p_current_input = GetCurrentItem(p_demux);
    input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url );
    input_item_PostSubItem( p_current_input, p_input );
    vlc_gc_decref( p_input );

    vlc_gc_decref(p_current_input);
    free( psz_url );

    return 0; /* Needed for correct operation of go back */
}
Exemplo n.º 8
0
Arquivo: ifo.c Projeto: cobr123/qtVlc
static int DemuxDVD_VR( demux_t *p_demux )
{
    char *psz_url = strdup( p_demux->psz_path );

    if( !psz_url )
        return 0;

    size_t len = strlen( psz_url );

    strncpy( psz_url + len - 12, "VR_MOVIE.VRO", 12 );

    input_item_t *p_current_input = GetCurrentItem(p_demux);
    input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url );
    input_item_PostSubItem( p_current_input, p_input );

    vlc_gc_decref( p_input );

    vlc_gc_decref(p_current_input);
    free( psz_url );

    return 0; /* Needed for correct operation of go back */
}
Exemplo n.º 9
0
Arquivo: xspf.c Projeto: Kafay/vlc
void Close_xspf( vlc_object_t *p_this )
{
    demux_t *p_demux = (demux_t *)p_this;
    int i;
    for(i = 0; i < p_demux->p_sys->i_tracklist_entries; i++)
    {
        if(p_demux->p_sys->pp_tracklist[i])
            vlc_gc_decref( p_demux->p_sys->pp_tracklist[i] );
    }
    free( p_demux->p_sys->pp_tracklist );
    free( p_demux->p_sys->psz_base );
    free( p_demux->p_sys );
}
Exemplo n.º 10
0
/* Garbage collection of an input_item_t */
static int vlclua_input_item_delete( lua_State *L )
{
    input_item_t **pp_item = luaL_checkudata( L, 1, "input_item" );
    input_item_t *p_item = *pp_item;

    if( !p_item )
        return luaL_error( L, "script went completely foobar" );

    *pp_item = NULL;
    vlc_gc_decref( p_item );

    return 1;
}
PLSelector::~PLSelector()
{
    if( podcastsParent )
    {
        int c = podcastsParent->childCount();
        for( int i = 0; i < c; i++ )
        {
            QTreeWidgetItem *item = podcastsParent->child(i);
            input_item_t *p_input = item->data( 0, IN_ITEM_ROLE ).value<input_item_t*>();
            vlc_gc_decref( p_input );
        }
    }
}
Exemplo n.º 12
0
static int onNewFileAdded( vlc_object_t *p_this, char const *psz_var,
                     vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
    (void)p_this;

    services_discovery_t *p_sd = p_data;
    services_discovery_sys_t *p_sys = p_sd->p_sys;

    (void)psz_var; (void)oldval;
    char* psz_file = newval.psz_string;
    if( !psz_file || !*psz_file )
        return VLC_EGENERIC;

    char* psz_uri = make_URI( psz_file, "file" );
    input_item_t* p_item = input_item_New( psz_uri, NULL );

    if( p_sys->i_type == Picture )
    {
        if( fileType( p_sd, psz_file ) == Picture )
        {
            formatSnapshotItem( p_item );
            services_discovery_AddItem( p_sd, p_item, NULL );

            msg_Dbg( p_sd, "New snapshot added : %s", psz_file );
        }
    }
    else if( p_sys->i_type == Audio )
    {
        if( fileType( p_sd, psz_file ) == Audio )
        {
            services_discovery_AddItem( p_sd, p_item, NULL );

            msg_Dbg( p_sd, "New recorded audio added : %s", psz_file );
        }
    }
    else if( p_sys->i_type == Video )
    {
        if( fileType( p_sd, psz_file ) == Video ||
            fileType( p_sd, psz_file ) == Unknown )
        {
            services_discovery_AddItem( p_sd, p_item, NULL );

            msg_Dbg( p_sd, "New recorded video added : %s", psz_file );
        }
    }

    vlc_gc_decref( p_item );
    free( psz_uri );

    return VLC_SUCCESS;
}
Exemplo n.º 13
0
/*****************************************************************************
 * Run:
 *****************************************************************************/
static void *Run( void *data )
{
    services_discovery_t *p_sd = data;
    services_discovery_sys_t *p_sys = p_sd->p_sys;

    int canc = vlc_savecancel();

    int num_dir = sizeof( p_sys->psz_dir ) / sizeof( p_sys->psz_dir[0] );
    for( int i = 0; i < num_dir; i++ )
    {
        char* psz_dir = p_sys->psz_dir[i];

        /* make sure the directory exists */
        struct stat st;
        if( psz_dir == NULL            ||
            utf8_stat( psz_dir, &st )  ||
            !S_ISDIR( st.st_mode ) )
            continue;

        // TODO:  make_URI is only for file://, what about dir:// ?
        // char* psz_uri = make_URI( psz_dir );
        char* psz_uri;
        if( asprintf( &psz_uri, "dir://%s",  psz_dir ) == -1 )
            continue;

        input_item_t* p_root = input_item_New( p_sd, psz_uri, NULL );
        if( p_sys->i_type == Picture )
            input_item_AddOption( p_root, "ignore-filetypes=ini,db,lnk,txt",
                                  VLC_INPUT_OPTION_TRUSTED );

        input_item_AddOption( p_root, "recursive=collapse",
                              VLC_INPUT_OPTION_TRUSTED );


        vlc_event_manager_t *p_em = &p_root->event_manager;
        vlc_event_attach( p_em, vlc_InputItemSubItemAdded,
                          input_item_subitem_added, p_sd );

        input_Read( p_sd, p_root );

        vlc_event_detach( p_em, vlc_InputItemSubItemAdded,
                          input_item_subitem_added, p_sd );

        vlc_gc_decref( p_root );
        free( psz_uri );
    }

    vlc_restorecancel(canc);
    return NULL;
}
Exemplo n.º 14
0
Arquivo: ifo.c Projeto: CivilPol/vlc
static int DemuxDVD_VR( demux_t *p_demux )
{
    size_t len = strlen( p_demux->psz_location );
    char *psz_url = malloc( len + 1 );

    if( unlikely( psz_url == NULL ) )
        return 0;
    assert( len >= 12 );
    len -= 12;
    memcpy( psz_url, p_demux->psz_location, len );
    memcpy( psz_url + len, "VR_MOVIE.VRO", 13 );

    input_item_t *p_current_input = GetCurrentItem(p_demux);
    input_item_t *p_input = input_item_New( psz_url, psz_url );
    input_item_PostSubItem( p_current_input, p_input );

    vlc_gc_decref( p_input );

    vlc_gc_decref(p_current_input);
    free( psz_url );

    return 0; /* Needed for correct operation of go back */
}
Exemplo n.º 15
0
/**
 * \brief demuxer function for iTML parsing
 */
int Demux( demux_t *p_demux )
{
    xml_reader_t *p_xml_reader;
    const char *node;

    input_item_t *p_current_input = GetCurrentItem(p_demux);
    p_demux->p_sys->i_ntracks = 0;

    /* create new xml parser from stream */
    p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s );
    if( !p_xml_reader )
        goto end;

    /* locating the root node */
    int type;
    do
    {
        type = xml_ReaderNextNode( p_xml_reader, &node );
        if( type <= 0 )
        {
            msg_Err( p_demux, "can't read xml stream" );
            goto end;
        }
    }
    while( type != XML_READER_STARTELEM );

    /* checking root node name */
    if( strcmp( node, "plist" ) )
    {
        msg_Err( p_demux, "invalid root node <%s>", node );
        goto end;
    }

    input_item_node_t *p_subitems = input_item_node_Create( p_current_input );
    xml_elem_hnd_t pl_elements[] =
//        { {"dict",    COMPLEX_CONTENT, {.cmplx = parse_plist_dict} } };
            { {"dict",    COMPLEX_CONTENT, {(bool (__cdecl *)(track_elem_t *,const char *,char *))parse_plist_dict} } };		// sunqueen modify
    parse_plist_node( p_demux, p_subitems, NULL, p_xml_reader, "plist",
                      pl_elements );
    input_item_node_PostAndDelete( p_subitems );

    vlc_gc_decref(p_current_input);

end:
    if( p_xml_reader )
        xml_ReaderDelete( p_xml_reader );

    /* Needed for correct operation of go back */
    return 0;
}
Exemplo n.º 16
0
Container::~Container()
{
    for ( unsigned int i = 0; i < _containers.size(); i++ )
    {
        delete _containers[i];
    }

    for ( unsigned int i = 0; i < _items.size(); i++ )
    {
        delete _items[i];
    }

    if(_inputItem )
        vlc_gc_decref( _inputItem );
}
Exemplo n.º 17
0
Arquivo: mtp.c Projeto: etix/vlc
static void CloseDevice( services_discovery_t *p_sd )
{
    input_item_t **pp_items = p_sd->p_sys->pp_items;

    if( pp_items != NULL )
    {
        for( int i_i = 0; i_i < p_sd->p_sys->i_count; i_i++ )
        {
            if( pp_items[i_i] != NULL )
            {
                services_discovery_RemoveItem( p_sd, pp_items[i_i] );
                vlc_gc_decref( pp_items[i_i] );
            }
        }
        free( pp_items );
    }
}
Exemplo n.º 18
0
Arquivo: udev.c Projeto: cobr123/qtVlc
/**
 * Adds a udev device.
 */
static int AddDevice (services_discovery_t *sd, struct udev_device *dev)
{
    services_discovery_sys_t *p_sys = sd->p_sys;

    char *mrl = p_sys->subsys->get_mrl (dev);
    if (mrl == NULL)
        return 0; /* don't know if it was an error... */
    char *name = p_sys->subsys->get_name (dev);
    input_item_t *item = input_item_NewWithType (VLC_OBJECT (sd), mrl,
                                                 name ? name : mrl,
                                                 0, NULL, 0, -1,
                                                 p_sys->subsys->item_type);
    msg_Dbg (sd, "adding %s (%s)", mrl, name);
    free (name);
    free (mrl);
    if (item == NULL)
        return -1;

    struct device *d = malloc (sizeof (*d));
    if (d == NULL)
    {
        vlc_gc_decref (item);
        return -1;
    }
    d->devnum = udev_device_get_devnum (dev);
    d->item = item;
    d->sd = NULL;

    struct device **dp = tsearch (d, &p_sys->root, cmpdev);
    if (dp == NULL) /* Out-of-memory */
    {
        DestroyDevice (d);
        return -1;
    }
    if (*dp != d) /* Overwrite existing device */
    {
        DestroyDevice (*dp);
        *dp = d;
    }

    name = p_sys->subsys->get_cat (dev);
    services_discovery_AddItem (sd, item, name ? name : "Generic");
    d->sd = sd;
    free (name);
    return 0;
}
Exemplo n.º 19
0
Arquivo: item.c Projeto: BossKing/vlc
static int RecursiveInsertCopy (
    playlist_t *p_playlist, playlist_item_t *p_item,
    playlist_item_t *p_parent, int i_pos, bool b_flat )
{
    PL_ASSERT_LOCKED;
    assert( p_parent != NULL && p_item != NULL );

    if( p_item == p_parent ) return i_pos;

    input_item_t *p_input = p_item->p_input;

    if( !(p_item->i_children != -1 && b_flat) )
    {
        input_item_t *p_new_input = input_item_Copy( p_input );
        if( !p_new_input ) return i_pos;

        playlist_item_t *p_new_item = NULL;
        if( p_item->i_children == -1 )
            p_new_item = playlist_NodeAddInput( p_playlist, p_new_input,
                                   p_parent, PLAYLIST_INSERT, i_pos,
                                   pl_Locked );
        else
            p_new_item = playlist_NodeCreate( p_playlist, NULL,
                                 p_parent, i_pos, 0, p_new_input );
        vlc_gc_decref( p_new_input );
        if( !p_new_item ) return i_pos;

        i_pos++;

        if( p_new_item->i_children != -1 )
            p_parent = p_new_item;
    }

    for( int i = 0; i < p_item->i_children; i++ )
    {
        if( b_flat )
            i_pos = RecursiveInsertCopy( p_playlist, p_item->pp_children[i],
                                         p_parent, i_pos, true );
        else
            RecursiveInsertCopy( p_playlist, p_item->pp_children[i],
                                 p_parent, p_parent->i_children, false );
    }

    return i_pos;
}
Exemplo n.º 20
0
Arquivo: pulse.c Projeto: 4udak/vlc
/**
 * Adds a source.
 */
static int AddSource (services_discovery_t *sd, const pa_source_info *info)
{
    services_discovery_sys_t *sys = sd->p_sys;

    msg_Dbg (sd, "adding %s (%s)", info->name, info->description);

    char *mrl;
    if (unlikely(asprintf (&mrl, "pulse://%s", info->name) == -1))
        return -1;

    input_item_t *item = input_item_NewWithType (mrl, info->description,
                                                 0, NULL, 0, -1,
                                                 ITEM_TYPE_CARD);
    free (mrl);
    if (unlikely(item == NULL))
        return -1;

    struct device *d = malloc (sizeof (*d));
    if (unlikely(d == NULL))
    {
        vlc_gc_decref (item);
        return -1;
    }
    d->index = info->index;
    d->item = item;
    d->sd = NULL;

    struct device **dp = tsearch (d, &sys->root, cmpsrc);
    if (dp == NULL) /* Out-of-memory */
    {
        DestroySource (d);
        return -1;
    }
    if (*dp != d) /* Replace existing source */
    {
        DestroySource (*dp);
        *dp = d;
    }

    const char *card = pa_proplist_gets(info->proplist, "device.product.name");
    services_discovery_AddItem (sd, item,
                                (card != NULL) ? card : N_("Generic"));
    d->sd = sd;
    return 0;
}
Exemplo n.º 21
0
/** **************************************************************************
 * \brief Add a media to the playlist
 *
 * \param id the item id
 * @todo this code must definitely be done by the ML core
 *****************************************************************************/
static void AddItemToPlaylist( int i_media_id, bool bPlay, media_library_t* p_ml,
        bool bRenew )
{

    input_item_t *p_item = ml_CreateInputItem( p_ml, i_media_id );
    if( !p_item )
    {
        msg_Dbg( p_ml, "unable to create input item for media %d",
                 i_media_id );
        return;
    }
    playlist_t *p_playlist = pl_Get( p_ml );
    playlist_item_t *p_playlist_item = NULL;

    playlist_Lock( p_playlist );
    if( !bRenew )
    {
        p_playlist_item = playlist_ItemGetByInput( p_playlist, p_item );
    }

    if( !p_playlist_item || p_playlist_item->i_id == 1 )
    {
        playlist_AddInput( p_playlist, p_item,
                           PLAYLIST_APPEND,
                           PLAYLIST_END, true, true );

        p_playlist_item = playlist_ItemGetByInput( p_playlist, p_item );
    }
    playlist_Unlock( p_playlist );

    if( !p_playlist_item || p_playlist_item->i_id == 1 )
    {
        msg_Dbg( p_ml, "could not find playlist item %s (%s:%d)",
                 p_item->psz_name, __FILE__, __LINE__ );
        return;
    }

    /* Auto play item */
    if( bPlay ) // || p_playlist->status.i_status == PLAYLIST_STOPPED )
    {
        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, false,
                          NULL, p_playlist_item );
    }
    vlc_gc_decref( p_item );
}
Exemplo n.º 22
0
Arquivo: shout.c Projeto: Kafay/vlc
/*****************************************************************************
 * AddSubitemsOfShoutItemURL:
 *****************************************************************************/
static void AddSubitemsOfShoutItemURL( services_discovery_t *p_sd,
                                       const struct shout_item_t * p_item,
                                       const char * psz_category )
{
    struct shout_category_t category = { p_sd, psz_category };

    /* Create the item */
    input_item_t *p_input = CreateInputItemFromShoutItem( p_sd, p_item );

    /* Read every subitems, and add them in ItemAdded */
    vlc_event_attach( &p_input->event_manager, vlc_InputItemSubItemAdded,
                      ItemAdded, &category );
    input_Read( p_sd, p_input, true );
    vlc_event_detach( &p_input->event_manager, vlc_InputItemSubItemAdded,
                      ItemAdded, &category );

    vlc_gc_decref( p_input );
}
Exemplo n.º 23
0
void playlist_preparser_Delete( playlist_preparser_t *p_preparser )
{
    vlc_mutex_lock( &p_preparser->lock );
    /* Remove pending item to speed up preparser thread exit */
    while( p_preparser->i_waiting > 0 )
    {
        vlc_gc_decref( p_preparser->pp_waiting[0] );
        REMOVE_ELEM( p_preparser->pp_waiting, p_preparser->i_waiting, 0 );
    }

    while( p_preparser->b_live )
        vlc_cond_wait( &p_preparser->wait, &p_preparser->lock );
    vlc_mutex_unlock( &p_preparser->lock );

    /* Destroy the item preparser */
    vlc_cond_destroy( &p_preparser->wait );
    vlc_mutex_destroy( &p_preparser->lock );
    free( p_preparser );
}
Exemplo n.º 24
0
Arquivo: item.c Projeto: BossKing/vlc
/**
 * Add a MRL into the playlist or the media library, duration and options given
 *
 * \param p_playlist the playlist to add into
 * \param psz_uri the mrl to add to the playlist
 * \param psz_name a text giving a name or description of this item
 * \param i_mode the mode used when adding
 * \param i_pos the position in the playlist where to add. If this is
 *        PLAYLIST_END the item will be added at the end of the playlist
 *        regardless of its size
 * \param i_duration length of the item in milliseconds.
 * \param i_options the number of options
 * \param ppsz_options an array of options
 * \param i_option_flags options flags
 * \param b_playlist TRUE for playlist, FALSE for media library
 * \param b_locked TRUE if the playlist is locked
 * \return VLC_SUCCESS or a VLC error code
*/
int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri,
                     const char *psz_name, int i_mode, int i_pos,
                     mtime_t i_duration,
                     int i_options, const char *const *ppsz_options,
                     unsigned i_option_flags,
                     bool b_playlist, bool b_locked )
{
    int i_ret;
    input_item_t *p_input;

    p_input = input_item_NewExt( psz_uri, psz_name, i_duration,
                                 ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN );
    if( p_input == NULL )
        return VLC_ENOMEM;
    input_item_AddOptions( p_input, i_options, ppsz_options, i_option_flags );
    i_ret = playlist_AddInput( p_playlist, p_input, i_mode, i_pos, b_playlist,
                               b_locked );
    vlc_gc_decref( p_input );
    return i_ret;
}
Exemplo n.º 25
0
Arquivo: sd.c Projeto: ToBeStrong/vlc
static void entry_item_remove( services_discovery_t *p_sd,
                               netbios_ns_entry *p_entry )
{
    services_discovery_sys_t *p_sys = p_sd->p_sys;

    for ( int i = 0; i < vlc_array_count( p_sys->p_entry_item_list ); i++ )
    {
        struct entry_item *p_entry_item;

        p_entry_item = vlc_array_item_at_index( p_sys->p_entry_item_list, i );
        if( p_entry_item->p_entry == p_entry  )
        {
            services_discovery_RemoveItem( p_sd, p_entry_item->p_item );
            vlc_gc_decref( p_entry_item->p_item );
            vlc_array_remove(  p_sys->p_entry_item_list, i );
            free( p_entry_item );
            break;
        }
    }
}
Exemplo n.º 26
0
/**************************************************************************
 * Create a new media descriptor object
 **************************************************************************/
libvlc_media_t *libvlc_media_new_location( libvlc_instance_t *p_instance,
                                           const char * psz_mrl )
{
    input_item_t * p_input_item;
    libvlc_media_t * p_md;

    p_input_item = input_item_New( psz_mrl, NULL );

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

    p_md = libvlc_media_new_from_input_item( p_instance, p_input_item );

    /* The p_input_item is retained in libvlc_media_new_from_input_item */
    vlc_gc_decref( p_input_item );

    return p_md;
}
Exemplo n.º 27
0
void EpgDialog::updateInfos()
{
    timer->stop();
    input_item_t *p_input_item = NULL;
    playlist_t *p_playlist = THEPL;
    input_thread_t *p_input_thread = playlist_CurrentInput( p_playlist ); /* w/hold */
    if( p_input_thread )
    {
        PL_LOCK; /* as input_GetItem still unfixed */
        p_input_item = input_GetItem( p_input_thread );
        if ( p_input_item ) vlc_gc_incref( p_input_item );
        PL_UNLOCK;
        vlc_object_release( p_input_thread );
        if ( p_input_item )
        {
            epg->updateEPG( p_input_item );
            vlc_gc_decref( p_input_item );
            if ( isVisible() ) timer->start();
        }
    }
}
Exemplo n.º 28
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;
}
Exemplo n.º 29
0
/**
 * This function does the preparsing and issues the art fetching requests
 */
static void *Thread( void *data )
{
    playlist_preparser_t *p_preparser = data;

    for( ;; )
    {
        input_item_t *p_current;
        input_item_meta_request_option_t i_options;

        /* */
        vlc_mutex_lock( &p_preparser->lock );
        if( p_preparser->i_waiting > 0 )
        {
            preparser_entry_t *p_entry = p_preparser->pp_waiting[0];
            p_current = p_entry->p_item;
            i_options = p_entry->i_options;
            free( p_entry );
            REMOVE_ELEM( p_preparser->pp_waiting, p_preparser->i_waiting, 0 );
        }
        else
        {
            p_current = NULL;
            p_preparser->b_live = false;
            vlc_cond_signal( &p_preparser->wait );
        }
        vlc_mutex_unlock( &p_preparser->lock );

        if( !p_current )
            break;

        Preparse( p_preparser, p_current, i_options );

        Art( p_preparser, p_current );
        vlc_gc_decref(p_current);
    }
    return NULL;
}
/** Detect dvb-utils zap channels.conf format */
int Import_DVB(vlc_object_t *obj)
{
    demux_t *demux = (demux_t *)obj;

    if (!demux_IsPathExtension(demux, ".conf" ) && !demux->b_force )
        return VLC_EGENERIC;

    /* Check if this really is a channels file */
    const uint8_t *peek;
    int len = stream_Peek(demux->s, &peek, 1023);
    if (len <= 0)
        return VLC_EGENERIC;

    const uint8_t *eol = memchr(peek, '\n', len);
    if (eol == NULL)
        return VLC_EGENERIC;
    len = eol - peek;

//    char line[len + 1];
	char *line = (char *)malloc(len + 1);			// sunqueen modify

    memcpy(line, peek, len);
    line[len] = '\0';

    input_item_t *item = ParseLine(line);
	free(line);			// sunqueen add
    if (item == NULL)
        return VLC_EGENERIC;
    vlc_gc_decref(item);

    msg_Dbg(demux, "found valid channels.conf file");
    demux->pf_control = Control;
    demux->pf_demux = Demux;

    return VLC_SUCCESS;
}