⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 item.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 3 页
字号:
 * Delete playlist item * * Remove a playlist item from the playlist, given its id * This function is to be used only by the playlist * \param p_playlist playlist object * \param i_id id of the item do delete * \return VLC_SUCCESS or an error */int playlist_DeleteFromItemId( playlist_t *p_playlist, int i_id ){    PL_ASSERT_LOCKED;    playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id,                                                    pl_Locked );    if( !p_item ) return VLC_EGENERIC;    return DeleteInner( p_playlist, p_item, true );}/*************************************************************************** * Playlist item addition ***************************************************************************//** * Playlist add * * Add an item to the playlist or the media library * \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 b_playlist TRUE for playlist, FALSE for media library * \param b_locked TRUE if the playlist is locked * \return The id of the playlist item */int playlist_Add( playlist_t *p_playlist, const char *psz_uri,                  const char *psz_name, int i_mode, int i_pos,                  bool b_playlist, bool b_locked ){    return playlist_AddExt( p_playlist, psz_uri, psz_name,                            i_mode, i_pos, -1, NULL, 0, b_playlist, b_locked );}/** * 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 ppsz_options an array of options * \param i_options the number of options * \param b_playlist TRUE for playlist, FALSE for media library * \param b_locked TRUE if the playlist is locked * \return The id of the playlist item*/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, const char *const *ppsz_options,                     int i_options, bool b_playlist, bool b_locked ){    int i_ret;    input_item_t *p_input = input_item_NewExt( p_playlist, psz_uri, psz_name,                                              i_options, ppsz_options,                                              i_duration );    i_ret = playlist_AddInput( p_playlist, p_input, i_mode, i_pos, b_playlist,                               b_locked );    int i_id = (i_ret == VLC_SUCCESS) ? p_input->i_id : -1;    vlc_gc_decref( p_input );    return i_id;}/** * Add an input item to the playlist node * * \param p_playlist the playlist to add into * \param p_input the input item to add * \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 b_playlist TRUE for playlist, FALSE for media library * \param b_locked TRUE if the playlist is locked * \return VLC_SUCCESS or VLC_ENOMEM or VLC_EGENERIC*/int playlist_AddInput( playlist_t* p_playlist, input_item_t *p_input,                       int i_mode, int i_pos, bool b_playlist,                       bool b_locked ){    playlist_item_t *p_item_cat, *p_item_one;    if( p_playlist->b_die ) return VLC_EGENERIC;    if( !p_playlist->b_doing_ml )        PL_DEBUG( "adding item `%s' ( %s )", p_input->psz_name,                                             p_input->psz_uri );    PL_LOCK_IF( !b_locked );    /* Add to ONELEVEL */    p_item_one = playlist_ItemNewFromInput( p_playlist, p_input );    if( p_item_one == NULL ) return VLC_ENOMEM;    AddItem( p_playlist, p_item_one,             b_playlist ? p_playlist->p_local_onelevel :                          p_playlist->p_ml_onelevel , i_mode, i_pos );    /* Add to CATEGORY */    p_item_cat = playlist_ItemNewFromInput( p_playlist, p_input );    if( p_item_cat == NULL ) return VLC_ENOMEM;    AddItem( p_playlist, p_item_cat,             b_playlist ? p_playlist->p_local_category :                          p_playlist->p_ml_category , i_mode, i_pos );    GoAndPreparse( p_playlist, i_mode, p_item_cat, p_item_one );    PL_UNLOCK_IF( !b_locked );    return VLC_SUCCESS;}/** * Add input * * Add an input item to p_direct_parent in the category tree, and to the * matching top category in onelevel * \param p_playlist the playlist to add into * \param p_input the input item to add * \param p_direct_parent the parent item to add into * \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_cat id of the items category * \param i_one id of the item onelevel category * \param b_locked TRUE if the playlist is locked * \return VLC_SUCCESS if success, VLC_EGENERIC if fail, VLC_ENOMEM if OOM */int playlist_BothAddInput( playlist_t *p_playlist,                           input_item_t *p_input,                           playlist_item_t *p_direct_parent,                           int i_mode, int i_pos,                           int *i_cat, int *i_one, bool b_locked ){    playlist_item_t *p_item_cat, *p_item_one, *p_up;    int i_top;    assert( p_input );    if( !vlc_object_alive( p_playlist ) )        return VLC_EGENERIC;    PL_LOCK_IF( !b_locked );    /* Add to category */    p_item_cat = playlist_ItemNewFromInput( p_playlist, p_input );    if( p_item_cat == NULL ) return VLC_ENOMEM;    AddItem( p_playlist, p_item_cat, p_direct_parent, i_mode, i_pos );    /* Add to onelevel */    /** \todo make a faster case for ml import */    p_item_one = playlist_ItemNewFromInput( p_playlist, p_input );    if( p_item_one == NULL ) return VLC_ENOMEM;    p_up = p_direct_parent;    while( p_up->p_parent != p_playlist->p_root_category )    {        p_up = p_up->p_parent;    }    for( i_top = 0 ; i_top < p_playlist->p_root_onelevel->i_children; i_top++ )    {        if( p_playlist->p_root_onelevel->pp_children[i_top]->p_input->i_id ==                             p_up->p_input->i_id )        {            AddItem( p_playlist, p_item_one,                     p_playlist->p_root_onelevel->pp_children[i_top],                     i_mode, i_pos );            break;        }    }    GoAndPreparse( p_playlist, i_mode, p_item_cat, p_item_one );    if( i_cat ) *i_cat = p_item_cat->i_id;    if( i_one ) *i_one = p_item_one->i_id;    PL_UNLOCK_IF( !b_locked );    return VLC_SUCCESS;}/** * Add an input item to a given node * * \param p_playlist the playlist to add into * \param p_input the input item to add * \param p_parent the parent item to add into * \param i_mode the mode used when addin * \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 b_locked TRUE if the playlist is locked * \return the new playlist item */playlist_item_t * playlist_NodeAddInput( playlist_t *p_playlist,                                         input_item_t *p_input,                                         playlist_item_t *p_parent,                                         int i_mode, int i_pos,                                         bool b_locked ){    playlist_item_t *p_item;    assert( p_input );    assert( p_parent && p_parent->i_children != -1 );    if( p_playlist->b_die )        return NULL;    PL_LOCK_IF( !b_locked );    p_item = playlist_ItemNewFromInput( p_playlist, p_input );    if( p_item == NULL ) return NULL;    AddItem( p_playlist, p_item, p_parent, i_mode, i_pos );    PL_UNLOCK_IF( !b_locked );    return p_item;}/***************************************************************************** * Playlist item misc operations *****************************************************************************//** * Item to node * * Transform an item to a node. Return the node in the category tree, or NULL * if not found there * This function must be entered without the playlist lock * \param p_playlist the playlist object * \param p_item the item to transform * \param b_locked TRUE if the playlist is locked * \return the item transform in a node */playlist_item_t *playlist_ItemToNode( playlist_t *p_playlist,                                      playlist_item_t *p_item,                                      bool b_locked ){    playlist_item_t *p_item_in_category;    /* What we do     * Find the input in CATEGORY.     *  - If we find it     *    - change it to node     *    - we'll return it at the end     *    - If we are a direct child of onelevel root, change to node, else     *      delete the input from ONELEVEL     *  - If we don't find it, just change to node (we are probably in VLM)     *    and return NULL     *     * If we were in ONELEVEL, we thus retrieve the node in CATEGORY (will be     * useful for later BothAddInput )     */    PL_LOCK_IF( !b_locked );    /* Fast track the media library, no time to loose */    if( p_item == p_playlist->p_ml_category ) {        PL_UNLOCK_IF( !b_locked );        return p_item;    }    /** \todo First look if we don't already have it */    p_item_in_category = playlist_ItemFindFromInputAndRoot(                                            p_playlist, p_item->p_input->i_id,                                            p_playlist->p_root_category,                                            true );    if( p_item_in_category )    {        playlist_item_t *p_item_in_one = playlist_ItemFindFromInputAndRoot(                                            p_playlist, p_item->p_input->i_id,                                            p_playlist->p_root_onelevel,                                            true );        assert( p_item_in_one );        /* We already have it, and there is nothing more to do */        ChangeToNode( p_playlist, p_item_in_category );        /* Item in one is a root, change it to node */        if( p_item_in_one->p_parent == p_playlist->p_root_onelevel )            ChangeToNode( p_playlist, p_item_in_one );        else        {            playlist_item_t *p_status_item = get_current_status_item( p_playlist );            playlist_item_t *p_status_node = get_current_status_node( p_playlist );            if( p_item_in_one == p_status_item )            {                /* We're deleting the current playlist item. Update                 * the playlist object to point at the previous item                 * so the playlist won't be restarted */                playlist_item_t *p_prev_status_item = NULL;                int i = 0;                while( i < p_status_node->i_children &&                       p_status_node->pp_children[i] != p_status_item )                {                    p_prev_status_item = p_status_node->pp_children[i];                    i++;                }                if( i == p_status_node->i_children )                    p_prev_status_item = NULL;                if( p_prev_status_item )                    set_current_status_item( p_playlist, p_prev_status_item );            }            DeleteFromInput( p_playlist, p_item_in_one->p_input->i_id,                             p_playlist->p_root_onelevel, false );        }        p_playlist->b_reset_currently_playing = true;        vlc_object_signal_unlocked( p_playlist );        var_SetInteger( p_playlist, "item-change", p_item_in_category->                                                        p_input->i_id );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -