]> git.sesse.net Git - vlc/commitdiff
*demux/asf Support for dvr-ms ASF. This is a a priorietary extension to ASF that...
authorDerk-Jan Hartman <hartman@videolan.org>
Sun, 15 Oct 2006 18:00:01 +0000 (18:00 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Sun, 15 Oct 2006 18:00:01 +0000 (18:00 +0000)
modules/demux/asf/asf.c
modules/demux/asf/libasf.h

index 622df5d069ab1a8a6c13d2354f4d847f91ff3ff6..a91c6fb5cc7ff9435d85b1e67b5917ee788267b3 100644 (file)
@@ -707,6 +707,14 @@ static int DemuxInit( demux_t *p_demux )
             fmt.video.i_width = GetDWLE( p_data + 4 );
             fmt.video.i_height= GetDWLE( p_data + 8 );
 
+
+            if( fmt.i_codec == VLC_FOURCC( 'D','V','R',' ') )
+            {
+                /* DVR-MS special ASF */
+                fmt.i_codec = VLC_FOURCC( 'm','p','g','2' ) ;
+                fmt.b_packetized = VLC_FALSE;
+            }
+
             if( p_sp->i_type_specific_data_length > 11 +
                 sizeof( BITMAPINFOHEADER ) )
             {
@@ -758,6 +766,53 @@ static int DemuxInit( demux_t *p_demux )
             msg_Dbg( p_demux, "added new video stream(ID:%d)",
                      p_sp->i_stream_number );
         }
+        else if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_extended_stream_header ) &&
+            p_sp->i_type_specific_data_length >= 64 )
+        {
+            /* Now follows a 64 byte header of which we don't know much */
+            es_format_t fmt;
+            guid_t  *p_ref  = (guid_t *)p_sp->p_type_specific_data;
+            uint8_t *p_data = p_sp->p_type_specific_data + 64;
+            unsigned int i_data = p_sp->i_type_specific_data_length - 64;
+
+            msg_Dbg( p_demux, "Ext stream header detected. datasize = %d", p_sp->i_type_specific_data_length );
+            if( ASF_CmpGUID( p_ref, &asf_object_extended_stream_type_audio ) && 
+                i_data >= sizeof( WAVEFORMATEX ) - 2)
+            {
+                int      i_format;
+                es_format_Init( &fmt, AUDIO_ES, 0 );
+                i_format = GetWLE( &p_data[0] );
+                if( i_format == 0 ) 
+                    fmt.i_codec = VLC_FOURCC( 'a','5','2',' ');
+                else
+                    wf_tag_to_fourcc( i_format, &fmt.i_codec, NULL );
+                fmt.audio.i_channels        = GetWLE(  &p_data[2] );
+                fmt.audio.i_rate      = GetDWLE( &p_data[4] );
+                fmt.i_bitrate         = GetDWLE( &p_data[8] ) * 8;
+                fmt.audio.i_blockalign      = GetWLE(  &p_data[12] );
+                fmt.audio.i_bitspersample   = GetWLE(  &p_data[14] );
+                fmt.b_packetized = VLC_TRUE;
+
+                if( p_sp->i_type_specific_data_length > sizeof( WAVEFORMATEX ) &&
+                    i_format != WAVE_FORMAT_MPEGLAYER3 &&
+                    i_format != WAVE_FORMAT_MPEG )
+                {
+                    fmt.i_extra = __MIN( GetWLE( &p_data[16] ),
+                                         p_sp->i_type_specific_data_length -
+                                         sizeof( WAVEFORMATEX ) );
+                    fmt.p_extra = malloc( fmt.i_extra );
+                    memcpy( fmt.p_extra, &p_data[sizeof( WAVEFORMATEX )],
+                        fmt.i_extra );
+                }
+
+                tk->i_cat = AUDIO_ES;
+                tk->p_es = es_out_Add( p_demux->out, &fmt );
+                es_format_Clean( &fmt );
+
+                msg_Dbg( p_demux, "added new audio stream (codec:0x%x,ID:%d)",
+                    i_format, p_sp->i_stream_number );
+            }
+        }
         else
         {
             tk->i_cat = UNKNOWN_ES;
index 9e21db503ef4e18ca37984780f266ef3e2dbbaed..6f65689f8e37c4e53c583bf63f345419f6d34217 100644 (file)
@@ -119,6 +119,12 @@ static const guid_t asf_object_stream_prioritization =
 static const guid_t asf_object_extended_content_description =
 {0xD2D0A440, 0xE307, 0x11D2, {0x97, 0xF0, 0x00, 0xA0, 0xC9, 0x5E, 0xA8, 0x50}};
 
+static const guid_t asf_object_extended_stream_header = 
+{0x3afb65e2, 0x47ef, 0x40f2, { 0xac, 0x2c, 0x70, 0xa9, 0x0d, 0x71, 0xd3, 0x43}};
+
+static const guid_t asf_object_extended_stream_type_audio =
+{0x31178c9d, 0x03e1, 0x4528, { 0xb5, 0x82, 0x3d, 0xf9, 0xdb, 0x22, 0xf5, 0x03}};
+
 #define ASF_OBJECT_COMMON          \
     int          i_type;           \
     guid_t       i_object_id;      \