+ /* Check if we already know this item */
+ for( i = 0 ; i< p_intf->p_sys->i_announces ; i++ )
+ {
+ if( !strcmp( p_intf->p_sys->pp_announces[i]->psz_uri,
+ psz_item_uri ) )
+ {
+ p_intf->p_sys->pp_announces[i]->i_last = mdate();
+
+ /* Check if the name changed */
+ if( strcmp( p_intf->p_sys->pp_announces[i]->psz_name,
+ p_sd->psz_sessionname ) )
+ {
+ playlist_item_t *p_item;
+ p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+
+ msg_Dbg(p_intf, "Name changed (%s -> %s) for %s",
+ p_intf->p_sys->pp_announces[i]->psz_name,
+ p_sd->psz_sessionname,
+ psz_item_uri );
+
+ p_item = playlist_ItemGetById( p_playlist,
+ p_intf->p_sys->pp_announces[i]->i_id );
+
+ /* Change the name in the item */
+ if( p_item->input.psz_name )
+ free( p_item->input.psz_name );
+ p_item->input.psz_name = strdup( p_sd->psz_sessionname);
+
+ /* Update the stored name */
+ if( p_intf->p_sys->pp_announces[i]->psz_name )
+ free( p_intf->p_sys->pp_announces[i]->psz_name );
+ p_intf->p_sys->pp_announces[i]->psz_name =
+ strdup( p_sd->psz_sessionname );
+
+ vlc_object_release( p_playlist );
+ }
+ free( psz_item_uri );
+ return;
+ }
+ }
+
+ /* Add the item in the playlist */
+ p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ i_id = playlist_Add ( p_playlist, psz_item_uri ,
+ p_sd->psz_sessionname,
+ PLAYLIST_CHECK_INSERT, PLAYLIST_END );
+ p_item = playlist_ItemGetById( p_playlist, i_id );
+ if( p_item )
+ {
+ vlc_mutex_lock( &p_item->input.lock );
+ playlist_ItemSetGroup( p_item, i_group );
+ vlc_mutex_unlock( &p_item->input.lock );
+ }
+
+ /* Then remember it */
+ p_announce = (struct sap_announce_t *)malloc(
+ sizeof(struct sap_announce_t) );
+ if( p_sd->psz_sessionname )
+ {
+ p_announce->psz_name = strdup( p_sd->psz_sessionname );
+ }
+ else
+ {
+ p_announce->psz_name = strdup( "" );
+ }
+ if( psz_item_uri )
+ {
+ p_announce->psz_uri = strdup( psz_item_uri );
+ }
+ else
+ {
+ p_announce->psz_uri = strdup( "" );
+ }
+ p_announce->i_id = i_id;
+
+ p_announce->i_last = mdate();
+
+ vlc_object_release( p_playlist );
+
+ INSERT_ELEM( p_intf->p_sys->pp_announces,
+ p_intf->p_sys->i_announces,
+ p_intf->p_sys->i_announces,
+ p_announce );
+ free( psz_item_uri );
+ }
+}