]> git.sesse.net Git - ffmpeg/blob - libavformat/rtpproto.c
Merge commit '7a9b764c0737f42cf2458c3c5378b0df216e14a2'
[ffmpeg] / libavformat / rtpproto.c
1 /*
2  * RTP network protocol
3  * Copyright (c) 2002 Fabrice Bellard
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 /**
23  * @file
24  * RTP protocol
25  */
26
27 #include "libavutil/parseutils.h"
28 #include "libavutil/avstring.h"
29 #include "libavutil/opt.h"
30 #include "avformat.h"
31 #include "avio_internal.h"
32 #include "rtp.h"
33 #include "rtpproto.h"
34 #include "url.h"
35
36 #include <stdarg.h>
37 #include "internal.h"
38 #include "network.h"
39 #include "os_support.h"
40 #include <fcntl.h>
41 #if HAVE_POLL_H
42 #include <sys/poll.h>
43 #endif
44
45 typedef struct RTPContext {
46     const AVClass *class;
47     URLContext *rtp_hd, *rtcp_hd;
48     int rtp_fd, rtcp_fd, nb_ssm_include_addrs, nb_ssm_exclude_addrs;
49     struct sockaddr_storage **ssm_include_addrs, **ssm_exclude_addrs;
50     int write_to_source;
51     struct sockaddr_storage last_rtp_source, last_rtcp_source;
52     socklen_t last_rtp_source_len, last_rtcp_source_len;
53     int ttl;
54     int buffer_size;
55     int rtcp_port, local_rtpport, local_rtcpport;
56     int connect;
57     int pkt_size;
58     char *sources;
59     char *block;
60 } RTPContext;
61
62 #define OFFSET(x) offsetof(RTPContext, x)
63 #define D AV_OPT_FLAG_DECODING_PARAM
64 #define E AV_OPT_FLAG_ENCODING_PARAM
65 static const AVOption options[] = {
66     { "ttl",                "Time to live (in milliseconds, multicast only)",                   OFFSET(ttl),             AV_OPT_TYPE_INT,    { .i64 = -1 },    -1, INT_MAX, .flags = D|E },
67     { "buffer_size",        "Send/Receive buffer size (in bytes)",                              OFFSET(buffer_size),     AV_OPT_TYPE_INT,    { .i64 = -1 },    -1, INT_MAX, .flags = D|E },
68     { "rtcp_port",          "Custom rtcp port",                                                 OFFSET(rtcp_port),       AV_OPT_TYPE_INT,    { .i64 = -1 },    -1, INT_MAX, .flags = D|E },
69     { "local_rtpport",      "Local rtp port",                                                   OFFSET(local_rtpport),   AV_OPT_TYPE_INT,    { .i64 = -1 },    -1, INT_MAX, .flags = D|E },
70     { "local_rtcpport",     "Local rtcp port",                                                  OFFSET(local_rtcpport),  AV_OPT_TYPE_INT,    { .i64 = -1 },    -1, INT_MAX, .flags = D|E },
71     { "connect",            "Connect socket",                                                   OFFSET(connect),         AV_OPT_TYPE_INT,    { .i64 =  0 },     0, 1,       .flags = D|E },
72     { "write_to_source",    "Send packets to the source address of the latest received packet", OFFSET(write_to_source), AV_OPT_TYPE_INT,    { .i64 =  0 },     0, 1,       .flags = D|E },
73     { "pkt_size",           "Maximum packet size",                                              OFFSET(pkt_size),        AV_OPT_TYPE_INT,    { .i64 = -1 },    -1, INT_MAX, .flags = D|E },
74     { "sources",            "Source list",                                                      OFFSET(sources),         AV_OPT_TYPE_STRING, { .str = NULL },               .flags = D|E },
75     { "block",              "Block list",                                                       OFFSET(block),           AV_OPT_TYPE_STRING, { .str = NULL },               .flags = D|E },
76     { NULL }
77 };
78
79 static const AVClass rtp_class = {
80     .class_name = "rtp",
81     .item_name  = av_default_item_name,
82     .option     = options,
83     .version    = LIBAVUTIL_VERSION_INT,
84 };
85
86 /**
87  * If no filename is given to av_open_input_file because you want to
88  * get the local port first, then you must call this function to set
89  * the remote server address.
90  *
91  * @param h media file context
92  * @param uri of the remote server
93  * @return zero if no error.
94  */
95
96 int ff_rtp_set_remote_url(URLContext *h, const char *uri)
97 {
98     RTPContext *s = h->priv_data;
99     char hostname[256];
100     int port, rtcp_port;
101     const char *p;
102
103     char buf[1024];
104     char path[1024];
105
106     av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port,
107                  path, sizeof(path), uri);
108     rtcp_port = port + 1;
109
110     p = strchr(uri, '?');
111     if (p) {
112         if (av_find_info_tag(buf, sizeof(buf), "rtcpport", p)) {
113             rtcp_port = strtol(buf, NULL, 10);
114         }
115     }
116
117     ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, port, "%s", path);
118     ff_udp_set_remote_url(s->rtp_hd, buf);
119
120     ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, rtcp_port, "%s", path);
121     ff_udp_set_remote_url(s->rtcp_hd, buf);
122     return 0;
123 }
124
125 static struct addrinfo* rtp_resolve_host(const char *hostname, int port,
126                                          int type, int family, int flags)
127 {
128     struct addrinfo hints = { 0 }, *res = 0;
129     int error;
130     char service[16];
131
132     snprintf(service, sizeof(service), "%d", port);
133     hints.ai_socktype = type;
134     hints.ai_family   = family;
135     hints.ai_flags    = flags;
136     if ((error = getaddrinfo(hostname, service, &hints, &res))) {
137         res = NULL;
138         av_log(NULL, AV_LOG_ERROR, "rtp_resolve_host: %s\n", gai_strerror(error));
139     }
140
141     return res;
142 }
143
144 static int compare_addr(const struct sockaddr_storage *a,
145                         const struct sockaddr_storage *b)
146 {
147     if (a->ss_family != b->ss_family)
148         return 1;
149     if (a->ss_family == AF_INET) {
150         return (((const struct sockaddr_in *)a)->sin_addr.s_addr !=
151                 ((const struct sockaddr_in *)b)->sin_addr.s_addr);
152     }
153
154 #if HAVE_STRUCT_SOCKADDR_IN6
155     if (a->ss_family == AF_INET6) {
156         const uint8_t *s6_addr_a = ((const struct sockaddr_in6 *)a)->sin6_addr.s6_addr;
157         const uint8_t *s6_addr_b = ((const struct sockaddr_in6 *)b)->sin6_addr.s6_addr;
158         return memcmp(s6_addr_a, s6_addr_b, 16);
159     }
160 #endif
161     return 1;
162 }
163
164 static int get_port(const struct sockaddr_storage *ss)
165 {
166     if (ss->ss_family == AF_INET)
167         return ntohs(((const struct sockaddr_in *)ss)->sin_port);
168 #if HAVE_STRUCT_SOCKADDR_IN6
169     if (ss->ss_family == AF_INET6)
170         return ntohs(((const struct sockaddr_in6 *)ss)->sin6_port);
171 #endif
172     return 0;
173 }
174
175 static void set_port(struct sockaddr_storage *ss, int port)
176 {
177     if (ss->ss_family == AF_INET)
178         ((struct sockaddr_in *)ss)->sin_port = htons(port);
179 #if HAVE_STRUCT_SOCKADDR_IN6
180     else if (ss->ss_family == AF_INET6)
181         ((struct sockaddr_in6 *)ss)->sin6_port = htons(port);
182 #endif
183 }
184
185 static int rtp_check_source_lists(RTPContext *s, struct sockaddr_storage *source_addr_ptr)
186 {
187     int i;
188     if (s->nb_ssm_exclude_addrs) {
189         for (i = 0; i < s->nb_ssm_exclude_addrs; i++) {
190             if (!compare_addr(source_addr_ptr, s->ssm_exclude_addrs[i]))
191                 return 1;
192         }
193     }
194     if (s->nb_ssm_include_addrs) {
195         for (i = 0; i < s->nb_ssm_include_addrs; i++) {
196             if (!compare_addr(source_addr_ptr, s->ssm_include_addrs[i]))
197                 return 0;
198         }
199         return 1;
200     }
201     return 0;
202 }
203
204 /**
205  * add option to url of the form:
206  * "http://host:port/path?option1=val1&option2=val2...
207  */
208
209 static av_printf_format(3, 4) void url_add_option(char *buf, int buf_size, const char *fmt, ...)
210 {
211     char buf1[1024];
212     va_list ap;
213
214     va_start(ap, fmt);
215     if (strchr(buf, '?'))
216         av_strlcat(buf, "&", buf_size);
217     else
218         av_strlcat(buf, "?", buf_size);
219     vsnprintf(buf1, sizeof(buf1), fmt, ap);
220     av_strlcat(buf, buf1, buf_size);
221     va_end(ap);
222 }
223
224 static void build_udp_url(RTPContext *s,
225                           char *buf, int buf_size,
226                           const char *hostname,
227                           int port, int local_port,
228                           int dscp,
229                           const char *include_sources,
230                           const char *exclude_sources)
231 {
232     ff_url_join(buf, buf_size, "udp", NULL, hostname, port, NULL);
233     if (local_port >= 0)
234         url_add_option(buf, buf_size, "localport=%d", local_port);
235     if (s->ttl >= 0)
236         url_add_option(buf, buf_size, "ttl=%d", s->ttl);
237     if (s->buffer_size >= 0)
238         url_add_option(buf, buf_size, "buffer_size=%d", s->buffer_size);
239     if (s->pkt_size >= 0)
240         url_add_option(buf, buf_size, "pkt_size=%d", s->pkt_size);
241     if (s->connect)
242         url_add_option(buf, buf_size, "connect=1");
243     if (dscp >= 0)
244         url_add_option(buf, buf_size, "dscp=%d", dscp);
245     url_add_option(buf, buf_size, "fifo_size=0");
246     if (include_sources && include_sources[0])
247         url_add_option(buf, buf_size, "sources=%s", include_sources);
248     if (exclude_sources && exclude_sources[0])
249         url_add_option(buf, buf_size, "block=%s", exclude_sources);
250 }
251
252 static void rtp_parse_addr_list(URLContext *h, char *buf,
253                                 struct sockaddr_storage ***address_list_ptr,
254                                 int *address_list_size_ptr)
255 {
256     struct addrinfo *ai = NULL;
257     struct sockaddr_storage *source_addr;
258     char tmp = '\0', *p = buf, *next;
259
260     /* Resolve all of the IPs */
261
262     while (p && p[0]) {
263         next = strchr(p, ',');
264
265         if (next) {
266             tmp = *next;
267             *next = '\0';
268         }
269
270         ai = rtp_resolve_host(p, 0, SOCK_DGRAM, AF_UNSPEC, 0);
271         if (ai) {
272             source_addr = av_mallocz(sizeof(struct sockaddr_storage));
273             if (!source_addr) {
274                 freeaddrinfo(ai);
275                 break;
276             }
277
278             memcpy(source_addr, ai->ai_addr, ai->ai_addrlen);
279             freeaddrinfo(ai);
280             dynarray_add(address_list_ptr, address_list_size_ptr, source_addr);
281         } else {
282             av_log(h, AV_LOG_WARNING, "Unable to resolve %s\n", p);
283         }
284
285         if (next) {
286             *next = tmp;
287             p = next + 1;
288         } else {
289             p = NULL;
290         }
291     }
292 }
293
294 /**
295  * url syntax: rtp://host:port[?option=val...]
296  * option: 'ttl=n'            : set the ttl value (for multicast only)
297  *         'rtcpport=n'       : set the remote rtcp port to n
298  *         'localrtpport=n'   : set the local rtp port to n
299  *         'localrtcpport=n'  : set the local rtcp port to n
300  *         'pkt_size=n'       : set max packet size
301  *         'connect=0/1'      : do a connect() on the UDP socket
302  *         'sources=ip[,ip]'  : list allowed source IP addresses
303  *         'block=ip[,ip]'    : list disallowed source IP addresses
304  *         'write_to_source=0/1' : send packets to the source address of the latest received packet
305  *         'dscp=n'           : set DSCP value to n (QoS)
306  * deprecated option:
307  *         'localport=n'      : set the local port to n
308  *
309  * if rtcpport isn't set the rtcp port will be the rtp port + 1
310  * if local rtp port isn't set any available port will be used for the local
311  * rtp and rtcp ports
312  * if the local rtcp port is not set it will be the local rtp port + 1
313  */
314
315 static int rtp_open(URLContext *h, const char *uri, int flags)
316 {
317     RTPContext *s = h->priv_data;
318     int rtp_port;
319     int dscp;
320     char hostname[256], include_sources[1024] = "", exclude_sources[1024] = "";
321     char *sources = include_sources, *block = exclude_sources;
322     char buf[1024];
323     char path[1024];
324     const char *p;
325     int i, max_retry_count = 3;
326
327     av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &rtp_port,
328                  path, sizeof(path), uri);
329     /* extract parameters */
330     dscp = -1;
331     if (s->rtcp_port < 0)
332         s->rtcp_port = rtp_port + 1;
333
334     p = strchr(uri, '?');
335     if (p) {
336         if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
337             s->ttl = strtol(buf, NULL, 10);
338         }
339         if (av_find_info_tag(buf, sizeof(buf), "rtcpport", p)) {
340             s->rtcp_port = strtol(buf, NULL, 10);
341         }
342         if (av_find_info_tag(buf, sizeof(buf), "localport", p)) {
343             s->local_rtpport = strtol(buf, NULL, 10);
344         }
345         if (av_find_info_tag(buf, sizeof(buf), "localrtpport", p)) {
346             s->local_rtpport = strtol(buf, NULL, 10);
347         }
348         if (av_find_info_tag(buf, sizeof(buf), "localrtcpport", p)) {
349             s->local_rtcpport = strtol(buf, NULL, 10);
350         }
351         if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
352             s->pkt_size = strtol(buf, NULL, 10);
353         }
354         if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
355             s->connect = strtol(buf, NULL, 10);
356         }
357         if (av_find_info_tag(buf, sizeof(buf), "write_to_source", p)) {
358             s->write_to_source = strtol(buf, NULL, 10);
359         }
360         if (av_find_info_tag(buf, sizeof(buf), "dscp", p)) {
361             dscp = strtol(buf, NULL, 10);
362         }
363         if (av_find_info_tag(buf, sizeof(buf), "sources", p)) {
364             av_strlcpy(include_sources, buf, sizeof(include_sources));
365
366             rtp_parse_addr_list(h, buf, &s->ssm_include_addrs, &s->nb_ssm_include_addrs);
367         } else {
368             rtp_parse_addr_list(h, s->sources, &s->ssm_include_addrs, &s->nb_ssm_include_addrs);
369             sources = s->sources;
370         }
371         if (av_find_info_tag(buf, sizeof(buf), "block", p)) {
372             av_strlcpy(exclude_sources, buf, sizeof(exclude_sources));
373             rtp_parse_addr_list(h, buf, &s->ssm_exclude_addrs, &s->nb_ssm_exclude_addrs);
374         } else {
375             rtp_parse_addr_list(h, s->block, &s->ssm_exclude_addrs, &s->nb_ssm_exclude_addrs);
376             block = s->block;
377         }
378     }
379
380     for (i = 0; i < max_retry_count; i++) {
381         build_udp_url(s, buf, sizeof(buf),
382                       hostname, rtp_port, s->local_rtpport,
383                       dscp, sources, block);
384         if (ffurl_open(&s->rtp_hd, buf, flags, &h->interrupt_callback, NULL) < 0)
385             goto fail;
386         s->local_rtpport = ff_udp_get_local_port(s->rtp_hd);
387         if(s->local_rtpport == 65535) {
388             s->local_rtpport = -1;
389             continue;
390         }
391         if (s->local_rtcpport < 0) {
392             s->local_rtcpport = s->local_rtpport + 1;
393             build_udp_url(s, buf, sizeof(buf),
394                           hostname, s->rtcp_port, s->local_rtcpport,
395                           dscp, sources, block);
396             if (ffurl_open(&s->rtcp_hd, buf, flags, &h->interrupt_callback, NULL) < 0) {
397                 s->local_rtpport = s->local_rtcpport = -1;
398                 continue;
399             }
400             break;
401         }
402         build_udp_url(s, buf, sizeof(buf),
403                       hostname, s->rtcp_port, s->local_rtcpport,
404                       dscp, sources, block);
405         if (ffurl_open(&s->rtcp_hd, buf, flags, &h->interrupt_callback, NULL) < 0)
406             goto fail;
407         break;
408     }
409
410     /* just to ease handle access. XXX: need to suppress direct handle
411        access */
412     s->rtp_fd = ffurl_get_file_handle(s->rtp_hd);
413     s->rtcp_fd = ffurl_get_file_handle(s->rtcp_hd);
414
415     h->max_packet_size = s->rtp_hd->max_packet_size;
416     h->is_streamed = 1;
417     return 0;
418
419  fail:
420     if (s->rtp_hd)
421         ffurl_close(s->rtp_hd);
422     if (s->rtcp_hd)
423         ffurl_close(s->rtcp_hd);
424     return AVERROR(EIO);
425 }
426
427 static int rtp_read(URLContext *h, uint8_t *buf, int size)
428 {
429     RTPContext *s = h->priv_data;
430     int len, n, i;
431     struct pollfd p[2] = {{s->rtp_fd, POLLIN, 0}, {s->rtcp_fd, POLLIN, 0}};
432     int poll_delay = h->flags & AVIO_FLAG_NONBLOCK ? 0 : 100;
433     struct sockaddr_storage *addrs[2] = { &s->last_rtp_source, &s->last_rtcp_source };
434     socklen_t *addr_lens[2] = { &s->last_rtp_source_len, &s->last_rtcp_source_len };
435
436     for(;;) {
437         if (ff_check_interrupt(&h->interrupt_callback))
438             return AVERROR_EXIT;
439         n = poll(p, 2, poll_delay);
440         if (n > 0) {
441             /* first try RTCP, then RTP */
442             for (i = 1; i >= 0; i--) {
443                 if (!(p[i].revents & POLLIN))
444                     continue;
445                 *addr_lens[i] = sizeof(*addrs[i]);
446                 len = recvfrom(p[i].fd, buf, size, 0,
447                                 (struct sockaddr *)addrs[i], addr_lens[i]);
448                 if (len < 0) {
449                     if (ff_neterrno() == AVERROR(EAGAIN) ||
450                         ff_neterrno() == AVERROR(EINTR))
451                         continue;
452                     return AVERROR(EIO);
453                 }
454                 if (rtp_check_source_lists(s, addrs[i]))
455                     continue;
456                 return len;
457             }
458         } else if (n < 0) {
459             if (ff_neterrno() == AVERROR(EINTR))
460                 continue;
461             return AVERROR(EIO);
462         }
463         if (h->flags & AVIO_FLAG_NONBLOCK)
464             return AVERROR(EAGAIN);
465     }
466     return len;
467 }
468
469 static int rtp_write(URLContext *h, const uint8_t *buf, int size)
470 {
471     RTPContext *s = h->priv_data;
472     int ret;
473     URLContext *hd;
474
475     if (size < 2)
476         return AVERROR(EINVAL);
477
478     if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
479         av_log(h, AV_LOG_WARNING, "Data doesn't look like RTP packets, "
480                                   "make sure the RTP muxer is used\n");
481
482     if (s->write_to_source) {
483         int fd;
484         struct sockaddr_storage *source, temp_source;
485         socklen_t *source_len, temp_len;
486         if (!s->last_rtp_source.ss_family && !s->last_rtcp_source.ss_family) {
487             av_log(h, AV_LOG_ERROR,
488                    "Unable to send packet to source, no packets received yet\n");
489             // Intentionally not returning an error here
490             return size;
491         }
492
493         if (RTP_PT_IS_RTCP(buf[1])) {
494             fd = s->rtcp_fd;
495             source     = &s->last_rtcp_source;
496             source_len = &s->last_rtcp_source_len;
497         } else {
498             fd = s->rtp_fd;
499             source     = &s->last_rtp_source;
500             source_len = &s->last_rtp_source_len;
501         }
502         if (!source->ss_family) {
503             source      = &temp_source;
504             source_len  = &temp_len;
505             if (RTP_PT_IS_RTCP(buf[1])) {
506                 temp_source = s->last_rtp_source;
507                 temp_len    = s->last_rtp_source_len;
508                 set_port(source, get_port(source) + 1);
509                 av_log(h, AV_LOG_INFO,
510                        "Not received any RTCP packets yet, inferring peer port "
511                        "from the RTP port\n");
512             } else {
513                 temp_source = s->last_rtcp_source;
514                 temp_len    = s->last_rtcp_source_len;
515                 set_port(source, get_port(source) - 1);
516                 av_log(h, AV_LOG_INFO,
517                        "Not received any RTP packets yet, inferring peer port "
518                        "from the RTCP port\n");
519             }
520         }
521
522         if (!(h->flags & AVIO_FLAG_NONBLOCK)) {
523             ret = ff_network_wait_fd(fd, 1);
524             if (ret < 0)
525                 return ret;
526         }
527         ret = sendto(fd, buf, size, 0, (struct sockaddr *) source,
528                      *source_len);
529
530         return ret < 0 ? ff_neterrno() : ret;
531     }
532
533     if (RTP_PT_IS_RTCP(buf[1])) {
534         /* RTCP payload type */
535         hd = s->rtcp_hd;
536     } else {
537         /* RTP payload type */
538         hd = s->rtp_hd;
539     }
540
541     ret = ffurl_write(hd, buf, size);
542     return ret;
543 }
544
545 static int rtp_close(URLContext *h)
546 {
547     RTPContext *s = h->priv_data;
548     int i;
549
550     for (i = 0; i < s->nb_ssm_include_addrs; i++)
551         av_freep(&s->ssm_include_addrs[i]);
552     av_freep(&s->ssm_include_addrs);
553     for (i = 0; i < s->nb_ssm_exclude_addrs; i++)
554         av_freep(&s->ssm_exclude_addrs[i]);
555     av_freep(&s->ssm_exclude_addrs);
556
557     ffurl_close(s->rtp_hd);
558     ffurl_close(s->rtcp_hd);
559     return 0;
560 }
561
562 /**
563  * Return the local rtp port used by the RTP connection
564  * @param h media file context
565  * @return the local port number
566  */
567
568 int ff_rtp_get_local_rtp_port(URLContext *h)
569 {
570     RTPContext *s = h->priv_data;
571     return ff_udp_get_local_port(s->rtp_hd);
572 }
573
574 /**
575  * Return the local rtcp port used by the RTP connection
576  * @param h media file context
577  * @return the local port number
578  */
579
580 int ff_rtp_get_local_rtcp_port(URLContext *h)
581 {
582     RTPContext *s = h->priv_data;
583     return ff_udp_get_local_port(s->rtcp_hd);
584 }
585
586 static int rtp_get_file_handle(URLContext *h)
587 {
588     RTPContext *s = h->priv_data;
589     return s->rtp_fd;
590 }
591
592 static int rtp_get_multi_file_handle(URLContext *h, int **handles,
593                                      int *numhandles)
594 {
595     RTPContext *s = h->priv_data;
596     int *hs       = *handles = av_malloc(sizeof(**handles) * 2);
597     if (!hs)
598         return AVERROR(ENOMEM);
599     hs[0] = s->rtp_fd;
600     hs[1] = s->rtcp_fd;
601     *numhandles = 2;
602     return 0;
603 }
604
605 URLProtocol ff_rtp_protocol = {
606     .name                      = "rtp",
607     .url_open                  = rtp_open,
608     .url_read                  = rtp_read,
609     .url_write                 = rtp_write,
610     .url_close                 = rtp_close,
611     .url_get_file_handle       = rtp_get_file_handle,
612     .url_get_multi_file_handle = rtp_get_multi_file_handle,
613     .priv_data_size            = sizeof(RTPContext),
614     .flags                     = URL_PROTOCOL_FLAG_NETWORK,
615     .priv_data_class           = &rtp_class,
616 };