Commit 9f2442c9 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Ogg: Parse chapters in comments

Ref #6895
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 1009e7f5
......@@ -578,7 +578,7 @@ static void ParseComment( demux_t *p_demux, const uint8_t *p_data, int i_data )
if( i_data < 4 )
return;
vorbis_ParseComment( &p_sys->p_meta, &p_data[4], i_data - 4, NULL, NULL );
vorbis_ParseComment( &p_sys->p_meta, &p_data[4], i_data - 4, NULL, NULL, NULL, NULL );
}
......
......@@ -188,6 +188,7 @@ static int Open( vlc_object_t * p_this )
/* */
p_sys->p_meta = NULL;
TAB_INIT( p_sys->i_seekpoints, p_sys->pp_seekpoints );
return VLC_SUCCESS;
}
......@@ -208,6 +209,8 @@ static void Close( vlc_object_t *p_this )
if( p_sys->p_old_stream )
Ogg_LogicalStreamDelete( p_demux, p_sys->p_old_stream );
TAB_CLEAN( p_sys->i_seekpoints, p_sys->pp_seekpoints );
free( p_sys );
}
......@@ -1783,7 +1786,8 @@ static void Ogg_ExtractXiphMeta( demux_t *p_demux, const void *p_headers, unsign
/* 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,
&p_ogg->i_attachments, &p_ogg->attachments );
&p_ogg->i_attachments, &p_ogg->attachments,
&p_ogg->i_seekpoints, &p_ogg->pp_seekpoints );
for( unsigned i = 0; i < i_count; i++ )
free( pp_data[i] );
......
......@@ -133,9 +133,10 @@ struct demux_sys_t
mtime_t i_st_pts;
/* */
vlc_meta_t *p_meta;
int i_seekpoints;
seekpoint_t **pp_seekpoints;
/* */
int i_attachments;
......
......@@ -23,6 +23,7 @@
#include <vlc_charset.h>
#include <vlc_strings.h>
#include <vlc_input.h>
static input_attachment_t* ParseFlacPicture( const uint8_t *p_data, int i_data, int i_attachments, int *i_type )
{
......@@ -70,8 +71,10 @@ error:
return p_attachment;
}
static inline void vorbis_ParseComment( vlc_meta_t **pp_meta, const uint8_t *p_data, int i_data,
int *i_attachments, input_attachment_t ***attachments)
static inline void vorbis_ParseComment( vlc_meta_t **pp_meta,
const uint8_t *p_data, int i_data,
int *i_attachments, input_attachment_t ***attachments,
int *i_seekpoint, seekpoint_t ***ppp_seekpoint )
{
int n;
int i_comment;
......@@ -185,6 +188,31 @@ static inline void vorbis_ParseComment( vlc_meta_t **pp_meta, const uint8_t *p_d
*i_attachments, *attachments, p_attachment );
}
}
else if( !strncasecmp(psz_comment, "chapter", strlen("chapter")) )
{
if( ppp_seekpoint == NULL )
continue;
int i_chapt;
if( strstr( psz_comment, "name") && sscanf( psz_comment, "chapter%i=", &i_chapt ) == 1 )
{
char *p = strchr( psz_comment, '=' );
*p++ = '\0';
}
else if( sscanf( psz_comment, "chapter %i=", &i_chapt ) == 1 )
{
int h, m, s, ms;
char *p = strchr( psz_comment, '=' );
*p++ = '\0';
if( sscanf( p, "%d:%d:%d.%d", &h, &m, &s, &ms ) == 4 )
{
seekpoint_t *sk = vlc_seekpoint_New();
sk->i_time_offset = ((h * 3600 + m * 60 + s) *1000 + ms) * 1000;
TAB_APPEND_CAST( (seekpoint_t**), *i_seekpoint, *ppp_seekpoint, sk );
}
}
}
else if( strchr( psz_comment, '=' ) )
{
/* generic (PERFORMER/LICENSE/ORGANIZATION/LOCATION/CONTACT/ISRC,
......
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