|
Lines 23-28
email : aumuell@reserv.at
Link Here
|
| 23 |
* MA 02110-1301 USA * |
23 |
* MA 02110-1301 USA * |
| 24 |
***************************************************************************/ |
24 |
***************************************************************************/ |
| 25 |
|
25 |
|
|
|
26 |
#include <config.h> |
| 27 |
|
| 26 |
#include "mp4file.h" |
28 |
#include "mp4file.h" |
| 27 |
|
29 |
|
| 28 |
#include "mp4tag.h" |
30 |
#include "mp4tag.h" |
|
Lines 34-40
email : aumuell@reserv.at
Link Here
|
| 34 |
#include <stdlib.h> |
36 |
#include <stdlib.h> |
| 35 |
#include <sys/types.h> |
37 |
#include <sys/types.h> |
| 36 |
|
38 |
|
|
|
39 |
#ifdef HAVE_MP4V2_H |
| 40 |
#define USE_ITMF_TAGS |
| 41 |
#else |
| 37 |
#define MP4V2_HAS_WRITE_BUG 1 |
42 |
#define MP4V2_HAS_WRITE_BUG 1 |
|
|
43 |
#endif |
| 38 |
|
44 |
|
| 39 |
namespace TagLib { |
45 |
namespace TagLib { |
| 40 |
//////////////////////////////////////////////////////////////////////////////// |
46 |
//////////////////////////////////////////////////////////////////////////////// |
|
Lines 102-107
bool MP4::File::save()
Link Here
|
| 102 |
return false; |
108 |
return false; |
| 103 |
} |
109 |
} |
| 104 |
|
110 |
|
|
|
111 |
#ifdef USE_ITMF_TAGS |
| 112 |
const MP4Tags* filetags = MP4TagsAlloc(); |
| 113 |
if(!MP4TagsFetch(filetags, handle)) { |
| 114 |
MP4TagsFree(filetags); |
| 115 |
return false; |
| 116 |
} |
| 117 |
#endif |
| 118 |
|
| 105 |
#ifdef MP4V2_HAS_WRITE_BUG |
119 |
#ifdef MP4V2_HAS_WRITE_BUG |
| 106 |
/* according to gtkpod we have to delete all meta data before modifying it, |
120 |
/* according to gtkpod we have to delete all meta data before modifying it, |
| 107 |
save the stuff we would not touch */ |
121 |
save the stuff we would not touch */ |
|
Lines 117-123
bool MP4::File::save()
Link Here
|
| 117 |
#endif |
131 |
#endif |
| 118 |
|
132 |
|
| 119 |
|
133 |
|
| 120 |
|
134 |
#ifdef USE_ITMF_TAGS |
|
|
135 |
MP4TagsSetName(filetags, mp4tag->title().isNull() ? "" : mp4tag->title().toCString(true)); |
| 136 |
MP4TagsSetArtist(filetags, mp4tag->artist().isNull() ? "" : mp4tag->artist().toCString(true)); |
| 137 |
MP4TagsSetAlbum(filetags, mp4tag->album().isNull() ? "" : mp4tag->album().toCString(true)); |
| 138 |
MP4TagsSetComments(filetags, mp4tag->comment().isNull() ? "" : mp4tag->comment().toCString(true)); |
| 139 |
MP4TagsSetGenre(filetags, mp4tag->genre().isNull() ? "" : mp4tag->genre().toCString(true)); |
| 140 |
#else |
| 121 |
#define setmeta(val, tag) \ |
141 |
#define setmeta(val, tag) \ |
| 122 |
if(mp4tag->val().isNull()) { \ |
142 |
if(mp4tag->val().isNull()) { \ |
| 123 |
/*MP4DeleteMetadata##tag(handle);*/ \ |
143 |
/*MP4DeleteMetadata##tag(handle);*/ \ |
|
Lines 125-151
bool MP4::File::save()
Link Here
|
| 125 |
} else { \ |
145 |
} else { \ |
| 126 |
MP4SetMetadata##tag(handle, mp4tag->val().toCString(true)); \ |
146 |
MP4SetMetadata##tag(handle, mp4tag->val().toCString(true)); \ |
| 127 |
} |
147 |
} |
| 128 |
|
|
|
| 129 |
setmeta(title, Name); |
148 |
setmeta(title, Name); |
| 130 |
setmeta(artist, Artist); |
149 |
setmeta(artist, Artist); |
| 131 |
setmeta(album, Album); |
150 |
setmeta(album, Album); |
| 132 |
setmeta(comment, Comment); |
151 |
setmeta(comment, Comment); |
| 133 |
setmeta(genre, Genre); |
152 |
setmeta(genre, Genre); |
|
|
153 |
setmeta(composer, Writer); |
| 154 |
#endif |
| 134 |
|
155 |
|
| 135 |
char buf[100] = ""; |
156 |
char buf[100] = ""; |
| 136 |
if(mp4tag->year()) |
157 |
if(mp4tag->year()) |
| 137 |
snprintf(buf, sizeof(buf), "%u", mp4tag->year()); |
158 |
snprintf(buf, sizeof(buf), "%u", mp4tag->year()); |
|
|
159 |
#ifdef USE_ITMF_TAGS |
| 160 |
MP4TagsSetReleaseDate(filetags, buf); |
| 161 |
#else |
| 138 |
MP4SetMetadataYear(handle, buf); |
162 |
MP4SetMetadataYear(handle, buf); |
|
|
163 |
#endif |
| 139 |
u_int16_t t1, t2; |
164 |
u_int16_t t1, t2; |
|
|
165 |
|
| 166 |
#ifdef USE_ITMF_TAGS |
| 167 |
MP4TagTrack track = *filetags->track; |
| 168 |
track.index = t1; |
| 169 |
MP4TagsSetTrack(filetags, &track); |
| 170 |
#else |
| 140 |
MP4GetMetadataTrack(handle, &t1, &t2); |
171 |
MP4GetMetadataTrack(handle, &t1, &t2); |
| 141 |
MP4SetMetadataTrack(handle, mp4tag->track(), t2); |
172 |
MP4SetMetadataTrack(handle, mp4tag->track(), t2); |
| 142 |
if(mp4tag->bpm() != 0) |
173 |
#endif |
|
|
174 |
if(mp4tag->bpm() != 0) { |
| 175 |
#ifdef USE_ITMF_TAGS |
| 176 |
u_int16_t tempo = mp4tag->bpm(); |
| 177 |
MP4TagsSetTempo(filetags, &tempo); |
| 178 |
#else |
| 143 |
MP4SetMetadataTempo(handle, mp4tag->bpm()); |
179 |
MP4SetMetadataTempo(handle, mp4tag->bpm()); |
|
|
180 |
#endif |
| 181 |
} |
| 144 |
if(mp4tag->compilation() != MP4::Tag::Undefined) { |
182 |
if(mp4tag->compilation() != MP4::Tag::Undefined) { |
|
|
183 |
#ifdef USE_ITMF_TAGS |
| 184 |
u_int8_t compilation = mp4tag->compilation(); |
| 185 |
MP4TagsSetCompilation(filetags, &compilation); |
| 186 |
#else |
| 145 |
MP4SetMetadataCompilation(handle, mp4tag->compilation()); |
187 |
MP4SetMetadataCompilation(handle, mp4tag->compilation()); |
|
|
188 |
#endif |
| 146 |
} |
189 |
} |
| 147 |
|
190 |
|
|
|
191 |
#ifdef USE_ITMF_TAGS |
| 192 |
if(mp4tag->cover().size()) { |
| 193 |
MP4TagArtwork art; |
| 194 |
art.size = mp4tag->cover().size(); |
| 195 |
art.data = mp4tag->cover().size() ? const_cast<u_int8_t *>( reinterpret_cast<const u_int8_t *>( mp4tag->cover().data() ) ) : 0; |
| 196 |
art.type = MP4_ART_UNDEFINED; // delegate typing to libmp4v2 |
| 197 |
if(filetags->artworkCount > 0) { |
| 198 |
MP4TagsSetArtwork(filetags, 0, &art); |
| 199 |
} |
| 200 |
else { |
| 201 |
MP4TagsAddArtwork(filetags, &art); |
| 202 |
} |
| 203 |
} |
| 204 |
#else |
| 148 |
MP4SetMetadataCoverArt(handle, mp4tag->cover().size() ? const_cast<u_int8_t *>( reinterpret_cast<const u_int8_t *>( mp4tag->cover().data() ) ) : 0, mp4tag->cover().size()); |
205 |
MP4SetMetadataCoverArt(handle, mp4tag->cover().size() ? const_cast<u_int8_t *>( reinterpret_cast<const u_int8_t *>( mp4tag->cover().data() ) ) : 0, mp4tag->cover().size()); |
|
|
206 |
#endif |
| 149 |
|
207 |
|
| 150 |
#ifdef MP4V2_HAS_WRITE_BUG |
208 |
#ifdef MP4V2_HAS_WRITE_BUG |
| 151 |
// set the saved data again |
209 |
// set the saved data again |
|
Lines 159-164
bool MP4::File::save()
Link Here
|
| 159 |
} |
217 |
} |
| 160 |
#endif |
218 |
#endif |
| 161 |
|
219 |
|
|
|
220 |
#ifdef USE_ITMF_TAGS |
| 221 |
MP4TagsStore(filetags, handle); |
| 222 |
MP4TagsFree(filetags); |
| 223 |
#endif |
| 162 |
MP4Close(handle); |
224 |
MP4Close(handle); |
| 163 |
|
225 |
|
| 164 |
mp4file = MP4Read(name()); |
226 |
mp4file = MP4Read(name()); |