vlc_meta.h 5.42 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
 *****************************************************************************/

#ifndef _VLC_META_H
#define _VLC_META_H 1

/* VLC meta name */
28
#define VLC_META_INFO_CAT           N_("Meta-information")
29 30 31 32 33
#define VLC_META_TITLE              N_("Title")
#define VLC_META_AUTHOR             N_("Author")
#define VLC_META_ARTIST             N_("Artist")
#define VLC_META_GENRE              N_("Genre")
#define VLC_META_COPYRIGHT          N_("Copyright")
34 35
#define VLC_META_COLLECTION         N_("Album/movie/show title")
#define VLC_META_SEQ_NUM            N_("Track number/position in set")
36 37 38 39
#define VLC_META_DESCRIPTION        N_("Description")
#define VLC_META_RATING             N_("Rating")
#define VLC_META_DATE               N_("Date")
#define VLC_META_SETTING            N_("Setting")
40
#define VLC_META_URL                N_("URL")
41
#define VLC_META_LANGUAGE           N_("Language")
42
#define VLC_META_NOW_PLAYING        N_("Now Playing")
43
#define VLC_META_PUBLISHER          N_("Publisher")
44

45 46 47 48 49
#define VLC_META_CODEC_NAME         N_("Codec Name")
#define VLC_META_CODEC_DESCRIPTION  N_("Codec Description")

struct vlc_meta_t
{
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
    char *psz_title;
    char *psz_author;
    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;
#if 0
66
    /* track meta information */
67 68
    int         i_track;
    vlc_meta_t  **track;
69
#endif
70 71
};

72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
#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_SetAuthor( meta, b ) vlc_meta_Set( meta, author, 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 );

92 93
static inline vlc_meta_t *vlc_meta_New( void )
{
94
    vlc_meta_t *m = (vlc_meta_t*)malloc( sizeof( vlc_meta_t ) );
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
    if( !m ) return NULL;
    m->psz_title = NULL;
    m->psz_author = 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;
111 112
    return m;
}
113

114 115
static inline void vlc_meta_Delete( vlc_meta_t *m )
{
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
    free( m->psz_title );
    free( m->psz_author );
    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 );
131 132 133

    free( m );
}
134 135 136

static inline void vlc_meta_Merge( vlc_meta_t *dst, vlc_meta_t *src )
{
137 138 139 140 141
    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 ); \
142
    }
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
    COPY_FIELD( title );
    COPY_FIELD( author );
    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 );
158
}
159
    /** \todo Track meta */
160

161
#endif