Commit fa84b4cf authored by Laurent Aimar's avatar Laurent Aimar

Do not access input object from decoders.

parent 30815340
......@@ -365,27 +365,19 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
= pi_channels_guessed[frame.channels];
/* Adjust stream info when dealing with SBR/PS */
if( (p_sys->b_sbr != frame.sbr || p_sys->b_ps != frame.ps) &&
p_dec->p_parent->i_object_type == VLC_OBJECT_INPUT )
if( p_sys->b_sbr != frame.sbr || p_sys->b_ps != frame.ps )
{
input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
char *psz_cat;
const char *psz_ext = (frame.sbr && frame.ps) ? "SBR+PS" :
frame.sbr ? "SBR" : "PS";
msg_Dbg( p_dec, "AAC %s (channels: %u, samplerate: %lu)",
psz_ext, frame.channels, frame.samplerate );
if( asprintf( &psz_cat, _("Stream %d"), p_dec->fmt_in.i_id ) != -1 )
{
input_Control( p_input, INPUT_ADD_INFO, psz_cat,
_("AAC extension"), "%s", psz_ext );
input_Control( p_input, INPUT_ADD_INFO, psz_cat,
_("Channels"), "%d", frame.channels );
input_Control( p_input, INPUT_ADD_INFO, psz_cat,
_("Sample rate"), _("%d Hz"), frame.samplerate );
free( psz_cat );
}
if( !p_dec->p_description )
p_dec->p_description = vlc_meta_New();
if( p_dec->p_description )
vlc_meta_AddExtra( p_dec->p_description, _("AAC extension"), psz_ext );
p_sys->b_sbr = frame.sbr; p_sys->b_ps = frame.ps;
}
......
......@@ -702,16 +702,13 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, kate_packet *p_kp, block_t
}
/*****************************************************************************
* ParseKateComments: FIXME should be done in demuxer
* ParseKateComments:
*****************************************************************************/
static void ParseKateComments( decoder_t *p_dec )
{
input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
char *psz_name, *psz_value, *psz_comment;
int i = 0;
if( p_input->i_object_type != VLC_OBJECT_INPUT ) return;
while ( i < p_dec->p_sys->kc.comments )
{
psz_comment = strdup( p_dec->p_sys->kc.user_comments[i] );
......@@ -723,8 +720,11 @@ static void ParseKateComments( decoder_t *p_dec )
{
*psz_value = '\0';
psz_value++;
input_Control( p_input, INPUT_ADD_INFO, _("Kate comment"),
psz_name, "%s", psz_value );
if( !p_dec->p_description )
p_dec->p_description = vlc_meta_New();
if( p_dec->p_description )
vlc_meta_AddExtra( p_dec->p_description, psz_name, psz_value );
}
free( psz_comment );
i++;
......
......@@ -812,7 +812,7 @@ static block_t *SendPacket( decoder_t *p_dec, block_t *p_block )
}
/*****************************************************************************
* ParseSpeexComments: FIXME should be done in demuxer
* ParseSpeexComments:
*****************************************************************************/
#define readint(buf, base) (((buf[base+3]<<24)&0xff000000)| \
((buf[base+2]<<16)&0xff0000)| \
......@@ -821,40 +821,31 @@ static block_t *SendPacket( decoder_t *p_dec, block_t *p_block )
static void ParseSpeexComments( decoder_t *p_dec, ogg_packet *p_oggpacket )
{
input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
decoder_sys_t *p_sys = p_dec->p_sys;
char *p_buf = (char *)p_oggpacket->packet;
const SpeexMode *p_mode;
int i_len;
if( p_input->i_object_type != VLC_OBJECT_INPUT ) return;
assert( p_sys->p_header->mode < SPEEX_NB_MODES );
p_mode = speex_mode_list[p_sys->p_header->mode];
assert( p_mode != NULL );
input_Control( p_input, INPUT_ADD_INFO, _("Speex comment"), _("Mode"),
"%s%s", p_mode->modeName,
p_sys->p_header->vbr ? " VBR" : "" );
if( p_oggpacket->bytes < 8 )
if( !p_dec->p_description )
{
msg_Err( p_dec, "invalid/corrupted comments" );
p_dec->p_description = vlc_meta_New();
if( !p_dec->p_description )
return;
}
i_len = readint( p_buf, 0 ); p_buf += 4;
if( i_len > p_oggpacket->bytes - 4 )
/* */
char *psz_mode;
if( asprintf( &psz_mode, "%s%s", p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" ) >= 0 )
{
msg_Err( p_dec, "invalid/corrupted comments" );
return;
vlc_meta_AddExtra( p_dec->p_description, _("Mode"), psz_mode );
free( psz_mode );
}
input_Control( p_input, INPUT_ADD_INFO, _("Speex comment"), p_buf, "" );
/* TODO: finish comments parsing */
VLC_UNUSED( p_oggpacket );
}
/*****************************************************************************
......
......@@ -506,16 +506,13 @@ static picture_t *DecodePacket( decoder_t *p_dec, ogg_packet *p_oggpacket )
}
/*****************************************************************************
* ParseTheoraComments: FIXME should be done in demuxer
* ParseTheoraComments:
*****************************************************************************/
static void ParseTheoraComments( decoder_t *p_dec )
{
input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
char *psz_name, *psz_value, *psz_comment;
int i = 0;
if( p_input->i_object_type != VLC_OBJECT_INPUT ) return;
while ( i < p_dec->p_sys->tc.comments )
{
psz_comment = strdup( p_dec->p_sys->tc.user_comments[i] );
......@@ -527,8 +524,11 @@ static void ParseTheoraComments( decoder_t *p_dec )
{
*psz_value = '\0';
psz_value++;
input_Control( p_input, INPUT_ADD_INFO, _("Theora comment"),
psz_name, "%s", psz_value );
if( !p_dec->p_description )
p_dec->p_description = vlc_meta_New();
if( p_dec->p_description )
vlc_meta_AddExtra( p_dec->p_description, psz_name, psz_value );
}
free( psz_comment );
i++;
......
......@@ -605,16 +605,9 @@ static block_t *SendPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
*****************************************************************************/
static void ParseVorbisComments( decoder_t *p_dec )
{
input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
char *psz_name, *psz_value, *psz_comment;
input_item_t *p_item;
int i = 0;
if( p_input->i_object_type != VLC_OBJECT_INPUT )
return;
p_item = input_GetItem( p_input );
while( i < p_dec->p_sys->vc.comments )
{
psz_comment = strdup( p_dec->p_sys->vc.user_comments[i] );
......@@ -626,33 +619,12 @@ static void ParseVorbisComments( decoder_t *p_dec )
{
*psz_value = '\0';
psz_value++;
input_Control( p_input, INPUT_ADD_INFO, _("Vorbis comment"),
psz_name, "%s", psz_value );
/*TODO: dot he test at the beginning and save time !! */
#ifndef HAVE_TAGLIB
if( psz_value && ( *psz_value != '\0' ) )
{
if( !strcasecmp( psz_name, "artist" ) )
input_item_SetArtist( p_item, psz_value );
else if( !strcasecmp( psz_name, "title" ) )
{
input_item_SetTitle( p_item, psz_value );
p_item->psz_name = strdup( psz_value );
}
else if( !strcasecmp( psz_name, "album" ) )
{
input_item_SetAlbum( p_item, psz_value );
}
else if( !strcasecmp( psz_name, "musicbrainz_trackid" ) )
input_item_SetTrackID( p_item, psz_value );
#if 0 //not used
else if( !strcasecmp( psz_name, "musicbrainz_artistid" ) )
vlc_meta_SetArtistID( p_item, psz_value );
else if( !strcasecmp( psz_name, "musicbrainz_albumid" ) )
input_item_SetAlbumID( p_item, psz_value );
#endif
}
#endif
if( !p_dec->p_description )
p_dec->p_description = vlc_meta_New();
if( p_dec->p_description )
vlc_meta_AddExtra( p_dec->p_description, psz_name, psz_value );
if( !strcasecmp( psz_name, "REPLAYGAIN_TRACK_GAIN" ) ||
!strcasecmp( psz_name, "RG_RADIO" ) )
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment