Changeset 98a6a9349091549d591be703aad7392b47b4e2a6
- Timestamp:
- 10/02/07 04:11:11 (1 year ago)
- git-parent:
- Files:
-
- include/vlc_common.h (modified) (1 diff)
- include/vlc_demux.h (modified) (1 diff)
- modules/codec/ffmpeg/demux.c (modified) (1 diff)
- modules/demux/flac.c (modified) (10 diffs)
- modules/demux/mpc.c (modified) (1 diff)
- modules/demux/mpeg/m4a.c (modified) (1 diff)
- modules/demux/mpeg/mpga.c (modified) (5 diffs)
- modules/demux/ogg.c (modified) (1 diff)
- modules/demux/tta.c (modified) (2 diffs)
- modules/meta_engine/id3tag.c (modified) (2 diffs)
- modules/meta_engine/taglib.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/vlc_common.h
rf010396 r98a6a93 282 282 typedef struct stream_sys_t stream_sys_t; 283 283 typedef struct demux_t demux_t; 284 typedef struct demux_meta_t demux_meta_t; 284 285 typedef struct demux_sys_t demux_sys_t; 285 286 typedef struct es_out_t es_out_t; include/vlc_demux.h
rf516f42 r98a6a93 73 73 }; 74 74 75 76 /* demux_meta_t is returned by "meta reader" module to the demuxer */ 77 struct demux_meta_t 78 { 79 vlc_meta_t *p_meta; /**< meta data */ 80 81 int i_attachments; /**< number of attachments */ 82 input_attachment_t **attachments; /**< array of attachments */ 83 }; 84 75 85 enum demux_query_e 76 86 { modules/codec/ffmpeg/demux.c
r75ebd70 r98a6a93 260 260 if( p_input ) 261 261 { 262 p_demux->p_private = malloc( sizeof( demux_meta_t ) ); 263 if( !p_demux->p_private ) 264 { 265 vlc_object_release( p_input ); 266 return VLC_ENOMEM; 267 } 262 268 module_t *p_meta = module_Need( p_demux, "meta reader", NULL, 0 ); 263 269 if( p_meta ) 264 270 { 265 vlc_meta_Merge( input_GetItem(p_input)->p_meta, (vlc_meta_t*)(p_demux->p_private ) ); 271 demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private; 272 vlc_meta_Merge( input_GetItem(p_input)->p_meta, 273 p_demux_meta->p_meta ); 274 vlc_meta_Delete( p_demux_meta->p_meta ); 266 275 module_Unneed( p_demux, p_meta ); 276 TAB_CLEAN( p_demux_meta->i_attachments, 277 p_demux_meta->attachments ); 267 278 } 268 279 vlc_object_release( p_input ); 280 free( p_demux->p_private ); 269 281 } 270 282 modules/demux/flac.c
r3f07af6 r98a6a93 79 79 80 80 /* */ 81 int i_attachment ;82 input_attachment_t **attachment ;81 int i_attachments; 82 input_attachment_t **attachments; 83 83 int i_cover_idx; 84 84 int i_cover_score; … … 124 124 p_sys->p_es = NULL; 125 125 TAB_INIT( p_sys->i_seekpoint, p_sys->seekpoint ); 126 TAB_INIT( p_sys->i_attachment , p_sys->attachment);126 TAB_INIT( p_sys->i_attachments, p_sys->attachments); 127 127 p_sys->i_cover_idx = 0; 128 128 p_sys->i_cover_score = 0; … … 156 156 157 157 /* Parse possible id3 header */ 158 p_demux->p_private = malloc( sizeof( demux_meta_t ) ); 159 if( !p_demux->p_private ) 160 return VLC_ENOMEM; 158 161 if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) ) 159 162 { 160 vlc_meta_t *p_meta = (vlc_meta_t *)p_demux->p_private; 163 demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private; 164 vlc_meta_t *p_meta = p_demux_meta->p_meta; 161 165 162 166 if( !p_sys->p_meta ) … … 171 175 p_demux->p_private = NULL; 172 176 module_Unneed( p_demux, p_id3 ); 173 } 174 175 if( p_sys->i_cover_idx < p_sys->i_attachment ) 177 int i; 178 for( i = 0; i < p_demux_meta->i_attachments; i++ ) 179 TAB_APPEND_CAST( (input_attachment_t**), 180 p_sys->i_attachments, p_sys->attachments, 181 p_demux_meta->attachments[p_demux_meta->i_attachments] ); 182 183 TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments ); 184 } 185 free( p_demux->p_private ); 186 187 if( p_sys->i_cover_idx < p_sys->i_attachments ) 176 188 { 177 189 char psz_url[128]; … … 179 191 p_sys->p_meta = vlc_meta_New(); 180 192 snprintf( psz_url, sizeof(psz_url), "attachment://%s", 181 p_sys->attachment [p_sys->i_cover_idx]->psz_name );193 p_sys->attachments[p_sys->i_cover_idx]->psz_name ); 182 194 vlc_meta_Set( p_sys->p_meta, vlc_meta_ArtworkURL, psz_url ); 183 195 } … … 193 205 demux_t *p_demux = (demux_t*)p_this; 194 206 demux_sys_t *p_sys = p_demux->p_sys; 207 208 TAB_CLEAN( p_sys->i_seekpoint, p_sys->seekpoint ); 209 TAB_CLEAN( p_sys->i_attachments, p_sys->attachments); 195 210 196 211 /* Unneed module */ … … 395 410 int i; 396 411 397 if( p_sys->i_attachment <= 0 )412 if( p_sys->i_attachments <= 0 ) 398 413 return VLC_EGENERIC; 399 414 400 *pi_int = p_sys->i_attachment ;;401 *ppp_attach = malloc( sizeof(input_attachment_t**) * p_sys->i_attachment );402 for( i = 0; i < p_sys->i_attachment ; i++ )403 *(ppp_attach)[i] = vlc_input_attachment_Duplicate( p_sys->attachment[i] );415 *pi_int = p_sys->i_attachments;; 416 *ppp_attach = malloc( sizeof(input_attachment_t**) * p_sys->i_attachments ); 417 for( i = 0; i < p_sys->i_attachments; i++ ) 418 (*ppp_attach)[i] = vlc_input_attachment_Duplicate( p_sys->attachments[i] ); 404 419 return VLC_SUCCESS; 405 420 } … … 473 488 s->i_byte_offset = 0; 474 489 TAB_APPEND( p_sys->i_seekpoint, p_sys->seekpoint, s ); 475 476 477 490 478 491 b_last = (*pp_streaminfo)[4]&0x80; … … 700 713 i_type, psz_mime, psz_description, i_len ); 701 714 702 snprintf( psz_name, sizeof(psz_name), "picture%d", p_sys->i_attachment );715 snprintf( psz_name, sizeof(psz_name), "picture%d", p_sys->i_attachments ); 703 716 if( !strcasecmp( psz_mime, "image/jpeg" ) ) 704 717 strcat( psz_name, ".jpg" ); … … 708 721 p_attachment = vlc_input_attachment_New( psz_name, psz_mime, psz_description, 709 722 p_data, i_data ); 710 TAB_APPEND( p_sys->i_attachment , p_sys->attachment, p_attachment );723 TAB_APPEND( p_sys->i_attachments, p_sys->attachments, p_attachment ); 711 724 712 725 if( i_type >= 0 && i_type < sizeof(pi_cover_score)/sizeof(pi_cover_score[0]) && 713 726 p_sys->i_cover_score < pi_cover_score[i_type] ) 714 727 { 715 p_sys->i_cover_idx = p_sys->i_attachment -1;728 p_sys->i_cover_idx = p_sys->i_attachments-1; 716 729 p_sys->i_cover_score = pi_cover_score[i_type]; 717 730 } modules/demux/mpc.c
r3f07af6 r98a6a93 190 190 191 191 /* Parse possible id3 header */ 192 p_demux->p_private = malloc( sizeof( demux_meta_t ) ); 193 if( !p_demux->p_private ) 194 return VLC_ENOMEM; 192 195 if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) ) 193 196 { 194 p_sys->p_meta = (vlc_meta_t *)p_demux->p_private;195 p_ demux->p_private = NULL;197 demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private; 198 p_sys->p_meta = p_demux_meta->p_meta; 196 199 module_Unneed( p_demux, p_id3 ); 197 } 200 TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments ); 201 } 202 free( p_demux->p_private ); 198 203 199 204 if( !p_sys->p_meta ) modules/demux/mpeg/m4a.c
r3f07af6 r98a6a93 116 116 117 117 /* Parse possible id3 header */ 118 p_demux->p_private = malloc( sizeof( demux_meta_t ) ); 119 if( !p_demux->p_private ) 120 return VLC_ENOMEM; 118 121 if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) ) 119 122 { 120 p_sys->meta = (vlc_meta_t *)p_demux->p_private; 123 demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private; 124 p_sys->meta = p_demux_meta->p_meta; 121 125 p_demux->p_private = NULL; 122 126 module_Unneed( p_demux, p_id3 ); 123 } 127 TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments ); 128 } 129 free( p_demux->p_private ); 124 130 return VLC_SUCCESS; 125 131 } modules/demux/mpeg/mpga.c
r3f07af6 r98a6a93 75 75 int i_xing_frame_samples; 76 76 block_t *p_block_in, *p_block_out; 77 78 int i_attachments; 79 input_attachment_t **attachments; 77 80 }; 78 81 … … 253 256 254 257 /* Parse possible id3 header */ 258 p_demux->p_private = malloc( sizeof( demux_meta_t ) ); 259 if( !p_demux->p_private ) 260 return VLC_ENOMEM; 255 261 if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) ) 256 262 { 257 p_sys->meta = (vlc_meta_t *)p_demux->p_private; 263 demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private; 264 p_sys->meta = p_demux_meta->p_meta; 258 265 p_demux->p_private = NULL; 259 266 module_Unneed( p_demux, p_id3 ); 260 } 267 p_sys->i_attachments = p_demux_meta->i_attachments; 268 p_sys->attachments = p_demux_meta->attachments; 269 } 270 free( p_demux->p_private ); 261 271 262 272 /* */ … … 338 348 if( p_sys->p_block_out ) block_Release( p_sys->p_block_out ); 339 349 350 TAB_CLEAN( p_sys->i_attachments, p_sys->attachments); 351 340 352 free( p_sys ); 341 353 } … … 351 363 int i_ret; 352 364 365 input_attachment_t ***ppp_attach; 366 int *pi_int, i; 367 353 368 switch( i_query ) 354 369 { … … 356 371 p_meta = (vlc_meta_t *)va_arg( args, vlc_meta_t* ); 357 372 vlc_meta_Merge( p_meta, p_sys->meta ); 373 return VLC_SUCCESS; 374 375 case DEMUX_GET_ATTACHMENTS: 376 ppp_attach = 377 (input_attachment_t***)va_arg( args, input_attachment_t*** ); 378 pi_int = (int*)va_arg( args, int * ); 379 380 if( p_sys->i_attachments <= 0 ) 381 return VLC_EGENERIC; 382 383 *pi_int = p_sys->i_attachments; 384 *ppp_attach = malloc( sizeof(input_attachment_t**) * p_sys->i_attachments ); 385 for( i = 0; i < p_sys->i_attachments; i++ ) 386 (*ppp_attach)[i] = vlc_input_attachment_Duplicate( p_sys->attachments[i] ); 358 387 return VLC_SUCCESS; 359 388 modules/demux/ogg.c
r3f07af6 r98a6a93 208 208 if( p_input ) 209 209 { 210 p_demux->p_private = malloc( sizeof( demux_meta_t ) ); 211 if( !p_demux->p_private ) 212 { 213 vlc_object_release( p_input ); 214 return VLC_ENOMEM; 215 } 210 216 module_t *p_meta = module_Need( p_demux, "meta reader", NULL, 0 ); 211 217 if( p_meta ) 212 218 { 213 vlc_meta_Merge( input_GetItem(p_input)->p_meta, (vlc_meta_t*)(p_demux->p_private ) ); 219 demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private; 220 vlc_meta_Merge( input_GetItem(p_input)->p_meta, 221 p_demux_meta->p_meta ); 222 vlc_meta_Delete( p_demux_meta->p_meta ); 214 223 module_Unneed( p_demux, p_meta ); 224 TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments ); 215 225 } 216 226 vlc_object_release( p_input ); 217 return VLC_SUCCESS; 218 } 219 if( p_input ) 220 vlc_object_release( p_input ); 227 free( p_demux->p_private ); 228 } 221 229 222 230 /* Initialize the Ogg physical bitstream parser */ modules/demux/tta.c
r3f07af6 r98a6a93 106 106 p_demux->pf_control = Control; 107 107 p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); 108 108 109 109 /* Read the metadata */ 110 110 es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'T', 'T', 'A', '1' ) ); … … 139 139 free( p_seektable ); 140 140 p_sys->i_start = stream_Tell( p_demux->s ); 141 141 142 142 #if 0 143 143 /* Parse possible id3 header */ 144 p_demux->p_private = malloc( sizeof( demux_meta_t ) ); 145 if( !p_demux->p_private ) 146 return VLC_ENOMEM; 144 147 if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) ) 145 148 { 146 p_sys->p_meta = (vlc_meta_t *)p_demux->p_private; 149 demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private; 150 p_sys->p_meta = p_demux_meta->p_meta; 147 151 p_demux->p_private = NULL; 148 152 module_Unneed( p_demux, p_id3 ); 153 TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments ); 149 154 } 155 free( p_demux->p_private ); 150 156 151 157 if( !p_sys->p_meta ) modules/meta_engine/id3tag.c
r6ee1e19 r98a6a93 62 62 struct id3_tag *p_id3_tag; 63 63 struct id3_frame *p_frame; 64 vlc_meta_t *p_meta = (vlc_meta_t *)p_demux->p_private; 64 demux_meta_t *p_demux_meta = p_demux->p_private; 65 vlc_meta_t *p_meta; 65 66 int i; 67 68 TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments ); 69 p_demux_meta->p_meta = NULL; 66 70 67 71 p_id3_tag = id3_tag_parse( p_data, i_size ); … … 69 73 return; 70 74 71 if( !p_meta ) 72 p_demux->p_private = p_meta = vlc_meta_New(); 75 p_demux_meta->p_meta = p_meta = vlc_meta_New(); 73 76 74 77 #define ID_IS( a ) (!strcmp( p_frame->id, a )) modules/meta_engine/taglib.cpp
r6ee1e19 r98a6a93 36 36 #include <mpegfile.h> 37 37 #include <flacfile.h> 38 #include <attachedpictureframe.h> 38 39 #if 0 39 40 #include <oggflacfile.h> … … 64 65 vlc_module_end(); 65 66 66 static bool checkID3Image( const TagLib::ID3v2::Tag *p_tag ) 67 /* Try detecting embedded art */ 68 static void DetectImage( TagLib::FileRef f, demux_t *p_demux ) 67 69 { 68 TagLib::ID3v2::FrameList l = p_tag->frameListMap()[ "APIC" ]; 69 return !l.isEmpty(); 70 } 71 72 /* Try detecting embedded art */ 73 static void DetectImage( TagLib::FileRef f, vlc_meta_t *p_meta ) 74 { 70 demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private; 71 vlc_meta_t *p_meta = p_demux_meta->p_meta; 72 TagLib::ID3v2::Tag *p_tag; 73 int i_score = -1; 74 75 /* Preferred type of image 76 * The 21 types are defined in id3v2 standard: 77 * http://www.id3.org/id3v2.4.0-frames */ 78 static const int pi_cover_score[] = { 79 0, /* Other */ 80 5, /* 32x32 PNG image that should be used as the file icon */ 81 4, /* File icon of a different size or format. */ 82 20, /* Front cover image of the album. */ 83 19, /* Back cover image of the album. */ 84 13, /* Inside leaflet page of the album. */ 85 18, /* Image from the album itself. */ 86 17, /* Picture of the lead artist or soloist. */ 87 16, /* Picture of the artist or performer. */ 88 14, /* Picture of the conductor. */ 89 15, /* Picture of the band or orchestra. */ 90 9, /* Picture of the composer. */ 91 8, /* Picture of the lyricist or text writer. */ 92 7, /* Picture of the recording location or studio. */ 93 10, /* Picture of the artists during recording. */ 94 11, /* Picture of the artists during performance. */ 95 6, /* Picture from a movie or video related to the track. */ 96 1, /* Picture of a large, coloured fish. */ 97 12, /* Illustration related to the track. */ 98 3, /* Logo of the band or performer. */ 99 2 /* Logo of the publisher (record company). */ 100 }; 101 75 102 if( TagLib::MPEG::File *mpeg = 76 103 dynamic_cast<TagLib::MPEG::File *>(f.file() ) ) 77 104 { 78 if( mpeg->ID3v2Tag() && checkID3Image( mpeg->ID3v2Tag() ) ) 79 vlc_meta_SetArtURL( p_meta, "APIC" ); 80 } 105 p_tag = mpeg->ID3v2Tag(); 106 if( !p_tag ) 107 return; 108 TagLib::ID3v2::FrameList list = p_tag->frameListMap()[ "APIC" ]; 109 if( list.isEmpty() ) 110 return; 111 input_thread_t *p_input = (input_thread_t *) 112 vlc_object_find( p_demux,VLC_OBJECT_INPUT, FIND_PARENT ); 113 if( !p_input ) 114 return; 115 input_item_t *p_item = input_GetItem( p_input ); 116 TagLib::ID3v2::AttachedPictureFrame *p_apic; 117 118 TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments ); 119 for( TagLib::ID3v2::FrameList::Iterator iter = list.begin(); 120 iter != list.end(); iter++ ) 121 { 122 p_apic = dynamic_cast<TagLib::ID3v2::AttachedPictureFrame*>(*iter); 123 input_attachment_t *p_attachment; 124 125 const char *psz_name, *psz_mime, *psz_description; 126 TagLib::ByteVector p_data_taglib; const char *p_data; int i_data; 127 128 psz_mime = p_apic->mimeType().toCString(true); 129 psz_description = p_apic->description().toCString(true); 130 psz_name = psz_description; 131 132 p_data_taglib = p_apic->picture(); 133 p_data = p_data_taglib.data(); 134 i_data = p_data_taglib.size(); 135 136 msg_Dbg( p_demux, "Found embedded art: %s (%s) is %i bytes", 137 psz_name, psz_mime, i_data ); 138 139 p_attachment = vlc_input_attachment_New( psz_name, psz_mime, 140 psz_description, p_data, i_data ); 141 TAB_APPEND_CAST( (input_attachment_t**), 142 p_demux_meta->i_attachments, p_demux_meta->attachments, 143 p_attachment ); 144 145 if( pi_cover_score[p_apic->type()] > i_score ) 146 { 147 i_score = pi_cover_score[p_apic->type()]; 148 char *psz_url; 149 if( asprintf( &psz_url, "attachment://%s", 150 p_attachment->psz_name ) == -1 ) 151 { 152 vlc_object_release( p_input ); 153 return; 154 } 155 vlc_meta_SetArtURL( p_meta, psz_url ); 156 free( psz_url ); 157 } 158 } 159 vlc_object_release( p_input ); 160 } 161 #if 0 162 //flac embedded images are extracted in the flac demuxer 81 163 else if( TagLib::FLAC::File *flac = 82 164 dynamic_cast<TagLib::FLAC::File *>(f.file() ) ) 83 165 { 84 if( flac->ID3v2Tag() && checkID3Image( flac->ID3v2Tag() ) ) 166 p_tag = flac->ID3v2Tag(); 167 if( p_tag ) 168 return; 169 TagLib::ID3v2::FrameList l = p_tag->frameListMap()[ "APIC" ]; 170 if( l.isEmpty() ) 171 return; 85 172 vlc_meta_SetArtURL( p_meta, "APIC" ); 86 173 } 174 #endif 87 175 #if 0 88 176 /* This needs special additions to taglib */ … … 100 188 static int ReadMeta( vlc_object_t *p_this ) 101 189 { 102 demux_t *p_demux = (demux_t *)p_this; 103 104 if( strncmp( p_demux->psz_access, "file", 4 ) ) 105 return VLC_EGENERIC; 190 demux_t *p_demux = (demux_t *)p_this; 191 demux_meta_t *p_demux_meta = (demux_meta_t*)p_demux->p_private; 192 vlc_meta_t *p_meta = p_demux_meta->p_meta; 193 194 TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments ); 195 p_demux_meta->p_meta = NULL; 106 196 107 197 TagLib::FileRef f( p_demux->psz_path ); … … 112 202 return VLC_EGENERIC; 113 203 114 if( !p_demux->p_private ) 115 p_demux->p_private = (void*)vlc_meta_New(); 116 vlc_meta_t *p_meta = (vlc_meta_t *)(p_demux->p_private ); 204 p_demux_meta->p_meta = p_meta = vlc_meta_New(); 117 205 TagLib::Tag *p_tag = f.tag(); 118 206 … … 204 292 vlc_object_release( p_input ); 205 293 } 206 294 207 295 } 208 296 #if 0 /* at this moment, taglib is unable to detect ogg/flac files … … 261 349 #undef SETINT 262 350 263 DetectImage( f, p_ meta);351 DetectImage( f, p_demux ); 264 352 265 353 return VLC_SUCCESS; … … 271 359 meta_export_t *p_export = (meta_export_t *)p_playlist->p_private; 272 360 input_item_t *p_item = p_export->p_item; 273 361 274 362 if( p_item == NULL ) 275 363 { … … 349 437 WRITE( EncodedBy, "TENC" ); 350 438 WRITE( Language, "TLAN" ); 351 439 352 440 #undef WRITE 353 441 }
