]> git.sesse.net Git - vlc/blob - modules/access/rtp/rtp.c
RTP: use poll() timeout, get rid of the threaded timer and lock
[vlc] / modules / access / rtp / rtp.c
1 /**
2  * @file rtp.c
3  * @brief Real-Time Protocol (RTP) demux module for VLC media player
4  */
5 /*****************************************************************************
6  * Copyright (C) 2001-2005 the VideoLAN team
7  * Copyright © 2007-2009 Rémi Denis-Courmont
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This library 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.
18  *
19  * You should have received a copy of the GNU General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  ****************************************************************************/
23
24 #ifdef HAVE_CONFIG_H
25 # include <config.h>
26 #endif
27 #include <stdarg.h>
28 #include <assert.h>
29 #include <errno.h>
30
31 #include <vlc_common.h>
32 #include <vlc_demux.h>
33 #include <vlc_aout.h>
34 #include <vlc_network.h>
35 #include <vlc_plugin.h>
36
37 #include "rtp.h"
38 #ifdef HAVE_SRTP
39 # include <srtp.h>
40 #endif
41
42 #define RTP_CACHING_TEXT N_("RTP de-jitter buffer length (msec)")
43 #define RTP_CACHING_LONGTEXT N_( \
44     "How long to wait for late RTP packets (and delay the performance)." )
45
46 #define RTCP_PORT_TEXT N_("RTCP (local) port")
47 #define RTCP_PORT_LONGTEXT N_( \
48     "RTCP packets will be received on this transport protocol port. " \
49     "If zero, multiplexed RTP/RTCP is used.")
50
51 #define SRTP_KEY_TEXT N_("SRTP key (hexadecimal)")
52 #define SRTP_KEY_LONGTEXT N_( \
53     "RTP packets will be authenticated and deciphered "\
54     "with this Secure RTP master shared secret key.")
55
56 #define SRTP_SALT_TEXT N_("SRTP salt (hexadecimal)")
57 #define SRTP_SALT_LONGTEXT N_( \
58     "Secure RTP requires a (non-secret) master salt value.")
59
60 #define RTP_MAX_SRC_TEXT N_("Maximum RTP sources")
61 #define RTP_MAX_SRC_LONGTEXT N_( \
62     "How many distinct active RTP sources are allowed at a time." )
63
64 #define RTP_TIMEOUT_TEXT N_("RTP source timeout (sec)")
65 #define RTP_TIMEOUT_LONGTEXT N_( \
66     "How long to wait for any packet before a source is expired.")
67
68 #define RTP_MAX_DROPOUT_TEXT N_("Maximum RTP sequence number dropout")
69 #define RTP_MAX_DROPOUT_LONGTEXT N_( \
70     "RTP packets will be discarded if they are too much ahead (i.e. in the " \
71     "future) by this many packets from the last received packet." )
72
73 #define RTP_MAX_MISORDER_TEXT N_("Maximum RTP sequence number misordering")
74 #define RTP_MAX_MISORDER_LONGTEXT N_( \
75     "RTP packets will be discarded if they are too far behind (i.e. in the " \
76     "past) by this many packets from the last received packet." )
77
78 #define RTP_DYNAMIC_PT_TEXT N_("RTP payload format assumed for dynamic " \
79                                "payloads")
80 #define RTP_DYNAMIC_PT_LONGTEXT N_( \
81     "This payload format will be assumed for dynamic payload types " \
82     "(between 96 and 127) if it can't be determined otherwise with " \
83     "out-of-band mappings (SDP)" )
84
85 static const char *const dynamic_pt_list[] = { "theora" };
86 static const char *const dynamic_pt_list_text[] = { "Theora Encoded Video" };
87
88 static int  Open (vlc_object_t *);
89 static void Close (vlc_object_t *);
90
91 /*
92  * Module descriptor
93  */
94 vlc_module_begin ()
95     set_shortname (N_("RTP"))
96     set_description (N_("Real-Time Protocol (RTP) input"))
97     set_category (CAT_INPUT)
98     set_subcategory (SUBCAT_INPUT_DEMUX)
99     set_capability ("access_demux", 0)
100     set_callbacks (Open, Close)
101
102     add_integer ("rtp-caching", 1000, RTP_CACHING_TEXT,
103                  RTP_CACHING_LONGTEXT, true)
104         change_integer_range (0, 65535)
105         change_safe ()
106     add_integer ("rtcp-port", 0, RTCP_PORT_TEXT,
107                  RTCP_PORT_LONGTEXT, false)
108         change_integer_range (0, 65535)
109         change_safe ()
110 #ifdef HAVE_SRTP
111     add_string ("srtp-key", "",
112                 SRTP_KEY_TEXT, SRTP_KEY_LONGTEXT, false)
113     add_string ("srtp-salt", "",
114                 SRTP_SALT_TEXT, SRTP_SALT_LONGTEXT, false)
115 #endif
116     add_integer ("rtp-max-src", 1, RTP_MAX_SRC_TEXT,
117                  RTP_MAX_SRC_LONGTEXT, true)
118         change_integer_range (1, 255)
119     add_integer ("rtp-timeout", 5, RTP_TIMEOUT_TEXT,
120                  RTP_TIMEOUT_LONGTEXT, true)
121     add_integer ("rtp-max-dropout", 3000, RTP_MAX_DROPOUT_TEXT,
122                  RTP_MAX_DROPOUT_LONGTEXT, true)
123         change_integer_range (0, 32767)
124     add_integer ("rtp-max-misorder", 100, RTP_MAX_MISORDER_TEXT,
125                  RTP_MAX_MISORDER_LONGTEXT, true)
126         change_integer_range (0, 32767)
127     add_string ("rtp-dynamic-pt", NULL, RTP_DYNAMIC_PT_TEXT,
128                 RTP_DYNAMIC_PT_LONGTEXT, true)
129         change_string_list (dynamic_pt_list, dynamic_pt_list_text, NULL)
130
131     /*add_shortcut ("sctp")*/
132     add_shortcut ("dccp", "rtptcp", /* "tcp" is already taken :( */
133                   "rtp", "udplite")
134 vlc_module_end ()
135
136 /*
137  * TODO: so much stuff
138  * - send RTCP-RR and RTCP-BYE
139  * - dynamic payload types (need SDP parser)
140  * - multiple medias (need SDP parser, and RTCP-SR parser for lip-sync)
141  * - support for stream_filter in case of stream_Demux (MPEG-TS)
142  */
143
144 #ifndef IPPROTO_DCCP
145 # define IPPROTO_DCCP 33 /* IANA */
146 #endif
147
148 #ifndef IPPROTO_UDPLITE
149 # define IPPROTO_UDPLITE 136 /* from IANA */
150 #endif
151
152
153 /*
154  * Local prototypes
155  */
156 static int Control (demux_t *, int i_query, va_list args);
157 static int extract_port (char **phost);
158
159 /**
160  * Probes and initializes.
161  */
162 static int Open (vlc_object_t *obj)
163 {
164     demux_t *demux = (demux_t *)obj;
165     int tp; /* transport protocol */
166
167     if (!strcmp (demux->psz_access, "dccp"))
168         tp = IPPROTO_DCCP;
169     else
170     if (!strcmp (demux->psz_access, "rtptcp"))
171         tp = IPPROTO_TCP;
172     else
173     if (!strcmp (demux->psz_access, "rtp"))
174         tp = IPPROTO_UDP;
175     else
176     if (!strcmp (demux->psz_access, "udplite"))
177         tp = IPPROTO_UDPLITE;
178     else
179         return VLC_EGENERIC;
180
181     char *tmp = strdup (demux->psz_location);
182     if (tmp == NULL)
183         return VLC_ENOMEM;
184
185     char *shost;
186     char *dhost = strchr (tmp, '@');
187     if (dhost != NULL)
188     {
189         *(dhost++) = '\0';
190         shost = tmp;
191     }
192     else
193     {
194         dhost = tmp;
195         shost = NULL;
196     }
197
198     /* Parses the port numbers */
199     int sport = 0, dport = 0;
200     if (shost != NULL)
201         sport = extract_port (&shost);
202     if (dhost != NULL)
203         dport = extract_port (&dhost);
204     if (dport == 0)
205         dport = 5004; /* avt-profile-1 port */
206
207     int rtcp_dport = var_CreateGetInteger (obj, "rtcp-port");
208
209     /* Try to connect */
210     int fd = -1, rtcp_fd = -1;
211
212     switch (tp)
213     {
214         case IPPROTO_UDP:
215         case IPPROTO_UDPLITE:
216             fd = net_OpenDgram (obj, dhost, dport,
217                                 shost, sport, AF_UNSPEC, tp);
218             if (fd == -1)
219                 break;
220             if (rtcp_dport > 0) /* XXX: source port is unknown */
221                 rtcp_fd = net_OpenDgram (obj, dhost, rtcp_dport, shost, 0,
222                                          AF_UNSPEC, tp);
223             break;
224
225          case IPPROTO_DCCP:
226 #ifndef SOCK_DCCP /* provisional API (FIXME) */
227 # ifdef __linux__
228 #  define SOCK_DCCP 6
229 # endif
230 #endif
231 #ifdef SOCK_DCCP
232             var_Create (obj, "dccp-service", VLC_VAR_STRING);
233             var_SetString (obj, "dccp-service", "RTPV"); /* FIXME: RTPA? */
234             fd = net_Connect (obj, dhost, dport, SOCK_DCCP, tp);
235 #else
236             msg_Err (obj, "DCCP support not included");
237 #endif
238             break;
239
240         case IPPROTO_TCP:
241             fd = net_Connect (obj, dhost, dport, SOCK_STREAM, tp);
242             break;
243     }
244
245     free (tmp);
246     if (fd == -1)
247         return VLC_EGENERIC;
248     net_SetCSCov (fd, -1, 12);
249
250     /* Initializes demux */
251     demux_sys_t *p_sys = malloc (sizeof (*p_sys));
252     if (p_sys == NULL)
253     {
254         net_Close (fd);
255         if (rtcp_fd != -1)
256             net_Close (rtcp_fd);
257         return VLC_EGENERIC;
258     }
259
260 #ifdef HAVE_SRTP
261     p_sys->srtp         = NULL;
262 #endif
263     p_sys->fd           = fd;
264     p_sys->rtcp_fd      = rtcp_fd;
265     p_sys->caching      = var_CreateGetInteger (obj, "rtp-caching");
266     p_sys->max_src      = var_CreateGetInteger (obj, "rtp-max-src");
267     p_sys->timeout      = var_CreateGetInteger (obj, "rtp-timeout")
268                         * CLOCK_FREQ;
269     p_sys->max_dropout  = var_CreateGetInteger (obj, "rtp-max-dropout");
270     p_sys->max_misorder = var_CreateGetInteger (obj, "rtp-max-misorder");
271     p_sys->thread_ready = false;
272     p_sys->autodetect   = true;
273
274     demux->pf_demux   = NULL;
275     demux->pf_control = Control;
276     demux->p_sys      = p_sys;
277
278     p_sys->session = rtp_session_create (demux);
279     if (p_sys->session == NULL)
280         goto error;
281
282 #ifdef HAVE_SRTP
283     char *key = var_CreateGetNonEmptyString (demux, "srtp-key");
284     if (key)
285     {
286         p_sys->srtp = srtp_create (SRTP_ENCR_AES_CM, SRTP_AUTH_HMAC_SHA1, 10,
287                                    SRTP_PRF_AES_CM, SRTP_RCC_MODE1);
288         if (p_sys->srtp == NULL)
289         {
290             free (key);
291             goto error;
292         }
293
294         char *salt = var_CreateGetNonEmptyString (demux, "srtp-salt");
295         errno = srtp_setkeystring (p_sys->srtp, key, salt ? salt : "");
296         free (salt);
297         free (key);
298         if (errno)
299         {
300             msg_Err (obj, "bad SRTP key/salt combination (%m)");
301             goto error;
302         }
303     }
304 #endif
305
306     if (vlc_clone (&p_sys->thread,
307                    (tp != IPPROTO_TCP) ? rtp_dgram_thread : rtp_stream_thread,
308                    demux, VLC_THREAD_PRIORITY_INPUT))
309         goto error;
310     p_sys->thread_ready = true;
311     return VLC_SUCCESS;
312
313 error:
314     Close (obj);
315     return VLC_EGENERIC;
316 }
317
318
319 /**
320  * Releases resources
321  */
322 static void Close (vlc_object_t *obj)
323 {
324     demux_t *demux = (demux_t *)obj;
325     demux_sys_t *p_sys = demux->p_sys;
326
327     if (p_sys->thread_ready)
328     {
329         vlc_cancel (p_sys->thread);
330         vlc_join (p_sys->thread, NULL);
331     }
332
333 #ifdef HAVE_SRTP
334     if (p_sys->srtp)
335         srtp_destroy (p_sys->srtp);
336 #endif
337     if (p_sys->session)
338         rtp_session_destroy (demux, p_sys->session);
339     if (p_sys->rtcp_fd != -1)
340         net_Close (p_sys->rtcp_fd);
341     net_Close (p_sys->fd);
342     free (p_sys);
343 }
344
345
346 /**
347  * Extracts port number from "[host]:port" or "host:port" strings,
348  * and remove brackets from the host name.
349  * @param phost pointer to the string upon entry,
350  * pointer to the hostname upon return.
351  * @return port number, 0 if missing.
352  */
353 static int extract_port (char **phost)
354 {
355     char *host = *phost, *port;
356
357     if (host[0] == '[')
358     {
359         host = ++*phost; /* skip '[' */
360         port = strchr (host, ']');
361         if (port)
362             *port++ = '\0'; /* skip ']' */
363     }
364     else
365         port = strchr (host, ':');
366
367     if (port == NULL)
368         return 0;
369     *port++ = '\0'; /* skip ':' */
370     return atoi (port);
371 }
372
373
374 /**
375  * Control callback
376  */
377 static int Control (demux_t *demux, int i_query, va_list args)
378 {
379     demux_sys_t *p_sys = demux->p_sys;
380
381     switch (i_query)
382     {
383         case DEMUX_GET_POSITION:
384         {
385             float *v = va_arg (args, float *);
386             *v = 0.;
387             return VLC_SUCCESS;
388         }
389
390         case DEMUX_GET_LENGTH:
391         case DEMUX_GET_TIME:
392         {
393             int64_t *v = va_arg (args, int64_t *);
394             *v = 0;
395             return VLC_SUCCESS;
396         }
397
398         case DEMUX_GET_PTS_DELAY:
399         {
400             int64_t *v = va_arg (args, int64_t *);
401             *v = (int64_t)p_sys->caching * 1000;
402             return VLC_SUCCESS;
403         }
404
405         case DEMUX_CAN_PAUSE:
406         case DEMUX_CAN_SEEK:
407         case DEMUX_CAN_CONTROL_PACE:
408         {
409             bool *v = (bool*)va_arg( args, bool * );
410             *v = false;
411             return VLC_SUCCESS;
412         }
413     }
414
415     return VLC_EGENERIC;
416 }
417
418
419 /*
420  * Generic packet handlers
421  */
422
423 void *codec_init (demux_t *demux, es_format_t *fmt)
424 {
425     return es_out_Add (demux->out, fmt);
426 }
427
428 void codec_destroy (demux_t *demux, void *data)
429 {
430     if (data)
431         es_out_Del (demux->out, (es_out_id_t *)data);
432 }
433
434 /* Send a packet to decoder */
435 void codec_decode (demux_t *demux, void *data, block_t *block)
436 {
437     if (data)
438     {
439         block->i_dts = VLC_TS_INVALID; /* RTP does not specify this */
440         es_out_Control (demux->out, ES_OUT_SET_PCR, block->i_pts );
441         es_out_Send (demux->out, (es_out_id_t *)data, block);
442     }
443     else
444         block_Release (block);
445 }
446
447 static void *stream_init (demux_t *demux, const char *name)
448 {
449     return stream_DemuxNew (demux, name, demux->out);
450 }
451
452 static void stream_destroy (demux_t *demux, void *data)
453 {
454     if (data)
455         stream_Delete ((stream_t *)data);
456     (void)demux;
457 }
458
459 /* Send a packet to a chained demuxer */
460 static void stream_decode (demux_t *demux, void *data, block_t *block)
461 {
462     if (data)
463         stream_DemuxSend ((stream_t *)data, block);
464     else
465         block_Release (block);
466     (void)demux;
467 }
468
469 static void *demux_init (demux_t *demux)
470 {
471     return stream_init (demux, demux->psz_demux);
472 }
473
474 /*
475  * Static payload types handler
476  */
477
478 /* PT=0
479  * PCMU: G.711 µ-law (RFC3551)
480  */
481 static void *pcmu_init (demux_t *demux)
482 {
483     es_format_t fmt;
484
485     es_format_Init (&fmt, AUDIO_ES, VLC_CODEC_MULAW);
486     fmt.audio.i_rate = 8000;
487     fmt.audio.i_channels = 1;
488     return codec_init (demux, &fmt);
489 }
490
491 /* PT=3
492  * GSM
493  */
494 static void *gsm_init (demux_t *demux)
495 {
496     es_format_t fmt;
497
498     es_format_Init (&fmt, AUDIO_ES, VLC_CODEC_GSM);
499     fmt.audio.i_rate = 8000;
500     fmt.audio.i_channels = 1;
501     return codec_init (demux, &fmt);
502 }
503
504 /* PT=8
505  * PCMA: G.711 A-law (RFC3551)
506  */
507 static void *pcma_init (demux_t *demux)
508 {
509     es_format_t fmt;
510
511     es_format_Init (&fmt, AUDIO_ES, VLC_CODEC_ALAW);
512     fmt.audio.i_rate = 8000;
513     fmt.audio.i_channels = 1;
514     return codec_init (demux, &fmt);
515 }
516
517 /* PT=10,11
518  * L16: 16-bits (network byte order) PCM
519  */
520 static void *l16s_init (demux_t *demux)
521 {
522     es_format_t fmt;
523
524     es_format_Init (&fmt, AUDIO_ES, VLC_CODEC_S16B);
525     fmt.audio.i_rate = 44100;
526     fmt.audio.i_channels = 2;
527     return codec_init (demux, &fmt);
528 }
529
530 static void *l16m_init (demux_t *demux)
531 {
532     es_format_t fmt;
533
534     es_format_Init (&fmt, AUDIO_ES, VLC_CODEC_S16B);
535     fmt.audio.i_rate = 44100;
536     fmt.audio.i_channels = 1;
537     return codec_init (demux, &fmt);
538 }
539
540 /* PT=12
541  * QCELP
542  */
543 static void *qcelp_init (demux_t *demux)
544 {
545     es_format_t fmt;
546
547     es_format_Init (&fmt, AUDIO_ES, VLC_CODEC_QCELP);
548     fmt.audio.i_rate = 8000;
549     fmt.audio.i_channels = 1;
550     return codec_init (demux, &fmt);
551 }
552
553 /* PT=14
554  * MPA: MPEG Audio (RFC2250, §3.4)
555  */
556 static void *mpa_init (demux_t *demux)
557 {
558     es_format_t fmt;
559
560     es_format_Init (&fmt, AUDIO_ES, VLC_CODEC_MPGA);
561     fmt.audio.i_channels = 2;
562     fmt.b_packetized = false;
563     return codec_init (demux, &fmt);
564 }
565
566 static void mpa_decode (demux_t *demux, void *data, block_t *block)
567 {
568     if (block->i_buffer < 4)
569     {
570         block_Release (block);
571         return;
572     }
573
574     block->i_buffer -= 4; /* 32-bits RTP/MPA header */
575     block->p_buffer += 4;
576
577     codec_decode (demux, data, block);
578 }
579
580
581 /* PT=32
582  * MPV: MPEG Video (RFC2250, §3.5)
583  */
584 static void *mpv_init (demux_t *demux)
585 {
586     es_format_t fmt;
587
588     es_format_Init (&fmt, VIDEO_ES, VLC_CODEC_MPGV);
589     fmt.b_packetized = false;
590     return codec_init (demux, &fmt);
591 }
592
593 static void mpv_decode (demux_t *demux, void *data, block_t *block)
594 {
595     if (block->i_buffer < 4)
596     {
597         block_Release (block);
598         return;
599     }
600
601     block->i_buffer -= 4; /* 32-bits RTP/MPV header */
602     block->p_buffer += 4;
603 #if 0
604     if (block->p_buffer[-3] & 0x4)
605     {
606         /* MPEG2 Video extension header */
607         /* TODO: shouldn't we skip this too ? */
608     }
609 #endif
610     codec_decode (demux, data, block);
611 }
612
613
614 /* PT=33
615  * MP2: MPEG TS (RFC2250, §2)
616  */
617 static void *ts_init (demux_t *demux)
618 {
619     return stream_init (demux, *demux->psz_demux ? demux->psz_demux : "ts");
620 }
621
622
623 /* Not using SDP, we need to guess the payload format used */
624 /* see http://www.iana.org/assignments/rtp-parameters */
625 int rtp_autodetect (demux_t *demux, rtp_session_t *session,
626                     const block_t *block)
627 {
628     uint8_t ptype = rtp_ptype (block);
629     rtp_pt_t pt = {
630         .init = NULL,
631         .destroy = codec_destroy,
632         .decode = codec_decode,
633         .frequency = 0,
634         .number = ptype,
635     };
636
637     /* Remember to keep this in sync with modules/services_discovery/sap.c */
638     switch (ptype)
639     {
640       case 0:
641         msg_Dbg (demux, "detected G.711 mu-law");
642         pt.init = pcmu_init;
643         pt.frequency = 8000;
644         break;
645
646       case 3:
647         msg_Dbg (demux, "detected GSM");
648         pt.init = gsm_init;
649         pt.frequency = 8000;
650         break;
651
652       case 8:
653         msg_Dbg (demux, "detected G.711 A-law");
654         pt.init = pcma_init;
655         pt.frequency = 8000;
656         break;
657
658       case 10:
659         msg_Dbg (demux, "detected stereo PCM");
660         pt.init = l16s_init;
661         pt.frequency = 44100;
662         break;
663
664       case 11:
665         msg_Dbg (demux, "detected mono PCM");
666         pt.init = l16m_init;
667         pt.frequency = 44100;
668         break;
669
670       case 12:
671         msg_Dbg (demux, "detected QCELP");
672         pt.init = qcelp_init;
673         pt.frequency = 8000;
674         break;
675
676       case 14:
677         msg_Dbg (demux, "detected MPEG Audio");
678         pt.init = mpa_init;
679         pt.decode = mpa_decode;
680         pt.frequency = 90000;
681         break;
682
683       case 32:
684         msg_Dbg (demux, "detected MPEG Video");
685         pt.init = mpv_init;
686         pt.decode = mpv_decode;
687         pt.frequency = 90000;
688         break;
689
690       case 33:
691         msg_Dbg (demux, "detected MPEG2 TS");
692         pt.init = ts_init;
693         pt.destroy = stream_destroy;
694         pt.decode = stream_decode;
695         pt.frequency = 90000;
696         break;
697
698       default:
699         /*
700          * If the rtp payload type is unknown then check demux if it is specified
701          */
702         if ((strcmp(demux->psz_demux, "h264") == 0) || (strcmp(demux->psz_demux, "ts") == 0))
703         {
704           msg_Dbg (demux, "rtp autodetect specified demux=%s", demux->psz_demux);
705           pt.init = demux_init;
706           pt.destroy = stream_destroy;
707           pt.decode = stream_decode;
708           pt.frequency = 90000;
709           break;
710         }
711         else if (ptype >= 96)
712         {
713             char *dynamic = var_InheritString(demux, "rtp-dynamic-pt");
714             if (dynamic == NULL)
715                 ;
716             else if (!strcmp(dynamic, "theora"))
717             {
718                 msg_Dbg (demux, "assuming Theora Encoded Video");
719                 pt.init = theora_init;
720                 pt.destroy = xiph_destroy;
721                 pt.decode = xiph_decode;
722                 pt.frequency = 90000;
723             }
724             else
725             {
726                 msg_Err (demux, "invalid dynamic payload format `%s' "
727                                 "specified", dynamic);
728                 free(dynamic);
729                 return -1;
730             }
731             free(dynamic);
732         }
733         else
734         {
735           return -1;
736         }
737     }
738     rtp_add_type (demux, session, &pt);
739     return 0;
740 }
741
742 /*
743  * Dynamic payload type handlers
744  * Hmm, none implemented yet apart from Xiph ones.
745  */