[vlc-commits] stream_filter: smooth: handle quality custom attributes
Francois Cartegnie
git at videolan.org
Tue Oct 28 21:48:22 CET 2014
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Oct 28 19:15:26 2014 +0100| [1b820cdae4971a971f5a55ad0bf7e6d9bc974b45] | committer: Francois Cartegnie
stream_filter: smooth: handle quality custom attributes
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1b820cdae4971a971f5a55ad0bf7e6d9bc974b45
---
modules/stream_filter/smooth/smooth.c | 42 ++++++++++++++++++++++++++++++---
modules/stream_filter/smooth/smooth.h | 7 ++++++
modules/stream_filter/smooth/utils.c | 2 ++
3 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/modules/stream_filter/smooth/smooth.c b/modules/stream_filter/smooth/smooth.c
index 6e61aba..62fe468 100644
--- a/modules/stream_filter/smooth/smooth.c
+++ b/modules/stream_filter/smooth/smooth.c
@@ -145,6 +145,7 @@ static int parse_Manifest( stream_t *s )
uint8_t *WaveFormatEx;
sms_stream_t *sms = NULL;
quality_level_t *ql = NULL;
+ custom_attrs_t *cp = NULL;
int64_t start_time = 0, duration = 0;
int64_t computed_start_time = 0, computed_duration = 0;
unsigned next_track_id = 1;
@@ -230,6 +231,25 @@ static int parse_Manifest( stream_t *s )
sms->name = strdup( "text" );
}
}
+ else if ( !strcmp( node, "CustomAttributes" ) )
+ {
+ if (!sms || !ql || cp)
+ break;
+ cp = (custom_attrs_t *) calloc( 1, sizeof(*cp) );
+ }
+ else if ( !strcmp( node, "Attribute" ) )
+ {
+ if (!sms || !ql || !cp)
+ break;
+ while( (name = xml_ReaderNextAttr( vlc_reader, &value )) )
+ {
+ if( !strcmp( name, "Name" ) && !cp->psz_key )
+ cp->psz_key = strdup( value );
+ else
+ if( !strcmp( name, "Value" ) && !cp->psz_value )
+ cp->psz_value = strdup( value );
+ }
+ }
else if( !strcmp( node, "QualityLevel" ) )
{
if ( !sms )
@@ -355,10 +375,26 @@ static int parse_Manifest( stream_t *s )
break;
case XML_READER_ENDELEM:
- if( strcmp( node, "StreamIndex" ) )
+ if ( !strcmp( node, "CustomAttributes" ) )
+ {
+ if ( cp )
+ {
+ ARRAY_APPEND(ql->custom_attrs, cp);
+ cp = NULL;
+ }
+ }
+ else if ( !strcmp( node, "Attribute" ) )
+ {
+ if( !cp->psz_key || !cp->psz_value )
+ {
+ free( cp->psz_key );
+ free( cp->psz_value );
+ FREENULL( cp );
+ }
+ }
+ else if( strcmp( node, "StreamIndex" ) )
break;
-
- if ( sms )
+ else if ( sms )
{
vlc_array_append( p_sys->sms_streams, sms );
diff --git a/modules/stream_filter/smooth/smooth.h b/modules/stream_filter/smooth/smooth.h
index 5a546d8..c4121b1 100644
--- a/modules/stream_filter/smooth/smooth.h
+++ b/modules/stream_filter/smooth/smooth.h
@@ -52,6 +52,12 @@ typedef struct chunk_s
uint8_t *data;
} chunk_t;
+typedef struct
+{
+ char *psz_key;
+ char *psz_value;
+} custom_attrs_t;
+
typedef struct quality_level_s
{
int Index;
@@ -66,6 +72,7 @@ typedef struct quality_level_s
unsigned nBlockAlign;
unsigned id;
char *CodecPrivateData; /* hex encoded string */
+ DECL_ARRAY(custom_attrs_t *) custom_attrs;
} quality_level_t;
diff --git a/modules/stream_filter/smooth/utils.c b/modules/stream_filter/smooth/utils.c
index 3b17138..594483f 100644
--- a/modules/stream_filter/smooth/utils.c
+++ b/modules/stream_filter/smooth/utils.c
@@ -70,12 +70,14 @@ quality_level_t * ql_New( void )
if( unlikely( !ql ) ) return NULL;
ql->Index = -1;
+ ARRAY_INIT(ql->custom_attrs);
return ql;
}
void ql_Free( quality_level_t *qlevel )
{
free( qlevel->CodecPrivateData );
+ ARRAY_RESET(qlevel->custom_attrs);
free( qlevel );
qlevel = NULL;
}
More information about the vlc-commits
mailing list