#include "network.h"
#include "os_support.h"
#include "url.h"
+
+#if HAVE_PTHREADS
#include <pthread.h>
+#endif
+
#include <sys/time.h>
#ifndef IPV6_ADD_MEMBERSHIP
/* Circular Buffer variables for use in UDP receive code */
int circular_buffer_size;
AVFifoBuffer *fifo;
- int circular_buffer_available_max;
int circular_buffer_error;
+#if HAVE_PTHREADS
pthread_t circular_buffer_thread;
+#endif
} UDPContext;
#define UDP_TX_BUF_SIZE 32768
goto fail;
}
- if (s->is_multicast && (h->flags & AVIO_FLAG_READ))
+ if ((s->is_multicast || !s->local_port) && (h->flags & AVIO_FLAG_READ))
s->local_port = port;
udp_fd = udp_socket_create(s, &my_addr, &len);
if (udp_fd < 0)
s->udp_fd = udp_fd;
+#if HAVE_PTHREADS
if (!is_output && s->circular_buffer_size) {
/* start the task going */
s->fifo = av_fifo_alloc(s->circular_buffer_size);
goto fail;
}
}
+#endif
return 0;
fail:
if (udp_fd >= 0)
closesocket(udp_fd);
- av_fifo_free(s->fifo);
+ av_fifo_free(s->fifo);
av_free(s);
return AVERROR(EIO);
}
UDPContext *s = h->priv_data;
int ret;
int avail;
- int left;
fd_set rfds;
struct timeval tv;
if (s->is_multicast && (h->flags & AVIO_FLAG_READ))
udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr);
closesocket(s->udp_fd);
- av_log( h, AV_LOG_INFO, "circular_buffer_info max:%d%%\r\n", (s->circular_buffer_available_max*100)/s->circular_buffer_size);
av_fifo_free(s->fifo);
av_free(s);
return 0;