Projects
Multimedia
mediatomb
mediatomb-0.12.1-mp4v2_2.0.0.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File mediatomb-0.12.1-mp4v2_2.0.0.patch of Package mediatomb (Revision 10)
Currently displaying revision
10
,
Show latest
diff -Naur mediatomb-0.12.1.svn2103.orig/src/metadata/libmp4v2_handler.cc mediatomb-0.12.1.svn2103/src/metadata/libmp4v2_handler.cc --- mediatomb-0.12.1.svn2103.orig/src/metadata/libmp4v2_handler.cc 2012-11-09 03:02:02.283176882 +0100 +++ mediatomb-0.12.1.svn2103/src/metadata/libmp4v2_handler.cc 2013-08-09 14:34:00.262756277 +0200 @@ -62,28 +62,26 @@ { } -static void addMetaField(metadata_fields_t field, MP4FileHandle mp4, Ref<CdsItem> item) +static void addMetaField(metadata_fields_t field, const MP4Tags* mp4tags, Ref<CdsItem> item) { String value; char* mp4_retval = NULL; - u_int16_t track; - u_int16_t total_tracks; Ref<StringConverter> sc = StringConverter::i2i(); switch (field) { case M_TITLE: - MP4GetMetadataName(mp4, &mp4_retval); + mp4_retval = (char *)mp4tags->name; break; case M_ARTIST: - MP4GetMetadataArtist(mp4, &mp4_retval); + mp4_retval = (char *)mp4tags->artist; break; case M_ALBUM: - MP4GetMetadataAlbum(mp4, &mp4_retval); + mp4_retval = (char *)mp4tags->album; break; case M_DATE: - MP4GetMetadataYear(mp4, &mp4_retval); + mp4_retval = (char *)mp4tags->releaseDate; if (mp4_retval) { value = mp4_retval; @@ -95,17 +93,16 @@ } break; case M_GENRE: - MP4GetMetadataGenre(mp4, &mp4_retval); + mp4_retval = (char *)mp4tags->genre; break; case M_DESCRIPTION: - MP4GetMetadataComment(mp4, &mp4_retval); + mp4_retval = (char *)mp4tags->description; break; case M_TRACKNUMBER: - MP4GetMetadataTrack(mp4, &track, &total_tracks); - if (track > 0) + if (mp4tags->track->index > 0) { - value = String::from(track); - item->setTrackNumber((int)track); + value = String::from(mp4tags->track->index); + item->setTrackNumber((int)mp4tags->track->index); } else return; @@ -128,6 +125,7 @@ item->setMetadata(MT_KEYS[field].upnp, sc->convert(value)); log_debug("mp4 handler: setting metadata on item: %d, %s\n", field, sc->convert(value).c_str()); } + } void LibMP4V2Handler::fillMetadata(Ref<CdsItem> item) @@ -145,8 +143,13 @@ try { + /* allocate */ + const MP4Tags* tags = MP4TagsAlloc(); + /* fetch data from MP4 file and populate structure */ + MP4TagsFetch( tags, mp4 ); + for (int i = 0; i < M_MAX; i++) - addMetaField((metadata_fields_t) i, mp4, item); + addMetaField((metadata_fields_t) i, tags, item); Ref<ConfigManager> cm = ConfigManager::getInstance(); @@ -190,32 +193,35 @@ } #if defined(HAVE_MAGIC) - u_int8_t *art_data; - u_int32_t art_data_len; + //u_int8_t *art_data; + //u_int32_t art_data_len; String art_mimetype; + const MP4TagArtwork *art; #ifdef HAVE_MP4_GET_METADATA_COVER_ART_COUNT - if (MP4GetMetadataCoverArtCount(mp4) && - MP4GetMetadataCoverArt(mp4, &art_data, &art_data_len)) + //if (MP4GetMetadataCoverArtCount(mp4) && + // MP4GetMetadataCoverArt(mp4, &art_data, &art_data_len)) + if (tags->artworkCount) #else - MP4GetMetadataCoverArt(mp4, &art_data, &art_data_len); + //MP4GetMetadataCoverArt(mp4, &art_data, &art_data_len); #endif { - if (art_data) + art = tags->artwork; + if (art->data) { try { - art_mimetype = ContentManager::getInstance()->getMimeTypeFromBuffer((void *)art_data, art_data_len); + art_mimetype = ContentManager::getInstance()->getMimeTypeFromBuffer((void *)art->data, art->size); if (!string_ok(art_mimetype)) art_mimetype = _(MIMETYPE_DEFAULT); } catch (Exception ex) { - free(art_data); + //free(art_data); throw ex; } - free(art_data); + //free(art_data); if (art_mimetype != _(MIMETYPE_DEFAULT)) { Ref<CdsResource> resource(new CdsResource(CH_MP4)); @@ -226,6 +232,7 @@ } } #endif + MP4TagsFree( tags ); MP4Close(mp4); } catch (Exception ex) @@ -247,24 +254,30 @@ String ctype = res->getParameters()->get(_(RESOURCE_CONTENT_TYPE)); + const MP4Tags* tags = MP4TagsAlloc(); + MP4TagsFetch( tags, mp4 ); + if (ctype != ID3_ALBUM_ART) throw _Exception(_("LibMP4V2Handler: got unknown content type: ") + ctype); #ifdef HAVE_MP4_GET_METADATA_COVER_ART_COUNT - if (!MP4GetMetadataCoverArtCount(mp4)) + if (!tags->artworkCount) throw _Exception(_("LibMP4V2Handler: resource has no album art information")); #endif - u_int8_t *art_data; - u_int32_t art_data_len; - if (MP4GetMetadataCoverArt(mp4, &art_data, &art_data_len)) + //u_int8_t *art_data; + //u_int32_t art_data_len; + const MP4TagArtwork *art; + art = tags->artwork; + if (art) { - if (art_data) + if (art->data) { - *data_size = (off_t)art_data_len; - Ref<IOHandler> h(new MemIOHandler((void *)art_data, art_data_len)); - free(art_data); + *data_size = (off_t)art->size; + Ref<IOHandler> h(new MemIOHandler((void *)art->data, art->size)); + //free(art_data); return h; } } + MP4TagsFree( tags ); throw _Exception(_("LibMP4V2Handler: could not serve album art " "for file") + item->getLocation() +
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.