+
+/**
+ * Add a parent to an item
+ *
+ * \param p_item the item
+ * \param i_view the view in which the parent is
+ * \param p_parent the parent to add
+ * \return nothing
+ */
+int playlist_ItemAddParent( playlist_item_t *p_item, int i_view,
+ playlist_item_t *p_parent )
+{
+ vlc_bool_t b_found = VLC_FALSE;
+ int i;
+
+ for( i= 0; i< p_item->i_parents ; i++ )
+ {
+ if( p_item->pp_parents[i]->i_view == i_view )
+
+ {
+ b_found = VLC_TRUE;
+ break;
+ }
+ }
+ if( b_found == VLC_FALSE )
+ {
+
+ struct item_parent_t *p_ip = (struct item_parent_t *)
+ malloc(sizeof(struct item_parent_t) );
+ p_ip->i_view = i_view;
+ p_ip->p_parent = p_parent;
+
+ INSERT_ELEM( p_item->pp_parents,
+ p_item->i_parents, p_item->i_parents,
+ p_ip );
+ }
+ return VLC_SUCCESS;
+}
+
+/**
+ * Copy all parents from parent to child
+ */
+int playlist_CopyParents( playlist_item_t *p_parent,
+ playlist_item_t *p_child )
+{
+ int i=0;
+ for( i= 0 ; i< p_parent->i_parents; i ++ )
+ {
+ playlist_ItemAddParent( p_child,
+ p_parent->pp_parents[i]->i_view,
+ p_parent );
+ }
+ return VLC_SUCCESS;
+}
+
+
+/**********************************************************************
+ * playlist_item_t structure accessors
+ * These functions give access to the fields of the playlist_item_t
+ * structure
+ **********************************************************************/
+
+
+/**
+ * Set the name of a playlist item
+ *
+ * \param p_item the item
+ * \param psz_name the new name
+ * \return VLC_SUCCESS on success, VLC_EGENERIC on failure
+ */
+int playlist_ItemSetName( playlist_item_t *p_item, char *psz_name )
+{
+ if( psz_name && p_item )
+ {
+ if( p_item->input.psz_name ) free( p_item->input.psz_name );
+ p_item->input.psz_name = strdup( psz_name );
+ return VLC_SUCCESS;
+ }
+ return VLC_EGENERIC;
+}
+
+/**
+ * Set the duration of a playlist item
+ * This function must be entered with the item lock
+ *
+ * \param p_item the item
+ * \param i_duration the new duration
+ * \return VLC_SUCCESS on success, VLC_EGENERIC on failure
+ */
+int playlist_ItemSetDuration( playlist_item_t *p_item, mtime_t i_duration )
+{
+ char psz_buffer[MSTRTIME_MAX_SIZE];
+ if( p_item )
+ {
+ p_item->input.i_duration = i_duration;
+ if( i_duration != -1 )
+ {
+ secstotimestr( psz_buffer, (int)(i_duration/1000000) );
+ }
+ else
+ {
+ memcpy( psz_buffer, "--:--:--", sizeof("--:--:--") );
+ }
+ vlc_input_item_AddInfo( &p_item->input, _("General") , _("Duration"),
+ "%s", psz_buffer );
+
+ return VLC_SUCCESS;
+ }
+ return VLC_EGENERIC;
+}
+
+/*
+ * Guess the type of the item using the beginning of the mrl */
+static void GuessType( input_item_t *p_item)
+{
+ int i;
+ static struct { char *psz_search; int i_type; } types_array[] =
+ {
+ { "http", ITEM_TYPE_NET },
+ { "dvd", ITEM_TYPE_DISC },
+ { "cdda", ITEM_TYPE_CDDA },
+ { "mms", ITEM_TYPE_NET },
+ { "rtsp", ITEM_TYPE_NET },
+ { "udp", ITEM_TYPE_NET },
+ { "rtp", ITEM_TYPE_NET },
+ { "vcd", ITEM_TYPE_DISC },
+ { "v4l", ITEM_TYPE_CARD },
+ { "dshow", ITEM_TYPE_CARD },
+ { "pvr", ITEM_TYPE_CARD },
+ { "dvb", ITEM_TYPE_CARD },
+ { "qpsk", ITEM_TYPE_CARD },
+ { "sdp", ITEM_TYPE_NET },
+ { NULL, 0 }
+ };
+
+#if 0 /* Unused */
+ static struct { char *psz_search; int i_type; } exts_array[] =
+ {
+ { "mp3", ITEM_TYPE_AFILE },
+ { NULL, 0 }
+ };
+#endif
+
+ for( i = 0; types_array[i].psz_search != NULL; i++ )
+ {
+ if( !strncmp( p_item->psz_uri, types_array[i].psz_search,
+ strlen( types_array[i].psz_search ) ) )
+ {
+ p_item->i_type = types_array[i].i_type;
+ return;
+ }
+ }
+ p_item->i_type = ITEM_TYPE_VFILE;
+}