#include "rtpdec.h"
#include "url.h"
-#include <unistd.h>
#include <stdarg.h>
#include "internal.h"
#include "network.h"
#if HAVE_POLL_H
#include <sys/poll.h>
#endif
-#include <sys/time.h>
#define RTP_TX_BUF_SIZE (64 * 1024)
#define RTP_RX_BUF_SIZE (128 * 1024)
static int rtp_open(URLContext *h, const char *uri, int flags)
{
- RTPContext *s;
+ RTPContext *s = h->priv_data;
int rtp_port, rtcp_port,
ttl, connect,
local_rtp_port, local_rtcp_port, max_packet_size;
char path[1024];
const char *p;
- s = av_mallocz(sizeof(RTPContext));
- if (!s)
- return AVERROR(ENOMEM);
- h->priv_data = s;
-
av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &rtp_port,
path, sizeof(path), uri);
/* extract parameters */
build_udp_url(buf, sizeof(buf),
hostname, rtp_port, local_rtp_port, ttl, max_packet_size,
connect);
- if (ffurl_open(&s->rtp_hd, buf, flags, &h->interrupt_callback) < 0)
+ if (ffurl_open(&s->rtp_hd, buf, flags, &h->interrupt_callback, NULL) < 0)
goto fail;
if (local_rtp_port>=0 && local_rtcp_port<0)
local_rtcp_port = ff_udp_get_local_port(s->rtp_hd) + 1;
build_udp_url(buf, sizeof(buf),
hostname, rtcp_port, local_rtcp_port, ttl, max_packet_size,
connect);
- if (ffurl_open(&s->rtcp_hd, buf, flags, &h->interrupt_callback) < 0)
+ if (ffurl_open(&s->rtcp_hd, buf, flags, &h->interrupt_callback, NULL) < 0)
goto fail;
/* just to ease handle access. XXX: need to suppress direct handle
ffurl_close(s->rtp_hd);
if (s->rtcp_hd)
ffurl_close(s->rtcp_hd);
- av_free(s);
return AVERROR(EIO);
}
int ret;
URLContext *hd;
- if (buf[1] >= RTCP_SR && buf[1] <= RTCP_APP) {
+ if (RTP_PT_IS_RTCP(buf[1])) {
/* RTCP payload type */
hd = s->rtcp_hd;
} else {
ffurl_close(s->rtp_hd);
ffurl_close(s->rtcp_hd);
- av_free(s);
return 0;
}
.url_write = rtp_write,
.url_close = rtp_close,
.url_get_file_handle = rtp_get_file_handle,
+ .priv_data_size = sizeof(RTPContext),
+ .flags = URL_PROTOCOL_FLAG_NETWORK,
};