|
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 |
MP4TagsFetch(filetags, handle); |
| 114 |
#endif |
| 115 |
|
| 105 |
#ifdef MP4V2_HAS_WRITE_BUG |
116 |
#ifdef MP4V2_HAS_WRITE_BUG |
| 106 |
/* according to gtkpod we have to delete all meta data before modifying it, |
117 |
/* according to gtkpod we have to delete all meta data before modifying it, |
| 107 |
save the stuff we would not touch */ |
118 |
save the stuff we would not touch */ |
|
Lines 117-123
bool MP4::File::save()
Link Here
|
| 117 |
#endif |
128 |
#endif |
| 118 |
|
129 |
|
| 119 |
|
130 |
|
| 120 |
|
131 |
#ifdef USE_ITMF_TAGS |
|
|
132 |
MP4TagsSetName(filetags, mp4tag->title().isNull() ? "" : mp4tag->title().toCString(true)); |
| 133 |
MP4TagsSetArtist(filetags, mp4tag->artist().isNull() ? "" : mp4tag->artist().toCString(true)); |
| 134 |
MP4TagsSetAlbum(filetags, mp4tag->album().isNull() ? "" : mp4tag->album().toCString(true)); |
| 135 |
MP4TagsSetComments(filetags, mp4tag->comment().isNull() ? "" : mp4tag->comment().toCString(true)); |
| 136 |
MP4TagsSetGenre(filetags, mp4tag->genre().isNull() ? "" : mp4tag->genre().toCString(true)); |
| 137 |
MP4TagsSetComposer(filetags, mp4tag->composer().isNull() ? "" : mp4tab->composer().toCString(true)); |
| 138 |
#else |
| 121 |
#define setmeta(val, tag) \ |
139 |
#define setmeta(val, tag) \ |
| 122 |
if(mp4tag->val().isNull()) { \ |
140 |
if(mp4tag->val().isNull()) { \ |
| 123 |
/*MP4DeleteMetadata##tag(handle);*/ \ |
141 |
/*MP4DeleteMetadata##tag(handle);*/ \ |
|
Lines 125-151
bool MP4::File::save()
Link Here
|
| 125 |
} else { \ |
143 |
} else { \ |
| 126 |
MP4SetMetadata##tag(handle, mp4tag->val().toCString(true)); \ |
144 |
MP4SetMetadata##tag(handle, mp4tag->val().toCString(true)); \ |
| 127 |
} |
145 |
} |
| 128 |
|
|
|
| 129 |
setmeta(title, Name); |
146 |
setmeta(title, Name); |
| 130 |
setmeta(artist, Artist); |
147 |
setmeta(artist, Artist); |
| 131 |
setmeta(album, Album); |
148 |
setmeta(album, Album); |
| 132 |
setmeta(comment, Comment); |
149 |
setmeta(comment, Comment); |
| 133 |
setmeta(genre, Genre); |
150 |
setmeta(genre, Genre); |
|
|
151 |
setmeta(composer, Writer); |
| 152 |
#endif |
| 134 |
|
153 |
|
| 135 |
char buf[100] = ""; |
154 |
char buf[100] = ""; |
| 136 |
if(mp4tag->year()) |
155 |
if(mp4tag->year()) |
| 137 |
snprintf(buf, sizeof(buf), "%u", mp4tag->year()); |
156 |
snprintf(buf, sizeof(buf), "%u", mp4tag->year()); |
|
|
157 |
#ifdef USE_ITMF_TAGS |
| 158 |
MP4TagsSetReleaseDate(filetags, buf); |
| 159 |
#else |
| 138 |
MP4SetMetadataYear(handle, buf); |
160 |
MP4SetMetadataYear(handle, buf); |
|
|
161 |
#endif |
| 139 |
u_int16_t t1, t2; |
162 |
u_int16_t t1, t2; |
|
|
163 |
|
| 164 |
#ifdef USE_ITMF_TAGS |
| 165 |
MP4TagTrack track = *filetags->track; |
| 166 |
track.index = t1; |
| 167 |
MP4TagsSetTrack(filetags, &track); |
| 168 |
#else |
| 140 |
MP4GetMetadataTrack(handle, &t1, &t2); |
169 |
MP4GetMetadataTrack(handle, &t1, &t2); |
| 141 |
MP4SetMetadataTrack(handle, mp4tag->track(), t2); |
170 |
MP4SetMetadataTrack(handle, mp4tag->track(), t2); |
| 142 |
if(mp4tag->bpm() != 0) |
171 |
#endif |
|
|
172 |
if(mp4tag->bpm() != 0) { |
| 173 |
#ifdef USE_ITMF_TAGS |
| 174 |
u_int16_t tempo = mp4tag->bpm(); |
| 175 |
MP4TagsSetTempo(filetags, &tempo); |
| 176 |
#else |
| 143 |
MP4SetMetadataTempo(handle, mp4tag->bpm()); |
177 |
MP4SetMetadataTempo(handle, mp4tag->bpm()); |
|
|
178 |
#endif |
| 179 |
} |
| 144 |
if(mp4tag->compilation() != MP4::Tag::Undefined) { |
180 |
if(mp4tag->compilation() != MP4::Tag::Undefined) { |
|
|
181 |
#ifdef USE_ITMF_TAGS |
| 182 |
u_int8_t compilation = mp4tag->compilation(); |
| 183 |
MP4TagsSetCompilation(filetags, &compilation); |
| 184 |
#else |
| 145 |
MP4SetMetadataCompilation(handle, mp4tag->compilation()); |
185 |
MP4SetMetadataCompilation(handle, mp4tag->compilation()); |
|
|
186 |
#endif |
| 146 |
} |
187 |
} |
| 147 |
|
188 |
|
|
|
189 |
#ifdef USE_ITMF_TAGS |
| 190 |
if(mp4tag->cover().size()) { |
| 191 |
MP4TagArtwork art; |
| 192 |
art.size = mp4tag->cover().size(); |
| 193 |
art.data = mp4tag->cover().size() ? const_cast<u_int8_t *>( reinterpret_cast<const u_int8_t *>( mp4tag->cover().data() ) ) : 0; |
| 194 |
art.type = MP4_ART_UNDEFINED; // delegate typing to libmp4v2 |
| 195 |
if(filetags->artworkCount > 0) { |
| 196 |
MP4TagsSetArtwork(filetags, 0, &art); |
| 197 |
} |
| 198 |
else { |
| 199 |
MP4TagsAddArtwork(filetags, &art); |
| 200 |
} |
| 201 |
} |
| 202 |
#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()); |
203 |
MP4SetMetadataCoverArt(handle, mp4tag->cover().size() ? const_cast<u_int8_t *>( reinterpret_cast<const u_int8_t *>( mp4tag->cover().data() ) ) : 0, mp4tag->cover().size()); |
|
|
204 |
#endif |
| 149 |
|
205 |
|
| 150 |
#ifdef MP4V2_HAS_WRITE_BUG |
206 |
#ifdef MP4V2_HAS_WRITE_BUG |
| 151 |
// set the saved data again |
207 |
// set the saved data again |
|
Lines 159-164
bool MP4::File::save()
Link Here
|
| 159 |
} |
215 |
} |
| 160 |
#endif |
216 |
#endif |
| 161 |
|
217 |
|
|
|
218 |
#ifdef USE_ITMF_TAGS |
| 219 |
MP4TagsStore(filetags, handle); |
| 220 |
MP4TagsFree(filetags); |
| 221 |
#endif |
| 162 |
MP4Close(handle); |
222 |
MP4Close(handle); |
| 163 |
|
223 |
|
| 164 |
mp4file = MP4Read(name()); |
224 |
mp4file = MP4Read(name()); |