1 /*****************************************************************************
2 * item.c: input_item management
3 *****************************************************************************
4 * Copyright (C) 1998-2004 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
29 #include <vlc_common.h>
31 #include "vlc_playlist.h"
32 #include "vlc_interface.h"
36 static int GuessType( const input_item_t *p_item );
38 /** Stuff moved out of vlc_input.h -- FIXME: should probably not be inline
40 static inline void input_item_Init( vlc_object_t *p_o, input_item_t *p_i )
42 memset( p_i, 0, sizeof(input_item_t) );
46 TAB_INIT( p_i->i_es, p_i->es );
47 TAB_INIT( p_i->i_options, p_i->ppsz_options );
48 p_i->optflagv = NULL, p_i->optflagc = 0;
49 TAB_INIT( p_i->i_categories, p_i->pp_categories );
51 p_i->i_type = ITEM_TYPE_UNKNOWN;
52 p_i->b_fixed_name = true;
57 vlc_mutex_init( &p_i->lock );
58 vlc_event_manager_t * p_em = &p_i->event_manager;
59 vlc_event_manager_init( p_em, p_i, p_o );
60 vlc_event_manager_register_event_type( p_em, vlc_InputItemMetaChanged );
61 vlc_event_manager_register_event_type( p_em, vlc_InputItemSubItemAdded );
62 vlc_event_manager_register_event_type( p_em, vlc_InputItemDurationChanged );
63 vlc_event_manager_register_event_type( p_em, vlc_InputItemPreparsedChanged );
64 vlc_event_manager_register_event_type( p_em, vlc_InputItemNameChanged );
65 vlc_event_manager_register_event_type( p_em, vlc_InputItemInfoChanged );
66 vlc_event_manager_register_event_type( p_em, vlc_InputItemErrorWhenReadingChanged );
69 static inline void input_item_Clean( input_item_t *p_i )
73 vlc_event_manager_fini( &p_i->event_manager );
75 free( p_i->psz_name );
79 vlc_mutex_destroy( &p_i->p_stats->lock );
84 vlc_meta_Delete( p_i->p_meta );
86 for( i = 0; i < p_i->i_options; i++ )
87 free( p_i->ppsz_options[i] );
88 TAB_CLEAN( p_i->i_options, p_i->ppsz_options );
91 for( i = 0; i < p_i->i_es; i++ )
93 es_format_Clean( p_i->es[i] );
96 TAB_CLEAN( p_i->i_es, p_i->es );
98 for( i = 0; i < p_i->i_categories; i++ )
100 info_category_t *p_category = p_i->pp_categories[i];
103 for( j = 0; j < p_category->i_infos; j++ )
105 struct info_t *p_info = p_category->pp_infos[j];
107 free( p_info->psz_name);
108 free( p_info->psz_value );
111 TAB_CLEAN( p_category->i_infos, p_category->pp_infos );
113 free( p_category->psz_name );
116 TAB_CLEAN( p_i->i_categories, p_i->pp_categories );
118 vlc_mutex_destroy( &p_i->lock );
120 void input_item_SetErrorWhenReading( input_item_t *p_i, bool b_error )
124 vlc_mutex_lock( &p_i->lock );
126 b_changed = p_i->b_error_when_reading != b_error;
127 p_i->b_error_when_reading = b_error;
129 vlc_mutex_unlock( &p_i->lock );
135 event.type = vlc_InputItemErrorWhenReadingChanged;
136 event.u.input_item_error_when_reading_changed.new_value = b_error;
137 vlc_event_send( &p_i->event_manager, &event );
140 void input_item_SetPreparsed( input_item_t *p_i, bool b_preparsed )
142 bool b_send_event = false;
144 vlc_mutex_lock( &p_i->lock );
147 p_i->p_meta = vlc_meta_New();
151 i_new_status = p_i->p_meta->i_status | ITEM_PREPARSED;
153 i_new_status = p_i->p_meta->i_status & ~ITEM_PREPARSED;
154 if( p_i->p_meta->i_status != i_new_status )
156 p_i->p_meta->i_status = i_new_status;
160 vlc_mutex_unlock( &p_i->lock );
165 event.type = vlc_InputItemPreparsedChanged;
166 event.u.input_item_preparsed_changed.new_status = i_new_status;
167 vlc_event_send( &p_i->event_manager, &event );
170 void input_item_SetArtNotFound( input_item_t *p_i, bool b_not_found )
172 vlc_mutex_lock( &p_i->lock );
175 p_i->p_meta = vlc_meta_New();
178 p_i->p_meta->i_status |= ITEM_ART_NOTFOUND;
180 p_i->p_meta->i_status &= ~ITEM_ART_NOTFOUND;
182 vlc_mutex_unlock( &p_i->lock );
184 void input_item_SetArtFetched( input_item_t *p_i, bool b_art_fetched )
186 vlc_mutex_lock( &p_i->lock );
189 p_i->p_meta = vlc_meta_New();
192 p_i->p_meta->i_status |= ITEM_ART_FETCHED;
194 p_i->p_meta->i_status &= ~ITEM_ART_FETCHED;
196 vlc_mutex_unlock( &p_i->lock );
199 void input_item_SetMeta( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz_val )
203 vlc_mutex_lock( &p_i->lock );
205 p_i->p_meta = vlc_meta_New();
206 vlc_meta_Set( p_i->p_meta, meta_type, psz_val );
207 vlc_mutex_unlock( &p_i->lock );
209 /* Notify interested third parties */
210 event.type = vlc_InputItemMetaChanged;
211 event.u.input_item_meta_changed.meta_type = meta_type;
212 vlc_event_send( &p_i->event_manager, &event );
215 /* FIXME GRRRRRRRRRR args should be in the reverse order to be
216 * consistant with (nearly?) all or copy funcs */
217 void input_item_CopyOptions( input_item_t *p_parent,
218 input_item_t *p_child )
220 vlc_mutex_lock( &p_parent->lock );
222 for( int i = 0 ; i< p_parent->i_options; i++ )
224 if( !strcmp( p_parent->ppsz_options[i], "meta-file" ) )
227 input_item_AddOption( p_child,
228 p_parent->ppsz_options[i],
229 p_parent->optflagv[i] );
232 vlc_mutex_unlock( &p_parent->lock );
235 /* This won't hold the item, but can tell to interested third parties
236 * Like the playlist, that there is a new sub item. With this design
237 * It is not the input item's responsability to keep all the ref of
238 * the input item children. */
239 void input_item_AddSubItem( input_item_t *p_parent, input_item_t *p_child )
241 vlc_mutex_lock( &p_parent->lock );
243 p_parent->i_type = ITEM_TYPE_PLAYLIST;
245 vlc_mutex_unlock( &p_parent->lock );
247 /* Notify interested third parties */
250 event.type = vlc_InputItemSubItemAdded;
251 event.u.input_item_subitem_added.p_new_child = p_child;
252 vlc_event_send( &p_parent->event_manager, &event );
255 bool input_item_HasErrorWhenReading( input_item_t *p_item )
257 vlc_mutex_lock( &p_item->lock );
259 bool b_error = p_item->b_error_when_reading;
261 vlc_mutex_unlock( &p_item->lock );
266 bool input_item_MetaMatch( input_item_t *p_i,
267 vlc_meta_type_t meta_type, const char *psz )
269 vlc_mutex_lock( &p_i->lock );
273 vlc_mutex_unlock( &p_i->lock );
276 const char *psz_meta = vlc_meta_Get( p_i->p_meta, meta_type );
277 bool b_ret = psz_meta && strcasestr( psz_meta, psz );
279 vlc_mutex_unlock( &p_i->lock );
284 char *input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type )
286 vlc_mutex_lock( &p_i->lock );
290 vlc_mutex_unlock( &p_i->lock );
295 if( vlc_meta_Get( p_i->p_meta, meta_type ) )
296 psz = strdup( vlc_meta_Get( p_i->p_meta, meta_type ) );
298 vlc_mutex_unlock( &p_i->lock );
302 /* Get the title of a given item or fallback to the name if the title is empty */
303 char *input_item_GetTitleFbName( input_item_t *p_item )
306 vlc_mutex_lock( &p_item->lock );
308 if( !p_item->p_meta )
310 psz_ret = p_item->psz_name ? strdup( p_item->psz_name ) : NULL;
311 vlc_mutex_unlock( &p_item->lock );
315 const char *psz_title = vlc_meta_Get( p_item->p_meta, vlc_meta_Title );
316 if( !EMPTY_STR( psz_title ) )
317 psz_ret = strdup( psz_title );
319 psz_ret = p_item->psz_name ? strdup( p_item->psz_name ) : NULL;
321 vlc_mutex_unlock( &p_item->lock );
325 char *input_item_GetName( input_item_t *p_item )
327 vlc_mutex_lock( &p_item->lock );
329 char *psz_name = p_item->psz_name ? strdup( p_item->psz_name ) : NULL;
331 vlc_mutex_unlock( &p_item->lock );
334 void input_item_SetName( input_item_t *p_item, const char *psz_name )
336 vlc_mutex_lock( &p_item->lock );
338 free( p_item->psz_name );
339 p_item->psz_name = strdup( psz_name );
341 vlc_mutex_unlock( &p_item->lock );
344 char *input_item_GetURI( input_item_t *p_i )
346 vlc_mutex_lock( &p_i->lock );
348 char *psz_s = p_i->psz_uri ? strdup( p_i->psz_uri ) : NULL;
350 vlc_mutex_unlock( &p_i->lock );
353 void input_item_SetURI( input_item_t *p_i, const char *psz_uri )
355 vlc_mutex_lock( &p_i->lock );
357 if( !strstr( psz_uri, "://" ) || strstr( psz_uri, " " ) || strstr( psz_uri, "\"" ) )
358 fprintf( stderr, "input_item_SetURI() was likely called with a path. FIXME\n" );
361 free( p_i->psz_uri );
362 p_i->psz_uri = strdup( psz_uri );
364 p_i->i_type = GuessType( p_i );
366 if( !p_i->psz_name && p_i->i_type == ITEM_TYPE_FILE )
368 const char *psz_filename = strrchr( p_i->psz_uri, '/' );
370 if( psz_filename && *psz_filename == '/' )
372 if( psz_filename && *psz_filename )
373 p_i->psz_name = strdup( psz_filename );
375 /* Make the name more readable */
377 decode_URI( p_i->psz_name );
380 /* The name is NULL: fill it with everything except login and password */
385 vlc_UrlParse( &url, psz_uri, 0 );
386 if( url.psz_protocol )
389 r=asprintf( &p_i->psz_name, "%s://%s:%d%s", url.psz_protocol,
390 url.psz_host, url.i_port,
391 url.psz_path ? url.psz_path : "" );
393 r=asprintf( &p_i->psz_name, "%s://%s%s", url.psz_protocol,
394 url.psz_host ? url.psz_host : "",
395 url.psz_path ? url.psz_path : "" );
400 r=asprintf( &p_i->psz_name, "%s:%d%s", url.psz_host, url.i_port,
401 url.psz_path ? url.psz_path : "" );
403 r=asprintf( &p_i->psz_name, "%s%s", url.psz_host,
404 url.psz_path ? url.psz_path : "" );
406 vlc_UrlClean( &url );
408 p_i->psz_name=NULL; /* recover from undefined value */
410 /* Make the name more readable */
412 decode_URI( p_i->psz_name );
415 vlc_mutex_unlock( &p_i->lock );
418 mtime_t input_item_GetDuration( input_item_t *p_i )
420 vlc_mutex_lock( &p_i->lock );
422 mtime_t i_duration = p_i->i_duration;
424 vlc_mutex_unlock( &p_i->lock );
428 void input_item_SetDuration( input_item_t *p_i, mtime_t i_duration )
430 bool b_send_event = false;
432 vlc_mutex_lock( &p_i->lock );
433 if( p_i->i_duration != i_duration )
435 p_i->i_duration = i_duration;
438 vlc_mutex_unlock( &p_i->lock );
444 event.type = vlc_InputItemDurationChanged;
445 event.u.input_item_duration_changed.new_duration = i_duration;
446 vlc_event_send( &p_i->event_manager, &event );
451 bool input_item_IsPreparsed( input_item_t *p_item )
453 vlc_mutex_lock( &p_item->lock );
454 bool b_preparsed = p_item->p_meta ? ( p_item->p_meta->i_status & ITEM_PREPARSED ) != 0 : false;
455 vlc_mutex_unlock( &p_item->lock );
460 bool input_item_IsArtFetched( input_item_t *p_item )
462 vlc_mutex_lock( &p_item->lock );
463 bool b_fetched = p_item->p_meta ? ( p_item->p_meta->i_status & ITEM_ART_FETCHED ) != 0 : false;
464 vlc_mutex_unlock( &p_item->lock );
469 static void input_item_Destroy ( gc_object_t *p_gc )
471 input_item_t *p_item = vlc_priv( p_gc, input_item_t );
473 input_item_Clean( p_item );
477 int input_item_AddOption( input_item_t *p_input, const char *psz_option,
480 int err = VLC_SUCCESS;
482 if( psz_option == NULL )
485 vlc_mutex_lock( &p_input->lock );
486 if (flags & VLC_INPUT_OPTION_UNIQUE)
488 for (int i = 0 ; i < p_input->i_options; i++)
489 if( !strcmp( p_input->ppsz_options[i], psz_option ) )
493 uint8_t *flagv = realloc (p_input->optflagv, p_input->optflagc + 1);
499 p_input->optflagv = flagv;
500 flagv[p_input->optflagc++] = flags;
502 INSERT_ELEM( p_input->ppsz_options, p_input->i_options,
503 p_input->i_options, strdup( psz_option ) );
505 vlc_mutex_unlock( &p_input->lock );
510 * Get a info item from a given category in a given input item.
512 * \param p_i The input item to get info from
513 * \param psz_cat String representing the category for the info
514 * \param psz_name String representing the name of the desired info
515 * \return A pointer to the string with the given info if found, or an
516 * empty string otherwise. The caller should free the returned
519 char *input_item_GetInfo( input_item_t *p_i,
521 const char *psz_name )
523 vlc_mutex_lock( &p_i->lock );
525 for( int i = 0; i< p_i->i_categories; i++ )
527 const info_category_t *p_cat = p_i->pp_categories[i];
529 if( !psz_cat || strcmp( p_cat->psz_name, psz_cat ) )
532 for( int j = 0; j < p_cat->i_infos; j++ )
534 if( !strcmp( p_cat->pp_infos[j]->psz_name, psz_name ) )
536 char *psz_ret = strdup( p_cat->pp_infos[j]->psz_value );
537 vlc_mutex_unlock( &p_i->lock );
542 vlc_mutex_unlock( &p_i->lock );
546 static int InputItemVaAddInfo( input_item_t *p_i,
548 const char *psz_name,
549 const char *psz_format, va_list args )
552 info_t *p_info = NULL;
553 info_category_t *p_cat = NULL ;
555 vlc_assert_locked( &p_i->lock );
557 for( i = 0 ; i < p_i->i_categories ; i ++ )
559 if( !strcmp( p_i->pp_categories[i]->psz_name, psz_cat ) )
561 p_cat = p_i->pp_categories[i];
567 if( !(p_cat = malloc( sizeof(*p_cat) )) )
570 p_cat->psz_name = strdup( psz_cat );
573 INSERT_ELEM( p_i->pp_categories, p_i->i_categories, p_i->i_categories,
577 for( i = 0; i< p_cat->i_infos; i++ )
579 if( !strcmp( p_cat->pp_infos[i]->psz_name, psz_name ) )
581 p_info = p_cat->pp_infos[i];
588 if( ( p_info = malloc( sizeof( *p_info ) ) ) == NULL )
591 INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos, p_cat->i_infos, p_info );
592 p_info->psz_name = strdup( psz_name );
596 free( p_info->psz_value );
599 if( vasprintf( &p_info->psz_value, psz_format, args ) == -1 )
600 p_info->psz_value = NULL;
602 return p_info->psz_value ? VLC_SUCCESS : VLC_ENOMEM;
605 static int InputItemAddInfo( input_item_t *p_i,
607 const char *psz_name,
608 const char *psz_format, ... )
612 va_start( args, psz_format );
613 const int i_ret = InputItemVaAddInfo( p_i, psz_cat, psz_name, psz_format, args );
619 int input_item_AddInfo( input_item_t *p_i,
621 const char *psz_name,
622 const char *psz_format, ... )
626 vlc_mutex_lock( &p_i->lock );
628 va_start( args, psz_format );
629 const int i_ret = InputItemVaAddInfo( p_i, psz_cat, psz_name, psz_format, args );
632 vlc_mutex_unlock( &p_i->lock );
639 event.type = vlc_InputItemInfoChanged;
640 vlc_event_send( &p_i->event_manager, &event );
645 int input_item_DelInfo( input_item_t *p_i,
647 const char *psz_name )
649 info_category_t *p_cat = NULL;
653 vlc_mutex_lock( &p_i->lock );
654 for( i_cat = 0; i_cat < p_i->i_categories; i_cat++ )
656 if( !strcmp( p_i->pp_categories[i_cat]->psz_name,
659 p_cat = p_i->pp_categories[i_cat];
665 vlc_mutex_unlock( &p_i->lock );
671 /* Remove a specific info */
672 for( i = 0; i < p_cat->i_infos; i++ )
674 if( !strcmp( p_cat->pp_infos[i]->psz_name, psz_name ) )
676 free( p_cat->pp_infos[i]->psz_name );
677 free( p_cat->pp_infos[i]->psz_value );
678 free( p_cat->pp_infos[i] );
679 REMOVE_ELEM( p_cat->pp_infos, p_cat->i_infos, i );
683 if( i >= p_cat->i_infos )
685 vlc_mutex_unlock( &p_i->lock );
691 /* Remove the complete categorie */
692 for( i = 0; i < p_cat->i_infos; i++ )
694 free( p_cat->pp_infos[i]->psz_name );
695 free( p_cat->pp_infos[i]->psz_value );
696 free( p_cat->pp_infos[i] );
698 free( p_cat->pp_infos );
699 REMOVE_ELEM( p_i->pp_categories, p_i->i_categories, i_cat );
703 free( p_cat->psz_name );
705 vlc_mutex_unlock( &p_i->lock );
709 event.type = vlc_InputItemInfoChanged;
710 vlc_event_send( &p_i->event_manager, &event );
715 void input_item_SetEpg( input_item_t *p_item,
716 const char *psz_epg, const vlc_epg_t *p_epg )
718 input_item_DelInfo( p_item, psz_epg, NULL );
720 #ifdef HAVE_LOCALTIME_R
721 vlc_mutex_lock( &p_item->lock );
722 for( int i = 0; i < p_epg->i_event; i++ )
724 const vlc_epg_event_t *p_evt = p_epg->pp_event[i];
725 time_t t_start = (time_t)p_evt->i_start;
729 localtime_r( &t_start, &tm_start );
731 snprintf( psz_start, sizeof(psz_start), "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d",
732 1900 + tm_start.tm_year, 1 + tm_start.tm_mon, tm_start.tm_mday,
733 tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec );
734 if( p_evt->psz_short_description || p_evt->psz_description )
735 InputItemAddInfo( p_item, psz_epg, psz_start, "%s (%2.2d:%2.2d) - %s",
737 p_evt->i_duration/60/60, (p_evt->i_duration/60)%60,
738 p_evt->psz_short_description ? p_evt->psz_short_description : p_evt->psz_description );
740 InputItemAddInfo( p_item, psz_epg, psz_start, "%s (%2.2d:%2.2d)",
742 p_evt->i_duration/60/60, (p_evt->i_duration/60)%60 );
744 vlc_mutex_unlock( &p_item->lock );
746 if( p_epg->i_event > 0 )
750 event.type = vlc_InputItemInfoChanged;
751 vlc_event_send( &p_item->event_manager, &event );
757 input_item_t *__input_item_NewExt( vlc_object_t *p_obj, const char *psz_uri,
758 const char *psz_name,
760 const char *const *ppsz_options,
761 unsigned i_option_flags,
764 return input_item_NewWithType( p_obj, psz_uri, psz_name,
765 i_options, ppsz_options, i_option_flags,
766 i_duration, ITEM_TYPE_UNKNOWN );
770 input_item_t *input_item_NewWithType( vlc_object_t *p_obj, const char *psz_uri,
771 const char *psz_name,
773 const char *const *ppsz_options,
774 unsigned i_option_flags,
778 libvlc_priv_t *priv = libvlc_priv (p_obj->p_libvlc);
779 static vlc_mutex_t input_id_lock = VLC_STATIC_MUTEX;
781 input_item_t* p_input = malloc( sizeof(input_item_t ) );
785 input_item_Init( p_obj, p_input );
786 vlc_gc_init( p_input, input_item_Destroy );
788 vlc_mutex_lock( &input_id_lock );
789 p_input->i_id = ++priv->i_last_input_id;
790 vlc_mutex_unlock( &input_id_lock );
792 p_input->b_fixed_name = false;
794 p_input->i_type = i_type;
795 p_input->b_prefers_tree = false;
798 input_item_SetURI( p_input, psz_uri );
800 if( i_type != ITEM_TYPE_UNKNOWN )
801 p_input->i_type = i_type;
804 input_item_SetName( p_input, psz_name );
806 p_input->i_duration = i_duration;
808 for( int i = 0; i < i_options; i++ )
809 input_item_AddOption( p_input, ppsz_options[i], i_option_flags );
813 struct item_type_entry
815 const char psz_scheme[7];
819 static int typecmp( const void *key, const void *entry )
821 const struct item_type_entry *type = entry;
822 const char *uri = key, *scheme = type->psz_scheme;
824 return strncmp( uri, scheme, strlen( scheme ) );
827 /* Guess the type of the item using the beginning of the mrl */
828 static int GuessType( const input_item_t *p_item )
830 static const struct item_type_entry tab[] =
831 { /* /!\ Alphabetical order /!\ */
832 /* Short match work, not just exact match */
833 { "alsa", ITEM_TYPE_CARD },
834 { "atsc", ITEM_TYPE_CARD },
835 { "bd", ITEM_TYPE_DISC },
836 { "cable", ITEM_TYPE_CARD },
837 { "cdda", ITEM_TYPE_CDDA },
838 { "dc1394", ITEM_TYPE_CARD },
839 { "dccp", ITEM_TYPE_NET },
840 { "dir", ITEM_TYPE_DIRECTORY },
841 { "dshow", ITEM_TYPE_CARD },
842 { "dv", ITEM_TYPE_CARD },
843 { "dvb", ITEM_TYPE_CARD },
844 { "dvd", ITEM_TYPE_DISC },
845 { "ftp", ITEM_TYPE_NET },
846 { "http", ITEM_TYPE_NET },
847 { "icyx", ITEM_TYPE_NET },
848 { "itpc", ITEM_TYPE_NET },
849 { "jack", ITEM_TYPE_CARD },
850 { "live", ITEM_TYPE_NET }, /* livedotcom */
851 { "mms", ITEM_TYPE_NET },
852 { "mtp", ITEM_TYPE_DISC },
853 { "ofdm", ITEM_TYPE_CARD },
854 { "oss", ITEM_TYPE_CARD },
855 { "pnm", ITEM_TYPE_NET },
856 { "pvr", ITEM_TYPE_CARD },
857 { "qam", ITEM_TYPE_CARD },
858 { "qpsk", ITEM_TYPE_CARD },
859 { "qtcapt", ITEM_TYPE_CARD }, /* qtcapture */
860 { "raw139", ITEM_TYPE_CARD }, /* raw1394 */
861 { "rt", ITEM_TYPE_NET }, /* rtp, rtsp, rtmp */
862 { "satell", ITEM_TYPE_CARD }, /* sattelite */
863 { "screen", ITEM_TYPE_CARD },
864 { "sdp", ITEM_TYPE_NET },
865 { "smb", ITEM_TYPE_NET },
866 { "svcd", ITEM_TYPE_DISC },
867 { "tcp", ITEM_TYPE_NET },
868 { "terres", ITEM_TYPE_CARD }, /* terrestrial */
869 { "udp", ITEM_TYPE_NET }, /* udplite too */
870 { "unsv", ITEM_TYPE_NET },
871 { "usdigi", ITEM_TYPE_CARD }, /* usdigital */
872 { "v4l", ITEM_TYPE_CARD },
873 { "vcd", ITEM_TYPE_DISC },
874 { "window", ITEM_TYPE_CARD },
876 const struct item_type_entry *e;
878 if( !strstr( p_item->psz_uri, "://" ) )
879 return ITEM_TYPE_FILE;
881 e = bsearch( p_item->psz_uri, tab, sizeof( tab ) / sizeof( tab[0] ),
882 sizeof( tab[0] ), typecmp );
883 return e ? e->i_type : ITEM_TYPE_FILE;