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 /* header[11] -> flags 0x02 -> keyframe */
206 msg_Dbg( p_demux, "packet %d size=%d id=%d pts=%u",
207 p_sys->i_data_packets, i_size, i_id, (uint32_t)(i_pts/1000) );
208 p_sys->i_data_packets++;
210 stream_Read( p_demux->s, p_sys->buffer, i_size );
212 for( i = 0; i < p_sys->i_track; i++ )
214 if( p_sys->track[i]->i_id == i_id )
216 tk = p_sys->track[i];
222 msg_Warn( p_demux, "unknown track id(0x%x)", i_id );
225 es_out_Control( p_demux->out, ES_OUT_GET_ES_STATE, tk->p_es, &b_selected );
227 if( tk->fmt.i_cat == VIDEO_ES && b_selected )
229 uint8_t *p = p_sys->buffer;
231 while( p < &p_sys->buffer[i_size - 2] )
240 if( (h&0xc0) == 0x40 )
244 i_len = &p_sys->buffer[i_size] - p;
250 i_subseq = (*p++)&0x7f;
252 i_len = (p[0] << 8)|p[1]; p += 2;
253 if( (i_len&0xc000) == 0 )
256 i_len |= (p[0] << 8)|p[1]; p += 2;
264 i_offset = (p[0] << 8)|p[1]; p += 2;
265 if( (i_offset&0xc000) == 0 )
268 i_offset |= (p[0] << 8)|p[1]; p += 2;
269 i_offset &= 0x3fffffff;
278 i_copy = i_len - i_offset;
279 if( i_copy > &p_sys->buffer[i_size] - p )
281 i_copy = &p_sys->buffer[i_size] - p;
283 else if( i_copy < 0 )
288 msg_Dbg( p_demux, " - len=%d offset=%d size=%d subseq=%d seqnum=%d",
289 i_len, i_offset, i_copy, i_subseq, i_seqnum );
291 if( (h&0xc0) == 0x80 )
293 /* last fragment -> fixes */
295 i_offset = i_len - i_copy;
296 msg_Dbg( p_demux, "last fixing copy=%d offset=%d",
301 ( tk->p_frame->i_dts != i_pts ||
302 tk->i_frame != i_len ) )
304 msg_Dbg( p_demux, "sending size=%d", tk->p_frame->i_buffer );
306 if( p_sys->i_pcr < tk->p_frame->i_dts )
308 p_sys->i_pcr = tk->p_frame->i_dts;
310 es_out_Control( p_demux->out, ES_OUT_SET_PCR,
311 (int64_t)p_sys->i_pcr );
313 es_out_Send( p_demux->out, tk->p_es, tk->p_frame );
319 if( (h&0xc0) != 0x80 && (h&0xc0) != 0x00 && !tk->p_frame )
327 if( tk->p_frame == NULL )
329 msg_Dbg( p_demux, "new frame size=%d", i_len );
331 if( !( tk->p_frame = block_New( p_demux, i_len + 8 + 1000) ) )
335 memset( &tk->p_frame->p_buffer[8], 0, i_len );
336 tk->p_frame->i_dts = i_pts;
337 tk->p_frame->i_pts = i_pts;
339 ((uint32_t*)tk->p_frame->p_buffer)[0] = i_len; /* len */
340 ((uint32_t*)tk->p_frame->p_buffer)[1] = 0; /* chunk counts */
343 if( i_offset < tk->i_frame)
345 int i_ck = ((uint32_t*)tk->p_frame->p_buffer)[1]++;
347 msg_Dbg( p_demux, "copying new buffer n=%d offset=%d copy=%d",
348 i_ck, i_offset, i_copy );
350 ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[i_ck] = i_offset;
352 memcpy( &tk->p_frame->p_buffer[i_offset + 8], p, i_copy );
357 if( (h&0xc0) != 0x80 )
366 int i_ck = ((uint32_t*)tk->p_frame->p_buffer)[1]++;
368 if( (h&0xc0) == 0x80 )
372 i_offset = i_len - i_offset;
374 ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[i_ck] = i_offset;
375 memcpy( &tk->p_frame->p_buffer[i_offset+ 8], p, i_copy );
378 if( p_sys->i_pcr < tk->p_frame->i_dts )
380 p_sys->i_pcr = tk->p_frame->i_dts;
381 es_out_Control( p_demux->out, ES_OUT_SET_PCR,
382 (int64_t)p_sys->i_pcr );
384 es_out_Send( p_demux->out, tk->p_es, tk->p_frame );
392 ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[i_ck] = i_offset;
393 memcpy( &tk->p_frame->p_buffer[i_offset + 8], p, i_copy );
397 if( (h&0xc0) != 0x00 )
402 if( !( p_frame = block_New( p_demux, i_copy + 8 + 8 ) ) )
406 p_frame->i_dts = i_pts;
407 p_frame->i_pts = i_pts;
409 ((uint32_t*)p_frame->p_buffer)[0] = i_copy;
410 ((uint32_t*)p_frame->p_buffer)[1] = 1;
411 ((uint32_t*)(p_frame->p_buffer+i_copy+8))[0] = 0;
412 memcpy( &p_frame->p_buffer[8], p, i_copy );
416 if( p_sys->i_pcr < p_frame->i_dts )
418 p_sys->i_pcr = p_frame->i_dts;
419 es_out_Control( p_demux->out, ES_OUT_SET_PCR,
420 (int64_t)p_sys->i_pcr );
422 es_out_Send( p_demux->out, tk->p_es, p_frame );
428 if( !( tk->p_frame = block_New( p_demux, i_len + 8 + 1000) ) )
432 memset( &tk->p_frame->p_buffer[8], 0, i_len );
433 tk->p_frame->i_dts = i_pts;
434 tk->p_frame->i_pts = i_pts;
436 ((uint32_t*)tk->p_frame->p_buffer)[0] = i_len; /* len */
437 ((uint32_t*)tk->p_frame->p_buffer)[1] = 1; /* chunk counts */
438 ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[0] = i_offset;
439 memcpy( &tk->p_frame->p_buffer[i_offset + 8], p, i_copy );
446 else if( tk->fmt.i_cat == AUDIO_ES && b_selected )
449 if( p_sys->i_pcr < i_pts )
451 p_sys->i_pcr = i_pts;
452 es_out_Control( p_demux->out, ES_OUT_SET_PCR,
453 (int64_t)p_sys->i_pcr );
456 if( tk->fmt.i_codec == VLC_FOURCC( 'm', 'p', '4', 'a' ) )
458 int i_sub = (p_sys->buffer[1] >> 4)&0x0f;
459 uint8_t *p_sub = &p_sys->buffer[2+2*i_sub];
462 for( i = 0; i < i_sub; i++ )
464 int i_sub_size = GetWBE( &p_sys->buffer[2+i*2]);
465 block_t *p_block = block_New( p_demux, i_sub_size );
468 memcpy( p_block->p_buffer, p_sub, i_sub_size );
472 p_block->i_pts = ( i == 0 ? i_pts : 0 );
474 es_out_Send( p_demux->out, tk->p_es, p_block );
480 block_t *p_block = block_New( p_demux, i_size );
482 if( tk->fmt.i_codec == VLC_FOURCC( 'a', '5', '2', ' ' ) )
484 uint8_t *src = p_sys->buffer;
485 uint8_t *dst = p_block->p_buffer;
488 while( dst < &p_block->p_buffer[i_size- 1])
498 memcpy( p_block->p_buffer, p_sys->buffer, i_size );
501 p_block->i_pts = i_pts;
503 es_out_Send( p_demux->out, tk->p_es, p_block );
511 /*****************************************************************************
513 *****************************************************************************/
514 static int Control( demux_t *p_demux, int i_query, va_list args )
517 demux_sys_t *p_sys = p_demux->p_sys;
523 case DEMUX_GET_POSITION:
524 pf = (double*) va_arg( args, double* );
525 i64 = stream_Size( p_demux->s );
528 *pf = (double)stream_Tell( p_demux->s ) / (double)i64;
535 case DEMUX_SET_POSITION:
536 f = (double) va_arg( args, double );
537 i64 = stream_Size( p_demux->s );
539 es_out_Control( p_demux->out, ES_OUT_RESET_PCR );
541 return stream_Seek( p_demux->s, (int64_t)(i64 * f) );
544 pi64 = (int64_t*)va_arg( args, int64_t * );
545 if( p_sys->i_mux_rate > 0 )
547 *pi64 = (int64_t)1000000 * ( stream_Tell( p_demux->s ) / 50 ) / p_sys->i_mux_rate;
553 case DEMUX_GET_LENGTH:
554 pi64 = (int64_t*)va_arg( args, int64_t * );
555 if( p_sys->i_mux_rate > 0 )
557 *pi64 = (int64_t)1000000 * ( stream_Size( p_demux->s ) / 50 ) / p_sys->i_mux_rate;
572 /*****************************************************************************
574 *****************************************************************************/
575 static int HeaderRead( demux_t *p_demux )
577 demux_sys_t *p_sys = p_demux->p_sys;
578 uint8_t header[100]; /* FIXME */
587 /* Read the header */
588 if( stream_Read( p_demux->s, header, 10 ) < 10 )
592 i_id = VLC_FOURCC( header[0], header[1], header[2], header[3] );
593 i_size = GetDWBE( &header[4] );
594 i_version = GetWBE( &header[8] );
596 msg_Dbg( p_demux, "object %4.4s size=%d version=%d",
597 (char*)&i_id, i_size, i_version );
599 if( i_size < 10 ) return VLC_EGENERIC;
600 i_skip = i_size - 10;
602 if( i_id == VLC_FOURCC('.','R','M','F') )
604 if( stream_Read( p_demux->s, header, 8 ) < 8 ) return VLC_EGENERIC;
605 msg_Dbg( p_demux, " - file version=0x%x num headers=%d",
606 GetDWBE( &header[0] ), GetDWBE( &header[4] ) );
610 else if( i_id == VLC_FOURCC('P','R','O','P') )
614 if( stream_Read(p_demux->s, header, 40) < 40 ) return VLC_EGENERIC;
616 msg_Dbg( p_demux, " - max bitrate=%d avg bitrate=%d",
617 GetDWBE(&header[0]), GetDWBE(&header[4]) );
618 msg_Dbg( p_demux, " - max packet size=%d avg bitrate=%d",
619 GetDWBE(&header[8]), GetDWBE(&header[12]) );
620 msg_Dbg( p_demux, " - packets count=%d", GetDWBE(&header[16]) );
621 msg_Dbg( p_demux, " - duration=%d ms", GetDWBE(&header[20]) );
622 msg_Dbg( p_demux, " - preroll=%d ms", GetDWBE(&header[24]) );
623 msg_Dbg( p_demux, " - index offset=%d", GetDWBE(&header[28]) );
624 msg_Dbg( p_demux, " - data offset=%d", GetDWBE(&header[32]) );
625 msg_Dbg( p_demux, " - num streams=%d", GetWBE(&header[36]) );
626 i_flags = GetWBE(&header[38]);
627 msg_Dbg( p_demux, " - flags=0x%x %s%s%s",
629 i_flags&0x0001 ? "PN_SAVE_ENABLED " : "",
630 i_flags&0x0002 ? "PN_PERFECT_PLAY_ENABLED " : "",
631 i_flags&0x0004 ? "PN_LIVE_BROADCAST" : "" );
634 else if( i_id == VLC_FOURCC('C','O','N','T') )
639 stream_Read( p_demux->s, header, 2 );
640 if( ( i_len = GetWBE( header ) ) > 0 )
642 psz = malloc( i_len + 1 );
643 stream_Read( p_demux->s, psz, i_len );
646 msg_Dbg( p_demux, " - title=`%s'", psz );
652 stream_Read( p_demux->s, header, 2 );
653 if( ( i_len = GetWBE( header ) ) > 0 )
655 psz = malloc( i_len + 1 );
656 stream_Read( p_demux->s, psz, i_len );
659 msg_Dbg( p_demux, " - author=`%s'", psz );
665 stream_Read( p_demux->s, header, 2 );
666 if( ( i_len = GetWBE( header ) ) > 0 )
668 psz = malloc( i_len + 1 );
669 stream_Read( p_demux->s, psz, i_len );
672 msg_Dbg( p_demux, " - copyright=`%s'", psz );
678 stream_Read( p_demux->s, header, 2 );
679 if( ( i_len = GetWBE( header ) ) > 0 )
681 psz = malloc( i_len + 1 );
682 stream_Read( p_demux->s, psz, i_len );
685 msg_Dbg( p_demux, " - comment=`%s'", psz );
691 else if( i_id == VLC_FOURCC('M','D','P','R') )
693 /* Media properties header */
698 if( stream_Read(p_demux->s, header, 30) < 30 ) return VLC_EGENERIC;
699 i_num = GetWBE( header );
700 msg_Dbg( p_demux, " - id=0x%x", i_num );
701 msg_Dbg( p_demux, " - max bitrate=%d avg bitrate=%d",
702 GetDWBE(&header[2]), GetDWBE(&header[6]) );
703 msg_Dbg( p_demux, " - max packet size=%d avg packet size=%d",
704 GetDWBE(&header[10]), GetDWBE(&header[14]) );
705 msg_Dbg( p_demux, " - start time=%d", GetDWBE(&header[18]) );
706 msg_Dbg( p_demux, " - preroll=%d", GetDWBE(&header[22]) );
707 msg_Dbg( p_demux, " - duration=%d", GetDWBE(&header[26]) );
710 stream_Read( p_demux->s, header, 1 );
711 if( ( i_len = header[0] ) > 0 )
713 psz = malloc( i_len + 1 );
714 stream_Read( p_demux->s, psz, i_len );
717 msg_Dbg( p_demux, " - name=`%s'", psz );
723 stream_Read( p_demux->s, header, 1 );
724 if( ( i_len = header[0] ) > 0 )
726 psz = malloc( i_len + 1 );
727 stream_Read( p_demux->s, psz, i_len );
730 msg_Dbg( p_demux, " - mime=`%s'", psz );
736 stream_Read( p_demux->s, header, 4 );
737 if( ( i_len = GetDWBE( header ) ) > 0 )
739 ReadCodecSpecificData( p_demux, i_len, i_num );
740 stream_Read( p_demux->s, NULL, i_len );
746 else if( i_id == VLC_FOURCC('D','A','T','A') )
748 stream_Read( p_demux->s, header, 8 );
750 p_sys->i_data_offset = stream_Tell( p_demux->s ) - 10;
751 p_sys->i_data_size = i_size;
752 p_sys->i_data_packets_count = GetDWBE( header );
753 p_sys->i_data_packets = 0;
754 p_sys->i_data_offset_next = GetDWBE( &header[4] );
756 msg_Dbg( p_demux, " - packets count=%d next=%u",
757 p_sys->i_data_packets_count,
758 (uint32_t)p_sys->i_data_offset_next );
760 /* we have finished the header */
766 msg_Dbg( p_demux, "unknown chunk" );
769 if( i_skip < 0 ) return VLC_EGENERIC;
770 stream_Read( p_demux->s, NULL, i_skip );
773 /* TODO read index if possible */
778 static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
780 demux_sys_t *p_sys = p_demux->p_sys;
785 msg_Dbg( p_demux, " - specific data len=%d", i_len );
786 if( stream_Peek(p_demux->s, &p_peek, i_len) < i_len ) return VLC_EGENERIC;
788 if( !strncmp( (char *)&p_peek[4], "VIDO", 4 ) )
790 es_format_Init( &fmt, VIDEO_ES, VLC_FOURCC( p_peek[8], p_peek[9],
791 p_peek[10], p_peek[11] ) );
792 fmt.video.i_width = GetWBE( &p_peek[12] );
793 fmt.video.i_height= GetWBE( &p_peek[14] );
796 fmt.p_extra = malloc( 8 );
797 ((uint32_t*)fmt.p_extra)[0] = GetDWBE( &p_peek[26] );
798 ((uint32_t*)fmt.p_extra)[1] = GetDWBE( &p_peek[30] );
800 msg_Dbg( p_demux, " - video 0x%08x 0x%08x",
801 ((uint32_t*)fmt.p_extra)[0], ((uint32_t*)fmt.p_extra)[1] );
803 if( GetDWBE( &p_peek[30] ) == 0x10003000 ||
804 GetDWBE( &p_peek[30] ) == 0x10003001 )
806 fmt.i_codec = VLC_FOURCC( 'R','V','1','3' );
809 msg_Dbg( p_demux, " - video %4.4s %dx%d",
810 (char*)&fmt.i_codec, fmt.video.i_width, fmt.video.i_height );
812 tk = malloc( sizeof( real_track_t ) );
817 tk->p_es = es_out_Add( p_demux->out, &fmt );
819 TAB_APPEND( p_sys->i_track, p_sys->track, tk );
821 else if( !strncmp( (char *)p_peek, ".ra\xfd", 4 ) )
823 int i_version = GetWBE( &p_peek[4] );
824 int i_header_size, i_flavor, i_coded_frame_size, i_subpacket_h;
825 int i_frame_size, i_subpacket_size;
827 msg_Dbg( p_demux, " - audio version=%d", i_version );
830 es_format_Init( &fmt, AUDIO_ES, 0 );
834 msg_Dbg( p_demux, " - audio version 3 is not supported!" );
838 p_peek += 2; /* 00 00 */
839 p_peek += 4; /* .ra4 or .ra5 */
840 p_peek += 4; /* ?? */
841 p_peek += 2; /* version (4 or 5) */
842 i_header_size = GetDWBE( p_peek ); p_peek += 4; /* header size */
843 i_flavor = GetWBE( p_peek ); p_peek += 2; /* codec flavor */
844 i_coded_frame_size = GetDWBE( p_peek ); p_peek += 4;
845 p_peek += 4; /* ?? */
846 p_peek += 4; /* ?? */
847 p_peek += 4; /* ?? */
848 i_subpacket_h = GetWBE( p_peek ); p_peek += 2;
849 i_frame_size = GetWBE( p_peek ); p_peek += 2;
850 i_subpacket_size = GetWBE( p_peek ); p_peek += 2;
851 p_peek += 2; /* ?? */
853 if( i_version == 5 ) p_peek += 6; /* 0, srate, 0 */
855 fmt.audio.i_rate = GetWBE( p_peek ); p_peek += 2;
856 p_peek += 2; /* ?? */
857 fmt.audio.i_bitspersample = GetWBE( p_peek ); p_peek += 2;
858 fmt.audio.i_channels = GetWBE( p_peek ); p_peek += 2;
859 fmt.audio.i_blockalign = i_frame_size;
863 p_peek += 4; /* genr */
864 memcpy( (char *)&fmt.i_codec, p_peek, 4 ); p_peek += 4;
868 p_peek += p_peek[0] + 1; /* descr 1 */
869 memcpy( (char *)&fmt.i_codec, p_peek + 1, 4 ); /* descr 2 */
870 p_peek += p_peek[0] + 1;
873 msg_Dbg( p_demux, " - audio codec=%4.4s channels=%d rate=%dHz",
874 (char*)&fmt.i_codec, fmt.audio.i_channels, fmt.audio.i_rate );
876 p_peek += 3; /* ?? */
877 if( i_version == 5 ) p_peek++;
879 switch( fmt.i_codec )
881 case VLC_FOURCC( 'd', 'n', 'e', 't' ):
882 fmt.i_codec = VLC_FOURCC( 'a', '5', '2', ' ' );
885 case VLC_FOURCC( 'r', 'a', 'a', 'c' ):
886 case VLC_FOURCC( 'r', 'a', 'c', 'p' ):
887 fmt.i_extra = GetDWBE( p_peek ); p_peek += 4;
888 if( fmt.i_extra > 0 ) { fmt.i_extra--; p_peek++; }
889 if( fmt.i_extra > 0 )
891 fmt.p_extra = malloc( fmt.i_extra );
892 memcpy( fmt.p_extra, p_peek, fmt.i_extra );
895 fmt.i_codec = VLC_FOURCC( 'm', 'p', '4', 'a' );
898 case VLC_FOURCC('c','o','o','k'):
899 fmt.i_extra = GetDWBE( p_peek ); p_peek += 4;
900 fmt.p_extra = malloc( fmt.i_extra + 10 );
902 ((short*)(fmt.p_extra))[0] = i_subpacket_size;
903 ((short*)(fmt.p_extra))[1] = i_subpacket_h;
904 ((short*)(fmt.p_extra))[2] = i_flavor;
905 ((short*)(fmt.p_extra))[3] = i_coded_frame_size;
906 ((short*)(fmt.p_extra))[4] = fmt.i_extra;
907 if( fmt.i_extra ) memcpy( fmt.p_extra + 10, p_peek, fmt.i_extra );
912 msg_Dbg( p_demux, " - unknown audio codec=%4.4s",
913 (char*)&fmt.i_codec );
917 if( fmt.i_codec != 0 )
919 msg_Dbg( p_demux, " - extra data=%d", fmt.i_extra );
922 for( i = 0; i < fmt.i_extra; i++ )
924 msg_Dbg( p_demux, " data[%d] = 0x%x", i,
925 ((uint8_t*)fmt.p_extra)[i] );
929 tk = malloc( sizeof( real_track_t ) );
934 tk->p_es = es_out_Add( p_demux->out, &fmt );
936 TAB_APPEND( p_sys->i_track, p_sys->track, tk );