FFmpeg
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 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/mem.h"
28 #include "libavutil/parseutils.h"
29 #include "libavutil/avstring.h"
30 #include "libavutil/opt.h"
31 #include "avformat.h"
32 #include "internal.h"
33 #include "rtp.h"
34 #include "rtpproto.h"
35 #include "url.h"
36 #include "ip.h"
37 
38 #include <stdarg.h>
39 #include "network.h"
40 #include "os_support.h"
41 #include <fcntl.h>
42 #if HAVE_POLL_H
43 #include <poll.h>
44 #endif
45 
46 typedef struct RTPContext {
47  const AVClass *class;
52  struct sockaddr_storage last_rtp_source, last_rtcp_source;
54  int ttl;
57  int connect;
58  int pkt_size;
59  int dscp;
60  char *sources;
61  char *block;
64  char *localaddr;
65 } RTPContext;
66 
67 #define OFFSET(x) offsetof(RTPContext, x)
68 #define D AV_OPT_FLAG_DECODING_PARAM
69 #define E AV_OPT_FLAG_ENCODING_PARAM
70 #define DEPR AV_OPT_FLAG_DEPRECATED
71 static const AVOption options[] = {
72  { "ttl", "Time to live (multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, .flags = D|E },
73  { "buffer_size", "Send/Receive buffer size (in bytes)", OFFSET(buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
74  { "rtcp_port", "Custom rtcp port", OFFSET(rtcp_port), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
75  { "rtcpport", "Custom rtcp port", OFFSET(rtcp_port), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
76  { "local_rtpport", "Local rtp port", OFFSET(local_rtpport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
77  { "localrtpport", "Local rtp port", OFFSET(local_rtpport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
78  { "localport", "Local rtp port", OFFSET(local_rtpport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E|DEPR },
79  { "local_rtcpport", "Local rtcp port", OFFSET(local_rtcpport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
80  { "localrtcpport", "Local rtcp port", OFFSET(local_rtcpport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
81  { "connect", "Connect socket", OFFSET(connect), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = D|E },
82  { "write_to_source", "Send packets to the source address of the latest received packet", OFFSET(write_to_source), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = D|E },
83  { "pkt_size", "Maximum packet size", OFFSET(pkt_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
84  { "dscp", "DSCP class", OFFSET(dscp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
85  { "timeout", "set timeout (in microseconds) of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
86  { "sources", "Source list", OFFSET(sources), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E },
87  { "block", "Block list", OFFSET(block), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E },
88  { "fec", "FEC", OFFSET(fec_options_str), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = E },
89  { "localaddr", "Local address", OFFSET(localaddr), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E },
90  { NULL }
91 };
92 
93 static const AVClass rtp_class = {
94  .class_name = "rtp",
95  .item_name = av_default_item_name,
96  .option = options,
97  .version = LIBAVUTIL_VERSION_INT,
98 };
99 
100 /**
101  * If no filename is given to av_open_input_file because you want to
102  * get the local port first, then you must call this function to set
103  * the remote server address.
104  *
105  * @param h media file context
106  * @param uri of the remote server
107  * @return zero if no error.
108  */
109 
110 int ff_rtp_set_remote_url(URLContext *h, const char *uri)
111 {
112  RTPContext *s = h->priv_data;
113  char hostname[256];
114  int port, rtcp_port;
115  const char *p;
116 
117  char buf[1024];
118  char path[1024];
119 
120  av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port,
121  path, sizeof(path), uri);
122  rtcp_port = port + 1;
123 
124  p = strchr(uri, '?');
125  if (p) {
126  if (av_find_info_tag(buf, sizeof(buf), "rtcpport", p)) {
127  rtcp_port = strtol(buf, NULL, 10);
128  }
129  }
130 
131  ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, port, "%s", path);
132  ff_udp_set_remote_url(s->rtp_hd, buf);
133 
134  ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, rtcp_port, "%s", path);
135  ff_udp_set_remote_url(s->rtcp_hd, buf);
136  return 0;
137 }
138 
139 static int get_port(const struct sockaddr_storage *ss)
140 {
141  if (ss->ss_family == AF_INET)
142  return ntohs(((const struct sockaddr_in *)ss)->sin_port);
143 #if HAVE_STRUCT_SOCKADDR_IN6
144  if (ss->ss_family == AF_INET6)
145  return ntohs(((const struct sockaddr_in6 *)ss)->sin6_port);
146 #endif
147  return 0;
148 }
149 
150 static void set_port(struct sockaddr_storage *ss, int port)
151 {
152  if (ss->ss_family == AF_INET)
153  ((struct sockaddr_in *)ss)->sin_port = htons(port);
154 #if HAVE_STRUCT_SOCKADDR_IN6
155  else if (ss->ss_family == AF_INET6)
156  ((struct sockaddr_in6 *)ss)->sin6_port = htons(port);
157 #endif
158 }
159 
160 /**
161  * add option to url of the form:
162  * "http://host:port/path?option1=val1&option2=val2...
163  */
164 
165 static av_printf_format(3, 4) void url_add_option(char *buf, int buf_size, const char *fmt, ...)
166 {
167  char buf1[1024];
168  va_list ap;
169 
170  va_start(ap, fmt);
171  if (strchr(buf, '?'))
172  av_strlcat(buf, "&", buf_size);
173  else
174  av_strlcat(buf, "?", buf_size);
175  vsnprintf(buf1, sizeof(buf1), fmt, ap);
176  av_strlcat(buf, buf1, buf_size);
177  va_end(ap);
178 }
179 
181  char *buf, int buf_size,
182  const char *hostname,
183  const char *localaddr,
184  int port, int local_port,
185  const char *include_sources,
186  const char *exclude_sources)
187 {
188  ff_url_join(buf, buf_size, "udp", NULL, hostname, port, NULL);
189  if (local_port >= 0)
190  url_add_option(buf, buf_size, "localport=%d", local_port);
191  if (s->ttl >= 0)
192  url_add_option(buf, buf_size, "ttl=%d", s->ttl);
193  if (s->buffer_size >= 0)
194  url_add_option(buf, buf_size, "buffer_size=%d", s->buffer_size);
195  if (s->pkt_size >= 0)
196  url_add_option(buf, buf_size, "pkt_size=%d", s->pkt_size);
197  if (s->connect)
198  url_add_option(buf, buf_size, "connect=1");
199  if (s->dscp >= 0)
200  url_add_option(buf, buf_size, "dscp=%d", s->dscp);
201  url_add_option(buf, buf_size, "fifo_size=0");
202  if (include_sources && include_sources[0])
203  url_add_option(buf, buf_size, "sources=%s", include_sources);
204  if (exclude_sources && exclude_sources[0])
205  url_add_option(buf, buf_size, "block=%s", exclude_sources);
206  if (localaddr && localaddr[0])
207  url_add_option(buf, buf_size, "localaddr=%s", localaddr);
208 }
209 
210 /**
211  * url syntax: rtp://host:port[?option=val...]
212  * option: 'ttl=n' : set the ttl value (for multicast only)
213  * 'rtcpport=n' : set the remote rtcp port to n
214  * 'localrtpport=n' : set the local rtp port to n
215  * 'localrtcpport=n' : set the local rtcp port to n
216  * 'pkt_size=n' : set max packet size
217  * 'connect=0/1' : do a connect() on the UDP socket
218  * 'sources=ip[,ip]' : list allowed source IP addresses
219  * 'block=ip[,ip]' : list disallowed source IP addresses
220  * 'write_to_source=0/1' : send packets to the source address of the latest received packet
221  * 'dscp=n' : set DSCP value to n (QoS)
222  * deprecated option:
223  * 'localport=n' : set the local port to n
224  *
225  * if rtcpport isn't set the rtcp port will be the rtp port + 1
226  * if local rtp port isn't set any available port will be used for the local
227  * rtp and rtcp ports
228  * if the local rtcp port is not set it will be the local rtp port + 1
229  */
230 
231 static int rtp_open(URLContext *h, const char *uri, int flags)
232 {
233  RTPContext *s = h->priv_data;
234  AVDictionary *fec_opts = NULL;
235  int rtp_port;
236  char hostname[256];
237  char *fec_protocol = NULL;
238  char buf[1024];
239  char path[1024];
240  const char *p;
241  int i, max_retry_count = 3;
242  int rtcpflags;
243  int ret;
244 
245  av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &rtp_port,
246  path, sizeof(path), uri);
247  /* extract parameters */
248  if (s->rtcp_port < 0)
249  s->rtcp_port = rtp_port + 1;
250 
251  p = strchr(uri, '?');
252  if (p) {
254  if (ret < 0)
255  goto fail;
256  }
257  if (s->sources) {
258  if ((ret = ff_ip_parse_sources(h, s->sources, &s->filters)) < 0)
259  goto fail;
260  }
261  if (s->block) {
262  if ((ret = ff_ip_parse_blocks(h, s->block, &s->filters)) < 0)
263  goto fail;
264  }
265  if (s->rw_timeout >= 0)
266  h->rw_timeout = s->rw_timeout;
267 
268  if (s->fec_options_str) {
269  p = s->fec_options_str;
270 
271  if (!(fec_protocol = av_get_token(&p, "="))) {
272  av_log(h, AV_LOG_ERROR, "Failed to parse the FEC protocol value\n");
273  ret = AVERROR(EINVAL);
274  goto fail;
275  }
276  if (strcmp(fec_protocol, "prompeg")) {
277  av_log(h, AV_LOG_ERROR, "Unsupported FEC protocol %s\n", fec_protocol);
278  ret = AVERROR(EINVAL);
279  goto fail;
280  }
281 
282  p = s->fec_options_str + strlen(fec_protocol);
283  while (*p && *p == '=') p++;
284 
285  if (av_dict_parse_string(&fec_opts, p, "=", ":", 0) < 0) {
286  av_log(h, AV_LOG_ERROR, "Failed to parse the FEC options\n");
287  ret = AVERROR(EINVAL);
288  goto fail;
289  }
290  if (s->ttl > 0) {
291  av_dict_set_int(&fec_opts, "ttl", s->ttl, 0);
292  }
293  }
294 
295  for (i = 0; i < max_retry_count; i++) {
296  const char *sources = s->sources ? s->sources : "";
297  const char *block = s->block ? s->block : "";
298  build_udp_url(s, buf, sizeof(buf),
299  hostname, s->localaddr, rtp_port, s->local_rtpport,
300  sources, block);
301  ret = ffurl_open_whitelist(&s->rtp_hd, buf, flags, &h->interrupt_callback,
302  NULL, h->protocol_whitelist, h->protocol_blacklist, h);
303  if (ret < 0)
304  goto fail;
305  s->local_rtpport = ff_udp_get_local_port(s->rtp_hd);
306  if(s->local_rtpport == 65535) {
307  s->local_rtpport = -1;
308  continue;
309  }
310  rtcpflags = flags | AVIO_FLAG_WRITE;
311  if (s->local_rtcpport < 0) {
312  s->local_rtcpport = s->local_rtpport + 1;
313  build_udp_url(s, buf, sizeof(buf),
314  hostname, s->localaddr, s->rtcp_port, s->local_rtcpport,
315  sources, block);
316  if (ffurl_open_whitelist(&s->rtcp_hd, buf, rtcpflags,
317  &h->interrupt_callback, NULL,
318  h->protocol_whitelist, h->protocol_blacklist, h) < 0) {
319  s->local_rtpport = s->local_rtcpport = -1;
320  continue;
321  }
322  break;
323  }
324  build_udp_url(s, buf, sizeof(buf),
325  hostname, s->localaddr, s->rtcp_port, s->local_rtcpport,
326  sources, block);
327  ret = ffurl_open_whitelist(&s->rtcp_hd, buf, rtcpflags, &h->interrupt_callback,
328  NULL, h->protocol_whitelist, h->protocol_blacklist, h);
329  if (ret < 0)
330  goto fail;
331  break;
332  }
333 
334  s->fec_hd = NULL;
335  if (fec_protocol) {
336  ff_url_join(buf, sizeof(buf), fec_protocol, NULL, hostname, rtp_port, NULL);
337  ret = ffurl_open_whitelist(&s->fec_hd, buf, flags, &h->interrupt_callback,
338  &fec_opts, h->protocol_whitelist, h->protocol_blacklist, h);
339  if (ret < 0)
340  goto fail;
341  }
342 
343  /* just to ease handle access. XXX: need to suppress direct handle
344  access */
345  s->rtp_fd = ffurl_get_file_handle(s->rtp_hd);
346  s->rtcp_fd = ffurl_get_file_handle(s->rtcp_hd);
347 
348  h->max_packet_size = s->rtp_hd->max_packet_size;
349  h->is_streamed = 1;
350 
351  av_free(fec_protocol);
352  av_dict_free(&fec_opts);
353 
354  return 0;
355 
356  fail:
357  ff_ip_reset_filters(&s->filters);
358  ffurl_closep(&s->rtp_hd);
359  ffurl_closep(&s->rtcp_hd);
360  ffurl_closep(&s->fec_hd);
361  av_free(fec_protocol);
362  av_dict_free(&fec_opts);
363  return ret;
364 }
365 
366 static int rtp_read(URLContext *h, uint8_t *buf, int size)
367 {
368  RTPContext *s = h->priv_data;
369  int len, n, i;
370  struct pollfd p[2] = {{s->rtp_fd, POLLIN, 0}, {s->rtcp_fd, POLLIN, 0}};
371  int poll_delay = h->flags & AVIO_FLAG_NONBLOCK ? 0 : POLLING_TIME;
372  struct sockaddr_storage *addrs[2] = { &s->last_rtp_source, &s->last_rtcp_source };
373  socklen_t *addr_lens[2] = { &s->last_rtp_source_len, &s->last_rtcp_source_len };
374  int runs = h->rw_timeout / 1000 / POLLING_TIME;
375 
376  for(;;) {
377  if (ff_check_interrupt(&h->interrupt_callback))
378  return AVERROR_EXIT;
379  n = poll(p, 2, poll_delay);
380  if (n > 0) {
381  /* first try RTCP, then RTP */
382  for (i = 1; i >= 0; i--) {
383  if (!(p[i].revents & POLLIN))
384  continue;
385  *addr_lens[i] = sizeof(*addrs[i]);
386  len = recvfrom(p[i].fd, buf, size, 0,
387  (struct sockaddr *)addrs[i], addr_lens[i]);
388  if (len < 0) {
389  if (ff_neterrno() == AVERROR(EAGAIN) ||
390  ff_neterrno() == AVERROR(EINTR))
391  continue;
392  return AVERROR(EIO);
393  }
394  if (ff_ip_check_source_lists(addrs[i], &s->filters))
395  continue;
396  return len;
397  }
398  } else if (n == 0 && h->rw_timeout > 0 && --runs <= 0) {
399  return AVERROR(ETIMEDOUT);
400  } else if (n < 0) {
401  if (ff_neterrno() == AVERROR(EINTR))
402  continue;
403  return AVERROR(EIO);
404  }
405  if (h->flags & AVIO_FLAG_NONBLOCK)
406  return AVERROR(EAGAIN);
407  }
408 }
409 
410 static int rtp_write(URLContext *h, const uint8_t *buf, int size)
411 {
412  RTPContext *s = h->priv_data;
413  int ret, ret_fec;
414  URLContext *hd;
415 
416  if (size < 2)
417  return AVERROR(EINVAL);
418 
419  if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
420  av_log(h, AV_LOG_WARNING, "Data doesn't look like RTP packets, "
421  "make sure the RTP muxer is used\n");
422 
423  if (s->write_to_source) {
424  int fd;
425  struct sockaddr_storage *source, temp_source;
426  socklen_t *source_len, temp_len;
427  if (!s->last_rtp_source.ss_family && !s->last_rtcp_source.ss_family) {
429  "Unable to send packet to source, no packets received yet\n");
430  // Intentionally not returning an error here
431  return size;
432  }
433 
434  if (RTP_PT_IS_RTCP(buf[1])) {
435  fd = s->rtcp_fd;
436  source = &s->last_rtcp_source;
437  source_len = &s->last_rtcp_source_len;
438  } else {
439  fd = s->rtp_fd;
440  source = &s->last_rtp_source;
441  source_len = &s->last_rtp_source_len;
442  }
443  if (!source->ss_family) {
444  source = &temp_source;
445  source_len = &temp_len;
446  if (RTP_PT_IS_RTCP(buf[1])) {
447  temp_source = s->last_rtp_source;
448  temp_len = s->last_rtp_source_len;
451  "Not received any RTCP packets yet, inferring peer port "
452  "from the RTP port\n");
453  } else {
454  temp_source = s->last_rtcp_source;
455  temp_len = s->last_rtcp_source_len;
458  "Not received any RTP packets yet, inferring peer port "
459  "from the RTCP port\n");
460  }
461  }
462 
463  if (!(h->flags & AVIO_FLAG_NONBLOCK)) {
464  ret = ff_network_wait_fd(fd, 1);
465  if (ret < 0)
466  return ret;
467  }
468  ret = sendto(fd, buf, size, 0, (struct sockaddr *) source,
469  *source_len);
470 
471  return ret < 0 ? ff_neterrno() : ret;
472  }
473 
474  if (RTP_PT_IS_RTCP(buf[1])) {
475  /* RTCP payload type */
476  hd = s->rtcp_hd;
477  } else {
478  /* RTP payload type */
479  hd = s->rtp_hd;
480  }
481 
482  if ((ret = ffurl_write(hd, buf, size)) < 0) {
483  return ret;
484  }
485 
486  if (s->fec_hd && !RTP_PT_IS_RTCP(buf[1])) {
487  if ((ret_fec = ffurl_write(s->fec_hd, buf, size)) < 0) {
488  av_log(h, AV_LOG_ERROR, "Failed to send FEC\n");
489  return ret_fec;
490  }
491  }
492 
493  return ret;
494 }
495 
496 static int rtp_close(URLContext *h)
497 {
498  RTPContext *s = h->priv_data;
499 
500  ff_ip_reset_filters(&s->filters);
501 
502  ffurl_closep(&s->rtp_hd);
503  ffurl_closep(&s->rtcp_hd);
504  ffurl_closep(&s->fec_hd);
505  return 0;
506 }
507 
508 /**
509  * Return the local rtp port used by the RTP connection
510  * @param h media file context
511  * @return the local port number
512  */
513 
515 {
516  RTPContext *s = h->priv_data;
517  return ff_udp_get_local_port(s->rtp_hd);
518 }
519 
520 /**
521  * Return the local rtcp port used by the RTP connection
522  * @param h media file context
523  * @return the local port number
524  */
525 
527 {
528  RTPContext *s = h->priv_data;
529  return s->rtp_fd;
530 }
531 
532 static int rtp_get_multi_file_handle(URLContext *h, int **handles,
533  int *numhandles)
534 {
535  RTPContext *s = h->priv_data;
536  int *hs = *handles = av_malloc(sizeof(**handles) * 2);
537  if (!hs)
538  return AVERROR(ENOMEM);
539  hs[0] = s->rtp_fd;
540  hs[1] = s->rtcp_fd;
541  *numhandles = 2;
542  return 0;
543 }
544 
546  .name = "rtp",
547  .url_open = rtp_open,
548  .url_read = rtp_read,
549  .url_write = rtp_write,
550  .url_close = rtp_close,
551  .url_get_file_handle = rtp_get_file_handle,
552  .url_get_multi_file_handle = rtp_get_multi_file_handle,
553  .priv_data_size = sizeof(RTPContext),
555  .priv_data_class = &rtp_class,
556 };
flags
const SwsFlags flags[]
Definition: swscale.c:61
ff_udp_get_local_port
int ff_udp_get_local_port(URLContext *h)
Return the local port used by the UDP connection.
Definition: udp.c:504
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:216
RTPContext::rtcp_fd
int rtcp_fd
Definition: rtpproto.c:49
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
RTPContext::connect
int connect
Definition: rtpproto.c:57
opt.h
av_find_info_tag
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:756
URL_PROTOCOL_FLAG_NETWORK
#define URL_PROTOCOL_FLAG_NETWORK
Definition: url.h:33
ff_ip_parse_sources
int ff_ip_parse_sources(void *log_ctx, const char *buf, IPSourceFilters *filters)
Parses the address[,address] source list in buf and adds it to the filters in the IPSourceFilters str...
Definition: ip.c:145
av_printf_format
static av_printf_format(3, 4)
add option to url of the form: "http://host:port/path?option1=val1&option2=val2...
Definition: rtpproto.c:165
RTP_VERSION
#define RTP_VERSION
Definition: rtp.h:80
RTPContext::local_rtcpport
int local_rtcpport
Definition: rtpproto.c:56
int64_t
long long int64_t
Definition: coverity.c:34
ffurl_write
static int ffurl_write(URLContext *h, const uint8_t *buf, int size)
Write size bytes from buf to the resource accessed by h.
Definition: url.h:202
rtp_close
static int rtp_close(URLContext *h)
Definition: rtpproto.c:496
sources
Note except for filters that can have queued frames and sources
Definition: filter_design.txt:286
AVOption
AVOption.
Definition: opt.h:429
OFFSET
#define OFFSET(x)
Definition: rtpproto.c:67
ff_udp_set_remote_url
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:435
AVDictionary
Definition: dict.c:32
URLProtocol
Definition: url.h:51
os_support.h
RTPContext::last_rtp_source_len
socklen_t last_rtp_source_len
Definition: rtpproto.c:53
sockaddr_storage
Definition: network.h:111
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
ff_rtp_protocol
const URLProtocol ff_rtp_protocol
Definition: rtpproto.c:545
ff_ip_reset_filters
void ff_ip_reset_filters(IPSourceFilters *filters)
Resets the IP filter list and frees the internal fields of an IPSourceFilters structure.
Definition: ip.c:155
rtp_class
static const AVClass rtp_class
Definition: rtpproto.c:93
fail
#define fail()
Definition: checkasm.h:204
ff_rtp_get_local_rtp_port
int ff_rtp_get_local_rtp_port(URLContext *h)
Return the local rtp port used by the RTP connection.
Definition: rtpproto.c:514
ff_rtp_set_remote_url
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:110
RTPContext::fec_options_str
char * fec_options_str
Definition: rtpproto.c:62
ss
#define ss(width, name, subs,...)
Definition: cbs_vp9.c:202
ff_check_interrupt
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
Definition: avio.c:855
DEPR
#define DEPR
Definition: rtpproto.c:70
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
ffurl_open_whitelist
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist, URLContext *parent)
Create an URLContext for accessing to the resource indicated by url, and open it.
Definition: avio.c:363
s
#define s(width, name)
Definition: cbs_vp9.c:198
RTPContext::ttl
int ttl
Definition: rtpproto.c:54
ff_url_join
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:40
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
Definition: opt.h:263
AVIO_FLAG_WRITE
#define AVIO_FLAG_WRITE
write-only
Definition: avio.h:618
internal.h
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
RTPContext::block
char * block
Definition: rtpproto.c:61
NULL
#define NULL
Definition: coverity.c:32
ff_ip_parse_blocks
int ff_ip_parse_blocks(void *log_ctx, const char *buf, IPSourceFilters *filters)
Parses the address[,address] source block list in buf and adds it to the filters in the IPSourceFilte...
Definition: ip.c:150
RTPContext::rtcp_hd
URLContext * rtcp_hd
Definition: rtpproto.c:48
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:241
RTPContext::buffer_size
int buffer_size
Definition: rtpproto.c:55
parseutils.h
options
Definition: swscale.c:43
ff_neterrno
#define ff_neterrno()
Definition: network.h:68
source
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a source
Definition: filter_design.txt:256
RTP_PT_IS_RTCP
#define RTP_PT_IS_RTCP(x)
Definition: rtp.h:112
RTPContext::pkt_size
int pkt_size
Definition: rtpproto.c:58
RTPContext::dscp
int dscp
Definition: rtpproto.c:59
rtp_read
static int rtp_read(URLContext *h, uint8_t *buf, int size)
Definition: rtpproto.c:366
RTPContext::rtp_hd
URLContext * rtp_hd
Definition: rtpproto.c:48
size
int size
Definition: twinvq_data.h:10344
URLProtocol::name
const char * name
Definition: url.h:52
set_port
static void set_port(struct sockaddr_storage *ss, int port)
Definition: rtpproto.c:150
RTPContext::localaddr
char * localaddr
Definition: rtpproto.c:64
build_udp_url
static void build_udp_url(RTPContext *s, char *buf, int buf_size, const char *hostname, const char *localaddr, int port, int local_port, const char *include_sources, const char *exclude_sources)
Definition: rtpproto.c:180
RTPContext::last_rtcp_source
struct sockaddr_storage last_rtp_source last_rtcp_source
Definition: rtpproto.c:52
av_dict_free
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition: dict.c:233
rtp.h
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:221
rtp_open
static int rtp_open(URLContext *h, const char *uri, int flags)
url syntax: rtp://host:port[?option=val...] option: 'ttl=n' : set the ttl value (for multicast only) ...
Definition: rtpproto.c:231
options
static const AVOption options[]
Definition: rtpproto.c:71
URLContext
Definition: url.h:35
RTPContext::sources
char * sources
Definition: rtpproto.c:60
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
ip.h
RTPContext::rw_timeout
int64_t rw_timeout
Definition: rtpproto.c:63
vsnprintf
#define vsnprintf
Definition: snprintf.h:36
rtpproto.h
av_url_split
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:361
url.h
len
int len
Definition: vorbis_enc_data.h:426
ff_parse_opts_from_query_string
int ff_parse_opts_from_query_string(void *obj, const char *str, int allow_unkown)
Set a list of query string options on an object.
Definition: utils.c:636
ffurl_closep
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
Definition: avio.c:589
ret
ret
Definition: filter_design.txt:187
AVClass::class_name
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:81
av_strlcat
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:95
E
#define E
Definition: rtpproto.c:69
avformat.h
rtp_write
static int rtp_write(URLContext *h, const uint8_t *buf, int size)
Definition: rtpproto.c:410
network.h
RTPContext::local_rtpport
int local_rtpport
Definition: rtpproto.c:56
RTPContext::fec_hd
URLContext * fec_hd
Definition: rtpproto.c:48
IPSourceFilters
Structure for storing IP (UDP) source filters or block lists.
Definition: ip.h:29
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
av_get_token
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
Definition: avstring.c:143
av_dict_parse_string
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
Definition: dict.c:210
RTPContext::rtcp_port
int rtcp_port
Definition: rtpproto.c:56
ff_ip_check_source_lists
int ff_ip_check_source_lists(struct sockaddr_storage *source_addr_ptr, IPSourceFilters *s)
Checks the source address against a given IP source filter.
Definition: ip.c:46
RTPContext
Definition: rtpproto.c:46
rtp_get_file_handle
static int rtp_get_file_handle(URLContext *h)
Return the local rtcp port used by the RTP connection.
Definition: rtpproto.c:526
rtp_get_multi_file_handle
static int rtp_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
Definition: rtpproto.c:532
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
av_dict_set_int
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set() that converts the value to a string and stores it.
Definition: dict.c:177
mem.h
get_port
static int get_port(const struct sockaddr_storage *ss)
Definition: rtpproto.c:139
D
#define D
Definition: rtpproto.c:68
RTPContext::write_to_source
int write_to_source
Definition: rtpproto.c:51
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
AVIO_FLAG_NONBLOCK
#define AVIO_FLAG_NONBLOCK
Use non-blocking mode.
Definition: avio.h:636
POLLING_TIME
#define POLLING_TIME
Definition: network.h:249
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
h
h
Definition: vp9dsp_template.c:2070
AVERROR_EXIT
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:58
RTPContext::rtp_fd
int rtp_fd
Definition: rtpproto.c:49
RTPContext::filters
IPSourceFilters filters
Definition: rtpproto.c:50
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
RTPContext::last_rtcp_source_len
socklen_t last_rtcp_source_len
Definition: rtpproto.c:53
ffurl_get_file_handle
int ffurl_get_file_handle(URLContext *h)
Return the file descriptor associated with this URL.
Definition: avio.c:815
ff_network_wait_fd
int ff_network_wait_fd(int fd, int write)
Definition: network.c:66