kwave  18.07.70
ID3_PropertyMap.cpp
Go to the documentation of this file.
1 /*************************************************************************
2  ID3_PropertyMap.cpp - map for translating properties to ID3 frame tags
3  -------------------
4  begin : Sat Jul 30 2012
5  copyright : (C) 2012 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "config.h"
19 
20 #include <id3/field.h>
21 
22 #include "ID3_PropertyMap.h"
23 
24 //***************************************************************************
26  :m_list()
27 {
28  // NOTE #1: the left column is allowed to have multiple entries with the
29  // same property, when encoding the first one is used, when
30  // decoding, the other ones serve as alternatives
31  // NOTE #2: the ID3 tag names in the right column must be *unique* !
32 
33  // Album/Movie/Show title
34  insert(Kwave::INF_ALBUM, ID3FID_ALBUM , ENC_TEXT);
35  // Original album/movie/show title
36  insert(Kwave::INF_ALBUM, ID3FID_ORIGALBUM , ENC_TEXT);
37  // Subtitle/Description refinement
38  insert(Kwave::INF_ANNOTATION, ID3FID_SUBTITLE , ENC_TEXT);
39  // User defined text information
40  insert(Kwave::INF_ANNOTATION, ID3FID_USERTEXT , ENC_TEXT);
41  // Kwave::INF_ARCHIVAL
42  // Original artist(s)/performer(s)
43  insert(Kwave::INF_AUTHOR, ID3FID_ORIGARTIST , ENC_TEXT_SLASH);
44  // Involved people list
45  insert(Kwave::INF_AUTHOR, ID3FID_INVOLVEDPEOPLE , ENC_TEXT_LIST);
46  // Involved people list
47  insert(Kwave::INF_AUTHOR, ID3FID_INVOLVEDPEOPLE2 , ENC_TEXT_LIST);
48  // Band/orchestra/accompaniment
49  insert(Kwave::INF_AUTHOR, ID3FID_BAND , ENC_TEXT);
50  // Original lyricist(s)/text writer(s)
51  insert(Kwave::INF_AUTHOR, ID3FID_ORIGLYRICIST , ENC_TEXT_SLASH);
52  // Official artist/performer webpage
53  insert(Kwave::INF_AUTHOR, ID3FID_WWWARTIST , ENC_TEXT_URL);
54  // Official publisher webpage
55  insert(Kwave::INF_AUTHOR, ID3FID_WWWPUBLISHER , ENC_TEXT_URL);
56  // Kwave::INF_BITRATE_LOWER
57  // Kwave::INF_BITRATE_NOMINAL
58  // Kwave::INF_BITRATE_UPPER
59  // Kwave::INF_BITS_PER_SAMPLE
60  // Part of a set
61  insert(Kwave::INF_CD, ID3FID_PARTINSET , ENC_TEXT_PARTINSET);
62  insert(Kwave::INF_CDS, ID3FID_PARTINSET , ENC_TEXT_PARTINSET);
63  // Internet radio station name
64  insert(Kwave::INF_COMMISSIONED, ID3FID_NETRADIOSTATION , ENC_TEXT);
65  // Internet radio station owner
66  insert(Kwave::INF_COMMISSIONED, ID3FID_NETRADIOOWNER , ENC_TEXT);
67  // Comments
68  insert(Kwave::INF_COMMENTS, ID3FID_COMMENT , ENC_COMMENT);
69  // Official audio source webpage
70  insert(Kwave::INF_CONTACT, ID3FID_WWWAUDIOSOURCE , ENC_TEXT_SLASH);
71  // Official internet radio station homepage
72  insert(Kwave::INF_CONTACT, ID3FID_WWWRADIOPAGE , ENC_TEXT_SLASH);
73  // Official audio file webpage
74  insert(Kwave::INF_CONTACT, ID3FID_WWWAUDIOFILE , ENC_TEXT_SLASH);
75  // Ownership (not supported by id3lib)
76  // (Kwave::INF_CONTACT, ID3FID_OWNERSHIP , ENC_OWNERSHIP?);
77  // Copyright message.
78  insert(Kwave::INF_COPYRIGHT, ID3FID_COPYRIGHT , ENC_TEXT);
79  // Copyright/Legal infromation
80  insert(Kwave::INF_COPYRIGHT, ID3FID_WWWCOPYRIGHT , ENC_TEXT_URL);
81  // Terms of use
82  insert(Kwave::INF_COPYRIGHT, ID3FID_TERMSOFUSE , ENC_TERMS_OF_USE);
83  // Kwave::INF_COPYRIGHTED
84 
85  // Recording dates
86  insert(Kwave::INF_CREATION_DATE, ID3FID_RECORDINGDATES , ENC_TEXT_TIMESTAMP);
87  // Recording time (not supported by id3lib)
88  // (Kwave::INF_CREATION_DATE, ID3FID_RECORDINGTIME , ENC_TEXT_TIMESTAMP);
89  // Date
91  // Year
93  // Time
95  // Release time (not supported by id3lib)
96  // (Kwave::INF_CREATION_DATE, ID3FID_RELEASETIME , ENC_TEXT_TIMESTAMP);
97  // Original release year
99  // Original release time (not supported by id3lib)
100  // (Kwave::INF_CREATION_DATE, ID3FID_ORIGRELEASETIME , ENC_TEXT_TIMESTAMP);
101  // Tagging time (not supported by id3lib)
102  // (Kwave::INF_CREATION_DATE, ID3FID_TAGGINGTIME , ENC_TEXT_TIMESTAMP);
103  // Encoding time (not supported by id3lib)
104  // (Kwave::INF_CREATION_DATE, ID3FID_ENCODINGTIME , ENC_TEXT_TIMESTAMP);
105 
106  // Kwave::INF_ENGINEER
107  // Kwave::INF_FILENAME
108  // Kwave::INF_FILESIZE
109  // Content type (Genre)
110  insert(Kwave::INF_GENRE, ID3FID_CONTENTTYPE , ENC_GENRE_TYPE);
111  // ISRC
112  insert(Kwave::INF_ISRC, ID3FID_ISRC , ENC_TEXT);
113  // Kwave::INF_KEYWORDS
114  // Kwave::INF_LABELS
115  // Length
116  insert(Kwave::INF_LENGTH, ID3FID_SONGLEN , ENC_LENGTH);
117  // File owner/licensee
118  insert(Kwave::INF_LICENSE, ID3FID_FILEOWNER , ENC_TEXT);
119  // Medium type
120  insert(Kwave::INF_MEDIUM, ID3FID_MEDIATYPE , ENC_TEXT);
121  // Kwave::INF_MIMETYPE
122  // Kwave::INF_MPEG_EMPHASIS
123  // Kwave::INF_MPEG_LAYER
124  // Kwave::INF_MPEG_MODEEXT
125  // Kwave::INF_MPEG_VERSION
126  // Title/songname/content description
127  insert(Kwave::INF_NAME, ID3FID_TITLE , ENC_TEXT);
128  // Composer
129  insert(Kwave::INF_ORGANIZATION, ID3FID_COMPOSER , ENC_TEXT_SLASH);
130  // Publisher
131  insert(Kwave::INF_ORGANIZATION, ID3FID_PUBLISHER , ENC_TEXT_SLASH);
132  // Produced notice
133  insert(Kwave::INF_ORGANIZATION, ID3FID_PRODUCEDNOTICE , ENC_TEXT_SLASH);
134  // Kwave::INF_ORIGINAL
135  // Lyricist/Text writer
136  insert(Kwave::INF_PERFORMER, ID3FID_LYRICIST , ENC_TEXT_SLASH);
137  // Lead performer(s)/Soloist(s).
138  insert(Kwave::INF_PERFORMER, ID3FID_LEADARTIST , ENC_TEXT_SLASH);
139  // Musician credits list
140  insert(Kwave::INF_PERFORMER, ID3FID_MUSICIANCREDITLIST , ENC_TEXT_SLASH);
141  // Conductor/performer refinement
142  insert(Kwave::INF_PERFORMER, ID3FID_CONDUCTOR , ENC_TEXT);
143  // Private frame
144  // Kwave::INF_PRIVATE
145  // Kwave::INF_PRODUCT
146  // Kwave::INF_SAMPLE_FORMAT
147  // Kwave::INF_SAMPLE_RATE
148  insert(Kwave::INF_SOFTWARE, ID3FID_ENCODERSETTINGS , ENC_TEXT);
149  // Kwave::INF_SOURCE
150  // Kwave::INF_SOURCE_FORM
151  // Kwave::INF_SUBJECT
152  // Encoded by.
153  insert(Kwave::INF_TECHNICAN, ID3FID_ENCODEDBY , ENC_TEXT);
154  // Track number/Position in set
155  insert(Kwave::INF_TRACK, ID3FID_TRACKNUM , ENC_TRACK_NUM);
156  // Number of Tracks
157  insert(Kwave::INF_TRACKS, ID3FID_TRACKNUM , ENC_TRACK_NUM);
158  // Kwave::INF_VBR_QUALITY
159  // Interpreted, remixed / modified by
160  insert(Kwave::INF_VERSION, ID3FID_MIXARTIST , ENC_TEXT);
161  // Set subtitle
162  insert(Kwave::INF_VERSION, ID3FID_SETSUBTITLE , ENC_TEXT);
163  // ID3FID_PRIVATE => user defined data
164 
165  insert(Kwave::INF_UNKNOWN, ID3FID_NOFRAME , ENC_NONE);
166 }
167 
168 //***************************************************************************
170  const ID3_FrameID id, const Kwave::ID3_PropertyMap::Encoding encoding)
171 {
173 
174  mapping.m_property = property;
175  mapping.m_frame_id = id;
176  mapping.m_encoding = encoding;
177  m_list.append(mapping);
178 }
179 
180 //***************************************************************************
182  const Kwave::FileProperty property) const
183 {
184  foreach(const Kwave::ID3_PropertyMap::Mapping &m, m_list) {
185  if ((m.m_property == property) && supported(m.m_frame_id))
186  return m.m_frame_id;
187  }
188  return ID3FID_NOFRAME;
189 }
190 
191 //***************************************************************************
193  const Kwave::FileProperty property) const
194 {
195  foreach(const Kwave::ID3_PropertyMap::Mapping &m, m_list) {
196  if ((m.m_property == property) && supported(m.m_frame_id))
197  return true;
198  }
199  return false;
200 }
201 
202 //***************************************************************************
203 bool Kwave::ID3_PropertyMap::containsID(const ID3_FrameID id) const
204 {
205  if (!supported(id))
206  return false;
207 
208  foreach(const Kwave::ID3_PropertyMap::Mapping &m, m_list) {
209  if (m.m_frame_id == id)
210  return true;
211  }
212  return false;
213 }
214 
215 //***************************************************************************
217  const ID3_FrameID id) const
218 {
219  foreach(const Kwave::ID3_PropertyMap::Mapping &m, m_list) {
220  if (m.m_frame_id == id)
221  return m.m_encoding;
222  }
224 }
225 
226 //***************************************************************************
227 QList<ID3_FrameID> Kwave::ID3_PropertyMap::knownIDs() const
228 {
229  QList<ID3_FrameID> list;
230  foreach(const Kwave::ID3_PropertyMap::Mapping &m, m_list) {
231  if (!list.contains(m.m_frame_id))
232  list.append(m.m_frame_id);
233  }
234  return list;
235 }
236 
237 //***************************************************************************
239 {
240  foreach(const Kwave::ID3_PropertyMap::Mapping &m, m_list) {
241  if (m.m_frame_id == id) return m.m_property;
242  }
243  return Kwave::INF_UNKNOWN;
244 }
245 
246 //***************************************************************************
247 QList<Kwave::FileProperty> Kwave::ID3_PropertyMap::properties() const
248 {
249  QList<Kwave::FileProperty> list;
250  foreach(const Kwave::ID3_PropertyMap::Mapping &m, m_list) {
251  if (!list.contains(m.m_property))
252  list.append(m.m_property);
253  }
254  return list;
255 }
256 
257 //***************************************************************************
258 bool Kwave::ID3_PropertyMap::supported(const ID3_FrameID id) const
259 {
260  ID3_FrameInfo frameInfo;
261  return (frameInfo.NumFields(id) != 0);
262 }
263 
264 //***************************************************************************
265 //***************************************************************************
void insert(const Kwave::FileProperty property, const ID3_FrameID id, const Encoding encoding)
QList< Kwave::FileProperty > properties() const
QList< Mapping > m_list
ID3_FrameID findProperty(const Kwave::FileProperty property) const
QList< ID3_FrameID > knownIDs() const
bool containsID(const ID3_FrameID id) const
Encoding encoding(const ID3_FrameID id) const
Kwave::FileProperty property(const ID3_FrameID id) const
bool supported(const ID3_FrameID id) const
bool containsProperty(const Kwave::FileProperty property) const
FileProperty
Definition: FileInfo.h:45