static int InputItemVaAddInfo( input_item_t *p_i, const char *psz_cat, const char *psz_name, const char *psz_format, va_list args ) { vlc_assert_locked( &p_i->lock ); info_category_t *p_cat = InputItemFindCat( p_i, NULL, psz_cat ); if( !p_cat ) { p_cat = info_category_New( psz_cat ); if( !p_cat ) return VLC_ENOMEM; INSERT_ELEM( (info_category_t **), p_i->pp_categories, p_i->i_categories, p_i->i_categories, // sunqueen modify p_cat ); }
/** * Get a info item from a given category in a given input item. * * \param p_i The input item to get info from * \param psz_cat String representing the category for the info * \param psz_name String representing the name of the desired info * \return A pointer to the string with the given info if found, or an * empty string otherwise. The caller should free the returned * pointer. */ char *input_item_GetInfo( input_item_t *p_i, const char *psz_cat, const char *psz_name ) { vlc_mutex_lock( &p_i->lock ); const info_category_t *p_cat = InputItemFindCat( p_i, NULL, psz_cat ); if( p_cat ) { info_t *p_info = info_category_FindInfo( p_cat, NULL, psz_name ); if( p_info && p_info->psz_value ) { char *psz_ret = strdup( p_info->psz_value ); vlc_mutex_unlock( &p_i->lock ); return psz_ret; } } vlc_mutex_unlock( &p_i->lock ); return strdup( "" ); }
static int InputItemVaAddInfo( input_item_t *p_i, const char *psz_cat, const char *psz_name, const char *psz_format, va_list args ) { vlc_assert_locked( &p_i->lock ); info_category_t *p_cat = InputItemFindCat( p_i, NULL, psz_cat ); if( !p_cat ) { p_cat = info_category_New( psz_cat ); if( !p_cat ) return VLC_ENOMEM; INSERT_ELEM( p_i->pp_categories, p_i->i_categories, p_i->i_categories, p_cat ); } info_t *p_info = info_category_VaAddInfo( p_cat, psz_name, psz_format, args ); if( !p_info || !p_info->psz_value ) return VLC_EGENERIC; return VLC_SUCCESS; }
void input_item_ReplaceInfos( input_item_t *p_item, info_category_t *p_cat ) { vlc_mutex_lock( &p_item->lock ); int i_cat; info_category_t *p_old = InputItemFindCat( p_item, &i_cat, p_cat->psz_name ); if( p_old ) { info_category_Delete( p_old ); p_item->pp_categories[i_cat] = p_cat; } else { INSERT_ELEM( p_item->pp_categories, p_item->i_categories, p_item->i_categories, p_cat ); } vlc_mutex_unlock( &p_item->lock ); vlc_event_t event; event.type = vlc_InputItemInfoChanged; vlc_event_send( &p_item->event_manager, &event ); }
int input_item_DelInfo( input_item_t *p_i, const char *psz_cat, const char *psz_name ) { vlc_mutex_lock( &p_i->lock ); int i_cat; info_category_t *p_cat = InputItemFindCat( p_i, &i_cat, psz_cat ); if( !p_cat ) { vlc_mutex_unlock( &p_i->lock ); return VLC_EGENERIC; } if( psz_name ) { /* Remove a specific info */ int i_ret = info_category_DeleteInfo( p_cat, psz_name ); if( i_ret ) { vlc_mutex_unlock( &p_i->lock ); return VLC_EGENERIC; } } else { /* Remove the complete categorie */ info_category_Delete( p_cat ); REMOVE_ELEM( p_i->pp_categories, p_i->i_categories, i_cat ); } vlc_mutex_unlock( &p_i->lock ); vlc_event_t event; event.type = vlc_InputItemInfoChanged; vlc_event_send( &p_i->event_manager, &event ); return VLC_SUCCESS; }
void input_item_MergeInfos( input_item_t *p_item, info_category_t *p_cat ) { vlc_mutex_lock( &p_item->lock ); info_category_t *p_old = InputItemFindCat( p_item, NULL, p_cat->psz_name ); if( p_old ) { for( int i = 0; i < p_cat->i_infos; i++ ) info_category_ReplaceInfo( p_old, p_cat->pp_infos[i] ); TAB_CLEAN( p_cat->i_infos, p_cat->pp_infos ); info_category_Delete( p_cat ); } else { INSERT_ELEM( p_item->pp_categories, p_item->i_categories, p_item->i_categories, p_cat ); } vlc_mutex_unlock( &p_item->lock ); vlc_event_t event; event.type = vlc_InputItemInfoChanged; vlc_event_send( &p_item->event_manager, &event ); }