mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-01 02:03:45 -04:00
Make compatible with libevent 2.0 by crippling streaming and ICY metadata (see issue #30)
This commit is contained in:
parent
5b4ef31758
commit
c740e6e3b0
19
configure.ac
19
configure.ac
@ -160,19 +160,28 @@ fi
|
|||||||
|
|
||||||
PKG_CHECK_MODULES(MINIXML, [ mxml ])
|
PKG_CHECK_MODULES(MINIXML, [ mxml ])
|
||||||
|
|
||||||
PKG_CHECK_MODULES(LIBEVENT, [ libevent >= 2.1.4 ],
|
PKG_CHECK_MODULES(LIBEVENT, [ libevent >= 2 ],
|
||||||
AC_DEFINE(HAVE_LIBEVENT2, 1, [Define to 1 if you have libevent >= 2.1.4]),
|
AC_DEFINE(HAVE_LIBEVENT2, 1, [Define to 1 if you have libevent 2]),
|
||||||
try_libevent1=true;
|
try_libevent1=true;
|
||||||
)
|
)
|
||||||
|
|
||||||
|
AM_CONDITIONAL(COND_LIBEVENT1, false)
|
||||||
|
AM_CONDITIONAL(COND_LIBEVENT20, false)
|
||||||
|
AM_CONDITIONAL(COND_LIBEVENT21, false)
|
||||||
|
|
||||||
if test x$try_libevent1 = xtrue; then
|
if test x$try_libevent1 = xtrue; then
|
||||||
AC_CHECK_HEADER(event.h, , AC_MSG_ERROR([event.h not found]))
|
AC_CHECK_HEADER(event.h, , AC_MSG_ERROR([event.h not found]))
|
||||||
AC_CHECK_LIB([event_core], [event_init], [LIBEVENT_LIBS="-levent_core"], AC_MSG_ERROR([libevent not found]))
|
AC_CHECK_LIB([event_core], [event_init], [LIBEVENT_LIBS="-levent_core"], AC_MSG_ERROR([libevent not found]))
|
||||||
AC_CHECK_LIB([event_core], [event_new], AC_MSG_ERROR([found libevent 2 but version should be at least 2.1.4]))
|
|
||||||
AC_SUBST(LIBEVENT_LIBS)
|
AC_SUBST(LIBEVENT_LIBS)
|
||||||
AM_CONDITIONAL(COND_LIBEVENT2, false)
|
AM_CONDITIONAL(COND_LIBEVENT1, true)
|
||||||
else
|
else
|
||||||
AM_CONDITIONAL(COND_LIBEVENT2, true)
|
PKG_CHECK_EXISTS([ libevent >= 2.1 ],
|
||||||
|
AM_CONDITIONAL(COND_LIBEVENT21, true),
|
||||||
|
AM_CONDITIONAL(COND_LIBEVENT20, true)
|
||||||
|
)
|
||||||
|
PKG_CHECK_EXISTS([ libevent >= 2.1.4 ], ,
|
||||||
|
AC_DEFINE(HAVE_LIBEVENT2_OLD, 1, [Define to 1 if you have libevent 2 (<2.1.4)])
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_CHECK_HEADER(avl.h, , AC_MSG_ERROR([avl.h not found]))
|
AC_CHECK_HEADER(avl.h, , AC_MSG_ERROR([avl.h not found]))
|
||||||
|
@ -31,13 +31,21 @@ else
|
|||||||
FFURL_SRC=ffmpeg_url_evbuffer.c ffmpeg_url_evbuffer.h
|
FFURL_SRC=ffmpeg_url_evbuffer.c ffmpeg_url_evbuffer.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if COND_LIBEVENT2
|
if COND_LIBEVENT1
|
||||||
RTSP_SRC=evrtsp/rtsp.c evrtp/evrtsp.h evrtsp/rtsp-internal.h evrtsp/log.h
|
|
||||||
else
|
|
||||||
EVHTTP_SRC=evhttp/http.c evhttp/evhttp.h evhttp/evhttp_compat.c evhttp/evhttp_compat.h evhttp/http-internal.h evhttp/log.h
|
EVHTTP_SRC=evhttp/http.c evhttp/evhttp.h evhttp/evhttp_compat.c evhttp/evhttp_compat.h evhttp/http-internal.h evhttp/log.h
|
||||||
RTSP_SRC=evrtsp/rtsp-libevent1.c evrtp/evrtsp.h evrtsp/rtsp-internal.h evrtsp/log.h
|
RTSP_SRC=evrtsp/rtsp-libevent1.c evrtp/evrtsp.h evrtsp/rtsp-internal.h evrtsp/log.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if COND_LIBEVENT20
|
||||||
|
EVHTTP_SRC=
|
||||||
|
RTSP_SRC=evrtsp/rtsp-libevent20.c evrtp/evrtsp.h evrtsp/rtsp-internal.h evrtsp/log.h
|
||||||
|
endif
|
||||||
|
|
||||||
|
if COND_LIBEVENT21
|
||||||
|
EVHTTP_SRC=
|
||||||
|
RTSP_SRC=evrtsp/rtsp.c evrtp/evrtsp.h evrtsp/rtsp-internal.h evrtsp/log.h
|
||||||
|
endif
|
||||||
|
|
||||||
GPERF_FILES = \
|
GPERF_FILES = \
|
||||||
daap_query.gperf \
|
daap_query.gperf \
|
||||||
rsp_query.gperf \
|
rsp_query.gperf \
|
||||||
|
1808
src/evrtsp/rtsp-libevent20.c
Normal file
1808
src/evrtsp/rtsp-libevent20.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -110,6 +110,7 @@ resolve_address(char *hostname, char *s, size_t maxlen)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_LIBEVENT2_OLD
|
||||||
static void
|
static void
|
||||||
scan_icy_request_cb(struct evhttp_request *req, void *arg)
|
scan_icy_request_cb(struct evhttp_request *req, void *arg)
|
||||||
{
|
{
|
||||||
@ -157,15 +158,18 @@ scan_icy_header_cb(struct evhttp_request *req, void *arg)
|
|||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
scan_metadata_icy(char *url, struct media_file_info *mfi)
|
scan_metadata_icy(char *url, struct media_file_info *mfi)
|
||||||
{
|
{
|
||||||
|
struct icy_ctx *ctx;
|
||||||
struct evhttp_connection *evcon;
|
struct evhttp_connection *evcon;
|
||||||
|
#ifndef HAVE_LIBEVENT2_OLD
|
||||||
struct evhttp_request *req;
|
struct evhttp_request *req;
|
||||||
struct evkeyvalq *headers;
|
struct evkeyvalq *headers;
|
||||||
struct icy_ctx *ctx;
|
|
||||||
char s[PATH_MAX];
|
char s[PATH_MAX];
|
||||||
|
#endif
|
||||||
time_t start;
|
time_t start;
|
||||||
time_t end;
|
time_t end;
|
||||||
int ret;
|
int ret;
|
||||||
@ -239,6 +243,9 @@ scan_metadata_icy(char *url, struct media_file_info *mfi)
|
|||||||
evhttp_connection_set_base(evcon, evbase_main);
|
evhttp_connection_set_base(evcon, evbase_main);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBEVENT2_OLD
|
||||||
|
DPRINTF(E_LOG, L_SCAN, "Skipping Shoutcast metadata request for %s (requires libevent>=2.1.4)\n", ctx->hostname);
|
||||||
|
#else
|
||||||
evhttp_connection_set_timeout(evcon, ICY_TIMEOUT);
|
evhttp_connection_set_timeout(evcon, ICY_TIMEOUT);
|
||||||
|
|
||||||
/* Set up request */
|
/* Set up request */
|
||||||
@ -269,6 +276,7 @@ scan_metadata_icy(char *url, struct media_file_info *mfi)
|
|||||||
status = ICY_DONE;
|
status = ICY_DONE;
|
||||||
goto no_icy;
|
goto no_icy;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Can't count on server support for ICY metadata, so
|
/* Can't count on server support for ICY metadata, so
|
||||||
* while waiting for a reply make a parallel call to scan_metadata_ffmpeg.
|
* while waiting for a reply make a parallel call to scan_metadata_ffmpeg.
|
||||||
|
37
src/httpd.c
37
src/httpd.c
@ -122,6 +122,9 @@ static struct event exitev;
|
|||||||
static struct evhttp *evhttpd;
|
static struct evhttp *evhttpd;
|
||||||
static pthread_t tid_httpd;
|
static pthread_t tid_httpd;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBEVENT2_OLD
|
||||||
|
struct stream_ctx *g_st;
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
stream_end(struct stream_ctx *st, int failed)
|
stream_end(struct stream_ctx *st, int failed)
|
||||||
@ -146,6 +149,11 @@ stream_end(struct stream_ctx *st, int failed)
|
|||||||
close(st->fd);
|
close(st->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBEVENT2_OLD
|
||||||
|
if (g_st == st)
|
||||||
|
g_st = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
free(st);
|
free(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,6 +188,15 @@ stream_chunk_resched_cb(struct evhttp_connection *evcon, void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBEVENT2_OLD
|
||||||
|
static void
|
||||||
|
stream_chunk_resched_cb_wrapper(struct bufferevent *bufev, void *arg)
|
||||||
|
{
|
||||||
|
if (g_st)
|
||||||
|
stream_chunk_resched_cb(NULL, g_st);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
stream_chunk_xcode_cb(int fd, short event, void *arg)
|
stream_chunk_xcode_cb(int fd, short event, void *arg)
|
||||||
{
|
{
|
||||||
@ -227,7 +244,17 @@ stream_chunk_xcode_cb(int fd, short event, void *arg)
|
|||||||
else
|
else
|
||||||
ret = xcoded;
|
ret = xcoded;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBEVENT2_OLD
|
||||||
|
evhttp_send_reply_chunk(st->req, st->evbuf);
|
||||||
|
|
||||||
|
struct evhttp_connection *evcon = evhttp_request_get_connection(st->req);
|
||||||
|
struct bufferevent *bufev = evhttp_connection_get_bufferevent(evcon);
|
||||||
|
|
||||||
|
g_st = st; // Can't pass st to callback so use global - limits libevent 2.0 to a single stream
|
||||||
|
bufev->writecb = stream_chunk_resched_cb_wrapper;
|
||||||
|
#else
|
||||||
evhttp_send_reply_chunk_with_cb(st->req, st->evbuf, stream_chunk_resched_cb, st);
|
evhttp_send_reply_chunk_with_cb(st->req, st->evbuf, stream_chunk_resched_cb, st);
|
||||||
|
#endif
|
||||||
|
|
||||||
st->offset += ret;
|
st->offset += ret;
|
||||||
|
|
||||||
@ -283,7 +310,17 @@ stream_chunk_raw_cb(int fd, short event, void *arg)
|
|||||||
|
|
||||||
evbuffer_add(st->evbuf, st->buf, ret);
|
evbuffer_add(st->evbuf, st->buf, ret);
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBEVENT2_OLD
|
||||||
|
evhttp_send_reply_chunk(st->req, st->evbuf);
|
||||||
|
|
||||||
|
struct evhttp_connection *evcon = evhttp_request_get_connection(st->req);
|
||||||
|
struct bufferevent *bufev = evhttp_connection_get_bufferevent(evcon);
|
||||||
|
|
||||||
|
g_st = st; // Can't pass st to callback so use global - limits libevent 2.0 to a single stream
|
||||||
|
bufev->writecb = stream_chunk_resched_cb_wrapper;
|
||||||
|
#else
|
||||||
evhttp_send_reply_chunk_with_cb(st->req, st->evbuf, stream_chunk_resched_cb, st);
|
evhttp_send_reply_chunk_with_cb(st->req, st->evbuf, stream_chunk_resched_cb, st);
|
||||||
|
#endif
|
||||||
|
|
||||||
st->offset += ret;
|
st->offset += ret;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user