[vlc-commits] demux: asf: add bitrate exclusion object handling

Francois Cartegnie git at videolan.org
Sat Nov 23 10:25:04 CET 2013


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Nov 23 08:30:43 2013 +0100| [f242004f65653c8a7b5fd483ba3b0215196efaca] | committer: Francois Cartegnie

demux: asf: add bitrate exclusion object handling

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f242004f65653c8a7b5fd483ba3b0215196efaca
---

 modules/demux/asf/libasf.c |   57 ++++++++++++++++++++++++++++++++++++++++++++
 modules/demux/asf/libasf.h |   10 ++++++++
 2 files changed, 67 insertions(+)

diff --git a/modules/demux/asf/libasf.c b/modules/demux/asf/libasf.c
index d0d5a10..afc57eb 100644
--- a/modules/demux/asf/libasf.c
+++ b/modules/demux/asf/libasf.c
@@ -1066,6 +1066,59 @@ static void ASF_FreeObject_stream_prioritization( asf_object_t *p_obj)
     FREENULL( p_sp->pi_priority_flag );
 }
 
+static int ASF_ReadObject_bitrate_mutual_exclusion( stream_t *s, asf_object_t *p_obj )
+{
+    asf_object_bitrate_mutual_exclusion_t *p_ex = &p_obj->bitrate_mutual_exclusion;
+    const uint8_t *p_peek, *p_data;
+    int i_peek;
+
+    if( ( i_peek = stream_Peek( s, &p_peek, p_ex->i_object_size ) ) < 42 )
+       return VLC_EGENERIC;
+
+    p_data = &p_peek[24];
+
+    if( !ASF_HAVE( 16 + 2 * sizeof(uint16_t) ) ) /* at least one entry */
+        return VLC_EGENERIC;
+
+    if ( guidcmp( (const guid_t *) p_data, &asf_guid_mutex_language ) )
+        p_ex->exclusion_type = LANGUAGE;
+    else if ( guidcmp( (const guid_t *) p_data, &asf_guid_mutex_bitrate ) )
+        p_ex->exclusion_type = BITRATE;
+    ASF_SKIP( 16 );
+
+    p_ex->i_stream_number_count = ASF_READ2();
+    p_ex->pi_stream_numbers = calloc( p_ex->i_stream_number_count, sizeof(uint16_t) );
+    if ( ! p_ex->pi_stream_numbers )
+    {
+        p_ex->i_stream_number_count = 0;
+        return VLC_ENOMEM;
+    }
+
+    for( uint16_t i = 0; i < p_ex->i_stream_number_count; i++ )
+    {
+        if( !ASF_HAVE(2) )
+            break;
+        p_ex->pi_stream_numbers[i] = ASF_READ2();
+    }
+
+#ifdef ASF_DEBUG
+    msg_Dbg( s, "read \"bitrate exclusion object\" type %s",
+             p_ex->exclusion_type == LANGUAGE ? "Language" :
+             ( p_ex->exclusion_type == BITRATE ) ? "Bitrate" : "Unknown"
+    );
+    for( uint16_t i = 0; i < p_ex->i_stream_number_count; i++ )
+        msg_Dbg( s, "  - stream=%i", p_ex->pi_stream_numbers[i] );
+#endif
+
+    return VLC_SUCCESS;
+}
+static void ASF_FreeObject_bitrate_mutual_exclusion( asf_object_t *p_obj)
+{
+    asf_object_bitrate_mutual_exclusion_t *p_ex = &p_obj->bitrate_mutual_exclusion;
+
+    FREENULL( p_ex->pi_stream_numbers );
+    p_ex->i_stream_number_count = 0;
+}
 
 static int ASF_ReadObject_extended_content_description( stream_t *s,
                                                         asf_object_t *p_obj)
@@ -1323,6 +1376,9 @@ static const struct
     { &asf_object_stream_prioritization, ASF_OBJECT_OTHER,
       ASF_ReadObject_stream_prioritization,
       ASF_FreeObject_stream_prioritization },
+    { &asf_object_bitrate_mutual_exclusion_guid, ASF_OBJECT_OTHER,
+      ASF_ReadObject_bitrate_mutual_exclusion,
+      ASF_FreeObject_bitrate_mutual_exclusion },
     { &asf_object_extended_content_description, ASF_OBJECT_OTHER,
       ASF_ReadObject_extended_content_description,
       ASF_FreeObject_extended_content_description },
@@ -1481,6 +1537,7 @@ static const struct
     { &asf_object_extended_stream_properties_guid, "Extended Stream Properties" },
     { &asf_object_advanced_mutual_exclusion, "Advanced Mutual Exclusion" },
     { &asf_object_stream_prioritization, "Stream Prioritization" },
+    { &asf_object_bitrate_mutual_exclusion_guid, "Bitrate Mutual Exclusion" },
     { &asf_object_extended_content_description, "Extended content description"},
     { &asf_object_content_encryption_guid, "Content Encryption"},
     { &asf_object_advanced_content_encryption_guid, "Advanced Content Encryption"},
diff --git a/modules/demux/asf/libasf.h b/modules/demux/asf/libasf.h
index 30103a0..5271fec 100644
--- a/modules/demux/asf/libasf.h
+++ b/modules/demux/asf/libasf.h
@@ -306,6 +306,15 @@ typedef struct
 {
     ASF_OBJECT_COMMON
 
+    asf_exclusion_type_t exclusion_type;
+    uint16_t i_stream_number_count;
+    uint16_t *pi_stream_numbers;
+} asf_object_bitrate_mutual_exclusion_t;
+
+typedef struct
+{
+    ASF_OBJECT_COMMON
+
     int i_count;
     char **ppsz_name;
     char **ppsz_value;
@@ -353,6 +362,7 @@ typedef union asf_object_u
     asf_object_content_description_t content_description;
     asf_object_advanced_mutual_exclusion_t advanced_mutual_exclusion;
     asf_object_stream_prioritization_t stream_prioritization;
+    asf_object_bitrate_mutual_exclusion_t bitrate_mutual_exclusion;
     asf_object_extended_content_description_t extended_content_description;
 
 } asf_object_t;



More information about the vlc-commits mailing list