X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Fflac.c;h=4140ed32fcedeb48fa1810f5436ee2774bf3b3ee;hb=f2a0cc3fb4839b410102e069c736dc6d2d72dbe2;hp=a041d781119a852604460d73f5990ba3e720e6c2;hpb=08ece243befadb2eaf51ce28067829733eaab3ab;p=vlc diff --git a/modules/demux/flac.c b/modules/demux/flac.c index a041d78111..4140ed32fc 100644 --- a/modules/demux/flac.c +++ b/modules/demux/flac.c @@ -2,7 +2,7 @@ * flac.c : FLAC demux module for vlc ***************************************************************************** * Copyright (C) 2001-2003 VideoLAN - * $Id: flac.c,v 1.12 2004/03/03 11:40:19 fenrir Exp $ + * $Id$ * * Authors: Gildas Bazin * @@ -37,6 +37,8 @@ static void Close ( vlc_object_t * ); vlc_module_begin(); set_description( _("FLAC demuxer") ); set_capability( "demux2", 155 ); + set_category( CAT_INPUT ); + set_subcategory( SUBCAT_INPUT_DEMUX ); set_callbacks( Open, Close ); add_shortcut( "flac" ); vlc_module_end(); @@ -54,6 +56,7 @@ struct demux_sys_t /* Packetizer */ decoder_t *p_packetizer; + vlc_meta_t *p_meta; }; #define STREAMINFO_SIZE 38 @@ -65,26 +68,19 @@ struct demux_sys_t static int Open( vlc_object_t * p_this ) { demux_t *p_demux = (demux_t*)p_this; + module_t *p_id3; demux_sys_t *p_sys; int i_peek; byte_t *p_peek; es_format_t fmt; /* Have a peep at the show. */ - if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) - { - /* Stream shorter than 4 bytes... */ - msg_Err( p_demux, "cannot peek()" ); - return VLC_EGENERIC; - } + if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC; if( p_peek[0]!='f' || p_peek[1]!='L' || p_peek[2]!='a' || p_peek[3]!='C' ) { - if( strncmp( p_demux->psz_demux, "flac", 4 ) ) - { - msg_Warn( p_demux, "flac module discarded (no startcode)" ); - return VLC_EGENERIC; - } + if( !p_demux->b_force ) return VLC_EGENERIC; + /* User forced */ msg_Err( p_demux, "this doesn't look like a flac stream, " "continuing anyway" ); @@ -95,6 +91,7 @@ static int Open( vlc_object_t * p_this ) p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'f', 'l', 'a', 'c' ) ); p_sys->b_start = VLC_TRUE; + p_sys->p_meta = 0; /* We need to read and store the STREAMINFO metadata */ i_peek = stream_Peek( p_demux->s, &p_peek, 8 ); @@ -136,19 +133,27 @@ static int Open( vlc_object_t * p_this ) STREAMINFO_SIZE + 4 ); p_sys->p_packetizer->p_module = - module_Need( p_sys->p_packetizer, "packetizer", NULL ); + module_Need( p_sys->p_packetizer, "packetizer", NULL, 0 ); if( !p_sys->p_packetizer->p_module ) { if( p_sys->p_packetizer->fmt_in.p_extra ) free( p_sys->p_packetizer->fmt_in.p_extra ); - vlc_object_destroy( p_sys->p_packetizer ); + msg_Err( p_demux, "cannot find flac packetizer" ); return VLC_EGENERIC; } p_sys->p_es = es_out_Add( p_demux->out, &fmt ); + /* Parse possible id3 header */ + if( ( p_id3 = module_Need( p_demux, "id3", NULL, 0 ) ) ) + { + p_sys->p_meta = (vlc_meta_t *)p_demux->p_private; + p_demux->p_private = NULL; + module_Unneed( p_demux, p_id3 ); + } + return VLC_SUCCESS; } @@ -168,7 +173,7 @@ static void Close( vlc_object_t * p_this ) /* Delete the decoder */ vlc_object_destroy( p_sys->p_packetizer ); - + if( p_sys->p_meta ) vlc_meta_Delete( p_sys->p_meta ); free( p_sys ); } @@ -223,8 +228,16 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) { /* demux_sys_t *p_sys = p_demux->p_sys; */ /* FIXME bitrate */ - return demux2_vaControlHelper( p_demux->s, - 0, -1, - 8*0, 1, i_query, args ); + if( i_query == DEMUX_SET_TIME ) return VLC_EGENERIC; + else if( i_query == DEMUX_GET_META ) + { + vlc_meta_t **pp_meta = (vlc_meta_t **)va_arg( args, vlc_meta_t** ); + if( p_demux->p_sys->p_meta ) + *pp_meta = vlc_meta_Duplicate( p_demux->p_sys->p_meta ); + else *pp_meta = NULL; + return VLC_SUCCESS; + } + else return demux2_vaControlHelper( p_demux->s, 0, -1, + 8*0, 1, i_query, args ); }