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 memset( p_sys, 0, sizeof( demux_sys_t ) );
104 p_sys->i_data_offset = 0;
110 /* Parse the headers */
111 if( HeaderRead( p_demux ) )
114 msg_Err( p_demux, "invalid header" );
115 for( i = 0; i < p_sys->i_track; i++ )
117 real_track_t *tk = p_sys->track[i];
121 es_out_Del( p_demux->out, tk->p_es );
125 if( p_sys->i_track > 0 )
127 free( p_sys->track );
136 /*****************************************************************************
138 *****************************************************************************/
139 static void Close( vlc_object_t *p_this )
141 demux_t *p_demux = (demux_t*)p_this;
142 demux_sys_t *p_sys = p_demux->p_sys;
145 for( i = 0; i < p_sys->i_track; i++ )
147 real_track_t *tk = p_sys->track[i];
151 block_Release( tk->p_frame );
156 if( p_sys->i_track > 0 )
158 free( p_sys->track );
165 /*****************************************************************************
167 *****************************************************************************/
168 static int Demux( demux_t *p_demux )
170 demux_sys_t *p_sys = p_demux->p_sys;
176 real_track_t *tk = NULL;
177 vlc_bool_t b_selected;
179 if( p_sys->i_data_packets >= p_sys->i_data_packets_count &&
180 p_sys->i_data_packets_count )
182 if( stream_Read( p_demux->s, header, 18 ) < 18 )
186 if( strncmp( (char *)header, "DATA", 4 ) )
190 p_sys->i_data_offset = stream_Tell( p_demux->s ) - 18;
191 p_sys->i_data_size = GetDWBE( &header[4] );
192 p_sys->i_data_packets_count = GetDWBE( &header[10] );
193 p_sys->i_data_packets = 0;
194 p_sys->i_data_offset_next = GetDWBE( &header[14] );
196 msg_Dbg( p_demux, "entering new DATA packets=%d next=%u",
197 p_sys->i_data_packets_count,
198 (uint32_t)p_sys->i_data_offset_next );
201 if( stream_Read( p_demux->s, header, 12 ) < 12 ) return 0;
203 i_size = GetWBE( &header[2] ) - 12;
204 i_id = GetWBE( &header[4] );
205 i_pts = 1000 * GetDWBE( &header[6] );
206 i_pts += 1000; /* Avoid 0 pts */
208 /* header[11] -> flags 0x02 -> keyframe */
211 msg_Dbg( p_demux, "packet %d size=%d id=%d pts=%u",
212 p_sys->i_data_packets, i_size, i_id, (uint32_t)(i_pts/1000) );
215 p_sys->i_data_packets++;
217 stream_Read( p_demux->s, p_sys->buffer, i_size );
219 for( i = 0; i < p_sys->i_track; i++ )
221 if( p_sys->track[i]->i_id == i_id )
223 tk = p_sys->track[i];
229 msg_Warn( p_demux, "unknown track id(0x%x)", i_id );
232 es_out_Control( p_demux->out, ES_OUT_GET_ES_STATE, tk->p_es, &b_selected );
234 if( tk->fmt.i_cat == VIDEO_ES && b_selected )
236 uint8_t *p = p_sys->buffer;
238 while( p < &p_sys->buffer[i_size - 2] )
247 if( (h&0xc0) == 0x40 )
251 i_len = &p_sys->buffer[i_size] - p;
257 i_subseq = (*p++)&0x7f;
259 i_len = (p[0] << 8)|p[1]; p += 2;
260 if( (i_len&0xc000) == 0 )
263 i_len |= (p[0] << 8)|p[1]; p += 2;
271 i_offset = (p[0] << 8)|p[1]; p += 2;
272 if( (i_offset&0xc000) == 0 )
275 i_offset |= (p[0] << 8)|p[1]; p += 2;
276 i_offset &= 0x3fffffff;
285 i_copy = i_len - i_offset;
286 if( i_copy > &p_sys->buffer[i_size] - p )
288 i_copy = &p_sys->buffer[i_size] - p;
290 else if( i_copy < 0 )
295 msg_Dbg( p_demux, " - len=%d offset=%d size=%d subseq=%d seqnum=%d",
296 i_len, i_offset, i_copy, i_subseq, i_seqnum );
298 if( (h&0xc0) == 0x80 )
300 /* last fragment -> fixes */
302 i_offset = i_len - i_copy;
303 msg_Dbg( p_demux, "last fixing copy=%d offset=%d",
308 ( tk->p_frame->i_dts != i_pts ||
309 tk->i_frame != i_len ) )
311 msg_Dbg( p_demux, "sending size=%d", tk->p_frame->i_buffer );
313 if( p_sys->i_pcr < tk->p_frame->i_dts )
315 p_sys->i_pcr = tk->p_frame->i_dts;
317 es_out_Control( p_demux->out, ES_OUT_SET_PCR,
318 (int64_t)p_sys->i_pcr );
320 es_out_Send( p_demux->out, tk->p_es, tk->p_frame );
326 if( (h&0xc0) != 0x80 && (h&0xc0) != 0x00 && !tk->p_frame )
334 if( tk->p_frame == NULL )
336 msg_Dbg( p_demux, "new frame size=%d", i_len );
338 if( !( tk->p_frame = block_New( p_demux, i_len + 8 + 1000) ) )
342 memset( &tk->p_frame->p_buffer[8], 0, i_len );
343 tk->p_frame->i_dts = i_pts;
344 tk->p_frame->i_pts = i_pts;
346 ((uint32_t*)tk->p_frame->p_buffer)[0] = i_len; /* len */
347 ((uint32_t*)tk->p_frame->p_buffer)[1] = 0; /* chunk counts */
350 if( i_offset < tk->i_frame)
352 int i_ck = ((uint32_t*)tk->p_frame->p_buffer)[1]++;
354 msg_Dbg( p_demux, "copying new buffer n=%d offset=%d copy=%d",
355 i_ck, i_offset, i_copy );
357 ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[i_ck] = i_offset;
359 memcpy( &tk->p_frame->p_buffer[i_offset + 8], p, i_copy );
364 if( (h&0xc0) != 0x80 )
373 int i_ck = ((uint32_t*)tk->p_frame->p_buffer)[1]++;
375 if( (h&0xc0) == 0x80 )
379 i_offset = i_len - i_offset;
381 ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[i_ck] = i_offset;
382 memcpy( &tk->p_frame->p_buffer[i_offset+ 8], p, i_copy );
385 if( p_sys->i_pcr < tk->p_frame->i_dts )
387 p_sys->i_pcr = tk->p_frame->i_dts;
388 es_out_Control( p_demux->out, ES_OUT_SET_PCR,
389 (int64_t)p_sys->i_pcr );
391 es_out_Send( p_demux->out, tk->p_es, tk->p_frame );
399 ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[i_ck] = i_offset;
400 memcpy( &tk->p_frame->p_buffer[i_offset + 8], p, i_copy );
404 if( (h&0xc0) != 0x00 )
409 if( !( p_frame = block_New( p_demux, i_copy + 8 + 8 ) ) )
413 p_frame->i_dts = i_pts;
414 p_frame->i_pts = i_pts;
416 ((uint32_t*)p_frame->p_buffer)[0] = i_copy;
417 ((uint32_t*)p_frame->p_buffer)[1] = 1;
418 ((uint32_t*)(p_frame->p_buffer+i_copy+8))[0] = 0;
419 memcpy( &p_frame->p_buffer[8], p, i_copy );
423 if( p_sys->i_pcr < p_frame->i_dts )
425 p_sys->i_pcr = p_frame->i_dts;
426 es_out_Control( p_demux->out, ES_OUT_SET_PCR,
427 (int64_t)p_sys->i_pcr );
429 es_out_Send( p_demux->out, tk->p_es, p_frame );
435 if( !( tk->p_frame = block_New( p_demux, i_len + 8 + 1000) ) )
439 memset( &tk->p_frame->p_buffer[8], 0, i_len );
440 tk->p_frame->i_dts = i_pts;
441 tk->p_frame->i_pts = i_pts;
443 ((uint32_t*)tk->p_frame->p_buffer)[0] = i_len; /* len */
444 ((uint32_t*)tk->p_frame->p_buffer)[1] = 1; /* chunk counts */
445 ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[0] = i_offset;
446 memcpy( &tk->p_frame->p_buffer[i_offset + 8], p, i_copy );
453 else if( tk->fmt.i_cat == AUDIO_ES && b_selected )
456 if( p_sys->i_pcr < i_pts )
458 p_sys->i_pcr = i_pts;
459 es_out_Control( p_demux->out, ES_OUT_SET_PCR,
460 (int64_t)p_sys->i_pcr );
463 if( tk->fmt.i_codec == VLC_FOURCC( 'm', 'p', '4', 'a' ) )
465 int i_sub = (p_sys->buffer[1] >> 4)&0x0f;
466 uint8_t *p_sub = &p_sys->buffer[2+2*i_sub];
469 for( i = 0; i < i_sub; i++ )
471 int i_sub_size = GetWBE( &p_sys->buffer[2+i*2]);
472 block_t *p_block = block_New( p_demux, i_sub_size );
475 memcpy( p_block->p_buffer, p_sub, i_sub_size );
479 p_block->i_pts = ( i == 0 ? i_pts : 0 );
481 es_out_Send( p_demux->out, tk->p_es, p_block );
487 block_t *p_block = block_New( p_demux, i_size );
489 if( tk->fmt.i_codec == VLC_FOURCC( 'a', '5', '2', ' ' ) )
491 uint8_t *src = p_sys->buffer;
492 uint8_t *dst = p_block->p_buffer;
495 while( dst < &p_block->p_buffer[i_size- 1])
505 memcpy( p_block->p_buffer, p_sys->buffer, i_size );
508 p_block->i_pts = i_pts;
510 es_out_Send( p_demux->out, tk->p_es, p_block );
518 /*****************************************************************************
520 *****************************************************************************/
521 static int Control( demux_t *p_demux, int i_query, va_list args )
524 demux_sys_t *p_sys = p_demux->p_sys;
530 case DEMUX_GET_POSITION:
531 pf = (double*) va_arg( args, double* );
532 i64 = stream_Size( p_demux->s );
535 *pf = (double)stream_Tell( p_demux->s ) / (double)i64;
542 case DEMUX_SET_POSITION:
543 f = (double) va_arg( args, double );
544 i64 = stream_Size( p_demux->s );
546 es_out_Control( p_demux->out, ES_OUT_RESET_PCR );
548 return stream_Seek( p_demux->s, (int64_t)(i64 * f) );
551 pi64 = (int64_t*)va_arg( args, int64_t * );
552 if( p_sys->i_mux_rate > 0 )
554 *pi64 = (int64_t)1000000 * ( stream_Tell( p_demux->s ) / 50 ) / p_sys->i_mux_rate;
560 case DEMUX_GET_LENGTH:
561 pi64 = (int64_t*)va_arg( args, int64_t * );
562 if( p_sys->i_mux_rate > 0 )
564 *pi64 = (int64_t)1000000 * ( stream_Size( p_demux->s ) / 50 ) / p_sys->i_mux_rate;
579 /*****************************************************************************
581 *****************************************************************************/
582 static int HeaderRead( demux_t *p_demux )
584 demux_sys_t *p_sys = p_demux->p_sys;
585 uint8_t header[100]; /* FIXME */
594 /* Read the header */
595 if( stream_Read( p_demux->s, header, 10 ) < 10 )
599 i_id = VLC_FOURCC( header[0], header[1], header[2], header[3] );
600 i_size = GetDWBE( &header[4] );
601 i_version = GetWBE( &header[8] );
603 msg_Dbg( p_demux, "object %4.4s size=%d version=%d",
604 (char*)&i_id, i_size, i_version );
608 msg_Dbg( p_demux, "invalid size for object %4.4s", (char*)&i_id );
611 i_skip = i_size - 10;
613 if( i_id == VLC_FOURCC('.','R','M','F') )
615 if( stream_Read( p_demux->s, header, 8 ) < 8 ) return VLC_EGENERIC;
616 msg_Dbg( p_demux, " - file version=0x%x num headers=%d",
617 GetDWBE( &header[0] ), GetDWBE( &header[4] ) );
621 else if( i_id == VLC_FOURCC('P','R','O','P') )
625 if( stream_Read(p_demux->s, header, 40) < 40 ) return VLC_EGENERIC;
627 msg_Dbg( p_demux, " - max bitrate=%d avg bitrate=%d",
628 GetDWBE(&header[0]), GetDWBE(&header[4]) );
629 msg_Dbg( p_demux, " - max packet size=%d avg bitrate=%d",
630 GetDWBE(&header[8]), GetDWBE(&header[12]) );
631 msg_Dbg( p_demux, " - packets count=%d", GetDWBE(&header[16]) );
632 msg_Dbg( p_demux, " - duration=%d ms", GetDWBE(&header[20]) );
633 msg_Dbg( p_demux, " - preroll=%d ms", GetDWBE(&header[24]) );
634 msg_Dbg( p_demux, " - index offset=%d", GetDWBE(&header[28]) );
635 msg_Dbg( p_demux, " - data offset=%d", GetDWBE(&header[32]) );
636 msg_Dbg( p_demux, " - num streams=%d", GetWBE(&header[36]) );
637 i_flags = GetWBE(&header[38]);
638 msg_Dbg( p_demux, " - flags=0x%x %s%s%s",
640 i_flags&0x0001 ? "PN_SAVE_ENABLED " : "",
641 i_flags&0x0002 ? "PN_PERFECT_PLAY_ENABLED " : "",
642 i_flags&0x0004 ? "PN_LIVE_BROADCAST" : "" );
645 else if( i_id == VLC_FOURCC('C','O','N','T') )
650 stream_Read( p_demux->s, header, 2 );
651 if( ( i_len = GetWBE( header ) ) > 0 )
653 psz = malloc( i_len + 1 );
654 stream_Read( p_demux->s, psz, i_len );
657 msg_Dbg( p_demux, " - title=`%s'", psz );
663 stream_Read( p_demux->s, header, 2 );
664 if( ( i_len = GetWBE( header ) ) > 0 )
666 psz = malloc( i_len + 1 );
667 stream_Read( p_demux->s, psz, i_len );
670 msg_Dbg( p_demux, " - author=`%s'", psz );
676 stream_Read( p_demux->s, header, 2 );
677 if( ( i_len = GetWBE( header ) ) > 0 )
679 psz = malloc( i_len + 1 );
680 stream_Read( p_demux->s, psz, i_len );
683 msg_Dbg( p_demux, " - copyright=`%s'", psz );
689 stream_Read( p_demux->s, header, 2 );
690 if( ( i_len = GetWBE( header ) ) > 0 )
692 psz = malloc( i_len + 1 );
693 stream_Read( p_demux->s, psz, i_len );
696 msg_Dbg( p_demux, " - comment=`%s'", psz );
702 else if( i_id == VLC_FOURCC('M','D','P','R') )
704 /* Media properties header */
709 if( stream_Read(p_demux->s, header, 30) < 30 ) return VLC_EGENERIC;
710 i_num = GetWBE( header );
711 msg_Dbg( p_demux, " - id=0x%x", i_num );
712 msg_Dbg( p_demux, " - max bitrate=%d avg bitrate=%d",
713 GetDWBE(&header[2]), GetDWBE(&header[6]) );
714 msg_Dbg( p_demux, " - max packet size=%d avg packet size=%d",
715 GetDWBE(&header[10]), GetDWBE(&header[14]) );
716 msg_Dbg( p_demux, " - start time=%d", GetDWBE(&header[18]) );
717 msg_Dbg( p_demux, " - preroll=%d", GetDWBE(&header[22]) );
718 msg_Dbg( p_demux, " - duration=%d", GetDWBE(&header[26]) );
721 stream_Read( p_demux->s, header, 1 );
722 if( ( i_len = header[0] ) > 0 )
724 psz = malloc( i_len + 1 );
725 stream_Read( p_demux->s, psz, i_len );
728 msg_Dbg( p_demux, " - name=`%s'", psz );
734 stream_Read( p_demux->s, header, 1 );
735 if( ( i_len = header[0] ) > 0 )
737 psz = malloc( i_len + 1 );
738 stream_Read( p_demux->s, psz, i_len );
741 msg_Dbg( p_demux, " - mime=`%s'", psz );
747 stream_Read( p_demux->s, header, 4 );
748 if( ( i_len = GetDWBE( header ) ) > 0 )
750 ReadCodecSpecificData( p_demux, i_len, i_num );
751 stream_Read( p_demux->s, NULL, i_len );
757 else if( i_id == VLC_FOURCC('D','A','T','A') )
759 stream_Read( p_demux->s, header, 8 );
761 p_sys->i_data_offset = stream_Tell( p_demux->s ) - 10;
762 p_sys->i_data_size = i_size;
763 p_sys->i_data_packets_count = GetDWBE( header );
764 p_sys->i_data_packets = 0;
765 p_sys->i_data_offset_next = GetDWBE( &header[4] );
767 msg_Dbg( p_demux, " - packets count=%d next=%u",
768 p_sys->i_data_packets_count,
769 (uint32_t)p_sys->i_data_offset_next );
771 /* we have finished the header */
777 msg_Dbg( p_demux, "unknown chunk" );
780 if( i_skip < 0 ) return VLC_EGENERIC;
781 stream_Read( p_demux->s, NULL, i_skip );
784 /* TODO read index if possible */
789 static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
791 demux_sys_t *p_sys = p_demux->p_sys;
796 msg_Dbg( p_demux, " - specific data len=%d", i_len );
797 if( stream_Peek(p_demux->s, &p_peek, i_len) < i_len ) return VLC_EGENERIC;
799 if( !strncmp( (char *)&p_peek[4], "VIDO", 4 ) )
801 es_format_Init( &fmt, VIDEO_ES, VLC_FOURCC( p_peek[8], p_peek[9],
802 p_peek[10], p_peek[11] ) );
803 fmt.video.i_width = GetWBE( &p_peek[12] );
804 fmt.video.i_height= GetWBE( &p_peek[14] );
807 fmt.p_extra = malloc( 8 );
808 ((uint32_t*)fmt.p_extra)[0] = GetDWBE( &p_peek[26] );
809 ((uint32_t*)fmt.p_extra)[1] = GetDWBE( &p_peek[30] );
811 msg_Dbg( p_demux, " - video 0x%08x 0x%08x",
812 ((uint32_t*)fmt.p_extra)[0], ((uint32_t*)fmt.p_extra)[1] );
814 if( GetDWBE( &p_peek[30] ) == 0x10003000 ||
815 GetDWBE( &p_peek[30] ) == 0x10003001 )
817 fmt.i_codec = VLC_FOURCC( 'R','V','1','3' );
820 msg_Dbg( p_demux, " - video %4.4s %dx%d",
821 (char*)&fmt.i_codec, fmt.video.i_width, fmt.video.i_height );
823 tk = malloc( sizeof( real_track_t ) );
828 tk->p_es = es_out_Add( p_demux->out, &fmt );
830 TAB_APPEND( p_sys->i_track, p_sys->track, tk );
832 else if( !strncmp( (char *)p_peek, ".ra\xfd", 4 ) )
834 int i_version = GetWBE( &p_peek[4] );
835 int i_header_size, i_flavor, i_coded_frame_size, i_subpacket_h;
836 int i_frame_size, i_subpacket_size;
838 msg_Dbg( p_demux, " - audio version=%d", i_version );
841 es_format_Init( &fmt, AUDIO_ES, 0 );
845 msg_Dbg( p_demux, " - audio version 3 is not supported!" );
849 p_peek += 2; /* 00 00 */
850 p_peek += 4; /* .ra4 or .ra5 */
851 p_peek += 4; /* ?? */
852 p_peek += 2; /* version (4 or 5) */
853 i_header_size = GetDWBE( p_peek ); p_peek += 4; /* header size */
854 i_flavor = GetWBE( p_peek ); p_peek += 2; /* codec flavor */
855 i_coded_frame_size = GetDWBE( p_peek ); p_peek += 4;
856 p_peek += 4; /* ?? */
857 p_peek += 4; /* ?? */
858 p_peek += 4; /* ?? */
859 i_subpacket_h = GetWBE( p_peek ); p_peek += 2;
860 i_frame_size = GetWBE( p_peek ); p_peek += 2;
861 i_subpacket_size = GetWBE( p_peek ); p_peek += 2;
862 p_peek += 2; /* ?? */
864 if( i_version == 5 ) p_peek += 6; /* 0, srate, 0 */
866 fmt.audio.i_rate = GetWBE( p_peek ); p_peek += 2;
867 p_peek += 2; /* ?? */
868 fmt.audio.i_bitspersample = GetWBE( p_peek ); p_peek += 2;
869 fmt.audio.i_channels = GetWBE( p_peek ); p_peek += 2;
870 fmt.audio.i_blockalign = i_frame_size;
874 p_peek += 4; /* genr */
875 memcpy( (char *)&fmt.i_codec, p_peek, 4 ); p_peek += 4;
879 p_peek += p_peek[0] + 1; /* descr 1 */
880 memcpy( (char *)&fmt.i_codec, p_peek + 1, 4 ); /* descr 2 */
881 p_peek += p_peek[0] + 1;
884 msg_Dbg( p_demux, " - audio codec=%4.4s channels=%d rate=%dHz",
885 (char*)&fmt.i_codec, fmt.audio.i_channels, fmt.audio.i_rate );
887 p_peek += 3; /* ?? */
888 if( i_version == 5 ) p_peek++;
890 switch( fmt.i_codec )
892 case VLC_FOURCC( 'd', 'n', 'e', 't' ):
893 fmt.i_codec = VLC_FOURCC( 'a', '5', '2', ' ' );
896 case VLC_FOURCC( 'r', 'a', 'a', 'c' ):
897 case VLC_FOURCC( 'r', 'a', 'c', 'p' ):
898 fmt.i_extra = GetDWBE( p_peek ); p_peek += 4;
899 if( fmt.i_extra > 0 ) { fmt.i_extra--; p_peek++; }
900 if( fmt.i_extra > 0 )
902 fmt.p_extra = malloc( fmt.i_extra );
903 memcpy( fmt.p_extra, p_peek, fmt.i_extra );
906 fmt.i_codec = VLC_FOURCC( 'm', 'p', '4', 'a' );
909 case VLC_FOURCC('c','o','o','k'):
910 fmt.i_extra = GetDWBE( p_peek ); p_peek += 4;
911 fmt.p_extra = malloc( fmt.i_extra + 10 );
913 ((short*)(fmt.p_extra))[0] = i_subpacket_size;
914 ((short*)(fmt.p_extra))[1] = i_subpacket_h;
915 ((short*)(fmt.p_extra))[2] = i_flavor;
916 ((short*)(fmt.p_extra))[3] = i_coded_frame_size;
917 ((short*)(fmt.p_extra))[4] = fmt.i_extra;
918 if( fmt.i_extra ) memcpy( fmt.p_extra + 10, p_peek, fmt.i_extra );
923 msg_Dbg( p_demux, " - unknown audio codec=%4.4s",
924 (char*)&fmt.i_codec );
928 if( fmt.i_codec != 0 )
930 msg_Dbg( p_demux, " - extra data=%d", fmt.i_extra );
932 tk = malloc( sizeof( real_track_t ) );
937 tk->p_es = es_out_Add( p_demux->out, &fmt );
939 TAB_APPEND( p_sys->i_track, p_sys->track, tk );