1 /*                                                     -*- linux-c -*-
2     Copyright (C) 2007 Tom Szilagyi
3 
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18     $Id: metadata_api.h 1235 2012-02-04 10:27:48Z assworth $
19 */
20 
21 /* Aqualung metadata internal API usage:
22  *   - open a file_decoder on file;
23  *   - fdec->meta is the metablock of the file;
24  *   - access/change it with functions in this module;
25  *   - call fdec->meta_write to write it back to the file
26  *     (only possible if fdec->meta->writable is true);
27  *   - close the file_decoder.
28  */
29 
30 #ifndef AQUALUNG_METADATA_API_H
31 #define AQUALUNG_METADATA_API_H
32 
33 #include "metadata.h"
34 
35 
36 /* Query frames of a given type, with respect to preference order
37    between tags. */
38 meta_frame_t * metadata_pref_frame_by_type(metadata_t * meta, int type, meta_frame_t * root);
39 
40 
41 int metadata_get_string_field(metadata_t * meta, int type, char ** str);
42 /* High-level accessor functions
43  *
44  * Return value: 1 if found, 0 if not found.
45  * Note that in case of text strings, if a match is returned,
46  * it is still owned by the meta object (only the pointer is
47  * passed back), so it should not be freed by the caller.
48  * Number data will be copied to the supplied pointer.
49  */
50 int metadata_get_title(metadata_t * meta, char ** str);
51 int metadata_get_artist(metadata_t * meta, char ** str);
52 int metadata_get_album(metadata_t * meta, char ** str);
53 int metadata_get_date(metadata_t * meta, char ** str);
54 int metadata_get_genre(metadata_t * meta, char ** str);
55 int metadata_get_comment(metadata_t * meta, char ** str);
56 int metadata_get_icy_name(metadata_t * meta, char ** str);
57 int metadata_get_icy_descr(metadata_t * meta, char ** str);
58 int metadata_get_tracknum(metadata_t * meta, int * val);
59 int metadata_get_rva(metadata_t * meta, float * fval);
60 
61 
62 /* Return values of meta_update_basic() */
63 #define META_ERROR_NONE                  0
64 #define META_ERROR_NOMEM                -1
65 #define META_ERROR_OPEN                 -2
66 #define META_ERROR_NO_METASUPPORT       -3
67 #define META_ERROR_NOT_WRITABLE         -4
68 #define META_ERROR_INVALID_TRACKNO      -5
69 #define META_ERROR_INVALID_GENRE        -6
70 #define META_ERROR_INVALID_CODING       -7
71 #define META_ERROR_INTERNAL             -8
72 
73 
74 /* Update basic metadata fields of a file. Used for mass-tagging.
75  *
76  * Any input string may be NULL, in which case that field won't
77  * be updated. Set trackno to -1 to leave it unaffected.
78  * Existing metadata not updated will be retained.
79  *
80  * filename should be locale encoded, text fields should be UTF8.
81  *
82  * Return 0 if OK, < 0 else.
83  * Use metadata_strerror() to get an error string from the
84  * return value.
85  */
86 int
87 meta_update_basic(char * filename,
88 		  char * title, char * artist, char * album,
89 		  char * comment, char * genre, char * date, int trackno);
90 
91 const char * metadata_strerror(int error);
92 
93 
94 #endif /* AQUALUNG_METADATA_API_H */
95