diff --git a/debian/control b/debian/control index 3d6349462..2dc38f0fa 100644 --- a/debian/control +++ b/debian/control @@ -4,6 +4,9 @@ Priority: extra Maintainer: Sipwise Development Team Build-Depends: debhelper (>= 5), iptables-dev (>= 1.4), + libavformat-dev, + libavcodec-dev, + libavutil-dev, libcurl4-openssl-dev | libcurl4-gnutls-dev | libcurl3-openssl-dev | libcurl3-gnutls-dev, libevent-dev (>= 2.0), libglib2.0-dev (>= 2.30), diff --git a/recording-daemon/.gitignore b/recording-daemon/.gitignore index 8577790bc..16889cdce 100644 --- a/recording-daemon/.gitignore +++ b/recording-daemon/.gitignore @@ -3,3 +3,4 @@ core core.* .ycm_extra_conf.pyc +rtpengine-recording diff --git a/recording-daemon/Makefile b/recording-daemon/Makefile index cd38772d0..5341fe470 100644 --- a/recording-daemon/Makefile +++ b/recording-daemon/Makefile @@ -7,6 +7,9 @@ CFLAGS+= -D_GNU_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE CFLAGS+= `pkg-config --cflags glib-2.0` CFLAGS+= `pkg-config --cflags gthread-2.0` #CFLAGS+= `pcre-config --cflags` +CFLAGS+= `pkg-config --cflags libavcodec` +CFLAGS+= `pkg-config --cflags libavformat` +CFLAGS+= `pkg-config --cflags libavutil` ifeq ($(DBG),yes) CFLAGS+= -D__DEBUG=1 @@ -18,6 +21,9 @@ LDFLAGS= -lm LDFLAGS+= `pkg-config --libs glib-2.0` LDFLAGS+= `pkg-config --libs gthread-2.0` #LDFLAGS+= `pcre-config --libs` +LDFLAGS+= `pkg-config --libs libavcodec` +LDFLAGS+= `pkg-config --libs libavformat` +LDFLAGS+= `pkg-config --libs libavutil` ifneq ($(DBG),yes) DPKG_BLDFLGS= $(shell which dpkg-buildflags 2>/dev/null) diff --git a/recording-daemon/main.c b/recording-daemon/main.c index 9ce523d0d..cbad04ee3 100644 --- a/recording-daemon/main.c +++ b/recording-daemon/main.c @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include "log.h" #include "epoll.h" #include "inotify.h" @@ -32,6 +34,9 @@ static void signals(void) { static void setup(void) { + av_register_all(); + avcodec_register_all(); + avformat_network_init(); signals(); metafile_setup(); epoll_setup(); diff --git a/recording-daemon/stream.c b/recording-daemon/stream.c index 686be84f2..3900177ed 100644 --- a/recording-daemon/stream.c +++ b/recording-daemon/stream.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "metafile.h" #include "epoll.h" #include "log.h" @@ -88,6 +89,15 @@ void stream_open(metafile_t *mf, unsigned long id, char *name) { return; } + stream->avinf = av_find_input_format("rtp"); + ilog(LOG_DEBUG, "avinf %p", stream->avinf); + + stream->avfctx = avformat_alloc_context(); + unsigned char *buf = av_malloc(1024); // ? + stream->avfctx->pb = avio_alloc_context(buf, 1024, 1, NULL, NULL, NULL, NULL); + int ret = avformat_open_input(&stream->avfctx, "", stream->avinf, NULL); + ilog(LOG_DEBUG, "ret %i avfctx %p", ret, stream->avfctx); + // add to epoll stream->handler.ptr = stream; stream->handler.func = stream_handler; diff --git a/recording-daemon/types.h b/recording-daemon/types.h index ada38263e..2fabc61e1 100644 --- a/recording-daemon/types.h +++ b/recording-daemon/types.h @@ -6,6 +6,7 @@ #include #include #include +#include typedef struct handler_s handler_t; @@ -22,6 +23,8 @@ struct stream_s { unsigned long id; int fd; handler_t handler; + AVInputFormat *avinf; + AVFormatContext *avfctx; }; typedef struct stream_s stream_t;