Libav
rtpproto.c
Go to the documentation of this file.
1 /*
2  * RTP network protocol
3  * Copyright (c) 2002 Fabrice Bellard
4  *
5  * This file is part of Libav.
6  *
7  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
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;
51  struct sockaddr_storage last_rtp_source, last_rtcp_source;
53  int ttl;
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 
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);
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 
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  const char *include_sources,
229  const char *exclude_sources)
230 {
231  ff_url_join(buf, buf_size, "udp", NULL, hostname, port, NULL);
232  if (local_port >= 0)
233  url_add_option(buf, buf_size, "localport=%d", local_port);
234  if (s->ttl >= 0)
235  url_add_option(buf, buf_size, "ttl=%d", s->ttl);
236  if (s->buffer_size >= 0)
237  url_add_option(buf, buf_size, "buffer_size=%d", s->buffer_size);
238  if (s->pkt_size >= 0)
239  url_add_option(buf, buf_size, "pkt_size=%d", s->pkt_size);
240  if (s->connect)
241  url_add_option(buf, buf_size, "connect=1");
242  if (include_sources && include_sources[0])
243  url_add_option(buf, buf_size, "sources=%s", include_sources);
244  if (exclude_sources && exclude_sources[0])
245  url_add_option(buf, buf_size, "block=%s", exclude_sources);
246 }
247 
248 static void rtp_parse_addr_list(URLContext *h, char *buf,
249  struct sockaddr_storage ***address_list_ptr,
250  int *address_list_size_ptr)
251 {
252  struct addrinfo *ai = NULL;
253  struct sockaddr_storage *source_addr;
254  char tmp = '\0', *p = buf, *next;
255 
256  /* Resolve all of the IPs */
257 
258  while (p && p[0]) {
259  next = strchr(p, ',');
260 
261  if (next) {
262  tmp = *next;
263  *next = '\0';
264  }
265 
266  ai = rtp_resolve_host(p, 0, SOCK_DGRAM, AF_UNSPEC, 0);
267  if (ai) {
268  source_addr = av_mallocz(sizeof(struct sockaddr_storage));
269  if (!source_addr) {
270  freeaddrinfo(ai);
271  break;
272  }
273 
274  memcpy(source_addr, ai->ai_addr, ai->ai_addrlen);
275  freeaddrinfo(ai);
276  dynarray_add(address_list_ptr, address_list_size_ptr, source_addr);
277  } else {
278  av_log(h, AV_LOG_WARNING, "Unable to resolve %s\n", p);
279  }
280 
281  if (next) {
282  *next = tmp;
283  p = next + 1;
284  } else {
285  p = NULL;
286  }
287  }
288 }
289 
310 static int rtp_open(URLContext *h, const char *uri, int flags)
311 {
312  RTPContext *s = h->priv_data;
313  int rtp_port;
314  char hostname[256], include_sources[1024] = "", exclude_sources[1024] = "";
315  char *sources = include_sources, *block = exclude_sources;
316  char buf[1024];
317  char path[1024];
318  const char *p;
319 
320  av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &rtp_port,
321  path, sizeof(path), uri);
322  /* extract parameters */
323  if (s->rtcp_port < 0)
324  s->rtcp_port = rtp_port + 1;
325 
326  p = strchr(uri, '?');
327  if (p) {
328  if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
329  s->ttl = strtol(buf, NULL, 10);
330  }
331  if (av_find_info_tag(buf, sizeof(buf), "rtcpport", p)) {
332  s->rtcp_port = strtol(buf, NULL, 10);
333  }
334  if (av_find_info_tag(buf, sizeof(buf), "localport", p)) {
335  s->local_rtpport = strtol(buf, NULL, 10);
336  }
337  if (av_find_info_tag(buf, sizeof(buf), "localrtpport", p)) {
338  s->local_rtpport = strtol(buf, NULL, 10);
339  }
340  if (av_find_info_tag(buf, sizeof(buf), "localrtcpport", p)) {
341  s->local_rtcpport = strtol(buf, NULL, 10);
342  }
343  if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
344  s->pkt_size = strtol(buf, NULL, 10);
345  }
346  if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
347  s->connect = strtol(buf, NULL, 10);
348  }
349  if (av_find_info_tag(buf, sizeof(buf), "write_to_source", p)) {
350  s->write_to_source = strtol(buf, NULL, 10);
351  }
352  if (av_find_info_tag(buf, sizeof(buf), "sources", p)) {
353  av_strlcpy(include_sources, buf, sizeof(include_sources));
354 
356  } else {
358  sources = s->sources;
359  }
360  if (av_find_info_tag(buf, sizeof(buf), "block", p)) {
361  av_strlcpy(exclude_sources, buf, sizeof(exclude_sources));
363  } else {
365  block = s->block;
366  }
367  }
368 
369  build_udp_url(s, buf, sizeof(buf),
370  hostname, rtp_port, s->local_rtpport, sources, block);
371  if (ffurl_open(&s->rtp_hd, buf, flags, &h->interrupt_callback, NULL,
372  h->protocols, h) < 0)
373  goto fail;
374  if (s->local_rtpport >= 0 && s->local_rtcpport < 0)
376 
377  build_udp_url(s, buf, sizeof(buf),
378  hostname, s->rtcp_port, s->local_rtcpport, sources, block);
379  if (ffurl_open(&s->rtcp_hd, buf, flags, &h->interrupt_callback, NULL,
380  h->protocols, h) < 0)
381  goto fail;
382 
383  /* just to ease handle access. XXX: need to suppress direct handle
384  access */
387 
389  h->is_streamed = 1;
390  return 0;
391 
392  fail:
393  if (s->rtp_hd)
394  ffurl_close(s->rtp_hd);
395  if (s->rtcp_hd)
396  ffurl_close(s->rtcp_hd);
397  return AVERROR(EIO);
398 }
399 
400 static int rtp_read(URLContext *h, uint8_t *buf, int size)
401 {
402  RTPContext *s = h->priv_data;
403  int len, n, i;
404  struct pollfd p[2] = {{s->rtp_fd, POLLIN, 0}, {s->rtcp_fd, POLLIN, 0}};
405  int poll_delay = h->flags & AVIO_FLAG_NONBLOCK ? 0 : 100;
406  struct sockaddr_storage *addrs[2] = { &s->last_rtp_source, &s->last_rtcp_source };
407  socklen_t *addr_lens[2] = { &s->last_rtp_source_len, &s->last_rtcp_source_len };
408 
409  for(;;) {
411  return AVERROR_EXIT;
412  n = poll(p, 2, poll_delay);
413  if (n > 0) {
414  /* first try RTCP, then RTP */
415  for (i = 1; i >= 0; i--) {
416  if (!(p[i].revents & POLLIN))
417  continue;
418  *addr_lens[i] = sizeof(*addrs[i]);
419  len = recvfrom(p[i].fd, buf, size, 0,
420  (struct sockaddr *)addrs[i], addr_lens[i]);
421  if (len < 0) {
422  if (ff_neterrno() == AVERROR(EAGAIN) ||
423  ff_neterrno() == AVERROR(EINTR))
424  continue;
425  return AVERROR(EIO);
426  }
427  if (rtp_check_source_lists(s, addrs[i]))
428  continue;
429  return len;
430  }
431  } else if (n < 0) {
432  if (ff_neterrno() == AVERROR(EINTR))
433  continue;
434  return AVERROR(EIO);
435  }
436  if (h->flags & AVIO_FLAG_NONBLOCK)
437  return AVERROR(EAGAIN);
438  }
439  return len;
440 }
441 
442 static int rtp_write(URLContext *h, const uint8_t *buf, int size)
443 {
444  RTPContext *s = h->priv_data;
445  int ret;
446  URLContext *hd;
447 
448  if (size < 2)
449  return AVERROR(EINVAL);
450 
451  if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
452  av_log(h, AV_LOG_WARNING, "Data doesn't look like RTP packets, "
453  "make sure the RTP muxer is used\n");
454 
455  if (s->write_to_source) {
456  int fd;
457  struct sockaddr_storage *source, temp_source;
458  socklen_t *source_len, temp_len;
459  if (!s->last_rtp_source.ss_family && !s->last_rtcp_source.ss_family) {
460  av_log(h, AV_LOG_ERROR,
461  "Unable to send packet to source, no packets received yet\n");
462  // Intentionally not returning an error here
463  return size;
464  }
465 
466  if (RTP_PT_IS_RTCP(buf[1])) {
467  fd = s->rtcp_fd;
468  source = &s->last_rtcp_source;
469  source_len = &s->last_rtcp_source_len;
470  } else {
471  fd = s->rtp_fd;
472  source = &s->last_rtp_source;
473  source_len = &s->last_rtp_source_len;
474  }
475  if (!source->ss_family) {
476  source = &temp_source;
477  source_len = &temp_len;
478  if (RTP_PT_IS_RTCP(buf[1])) {
479  temp_source = s->last_rtp_source;
480  temp_len = s->last_rtp_source_len;
481  set_port(source, get_port(source) + 1);
482  av_log(h, AV_LOG_INFO,
483  "Not received any RTCP packets yet, inferring peer port "
484  "from the RTP port\n");
485  } else {
486  temp_source = s->last_rtcp_source;
487  temp_len = s->last_rtcp_source_len;
488  set_port(source, get_port(source) - 1);
489  av_log(h, AV_LOG_INFO,
490  "Not received any RTP packets yet, inferring peer port "
491  "from the RTCP port\n");
492  }
493  }
494 
495  if (!(h->flags & AVIO_FLAG_NONBLOCK)) {
496  ret = ff_network_wait_fd(fd, 1);
497  if (ret < 0)
498  return ret;
499  }
500  ret = sendto(fd, buf, size, 0, (struct sockaddr *) source,
501  *source_len);
502 
503  return ret < 0 ? ff_neterrno() : ret;
504  }
505 
506  if (RTP_PT_IS_RTCP(buf[1])) {
507  /* RTCP payload type */
508  hd = s->rtcp_hd;
509  } else {
510  /* RTP payload type */
511  hd = s->rtp_hd;
512  }
513 
514  ret = ffurl_write(hd, buf, size);
515  return ret;
516 }
517 
518 static int rtp_close(URLContext *h)
519 {
520  RTPContext *s = h->priv_data;
521  int i;
522 
523  for (i = 0; i < s->nb_ssm_include_addrs; i++)
524  av_free(s->ssm_include_addrs[i]);
526  for (i = 0; i < s->nb_ssm_exclude_addrs; i++)
527  av_free(s->ssm_exclude_addrs[i]);
529 
530  ffurl_close(s->rtp_hd);
531  ffurl_close(s->rtcp_hd);
532  return 0;
533 }
534 
542 {
543  RTPContext *s = h->priv_data;
544  return ff_udp_get_local_port(s->rtp_hd);
545 }
546 
554 {
555  RTPContext *s = h->priv_data;
556  return ff_udp_get_local_port(s->rtcp_hd);
557 }
558 
560 {
561  RTPContext *s = h->priv_data;
562  return s->rtp_fd;
563 }
564 
565 static int rtp_get_multi_file_handle(URLContext *h, int **handles,
566  int *numhandles)
567 {
568  RTPContext *s = h->priv_data;
569  int *hs = *handles = av_malloc(sizeof(**handles) * 2);
570  if (!hs)
571  return AVERROR(ENOMEM);
572  hs[0] = s->rtp_fd;
573  hs[1] = s->rtcp_fd;
574  *numhandles = 2;
575  return 0;
576 }
577 
579  .name = "rtp",
580  .url_open = rtp_open,
581  .url_read = rtp_read,
582  .url_write = rtp_write,
583  .url_close = rtp_close,
584  .url_get_file_handle = rtp_get_file_handle,
585  .url_get_multi_file_handle = rtp_get_multi_file_handle,
586  .priv_data_size = sizeof(RTPContext),
588  .priv_data_class = &rtp_class,
589 };
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
Definition: utils.c:2870
int rtcp_port
Definition: rtpproto.c:55
int buffer_size
Definition: rtpproto.c:54
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:62
int ff_rtp_get_local_rtp_port(URLContext *h)
Return the local rtp port used by the RTP connection.
Definition: rtpproto.c:541
int size
#define URL_PROTOCOL_FLAG_NETWORK
Definition: url.h:34
AVOption.
Definition: opt.h:234
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:130
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
Definition: avio.c:257
int is_streamed
true if streamed (no seek possible), default = false
Definition: url.h:49
AVIOInterruptCB interrupt_callback
Definition: url.h:51
#define RTP_VERSION
Definition: rtp.h:78
static int rtp_check_source_lists(RTPContext *s, struct sockaddr_storage *source_addr_ptr)
Definition: rtpproto.c:185
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
static void rtp_parse_addr_list(URLContext *h, char *buf, struct sockaddr_storage ***address_list_ptr, int *address_list_size_ptr)
Definition: rtpproto.c:248
char * block
Definition: rtpproto.c:59
int flags
Definition: url.h:47
#define freeaddrinfo
Definition: network.h:187
const URLProtocol ff_rtp_protocol
Definition: rtpproto.c:578
URLContext * rtcp_hd
Definition: rtpproto.c:47
static int compare_addr(const struct sockaddr_storage *a, const struct sockaddr_storage *b)
Definition: rtpproto.c:144
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:202
static int rtp_write(URLContext *h, const uint8_t *buf, int size)
Definition: rtpproto.c:442
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:39
static int rtp_close(URLContext *h)
Definition: rtpproto.c:518
uint8_t
AVOptions.
#define D
Definition: rtpproto.c:63
miscellaneous OS support macros and functions.
socklen_t last_rtp_source_len
Definition: rtpproto.c:52
static int get_port(const struct sockaddr_storage *ss)
Definition: rtpproto.c:164
int ff_udp_get_local_port(URLContext *h)
Return the local port used by the UDP connection.
Definition: udp.c:401
uint16_t ss_family
Definition: network.h:93
int pkt_size
Definition: rtpproto.c:57
#define b
Definition: input.c:52
static int flags
Definition: log.c:50
struct sockaddr_storage ** ssm_include_addrs
Definition: rtpproto.c:49
int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
Attempt to find a specific tag in a URL.
Definition: parseutils.c:619
int ffurl_open(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const URLProtocol **protocols, URLContext *parent)
Create an URLContext for accessing to the resource indicated by url, and open it. ...
Definition: avio.c:175
URLContext * rtp_hd
Definition: rtpproto.c:47
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:124
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
Definition: mem.c:190
int ff_udp_set_remote_url(URLContext *h, const char *uri)
If no filename is given to av_open_input_file because you want to get the local port first...
Definition: udp.c:362
#define AVERROR(e)
Definition: error.h:43
static int rtp_read(URLContext *h, uint8_t *buf, int size)
Definition: rtpproto.c:400
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition: avstring.c:81
#define fail()
Definition: checkasm.h:80
int ai_addrlen
Definition: network.h:111
#define dynarray_add(tab, nb_ptr, elem)
Definition: internal.h:134
static const AVClass rtp_class
Definition: rtpproto.c:79
struct sockaddr_storage last_rtp_source last_rtcp_source
Definition: rtpproto.c:51
#define ff_neterrno()
Definition: network.h:63
static int rtp_open(URLContext *h, const char *uri, int flags)
url syntax: rtp://host:port[?option=val...] option: &#39;ttl=n&#39; : set the ttl value (for multicast only) ...
Definition: rtpproto.c:310
static const AVOption options[]
Definition: rtpproto.c:65
int rtcp_fd
Definition: rtpproto.c:48
static int rtp_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
Definition: rtpproto.c:565
int rtp_fd
Definition: rtpproto.c:48
int ffurl_get_file_handle(URLContext *h)
Return the file descriptor associated with this URL.
Definition: avio.c:345
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:52
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
int local_rtcpport
Definition: rtpproto.c:55
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
Definition: url.c:36
NULL
Definition: eval.c:55
#define AV_LOG_INFO
Standard information.
Definition: log.h:135
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
Definition: avio.c:374
#define AVIO_FLAG_NONBLOCK
Use non-blocking mode.
Definition: avio.h:387
av_default_item_name
Definition: dnxhdenc.c:55
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
socklen_t last_rtcp_source_len
Definition: rtpproto.c:52
Definition: url.h:38
Describe the class of an AVClass context structure.
Definition: log.h:34
static av_printf_format(3, 4)
add option to url of the form: "http://host:port/path?option1=val1&option2=val2...
Definition: rtpproto.c:209
void * priv_data
Definition: url.h:45
#define gai_strerror
Definition: network.h:194
misc parsing utilities
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
Definition: avstring.c:91
const char * name
Definition: url.h:56
int ai_socktype
Definition: network.h:109
#define RTP_PT_IS_RTCP(x)
Definition: rtp.h:110
static void set_port(struct sockaddr_storage *ss, int port)
Definition: rtpproto.c:175
int ffurl_close(URLContext *h)
Close the resource accessed by the URLContext h, and free the memory used by it.
Definition: avio.c:280
char * sources
Definition: rtpproto.c:58
static struct addrinfo * rtp_resolve_host(const char *hostname, int port, int type, int family, int flags)
Definition: rtpproto.c:125
int nb_ssm_include_addrs
Definition: rtpproto.c:48
#define getaddrinfo
Definition: network.h:186
const struct URLProtocol ** protocols
A NULL-terminated list of protocols usable by the child contexts.
Definition: url.h:44
Main libavformat public API header.
struct sockaddr_storage ** ssm_exclude_addrs
Definition: rtpproto.c:49
static int rtp_get_file_handle(URLContext *h)
Definition: rtpproto.c:559
static void build_udp_url(RTPContext *s, char *buf, int buf_size, const char *hostname, int port, int local_port, const char *include_sources, const char *exclude_sources)
Definition: rtpproto.c:224
int ff_rtp_get_local_rtcp_port(URLContext *h)
Return the local rtcp port used by the RTP connection.
Definition: rtpproto.c:553
int write_to_source
Definition: rtpproto.c:50
int len
int nb_ssm_exclude_addrs
Definition: rtpproto.c:48
int local_rtpport
Definition: rtpproto.c:55
static uint8_t tmp[8]
Definition: des.c:38
int ttl
Definition: rtpproto.c:53
#define OFFSET(x)
Definition: rtpproto.c:62
int ai_flags
Definition: network.h:107
int max_packet_size
if non zero, the stream is packetized with this max packet size
Definition: url.h:48
int ff_network_wait_fd(int fd, int write)
Definition: network.c:68
unbuffered private I/O API
struct sockaddr * ai_addr
Definition: network.h:112
int ff_rtp_set_remote_url(URLContext *h, const char *uri)
If no filename is given to av_open_input_file because you want to get the local port first...
Definition: rtpproto.c:96
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:211
int connect
Definition: rtpproto.c:56
#define E
Definition: rtpproto.c:64
int ai_family
Definition: network.h:108