vlc_meta.h 7.93 KB
Newer Older
1
/*****************************************************************************
2
 * vlc_meta.h: Stream meta-data
3
 *****************************************************************************
4
 * Copyright (C) 2004 the VideoLAN team
5
 * $Id$
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
 *
 * 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
Antoine Cellerier's avatar
Antoine Cellerier committed
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 23
 *****************************************************************************/

24 25 26 27
#if !defined( __LIBVLC__ )
  #error You are not libvlc or one of its plugins. You cannot include this file
#endif

28 29 30 31
#ifndef _VLC_META_H
#define _VLC_META_H 1

/* VLC meta name */
32
#define VLC_META_INFO_CAT           N_("Meta-information")
33 34 35 36
#define VLC_META_TITLE              N_("Title")
#define VLC_META_ARTIST             N_("Artist")
#define VLC_META_GENRE              N_("Genre")
#define VLC_META_COPYRIGHT          N_("Copyright")
37 38
#define VLC_META_COLLECTION         N_("Album/movie/show title")
#define VLC_META_SEQ_NUM            N_("Track number/position in set")
39 40 41 42
#define VLC_META_DESCRIPTION        N_("Description")
#define VLC_META_RATING             N_("Rating")
#define VLC_META_DATE               N_("Date")
#define VLC_META_SETTING            N_("Setting")
43
#define VLC_META_URL                N_("URL")
44
#define VLC_META_LANGUAGE           N_("Language")
45
#define VLC_META_NOW_PLAYING        N_("Now Playing")
46
#define VLC_META_PUBLISHER          N_("Publisher")
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
47
#define VLC_META_ENCODED_BY         N_("Encoded by")
48

49 50
#define VLC_META_ART_URL            N_("Art URL")

51 52 53
#define VLC_META_CODEC_NAME         N_("Codec Name")
#define VLC_META_CODEC_DESCRIPTION  N_("Codec Description")

54 55 56 57
#define ITEM_PREPARSED      0x01
#define ITEM_META_FETCHED   0x02
#define ITEM_ARTURL_FETCHED 0x04
#define ITEM_ART_FETCHED    0x08
58
#define ITEM_ART_NOTFOUND   0x10
59

60 61
struct vlc_meta_t
{
62 63 64 65 66 67 68 69 70 71 72 73 74 75
    char *psz_title;
    char *psz_artist;
    char *psz_genre;
    char *psz_copyright;
    char *psz_album;
    char *psz_tracknum;
    char *psz_description;
    char *psz_rating;
    char *psz_date;
    char *psz_setting;
    char *psz_url;
    char *psz_language;
    char *psz_nowplaying;
    char *psz_publisher;
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
76
    char *psz_encodedby;
77
    char *psz_arturl;
78
    char *psz_trackid;
79
#if 0 //not used
80 81
    char *psz_artistid;
    char *psz_albumid;
82
#endif
83 84

    int i_status;
85
#if 0
86
    /* track meta information */
87 88
    int         i_track;
    vlc_meta_t  **track;
89
#endif
90 91
};

