+/**
+ * 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 );
+
+ if( !b_locked ) PL_LOCK;
+
+ /* 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 );
+
+ if( !b_locked ) PL_UNLOCK;
+ return VLC_SUCCESS;