MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / udp_open

Function udp_open

libavformat/udp.c:693–965  ·  view source on GitHub ↗

put it in UDP context */ return non zero if error */

Source from the content-addressed store, hash-verified

691/* put it in UDP context */
692/* return non zero if error */
693static int udp_open(URLContext *h, const char *uri, int flags)
694{
695 char hostname[1024];
696 int port, udp_fd = -1, tmp, bind_ret = -1;
697 UDPContext *s = h->priv_data;
698 int is_output;
699 const char *p;
700 struct sockaddr_storage my_addr;
701 socklen_t len;
702 int ret;
703 const char *bind_addr = NULL;
704
705 h->is_streamed = 1;
706
707 is_output = !(flags & AVIO_FLAG_READ);
708 if (s->buffer_size < 0)
709 s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_RX_BUF_SIZE;
710
711 p = strchr(uri, '?');
712 if (p) {
713 ret = ff_parse_opts_from_query_string(s, p, 1);
714 if (ret < 0)
715 goto fail;
716 }
717 if (!HAVE_PTHREAD_CANCEL) {
718 int64_t optvals[] = {s->overrun_nonfatal, s->bitrate, s->circular_buffer_size};
719 const char* optnames[] = { "overrun_nonfatal", "bitrate", "fifo_size"};
720 for (unsigned i = 0; i < FF_ARRAY_ELEMS(optvals); i++) {
721 if (optvals[i])
722 av_log(h, AV_LOG_WARNING,
723 "'%s' option was set but it is not supported "
724 "on this build (pthread support is required)\n", optnames[i]);
725 }
726 }
727 if (s->sources) {
728 if ((ret = ff_ip_parse_sources(h, s->sources, &s->filters)) < 0)
729 goto fail;
730 }
731 if (s->block) {
732 if ((ret = ff_ip_parse_blocks(h, s->block, &s->filters)) < 0)
733 goto fail;
734 }
735
736 /* handling needed to support options picking from both AVOption and URL */
737 s->circular_buffer_size *= 188;
738 if (flags & AVIO_FLAG_WRITE) {
739 h->max_packet_size = s->pkt_size;
740 } else {
741 h->max_packet_size = UDP_MAX_PKT_SIZE;
742 }
743 h->rw_timeout = s->timeout;
744
745 /* fill the dest addr */
746 av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
747
748 /* XXX: fix av_url_split */
749 if (hostname[0] == '\0' || hostname[0] == '?') {
750 /* only accepts null hostname if input */

Callers 1

udplite_openFunction · 0.85

Calls 15

av_logFunction · 0.85
ff_ip_parse_sourcesFunction · 0.85
ff_ip_parse_blocksFunction · 0.85
av_url_splitFunction · 0.85
ff_udp_set_remote_urlFunction · 0.85
udp_socket_createFunction · 0.85
ff_neterrnoFunction · 0.85
ff_log_net_errorFunction · 0.85
udp_portFunction · 0.85
udp_set_multicast_ttlFunction · 0.85

Tested by

no test coverage detected