1 /*****************************************************************************
2 * meta.c : Metadata handling
3 *****************************************************************************
4 * Copyright (C) 1998-2004 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea@videolan.org>
8 * Clément Stenac <zorglub@videolan.org
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
29 #include <vlc_common.h>
30 #include <vlc_playlist.h>
31 #include "input_internal.h"
32 #include "../playlist/art.h"
34 /* FIXME bad name convention */
35 const char * input_MetaTypeToLocalizedString( vlc_meta_type_t meta_type )
39 case vlc_meta_Title: return _("Title");
40 case vlc_meta_Artist: return _("Artist");
41 case vlc_meta_Genre: return _("Genre");
42 case vlc_meta_Copyright: return _("Copyright");
43 case vlc_meta_Album: return _("Album");
44 case vlc_meta_TrackNumber: return _("Track number");
45 case vlc_meta_Description: return _("Description");
46 case vlc_meta_Rating: return _("Rating");
47 case vlc_meta_Date: return _("Date");
48 case vlc_meta_Setting: return _("Setting");
49 case vlc_meta_URL: return _("URL");
50 case vlc_meta_Language: return _("Language");
51 case vlc_meta_NowPlaying: return _("Now Playing");
52 case vlc_meta_Publisher: return _("Publisher");
53 case vlc_meta_EncodedBy: return _("Encoded by");
54 case vlc_meta_ArtworkURL: return _("Artwork URL");
55 case vlc_meta_TrackID: return _("Track ID");
61 void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
63 input_item_t *p_item = p_input->p->p_item;
66 char *psz_arturl = input_item_GetArtURL( p_item );
67 if( !psz_arturl || strncmp( psz_arturl, "attachment://", strlen("attachment://") ) )
69 msg_Err( p_input, "internal input error with input_ExtractAttachmentAndCacheArt" );
74 playlist_t *p_playlist = pl_Hold( p_input );
82 if( input_item_IsArtFetched( p_item ) )
84 /* XXX Weird, we should not have end up with attachment:// art url unless there is a race
86 msg_Warn( p_input, "internal input error with input_ExtractAttachmentAndCacheArt" );
87 playlist_FindArtInCache( p_item );
92 input_attachment_t *p_attachment = NULL;
94 vlc_mutex_lock( &p_item->lock );
95 for( int i_idx = 0; i_idx < p_input->p->i_attachment; i_idx++ )
97 if( !strcmp( p_input->p->attachment[i_idx]->psz_name,
98 &psz_arturl[strlen("attachment://")] ) )
100 p_attachment = vlc_input_attachment_Duplicate( p_input->p->attachment[i_idx] );
104 vlc_mutex_unlock( &p_item->lock );
106 if( !p_attachment || p_attachment->i_data <= 0 )
109 vlc_input_attachment_Delete( p_attachment );
110 msg_Warn( p_input, "internal input error with input_ExtractAttachmentAndCacheArt" );
115 const char *psz_type = NULL;
116 if( !strcmp( p_attachment->psz_mime, "image/jpeg" ) )
118 else if( !strcmp( p_attachment->psz_mime, "image/png" ) )
122 playlist_SaveArt( p_playlist, p_item,
123 p_attachment->p_data, p_attachment->i_data, psz_type );
125 vlc_input_attachment_Delete( p_attachment );
128 pl_Release( p_input );