Audacious  $Id:Doxyfile42802007-03-2104:39:00Znenolod$
tuple.h
Go to the documentation of this file.
00001 /*
00002  * Audacious
00003  * Copyright (c) 2006-2007 Audacious team
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; under version 3 of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses>.
00016  *
00017  * The Audacious team does not consider modular code linking to
00018  * Audacious or using our public API to be a derived work.
00019  */
00025 #ifndef AUDACIOUS_TUPLE_H
00026 #define AUDACIOUS_TUPLE_H
00027 
00028 #include <glib.h>
00029 #include <mowgli.h>
00030 
00031 G_BEGIN_DECLS
00032 
00036 enum {
00037     FIELD_ARTIST = 0,
00038     FIELD_TITLE,        
00039     FIELD_ALBUM,        
00040     FIELD_COMMENT,      
00041     FIELD_GENRE,        
00043     FIELD_TRACK,
00044     FIELD_TRACK_NUMBER,
00045     FIELD_LENGTH,       
00046     FIELD_YEAR,         
00047     FIELD_QUALITY,      
00050     FIELD_CODEC,        
00051     FIELD_FILE_NAME,    
00052     FIELD_FILE_PATH,    
00053     FIELD_FILE_EXT,     
00054     FIELD_SONG_ARTIST,
00055 
00056     FIELD_MTIME,        
00057     FIELD_FORMATTER,    
00058     FIELD_PERFORMER,
00059     FIELD_COPYRIGHT,
00060     FIELD_DATE,
00061 
00062     FIELD_SUBSONG_ID,   
00063     FIELD_SUBSONG_NUM,  
00064     FIELD_MIMETYPE,
00065     FIELD_BITRATE,      
00067     FIELD_SEGMENT_START,
00068     FIELD_SEGMENT_END,
00069 
00070     /* Preserving replay gain information accurately is a challenge since there
00071      * are several differents formats around.  We use an integer fraction, with
00072      * the denominator stored in the *_UNIT fields.  For example, if ALBUM_GAIN
00073      * is 512 and GAIN_UNIT is 256, then the album gain is +2 dB.  If TRACK_PEAK
00074      * is 787 and PEAK_UNIT is 1000, then the peak volume is 0.787 in a -1.0 to
00075      * 1.0 range. */
00076     FIELD_GAIN_ALBUM_GAIN,
00077     FIELD_GAIN_ALBUM_PEAK,
00078     FIELD_GAIN_TRACK_GAIN,
00079     FIELD_GAIN_TRACK_PEAK,
00080     FIELD_GAIN_GAIN_UNIT,
00081     FIELD_GAIN_PEAK_UNIT,
00082 
00083     FIELD_COMPOSER,     
00085     /* Special field, must always be last */
00086     FIELD_LAST
00087 };
00088 
00089 typedef enum {
00090     TUPLE_STRING,
00091     TUPLE_INT,
00092     TUPLE_UNKNOWN
00093 } TupleValueType;
00094 
00095 typedef struct {
00096     gchar *name;
00097     TupleValueType type;
00098 } TupleBasicType;
00099 
00100 extern const TupleBasicType tuple_fields[FIELD_LAST];
00101 
00102 #define TUPLE_NAME_MAX 20
00103 
00104 typedef struct {
00105     gchar name[TUPLE_NAME_MAX]; /* for standard fields, the empty string */
00106     TupleValueType type;
00107     union {
00108         gchar *string;
00109         gint integer;
00110     } value;
00111 } TupleValue;
00112 
00117 typedef struct _Tuple {
00118     mowgli_object_t parent;
00119     mowgli_patricia_t *dict;        
00120     TupleValue *values[FIELD_LAST]; 
00121     gint nsubtunes;                 
00124     gint *subtunes;                 
00127 } Tuple;
00128 
00129 
00130 Tuple *tuple_new(void);
00131 Tuple *tuple_copy(const Tuple *);
00132 void tuple_set_filename(Tuple *tuple, const gchar *filename);
00133 Tuple *tuple_new_from_filename(const gchar *filename);
00134 gboolean tuple_associate_string_rel(Tuple *tuple, const gint nfield, const gchar *field, gchar *string);
00135 gboolean tuple_associate_string(Tuple *tuple, const gint nfield, const gchar *field, const gchar *string);
00136 gboolean tuple_associate_int(Tuple *tuple, const gint nfield, const gchar *field, gint integer);
00137 void tuple_disassociate(Tuple *tuple, const gint nfield, const gchar *field);
00138 void tuple_disassociate_now(TupleValue *value);
00139 TupleValueType tuple_get_value_type (const Tuple * tuple, gint nfield,
00140  const gchar * field);
00141 const gchar * tuple_get_string (const Tuple * tuple, gint nfield, const gchar *
00142  field);
00143 gint tuple_get_int (const Tuple * tuple, gint nfield, const gchar * field);
00144 #define tuple_free(x) mowgli_object_unref(x);
00145 
00146 /* Fills in format-related fields (specifically FIELD_CODEC, FIELD_QUALITY, and
00147  * FIELD_BITRATE.  Plugins should use this function instead of setting these
00148  * fields individually so that the style is consistent across file formats.
00149  * <format> should be a brief description such as "Microsoft WAV", "MPEG-1 layer
00150  * 3", "Audio CD", and so on.  <samplerate> is in Hertz.  <bitrate> is in 1000
00151  * bits per second. */
00152 void tuple_set_format (Tuple * tuple, const gchar * format, gint channels, gint
00153  samplerate, gint bitrate);
00154 
00155 G_END_DECLS
00156 
00157 #endif /* AUDACIOUS_TUPLE_H */