+/**
+ * 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 )