Changeset a2d07c0596ca2994e8c463833516faab371d921e
- Timestamp:
- 24/09/06 17:09:25
(2 years ago)
- Author:
- Clément Stenac <zorglub@videolan.org>
- git-committer:
- Clément Stenac <zorglub@videolan.org> 1159110565 +0000
- git-parent:
[b59b5633c5d4fce70a9dddfb3e3230b0eaa64f73]
- git-author:
- Clément Stenac <zorglub@videolan.org> 1159110565 +0000
- Message:
Read album, also detect images in FLAC
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rb59b563 |
ra2d07c0 |
|
| 29 | 29 | #include <id3v2tag.h> |
|---|
| 30 | 30 | #include <mpegfile.h> |
|---|
| | 31 | #include <flacfile.h> |
|---|
| 31 | 32 | |
|---|
| 32 | 33 | static int ReadMeta ( vlc_object_t * ); |
|---|
| … | … | |
| 37 | 38 | vlc_module_end(); |
|---|
| 38 | 39 | |
|---|
| 39 | | bool checkID3Image( const TagLib::ID3v2::Tag *tag ) |
|---|
| | 40 | static bool checkID3Image( const TagLib::ID3v2::Tag *tag ) |
|---|
| 40 | 41 | { |
|---|
| 41 | 42 | TagLib::ID3v2::FrameList l = tag->frameListMap()[ "APIC" ]; |
|---|
| … | … | |
| 43 | 44 | } |
|---|
| 44 | 45 | |
|---|
| | 46 | /* Try detecting embedded art */ |
|---|
| | 47 | static void DetectImage( TagLib::FileRef f, vlc_meta_t *p_meta ) |
|---|
| | 48 | { |
|---|
| | 49 | if( TagLib::MPEG::File *mpeg = |
|---|
| | 50 | dynamic_cast<TagLib::MPEG::File *>(f.file() ) ) |
|---|
| | 51 | { |
|---|
| | 52 | if( mpeg->ID3v2Tag() && checkID3Image( mpeg->ID3v2Tag() ) ) |
|---|
| | 53 | vlc_meta_SetArtURL( p_meta, "APIC" ); |
|---|
| | 54 | } |
|---|
| | 55 | else if( TagLib::FLAC::File *flac = |
|---|
| | 56 | dynamic_cast<TagLib::FLAC::File *>(f.file() ) ) |
|---|
| | 57 | { |
|---|
| | 58 | if( flac->ID3v2Tag() && checkID3Image( flac->ID3v2Tag() ) ) |
|---|
| | 59 | vlc_meta_SetArtURL( p_meta, "APIC" ); |
|---|
| | 60 | } |
|---|
| | 61 | #if 0 |
|---|
| | 62 | /* This needs special additions to taglib */ |
|---|
| | 63 | * else if( TagLib::MP4::File *mp4 = |
|---|
| | 64 | dynamic_cast<TagLib::MP4::File *>( f.file() ) ) |
|---|
| | 65 | { |
|---|
| | 66 | TagLib::MP4::Tag *mp4tag = |
|---|
| | 67 | dynamic_cast<TagLib::MP4::Tag *>( mp4->tag() ); |
|---|
| | 68 | if( mp4tag && mp4tag->cover().size() ) |
|---|
| | 69 | vlc_meta_SetArtURL( p_meta, "MP4C" ); |
|---|
| | 70 | } |
|---|
| | 71 | #endif |
|---|
| | 72 | } |
|---|
| 45 | 73 | |
|---|
| 46 | 74 | static int ReadMeta( vlc_object_t *p_this ) |
|---|
| … | … | |
| 58 | 86 | vlc_meta_t *p_meta = (vlc_meta_t *)(p_demux->p_private ); |
|---|
| 59 | 87 | |
|---|
| 60 | | vlc_meta_SetTitle( p_meta, tag->title().toCString( true ) ); |
|---|
| 61 | | vlc_meta_SetArtist( p_meta, tag->artist().toCString( true ) ); |
|---|
| | 88 | #define SET( foo, bar ) vlc_meta_Set##foo( p_meta, tag->bar ().toCString(true)) |
|---|
| | 89 | SET( Title, title ); |
|---|
| | 90 | SET( Artist, artist ); |
|---|
| | 91 | SET( Album, album ); |
|---|
| | 92 | // SET( Comment, comment ); |
|---|
| | 93 | SET( Genre, genre ); |
|---|
| | 94 | // SET( Year, year ); Gra, this is an int, need to convert |
|---|
| | 95 | // SET( Tracknum , track ); Same |
|---|
| | 96 | #undef SET |
|---|
| | 97 | DetectImage( f, p_meta ); |
|---|
| 62 | 98 | |
|---|
| 63 | | if( TagLib::MPEG::File *mpeg = |
|---|
| 64 | | dynamic_cast<TagLib::MPEG::File *>(f.file() ) ) |
|---|
| 65 | | { |
|---|
| 66 | | if( mpeg->ID3v2Tag() && checkID3Image( mpeg->ID3v2Tag() ) ) |
|---|
| 67 | | { |
|---|
| 68 | | fprintf( stderr, "%s has APIC\n", p_meta->psz_title ); |
|---|
| 69 | | vlc_meta_SetArtURL( p_meta, "APIC" ); /// Means that the interface will use us to actually fetch it |
|---|
| 70 | | } |
|---|
| 71 | | } |
|---|
| 72 | 99 | return VLC_SUCCESS; |
|---|
| 73 | 100 | } |
|---|