diff --git a/configure.in b/configure.in index 7f1e14b7..145bac52 100644 --- a/configure.in +++ b/configure.in @@ -136,6 +136,14 @@ save_LIBS="$LIBS" AC_CHECK_LIB([avcodec], [av_lockmgr_register], , AC_MSG_ERROR([libav (ffmpeg) >= 0.5.1 required])) LIBS="$save_LIBS" +# Check for libavformat >= 53; url -> avio switch +_PKG_CONFIG([libavformat_VERSION], [atleast-version=53], [libavformat]) +if test $pkg_failed = yes; then + AM_CONDITIONAL(COND_AVIO, false) +else + AM_CONDITIONAL(COND_AVIO, true) +fi + PKG_CHECK_MODULES(MINIXML, [ mxml ]) AC_CHECK_HEADER(event.h, , AC_MSG_ERROR([event.h not found])) diff --git a/src/Makefile.am b/src/Makefile.am index 0d6762b2..be8a3553 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,6 +21,12 @@ if COND_OSS4 OSS4SRC=laudio_oss4.c endif +if COND_AVIO +AVIO_SRC=avio_evbuffer.c avio_evbuffer.h +else +FFURL_SRC=ffmpeg_url_evbuffer.c ffmpeg_url_evbuffer.h +endif + GPERF_FILES = \ daap_query.gperf \ rsp_query.gperf \ @@ -71,7 +77,7 @@ forked_daapd_SOURCES = main.c \ remote_pairing.c remote_pairing.h \ evhttp/http.c evhttp/evhttp.h \ evhttp/http-internal.h evhttp/log.h \ - ffmpeg_url_evbuffer.c ffmpeg_url_evbuffer.h \ + $(FFURL_SRC) $(AVIO_SRC) \ httpd.c httpd.h \ httpd_rsp.c httpd_rsp.h \ httpd_daap.c httpd_daap.h \ diff --git a/src/artwork.c b/src/artwork.c index d41f8156..8d25580d 100644 --- a/src/artwork.c +++ b/src/artwork.c @@ -37,6 +37,9 @@ #include "db.h" #include "logger.h" +#if LIBAVFORMAT_VERSION_MAJOR >= 53 +# include "avio_evbuffer.h" +#endif #include "artwork.h" @@ -196,6 +199,9 @@ artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, int forma dst_ctx->oformat = dst_fmt; +#if LIBAVFORMAT_VERSION_MAJOR >= 53 + dst_fmt->flags &= ~AVFMT_NOFILE; +#else ret = snprintf(dst_ctx->filename, sizeof(dst_ctx->filename), "evbuffer:%p", evbuf); if ((ret < 0) || (ret >= sizeof(dst_ctx->filename))) { @@ -204,6 +210,7 @@ artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, int forma ret = -1; goto out_free_dst_ctx; } +#endif dst_st = av_new_stream(dst_ctx, 0); if (!dst_st) @@ -357,7 +364,11 @@ artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, int forma av_free_packet(&pkt); /* Open output file */ +#if LIBAVFORMAT_VERSION_MAJOR >= 53 + dst_ctx->pb = avio_evbuffer_open(evbuf); +#else ret = url_fopen(&dst_ctx->pb, dst_ctx->filename, URL_WRONLY); +#endif if (ret < 0) { DPRINTF(E_LOG, L_ART, "Could not open artwork destination buffer\n"); @@ -376,7 +387,11 @@ artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, int forma { DPRINTF(E_LOG, L_ART, "Out of memory for encoded artwork buffer\n"); +#if LIBAVFORMAT_VERSION_MAJOR >= 53 + avio_evbuffer_close(dst_ctx->pb); +#else url_fclose(dst_ctx->pb); +#endif ret = -1; goto out_free_buf; @@ -441,7 +456,11 @@ artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, int forma } out_fclose_dst: +#if LIBAVFORMAT_VERSION_MAJOR >= 53 + avio_evbuffer_close(dst_ctx->pb); +#else url_fclose(dst_ctx->pb); +#endif av_free(outbuf); out_free_buf: diff --git a/src/main.c b/src/main.c index 31415924..465ca3b0 100644 --- a/src/main.c +++ b/src/main.c @@ -64,7 +64,9 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL; #include "mdns.h" #include "remote_pairing.h" #include "player.h" -#include "ffmpeg_url_evbuffer.h" +#if LIBAVFORMAT_VERSION_MAJOR < 53 +# include "ffmpeg_url_evbuffer.h" +#endif #define PIDFILE STATEDIR "/run/" PACKAGE ".pid" @@ -597,7 +599,9 @@ main(int argc, char **argv) av_register_all(); av_log_set_callback(logger_ffmpeg); +#if LIBAVFORMAT_VERSION_MAJOR < 53 register_ffmpeg_evbuffer_url_protocol(); +#endif /* Initialize libgcrypt */ gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);