]> git.sesse.net Git - vlc/blob - modules/access/udp.c
Always autodetect MRU
[vlc] / modules / access / udp.c
1 /*****************************************************************************
2  * udp.c: raw UDP & RTP input module
3  *****************************************************************************
4  * Copyright (C) 2001-2005 the VideoLAN team
5  * Copyright (C) 2007 Remi Denis-Courmont
6  * $Id$
7  *
8  * Authors: Christophe Massiot <massiot@via.ecp.fr>
9  *          Tristan Leteurtre <tooney@via.ecp.fr>
10  *          Laurent Aimar <fenrir@via.ecp.fr>
11  *          Jean-Paul Saman <jpsaman #_at_# m2x dot nl>
12  *          Remi Denis-Courmont
13  *
14  * Reviewed: 23 October 2003, Jean-Paul Saman <jpsaman _at_ videolan _dot_ org>
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 2 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
29  *****************************************************************************/
30
31 /*****************************************************************************
32  * Preamble
33  *****************************************************************************/
34
35 #include <vlc/vlc.h>
36 #include <vlc_access.h>
37 #include <vlc_network.h>
38
39 /* Big pile of stuff missing form glibc 2.5 */
40 #if defined (HAVE_NETINET_UDPLITE_H)
41 # include <netinet/udplite.h>
42 #elif defined (__linux__)
43 # define UDPLITE_SEND_CSCOV     10
44 # define UDPLITE_RECV_CSCOV     11
45 #endif
46
47 #ifndef SOCK_DCCP /* provisional API */
48 # ifdef __linux__
49 #  define SOCK_DCCP 6
50 # endif
51 #endif
52
53 #ifndef IPPROTO_DCCP
54 # define IPPROTO_DCCP 33 /* IANA */
55 #endif
56
57 #ifndef IPPROTO_UDPLITE
58 # define IPPROTO_UDPLITE 136 /* from IANA */
59 #endif
60 #ifndef SOL_UDPLITE
61 # define SOL_UDPLITE IPPROTO_UDPLITE
62 #endif
63
64 #define MTU 65535
65
66 /*****************************************************************************
67  * Module descriptor
68  *****************************************************************************/
69 #define CACHING_TEXT N_("Caching value in ms")
70 #define CACHING_LONGTEXT N_( \
71     "Caching value for UDP streams. This " \
72     "value should be set in milliseconds." )
73
74 #define RTP_LATE_TEXT N_("RTP reordering timeout in ms")
75 #define RTP_LATE_LONGTEXT N_( \
76     "VLC reorders RTP packets. The input will wait for late packets at most "\
77     "the time specified here (in milliseconds)." )
78
79 static int  Open ( vlc_object_t * );
80 static void Close( vlc_object_t * );
81
82 vlc_module_begin();
83     set_shortname( _("UDP/RTP" ) );
84     set_description( _("UDP/RTP input") );
85     set_category( CAT_INPUT );
86     set_subcategory( SUBCAT_INPUT_ACCESS );
87
88     add_integer( "udp-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT,
89                  CACHING_LONGTEXT, VLC_TRUE );
90     add_integer( "rtp-late", 100, NULL, RTP_LATE_TEXT, RTP_LATE_LONGTEXT, VLC_TRUE );
91     add_obsolete_bool( "udp-auto-mtu" );
92
93     set_capability( "access2", 0 );
94     add_shortcut( "udp" );
95     add_shortcut( "udpstream" );
96     add_shortcut( "udp4" );
97     add_shortcut( "udp6" );
98     add_shortcut( "rtp" );
99     add_shortcut( "rtp4" );
100     add_shortcut( "rtp6" );
101     add_shortcut( "udplite" );
102     add_shortcut( "rtptcp" );
103     add_shortcut( "dccp" );
104
105     set_callbacks( Open, Close );
106 vlc_module_end();
107
108 /*****************************************************************************
109  * Local prototypes
110  *****************************************************************************/
111 #define RTP_HEADER_LEN 12
112
113 static block_t *BlockUDP( access_t * );
114 static block_t *BlockTCP( access_t * );
115 static block_t *BlockRTP( access_t * );
116 static block_t *BlockChoose( access_t * );
117 static int Control( access_t *, int, va_list );
118
119 struct access_sys_t
120 {
121     int fd;
122
123     vlc_bool_t b_framed_rtp;
124
125     /* reorder rtp packets when out-of-sequence */
126     uint16_t i_last_seqno;
127     mtime_t i_rtp_late;
128     block_t *p_list;
129     block_t *p_end;
130     block_t *p_partial_frame; /* Partial Framed RTP packet */
131 };
132
133 /*****************************************************************************
134  * Open: open the socket
135  *****************************************************************************/
136 static int Open( vlc_object_t *p_this )
137 {
138     access_t     *p_access = (access_t*)p_this;
139     access_sys_t *p_sys;
140
141     char *psz_name = strdup( p_access->psz_path );
142     char *psz_parser;
143     const char *psz_server_addr, *psz_bind_addr = "";
144     int  i_bind_port, i_server_port = 0;
145     int fam = AF_UNSPEC, proto = IPPROTO_UDP;
146
147     if (strlen (p_access->psz_access) >= 3)
148     {
149         switch (p_access->psz_access[3])
150         {
151             case '4':
152                 fam = AF_INET;
153                 break;
154
155             case '6':
156                 fam = AF_INET6;
157                 break;
158         }
159         if (strcmp (p_access->psz_access + 3, "lite") == 0)
160             proto = IPPROTO_UDPLITE;
161         else
162         if (strcmp (p_access->psz_access + 3, "tcp") == 0)
163             proto = IPPROTO_TCP;
164         else
165         if (strcmp (p_access->psz_access, "dccp") == 0)
166             proto = IPPROTO_DCCP;
167     }
168
169     i_bind_port = var_CreateGetInteger( p_access, "server-port" );
170
171     /* Parse psz_name syntax :
172      * [serveraddr[:serverport]][@[bindaddr]:[bindport]] */
173     psz_parser = strchr( psz_name, '@' );
174     if( psz_parser != NULL )
175     {
176         /* Found bind address and/or bind port */
177         *psz_parser++ = '\0';
178         psz_bind_addr = psz_parser;
179
180         if( psz_bind_addr[0] == '[' )
181             /* skips bracket'd IPv6 address */
182             psz_parser = strchr( psz_parser, ']' );
183
184         if( psz_parser != NULL )
185         {
186             psz_parser = strchr( psz_parser, ':' );
187             if( psz_parser != NULL )
188             {
189                 *psz_parser++ = '\0';
190                 i_bind_port = atoi( psz_parser );
191             }
192         }
193     }
194
195     psz_server_addr = psz_name;
196     psz_parser = ( psz_server_addr[0] == '[' )
197         ? strchr( psz_name, ']' ) /* skips bracket'd IPv6 address */
198         : psz_name;
199
200     if( psz_parser != NULL )
201     {
202         psz_parser = strchr( psz_parser, ':' );
203         if( psz_parser != NULL )
204         {
205             *psz_parser++ = '\0';
206             i_server_port = atoi( psz_parser );
207         }
208     }
209
210     msg_Dbg( p_access, "opening server=%s:%d local=%s:%d",
211              psz_server_addr, i_server_port, psz_bind_addr, i_bind_port );
212
213     /* Set up p_access */
214     access_InitFields( p_access );
215     ACCESS_SET_CALLBACKS( NULL, BlockChoose, Control, NULL );
216     p_access->info.b_prebuffered = VLC_FALSE;
217     MALLOC_ERR( p_access->p_sys, access_sys_t ); p_sys = p_access->p_sys;
218     memset (p_sys, 0, sizeof (*p_sys));
219
220     switch (proto)
221     {
222         case IPPROTO_UDP:
223         case IPPROTO_UDPLITE:
224             p_sys->fd = net_OpenDgram( p_access, psz_bind_addr, i_bind_port,
225                                        psz_server_addr, i_server_port, fam,
226                                        proto );
227             break;
228
229         case IPPROTO_TCP:
230             p_sys->fd = net_ConnectTCP( p_access, psz_server_addr, i_server_port );
231             p_sys->b_framed_rtp = VLC_TRUE;
232             break;
233
234         case IPPROTO_DCCP:
235 #ifdef SOCK_DCCP
236             p_sys->fd = net_Connect( p_access, psz_server_addr, i_server_port,
237                                      SOCK_DCCP, IPPROTO_DCCP );
238 #else
239             p_sys->fd = -1;
240             msg_Err( p_access, "DCCP support not compiled-in!" );
241 #endif
242             break;
243     }
244     free (psz_name);
245     if( p_sys->fd == -1 )
246     {
247         msg_Err( p_access, "cannot open socket" );
248         free( p_sys );
249         return VLC_EGENERIC;
250     }
251
252     shutdown( p_sys->fd, SHUT_WR );
253
254 #ifdef UDPLITE_RECV_CSCOV
255     if (proto == IPPROTO_UDPLITE)
256         /* UDP header: 8 bytes + RTP header: 12 bytes (or more) */
257         setsockopt (p_sys->fd, SOL_UDPLITE, UDPLITE_RECV_CSCOV,
258                     &(int){ 20 }, sizeof (int));
259 #endif
260
261     if (p_sys->b_framed_rtp)
262     {
263         /* We don't do autodetection and prebuffering in case of framing */
264         p_access->pf_block = BlockRTP;
265     }
266
267     /* Update default_pts to a suitable value for udp access */
268     var_Create( p_access, "udp-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
269
270     /* RTP reordering for out-of-sequence packets */
271     p_sys->i_rtp_late = var_CreateGetInteger( p_access, "rtp-late" ) * 1000;
272     p_sys->i_last_seqno = 0;
273     p_sys->p_list = NULL;
274     p_sys->p_end = NULL;
275     return VLC_SUCCESS;
276 }
277
278 /*****************************************************************************
279  * Close: free unused data structures
280  *****************************************************************************/
281 static void Close( vlc_object_t *p_this )
282 {
283     access_t     *p_access = (access_t*)p_this;
284     access_sys_t *p_sys = p_access->p_sys;
285
286     block_ChainRelease( p_sys->p_list );
287     net_Close( p_sys->fd );
288     free( p_sys );
289 }
290
291 /*****************************************************************************
292  * Control:
293  *****************************************************************************/
294 static int Control( access_t *p_access, int i_query, va_list args )
295 {
296     vlc_bool_t   *pb_bool;
297     int          *pi_int;
298     int64_t      *pi_64;
299
300     switch( i_query )
301     {
302         /* */
303         case ACCESS_CAN_SEEK:
304         case ACCESS_CAN_FASTSEEK:
305         case ACCESS_CAN_PAUSE:
306         case ACCESS_CAN_CONTROL_PACE:
307             pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
308             *pb_bool = VLC_FALSE;
309             break;
310         /* */
311         case ACCESS_GET_MTU:
312             pi_int = (int*)va_arg( args, int * );
313             *pi_int = MTU;
314             break;
315
316         case ACCESS_GET_PTS_DELAY:
317             pi_64 = (int64_t*)va_arg( args, int64_t * );
318             *pi_64 = var_GetInteger( p_access, "udp-caching" ) * 1000;
319             break;
320
321         /* */
322         case ACCESS_SET_PAUSE_STATE:
323         case ACCESS_GET_TITLE_INFO:
324         case ACCESS_SET_TITLE:
325         case ACCESS_SET_SEEKPOINT:
326         case ACCESS_SET_PRIVATE_ID_STATE:
327             return VLC_EGENERIC;
328
329         default:
330             msg_Warn( p_access, "unimplemented query in control" );
331             return VLC_EGENERIC;
332
333     }
334     return VLC_SUCCESS;
335 }
336
337 /*****************************************************************************
338  * BlockUDP:
339  *****************************************************************************/
340 static block_t *BlockUDP( access_t *p_access )
341 {
342     access_sys_t *p_sys = p_access->p_sys;
343     block_t      *p_block;
344
345     /* Read data */
346     p_block = block_New( p_access, MTU );
347     p_block->i_buffer = net_Read( p_access, p_sys->fd, NULL,
348                                   p_block->p_buffer, MTU, VLC_FALSE );
349     if( p_block->i_buffer < 0 )
350     {
351         block_Release( p_block );
352         return NULL;
353     }
354
355     return block_Realloc( p_block, 0, p_block->i_buffer );
356 }
357
358 /*****************************************************************************
359  * BlockTCP: Framed RTP/AVP packet reception for COMEDIA (see RFC4571)
360  *****************************************************************************/
361 static block_t *BlockTCP( access_t *p_access )
362 {
363     access_sys_t *p_sys = p_access->p_sys;
364     block_t      *p_block = p_sys->p_partial_frame;
365
366     if( p_access->info.b_eof )
367         return NULL;
368
369     if( p_block == NULL )
370     {
371         /* MTU should always be 65535 in this case */
372         p_sys->p_partial_frame = p_block = block_New( p_access, 2 + MTU );
373         if (p_block == NULL)
374             return NULL;
375     }
376
377     /* Read RTP framing */
378     if (p_block->i_buffer < 2)
379     {
380         /* FIXME: not very efficient */
381         int i_read = net_Read( p_access, p_sys->fd, NULL,
382                                p_block->p_buffer + p_block->i_buffer,
383                                2 - p_block->i_buffer, VLC_FALSE );
384         if( i_read <= 0 )
385             goto error;
386
387         p_block->i_buffer += i_read;
388         if (p_block->i_buffer < 2)
389             return NULL;
390     }
391
392     uint16_t framelen = GetWLE( p_block->p_buffer );
393     /* Read RTP frame */
394     if( framelen > 0 )
395     {
396         int i_read = net_Read( p_access, p_sys->fd, NULL,
397                                p_block->p_buffer + p_block->i_buffer,
398                                2 + framelen - p_block->i_buffer, VLC_FALSE );
399         if( i_read <= 0 )
400             goto error;
401
402         p_block->i_buffer += i_read;
403     }
404
405     if( p_block->i_buffer < (2 + framelen) )
406         return NULL; // incomplete frame
407
408     /* Hide framing from RTP layer */
409     p_block->p_buffer += 2;
410     p_block->i_buffer -= 2;
411     p_sys->p_partial_frame = NULL;
412     return p_block;
413
414 error:
415     p_access->info.b_eof = VLC_TRUE;
416     block_Release( p_block );
417     p_sys->p_partial_frame = NULL;
418     return NULL;
419 }
420
421
422 /*
423  * rtp_ChainInsert - insert a p_block in the chain and
424  * look at the sequence numbers.
425  */
426 static inline vlc_bool_t rtp_ChainInsert( access_t *p_access, block_t *p_block )
427 {
428     access_sys_t *p_sys = (access_sys_t *) p_access->p_sys;
429     block_t *p_prev = NULL;
430     block_t *p = p_sys->p_end;
431     uint16_t i_new = (uint16_t) p_block->i_dts;
432     uint16_t i_tmp = 0;
433
434     if( !p_sys->p_list )
435     {
436         p_sys->p_list = p_block;
437         p_sys->p_end = p_block;
438         return VLC_TRUE;
439     }
440     /* walk through the queue from top down since the new packet is in 
441     most cases just appended to the end */
442
443     for( ;; )
444     {
445         i_tmp = i_new - (uint16_t) p->i_dts;
446
447         if( !i_tmp )   /* trash duplicate */
448             break;
449
450         if ( i_tmp < 32768 )
451         {   /* insert after this block ( i_new > p->i_dts ) */
452             p_block->p_next = p->p_next;
453             p->p_next = p_block;
454             p_block->p_prev = p;
455             if (p_prev)
456             {
457                 p_prev->p_prev = p_block;
458                 msg_Dbg(p_access, "RTP reordering: insert after %d, new %d",
459                         (uint16_t) p->i_dts, i_new );
460             }
461             else
462             {
463                 p_sys->p_end = p_block;
464             }
465             return VLC_TRUE;
466         }
467         if( p == p_sys->p_list )
468         {   /* we've reached bottom of chain */
469             i_tmp = p_sys->i_last_seqno - i_new;
470             if( !p_access->info.b_prebuffered || (i_tmp > 32767) )
471             {
472                 msg_Dbg(p_access, "RTP reordering: prepend %d before %d",
473                         i_new, (uint16_t) p->i_dts );
474                 p_block->p_next = p;
475                 p->p_prev = p_block;
476                 p_sys->p_list = p_block;
477                 return VLC_TRUE;
478             }
479
480             if( !i_tmp )   /* trash duplicate */
481                 break;
482
483             /* reordering failed - append the packet to the end of queue */
484             msg_Dbg(p_access, "RTP: sequence changed (or buffer too small) "
485                     "new: %d, buffer %d...%d", i_new, (uint16_t) p->i_dts,
486                 (uint16_t) p_sys->p_end->i_dts);
487             p_sys->p_end->p_next = p_block;
488             p_block->p_prev = p_sys->p_end;
489             p_sys->p_end = p_block;
490             return VLC_TRUE;
491         }
492         p_prev = p;
493         p = p->p_prev;
494     }
495     block_Release( p_block );
496     return VLC_FALSE;
497 }
498
499 /*****************************************************************************
500  * BlockParseRTP/BlockRTP:
501  *****************************************************************************/
502 static block_t *BlockParseRTP( access_t *p_access, block_t *p_block )
503 {
504     int      i_payload_type;
505     size_t   i_skip = RTP_HEADER_LEN;
506
507     if( p_block == NULL )
508         return NULL;
509
510     if( p_block->i_buffer < RTP_HEADER_LEN )
511     {
512         msg_Dbg( p_access, "short RTP packet received" );
513         goto trash;
514     }
515
516     /* Parse the header and make some verifications.
517      * See RFC 3550. */
518     // Version number:
519     if( ( p_block->p_buffer[0] >> 6 ) != 2)
520     {
521         msg_Dbg( p_access, "RTP version is %u instead of 2",
522                  p_block->p_buffer[0] >> 6 );
523         goto trash;
524     }
525     // Padding bit:
526     uint8_t pad = (p_block->p_buffer[0] & 0x20)
527                     ? p_block->p_buffer[p_block->i_buffer - 1] : 0;
528     // CSRC count:
529     i_skip += (p_block->p_buffer[0] & 0x0F) * 4;
530     // Extension header:
531     if (p_block->p_buffer[0] & 0x10) /* Extension header */
532     {
533         i_skip += 4;
534         if ((size_t)p_block->i_buffer < i_skip)
535             goto trash;
536
537         i_skip += 4 * GetWBE( p_block->p_buffer + i_skip - 2 );
538     }
539
540     i_payload_type    = p_block->p_buffer[1] & 0x7F;
541
542     /* Remember sequence number in i_dts */
543     p_block->i_pts = mdate();
544     p_block->i_dts = (mtime_t) GetWBE( p_block->p_buffer + 2 );
545
546     /* FIXME: use rtpmap */
547     switch( i_payload_type )
548     {
549         case 14: // MPA: MPEG Audio (RFC2250, §3.4)
550             i_skip += 4; // 32 bits RTP/MPA header
551             break;
552
553         case 32: // MPV: MPEG Video (RFC2250, §3.5)
554             i_skip += 4; // 32 bits RTP/MPV header
555             if( (size_t)p_block->i_buffer < i_skip )
556                 goto trash;
557             if( p_block->p_buffer[i_skip - 3] & 0x4 )
558             {
559                 /* MPEG2 Video extension header */
560                 /* TODO: shouldn't we skip this too ? */
561             }
562             break;
563
564         case 33: // MP2: MPEG TS (RFC2250, §2)
565             /* plain TS over RTP */
566             break;
567
568         default:
569             msg_Dbg( p_access, "unsupported RTP payload type: %u", i_payload_type );
570             goto trash;
571     }
572
573     if( (size_t)p_block->i_buffer < (i_skip + pad) )
574         goto trash;
575
576     /* Remove the RTP header */
577     p_block->i_buffer -= i_skip;
578     p_block->p_buffer += i_skip;
579
580     /* This is the place for deciphering and authentication */
581
582     /* Remove padding (at the end) */
583     p_block->i_buffer -= pad;
584
585 #if 0
586     /* Emulate packet loss */
587     if ( (i_sequence_number % 4000) == 0)
588     {
589         msg_Warn( p_access, "Emulating packet drop" );
590         block_Release( p_block );
591         return NULL;
592     }
593 #endif
594
595     return p_block;
596
597 trash:
598     block_Release( p_block );
599     return NULL;
600 }
601
602 static block_t *BlockPrebufferRTP( access_t *p_access, block_t *p_block )
603 {
604     access_sys_t *p_sys = p_access->p_sys;
605     mtime_t   i_first = mdate();
606     int       i_count = 0;
607     block_t   *p = p_block;
608
609     for( ;; )
610     {
611         mtime_t i_date = mdate();
612
613         if( p && rtp_ChainInsert( p_access, p ))
614             i_count++;
615
616         /* Require at least 2 packets in the buffer */
617         if( i_count > 2 && (i_date - i_first) > p_sys->i_rtp_late )
618             break;
619
620         p = BlockParseRTP( p_access, BlockUDP( p_access ) );
621         if( !p && (i_date - i_first) > p_sys->i_rtp_late ) 
622         {
623             msg_Err( p_access, "error in RTP prebuffering!" );
624             break;
625         }
626     }
627
628     msg_Dbg( p_access, "RTP: prebuffered %d packets", i_count - 1 );
629     p_access->info.b_prebuffered = VLC_TRUE;
630     p = p_sys->p_list;
631     p_sys->p_list = p_sys->p_list->p_next;
632     p_sys->i_last_seqno = (uint16_t) p->i_dts;
633     p->p_next = NULL;
634     return p;
635 }
636
637 static block_t *BlockRTP( access_t *p_access )
638 {
639     access_sys_t *p_sys = p_access->p_sys;
640     block_t *p;
641
642     while ( !p_sys->p_list ||
643              ( mdate() - p_sys->p_list->i_pts ) < p_sys->i_rtp_late )
644     {
645         p = BlockParseRTP( p_access,
646                            p_sys->b_framed_rtp ? BlockTCP( p_access )
647                                                : BlockUDP( p_access ) );
648         if ( !p )
649             return NULL;
650
651         rtp_ChainInsert( p_access, p );
652     }
653
654     p = p_sys->p_list;
655     p_sys->p_list = p_sys->p_list->p_next;
656     p_sys->i_last_seqno++;
657     if( p_sys->i_last_seqno != (uint16_t) p->i_dts )
658     {
659         msg_Dbg( p_access, "RTP: packet(s) lost, expected %d, got %d",
660                  p_sys->i_last_seqno, (uint16_t) p->i_dts );
661         p_sys->i_last_seqno = (uint16_t) p->i_dts;
662     }
663     p->p_next = NULL;
664     return p;
665 }
666
667 /*****************************************************************************
668  * BlockChoose: decide between RTP and UDP
669  *****************************************************************************/
670 static block_t *BlockChoose( access_t *p_access )
671 {
672     block_t *p_block;
673     int     i_rtp_version;
674     int     i_payload_type;
675
676     if( ( p_block = BlockUDP( p_access ) ) == NULL )
677         return NULL;
678
679     if( p_block->p_buffer[0] == 0x47 )
680     {
681         msg_Dbg( p_access, "detected TS over raw UDP" );
682         p_access->pf_block = BlockUDP;
683         p_access->info.b_prebuffered = VLC_TRUE;
684         return p_block;
685     }
686
687     if( p_block->i_buffer < RTP_HEADER_LEN )
688         return p_block;
689
690     /* Parse the header and make some verifications.
691      * See RFC 3550. */
692
693     i_rtp_version  = p_block->p_buffer[0] >> 6;
694     i_payload_type = ( p_block->p_buffer[1] & 0x7F );
695
696     if( i_rtp_version != 2 )
697     {
698         msg_Dbg( p_access, "no supported RTP header detected" );
699         p_access->pf_block = BlockUDP;
700         p_access->info.b_prebuffered = VLC_TRUE;
701         return p_block;
702     }
703
704     switch( i_payload_type )
705     {
706         case 33:
707             msg_Dbg( p_access, "detected MPEG2 TS over RTP" );
708             p_access->psz_demux = strdup( "ts" );
709             break;
710
711         case 14:
712             msg_Dbg( p_access, "detected MPEG Audio over RTP" );
713             p_access->psz_demux = strdup( "mpga" );
714             break;
715
716         case 32:
717             msg_Dbg( p_access, "detected MPEG Video over RTP" );
718             p_access->psz_demux = strdup( "mpgv" );
719             break;
720
721         default:
722             msg_Dbg( p_access, "no RTP header detected" );
723             p_access->pf_block = BlockUDP;
724             p_access->info.b_prebuffered = VLC_TRUE;
725             return p_block;
726     }
727
728     if( !BlockParseRTP( p_access, p_block )) return NULL;
729
730     p_access->pf_block = BlockRTP;
731
732     return BlockPrebufferRTP( p_access, p_block );
733 }