1 /*****************************************************************************
2 * real.c: Real demuxer.
3 *****************************************************************************
4 * Copyright (C) 2004 the VideoLAN team
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
30 #include <vlc/input.h>
32 /*****************************************************************************
34 *****************************************************************************/
35 static int Open ( vlc_object_t * );
36 static void Close ( vlc_object_t * );
39 set_description( _("Real demuxer" ) );
40 set_capability( "demux2", 15 );
41 set_category( CAT_INPUT );
42 set_subcategory( SUBCAT_INPUT_DEMUX );
43 set_callbacks( Open, Close );
44 add_shortcut( "real" );
48 /*****************************************************************************
50 *****************************************************************************/
66 int64_t i_data_offset;
68 uint32_t i_data_packets_count;
69 uint32_t i_data_packets;
70 int64_t i_data_offset_next;
75 uint8_t buffer[65536];
80 static int Demux( demux_t *p_demux );
81 static int Control( demux_t *p_demux, int i_query, va_list args );
83 static int HeaderRead( demux_t *p_demux );
84 static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num );
86 /*****************************************************************************
88 *****************************************************************************/
89 static int Open( vlc_object_t *p_this )
91 demux_t *p_demux = (demux_t*)p_this;
96 if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 ) return VLC_EGENERIC;
97 if( strncmp( (char *)p_peek, ".RMF", 4 ) ) return VLC_EGENERIC;
99 /* Fill p_demux field */
100 p_demux->pf_demux = Demux;
101 p_demux->pf_control = Control;
102 p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
103 p_sys->i_data_offset = 0;
109 /* Parse the headers */
110 if( HeaderRead( p_demux ) )
113 msg_Err( p_demux, "invalid header" );
114 for( i = 0; i < p_sys->i_track; i++ )
116 real_track_t *tk = p_sys->track[i];
120 es_out_Del( p_demux->out, tk->p_es );
124 if( p_sys->i_track > 0 )
126 free( p_sys->track );
135 /*****************************************************************************
137 *****************************************************************************/
138 static void Close( vlc_object_t *p_this )
140 demux_t *p_demux = (demux_t*)p_this;
141 demux_sys_t *p_sys = p_demux->p_sys;
144 for( i = 0; i < p_sys->i_track; i++ )
146 real_track_t *tk = p_sys->track[i];
150 block_Release( tk->p_frame );
155 if( p_sys->i_track > 0 )
157 free( p_sys->track );
164 /*****************************************************************************
166 *****************************************************************************/
167 static int Demux( demux_t *p_demux )
169 demux_sys_t *p_sys = p_demux->p_sys;
175 real_track_t *tk = NULL;
176 vlc_bool_t b_selected;
178 if( p_sys->i_data_packets >= p_sys->i_data_packets_count )
181 if( stream_Read( p_demux->s, header, 18 ) < 18 )
185 if( strncmp( (char *)header, "DATA", 4 ) )
189 p_sys->i_data_offset = stream_Tell( p_demux->s ) - 18;
190 p_sys->i_data_size = GetDWBE( &header[4] );
191 p_sys->i_data_packets_count = GetDWBE( &header[10] );
192 p_sys->i_data_packets = 0;
193 p_sys->i_data_offset_next = GetDWBE( &header[14] );
195 msg_Dbg( p_demux, "entering new DATA packets=%d next=%u",
196 p_sys->i_data_packets_count,
197 (uint32_t)p_sys->i_data_offset_next );
200 if( stream_Read( p_demux->s, header, 12 ) < 12 ) return 0;
202 i_size = GetWBE( &header[2] ) - 12;
203 i_id = GetWBE( &header[4] );
204 i_pts = 1000 * GetDWBE( &header[6] );
205 i_pts += 1000; /* Avoid 0 pts */
207 /* header[11] -> flags 0x02 -> keyframe */
210 msg_Dbg( p_demux, "packet %d size=%d id=%d pts=%u",
211 p_sys->i_data_packets, i_size, i_id, (uint32_t)(i_pts/1000) );
214 p_sys->i_data_packets++;
216 stream_Read( p_demux->s, p_sys->buffer, i_size );
218 for( i = 0; i < p_sys->i_track; i++ )
220 if( p_sys->track[i]->i_id == i_id )
222 tk = p_sys->track[i];
228 msg_Warn( p_demux, "unknown track id(0x%x)", i_id );
231 es_out_Control( p_demux->out, ES_OUT_GET_ES_STATE, tk->p_es, &b_selected );
233 if( tk->fmt.i_cat == VIDEO_ES && b_selected )
235 uint8_t *p = p_sys->buffer;
237 while( p < &p_sys->buffer[i_size - 2] )
246 if( (h&0xc0) == 0x40 )
250 i_len = &p_sys->buffer[i_size] - p;
256 i_subseq = (*p++)&0x7f;
258 i_len = (p[0] << 8)|p[1]; p += 2;
259 if( (i_len&0xc000) == 0 )
262 i_len |= (p[0] << 8)|p[1]; p += 2;
270 i_offset = (p[0] << 8)|p[1]; p += 2;
271 if( (i_offset&0xc000) == 0 )
274 i_offset |= (p[0] << 8)|p[1]; p += 2;
275 i_offset &= 0x3fffffff;
284 i_copy = i_len - i_offset;
285 if( i_copy > &p_sys->buffer[i_size] - p )
287 i_copy = &p_sys->buffer[i_size] - p;
289 else if( i_copy < 0 )
294 msg_Dbg( p_demux, " - len=%d offset=%d size=%d subseq=%d seqnum=%d",
295 i_len, i_offset, i_copy, i_subseq, i_seqnum );
297 if( (h&0xc0) == 0x80 )
299 /* last fragment -> fixes */
301 i_offset = i_len - i_copy;
302 msg_Dbg( p_demux, "last fixing copy=%d offset=%d",
307 ( tk->p_frame->i_dts != i_pts ||
308 tk->i_frame != i_len ) )
310 msg_Dbg( p_demux, "sending size=%d", tk->p_frame->i_buffer );
312 if( p_sys->i_pcr < tk->p_frame->i_dts )
314 p_sys->i_pcr = tk->p_frame->i_dts;
316 es_out_Control( p_demux->out, ES_OUT_SET_PCR,
317 (int64_t)p_sys->i_pcr );
319 es_out_Send( p_demux->out, tk->p_es, tk->p_frame );
325 if( (h&0xc0) != 0x80 && (h&0xc0) != 0x00 && !tk->p_frame )
333 if( tk->p_frame == NULL )
335 msg_Dbg( p_demux, "new frame size=%d", i_len );
337 if( !( tk->p_frame = block_New( p_demux, i_len + 8 + 1000) ) )
341 memset( &tk->p_frame->p_buffer[8], 0, i_len );
342 tk->p_frame->i_dts = i_pts;
343 tk->p_frame->i_pts = i_pts;
345 ((uint32_t*)tk->p_frame->p_buffer)[0] = i_len; /* len */
346 ((uint32_t*)tk->p_frame->p_buffer)[1] = 0; /* chunk counts */
349 if( i_offset < tk->i_frame)
351 int i_ck = ((uint32_t*)tk->p_frame->p_buffer)[1]++;
353 msg_Dbg( p_demux, "copying new buffer n=%d offset=%d copy=%d",
354 i_ck, i_offset, i_copy );
356 ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[i_ck] = i_offset;
358 memcpy( &tk->p_frame->p_buffer[i_offset + 8], p, i_copy );
363 if( (h&0xc0) != 0x80 )
372 int i_ck = ((uint32_t*)tk->p_frame->p_buffer)[1]++;
374 if( (h&0xc0) == 0x80 )
378 i_offset = i_len - i_offset;
380 ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[i_ck] = i_offset;
381 memcpy( &tk->p_frame->p_buffer[i_offset+ 8], p, i_copy );
384 if( p_sys->i_pcr < tk->p_frame->i_dts )
386 p_sys->i_pcr = tk->p_frame->i_dts;
387 es_out_Control( p_demux->out, ES_OUT_SET_PCR,
388 (int64_t)p_sys->i_pcr );
390 es_out_Send( p_demux->out, tk->p_es, tk->p_frame );
398 ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[i_ck] = i_offset;
399 memcpy( &tk->p_frame->p_buffer[i_offset + 8], p, i_copy );
403 if( (h&0xc0) != 0x00 )
408 if( !( p_frame = block_New( p_demux, i_copy + 8 + 8 ) ) )
412 p_frame->i_dts = i_pts;
413 p_frame->i_pts = i_pts;
415 ((uint32_t*)p_frame->p_buffer)[0] = i_copy;
416 ((uint32_t*)p_frame->p_buffer)[1] = 1;
417 ((uint32_t*)(p_frame->p_buffer+i_copy+8))[0] = 0;
418 memcpy( &p_frame->p_buffer[8], p, i_copy );
422 if( p_sys->i_pcr < p_frame->i_dts )
424 p_sys->i_pcr = p_frame->i_dts;
425 es_out_Control( p_demux->out, ES_OUT_SET_PCR,
426 (int64_t)p_sys->i_pcr );
428 es_out_Send( p_demux->out, tk->p_es, p_frame );
434 if( !( tk->p_frame = block_New( p_demux, i_len + 8 + 1000) ) )
438 memset( &tk->p_frame->p_buffer[8], 0, i_len );
439 tk->p_frame->i_dts = i_pts;
440 tk->p_frame->i_pts = i_pts;
442 ((uint32_t*)tk->p_frame->p_buffer)[0] = i_len; /* len */
443 ((uint32_t*)tk->p_frame->p_buffer)[1] = 1; /* chunk counts */
444 ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[0] = i_offset;
445 memcpy( &tk->p_frame->p_buffer[i_offset + 8], p, i_copy );
452 else if( tk->fmt.i_cat == AUDIO_ES && b_selected )
455 if( p_sys->i_pcr < i_pts )
457 p_sys->i_pcr = i_pts;
458 es_out_Control( p_demux->out, ES_OUT_SET_PCR,
459 (int64_t)p_sys->i_pcr );
462 if( tk->fmt.i_codec == VLC_FOURCC( 'm', 'p', '4', 'a' ) )
464 int i_sub = (p_sys->buffer[1] >> 4)&0x0f;
465 uint8_t *p_sub = &p_sys->buffer[2+2*i_sub];
468 for( i = 0; i < i_sub; i++ )
470 int i_sub_size = GetWBE( &p_sys->buffer[2+i*2]);
471 block_t *p_block = block_New( p_demux, i_sub_size );
474 memcpy( p_block->p_buffer, p_sub, i_sub_size );
478 p_block->i_pts = ( i == 0 ? i_pts : 0 );
480 es_out_Send( p_demux->out, tk->p_es, p_block );
486 block_t *p_block = block_New( p_demux, i_size );
488 if( tk->fmt.i_codec == VLC_FOURCC( 'a', '5', '2', ' ' ) )
490 uint8_t *src = p_sys->buffer;
491 uint8_t *dst = p_block->p_buffer;
494 while( dst < &p_block->p_buffer[i_size- 1])
504 memcpy( p_block->p_buffer, p_sys->buffer, i_size );
507 p_block->i_pts = i_pts;
509 es_out_Send( p_demux->out, tk->p_es, p_block );
517 /*****************************************************************************
519 *****************************************************************************/
520 static int Control( demux_t *p_demux, int i_query, va_list args )
523 demux_sys_t *p_sys = p_demux->p_sys;
529 case DEMUX_GET_POSITION:
530 pf = (double*) va_arg( args, double* );
531 i64 = stream_Size( p_demux->s );
534 *pf = (double)stream_Tell( p_demux->s ) / (double)i64;
541 case DEMUX_SET_POSITION:
542 f = (double) va_arg( args, double );
543 i64 = stream_Size( p_demux->s );
545 es_out_Control( p_demux->out, ES_OUT_RESET_PCR );
547 return stream_Seek( p_demux->s, (int64_t)(i64 * f) );
550 pi64 = (int64_t*)va_arg( args, int64_t * );
551 if( p_sys->i_mux_rate > 0 )
553 *pi64 = (int64_t)1000000 * ( stream_Tell( p_demux->s ) / 50 ) / p_sys->i_mux_rate;
559 case DEMUX_GET_LENGTH:
560 pi64 = (int64_t*)va_arg( args, int64_t * );
561 if( p_sys->i_mux_rate > 0 )
563 *pi64 = (int64_t)1000000 * ( stream_Size( p_demux->s ) / 50 ) / p_sys->i_mux_rate;
578 /*****************************************************************************
580 *****************************************************************************/
581 static int HeaderRead( demux_t *p_demux )
583 demux_sys_t *p_sys = p_demux->p_sys;
584 uint8_t header[100]; /* FIXME */
593 /* Read the header */
594 if( stream_Read( p_demux->s, header, 10 ) < 10 )
598 i_id = VLC_FOURCC( header[0], header[1], header[2], header[3] );
599 i_size = GetDWBE( &header[4] );
600 i_version = GetWBE( &header[8] );
602 msg_Dbg( p_demux, "object %4.4s size=%d version=%d",
603 (char*)&i_id, i_size, i_version );
605 if( i_size < 10 ) return VLC_EGENERIC;
606 i_skip = i_size - 10;
608 if( i_id == VLC_FOURCC('.','R','M','F') )
610 if( stream_Read( p_demux->s, header, 8 ) < 8 ) return VLC_EGENERIC;
611 msg_Dbg( p_demux, " - file version=0x%x num headers=%d",
612 GetDWBE( &header[0] ), GetDWBE( &header[4] ) );
616 else if( i_id == VLC_FOURCC('P','R','O','P') )
620 if( stream_Read(p_demux->s, header, 40) < 40 ) return VLC_EGENERIC;
622 msg_Dbg( p_demux, " - max bitrate=%d avg bitrate=%d",
623 GetDWBE(&header[0]), GetDWBE(&header[4]) );
624 msg_Dbg( p_demux, " - max packet size=%d avg bitrate=%d",
625 GetDWBE(&header[8]), GetDWBE(&header[12]) );
626 msg_Dbg( p_demux, " - packets count=%d", GetDWBE(&header[16]) );
627 msg_Dbg( p_demux, " - duration=%d ms", GetDWBE(&header[20]) );
628 msg_Dbg( p_demux, " - preroll=%d ms", GetDWBE(&header[24]) );
629 msg_Dbg( p_demux, " - index offset=%d", GetDWBE(&header[28]) );
630 msg_Dbg( p_demux, " - data offset=%d", GetDWBE(&header[32]) );
631 msg_Dbg( p_demux, " - num streams=%d", GetWBE(&header[36]) );
632 i_flags = GetWBE(&header[38]);
633 msg_Dbg( p_demux, " - flags=0x%x %s%s%s",
635 i_flags&0x0001 ? "PN_SAVE_ENABLED " : "",
636 i_flags&0x0002 ? "PN_PERFECT_PLAY_ENABLED " : "",
637 i_flags&0x0004 ? "PN_LIVE_BROADCAST" : "" );
640 else if( i_id == VLC_FOURCC('C','O','N','T') )
645 stream_Read( p_demux->s, header, 2 );
646 if( ( i_len = GetWBE( header ) ) > 0 )
648 psz = malloc( i_len + 1 );
649 stream_Read( p_demux->s, psz, i_len );
652 msg_Dbg( p_demux, " - title=`%s'", psz );
658 stream_Read( p_demux->s, header, 2 );
659 if( ( i_len = GetWBE( header ) ) > 0 )
661 psz = malloc( i_len + 1 );
662 stream_Read( p_demux->s, psz, i_len );
665 msg_Dbg( p_demux, " - author=`%s'", psz );
671 stream_Read( p_demux->s, header, 2 );
672 if( ( i_len = GetWBE( header ) ) > 0 )
674 psz = malloc( i_len + 1 );
675 stream_Read( p_demux->s, psz, i_len );
678 msg_Dbg( p_demux, " - copyright=`%s'", psz );
684 stream_Read( p_demux->s, header, 2 );
685 if( ( i_len = GetWBE( header ) ) > 0 )
687 psz = malloc( i_len + 1 );
688 stream_Read( p_demux->s, psz, i_len );
691 msg_Dbg( p_demux, " - comment=`%s'", psz );
697 else if( i_id == VLC_FOURCC('M','D','P','R') )
699 /* Media properties header */
704 if( stream_Read(p_demux->s, header, 30) < 30 ) return VLC_EGENERIC;
705 i_num = GetWBE( header );
706 msg_Dbg( p_demux, " - id=0x%x", i_num );
707 msg_Dbg( p_demux, " - max bitrate=%d avg bitrate=%d",
708 GetDWBE(&header[2]), GetDWBE(&header[6]) );
709 msg_Dbg( p_demux, " - max packet size=%d avg packet size=%d",
710 GetDWBE(&header[10]), GetDWBE(&header[14]) );
711 msg_Dbg( p_demux, " - start time=%d", GetDWBE(&header[18]) );
712 msg_Dbg( p_demux, " - preroll=%d", GetDWBE(&header[22]) );
713 msg_Dbg( p_demux, " - duration=%d", GetDWBE(&header[26]) );
716 stream_Read( p_demux->s, header, 1 );
717 if( ( i_len = header[0] ) > 0 )
719 psz = malloc( i_len + 1 );
720 stream_Read( p_demux->s, psz, i_len );
723 msg_Dbg( p_demux, " - name=`%s'", psz );
729 stream_Read( p_demux->s, header, 1 );
730 if( ( i_len = header[0] ) > 0 )
732 psz = malloc( i_len + 1 );
733 stream_Read( p_demux->s, psz, i_len );
736 msg_Dbg( p_demux, " - mime=`%s'", psz );
742 stream_Read( p_demux->s, header, 4 );
743 if( ( i_len = GetDWBE( header ) ) > 0 )
745 ReadCodecSpecificData( p_demux, i_len, i_num );
746 stream_Read( p_demux->s, NULL, i_len );
752 else if( i_id == VLC_FOURCC('D','A','T','A') )
754 stream_Read( p_demux->s, header, 8 );
756 p_sys->i_data_offset = stream_Tell( p_demux->s ) - 10;
757 p_sys->i_data_size = i_size;
758 p_sys->i_data_packets_count = GetDWBE( header );
759 p_sys->i_data_packets = 0;
760 p_sys->i_data_offset_next = GetDWBE( &header[4] );
762 msg_Dbg( p_demux, " - packets count=%d next=%u",
763 p_sys->i_data_packets_count,
764 (uint32_t)p_sys->i_data_offset_next );
766 /* we have finished the header */
772 msg_Dbg( p_demux, "unknown chunk" );
775 if( i_skip < 0 ) return VLC_EGENERIC;
776 stream_Read( p_demux->s, NULL, i_skip );
779 /* TODO read index if possible */
784 static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
786 demux_sys_t *p_sys = p_demux->p_sys;
791 msg_Dbg( p_demux, " - specific data len=%d", i_len );
792 if( stream_Peek(p_demux->s, &p_peek, i_len) < i_len ) return VLC_EGENERIC;
794 if( !strncmp( (char *)&p_peek[4], "VIDO", 4 ) )
796 es_format_Init( &fmt, VIDEO_ES, VLC_FOURCC( p_peek[8], p_peek[9],
797 p_peek[10], p_peek[11] ) );
798 fmt.video.i_width = GetWBE( &p_peek[12] );
799 fmt.video.i_height= GetWBE( &p_peek[14] );
802 fmt.p_extra = malloc( 8 );
803 ((uint32_t*)fmt.p_extra)[0] = GetDWBE( &p_peek[26] );
804 ((uint32_t*)fmt.p_extra)[1] = GetDWBE( &p_peek[30] );
806 msg_Dbg( p_demux, " - video 0x%08x 0x%08x",
807 ((uint32_t*)fmt.p_extra)[0], ((uint32_t*)fmt.p_extra)[1] );
809 if( GetDWBE( &p_peek[30] ) == 0x10003000 ||
810 GetDWBE( &p_peek[30] ) == 0x10003001 )
812 fmt.i_codec = VLC_FOURCC( 'R','V','1','3' );
815 msg_Dbg( p_demux, " - video %4.4s %dx%d",
816 (char*)&fmt.i_codec, fmt.video.i_width, fmt.video.i_height );
818 tk = malloc( sizeof( real_track_t ) );
823 tk->p_es = es_out_Add( p_demux->out, &fmt );
825 TAB_APPEND( p_sys->i_track, p_sys->track, tk );
827 else if( !strncmp( (char *)p_peek, ".ra\xfd", 4 ) )
829 int i_version = GetWBE( &p_peek[4] );
830 int i_header_size, i_flavor, i_coded_frame_size, i_subpacket_h;
831 int i_frame_size, i_subpacket_size;
833 msg_Dbg( p_demux, " - audio version=%d", i_version );
836 es_format_Init( &fmt, AUDIO_ES, 0 );
840 msg_Dbg( p_demux, " - audio version 3 is not supported!" );
844 p_peek += 2; /* 00 00 */
845 p_peek += 4; /* .ra4 or .ra5 */
846 p_peek += 4; /* ?? */
847 p_peek += 2; /* version (4 or 5) */
848 i_header_size = GetDWBE( p_peek ); p_peek += 4; /* header size */
849 i_flavor = GetWBE( p_peek ); p_peek += 2; /* codec flavor */
850 i_coded_frame_size = GetDWBE( p_peek ); p_peek += 4;
851 p_peek += 4; /* ?? */
852 p_peek += 4; /* ?? */
853 p_peek += 4; /* ?? */
854 i_subpacket_h = GetWBE( p_peek ); p_peek += 2;
855 i_frame_size = GetWBE( p_peek ); p_peek += 2;
856 i_subpacket_size = GetWBE( p_peek ); p_peek += 2;
857 p_peek += 2; /* ?? */
859 if( i_version == 5 ) p_peek += 6; /* 0, srate, 0 */
861 fmt.audio.i_rate = GetWBE( p_peek ); p_peek += 2;
862 p_peek += 2; /* ?? */
863 fmt.audio.i_bitspersample = GetWBE( p_peek ); p_peek += 2;
864 fmt.audio.i_channels = GetWBE( p_peek ); p_peek += 2;
865 fmt.audio.i_blockalign = i_frame_size;
869 p_peek += 4; /* genr */
870 memcpy( (char *)&fmt.i_codec, p_peek, 4 ); p_peek += 4;
874 p_peek += p_peek[0] + 1; /* descr 1 */
875 memcpy( (char *)&fmt.i_codec, p_peek + 1, 4 ); /* descr 2 */
876 p_peek += p_peek[0] + 1;
879 msg_Dbg( p_demux, " - audio codec=%4.4s channels=%d rate=%dHz",
880 (char*)&fmt.i_codec, fmt.audio.i_channels, fmt.audio.i_rate );
882 p_peek += 3; /* ?? */
883 if( i_version == 5 ) p_peek++;
885 switch( fmt.i_codec )
887 case VLC_FOURCC( 'd', 'n', 'e', 't' ):
888 fmt.i_codec = VLC_FOURCC( 'a', '5', '2', ' ' );
891 case VLC_FOURCC( 'r', 'a', 'a', 'c' ):
892 case VLC_FOURCC( 'r', 'a', 'c', 'p' ):
893 fmt.i_extra = GetDWBE( p_peek ); p_peek += 4;
894 if( fmt.i_extra > 0 ) { fmt.i_extra--; p_peek++; }
895 if( fmt.i_extra > 0 )
897 fmt.p_extra = malloc( fmt.i_extra );
898 memcpy( fmt.p_extra, p_peek, fmt.i_extra );
901 fmt.i_codec = VLC_FOURCC( 'm', 'p', '4', 'a' );
904 case VLC_FOURCC('c','o','o','k'):
905 fmt.i_extra = GetDWBE( p_peek ); p_peek += 4;
906 fmt.p_extra = malloc( fmt.i_extra + 10 );
908 ((short*)(fmt.p_extra))[0] = i_subpacket_size;
909 ((short*)(fmt.p_extra))[1] = i_subpacket_h;
910 ((short*)(fmt.p_extra))[2] = i_flavor;
911 ((short*)(fmt.p_extra))[3] = i_coded_frame_size;
912 ((short*)(fmt.p_extra))[4] = fmt.i_extra;
913 if( fmt.i_extra ) memcpy( fmt.p_extra + 10, p_peek, fmt.i_extra );
918 msg_Dbg( p_demux, " - unknown audio codec=%4.4s",
919 (char*)&fmt.i_codec );
923 if( fmt.i_codec != 0 )
925 msg_Dbg( p_demux, " - extra data=%d", fmt.i_extra );
928 for( i = 0; i < fmt.i_extra; i++ )
930 msg_Dbg( p_demux, " data[%d] = 0x%x", i,
931 ((uint8_t*)fmt.p_extra)[i] );
935 tk = malloc( sizeof( real_track_t ) );
940 tk->p_es = es_out_Add( p_demux->out, &fmt );
942 TAB_APPEND( p_sys->i_track, p_sys->track, tk );