Changeset e398a81bd261feaada934e7b402b5fed57646593

Show
Ignore:
Timestamp:
24/09/06 22:51:56 (2 years ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1159131116 +0000
git-parent:

[6d6d53e143b6c8b39fb6fab0099ee39b2fea5ee3]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1159131116 +0000
Message:

Some more meta changes (mostly cleanup and check the i_mandatory flags)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_input.h

    rbd3484b re398a81  
    539539VLC_EXPORT( vlc_bool_t, input_AddSubtitles, ( input_thread_t *, char *, vlc_bool_t ) ); 
    540540 
     541VLC_EXPORT( int, input_DownloadAndCacheArt, ( vlc_object_t *p_parent, input_item_t *p_item ) ); 
     542 
     543 
    541544#endif 
  • include/vlc_meta.h

    rbd3484b re398a81  
    226226}; 
    227227 
     228VLC_EXPORT( uint32_t, input_GetMetaEngineFlags, ( vlc_meta_t *p_meta ) ); 
     229 
    228230#endif 
  • include/vlc_symbols.h

    rbd3484b re398a81  
    545545    void (*input_ItemAddOptionNoDup_inner) (input_item_t *, const char *); 
    546546    int (*__input_MetaFetch_inner) (vlc_object_t *, input_item_t *); 
     547    int (*input_DownloadAndCacheArt_inner) (vlc_object_t *p_parent, input_item_t *p_item); 
     548    uint32_t (*input_GetMetaEngineFlags_inner) (vlc_meta_t *p_meta); 
    547549}; 
    548550# if defined (__PLUGIN__) 
     
    10191021#  define input_ItemAddOptionNoDup (p_symbols)->input_ItemAddOptionNoDup_inner 
    10201022#  define __input_MetaFetch (p_symbols)->__input_MetaFetch_inner 
     1023#  define input_DownloadAndCacheArt (p_symbols)->input_DownloadAndCacheArt_inner 
     1024#  define input_GetMetaEngineFlags (p_symbols)->input_GetMetaEngineFlags_inner 
    10211025# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) 
    10221026/****************************************************************** 
     
    14961500    ((p_symbols)->input_ItemAddOptionNoDup_inner) = input_ItemAddOptionNoDup; \ 
    14971501    ((p_symbols)->__input_MetaFetch_inner) = __input_MetaFetch; \ 
     1502    ((p_symbols)->input_DownloadAndCacheArt_inner) = input_DownloadAndCacheArt; \ 
     1503    ((p_symbols)->input_GetMetaEngineFlags_inner) = input_GetMetaEngineFlags; \ 
    14981504    (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ 
    14991505    (p_symbols)->vlc_input_item_GetInfo_deprecated = NULL; \ 
  • modules/meta_engine/Modules.am

    rb45afc2 re398a81  
    11SOURCES_musicbrainz = musicbrainz.c 
    2 SOURCES_dummy = dummy.c 
    32SOURCES_folder = folder.c 
    43SOURCES_taglib = taglib.cpp 
  • modules/meta_engine/folder.c

    r6d6d53e re398a81  
    6868    input_item_t *p_item = p_me->p_item; 
    6969    vlc_bool_t b_have_art = VLC_FALSE; 
     70    uint32_t i_meta; 
    7071 
    7172    if( !p_item->p_meta ) return VLC_EGENERIC; 
     
    124125    } 
    125126 
    126     return VLC_SUCCESS; 
     127    i_meta = input_GetMetaEngineFlags( p_item->p_meta ); 
     128    p_me->i_mandatory &= ~i_meta; 
     129    p_me->i_optional &= ~i_meta; 
     130    if( p_me->i_mandatory ) 
     131        return VLC_EGENERIC; 
     132    else 
     133        return VLC_SUCCESS; 
    127134} 
  • modules/meta_engine/musicbrainz.c

    r6d6d53e re398a81  
    6868    char i_album_count, i; 
    6969    char *ppsz_args[4]; 
     70    uint32_t i_meta; 
    7071 
    7172    if( !p_item->p_meta ) return VLC_EGENERIC; 
     
    133134    mb_Delete( p_mb ); 
    134135 
    135     return VLC_SUCCESS; 
     136    i_meta = input_GetMetaEngineFlags( p_item->p_meta ); 
     137    p_me->i_mandatory &= ~i_meta; 
     138    p_me->i_optional &= ~i_meta; 
     139    if( p_me->i_mandatory ) 
     140        return VLC_EGENERIC; 
     141    else 
     142        return VLC_SUCCESS; 
    136143} 
  • src/input/meta.c

    rbd3484b re398a81  
    3333#endif 
    3434 
     35int input_FindArt( vlc_object_t *p_parent, input_item_t *p_item ); 
     36 
    3537int __input_MetaFetch( vlc_object_t *p_parent, input_item_t *p_item ) 
    3638{ 
    3739    struct meta_engine_t *p_me; 
    38  
    39     /* FIXME: don't launch any module if we already have all the needed 
    40      * info. Easiest way to do this would be to add a dummy module. 
    41      * I'll do that later */ 
     40    uint32_t i_mandatory = 0, i_optional = 0, i_meta; 
     41    int i_policy; 
     42 
     43    if( !p_item->p_meta ) return VLC_EGENERIC; 
     44 
     45    i_policy = var_CreateGetInteger( p_parent, "album-art" ); 
     46 
     47    i_mandatory =   VLC_META_ENGINE_TITLE 
     48                  | VLC_META_ENGINE_ARTIST; 
     49    if( i_policy == ALBUM_ART_ALL ) 
     50    { 
     51        i_mandatory |= VLC_META_ENGINE_ART_URL; 
     52    } 
     53    else 
     54    { 
     55        i_optional |= VLC_META_ENGINE_ART_URL; 
     56    } 
     57 
     58    input_FindArt( p_parent, p_item ); 
     59 
     60    i_meta = input_GetMetaEngineFlags( p_item->p_meta ); 
     61    i_mandatory &= ~i_meta; 
     62    i_optional &= ~i_meta; 
     63 
     64    if( !i_mandatory ) return VLC_SUCCESS; 
    4265 
    4366    p_me = vlc_object_create( p_parent, VLC_OBJECT_META_ENGINE ); 
    4467    p_me->i_flags |= OBJECT_FLAGS_NOINTERACT; 
    45     p_me->i_mandatory =   VLC_META_ENGINE_TITLE 
    46                         | VLC_META_ENGINE_ARTIST; 
    47     p_me->i_optional = 0; 
    48 /* 
    49     if( var_CreateGetInteger( p_parent, "album-art" ) != ALBUM_ART_NEVER ) 
    50     { 
    51         p_me->i_mandatory |= VLC_META_ENGINE_ART_URL; 
    52     } 
    53     else 
    54     { 
    55         p_me->i_optional |= VLC_META_ENGINE_ART_URL; 
    56     } 
    57 */ 
     68    p_me->i_mandatory = i_mandatory; 
     69    p_me->i_optional = i_optional; 
     70 
    5871    p_me->p_item = p_item; 
    5972    p_me->p_module = module_Need( p_me, "meta fetcher", 0, VLC_FALSE ); 
     
    6174    if( !p_me->p_module ) 
    6275    { 
    63         msg_Err( p_parent, "no suitable meta engine module" ); 
     76        msg_Err( p_parent, "no suitable meta fetcher module" ); 
    6477        vlc_object_detach( p_me ); 
    6578        vlc_object_destroy( p_me ); 
     
    6982    module_Unneed( p_me, p_me->p_module ); 
    7083 
     84    vlc_object_detach( p_me ); 
    7185    vlc_object_destroy( p_me ); 
    7286 
     
    8397    char *psz_type; 
    8498    char psz_filename[MAX_PATH]; 
    85     int i_ret
     99    int i
    86100    struct stat a; 
     101    const char ppsz_type[] = { ".jpg", ".png", ".gif", ".bmp", "" }; 
    87102 
    88103    if( !p_item->p_meta ) return VLC_EGENERIC; 
     
    91106    psz_album = p_item->p_meta->psz_album; 
    92107 
    93     //FIXME !!!!! 
    94     psz_type = strdup( "jpg" ); 
    95  
    96     snprintf( psz_filename, MAX_PATH, 
    97               "file://%s" DIR_SEP CONFIG_DIR DIR_SEP "art" 
    98               DIR_SEP "%s" DIR_SEP "%s" DIR_SEP "art%s", 
    99               p_parent->p_libvlc->psz_homedir, 
    100               psz_artist, psz_album, psz_type ); 
    101  
    102     /* Check if file exists */ 
    103     i_ret = utf8_stat( psz_filename+7, &a ); 
    104     if( i_ret == 0 ) 
    105     { 
    106         msg_Dbg( p_parent, "album art %s already exists in cache" 
    107                          , psz_filename ); 
    108         return VLC_SUCCESS; 
    109     } 
    110     else 
    111     { 
    112         /* Use a art finder module to find the URL */ 
    113         return VLC_EGENERIC; 
    114     } 
     108    for( i = 0; i < 5; i++ ) 
     109    { 
     110        snprintf( psz_filename, MAX_PATH, 
     111                  "file://%s" DIR_SEP CONFIG_DIR DIR_SEP "art" 
     112                  DIR_SEP "%s" DIR_SEP "%s" DIR_SEP "art%s", 
     113                  p_parent->p_libvlc->psz_homedir, 
     114                  psz_artist, psz_album, psz_type ); 
     115 
     116        /* Check if file exists */ 
     117        if( utf8_stat( psz_filename+7, &a ) == 0 ) 
     118        { 
     119            msg_Dbg( p_parent, "album art %s already exists in cache" 
     120                             , psz_filename ); 
     121            return VLC_SUCCESS; 
     122        } 
     123    } 
     124 
     125    /* Use a art finder module to find the URL */ 
     126    return VLC_EGENERIC; 
    115127} 
    116128 
     
    122134{ 
    123135    int i_status = VLC_EGENERIC; 
    124     int i_ret; 
    125     struct stat a; 
    126136    stream_t *p_stream; 
    127137    char psz_filename[MAX_PATH], psz_dir[MAX_PATH]; 
     
    136146                        || !*p_item->p_meta->psz_arturl ) 
    137147        return VLC_EGENERIC; 
     148 
     149    psz_type = strrchr( p_item->p_meta->psz_arturl, '.' ); 
    138150 
    139151    /* Todo: get a helper to do this */ 
     
    182194    return i_status; 
    183195} 
     196 
     197uint32_t input_GetMetaEngineFlags( vlc_meta_t *p_meta ) 
     198{ 
     199    uint32_t i_meta = 0; 
     200 
     201#define CHECK( a, b ) \ 
     202    if( p_meta->psz_ ## a && *p_meta->psz_ ## a ) \ 
     203        i_meta |= VLC_META_ENGINE_ ## b; 
     204 
     205    CHECK( title, TITLE ) 
     206    CHECK( author, AUTHOR ) 
     207    CHECK( artist, ARTIST ) 
     208    CHECK( genre, GENRE ) 
     209    CHECK( copyright, COPYRIGHT ) 
     210    CHECK( album, COLLECTION ) 
     211    CHECK( tracknum, SEQ_NUM ) 
     212    CHECK( description, DESCRIPTION ) 
     213    CHECK( rating, RATING ) 
     214    CHECK( date, DATE ) 
     215    CHECK( url, URL ) 
     216    CHECK( language, LANGUAGE ) 
     217    CHECK( arturl, ART_URL ) 
     218 
     219    return i_meta; 
     220} 
  • src/input/subtitles.c

    r666dc08 re398a81  
    4646 
    4747#include <ctype.h> 
    48  
    49 /** 
    50  * What's between a directory and a filename? 
    51  */ 
    52 #if defined( WIN32 ) 
    53     #define DIRECTORY_SEPARATOR '\\' 
    54 #else 
    55     #define DIRECTORY_SEPARATOR '/' 
    56 #endif 
    5748 
    5849/** 
     
    232223                             psz_subdir, 
    233224                             psz_subdir[strlen(psz_subdir) - 1] == 
    234                               DIRECTORY_SEPARATOR ? '\0' : DIRECTORY_SEPARATOR ); 
     225                              DIR_SEP ? '\0' : DIR_SEP ); 
    235226                    subdirs[i] = psz_temp; 
    236227                    i++; 
     
    287278 
    288279    /* extract filename & dirname from psz_fname */ 
    289     tmp = strrchr( psz_fname, DIRECTORY_SEPARATOR ); 
     280    tmp = strrchr( psz_fname, DIR_SEP ); 
    290281    if( tmp ) 
    291282    { 
     
    314305        dirlen = strlen( f_dir ); 
    315306        f_dir = (char *)realloc(f_dir, dirlen +2 ); 
    316         f_dir[dirlen] = DIRECTORY_SEPARATOR
     307        f_dir[dirlen] = DIR_SEP
    317308        f_dir[dirlen+1] = '\0'; 
    318309        f_fname = FromLocaleDup( psz_fname );