aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/tcp.c
diff options
context:
space:
mode:
authorStephan Holljes <klaxa1337@googlemail.com>2015-07-21 06:10:25 +0200
committerStephan Holljes <klaxa1337@googlemail.com>2015-08-01 00:58:31 +0200
commit21198155a79a8372f5d8abe7e6de2d4ba3eaf550 (patch)
tree4ffd5ee600a4d5418a326603339225a6bda19444 /libavformat/tcp.c
parent63c07a956bb240ebd5aeb0509953fe80e08e4699 (diff)
downloadffmpeg-21198155a79a8372f5d8abe7e6de2d4ba3eaf550.tar.gz
lavf/tcp: add tcp_accept
Signed-off-by: Stephan Holljes <klaxa1337@googlemail.com>
Diffstat (limited to 'libavformat/tcp.c')
-rw-r--r--libavformat/tcp.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index f24cad2080..c559b806f8 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
+#include "libavutil/avassert.h"
#include "libavutil/parseutils.h"
#include "libavutil/opt.h"
#include "libavutil/time.h"
@@ -163,6 +164,22 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
return ret;
}
+static int tcp_accept(URLContext *s, URLContext **c)
+{
+ TCPContext *sc = s->priv_data;
+ TCPContext *cc;
+ int ret;
+ av_assert0(sc->listen);
+ if ((ret = ffurl_alloc(c, s->filename, s->flags, &s->interrupt_callback)) < 0)
+ return ret;
+ cc = (*c)->priv_data;
+ ret = ff_accept(sc->fd, sc->listen_timeout, s);
+ if (ret < 0)
+ return ff_neterrno();
+ cc->fd = ret;
+ return 0;
+}
+
static int tcp_read(URLContext *h, uint8_t *buf, int size)
{
TCPContext *s = h->priv_data;
@@ -223,6 +240,7 @@ static int tcp_get_file_handle(URLContext *h)
URLProtocol ff_tcp_protocol = {
.name = "tcp",
.url_open = tcp_open,
+ .url_accept = tcp_accept,
.url_read = tcp_read,
.url_write = tcp_write,
.url_close = tcp_close,