+static void Ogg_ExtractXiphMeta( demux_t *p_demux, const void *p_headers, unsigned i_headers, unsigned i_skip )
+{
+ demux_sys_t *p_ogg = p_demux->p_sys;
+
+ unsigned pi_size[XIPH_MAX_HEADER_COUNT];
+ void *pp_data[XIPH_MAX_HEADER_COUNT];
+ unsigned i_count;
+ if( xiph_SplitHeaders( pi_size, pp_data, &i_count, i_headers, p_headers ) )
+ return;
+
+ /* TODO how to handle multiple comments properly ? */
+ if( i_count >= 2 && pi_size[1] > i_skip )
+ vorbis_ParseComment( &p_ogg->p_meta, (uint8_t*)pp_data[1] + i_skip, pi_size[1] - i_skip );
+
+ for( unsigned i = 0; i < i_count; i++ )
+ free( pp_data[i] );
+}
+static void Ogg_ExtractMeta( demux_t *p_demux, vlc_fourcc_t i_codec, const uint8_t *p_headers, int i_headers )
+{
+ demux_sys_t *p_ogg = p_demux->p_sys;
+
+ switch( i_codec )
+ {
+ /* 3 headers with the 2° one being the comments */
+ case VLC_CODEC_VORBIS:
+ Ogg_ExtractXiphMeta( p_demux, p_headers, i_headers, 1+6 );
+ break;
+ case VLC_CODEC_THEORA:
+ Ogg_ExtractXiphMeta( p_demux, p_headers, i_headers, 1+6 );
+ break;
+ case VLC_CODEC_SPEEX:
+ Ogg_ExtractXiphMeta( p_demux, p_headers, i_headers, 0 );
+ break;
+
+ /* N headers with the 2° one being the comments */
+ case VLC_CODEC_KATE:
+ /* 1 byte for header type, 7 bytes for magic, 1 reserved zero byte */
+ Ogg_ExtractXiphMeta( p_demux, p_headers, i_headers, 1+7+1 );
+ break;
+
+ /* TODO */
+ case VLC_CODEC_FLAC:
+ msg_Warn( p_demux, "Ogg_ExtractMeta does not support %4.4s", (const char*)&i_codec );
+ break;
+
+ /* No meta data */
+ case VLC_CODEC_CMML: /* CMML is XML text, doesn't have Vorbis comments */
+ case VLC_CODEC_DIRAC:
+ default:
+ break;
+ }
+ if( p_ogg->p_meta )
+ p_demux->info.i_update |= INPUT_UPDATE_META;
+}