From: Gildas Bazin Date: Wed, 31 Mar 2004 20:52:31 +0000 (+0000) Subject: * src/input/control.c: added INPUT_ADD_INFO/INPUT_SET_NAME to input_Control(). X-Git-Tag: 0.7.2~537 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=562ab59b24114e526144b59b5967224de432412a;hp=d79a68397146126b899966f9e7816e063ec270c1;p=vlc * src/input/control.c: added INPUT_ADD_INFO/INPUT_SET_NAME to input_Control(). * src/input/input.c: + introduced input_item_t that is shared between the playlist/vlm and the input thread (contains input name, options, infos, etc...). + changed prototype of input_CreateThread() to input_thread_t *input_CreateThread( vlc_object_t *, input_item_t * ). * ALL: use input_item_t and INPUT_ADD_INFO when necessary. --- diff --git a/Makefile.am b/Makefile.am index 3c053b4df2..99addfe7e9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -333,7 +333,6 @@ SOURCES_libvlc_common = \ src/input/input_dec.c \ src/input/input_programs.c \ src/input/input_clock.c \ - src/input/input_info.c \ src/video_output/video_output.c \ src/video_output/vout_pictures.c \ src/video_output/vout_pictures.h \ diff --git a/include/input_ext-intf.h b/include/input_ext-intf.h index 09b32b2bbc..1944abb2d2 100644 --- a/include/input_ext-intf.h +++ b/include/input_ext-intf.h @@ -153,57 +153,8 @@ struct input_area_t off_t i_plugin_data; }; -/** - * \brief A list of info items. - * - * Composes a linked list of name/value pairs intended to inform the - * user about the current stream - * \see input_AddInfo - */ -struct input_info_t { - /** - * Name of this item - */ - char * psz_name; - - /** - * Value of this item - */ - char * psz_value; - - /** - * Pointer to next item in list, or NULL it at end of list - */ - input_info_t * p_next; -}; - -/** - * \brief A list of info categories. - * - * Composes a NULL terminated linked list of categories in which to - * place info about the stream. - * - * \see input_InfoCategory - */ -struct input_info_category_t { - /** - * The name of this category - */ - char * psz_name; - - /** - * first element of a linked list containing info items - */ - input_info_t * p_info; - - /** - * Pointer to next element in this list, or NULL if at end of list - */ - input_info_category_t * p_next; -}; - /***************************************************************************** -* stream_descriptor_t + * stream_descriptor_t ***************************************************************************** * Describes a stream and list its associated programs. Build upon * the information carried in program association sections (for instance) @@ -262,9 +213,6 @@ struct stream_descriptor_t /* Optional stream output */ sout_instance_t * p_sout; - /* Input info */ - input_info_category_t * p_info; - /* Statistics */ count_t c_packets_read; /* packets read */ count_t c_packets_trashed; /* trashed packets */ @@ -286,6 +234,53 @@ struct stream_position_t #define MUTE_NO_CHANGE -1 +/***************************************************************************** + * info_t + *****************************************************************************/ + +/** + * Info item + */ + +struct info_t +{ + char *psz_name; /**< Name of this info */ + char *psz_value; /**< Value of the info */ +}; + +/** + * Info category + * \see info_t + */ +struct info_category_t +{ + char *psz_name; /**< Name of this category */ + int i_infos; /**< Number of infos in the category */ + struct info_t **pp_infos; /**< Pointer to an array of infos */ +}; + +/***************************************************************************** + * input_item_t + ***************************************************************************** + * Describes an input and is used to spawn input_thread_t objects. + *****************************************************************************/ +struct input_item_t +{ + char *psz_name; /**< text describing this item */ + char *psz_uri; /**< mrl of this item */ + + int i_options; /**< Number of input options */ + char **ppsz_options; /**< Array of input options */ + + mtime_t i_duration; /**< A hint about the duration of this + * item, in milliseconds*/ + + int i_categories; /**< Number of info categories */ + info_category_t **pp_categories; /**< Pointer to the first info category */ + + vlc_mutex_t lock; /**< Item cannot be changed without this lock */ +}; + /***************************************************************************** * input_thread_t ***************************************************************************** @@ -335,6 +330,9 @@ struct input_thread_t /* General stream description */ stream_descriptor_t stream; + /* Input item description */ + input_item_t *p_item; + /* Playlist item */ char * psz_source; char * psz_dupsource; @@ -388,8 +386,8 @@ struct input_thread_t /***************************************************************************** * Prototypes *****************************************************************************/ -#define input_CreateThread(a,b,c,d) __input_CreateThread(VLC_OBJECT(a),b,c,d) -VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, char *psz_uri, char **ppsz_options, int i_options ) ); +#define input_CreateThread(a,b) __input_CreateThread(VLC_OBJECT(a),b) +VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, input_item_t * ) ); VLC_EXPORT( void, input_StopThread, ( input_thread_t * ) ); VLC_EXPORT( void, input_DestroyThread, ( input_thread_t * ) ); diff --git a/include/input_ext-plugins.h b/include/input_ext-plugins.h index 57dc3d40da..07a6d67629 100644 --- a/include/input_ext-plugins.h +++ b/include/input_ext-plugins.h @@ -82,13 +82,6 @@ VLC_EXPORT( int, input_ClockManageControl, ( input_thread_t *, pgrm_descriptor_ VLC_EXPORT( void, input_ClockManageRef, ( input_thread_t *, pgrm_descriptor_t *, mtime_t ) ); VLC_EXPORT( mtime_t, input_ClockGetTS, ( input_thread_t *, pgrm_descriptor_t *, mtime_t ) ); -/***************************************************************************** - * Prototypes from input_info.c - *****************************************************************************/ -VLC_EXPORT( input_info_category_t *, input_InfoCategory, ( input_thread_t *, char * ) ); -VLC_EXPORT( int, input_AddInfo, ( input_info_category_t *, char *, char *, ... ) ); -int input_DelInfo( input_thread_t * p_input ); /* no need to export this */ - /***************************************************************************** * Prototypes from input_ext-plugins.h (buffers management) *****************************************************************************/ diff --git a/include/ninput.h b/include/ninput.h index 0b2f2737a9..d64fb730ac 100644 --- a/include/ninput.h +++ b/include/ninput.h @@ -386,6 +386,12 @@ enum input_query_e INPUT_DEL_BOOKMARK, /* arg1= seekpoint_t * res=can fail */ INPUT_SET_BOOKMARK, /* arg1= int res=can fail */ + INPUT_ADD_OPTION, /* arg1= char * arg2= char * res=can fail */ + + INPUT_ADD_INFO, /* arg1= char * arg2= char * arg3=... res=can fail */ + + INPUT_SET_NAME, /* arg1= char * res=can fail */ + INPUT_GET_SUBDELAY, /* arg1 = int* res=can fail */ INPUT_SET_SUBDELAY, /* arg1 = int res=can fail */ diff --git a/include/vlc/intf.h b/include/vlc/intf.h index 356408cda0..1c254d4629 100644 --- a/include/vlc/intf.h +++ b/include/vlc/intf.h @@ -2,7 +2,7 @@ * intf.h: interface header for vlc ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: intf.h,v 1.4 2004/01/25 18:17:08 zorglub Exp $ + * $Id$ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,9 +36,9 @@ extern "C" { *****************************************************************************/ #include "vlc_interface.h" #include "intf_eject.h" -#include "vlc_playlist.h" #include "stream_control.h" #include "input_ext-intf.h" +#include "vlc_playlist.h" # ifdef __cplusplus } diff --git a/include/vlc_common.h b/include/vlc_common.h index ff844e7150..0d32ea6a88 100644 --- a/include/vlc_common.h +++ b/include/vlc_common.h @@ -192,8 +192,6 @@ typedef struct msg_subscription_t msg_subscription_t; typedef struct playlist_t playlist_t; typedef struct playlist_item_t playlist_item_t; typedef struct playlist_group_t playlist_group_t; -typedef struct item_info_t item_info_t; -typedef struct item_info_category_t item_info_category_t; typedef struct playlist_export_t playlist_export_t; /* Modules */ @@ -212,11 +210,10 @@ typedef struct intf_channel_t intf_channel_t; /* Input */ typedef struct input_thread_t input_thread_t; typedef struct input_thread_sys_t input_thread_sys_t; +typedef struct input_item_t input_item_t; typedef struct input_area_t input_area_t; typedef struct input_buffers_t input_buffers_t; typedef struct input_socket_t input_socket_t; -typedef struct input_info_t input_info_t; -typedef struct input_info_category_t input_info_category_t; typedef struct access_sys_t access_sys_t; typedef struct demux_sys_t demux_sys_t; typedef struct es_descriptor_t es_descriptor_t; @@ -225,6 +222,8 @@ typedef struct pgrm_descriptor_t pgrm_descriptor_t; typedef struct pgrm_sys_t pgrm_sys_t; typedef struct stream_descriptor_t stream_descriptor_t; typedef struct seekpoint_t seekpoint_t; +typedef struct info_t info_t; +typedef struct info_category_t info_category_t; /* Format */ typedef struct audio_format_t audio_format_t; diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h index bf7593fd50..808f3d4085 100644 --- a/include/vlc_playlist.h +++ b/include/vlc_playlist.h @@ -2,7 +2,7 @@ * vlc_playlist.h : Playlist functions ***************************************************************************** * Copyright (C) 1999-2004 VideoLAN - * $Id: vlc_playlist.h,v 1.27 2004/01/29 17:51:07 zorglub Exp $ + * $Id$ * * Authors: Samuel Hocevar * @@ -33,29 +33,6 @@ * @{ */ -/** - * Playlist info item - * \see playlist_item_t - */ - -struct item_info_t -{ - char * psz_name; /**< Name of this info */ - char * psz_value; /**< Value of the info */ -}; - -/** - * playlist item info category - * \see playlist_item_t - * \see item_info_t - */ -struct item_info_category_t -{ - char * psz_name; /**< Name of this category */ - int i_infos; /**< Number of infos in the category */ - item_info_t **pp_infos; /**< Pointer to an array of infos */ -}; - /** * playlist export helper structure */ @@ -71,15 +48,8 @@ struct playlist_export_t */ struct playlist_item_t { - char * psz_name; /**< text describing this item */ - char * psz_uri; /**< mrl of this item */ - mtime_t i_duration; /**< A hint about the duration of this - * item, in milliseconds*/ - int i_categories; /**< Number of info categories */ - item_info_category_t ** - pp_categories; /**< Pointer to the first info category */ - int i_options; /**< Number of options */ - char ** ppsz_options; /**< Array of options */ + input_item_t input; /**< input item descriptor */ + int i_nb_played; /**< How many times was this item played ? */ vlc_bool_t b_autodeletion; /**< Indicates whther this item is to * be deleted after playback. True mean @@ -89,7 +59,6 @@ struct playlist_item_t * played or skipped */ int i_group; /**< Which group does this item belongs to ? */ int i_id; /**< Unique id to track this item */ - vlc_mutex_t lock; /**< Item cannot be changed without this lock */ }; /** @@ -211,17 +180,14 @@ VLC_EXPORT( int, playlist_GroupToId, (playlist_t *, char * ) ); VLC_EXPORT( char * , playlist_GetInfo, ( playlist_t * , int, const char *, const char *) ); VLC_EXPORT( char * , playlist_ItemGetInfo, ( playlist_item_t * , const char *, const char *) ); -VLC_EXPORT( item_info_category_t*, playlist_GetCategory, ( playlist_t *, int, const char *) ); -VLC_EXPORT( item_info_category_t*, playlist_ItemGetCategory, ( playlist_item_t *, const char *) ); +VLC_EXPORT( info_category_t*, playlist_ItemGetCategory, ( playlist_item_t *, const char *) ); -VLC_EXPORT( item_info_category_t*, playlist_CreateCategory, ( playlist_t *, int, const char *) ); -VLC_EXPORT( item_info_category_t*, playlist_ItemCreateCategory, ( playlist_item_t *, const char *) ); +VLC_EXPORT( info_category_t*, playlist_ItemCreateCategory, ( playlist_item_t *, const char *) ); VLC_EXPORT( int, playlist_AddInfo, (playlist_t *, int, const char * , const char *, const char *, ...) ); VLC_EXPORT( int, playlist_ItemAddInfo, (playlist_item_t *, const char * , const char *, const char *, ...) ); /* Option functions */ -VLC_EXPORT( int, playlist_AddOption, (playlist_t *, int, const char *) ); VLC_EXPORT( int, playlist_ItemAddOption, (playlist_item_t *, const char *) ); /* Playlist sorting */ diff --git a/include/vlc_vlm.h b/include/vlc_vlm.h index ba4f2d5d1f..1e7fa244d1 100644 --- a/include/vlc_vlm.h +++ b/include/vlc_vlm.h @@ -55,8 +55,7 @@ typedef struct char **option; /* global options for all inputs */ - char **input_option; - int i_input_option; + input_item_t item; input_thread_t *p_input; } vlm_media_t; diff --git a/modules/access/cdda/access.c b/modules/access/cdda/access.c index fa573c7acc..13aff10294 100644 --- a/modules/access/cdda/access.c +++ b/modules/access/cdda/access.c @@ -352,55 +352,44 @@ CDDAUpdateVar( input_thread_t *p_input, int i_num, int i_action, } #endif -#define meta_info_add_str(title, str) \ - if ( str ) { \ - dbg_print( INPUT_DBG_META, "field %s: %s\n", title, str); \ - input_AddInfo( p_cat, _(title), "%s", str ); \ - vlc_mutex_lock( &p_playlist->object_lock ); \ - p_item = playlist_ItemGetByPos( p_playlist, -1 ); \ - vlc_mutex_unlock( &p_playlist->object_lock ); \ - vlc_mutex_lock( &p_item->lock ); \ - playlist_ItemAddInfo( p_item, p_cat->psz_name, \ - _(title), "%s" , str ); \ - vlc_mutex_unlock( &p_item->lock ); \ - } - - static void InformationCreate( input_thread_t *p_input ) { cdda_data_t *p_cdda = (cdda_data_t *) p_input->p_access_data; - playlist_t *p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, - FIND_PARENT ); - input_info_category_t *p_cat; - - p_cat = input_InfoCategory( p_input, "General" ); - #ifdef HAVE_LIBCDDB if (p_cdda->i_cddb_enabled) { - playlist_item_t *p_item; - - meta_info_add_str( "Title", p_cdda->cddb.disc->title ); - meta_info_add_str( "Artist", p_cdda->cddb.disc->artist ); - meta_info_add_str( "Genre", p_cdda->cddb.disc->genre ); - meta_info_add_str( "Extended Data", p_cdda->cddb.disc->ext_data ); - { - char year[5]; - if (p_cdda->cddb.disc->year != 0) { - snprintf(year, 5, "%d", p_cdda->cddb.disc->year); - meta_info_add_str( "Year", year ); - } - if ( p_cdda->cddb.disc->discid ) { - input_AddInfo( p_cat, _("CDDB Disc ID"), "%x", - p_cdda->cddb.disc->discid ); - } - - if ( p_cdda->cddb.disc->category != CDDB_CAT_INVALID ) { - input_AddInfo( p_cat, _("CDDB Disc Category"), "%s", - CDDB_CATEGORY[p_cdda->cddb.disc->category] ); - } - } + dbg_print( INPUT_DBG_META, "field %s: %s\n", "Title", + p_cdda->cddb.disc->title ); + input_Control( p_input, INPUT_ADD_INFO, _("General"), _("Title"), + "%s", p_cdda->cddb.disc->title ); + + dbg_print( INPUT_DBG_META, "field %s: %s\n", "Artist", + p_cdda->cddb.disc->artist ); + input_Control( p_input, INPUT_ADD_INFO, _("General"), _("Artist"), + "%s", p_cdda->cddb.disc->artist ); + + dbg_print( INPUT_DBG_META, "field %s: %s\n", "Genre", + p_cdda->cddb.disc->genre ); + input_Control( p_input, INPUT_ADD_INFO, _("General"), _("Genre"), + "%s", p_cdda->cddb.disc->genre ); + + dbg_print( INPUT_DBG_META, "field %s: %s\n", "Extended Data", + p_cdda->cddb.disc->ext_data ); + input_Control( p_input, INPUT_ADD_INFO, _("General"), _("Extended Data"), + "%s", p_cdda->cddb.disc->ext_data ); + + if (p_cdda->cddb.disc->year != 0) + input_Control( p_input, INPUT_ADD_INFO, _("General"), + _("Year"), "%d", p_cdda->cddb.disc->year ); + if ( p_cdda->cddb.disc->discid ) + input_Control( p_input, INPUT_ADD_INFO, _("General"), + _("CDDB Disc ID"), "%x", p_cdda->cddb.disc->discid ); + + if ( p_cdda->cddb.disc->category != CDDB_CAT_INVALID ) + input_Control( p_input, INPUT_ADD_INFO, _("General"), + _("CDDB Disc Category"), "%s", + CDDB_CATEGORY[p_cdda->cddb.disc->category] ); } #endif /*HAVE_LIBCDDB*/ @@ -414,40 +403,40 @@ static void InformationCreate( input_thread_t *p_input ) / CDIO_CD_FRAMES_PER_SEC; dbg_print( INPUT_DBG_META, "Duration %ld", (long int) i_duration ); - input_AddInfo( p_cat, _("Duration"), "%s", - secstotimestr( psz_buffer, i_duration ) ); + input_Control( p_input, INPUT_ADD_INFO, _("General"), _("Duration"), "%s", + secstotimestr( psz_buffer, i_duration ) ); for( i_track = 0 ; i_track < p_cdda->i_nb_tracks ; i_track++ ) { char track_str[TITLE_MAX]; mtime_t i_duration = - (p_cdda->p_sectors[i_track+1] - p_cdda->p_sectors[i_track]) - / CDIO_CD_FRAMES_PER_SEC; + (p_cdda->p_sectors[i_track+1] - p_cdda->p_sectors[i_track]) + / CDIO_CD_FRAMES_PER_SEC; snprintf(track_str, TITLE_MAX, "%s %02d", _("Track"), i_track+1); - p_cat = input_InfoCategory( p_input, track_str ); - input_AddInfo( p_cat, _("Duration"), "%s", - secstotimestr( psz_buffer, i_duration ) ); + input_Control( p_input, INPUT_ADD_INFO, track_str, _("Duration"), "%s", + secstotimestr( psz_buffer, i_duration ) ); #ifdef HAVE_LIBCDDB if (p_cdda->i_cddb_enabled) { cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc, i_track); if (t != NULL) { - if ( t->artist != NULL && strlen(t->artist) ) { - input_AddInfo( p_cat, _("Artist"), "%s", t->artist ); - } - if ( t->title != NULL && strlen(t->title) ) { - input_AddInfo( p_cat, _("Title"), "%s", t->title ); - } - if ( t->ext_data != NULL && strlen(t->ext_data) ) { - input_AddInfo( p_cat, _("Extended Data"), "%s", t->ext_data ); - } - } + if ( t->artist != NULL && strlen(t->artist) ) { + input_Control( p_input, INPUT_ADD_INFO, track_str, + _("Artist"), "%s", t->artist ); + } + if ( t->title != NULL && strlen(t->title) ) { + input_Control( p_input, INPUT_ADD_INFO, track_str, + _("Title"), "%s", t->title ); + } + if ( t->ext_data != NULL && strlen(t->ext_data) ) { + input_Control( p_input, INPUT_ADD_INFO, track_str, + _("Extended Data"), "%s", t->ext_data ); + } + } } #endif } } - - if( p_playlist ) vlc_object_release( p_playlist ); } @@ -759,7 +748,7 @@ CDDACreatePlayListItem(const input_thread_t *p_input, cdda_data_t *p_cdda, if( !p_item ) return; - vlc_mutex_lock( &p_item->lock ); + vlc_mutex_lock( &p_item->input.lock ); p_author = CDDAFormatStr( p_input, p_cdda, @@ -804,7 +793,7 @@ CDDACreatePlayListItem(const input_thread_t *p_input, cdda_data_t *p_cdda, } #endif /*HAVE_LIBCDDB*/ - vlc_mutex_unlock( &p_item->lock ); + vlc_mutex_unlock( &p_item->input.lock ); } static int diff --git a/modules/access/slp.c b/modules/access/slp.c index 0e5dd6dd1f..7d064877e8 100644 --- a/modules/access/slp.c +++ b/modules/access/slp.c @@ -2,7 +2,7 @@ * slp.c: SLP access plugin ***************************************************************************** * Copyright (C) 2002-2004 VideoLAN - * $Id: slp.c,v 1.20 2004/01/25 17:31:22 gbazin Exp $ + * $Id$ * * Authors: Loïc Minier * @@ -132,7 +132,10 @@ static SLPBoolean AttrCallback( SLPHandle slph_slp, return SLP_TRUE; } - p_playlist_item->psz_name = strdup(psz_attrlist); /* NULL is checked */ + if( p_playlist_item->input.psz_name ) + free( p_playlist_item->input.psz_name ); + + p_playlist_item->input.psz_name = strdup(psz_attrlist); /* NULL is checked */ return SLP_TRUE; } @@ -145,7 +148,7 @@ static SLPBoolean SrvUrlCallback( SLPHandle slph_slp, SLPError slpe_errcode, void * p_cookie ) { - input_thread_t * p_input = (input_thread_t *)p_cookie; + input_thread_t *p_input = (input_thread_t *)p_cookie; playlist_t * p_playlist; char psz_item[42] = ""; //"udp:@"; char * psz_s; /* to hold the uri of the stream */ @@ -159,7 +162,7 @@ static SLPBoolean SrvUrlCallback( SLPHandle slph_slp, return SLP_TRUE; } - msg_Dbg(p_input,"URL: %s",psz_srvurl); + msg_Dbg( p_input,"URL: %s", psz_srvurl ); /* or there was a problem with getting the data we requested */ if( (slpe_errcode != SLP_OK) ) @@ -173,7 +176,7 @@ static SLPBoolean SrvUrlCallback( SLPHandle slph_slp, psz_s = strstr( psz_srvurl, "//" ); if( psz_s == NULL ) { - msg_Err( (input_thread_t *)p_input, + msg_Err( p_input, "SrvUrlCallback got a strange string of your libslp" ); return SLP_TRUE; } @@ -185,17 +188,13 @@ static SLPBoolean SrvUrlCallback( SLPHandle slph_slp, sizeof(psz_item) - strlen(psz_item) - 1 ); /* create a playlist item */ - p_playlist_item = malloc( sizeof( playlist_item_t ) ); - memset( p_playlist_item, 0, sizeof( playlist_item_t ) ); + p_playlist_item = playlist_ItemNew( p_input, psz_s, NULL ); if( p_playlist_item == NULL ) { msg_Err( p_input, "out of memory" ); return SLP_TRUE; } - p_playlist_item->psz_name = NULL; - p_playlist_item->psz_uri = strdup( psz_s ); - p_playlist_item->i_duration = -1; p_playlist_item->i_group = i_group; p_playlist_item->b_enabled = VLC_TRUE; @@ -217,32 +216,21 @@ static SLPBoolean SrvUrlCallback( SLPHandle slph_slp, SLPClose( slph_slp3 ); } - /* add a default name if we found no attribute */ - if( p_playlist_item->psz_name == NULL ) - { - p_playlist_item->psz_name = strdup( psz_s ); - } - /* search the main playlist object */ - p_playlist = vlc_object_find( (input_thread_t *)p_input, - VLC_OBJECT_PLAYLIST, + p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) { - msg_Warn( (input_thread_t *)p_input, - "could not find playlist, not adding entries" ); + msg_Warn( p_input, "could not find playlist, not adding entries" ); return SLP_TRUE; } - playlist_AddItem( p_playlist, - p_playlist_item, - PLAYLIST_APPEND, - PLAYLIST_END ); - vlc_object_release( (vlc_object_t *)p_playlist ); + playlist_AddItem( p_playlist, p_playlist_item, + PLAYLIST_APPEND, PLAYLIST_END ); + vlc_object_release( p_playlist ); - msg_Info( (input_thread_t *)p_input, - "added « %s » (lifetime %i) to playlist", - psz_srvurl, i_lifetime ); + msg_Info( p_input, "added « %s » (lifetime %i) to playlist", + psz_srvurl, i_lifetime ); return SLP_TRUE; } diff --git a/modules/codec/mpeg_audio.c b/modules/codec/mpeg_audio.c index 9af3348b3e..56fbe3a435 100644 --- a/modules/codec/mpeg_audio.c +++ b/modules/codec/mpeg_audio.c @@ -28,7 +28,6 @@ * Preamble *****************************************************************************/ #include -#include /* for input infos */ #include #include @@ -464,35 +463,11 @@ static uint8_t *GetOutBuffer( decoder_t *p_dec, void **pp_out_buffer ) if( p_dec->fmt_out.audio.i_rate != p_sys->i_rate ) { -#define TITLE_MAX 30 - input_info_category_t *p_cat; - char psz_streamid[TITLE_MAX]; - int i_es_id = p_dec->fmt_out.i_id; - input_thread_t * p_input = vlc_object_find( p_dec, VLC_OBJECT_INPUT, FIND_PARENT ); + msg_Info( p_dec, "MPGA channels:%d samplerate:%d bitrate:%d", + p_sys->i_channels, p_sys->i_rate, p_sys->i_bit_rate ); - if( p_input ) - { - snprintf(psz_streamid, TITLE_MAX, "%s%04x", _("Stream "), i_es_id); - p_cat = input_InfoCategory( p_input, psz_streamid ); - -#if 1 - /* We should be finding this stream, but we aren't. */ - input_AddInfo( p_cat, _("Type"), "%s", _("audio") ); - input_AddInfo( p_cat, _("Description"), "%s", _("MPEG audio") ); -#endif - - input_AddInfo( p_cat, _("Sample Rate"), "%d", p_sys->i_rate ); - input_AddInfo( p_cat, _("Bit Rate"), "%d", p_sys->i_bit_rate ); - input_AddInfo( p_cat, _("Channel(s)"), "%d", p_sys->i_channels ); - - msg_Info( p_dec, "MPGA channels:%d samplerate:%d bitrate:%d", - p_sys->i_channels, p_sys->i_rate, p_sys->i_bit_rate ); - - aout_DateInit( &p_sys->end_date, p_sys->i_rate ); - aout_DateSet( &p_sys->end_date, p_sys->i_pts ); - - vlc_object_release( p_input ); - } + aout_DateInit( &p_sys->end_date, p_sys->i_rate ); + aout_DateSet( &p_sys->end_date, p_sys->i_pts ); } p_dec->fmt_out.audio.i_rate = p_sys->i_rate; diff --git a/modules/codec/speex.c b/modules/codec/speex.c index 1a6dffb6e6..f201863c45 100755 --- a/modules/codec/speex.c +++ b/modules/codec/speex.c @@ -2,9 +2,9 @@ * speex.c: speex decoder/packetizer/encoder module making use of libspeex. ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: speex.c,v 1.13 2004/02/22 15:57:41 fenrir Exp $ + * $Id$ * - * Authors: Gildas Bazin + * Authors: Gildas Bazin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,8 +26,6 @@ *****************************************************************************/ #include #include -#include -#include "vlc_playlist.h" #include #include @@ -461,32 +459,15 @@ static void ParseSpeexComments( decoder_t *p_dec, ogg_packet *p_oggpacket ) input_thread_t *p_input = (input_thread_t *)p_dec->p_parent; decoder_sys_t *p_sys = p_dec->p_sys; - input_info_category_t *p_cat = - input_InfoCategory( p_input, _("Speex comment") ); - playlist_t *p_playlist = vlc_object_find( p_dec, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - playlist_item_t *p_item; - char *p_buf = (char *)p_oggpacket->packet; SpeexMode *p_mode; int i_len; p_mode = speex_mode_list[p_sys->p_header->mode]; - input_AddInfo( p_cat, _("Mode"), "%s%s", - p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" ); - vlc_mutex_lock( &p_playlist->object_lock ); - p_item = playlist_ItemGetByPos( p_playlist, -1 ); - vlc_mutex_unlock( &p_playlist->object_lock ); - if( !p_item) - { - msg_Err(p_dec, "unable to find item" ); - return; - } - vlc_mutex_lock( &p_item->lock ); - - playlist_ItemAddInfo( p_item, _("Speex comment") , _("Mode"),"%s%s", - p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" ); + input_Control( p_input, INPUT_ADD_INFO, _("Speex comment"), _("Mode"), + "%s%s", p_mode->modeName, + p_sys->p_header->vbr ? " VBR" : "" ); if( p_oggpacket->bytes < 8 ) { @@ -501,12 +482,7 @@ static void ParseSpeexComments( decoder_t *p_dec, ogg_packet *p_oggpacket ) return; } - input_AddInfo( p_cat, p_buf, "" ); - playlist_ItemAddInfo( p_item , _("Speex comment") , p_buf , "" ); - - vlc_mutex_unlock( &p_item->lock ); - - if( p_playlist ) vlc_object_release( p_playlist ); + input_Control( p_input, INPUT_ADD_INFO, _("Speex comment"), p_buf, "" ); /* TODO: finish comments parsing */ } diff --git a/modules/codec/theora.c b/modules/codec/theora.c index ad633c96ce..2e578cb7a6 100644 --- a/modules/codec/theora.c +++ b/modules/codec/theora.c @@ -2,9 +2,9 @@ * theora.c: theora decoder module making use of libtheora. ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: theora.c,v 1.24 2004/01/29 17:51:07 zorglub Exp $ + * $Id$ * - * Authors: Gildas Bazin + * Authors: Gildas Bazin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,8 +26,6 @@ *****************************************************************************/ #include #include -#include "input_ext-plugins.h" -#include "vlc_playlist.h" #include @@ -336,11 +334,7 @@ static picture_t *DecodePacket( decoder_t *p_dec, ogg_packet *p_oggpacket ) static void ParseTheoraComments( decoder_t *p_dec ) { input_thread_t *p_input = (input_thread_t *)p_dec->p_parent; - input_info_category_t *p_cat = - input_InfoCategory( p_input, _("Theora comment") ); - playlist_t *p_playlist = vlc_object_find( p_dec, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - playlist_item_t *p_item; + int i = 0; char *psz_name, *psz_value, *psz_comment; while ( i < p_dec->p_sys->tc.comments ) @@ -357,24 +351,12 @@ static void ParseTheoraComments( decoder_t *p_dec ) { *psz_value = '\0'; psz_value++; - input_AddInfo( p_cat, psz_name, psz_value ); - vlc_mutex_lock( &p_playlist->object_lock ); - p_item = playlist_ItemGetByPos( p_playlist, -1 ); - vlc_mutex_unlock( &p_playlist->object_lock ); - if( !p_item) - { - msg_Err(p_dec, "unable to find item" ); - return; - } - vlc_mutex_lock( &p_item->lock ); - playlist_ItemAddInfo( p_item, _("Theora comment") , - psz_name, psz_value ); - vlc_mutex_unlock( &p_item->lock ); + input_Control( p_input, INPUT_ADD_INFO, _("Theora comment"), + psz_name, psz_value ); } free( psz_comment ); i++; } - if( p_playlist) vlc_object_release( p_playlist ); } /***************************************************************************** diff --git a/modules/codec/vorbis.c b/modules/codec/vorbis.c index 694085a2b1..976ac38c49 100644 --- a/modules/codec/vorbis.c +++ b/modules/codec/vorbis.c @@ -2,9 +2,9 @@ * vorbis.c: vorbis decoder/encoder/packetizer module making use of libvorbis. ***************************************************************************** * Copyright (C) 2001-2003 VideoLAN - * $Id: vorbis.c,v 1.32 2004/02/22 15:57:41 fenrir Exp $ + * $Id$ * - * Authors: Gildas Bazin + * Authors: Gildas Bazin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,8 +26,6 @@ *****************************************************************************/ #include #include -#include -#include "vlc_playlist.h" #include @@ -453,11 +451,6 @@ static block_t *SendPacket( decoder_t *p_dec, ogg_packet *p_oggpacket, static void ParseVorbisComments( decoder_t *p_dec ) { input_thread_t *p_input = (input_thread_t *)p_dec->p_parent; - input_info_category_t *p_cat = - input_InfoCategory( p_input, _("Vorbis comment") ); - playlist_t *p_playlist = vlc_object_find( p_dec, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - playlist_item_t *p_item; int i = 0; char *psz_name, *psz_value, *psz_comment; while ( i < p_dec->p_sys->vc.comments ) @@ -474,24 +467,12 @@ static void ParseVorbisComments( decoder_t *p_dec ) { *psz_value = '\0'; psz_value++; - input_AddInfo( p_cat, psz_name, psz_value ); - vlc_mutex_lock( &p_playlist->object_lock ); - p_item = playlist_ItemGetByPos( p_playlist, -1 ); - vlc_mutex_unlock( &p_playlist->object_lock ); - if( !p_item) - { - msg_Err(p_dec, "unable to find item" ); - return; - } - vlc_mutex_lock( &p_item->lock ); - playlist_ItemAddInfo( p_item, _("Vorbis comment") , - psz_name, psz_value ); - vlc_mutex_unlock( &p_item->lock ); + input_Control( p_input, INPUT_ADD_INFO, _("Vorbis comment"), + psz_name, psz_value ); } free( psz_comment ); i++; } - if( p_playlist ) vlc_object_release( p_playlist ); } /***************************************************************************** diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c index d2afb43033..ba9a0ad5d6 100755 --- a/modules/control/hotkeys.c +++ b/modules/control/hotkeys.c @@ -433,7 +433,7 @@ static void Run( intf_thread_t *p_intf ) if( p_playlist ) { mtime_t dur = - p_playlist->pp_items[p_playlist->i_index]->i_duration; + p_playlist->pp_items[p_playlist->i_index]->input.i_duration; i_seconds = time.i_time / 1000000; secstotimestr ( psz_time, i_seconds ); @@ -545,7 +545,7 @@ static void PlayBookmark( intf_thread_t *p_intf, int i_num ) char *psz_bookmark = strdup( val.psz_string ); for( i_position = 0 ; i_position < p_playlist->i_size ; i_position++) { - if( !strcmp( psz_bookmark, p_playlist->pp_items[i_position]->psz_uri ) ) + if( !strcmp( psz_bookmark, p_playlist->pp_items[i_position]->input.psz_uri ) ) { playlist_Goto( p_playlist, i_position ); break; @@ -565,7 +565,7 @@ static void SetBookmark( intf_thread_t *p_intf, int i_num ) char psz_bookmark_name[11]; sprintf( psz_bookmark_name, "bookmark%i", i_num ); var_Create( p_intf, psz_bookmark_name, VLC_VAR_STRING|VLC_VAR_DOINHERIT ); - val.psz_string = strdup( p_playlist->pp_items[p_playlist->i_index]->psz_uri ); + val.psz_string = strdup( p_playlist->pp_items[p_playlist->i_index]->input.psz_uri ); var_Set( p_intf, psz_bookmark_name, val ); msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num, val.psz_string ); vlc_object_release( p_playlist ); diff --git a/modules/control/http.c b/modules/control/http.c index 3952522d39..1e547915ec 100644 --- a/modules/control/http.c +++ b/modules/control/http.c @@ -848,9 +848,9 @@ static mvar_t *mvar_PlaylistSetNew( char *name, playlist_t *p_pl ) sprintf( value, "%d", i ); mvar_AppendNewVar( itm, "index", value ); - mvar_AppendNewVar( itm, "name", p_pl->pp_items[i]->psz_name ); + mvar_AppendNewVar( itm, "name", p_pl->pp_items[i]->input.psz_name ); - mvar_AppendNewVar( itm, "uri", p_pl->pp_items[i]->psz_uri ); + mvar_AppendNewVar( itm, "uri", p_pl->pp_items[i]->input.psz_uri ); sprintf( value, "%d", p_pl->pp_items[i]->i_group ); mvar_AppendNewVar( itm, "group", value ); @@ -865,9 +865,7 @@ static mvar_t *mvar_PlaylistSetNew( char *name, playlist_t *p_pl ) static mvar_t *mvar_InfoSetNew( char *name, input_thread_t *p_input ) { mvar_t *s = mvar_New( name, "set" ); - - input_info_category_t * p_category; - input_info_t * p_info; + int i, j; fprintf( stderr," mvar_InfoSetNew: name=`%s'\n", name ); if( p_input == NULL ) @@ -875,31 +873,30 @@ static mvar_t *mvar_InfoSetNew( char *name, input_thread_t *p_input ) return s; } - vlc_mutex_lock( &p_input->stream.stream_lock ); - p_category = p_input->stream.p_info; - while ( p_category ) + vlc_mutex_lock( &p_input->p_item->lock ); + for ( i = 0; i < p_input->p_item->i_categories; i++ ) { + info_category_t *p_category = p_input->p_item->pp_categories[i]; mvar_t *cat = mvar_New( name, "set" ); mvar_t *iset = mvar_New( "info", "set" ); mvar_AppendNewVar( cat, "name", p_category->psz_name ); mvar_AppendVar( cat, iset ); - p_info = p_category->p_info; - while ( p_info ) + for ( j = 0; j < p_category->i_infos; j++ ) { + info_t *p_info = p_category->pp_infos[j]; mvar_t *info = mvar_New( "info", "" ); - msg_Dbg( p_input, "adding info name=%s value=%s", p_info->psz_name, p_info->psz_value ); + msg_Dbg( p_input, "adding info name=%s value=%s", + p_info->psz_name, p_info->psz_value ); mvar_AppendNewVar( info, "name", p_info->psz_name ); mvar_AppendNewVar( info, "value", p_info->psz_value ); mvar_AppendVar( iset, info ); - p_info = p_info->p_next; } mvar_AppendVar( s, cat ); - p_category = p_category->p_next; } - vlc_mutex_unlock( &p_input->stream.stream_lock ); + vlc_mutex_unlock( &p_input->p_item->lock ); return s; } @@ -1779,7 +1776,8 @@ static void MacroDo( httpd_file_sys_t *p_args, uri_decode_url_encoded( mrl ); p_item = parse_MRL( p_intf, mrl ); - if( !p_item || !p_item->psz_uri || !*p_item->psz_uri ) + if( !p_item || !p_item->input.psz_uri || + !*p_item->input.psz_uri ) { msg_Dbg( p_intf, "invalid requested mrl: %s", mrl ); } else diff --git a/modules/control/rc.c b/modules/control/rc.c index 884b32e107..cd9000f381 100644 --- a/modules/control/rc.c +++ b/modules/control/rc.c @@ -130,8 +130,6 @@ static void Run( intf_thread_t *p_intf ) char p_buffer[ MAX_LINE_LENGTH + 1 ]; vlc_bool_t b_showpos = config_GetInt( p_intf, "rc-show-pos" ); - input_info_category_t * p_category; - input_info_t * p_info; int i_dummy; off_t i_oldpos = 0; @@ -401,24 +399,25 @@ static void Run( intf_thread_t *p_intf ) { if ( p_input ) { - vlc_mutex_lock( &p_input->stream.stream_lock ); - p_category = p_input->stream.p_info; - while ( p_category ) + int i, j; + vlc_mutex_lock( &p_input->p_item->lock ); + for ( i = 0; i < p_input->p_item->i_categories; i++ ) { + info_category_t *p_category = + p_input->p_item->pp_categories[i]; + printf( "+----[ %s ]\n", p_category->psz_name ); printf( "| \n" ); - p_info = p_category->p_info; - while ( p_info ) + for ( j = 0; j < p_category->i_infos; j++ ) { + info_t *p_info = p_category->pp_infos[j]; printf( "| %s: %s\n", p_info->psz_name, p_info->psz_value ); - p_info = p_info->p_next; } - p_category = p_category->p_next; printf( "| \n" ); } printf( "+----[ end of stream info ]\n" ); - vlc_mutex_unlock( &p_input->stream.stream_lock ); + vlc_mutex_unlock( &p_input->p_item->lock ); } else { @@ -663,8 +662,8 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd, for ( i = 0; i < p_playlist->i_size; i++ ) { printf( "|%s%s %s|\n", i == p_playlist->i_index?"*":" ", - p_playlist->pp_items[i]->psz_name, - p_playlist->pp_items[i]->psz_uri ); + p_playlist->pp_items[i]->input.psz_name, + p_playlist->pp_items[i]->input.psz_uri ); } if ( i == 0 ) { diff --git a/modules/demux/mp4/mp4.h b/modules/demux/mp4/mp4.h index de747749ff..fe82ab194f 100644 --- a/modules/demux/mp4/mp4.h +++ b/modules/demux/mp4/mp4.h @@ -2,7 +2,7 @@ * mp4.h : MP4 file input module for vlc ***************************************************************************** * Copyright (C) 2001-2004 VideoLAN - * $Id: mp4.h,v 1.14 2004/01/25 20:05:28 hartman Exp $ + * $Id$ * Authors: Laurent Aimar * * This program is free software; you can redistribute it and/or modify diff --git a/modules/demux/util/id3tag.c b/modules/demux/util/id3tag.c index 9b08026c81..5f07c12959 100644 --- a/modules/demux/util/id3tag.c +++ b/modules/demux/util/id3tag.c @@ -2,7 +2,7 @@ * id3tag.c: id3 tag parser/skipper based on libid3tag ***************************************************************************** * Copyright (C) 2002-2004 VideoLAN - * $Id: id3tag.c,v 1.22 2004/03/03 11:38:14 fenrir Exp $ + * $Id$ * * Authors: Sigmund Augdal * @@ -61,10 +61,8 @@ vlc_module_end(); *****************************************************************************/ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size ) { - playlist_t *p_playlist; struct id3_tag *p_id3_tag; struct id3_frame *p_frame; - input_info_category_t *p_category; char *psz_temp; vlc_value_t val; int i; @@ -76,24 +74,13 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size ) return; } - p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_PARENT ); - val.b_bool = VLC_FALSE; p_id3_tag = id3_tag_parse( p_data, i_size ); - p_category = input_InfoCategory( p_input, "ID3" ); i = 0; while ( ( p_frame = id3_tag_findframe( p_id3_tag , "T", i ) ) ) { int i_strings; - playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist, -1 ); - if( !p_item ) - { - msg_Err( p_input, "Unable to get item" ); - return; - } - - vlc_mutex_lock( &p_item->lock ); i_strings = id3_field_getnstrings( &p_frame->fields[1] ); @@ -107,82 +94,42 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size ) i_genre = strtol( psz_temp, &psz_endptr, 10 ); if( psz_temp != psz_endptr && i_genre >= 0 && i_genre < NUM_GENRES ) { - input_AddInfo( p_category, (char *)p_frame->description, + input_Control( p_input, INPUT_ADD_INFO, "ID3", + (char *)p_frame->description, ppsz_genres[atoi(psz_temp)]); - playlist_ItemAddInfo( p_item, "ID3", - (char *)p_frame->description, - ppsz_genres[atoi(psz_temp)]); } else { - input_AddInfo( p_category, (char *)p_frame->description, - psz_temp ); - playlist_ItemAddInfo( p_item, "ID3", - (char *)p_frame->description, - psz_temp); + input_Control( p_input, INPUT_ADD_INFO, "ID3", + (char *)p_frame->description, psz_temp); } } else if ( !strcmp(p_frame->id, ID3_FRAME_TITLE ) ) { - if( p_item ) - { - if( p_item->psz_name ) - { - free( p_item->psz_name ); - } - p_item->psz_name = strdup( psz_temp );; - - val.b_bool = VLC_TRUE; - } - input_AddInfo( p_category, (char *)p_frame->description, - psz_temp ); - playlist_ItemAddInfo( p_item, "ID3", - (char *)p_frame->description, - psz_temp); + input_Control( p_input, INPUT_SET_NAME, psz_temp ); + input_Control( p_input, INPUT_ADD_INFO, "ID3", + (char *)p_frame->description, psz_temp ); } else if ( !strcmp(p_frame->id, ID3_FRAME_ARTIST ) ) { - if( p_item ) - { - playlist_ItemAddInfo( p_item, - _("General"), _("Author"), psz_temp); - val.b_bool = VLC_TRUE; - } - input_AddInfo( p_category, (char *)p_frame->description, - psz_temp ); - playlist_ItemAddInfo( p_item, "ID3", - (char *)p_frame->description, - psz_temp); + input_Control( p_input, INPUT_ADD_INFO, + _("General"), _("Author"), psz_temp ); + input_Control( p_input, INPUT_ADD_INFO, "ID3", + (char *)p_frame->description, psz_temp ); } else { - input_AddInfo( p_category, (char *)p_frame->description, - psz_temp ); - playlist_ItemAddInfo( p_item, "ID3", - (char *)p_frame->description, - psz_temp); + input_Control( p_input, INPUT_ADD_INFO, "ID3", + (char *)p_frame->description, psz_temp ); } free( psz_temp ); } i++; - vlc_mutex_unlock( &p_item->lock ); } id3_tag_delete( p_id3_tag ); - if(val.b_bool == VLC_TRUE ) - { - if( p_playlist ) - { - val.b_bool = p_playlist->i_index; - var_Set( p_playlist, "item-change", val ); - } - } + val.b_bool = VLC_TRUE; var_Change( p_input, "demuxed-id3", VLC_VAR_SETVALUE, &val, NULL ); - - if( p_playlist ) - { - vlc_object_release( p_playlist ); - } } /***************************************************************************** diff --git a/modules/gui/gtk/gtk_callbacks.c b/modules/gui/gtk/gtk_callbacks.c index 407210f244..194fe31e7f 100644 --- a/modules/gui/gtk/gtk_callbacks.c +++ b/modules/gui/gtk/gtk_callbacks.c @@ -2,7 +2,7 @@ * gtk_callbacks.c : Callbacks for the Gtk+ plugin. ***************************************************************************** * Copyright (C) 2000, 2001, 2003 VideoLAN - * $Id: gtk_callbacks.c,v 1.16 2003/12/22 14:32:56 sam Exp $ + * $Id$ * * Authors: Sam Hocevar * Stéphane Borel @@ -445,7 +445,7 @@ gboolean GtkDiscEject ( GtkWidget *widget, gpointer user_data ) return FALSE; } - psz_current = p_playlist->pp_items[ p_playlist->i_index ]->psz_name; + psz_current = p_playlist->pp_items[ p_playlist->i_index ]->input.psz_name; /* * Get the active input diff --git a/modules/gui/gtk/playlist.c b/modules/gui/gtk/playlist.c index 33f29bc600..3f8d204104 100644 --- a/modules/gui/gtk/playlist.c +++ b/modules/gui/gtk/playlist.c @@ -2,7 +2,7 @@ * gtk_playlist.c : Interface for the playlist dialog ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: playlist.c,v 1.9 2004/01/05 13:07:03 zorglub Exp $ + * $Id$ * * Authors: Pierre Baillet * Stéphane Borel @@ -696,7 +696,7 @@ void GtkRebuildCList( GtkCList * p_clist, playlist_t * p_playlist ) for( i_dummy = p_playlist->i_size ; i_dummy-- ; ) { char psz_duration[MSTRTIME_MAX_SIZE]; - mtime_t dur = p_playlist->pp_items[i_dummy]->i_duration; + mtime_t dur = p_playlist->pp_items[i_dummy]->input.i_duration; if ( dur != -1 ) { secstotimestr( psz_duration, dur/1000000 ); @@ -705,7 +705,7 @@ void GtkRebuildCList( GtkCList * p_clist, playlist_t * p_playlist ) { memcpy( psz_duration ,"no info",sizeof("no info" )); } - ppsz_text[0] = p_playlist->pp_items[i_dummy]->psz_name; + ppsz_text[0] = p_playlist->pp_items[i_dummy]->input.psz_name; ppsz_text[1] = strdup( psz_duration ); gtk_clist_insert( p_clist, 0, ppsz_text ); } diff --git a/modules/gui/skins/controls/playlist.cpp b/modules/gui/skins/controls/playlist.cpp index b03b079b61..4a88543f86 100644 --- a/modules/gui/skins/controls/playlist.cpp +++ b/modules/gui/skins/controls/playlist.cpp @@ -2,7 +2,7 @@ * playlist.cpp: Playlist control ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: playlist.cpp,v 1.15 2003/06/23 20:35:36 asmax Exp $ + * $Id$ * * Authors: Olivier Teulière * Emmanuel Puig @@ -375,13 +375,13 @@ char * ControlPlayList::GetFileName( int i ) { if( LongFileName ) { - return PlayList->pp_items[i]->psz_name; + return PlayList->pp_items[i]->input.psz_name; } else { - string f = PlayList->pp_items[i]->psz_name; + string f = PlayList->pp_items[i]->input.psz_name; int pos = f.rfind( DIRECTORY_SEPARATOR, f.size() ); - return PlayList->pp_items[i]->psz_name + pos + 1; + return PlayList->pp_items[i]->input.psz_name + pos + 1; } } //--------------------------------------------------------------------------- @@ -554,12 +554,12 @@ bool ControlPlayList::ToolTipTest( int x, int y ) if( x >= CaseLeft[i] && x <= CaseRight[i] && y >= TextTop + i * CaseHeight && y < TextTop + (i + 1) * CaseHeight ) { - TextFont->GetSize( PlayList->pp_items[i + StartIndex]->psz_name, w, + TextFont->GetSize( PlayList->pp_items[i + StartIndex]->input.psz_name, w, h ); if( w > FileWidth ) { ParentWindow->ChangeToolTipText( - (string)PlayList->pp_items[i + StartIndex]->psz_name ); + (string)PlayList->pp_items[i + StartIndex]->input.psz_name ); return true; } } diff --git a/modules/gui/skins/src/vlcproc.cpp b/modules/gui/skins/src/vlcproc.cpp index 3adfc347d7..c29115cdee 100644 --- a/modules/gui/skins/src/vlcproc.cpp +++ b/modules/gui/skins/src/vlcproc.cpp @@ -2,7 +2,7 @@ * vlcproc.cpp: VlcProc class ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: vlcproc.cpp,v 1.54 2004/02/15 18:58:38 ipkiss Exp $ + * $Id$ * * Authors: Olivier Teulière * Emmanuel Puig @@ -337,15 +337,15 @@ void VlcProc::InterfaceRefresh() // Update file name if( PlayList->i_index >= 0 && PlayList->i_index != Sys->i_index ) { - string long_name = PlayList->pp_items[PlayList->i_index]->psz_name; + string long_name = PlayList->pp_items[PlayList->i_index]->input.psz_name; int pos = long_name.rfind( DIRECTORY_SEPARATOR, long_name.size() ); // Complete file name Thema->EvtBank->Get( "file_name" )->PostTextMessage( - PlayList->pp_items[PlayList->i_index]->psz_name ); + PlayList->pp_items[PlayList->i_index]->input.psz_name ); // File name without path Thema->EvtBank->Get( "title" )->PostTextMessage( - PlayList->pp_items[PlayList->i_index]->psz_name + pos + 1 ); + PlayList->pp_items[PlayList->i_index]->input.psz_name + pos + 1 ); } // Update playlists diff --git a/modules/gui/skins2/vars/playlist.cpp b/modules/gui/skins2/vars/playlist.cpp index 68aa3b95e5..6fadc77a7c 100644 --- a/modules/gui/skins2/vars/playlist.cpp +++ b/modules/gui/skins2/vars/playlist.cpp @@ -2,7 +2,7 @@ * playlist.cpp ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: playlist.cpp,v 1.7 2004/02/27 13:24:12 gbazin Exp $ + * $Id$ * * Authors: Cyril Deguet * @@ -122,7 +122,7 @@ void Playlist::buildList() for( int i = 0; i < m_pPlaylist->i_size; i++ ) { // Get the name of the playlist item - UString *pName = convertName( m_pPlaylist->pp_items[i]->psz_name ); + UString *pName = convertName( m_pPlaylist->pp_items[i]->input.psz_name ); // Is it the played stream ? bool playing = (i == m_pPlaylist->i_index ); // Add the item in the list diff --git a/modules/gui/wxwindows/fileinfo.cpp b/modules/gui/wxwindows/fileinfo.cpp index 464f6763cc..fe30bf1601 100644 --- a/modules/gui/wxwindows/fileinfo.cpp +++ b/modules/gui/wxwindows/fileinfo.cpp @@ -2,7 +2,7 @@ * fileinfo.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2004 VideoLAN - * $Id: fileinfo.cpp,v 1.23 2004/01/25 03:29:01 hartman Exp $ + * $Id$ * * Authors: Sigmund Augdal * @@ -115,26 +115,23 @@ void FileInfo::UpdateFileInfo() fileinfo_tree->DeleteChildren( fileinfo_root ); fileinfo_root_label = wxL2U(p_input->psz_name); - vlc_mutex_lock( &p_input->stream.stream_lock ); - - input_info_category_t *p_cat = p_input->stream.p_info; - - while( p_cat ) + vlc_mutex_lock( &p_input->p_item->lock ); + for( int i = 0; i < p_input->p_item->i_categories; i++ ) { + info_category_t *p_cat = p_input->p_item->pp_categories[i]; + wxTreeItemId cat = fileinfo_tree->AppendItem( fileinfo_root, wxL2U(p_cat->psz_name) ); - input_info_t *p_info = p_cat->p_info; - while( p_info ) + for( int j = 0; j < p_cat->i_infos; j++ ) { + info_t *p_info = p_cat->pp_infos[j]; + fileinfo_tree->AppendItem( cat, (wxString)wxL2U(p_info->psz_name) + wxT(": ") + wxL2U(p_info->psz_value) ); - p_info = p_info->p_next; } - p_cat = p_cat->p_next; fileinfo_tree->Expand( cat ); } - - vlc_mutex_unlock( &p_input->stream.stream_lock ); + vlc_mutex_unlock( &p_input->p_item->lock ); return; } diff --git a/modules/gui/wxwindows/iteminfo.cpp b/modules/gui/wxwindows/iteminfo.cpp index b9feabfdfb..a6e83633cd 100644 --- a/modules/gui/wxwindows/iteminfo.cpp +++ b/modules/gui/wxwindows/iteminfo.cpp @@ -2,7 +2,7 @@ * iteminfo.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2004 VideoLAN - * $Id: iteminfo.cpp,v 1.8 2004/01/29 17:51:08 zorglub Exp $ + * $Id$ * * Authors: Clément Stenac * @@ -143,10 +143,9 @@ wxPanel *ItemInfoDialog::InfoPanel( wxWindow* parent ) wxStaticText *uri_label = new wxStaticText( info_panel, -1, wxU(_("URI")) ); - uri_text = new wxTextCtrl( info_panel, Uri_Event, - wxU(p_item->psz_uri), - wxDefaultPosition, wxSize( 300, -1 ), - wxTE_PROCESS_ENTER); + uri_text = new wxTextCtrl( info_panel, Uri_Event, + wxU(p_item->input.psz_uri), wxDefaultPosition, wxSize( 300, -1 ), + wxTE_PROCESS_ENTER ); wxBoxSizer *uri_sizer = new wxBoxSizer( wxHORIZONTAL ); @@ -159,11 +158,9 @@ wxPanel *ItemInfoDialog::InfoPanel( wxWindow* parent ) wxStaticText *name_label = new wxStaticText( info_panel, -1, wxU(_("Name")) ); - name_text = - new wxTextCtrl( info_panel, Uri_Event, - wxU(p_item->psz_name), - wxDefaultPosition, wxSize( 300, -1 ), - wxTE_PROCESS_ENTER); + name_text = new wxTextCtrl( info_panel, Uri_Event, + wxU(p_item->input.psz_name), wxDefaultPosition, wxSize( 300, -1 ), + wxTE_PROCESS_ENTER ); wxBoxSizer *name_sizer = new wxBoxSizer( wxHORIZONTAL ); @@ -282,25 +279,25 @@ void ItemInfoDialog::UpdateInfo() { if( !info_root ) { - info_root = info_tree->AddRoot( wxU( p_item->psz_name) ); + info_root = info_tree->AddRoot( wxU( p_item->input.psz_name) ); } /* Rebuild the tree */ - for( int i = 0; i< p_item->i_categories ; i++) + for( int i = 0; i< p_item->input.i_categories ; i++) { - if( !strcmp( p_item->pp_categories[i]->psz_name, _("Options") ) ) + if( !strcmp( p_item->input.pp_categories[i]->psz_name, _("Options") ) ) { continue; } wxTreeItemId cat = info_tree->AppendItem( info_root, - wxU( p_item->pp_categories[i]->psz_name) ); + wxU( p_item->input.pp_categories[i]->psz_name) ); - for( int j = 0 ; j < p_item->pp_categories[i]->i_infos ; j++ ) + for( int j = 0 ; j < p_item->input.pp_categories[i]->i_infos ; j++ ) { info_tree->AppendItem( cat , (wxString) - wxU(p_item->pp_categories[i]->pp_infos[j]->psz_name) + - wxT(": ") + - wxU(p_item->pp_categories[i]->pp_infos[j]->psz_value) ); + wxU(p_item->input.pp_categories[i]->pp_infos[j]->psz_name) + + wxT(": ") + + wxU(p_item->input.pp_categories[i]->pp_infos[j]->psz_value) ); } } } @@ -310,9 +307,9 @@ void ItemInfoDialog::UpdateInfo() *****************************************************************************/ void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) { - vlc_mutex_lock( &p_item->lock ); - p_item->psz_name = strdup( name_text->GetLineText(0).mb_str() ); - p_item->psz_uri = strdup( uri_text->GetLineText(0).mb_str() ); + vlc_mutex_lock( &p_item->input.lock ); + p_item->input.psz_name = strdup( name_text->GetLineText(0).mb_str() ); + p_item->input.psz_uri = strdup( uri_text->GetLineText(0).mb_str() ); playlist_ItemAddInfo( p_item,"General","Author", author_text->GetLineText(0).mb_str() ); vlc_bool_t b_old_enabled = p_item->b_enabled; @@ -341,7 +338,7 @@ void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) } p_item->b_enabled = enabled_checkbox->IsChecked() ? VLC_TRUE : VLC_FALSE ; - vlc_mutex_unlock( &p_item->lock ); + vlc_mutex_unlock( &p_item->input.lock ); EndModal( wxID_OK ); } diff --git a/modules/gui/wxwindows/playlist.cpp b/modules/gui/wxwindows/playlist.cpp index 794fb910e3..d08b32cd5a 100644 --- a/modules/gui/wxwindows/playlist.cpp +++ b/modules/gui/wxwindows/playlist.cpp @@ -431,7 +431,7 @@ void Playlist::UpdateItem( int i ) return; } - listview->SetItem( i, 0, wxL2U(p_item->psz_name) ); + listview->SetItem( i, 0, wxL2U(p_item->input.psz_name) ); listview->SetItem( i, 1, wxU( playlist_ItemGetInfo( p_item, _("General") , _("Author") ) ) ); char *psz_group = playlist_FindGroup(p_playlist, @@ -448,7 +448,7 @@ void Playlist::UpdateItem( int i ) } char psz_duration[MSTRTIME_MAX_SIZE]; - mtime_t dur = p_item->i_duration; + mtime_t dur = p_item->input.i_duration; if( dur != -1 ) secstotimestr( psz_duration, dur/1000000 ); else memcpy( psz_duration , "-:--:--", sizeof("-:--:--") ); listview->SetItem( i, 2, wxU(psz_duration) ); @@ -491,7 +491,7 @@ void Playlist::Rebuild() vlc_mutex_lock( &p_playlist->object_lock ); for( int i = 0; i < p_playlist->i_size; i++ ) { - wxString filename = wxL2U(p_playlist->pp_items[i]->psz_name); + wxString filename = wxL2U(p_playlist->pp_items[i]->input.psz_name); listview->InsertItem( i, filename ); UpdateItem( i ); } diff --git a/modules/misc/playlist/m3u.c b/modules/misc/playlist/m3u.c index b558ac1aa5..8debb706e3 100644 --- a/modules/misc/playlist/m3u.c +++ b/modules/misc/playlist/m3u.c @@ -2,7 +2,7 @@ * m3u.c : M3U playlist export module ***************************************************************************** * Copyright (C) 2004 VideoLAN - * $Id: m3u.c,v 1.1 2004/01/11 00:45:06 zorglub Exp $ + * $Id$ * * Authors: Clément Stenac * @@ -53,17 +53,18 @@ int Export_M3U( vlc_object_t *p_this ) /* Go through the playlist and add items */ for( i = 0; i< p_playlist->i_size ; i++) { - if( strcmp( p_playlist->pp_items[i]->psz_name, - p_playlist->pp_items[i]->psz_uri ) ) + if( strcmp( p_playlist->pp_items[i]->input.psz_name, + p_playlist->pp_items[i]->input.psz_uri ) ) { char *psz_author = playlist_GetInfo( p_playlist, i, _("General"), _("Author") ); fprintf( p_export->p_file,"#EXTINF:%i,%s%s\n", - (int)(p_playlist->pp_items[i]->i_duration/1000000), + (int)(p_playlist->pp_items[i]->input.i_duration/1000000), psz_author ? psz_author : "", - p_playlist->pp_items[i]->psz_name ); + p_playlist->pp_items[i]->input.psz_name ); } - fprintf( p_export->p_file, "%s\n", p_playlist->pp_items[i]->psz_uri ); + fprintf( p_export->p_file, "%s\n", + p_playlist->pp_items[i]->input.psz_uri ); } return VLC_SUCCESS; } diff --git a/modules/misc/playlist/old.c b/modules/misc/playlist/old.c index 79c5ef42a5..1715a618db 100644 --- a/modules/misc/playlist/old.c +++ b/modules/misc/playlist/old.c @@ -2,7 +2,7 @@ * old.c : Old playlist format import/export ***************************************************************************** * Copyright (C) 2004 VideoLAN - * $Id: old.c,v 1.1 2004/01/11 00:45:06 zorglub Exp $ + * $Id$ * * Authors: Clément Stenac * @@ -54,7 +54,8 @@ int Export_Old( vlc_object_t *p_this ) for ( i = 0 ; i < p_playlist->i_size ; i++ ) { - fprintf( p_export->p_file , "%s\n" , p_playlist->pp_items[i]->psz_uri ); - } + fprintf( p_export->p_file , "%s\n" , + p_playlist->pp_items[i]->input.psz_uri ); + } return VLC_SUCCESS; } diff --git a/modules/misc/sap.c b/modules/misc/sap.c index 44ace58e6e..9f80a42dc9 100644 --- a/modules/misc/sap.c +++ b/modules/misc/sap.c @@ -1,3 +1,4 @@ + /***************************************************************************** * sap.c : SAP interface module ***************************************************************************** @@ -848,9 +849,9 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) p_intf->p_sys->pp_announces[i]->i_id ); /* Change the name in the item */ - if( p_item->psz_name ) - free( p_item->psz_name ); - p_item->psz_name = strdup( p_sd->psz_sessionname); + 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 ) @@ -874,9 +875,9 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) p_item = playlist_ItemGetById( p_playlist, i_id ); if( p_item ) { - vlc_mutex_lock( &p_item->lock ); + vlc_mutex_lock( &p_item->input.lock ); playlist_ItemSetGroup( p_item, i_group ); - vlc_mutex_unlock( &p_item->lock ); + vlc_mutex_unlock( &p_item->input.lock ); } /* Then remember it */ diff --git a/src/input/control.c b/src/input/control.c index 1fc129c736..5168a76467 100644 --- a/src/input/control.c +++ b/src/input/control.c @@ -25,6 +25,8 @@ #include #include +#include "vlc_playlist.h" + #include "ninput.h" #include "../../modules/demux/util/sub.h" @@ -64,10 +66,127 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) int i_bkmk, *pi_bkmk; int i, *pi; vlc_value_t val, text; + char *psz_option, *psz_value; vlc_mutex_lock( &p_input->stream.stream_lock ); switch( i_query ) { + case INPUT_ADD_OPTION: + { + psz_option = (char *)va_arg( args, char * ); + psz_value = (char *)va_arg( args, char * ); + i_ret = VLC_EGENERIC; + + vlc_mutex_lock( &p_input->p_item->lock ); + vlc_mutex_unlock( &p_input->p_item->lock ); + + i_ret = VLC_SUCCESS; + break; + } + + case INPUT_SET_NAME: + { + char *psz_name = (char *)va_arg( args, char * ); + i_ret = VLC_EGENERIC; + if( !psz_name ) break; + vlc_mutex_lock( &p_input->p_item->lock ); + if( p_input->p_item->psz_name ) free( p_input->p_item->psz_name ); + p_input->p_item->psz_name = strdup( psz_name ); + vlc_mutex_unlock( &p_input->p_item->lock ); + i_ret = VLC_SUCCESS; + + /* Notify playlist */ + { + vlc_value_t val; + playlist_t *p_playlist = + (playlist_t *)vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, + FIND_PARENT ); + if( p_playlist ) + { + val.i_int = p_playlist->i_index; + var_Set( p_playlist, "item-change", val ); + vlc_object_release( p_playlist ); + } + } + break; + } + + case INPUT_ADD_INFO: + { + char *psz_cat = (char *)va_arg( args, char * ); + char *psz_name = (char *)va_arg( args, char * ); + char *psz_format = (char *)va_arg( args, char * ); + + info_category_t *p_cat; + info_t *p_info; + int i; + + i_ret = VLC_EGENERIC; + + vlc_mutex_lock( &p_input->p_item->lock ); + for( i = 0; i < p_input->p_item->i_categories; i++ ) + { + if( !strcmp( p_input->p_item->pp_categories[i]->psz_name, + psz_cat ) ) + break; + } + + if( i == p_input->p_item->i_categories ) + { + p_cat = malloc( sizeof( info_category_t ) ); + if( !p_cat ) break; + p_cat->psz_name = strdup( psz_cat ); + p_cat->i_infos = 0; + p_cat->pp_infos = NULL; + INSERT_ELEM( p_input->p_item->pp_categories, + p_input->p_item->i_categories, + p_input->p_item->i_categories, p_cat ); + } + + p_cat = p_input->p_item->pp_categories[i]; + + for( i = 0; i < p_cat->i_infos; i++ ) + { + if( !strcmp( p_cat->pp_infos[i]->psz_name, psz_name ) ) + { + if( p_cat->pp_infos[i]->psz_value ) + free( p_cat->pp_infos[i]->psz_value ); + break; + } + } + + if( i == p_cat->i_infos ) + { + p_info = malloc( sizeof( info_t ) ); + if( !p_info ) break; + INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos, + p_cat->i_infos, p_info ); + p_info->psz_name = strdup( psz_name ); + } + + p_info = p_cat->pp_infos[i]; + vasprintf( &p_info->psz_value, psz_format, args ); + + vlc_mutex_unlock( &p_input->p_item->lock ); + + i_ret = VLC_SUCCESS; + + /* Notify playlist */ + { + vlc_value_t val; + playlist_t *p_playlist = + (playlist_t *)vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, + FIND_PARENT ); + if( p_playlist ) + { + val.i_int = p_playlist->i_index; + var_Set( p_playlist, "item-change", val ); + vlc_object_release( p_playlist ); + } + } + } + break; + case INPUT_ADD_BOOKMARK: p_bkmk = (seekpoint_t *)va_arg( args, seekpoint_t * ); p_bkmk = vlc_seekpoint_Duplicate( p_bkmk ); diff --git a/src/input/es_out.c b/src/input/es_out.c index a1df9b9393..173c72bc2f 100644 --- a/src/input/es_out.c +++ b/src/input/es_out.c @@ -295,12 +295,10 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force ) static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt ) { es_out_sys_t *p_sys = out->p_sys; - playlist_t *p_playlist = NULL; input_thread_t *p_input = p_sys->p_input; es_out_id_t *es = malloc( sizeof( es_out_id_t ) ); pgrm_descriptor_t *p_prgm = NULL; char psz_cat[sizeof( _("Stream ") ) + 10]; - input_info_category_t *p_cat; char *psz_description; vlc_mutex_lock( &p_input->stream.stream_lock ); @@ -362,111 +360,73 @@ static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt ) break; } + /* Add stream info */ + vlc_mutex_unlock( &p_input->stream.stream_lock ); sprintf( psz_cat, _("Stream %d"), out->p_sys->i_id - 1 ); - /* Get a category and the playlist */ - if( ( p_cat = input_InfoCategory( p_input, psz_cat ) ) && - ( p_playlist = (playlist_t *)vlc_object_find( p_input, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ) ) ) + + input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Codec"), + "%.4s", (char*)&fmt->i_codec ); + + if( *psz_description ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Language"), + "%s", psz_description ); + + if( fmt->psz_description && *fmt->psz_description ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Description"), + "%s", fmt->psz_description ); + + /* Add information */ + switch( fmt->i_cat ) { - char *psz_type; - switch( fmt->i_cat ) - { - case AUDIO_ES: - psz_type = _("Audio"); - break; - case VIDEO_ES: - psz_type = _("Video"); - break; - case SPU_ES: - psz_type = _("Subtitle"); - break; - default: - psz_type = NULL; - break; - } - if( psz_type ) - { - input_AddInfo( p_cat, _("Type"), psz_type ); - playlist_AddInfo( p_playlist, -1, psz_cat, _("Type"), psz_type ); - } - input_AddInfo( p_cat, _("Codec"), "%.4s", (char*)&fmt->i_codec ); - playlist_AddInfo( p_playlist, -1, psz_cat, _("Codec"), - "%.4s",(char*)&fmt->i_codec ); - if( *psz_description ) - { - input_AddInfo( p_cat, _("Language"), psz_description ); - playlist_AddInfo( p_playlist, -1, psz_cat, _("Language"), - "%s", psz_description ); - } - if( fmt->psz_description && *fmt->psz_description ) - { - input_AddInfo( p_cat, _("Description"), "%s", fmt->psz_description ); - playlist_AddInfo( p_playlist, -1, psz_cat, _("Description"), - "%s", fmt->psz_description ); - } + case AUDIO_ES: + input_Control( p_input, INPUT_ADD_INFO, psz_cat, + _("Type"), _("Audio") ); - /* Add information */ - switch( fmt->i_cat ) - { - case AUDIO_ES: - if( fmt->audio.i_channels > 0 ) - { - input_AddInfo( p_cat, _("Channels"), - "%d", fmt->audio.i_channels ); - playlist_AddInfo( p_playlist, -1, psz_cat, _("Channels"), - "%d", fmt->audio.i_channels ); - } - if( fmt->audio.i_rate > 0 ) - { - input_AddInfo( p_cat, _("Sample rate"), - _("%d Hz"), fmt->audio.i_rate ); - playlist_AddInfo( p_playlist, -1, psz_cat, _("Sample rate"), - _("%d Hz"), fmt->audio.i_rate ); - } - if( fmt->audio.i_bitspersample > 0 ) - { - input_AddInfo( p_cat, _("Bits per sample"), - "%d", fmt->audio.i_bitspersample ); - playlist_AddInfo( p_playlist, -1, psz_cat, _("Bits per sample"), - "%d", fmt->audio.i_bitspersample ); - } - if( fmt->i_bitrate > 0 ) - { - input_AddInfo( p_cat, _("Bitrate"), - _("%d bps"), fmt->i_bitrate ); - playlist_AddInfo( p_playlist, -1, psz_cat, _("Bitrate"), - _("%d bps"), fmt->i_bitrate ); - } - break; + if( fmt->audio.i_channels > 0 ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Channels"), + "%d", fmt->audio.i_channels ); - case VIDEO_ES: - if( fmt->video.i_width > 0 && fmt->video.i_height > 0 ) - { - input_AddInfo( p_cat, _("Resolution"), "%dx%d", - fmt->video.i_width, fmt->video.i_height ); - playlist_AddInfo( p_playlist, -1, psz_cat, - _("Resolution"), "%dx%d", - fmt->video.i_width, fmt->video.i_height ); - } - if( fmt->video.i_visible_width > 0 && - fmt->video.i_visible_height > 0 ) - { - input_AddInfo( p_cat, _("Display resolution"), "%dx%d", - fmt->video.i_visible_width, - fmt->video.i_visible_height); - playlist_AddInfo( p_playlist, -1, psz_cat, - _("Display resolution"), "%dx%d", - fmt->video.i_visible_width, - fmt->video.i_visible_height); - } - break; + if( fmt->audio.i_rate > 0 ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Sample rate"), + _("%d Hz"), fmt->audio.i_rate ); - case SPU_ES: - default: - break; - } - if( p_playlist ) vlc_object_release( p_playlist ); + if( fmt->audio.i_bitspersample > 0 ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, + _("Bits per sample"), "%d", + fmt->audio.i_bitspersample ); + + if( fmt->i_bitrate > 0 ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Bitrate"), + _("%d bps"), fmt->i_bitrate ); + break; + + case VIDEO_ES: + input_Control( p_input, INPUT_ADD_INFO, psz_cat, + _("Type"), _("Video") ); + + if( fmt->video.i_width > 0 && fmt->video.i_height > 0 ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, + _("Resolution"), "%dx%d", + fmt->video.i_width, fmt->video.i_height ); + + if( fmt->video.i_visible_width > 0 && + fmt->video.i_visible_height > 0 ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, + _("Display resolution"), "%dx%d", + fmt->video.i_visible_width, + fmt->video.i_visible_height); + break; + + case SPU_ES: + input_Control( p_input, INPUT_ADD_INFO, psz_cat, + _("Type"), _("Subtitle") ); + break; + + default: + break; } + + vlc_mutex_lock( &p_input->stream.stream_lock ); free( psz_description ); es_format_Copy( &es->p_es->fmt, fmt ); diff --git a/src/input/input.c b/src/input/input.c index dfc78a48a2..af18fb9c52 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -37,8 +37,6 @@ # include #endif -#include "vlc_playlist.h" - #include "stream_output.h" #include "vlc_interface.h" @@ -86,8 +84,8 @@ static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd, * This function creates a new input, and returns a pointer * to its description. On error, it returns NULL. *****************************************************************************/ -input_thread_t *__input_CreateThread( vlc_object_t *p_parent, char *psz_uri, - char **ppsz_options, int i_options ) +input_thread_t *__input_CreateThread( vlc_object_t *p_parent, + input_item_t *p_item ) { input_thread_t *p_input; /* thread descriptor */ @@ -102,12 +100,17 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, char *psz_uri, return NULL; } + /* Store pointer to input item descriptor */ + p_input->p_item = p_item; + /* Parse input options */ - for( i = 0; i < i_options; i++ ) + vlc_mutex_lock( &p_item->lock ); + for( i = 0; i < p_item->i_options; i++ ) { - msg_Dbg( p_input, "option: %s", ppsz_options[i] ); - ParseOption( p_input, ppsz_options[i] ); + msg_Dbg( p_input, "option: %s", p_item->ppsz_options[i] ); + ParseOption( p_input, p_item->ppsz_options[i] ); } + vlc_mutex_unlock( &p_item->lock ); /* Create a few object variables we'll need later on */ var_Create( p_input, "video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); @@ -115,8 +118,10 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, char *psz_uri, var_Create( p_input, "audio-channel", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); var_Create( p_input, "spu-channel", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); var_Create( p_input, "sub-file", VLC_VAR_FILE | VLC_VAR_DOINHERIT ); - var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); - var_Create( p_input, "sub-autodetect-fuzzy", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); + var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL | + VLC_VAR_DOINHERIT ); + var_Create( p_input, "sub-autodetect-fuzzy", VLC_VAR_INTEGER | + VLC_VAR_DOINHERIT ); var_Create( p_input, "sout", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "sout-all", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); @@ -184,7 +189,9 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, char *psz_uri, p_input->p_sys = NULL; /* Set target */ - p_input->psz_source = strdup( psz_uri ); + vlc_mutex_lock( &p_item->lock ); + p_input->psz_source = strdup( p_item->psz_uri ); + vlc_mutex_unlock( &p_item->lock ); /* Stream */ p_input->s = NULL; @@ -309,11 +316,6 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, char *psz_uri, free( val.psz_string ); } - /* Initialize input info */ - p_input->stream.p_info = NULL; - p_input->stream.p_info = input_InfoCategory( p_input, _("General") ); - input_AddInfo( p_input->stream.p_info, _("Playlist Item"), - p_input->psz_source ); vlc_object_attach( p_input, p_parent ); /* Create thread and wait for its readiness. */ @@ -321,7 +323,6 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, char *psz_uri, VLC_THREAD_PRIORITY_INPUT, VLC_TRUE ) ) { msg_Err( p_input, "cannot create input thread" ); - input_DelInfo( p_input ); free( p_input ); return NULL; } @@ -384,8 +385,6 @@ static int RunThread( input_thread_t *p_input ) /* Tell we're dead */ p_input->b_dead = 1; - input_DelInfo( p_input ); - return 0; } @@ -623,7 +622,6 @@ static int InitThread( input_thread_t * p_input ) vlc_meta_t *p_meta = NULL, *p_meta_user = NULL; // float f_fps; double f_fps; - playlist_t *p_playlist; mtime_t i_length; /* Parse source string. Syntax : [[][/]:][] */ @@ -936,52 +934,29 @@ static int InitThread( input_thread_t * p_input ) if( !demux_Control( p_input, DEMUX_GET_META, &p_meta ) || ( p_meta_user && p_meta_user->i_meta ) ) { - playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_input, - VLC_OBJECT_PLAYLIST, FIND_PARENT); - playlist_item_t *p_item = NULL; - input_info_category_t *p_cat; int i; /* Merge demux and user metadata */ if( !p_meta ){ p_meta = p_meta_user; p_meta_user = NULL; } else if( p_meta && p_meta_user ) vlc_meta_Merge( p_meta, p_meta_user ); - if( p_playlist ) - { - vlc_mutex_lock( &p_playlist->object_lock ); - p_item = playlist_ItemGetByPos( p_playlist, -1 ); - if( p_item ) - { - vlc_mutex_lock( &p_item->lock ); - } - vlc_mutex_unlock( &p_playlist->object_lock ); - } - msg_Dbg( p_input, "meta informations:" ); if( p_meta->i_meta > 0 ) { - p_cat = input_InfoCategory( p_input, _("File") ); for( i = 0; i < p_meta->i_meta; i++ ) { msg_Dbg( p_input, " - '%s' = '%s'", _(p_meta->name[i]), p_meta->value[i] ); - if( !strcmp( p_meta->name[i], VLC_META_TITLE ) ) - { - playlist_ItemSetName( p_item, p_meta->value[i] ); - } + if( !strcmp( p_meta->name[i], VLC_META_TITLE ) && + p_meta->value[i] ) + input_Control( p_input, INPUT_SET_NAME, p_meta->value[i] ); + if( !strcmp( p_meta->name[i], VLC_META_AUTHOR ) ) - { - playlist_ItemAddInfo( p_item, _("General"), _("Author"), - p_meta->value[i] ); - } - input_AddInfo( p_cat, _(p_meta->name[i]), "%s", - p_meta->value[i] ); - if( p_item ) - { - playlist_ItemAddInfo( p_item, _("File"), - _(p_meta->name[i]), "%s", - p_meta->value[i] ); - } + input_Control( p_input, INPUT_ADD_INFO, _("General"), + _("Author"), p_meta->value[i] ); + + input_Control( p_input, INPUT_ADD_INFO, _("File"), + _(p_meta->name[i]), "%s", p_meta->value[i] ); } } for( i = 0; i < p_meta->i_track; i++ ) @@ -994,28 +969,18 @@ static int InitThread( input_thread_t * p_input ) { char *psz_cat = malloc( strlen(_("Stream")) + 10 ); sprintf( psz_cat, "%s %d", _("Stream"), i ); - p_cat = input_InfoCategory( p_input, psz_cat ); for( j = 0; j < tk->i_meta; j++ ) { msg_Dbg( p_input, " - '%s' = '%s'", _(tk->name[j]), tk->value[j] ); - input_AddInfo( p_cat, _(tk->name[j]), "%s", tk->value[j] ); - if( p_item ) - { - playlist_ItemAddInfo( p_item, psz_cat, _(tk->name[j]), - "%s", tk->value[j] ); - } + + input_Control( p_input, INPUT_ADD_INFO, psz_cat, + _(tk->name[j]), "%s", tk->value[j] ); } } } - if( p_item ) - { - vlc_mutex_unlock( &p_item->lock ); - } - if( p_playlist ) vlc_object_release( p_playlist ); - if( p_input->stream.p_sout && p_input->stream.p_sout->p_meta == NULL ) { p_input->stream.p_sout->p_meta = p_meta; @@ -1031,24 +996,14 @@ static int InitThread( input_thread_t * p_input ) if( !demux_Control( p_input, DEMUX_GET_LENGTH, &i_length ) && i_length > 0 ) { - input_info_category_t *p_cat = - input_InfoCategory( p_input, _("File") ); - p_playlist = - (playlist_t*)vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, - FIND_PARENT ); - if( p_playlist ) - { - playlist_SetDuration( p_playlist, -1 , i_length ); - val.b_bool = p_playlist->i_index; - var_Set( p_playlist, "item-change", val ); - vlc_object_release( p_playlist ); - } - if( p_cat ) - { - char psz_buffer[MSTRTIME_MAX_SIZE]; - input_AddInfo( p_cat, _("Duration"), - msecstotimestr( psz_buffer, i_length / 1000 ) ); - } + char psz_buffer[MSTRTIME_MAX_SIZE]; + + vlc_mutex_lock( &p_input->p_item->lock ); + p_input->p_item->i_duration = i_length; + vlc_mutex_unlock( &p_input->p_item->lock ); + + input_Control( p_input, INPUT_ADD_INFO, _("General"), _("Duration"), + msecstotimestr( psz_buffer, i_length / 1000 ) ); /* Set start time */ var_Get( p_input, "start-time", &val ); @@ -1264,7 +1219,6 @@ static void EndThread( input_thread_t * p_input ) /* Free info structures XXX destroy es before 'cause vorbis */ msg_Dbg( p_input, "freeing info structures..."); - input_DelInfo( p_input ); free( p_input->psz_source ); if( p_input->psz_dupsource != NULL ) free( p_input->psz_dupsource ); diff --git a/src/input/input_info.c b/src/input/input_info.c deleted file mode 100644 index 7715d46d12..0000000000 --- a/src/input/input_info.c +++ /dev/null @@ -1,180 +0,0 @@ -/***************************************************************************** - * input_info.c: Convenient functions to handle the input info structures - ***************************************************************************** - * Copyright (C) 1998-2004 VideoLAN - * $Id: input_info.c,v 1.14 2004/01/25 17:16:06 zorglub Exp $ - * - * Authors: Sigmund Augdal - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -/***************************************************************************** - * Preamble - *****************************************************************************/ -#include -#include - -#include - -#include "stream_control.h" -#include "input_ext-intf.h" -#include "vlc_interface.h" - -/** - * \brief Find info category by name. - * - * Returns a pointer to the info category with the given name, and - * creates it if necessary - * - * \param p_input pointer to the input thread in which the info is to be found - * \param psz_name the name of the category to be found - * \returns a pointer to the category with the given name - */ -input_info_category_t * input_InfoCategory( input_thread_t * p_input, - char * psz_name) -{ - input_info_category_t * p_category, * p_prev; - p_prev = NULL; - for ( p_category = p_input->stream.p_info; - (p_category != NULL) && strcmp( p_category->psz_name, psz_name ); - p_category = p_category->p_next) - { - p_prev = p_category; - } - if ( p_category ) - { - return p_category; - } - else - { - p_category = malloc( sizeof( input_info_category_t ) ); - if ( !p_category ) - { - msg_Err( p_input, "out of memory" ); - return NULL; - } - p_category->psz_name = strdup( psz_name ); - p_category->p_next = NULL; - p_category->p_info = NULL; - if( p_prev ) p_prev->p_next = p_category; - return p_category; - } -} - -/** - * \brief Add a info item to a category - * - * \param p_category Pointer to the category to put this info in - * \param psz_name Name of the info item to add - * \param psz_format printf style format string for the value. - * \return a negative number on error. 0 on success. - */ -int input_AddInfo( input_info_category_t * p_category, char * psz_name, - char * psz_format, ...) -{ - input_info_t * p_info, * p_prev; - char * psz_str = NULL; - va_list args; - - p_prev = NULL; - if ( !p_category ) - { - return -1; - } - - va_start( args, psz_format ); - - /* - * Convert message to string - */ -#if defined(HAVE_VASPRINTF) && !defined(SYS_DARWIN) && !defined(SYS_BEOS) - vasprintf( &psz_str, psz_format, args ); -#else - psz_str = (char*) malloc( strlen(psz_format) + INTF_MAX_MSG_SIZE ); - if( psz_str == NULL ) - { - return -1; - } - - vsprintf( psz_str, psz_format, args ); -#endif - - va_end( args ); - p_info = p_category->p_info; - while ( p_info ) - { - p_prev = p_info; - p_info = p_info->p_next; - } - p_info = malloc( sizeof( input_info_t ) ); - if( !p_info ) - { - return -1; - } - p_info->psz_name = strdup( psz_name ); - p_info->psz_value = psz_str; - p_info->p_next = NULL; - if ( p_prev ) - { - p_prev->p_next = p_info; - } - else - { - p_category->p_info = p_info; - } - return 0; -} - -/** - * \brief Destroy info structures - * \internal - * - * \param p_input The input thread to be cleaned for info - * \returns for the moment VLC_SUCCESS - */ -int input_DelInfo( input_thread_t * p_input ) -{ - input_info_category_t * p_category, * p_prev_category; - input_info_t * p_info, * p_prev_info; - - p_category = p_input->stream.p_info; - while ( p_category ) - { - p_info = p_category->p_info; - while ( p_info ) - { - if ( p_info->psz_name ) - { - free( p_info->psz_name ); - } - if ( p_info->psz_value ) - { - free( p_info->psz_value ); - } - p_prev_info = p_info; - p_info = p_info->p_next; - free( p_prev_info ); - } - if ( p_category->psz_name ) - { - free( p_category->psz_name ); - } - p_prev_category = p_category; - p_category = p_category->p_next; - free( p_prev_category ); - } - return VLC_SUCCESS; -} diff --git a/src/input/input_programs.c b/src/input/input_programs.c index b958340600..f5b08b1011 100644 --- a/src/input/input_programs.c +++ b/src/input/input_programs.c @@ -600,7 +600,6 @@ es_descriptor_t * input_AddES( input_thread_t * p_input, es_descriptor_t * p_es; vlc_value_t val, text; char *psz_var = NULL; - char *psz_type = NULL; p_es = (es_descriptor_t *)malloc( sizeof(es_descriptor_t) ); if( p_es == NULL ) @@ -663,37 +662,13 @@ es_descriptor_t * input_AddES( input_thread_t * p_input, { case AUDIO_ES: psz_var = "audio-es"; - psz_type = _("audio"); break; case SPU_ES: psz_var = "spu-es"; - psz_type = _("subtitle"); break; case VIDEO_ES: psz_var = "video-es"; - psz_type = _("video"); break; - case NAV_ES: - psz_type = _("navigation"); - break; - case UNKNOWN_ES: - psz_type = _("unknown"); - break; - default: - psz_type = _("error"); - } - -#define TITLE_MAX 30 - /* Add stream info. */ - { - input_info_category_t *p_cat; - char psz_streamid[TITLE_MAX]; - - snprintf(psz_streamid, TITLE_MAX, "%s%04x", _("Stream "), i_es_id); - p_cat = input_InfoCategory( p_input, psz_streamid ); - input_AddInfo( p_cat, _("Type"), "%s", psz_type ); - if ( psz_desc && *psz_desc ) - input_AddInfo( p_cat, _("Description"), "%s", psz_desc ); } if( psz_var ) diff --git a/src/misc/modules.c b/src/misc/modules.c index b6321ec875..0dd7c3d937 100644 --- a/src/misc/modules.c +++ b/src/misc/modules.c @@ -82,7 +82,6 @@ #include "vlc_error.h" #include "vlc_interface.h" -#include "vlc_playlist.h" #include "intf_eject.h" #include "stream_control.h" @@ -91,6 +90,8 @@ #include "input_ext-plugins.h" #include "ninput.h" +#include "vlc_playlist.h" + #include "vlc_video.h" #include "video_output.h" #include "vout_synchro.h" diff --git a/src/misc/vlm.c b/src/misc/vlm.c index 094f27ca6f..4f60141513 100644 --- a/src/misc/vlm.c +++ b/src/misc/vlm.c @@ -167,7 +167,6 @@ int vlm_ExecuteCommand( vlm_t *vlm, char *command, vlm_message_t **message) return result; } - /***************************************************************************** * *****************************************************************************/ @@ -922,12 +921,19 @@ static vlm_media_t *vlm_MediaNew( vlm_t *vlm , char *psz_name, int i_type ) media->psz_output = NULL; media->i_option = 0; media->option = NULL; - media->i_input_option = 0; - media->input_option = NULL; media->i_type = i_type; media->p_input = NULL; - TAB_APPEND( vlm->i_media , vlm->media , media ); + media->item.psz_uri = strdup( psz_name ); + media->item.psz_name = NULL; + media->item.i_duration = -1; + media->item.ppsz_options = NULL; + media->item.i_options = 0; + media->item.i_categories = 0; + media->item.pp_categories = NULL; + vlc_mutex_init( vlm, &media->item.lock ); + + TAB_APPEND( vlm->i_media, vlm->media, media ); return media; } @@ -972,11 +978,15 @@ static int vlm_MediaDelete( vlm_t *vlm, vlm_media_t *media, char *psz_name ) } if(media->option) free( media->option ); - for( i = 0; i < media->i_input_option; i++ ) + if( media->item.psz_uri ) free( media->item.psz_uri ); + if( media->item.psz_name ) free( media->item.psz_name ); + vlc_mutex_destroy( &media->item.lock ); + for( i = 0; i < media->item.i_options; i++ ) { - free( media->input_option[i] ); + free( media->item.ppsz_options[i] ); } - if( media->input_option ) free( media->input_option ); + if( media->item.ppsz_options ) free( media->item.ppsz_options ); + /* FIXME: free the info categories. */ free( media ); @@ -1043,7 +1053,8 @@ static int vlm_MediaSetup( vlm_media_t *media, char *psz_cmd, char *psz_value ) return 0; } -static int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, char *psz_name, char *psz_args ) +static int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, char *psz_name, + char *psz_args ) { if( strcmp( psz_name, "play" ) == 0 ) { @@ -1051,7 +1062,8 @@ static int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, char *psz_name, cha if( media->b_enabled == VLC_TRUE && media->i_input > 0 ) { - if( psz_args != NULL && sscanf( psz_args, "%d", &i ) == 1 && i < media->i_input ) + if( psz_args != NULL && sscanf( psz_args, "%d", &i ) == 1 && + i < media->i_input ) { media->i_index = i; } @@ -1060,28 +1072,34 @@ static int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, char *psz_name, cha media->i_index = 0; } + /* FIXME!!! we need an input_item_t per input spawned */ + //input_ItemNew( &media->item ); if( media->psz_output != NULL ) { - media->input_option = malloc( sizeof( char* ) ); - media->input_option[0] = malloc( strlen(media->psz_output) + 1 + 6 ); - sprintf( media->input_option[0], ":sout=%s" , media->psz_output ); - media->i_input_option = 1; + media->item.ppsz_options = malloc( sizeof( char* ) ); + media->item.ppsz_options[0] = + malloc( strlen(media->psz_output) + sizeof("sout=") ); + sprintf( media->item.ppsz_options[0], "sout=%s", + media->psz_output ); + media->item.i_options = 1; } else { - media->input_option = NULL; - media->i_input_option = 0; + media->item.ppsz_options = NULL; + media->item.i_options = 0; } - for( i=0 ; i < media->i_option ; i++ ) + for( i = 0; i < media->i_option; i++ ) { - media->i_input_option++; - media->input_option = realloc( media->input_option, (media->i_input_option) * sizeof( char* ) ); - media->input_option[ media->i_input_option - 1 ] = malloc( strlen(media->option[i]) + 1 + 1 ); - sprintf( media->input_option[ media->i_input_option - 1 ], ":%s" , media->option[i] ); + media->item.i_options++; + media->item.ppsz_options = + realloc( media->item.ppsz_options, + media->item.i_options * sizeof( char* ) ); + media->item.ppsz_options[ media->item.i_options - 1 ] = + strdup( media->option[i] ); } - media->p_input = input_CreateThread( vlm, media->input[media->i_index], media->input_option, media->i_input_option ); + media->p_input = input_CreateThread( vlm, &media->item ); return 0; } @@ -1104,8 +1122,7 @@ static int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, char *psz_name, cha } else if( strcmp( psz_name, "stop" ) == 0 ) { - int i; - + /* FIXME!!! we need an input_item_t per input spawned */ if( media->p_input ) { input_StopThread( media->p_input ); @@ -1114,14 +1131,7 @@ static int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, char *psz_name, cha vlc_object_destroy( media->p_input ); media->p_input = NULL; - for( i=0 ; i < media->i_input_option ; i++ ) - { - free( media->input_option[i] ); - } - if( media->input_option) free( media->input_option ); - - media->input_option = NULL; - media->i_input_option = 0; + //input_ItemDelete( &media->item ); } return 0; @@ -2175,4 +2185,3 @@ static vlm_message_t* vlm_MessageAdd( vlm_message_t* message , vlm_message_t* ch return child; } - diff --git a/src/playlist/group.c b/src/playlist/group.c index 51b9df16be..6ab0882e2a 100644 --- a/src/playlist/group.c +++ b/src/playlist/group.c @@ -2,7 +2,7 @@ * playlist.c : Playlist groups management functions ***************************************************************************** * Copyright (C) 1999-2004 VideoLAN - * $Id: group.c,v 1.9 2004/01/25 17:16:06 zorglub Exp $ + * $Id$ * * Authors: Clément Stenac * @@ -25,12 +25,10 @@ #include /* strerror() */ #include -#include -#include +#include #include "vlc_playlist.h" - /** * Create a group * @@ -39,7 +37,7 @@ * \param psz_name the name of the group to be created * \return a pointer to the created group, or NULL on error */ -playlist_group_t * playlist_CreateGroup(playlist_t * p_playlist, char *psz_name) +playlist_group_t *playlist_CreateGroup( playlist_t *p_playlist, char *psz_name) { playlist_group_t *p_group; int i; @@ -144,7 +142,7 @@ int playlist_GroupToId( playlist_t *p_playlist, char *psz_name ) { if( p_playlist->pp_groups[i]->psz_name) { - if( ! strcasecmp( p_playlist->pp_groups[i]->psz_name , psz_name ) ) + if( ! strcasecmp( p_playlist->pp_groups[i]->psz_name, psz_name ) ) { return p_playlist->pp_groups[i]->i_id; } diff --git a/src/playlist/info.c b/src/playlist/info.c index f0961102dc..73aaaae7b4 100644 --- a/src/playlist/info.c +++ b/src/playlist/info.c @@ -2,7 +2,7 @@ * info.c : Playlist info management ***************************************************************************** * Copyright (C) 1999-2004 VideoLAN - * $Id: info.c,v 1.10 2004/02/28 17:10:23 gbazin Exp $ + * $Id$ * * Authors: Clément Stenac * @@ -25,8 +25,7 @@ #include /* strerror() */ #include -#include -#include +#include #include "vlc_playlist.h" @@ -46,20 +45,16 @@ char * playlist_GetInfo( playlist_t *p_playlist, int i_pos, { playlist_item_t *p_item; char *psz_buffer; - /* Check the existence of the playlist */ - if( p_playlist == NULL) - { - return strdup(""); - } + + /* Sanity check */ + if( p_playlist == NULL) return strdup(""); + p_item = playlist_ItemGetByPos( p_playlist, i_pos ); - if( !p_item ) - { - return strdup(""); - } - vlc_mutex_lock( &p_item->lock ); - psz_buffer = playlist_ItemGetInfo( p_item , - psz_cat, psz_name ); - vlc_mutex_unlock( &p_item->lock ); + if( !p_item ) return strdup(""); + + vlc_mutex_lock( &p_item->input.lock ); + psz_buffer = playlist_ItemGetInfo( p_item , psz_cat, psz_name ); + vlc_mutex_unlock( &p_item->input.lock ); return psz_buffer; } @@ -73,54 +68,27 @@ char * playlist_GetInfo( playlist_t *p_playlist, int i_pos, * \return the info value if any, an empty string else */ char * playlist_ItemGetInfo( playlist_item_t *p_item, - const char * psz_cat, const char *psz_name ) + const char * psz_cat, const char *psz_name ) { - int i,j ; - for( i = 0 ; i< p_item->i_categories ; i++ ) + int i, j; + + for( i = 0 ; i< p_item->input.i_categories ; i++ ) { - if( !strcmp( p_item->pp_categories[i]->psz_name , psz_cat ) ) + info_category_t *p_category = p_item->input.pp_categories[i]; + + if( strcmp( p_category->psz_name , psz_cat ) ) continue; + + for( j = 0 ; j< p_category->i_infos ; j++ ) { - for( j = 0 ; j< p_item->pp_categories[i]->i_infos ; j++ ) + if( !strcmp( p_category->pp_infos[j]->psz_name, psz_name) ) { - if( !strcmp( p_item->pp_categories[i]->pp_infos[j]->psz_name, - psz_name ) ) - { - return - strdup(p_item->pp_categories[i]->pp_infos[j]->psz_value ); - } + return strdup( p_category->pp_infos[j]->psz_value ); } } } return strdup(""); } -/** - * Get one info category. Create it if it does not exist - * - * \param p_playlist the playlist to get the category from - * \param i_item the position of the item on which we want - * the info ( -1 for current ) - * \param psz_cat the category we want - * \return the info category. - */ -item_info_category_t * -playlist_GetCategory( playlist_t *p_playlist, int i_pos, - const char * psz_cat ) -{ - playlist_item_t *p_item; - /* Check the existence of the playlist */ - if( p_playlist == NULL) - { - return NULL; - } - p_item= playlist_ItemGetByPos( p_playlist , i_pos ); - if( !p_item ) - { - return NULL; - } - return playlist_ItemGetCategory( p_item , psz_cat ); -} - /** * Get one info category (no p_playlist). Create it if it does not exist * @@ -128,17 +96,17 @@ playlist_GetCategory( playlist_t *p_playlist, int i_pos, * \param psz_cat the category we want * \return the info category. */ -item_info_category_t *playlist_ItemGetCategory( playlist_item_t *p_item, - const char *psz_cat ) +info_category_t * playlist_ItemGetCategory( playlist_item_t *p_item, + const char *psz_cat ) { int i; /* Search the category */ - for( i = 0 ; i< p_item->i_categories ; i++ ) + for( i = 0 ; i< p_item->input.i_categories ; i++ ) { - if( !strncmp( p_item->pp_categories[i]->psz_name , psz_cat, - strlen(psz_cat) ) ) + if( !strncmp( p_item->input.pp_categories[i]->psz_name, psz_cat, + strlen(psz_cat) ) ) { - return p_item->pp_categories[i]; + return p_item->input.pp_categories[i]; } } @@ -146,36 +114,6 @@ item_info_category_t *playlist_ItemGetCategory( playlist_item_t *p_item, return playlist_ItemCreateCategory( p_item, psz_cat ); } - -/** - * Create one info category. - * - * \param p_playlist the playlist - * \param i_item the position of the item for which we create - * the category ( -1 for current ) - * \param psz_cat the category we want to create - * \return the info category. - */ -item_info_category_t * -playlist_CreateCategory( playlist_t *p_playlist, int i_pos, - const char * psz_cat ) -{ - playlist_item_t *p_item = NULL; - - /* Check the existence of the playlist */ - if( p_playlist == NULL) - { - return NULL; - } - p_item = playlist_ItemGetByPos( p_playlist , i_pos ); - if( !p_item ) - { - return NULL; - } - - return playlist_ItemCreateCategory( p_item, psz_cat ); -} - /** * Create one info category for an item ( no p_playlist required ) * @@ -184,19 +122,21 @@ playlist_CreateCategory( playlist_t *p_playlist, int i_pos, * \param psz_cat the category we want to create * \return the info category. */ -item_info_category_t * -playlist_ItemCreateCategory( playlist_item_t *p_item, const char *psz_cat ) +info_category_t * playlist_ItemCreateCategory( playlist_item_t *p_item, + const char *psz_cat ) { - item_info_category_t *p_cat; + info_category_t *p_cat; int i; - for( i = 0 ; i< p_item->i_categories ; i++) + + for( i = 0 ; i< p_item->input.i_categories ; i++) { - if( !strcmp( p_item->pp_categories[i]->psz_name,psz_cat ) ) + if( !strcmp( p_item->input.pp_categories[i]->psz_name,psz_cat ) ) { - return p_item->pp_categories[i]; + return p_item->input.pp_categories[i]; } } - if( ( p_cat = malloc( sizeof( item_info_category_t) ) ) == NULL ) + + if( ( p_cat = malloc( sizeof( info_category_t) ) ) == NULL ) { return NULL; } @@ -205,10 +145,8 @@ playlist_ItemCreateCategory( playlist_item_t *p_item, const char *psz_cat ) p_cat->i_infos = 0; p_cat->pp_infos = NULL; - INSERT_ELEM( p_item->pp_categories , - p_item->i_categories , - p_item->i_categories , - p_cat ); + INSERT_ELEM( p_item->input.pp_categories, p_item->input.i_categories, + p_item->input.i_categories, p_cat ); return p_cat; } @@ -234,31 +172,24 @@ int playlist_AddInfo( playlist_t *p_playlist, int i_item, playlist_item_t *p_item; char *psz_value; - /* Check the existence of the playlist */ - if( p_playlist == NULL) - { - return VLC_EGENERIC; - } + /* Sanity check */ + if( p_playlist == NULL) return VLC_EGENERIC; p_item = playlist_ItemGetByPos( p_playlist, i_item ); - if( !p_item ) - { - return VLC_ENOOBJ; - } + if( !p_item ) return VLC_ENOOBJ; va_start( args, psz_format ); vasprintf( &psz_value, psz_format, args ); va_end( args ); - vlc_mutex_lock( &p_item->lock ); - i_ret = playlist_ItemAddInfo( p_item , psz_cat , psz_name , psz_value ); - vlc_mutex_unlock( &p_item->lock ); + vlc_mutex_lock( &p_item->input.lock ); + i_ret = playlist_ItemAddInfo( p_item, psz_cat, psz_name, psz_value ); + vlc_mutex_unlock( &p_item->input.lock ); free( psz_value ); return i_ret; } - /** * Add info to one item ( no need for p_playlist ) * @@ -269,21 +200,18 @@ int playlist_AddInfo( playlist_t *p_playlist, int i_item, * \return VLC_SUCCESS on success */ int playlist_ItemAddInfo( playlist_item_t *p_item, - const char *psz_cat, const char *psz_name, - const char *psz_format, ... ) + const char *psz_cat, const char *psz_name, + const char *psz_format, ... ) { va_list args; int i; int i_new = VLC_TRUE; - item_info_t *p_info = NULL; - item_info_category_t *p_cat; + info_t *p_info = NULL; + info_category_t *p_cat; /* Find or create the category */ p_cat = playlist_ItemGetCategory( p_item, psz_cat ); - if( p_cat == NULL) - { - return VLC_EGENERIC; - } + if( p_cat == NULL) return VLC_EGENERIC; for( i = 0 ; i< p_cat->i_infos ; i++) { @@ -299,7 +227,7 @@ int playlist_ItemAddInfo( playlist_item_t *p_item, /* New info, create it */ if( p_info == NULL ) { - if( ( p_info = malloc( sizeof( item_info_t) ) ) == NULL ) + if( ( p_info = malloc( sizeof( info_t) ) ) == NULL ) { return VLC_EGENERIC; } @@ -317,10 +245,7 @@ int playlist_ItemAddInfo( playlist_item_t *p_item, /* If this is new, insert it */ if( i_new == VLC_TRUE ) { - INSERT_ELEM( p_cat->pp_infos, - p_cat->i_infos, - p_cat->i_infos, - p_info ); + INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos, p_cat->i_infos, p_info ); } return VLC_SUCCESS; diff --git a/src/playlist/item-ext.c b/src/playlist/item-ext.c index e28495a092..8a829ef064 100644 --- a/src/playlist/item-ext.c +++ b/src/playlist/item-ext.c @@ -26,8 +26,7 @@ #include /* strerror() */ #include -#include -#include +#include #include "vlc_playlist.h" @@ -55,8 +54,9 @@ int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri, mtime_t i_duration, const char **ppsz_options, int i_options ) { - playlist_item_t * p_item = + playlist_item_t *p_item = playlist_ItemNew( p_playlist , psz_uri, psz_name ); + int i; if( p_item == NULL ) @@ -65,23 +65,23 @@ int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri, return -1; } - p_item->i_duration = i_duration; + p_item->input.i_duration = i_duration; - p_item->i_options = i_options; - p_item->ppsz_options = NULL; + p_item->input.i_options = i_options; + p_item->input.ppsz_options = NULL; for( i = 0; i < i_options; i++ ) { if( i == 0 ) { - p_item->ppsz_options = malloc( i_options * sizeof(char *) ); - if( !p_item->ppsz_options ) + p_item->input.ppsz_options = malloc( i_options * sizeof(char *) ); + if( !p_item->input.ppsz_options ) { - p_item->i_options = 0; + p_item->input.i_options = 0; break; } } - p_item->ppsz_options[i] = strdup( ppsz_options[i] ); + p_item->input.ppsz_options[i] = strdup( ppsz_options[i] ); } return playlist_AddItem( p_playlist, p_item, i_mode, i_pos ); @@ -99,115 +99,13 @@ int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri, * regardless of it's size * \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 ) +int playlist_Add( playlist_t *p_playlist, const char *psz_uri, + const char *psz_name, int i_mode, int i_pos ) { - return playlist_AddExt ( p_playlist, psz_uri, psz_name, i_mode, i_pos, + return playlist_AddExt( p_playlist, psz_uri, psz_name, i_mode, i_pos, -1, NULL, 0 ); } -/** - * Create a new item, without adding it to the playlist - * - * \param psz_uri the mrl of the item - * \param psz_name a text giving a name or description of the item - * \return the new item or NULL on failure - */ -playlist_item_t * __playlist_ItemNew( vlc_object_t *p_obj, - const char *psz_uri, - const char *psz_name ) -{ - playlist_item_t * p_item; - - p_item = malloc( sizeof( playlist_item_t ) ); - if( p_item == NULL ) - { - return NULL; - } - if( psz_uri == NULL) - { - return NULL; - } - memset( p_item, 0, sizeof( playlist_item_t ) ); - p_item->psz_uri = strdup( psz_uri ); - if( psz_name != NULL ) - { - p_item->psz_name = strdup( psz_name ); - } - else - { - p_item->psz_name = strdup ( psz_uri ); - } - p_item->b_enabled = VLC_TRUE; - p_item->i_group = PLAYLIST_TYPE_MANUAL; - - p_item->i_duration = -1; - p_item->ppsz_options = NULL; - p_item->i_options = 0; - - vlc_mutex_init( p_obj->p_vlc , &p_item->lock ); - - playlist_ItemCreateCategory( p_item, _("General") ); - return p_item; -} - -/** - * Deletes a playlist item - * - * \param p_item the item to delete - * \return nothing - */ -void playlist_ItemDelete( playlist_item_t *p_item) -{ - int i,j; - - vlc_mutex_lock( &p_item->lock ); - - if( p_item->psz_name ) - { - free( p_item->psz_name ); - } - if( p_item->psz_uri ) - { - free( p_item->psz_uri ); - } - - /* Free the info categories. Welcome to the segfault factory */ - if( p_item->i_categories > 0 ) - { - for( i = 0; i < p_item->i_categories; i++ ) - { - for( j= 0 ; j < p_item->pp_categories[i]->i_infos; j++) - { - if( p_item->pp_categories[i]->pp_infos[j]->psz_name) - { - free( p_item->pp_categories[i]-> - pp_infos[j]->psz_name); - } - if( p_item->pp_categories[i]->pp_infos[j]->psz_value) - { - free( p_item->pp_categories[i]-> - pp_infos[j]->psz_value); - } - free( p_item->pp_categories[i]->pp_infos[j] ); - } - if( p_item->pp_categories[i]->i_infos ) - free( p_item->pp_categories[i]->pp_infos ); - if( p_item->pp_categories[i]->psz_name) - { - free( p_item->pp_categories[i]->psz_name ); - } - free( p_item->pp_categories[i] ); - } - free( p_item->pp_categories ); - } - - vlc_mutex_unlock( &p_item->lock ); - vlc_mutex_destroy( &p_item->lock ); - - free( p_item ); -} - /*************************************************************************** * Item search functions ***************************************************************************/ @@ -233,7 +131,6 @@ int playlist_GetPositionById( playlist_t * p_playlist , int i_id ) return VLC_EGENERIC; } - /** * Search an item by its id * @@ -321,9 +218,9 @@ int playlist_SetGroup( playlist_t *p_playlist, int i_pos, int i_group ) return VLC_ENOOBJ; } - vlc_mutex_lock( &p_item->lock ); + vlc_mutex_lock( &p_item->input.lock ); playlist_ItemSetGroup( p_item , i_group ); - vlc_mutex_unlock( &p_item->lock ); + vlc_mutex_unlock( &p_item->input.lock ); val.b_bool = (i_pos >= 0 && i_pos < p_playlist->i_size ) ? i_pos : -1; var_Set( p_playlist, "item-change", val ); @@ -342,7 +239,7 @@ int playlist_ItemSetName( playlist_item_t *p_item, char *psz_name ) { if( psz_name && p_item ) { - p_item->psz_name = strdup( psz_name ); + p_item->input.psz_name = strdup( psz_name ); return VLC_SUCCESS; } return VLC_EGENERIC; @@ -373,9 +270,9 @@ int playlist_SetName( playlist_t *p_playlist, int i_pos, char *psz_name ) return VLC_ENOOBJ; } - vlc_mutex_lock( &p_item->lock ); + vlc_mutex_lock( &p_item->input.lock ); playlist_ItemSetName( p_item , psz_name ); - vlc_mutex_unlock( &p_item->lock ); + vlc_mutex_unlock( &p_item->input.lock ); val.b_bool = (i_pos >= 0 && i_pos < p_playlist->i_size ) ? i_pos : -1; var_Set( p_playlist, "item-change", val ); @@ -396,7 +293,7 @@ int playlist_ItemSetDuration( playlist_item_t *p_item, mtime_t i_duration ) char psz_buffer[MSTRTIME_MAX_SIZE]; if( p_item ) { - p_item->i_duration = i_duration; + p_item->input.i_duration = i_duration; if( i_duration != -1 ) { secstotimestr( psz_buffer, i_duration/1000000 ); @@ -406,7 +303,7 @@ int playlist_ItemSetDuration( playlist_item_t *p_item, mtime_t i_duration ) memcpy( psz_buffer, "--:--:--", sizeof("--:--:--") ); } playlist_ItemAddInfo( p_item, _("General") , _("Duration"), - "%s", psz_buffer ); + "%s", psz_buffer ); return VLC_SUCCESS; } @@ -438,9 +335,9 @@ int playlist_SetDuration( playlist_t *p_playlist, int i_pos, mtime_t i_duration return VLC_ENOOBJ; } - vlc_mutex_lock( &p_item->lock ); + vlc_mutex_lock( &p_item->input.lock ); playlist_ItemSetDuration( p_item , i_duration ); - vlc_mutex_unlock( &p_item->lock ); + vlc_mutex_unlock( &p_item->input.lock ); val.b_bool = (i_pos >= 0 && i_pos < p_playlist->i_size ) ? i_pos : -1; var_Set( p_playlist, "item-change", val ); @@ -452,7 +349,6 @@ int playlist_SetDuration( playlist_t *p_playlist, int i_pos, mtime_t i_duration * Actions on existing playlist items **********************************************************************/ - /** * delete an item from a playlist. * @@ -477,7 +373,7 @@ int playlist_Delete( playlist_t * p_playlist, int i_pos ) playlist_item_t *p_item = p_playlist->pp_items[i_pos]; msg_Dbg( p_playlist, "deleting playlist item `%s'", - p_item->psz_name ); + p_item->input.psz_name ); #if 0 int i,j; @@ -535,11 +431,9 @@ int playlist_Delete( playlist_t * p_playlist, int i_pos ) } /* Renumber the playlist */ - REMOVE_ELEM( p_playlist->pp_items, - p_playlist->i_size, - i_pos ); - if( p_playlist->i_enabled > 0 ) - p_playlist->i_enabled--; + REMOVE_ELEM( p_playlist->pp_items, p_playlist->i_size, i_pos ); + + if( p_playlist->i_enabled > 0 ) p_playlist->i_enabled--; } vlc_mutex_unlock( &p_playlist->object_lock ); @@ -556,7 +450,8 @@ int playlist_Delete( playlist_t * p_playlist, int i_pos ) * \param p_playlist the playlist to be cleared. * \return returns 0 */ -int playlist_Clear( playlist_t * p_playlist ) { +int playlist_Clear( playlist_t * p_playlist ) +{ while( p_playlist->i_groups > 0 ) { @@ -578,7 +473,6 @@ int playlist_Clear( playlist_t * p_playlist ) { return 0; } - /** * Disables a playlist item * @@ -595,7 +489,7 @@ int playlist_Disable( playlist_t * p_playlist, int i_pos ) if( i_pos >= 0 && i_pos < p_playlist->i_size ) { msg_Dbg( p_playlist, "disabling playlist item `%s'", - p_playlist->pp_items[i_pos]->psz_name ); + p_playlist->pp_items[i_pos]->input.psz_name ); if( p_playlist->pp_items[i_pos]->b_enabled == VLC_TRUE ) p_playlist->i_enabled--; @@ -625,7 +519,7 @@ int playlist_Enable( playlist_t * p_playlist, int i_pos ) if( i_pos >= 0 && i_pos < p_playlist->i_size ) { msg_Dbg( p_playlist, "enabling playlist item `%s'", - p_playlist->pp_items[i_pos]->psz_name ); + p_playlist->pp_items[i_pos]->input.psz_name ); if( p_playlist->pp_items[i_pos]->b_enabled == VLC_FALSE ) p_playlist->i_enabled++; @@ -648,19 +542,19 @@ int playlist_Enable( playlist_t * p_playlist, int i_pos ) * \param i_group the id of the group to disable * \return returns 0 */ -int playlist_DisableGroup( playlist_t * p_playlist, int i_group) +int playlist_DisableGroup( playlist_t * p_playlist, int i_group ) { vlc_value_t val; int i; vlc_mutex_lock( &p_playlist->object_lock ); - msg_Dbg(p_playlist,"disabling group %i",i_group); + msg_Dbg( p_playlist, "disabling group %i", i_group ); for( i = 0 ; i< p_playlist->i_size; i++ ) { if( p_playlist->pp_items[i]->i_group == i_group ) { msg_Dbg( p_playlist, "disabling playlist item `%s'", - p_playlist->pp_items[i]->psz_name ); + p_playlist->pp_items[i]->input.psz_name ); if( p_playlist->pp_items[i]->b_enabled == VLC_TRUE ) p_playlist->i_enabled--; @@ -682,18 +576,18 @@ int playlist_DisableGroup( playlist_t * p_playlist, int i_group) * \param i_group the id of the group to enable * \return returns 0 */ -int playlist_EnableGroup( playlist_t * p_playlist, int i_group) +int playlist_EnableGroup( playlist_t * p_playlist, int i_group ) { - vlc_value_t val; + vlc_value_t val; int i; vlc_mutex_lock( &p_playlist->object_lock ); - for( i = 0 ; i< p_playlist->i_size; i++ ) + for( i = 0; i< p_playlist->i_size; i++ ) { if( p_playlist->pp_items[i]->i_group == i_group ) { msg_Dbg( p_playlist, "enabling playlist item `%s'", - p_playlist->pp_items[i]->psz_name ); + p_playlist->pp_items[i]->input.psz_name ); if( p_playlist->pp_items[i]->b_enabled == VLC_FALSE ) p_playlist->i_enabled++; @@ -719,22 +613,21 @@ int playlist_EnableGroup( playlist_t * p_playlist, int i_group) * after the move * \return returns VLC_SUCCESS */ -int playlist_Move( playlist_t * p_playlist, int i_pos, int i_newpos) +int playlist_Move( playlist_t * p_playlist, int i_pos, int i_newpos ) { - vlc_value_t val; + vlc_value_t val; vlc_mutex_lock( &p_playlist->object_lock ); /* take into account that our own row disappears. */ - if ( i_pos < i_newpos ) i_newpos--; + if( i_pos < i_newpos ) i_newpos--; - if( i_pos >= 0 && i_newpos >=0 && i_pos <= p_playlist->i_size - && i_newpos <= p_playlist->i_size ) + if( i_pos >= 0 && i_newpos >=0 && i_pos <= p_playlist->i_size && + i_newpos <= p_playlist->i_size ) { playlist_item_t * temp; msg_Dbg( p_playlist, "moving playlist item `%s' (%i -> %i)", - p_playlist->pp_items[i_pos]->psz_name, i_pos, - i_newpos ); + p_playlist->pp_items[i_pos]->input.psz_name, i_pos, i_newpos); if( i_pos == p_playlist->i_index ) { @@ -778,37 +671,3 @@ int playlist_Move( playlist_t * p_playlist, int i_pos, int i_newpos) return VLC_SUCCESS; } - -/** - * Add a special info : option - * - * \param p_playlist the playlist - * \param i_item the position of the item on which we - * add the option ( -1 for current ) - * \param psz_value the option to add - * \return the info category. - */ -int playlist_AddOption( playlist_t *p_playlist, int i_pos, - const char *psz_option ) -{ - playlist_item_t *p_item; - - /* Check the existence of the playlist */ - if( p_playlist == NULL) - { - return VLC_EGENERIC; - } - - p_item = playlist_ItemGetByPos( p_playlist , i_pos ); - if( !p_item ) - { - return VLC_ENOOBJ; - } - - vlc_mutex_lock( &p_item->lock ); - INSERT_ELEM( p_item->ppsz_options, p_item->i_options, p_item->i_options, - strdup( psz_option ) ); - vlc_mutex_unlock( &p_item->lock ); - - return VLC_SUCCESS; -} diff --git a/src/playlist/item.c b/src/playlist/item.c index 6d556ae865..bd2a57b36d 100644 --- a/src/playlist/item.c +++ b/src/playlist/item.c @@ -25,15 +25,101 @@ #include /* strerror() */ #include -#include -#include #include #include "vlc_playlist.h" +/** + * Create a new item, without adding it to the playlist + * + * \param psz_uri the mrl of the item + * \param psz_name a text giving a name or description of the item + * \return the new item or NULL on failure + */ +playlist_item_t * __playlist_ItemNew( vlc_object_t *p_obj, + const char *psz_uri, + const char *psz_name ) +{ + playlist_item_t * p_item; + + p_item = malloc( sizeof( playlist_item_t ) ); + if( p_item == NULL ) return NULL; + if( psz_uri == NULL) return NULL; + + memset( p_item, 0, sizeof( playlist_item_t ) ); + + p_item->input.psz_uri = strdup( psz_uri ); + + if( psz_name != NULL ) p_item->input.psz_name = strdup( psz_name ); + else p_item->input.psz_name = strdup ( psz_uri ); + p_item->b_enabled = VLC_TRUE; + p_item->i_group = PLAYLIST_TYPE_MANUAL; + p_item->input.i_duration = -1; + p_item->input.ppsz_options = NULL; + p_item->input.i_options = 0; + vlc_mutex_init( p_obj, &p_item->input.lock ); + + playlist_ItemCreateCategory( p_item, _("General") ); + return p_item; +} + +/** + * Deletes a playlist item + * + * \param p_item the item to delete + * \return nothing + */ +void playlist_ItemDelete( playlist_item_t *p_item ) +{ +#if 0 + int i,j; +#endif + + vlc_mutex_lock( &p_item->input.lock ); + + if( p_item->input.psz_name ) free( p_item->input.psz_name ); + if( p_item->input.psz_uri ) free( p_item->input.psz_uri ); + +#if 0 + /* Free the info categories. Welcome to the segfault factory */ + if( p_item->i_categories > 0 ) + { + for( i = 0; i < p_item->i_categories; i++ ) + { + for( j= 0 ; j < p_item->pp_categories[i]->i_infos; j++) + { + if( p_item->pp_categories[i]->pp_infos[j]->psz_name) + { + free( p_item->pp_categories[i]-> + pp_infos[j]->psz_name); + } + if( p_item->pp_categories[i]->pp_infos[j]->psz_value) + { + free( p_item->pp_categories[i]-> + pp_infos[j]->psz_value); + } + free( p_item->pp_categories[i]->pp_infos[j] ); + } + if( p_item->pp_categories[i]->i_infos ) + free( p_item->pp_categories[i]->pp_infos ); + if( p_item->pp_categories[i]->psz_name) + { + free( p_item->pp_categories[i]->psz_name ); + } + free( p_item->pp_categories[i] ); + } + free( p_item->pp_categories ); + } +#endif + + vlc_mutex_unlock( &p_item->input.lock ); + vlc_mutex_destroy( &p_item->input.lock ); + + free( p_item ); +} /** * Add a playlist item into a playlist @@ -45,11 +131,11 @@ * PLAYLIST_END the item will be added at the end of the playlist * regardless of it's size * \return The id of the playlist item -*/ -int playlist_AddItem( playlist_t *p_playlist, playlist_item_t * p_item, - int i_mode, int i_pos) + */ +int playlist_AddItem( playlist_t *p_playlist, playlist_item_t *p_item, + int i_mode, int i_pos) { - vlc_value_t val; + vlc_value_t val; vlc_mutex_lock( &p_playlist->object_lock ); @@ -65,15 +151,16 @@ int playlist_AddItem( playlist_t *p_playlist, playlist_item_t * p_item, { for ( j = 0; j < p_playlist->i_size; j++ ) { - if ( !strcmp( p_playlist->pp_items[j]->psz_uri, p_item->psz_uri ) ) + if ( !strcmp( p_playlist->pp_items[j]->input.psz_uri, + p_item->input.psz_uri ) ) { - if( p_item->psz_name ) + if ( p_item->input.psz_name ) { - free( p_item->psz_name ); + free( p_item->input.psz_name ); } - if( p_item->psz_uri ) + if ( p_item->input.psz_uri ) { - free( p_item->psz_uri ); + free ( p_item->input.psz_uri ); } free( p_item ); vlc_mutex_unlock( &p_playlist->object_lock ); @@ -85,10 +172,8 @@ int playlist_AddItem( playlist_t *p_playlist, playlist_item_t * p_item, i_mode |= PLAYLIST_APPEND; } - msg_Dbg( p_playlist, "adding playlist item `%s' ( %s )", - p_item->psz_name, p_item->psz_uri ); - + p_item->input.psz_name, p_item->input.psz_uri ); p_item->i_id = ++p_playlist->i_last_id; @@ -122,10 +207,7 @@ int playlist_AddItem( playlist_t *p_playlist, playlist_item_t * p_item, i_pos = p_playlist->i_size; } - INSERT_ELEM( p_playlist->pp_items, - p_playlist->i_size, - i_pos, - p_item ); + INSERT_ELEM( p_playlist->pp_items, p_playlist->i_size, i_pos, p_item ); p_playlist->i_enabled ++; if( p_playlist->i_index >= i_pos ) @@ -136,13 +218,13 @@ int playlist_AddItem( playlist_t *p_playlist, playlist_item_t * p_item, else { /* i_mode == PLAYLIST_REPLACE and 0 <= i_pos < p_playlist->i_size */ - if( p_playlist->pp_items[i_pos]->psz_name ) + if( p_playlist->pp_items[i_pos]->input.psz_name ) { - free( p_playlist->pp_items[i_pos]->psz_name ); + free( p_playlist->pp_items[i_pos]->input.psz_name ); } - if( p_playlist->pp_items[i_pos]->psz_uri ) + if( p_playlist->pp_items[i_pos]->input.psz_uri ) { - free( p_playlist->pp_items[i_pos]->psz_uri ); + free( p_playlist->pp_items[i_pos]->input.psz_uri ); } /* XXX: what if the item is still in use? */ free( p_playlist->pp_items[i_pos] ); @@ -173,14 +255,15 @@ int playlist_AddItem( playlist_t *p_playlist, playlist_item_t * p_item, * \param p_item the item on which we want the info * \param psz_format the option * \return 0 on success -*/ -int playlist_ItemAddOption( playlist_item_t *p_item, - const char *psz_option ) + */ +int playlist_ItemAddOption( playlist_item_t *p_item, const char *psz_option ) { if( !psz_option ) return VLC_EGENERIC; - INSERT_ELEM( p_item->ppsz_options, p_item->i_options, p_item->i_options, - strdup( psz_option ) ); + vlc_mutex_lock( &p_item->input.lock ); + INSERT_ELEM( p_item->input.ppsz_options, p_item->input.i_options, + p_item->input.i_options, strdup( psz_option ) ); + vlc_mutex_unlock( &p_item->input.lock ); return VLC_SUCCESS; } diff --git a/src/playlist/playlist.c b/src/playlist/playlist.c index 5a7c8dc9ac..fea9148adc 100644 --- a/src/playlist/playlist.c +++ b/src/playlist/playlist.c @@ -580,9 +580,7 @@ static void PlayItem( playlist_t *p_playlist ) p_item = p_playlist->pp_items[p_playlist->i_index]; p_item->i_nb_played++; - p_playlist->p_input = input_CreateThread( p_playlist, p_item->psz_uri, - p_item->ppsz_options, - p_item->i_options ); + p_playlist->p_input = input_CreateThread( p_playlist, &p_item->input ); val.i_int = p_playlist->i_index; /* unlock the playlist to set the var...mmm */ diff --git a/src/playlist/sort.c b/src/playlist/sort.c index ecf1346e4d..855d305a4c 100644 --- a/src/playlist/sort.c +++ b/src/playlist/sort.c @@ -2,7 +2,7 @@ * sort.c : Playlist sorting functions ***************************************************************************** * Copyright (C) 1999-2004 VideoLAN - * $Id: sort.c,v 1.9 2004/01/23 10:48:08 zorglub Exp $ + * $Id$ * * Authors: Clément Stenac * @@ -25,6 +25,7 @@ #include /* strerror() */ #include +#include #include #include @@ -87,18 +88,18 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type ) } else if( i_mode == SORT_TITLE ) { - i_test = strcasecmp( p_playlist->pp_items[i]->psz_name, - p_playlist->pp_items[i_small]->psz_name ); + i_test = strcasecmp( p_playlist->pp_items[i]->input.psz_name, + p_playlist->pp_items[i_small]->input.psz_name ); } else if( i_mode == SORT_GROUP ) { i_test = p_playlist->pp_items[i]->i_group - - p_playlist->pp_items[i_small]->i_group; + p_playlist->pp_items[i_small]->i_group; } else if( i_mode == SORT_DURATION ) { - i_test = p_playlist->pp_items[i]->i_duration - - p_playlist->pp_items[i_small]->i_duration; + i_test = p_playlist->pp_items[i]->input.i_duration - + p_playlist->pp_items[i_small]->input.i_duration; } else if( i_mode == SORT_AUTHOR ) {