92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
#define vlc_meta_Set( meta,var,val ) { \
    if( meta->psz_##var ) free( meta->psz_##var ); \
    meta->psz_##var = strdup( val ); }

#define vlc_meta_SetTitle( meta, b ) vlc_meta_Set( meta, title, b );
#define vlc_meta_SetArtist( meta, b ) vlc_meta_Set( meta, artist, b );
#define vlc_meta_SetGenre( meta, b ) vlc_meta_Set( meta, genre, b );
#define vlc_meta_SetCopyright( meta, b ) vlc_meta_Set( meta, copyright, b );
#define vlc_meta_SetAlbum( meta, b ) vlc_meta_Set( meta, album, b );
#define vlc_meta_SetTracknum( meta, b ) vlc_meta_Set( meta, tracknum, b );
#define vlc_meta_SetDescription( meta, b ) vlc_meta_Set( meta, description, b );
#define vlc_meta_SetRating( meta, b ) vlc_meta_Set( meta, rating, b );
#define vlc_meta_SetDate( meta, b ) vlc_meta_Set( meta, date, b );
#define vlc_meta_SetSetting( meta, b ) vlc_meta_Set( meta, setting, b );
#define vlc_meta_SetURL( meta, b ) vlc_meta_Set( meta, url, b );
#define vlc_meta_SetLanguage( meta, b ) vlc_meta_Set( meta, language, b );
#define vlc_meta_SetNowPlaying( meta, b ) vlc_meta_Set( meta, nowplaying, b );
#define vlc_meta_SetPublisher( meta, b ) vlc_meta_Set( meta, publisher, b );
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
110
#define vlc_meta_SetEncodedBy( meta, b ) vlc_meta_Set( meta, encodedby, b );
111
#define vlc_meta_SetArtURL( meta, b ) vlc_meta_Set( meta, arturl, b );
112
#define vlc_meta_SetTrackID( meta, b ) vlc_meta_Set( meta, trackid, b );
113
#if 0 //not used
114 115
#define vlc_meta_SetArtistID( meta, b ) vlc_meta_Set( meta, artistid, b );
#define vlc_meta_SetAlbumID( meta, b ) vlc_meta_Set( meta, albumid, b );
116
#endif
117

118

119 120
static inline vlc_meta_t *vlc_meta_New( void )
{
121
    vlc_meta_t *m = (vlc_meta_t*)malloc( sizeof( vlc_meta_t ) );
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
    if( !m ) return NULL;
    m->psz_title = NULL;
    m->psz_artist = NULL;
    m->psz_genre = NULL;
    m->psz_copyright = NULL;
    m->psz_album = NULL;
    m->psz_tracknum = NULL;
    m->psz_description = NULL;
    m->psz_rating = NULL;
    m->psz_date = NULL;
    m->psz_setting = NULL;
    m->psz_url = NULL;
    m->psz_language = NULL;
    m->psz_nowplaying = NULL;
    m->psz_publisher = NULL;
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
137
    m->psz_encodedby = NULL;
138
    m->psz_arturl = NULL;
139
    m->psz_trackid = NULL;
140
#if 0 //not used
141 142
    m->psz_artistid = NULL;
    m->psz_albumid = NULL;
143
#endif
144
    m->i_status = 0;
145 146
    return m;
}
147

148 149
static inline void vlc_meta_Delete( vlc_meta_t *m )
{
150 151 152 153 154 155 156 157 158 159 160 161 162 163
    free( m->psz_title );
    free( m->psz_artist );
    free( m->psz_genre );
    free( m->psz_copyright );
    free( m->psz_album );
    free( m->psz_tracknum );
    free( m->psz_description );
    free( m->psz_rating );
    free( m->psz_date );
    free( m->psz_setting );
    free( m->psz_url );
    free( m->psz_language );
    free( m->psz_nowplaying );
    free( m->psz_publisher );
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
164
    free( m->psz_encodedby );
165
    free( m->psz_trackid );
166
#if 0 //not used
167 168
    free( m->psz_artistid );
    free( m->psz_albumid );
169
#endif
170
    free( m->psz_arturl );
171 172 173

    free( m );
}
174 175 176

static inline void vlc_meta_Merge( vlc_meta_t *dst, vlc_meta_t *src )
{
177 178 179 180 181
    if( !dst || !src ) return;
#define COPY_FIELD( a ) \
    if( src->psz_ ## a ) { \
        if( dst->psz_ ## a ) free( dst->psz_## a ); \
        dst->psz_##a = strdup( src->psz_##a ); \
182
    }
183 184 185 186 187 188 189 190 191 192 193 194 195 196
    COPY_FIELD( title );
    COPY_FIELD( artist );
    COPY_FIELD( genre );
    COPY_FIELD( copyright );
    COPY_FIELD( album );
    COPY_FIELD( tracknum );
    COPY_FIELD( description );
    COPY_FIELD( rating );
    COPY_FIELD( date );
    COPY_FIELD( setting );
    COPY_FIELD( url );
    COPY_FIELD( language );
    COPY_FIELD( nowplaying );
    COPY_FIELD( publisher );
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
197
    COPY_FIELD( encodedby );
198
    COPY_FIELD( trackid );
199
#if 0 //not used
200 201
    COPY_FIELD( artistid );
    COPY_FIELD( albumid );
202
#endif
203
    COPY_FIELD( arturl );
204
}
205
    /** \todo Track meta */
206

207 208 209
enum {
    ALBUM_ART_WHEN_ASKED,
    ALBUM_ART_WHEN_PLAYED,
210 211
    ALBUM_ART_ALL
};
212

213 214 215 216 217 218
struct meta_export_t
{
    input_item_t *p_item;
    const char *psz_file;
};

219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
#define VLC_META_ENGINE_TITLE           0x00000001
#define VLC_META_ENGINE_ARTIST          0x00000004
#define VLC_META_ENGINE_GENRE           0x00000008
#define VLC_META_ENGINE_COPYRIGHT       0x00000010
#define VLC_META_ENGINE_COLLECTION      0x00000020
#define VLC_META_ENGINE_SEQ_NUM         0x00000040
#define VLC_META_ENGINE_DESCRIPTION     0x00000080
#define VLC_META_ENGINE_RATING          0x00000100
#define VLC_META_ENGINE_DATE            0x00000200
#define VLC_META_ENGINE_URL             0x00000400
#define VLC_META_ENGINE_LANGUAGE        0x00000800

#define VLC_META_ENGINE_ART_URL         0x00001000

#define VLC_META_ENGINE_MB_ARTIST_ID    0x00002000
#define VLC_META_ENGINE_MB_RELEASE_ID   0x00004000
#define VLC_META_ENGINE_MB_TRACK_ID     0x00008000
#define VLC_META_ENGINE_MB_TRM_ID       0x00010000

typedef struct meta_engine_sys_t meta_engine_sys_t;

struct meta_engine_t
{
    VLC_COMMON_MEMBERS

    module_t *p_module;

    uint32_t i_mandatory; /**< Stuff which we really need to get */
    uint32_t i_optional; /**< Stuff which we'd like to have */

    input_item_t *p_item;
};

Clément Stenac's avatar
Clément Stenac committed
252
VLC_EXPORT(uint32_t, input_CurrentMetaFlags,( vlc_meta_t *p_meta ) );
253

254
#endif