Skip to content

Commit

Permalink
Drop support for libavformat versions < 53 (issue #128)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejurgensen committed Apr 12, 2015
1 parent 8a09948 commit 2d8a6a7
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 205 deletions.
8 changes: 0 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,6 @@ AC_CHECK_LIB([avcodec], [avcodec_find_best_pix_fmt_of_list],
AC_DEFINE(HAVE_FFMPEG, 1, [Define to 1 if you have ffmpeg (and not libav).]))
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 ])

PKG_CHECK_MODULES(LIBEVENT, [ libevent >= 2 ],
Expand Down
8 changes: 1 addition & 7 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ if COND_OSS4
OSS4_SRC=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

if COND_LIBEVENT1
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
Expand Down Expand Up @@ -105,7 +99,7 @@ forked_daapd_SOURCES = main.c \
mdns_avahi.c mdns.h \
remote_pairing.c remote_pairing.h \
$(EVHTTP_SRC) \
$(FFURL_SRC) $(AVIO_SRC) \
avio_evbuffer.c avio_evbuffer.h \
httpd.c httpd.h \
httpd_rsp.c httpd_rsp.h \
httpd_daap.c httpd_daap.h \
Expand Down
32 changes: 1 addition & 31 deletions src/artwork.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
#include "player.h"
#include "http.h"

#if LIBAVFORMAT_VERSION_MAJOR >= 53
# include "avio_evbuffer.h"
#endif
#include "avio_evbuffer.h"
#include "artwork.h"

#ifndef HAVE_LIBEVENT2
Expand Down Expand Up @@ -207,12 +205,7 @@ artwork_rescale(struct evbuffer *evbuf, AVFormatContext *src_ctx, int s, int out
}

/* Set up output */
#if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 52 && LIBAVFORMAT_VERSION_MINOR >= 45)
/* FFmpeg 0.6 */
dst_fmt = av_guess_format("image2", NULL, NULL);
#else
dst_fmt = guess_format("image2", NULL, NULL);
#endif
if (!dst_fmt)
{
DPRINTF(E_LOG, L_ART, "ffmpeg image2 muxer not available\n");
Expand Down Expand Up @@ -255,18 +248,7 @@ artwork_rescale(struct evbuffer *evbuf, AVFormatContext *src_ctx, int s, int out

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)))
{
DPRINTF(E_LOG, L_ART, "Output artwork URL too long\n");

ret = -1;
goto out_free_dst_ctx;
}
#endif

#if LIBAVFORMAT_VERSION_MAJOR >= 54 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR >= 21)
dst_st = avformat_new_stream(dst_ctx, NULL);
Expand Down Expand Up @@ -445,11 +427,7 @@ artwork_rescale(struct evbuffer *evbuf, AVFormatContext *src_ctx, int s, int out
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");
Expand All @@ -468,11 +446,7 @@ artwork_rescale(struct evbuffer *evbuf, AVFormatContext *src_ctx, int s, int out
{
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;
Expand Down Expand Up @@ -560,11 +534,7 @@ artwork_rescale(struct evbuffer *evbuf, AVFormatContext *src_ctx, int s, int out
}

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:
Expand Down
137 changes: 0 additions & 137 deletions src/ffmpeg_url_evbuffer.c

This file was deleted.

8 changes: 0 additions & 8 deletions src/ffmpeg_url_evbuffer.h

This file was deleted.

8 changes: 0 additions & 8 deletions src/filescanner_ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,7 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi)

#if 0
/* Dump input format as determined by ffmpeg */
# if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 52 && LIBAVFORMAT_VERSION_MINOR >= 101)
av_dump_format(ctx, 0, file, 0);
# else
dump_format(ctx, 0, file, FALSE);
# endif
#endif

DPRINTF(E_DBG, L_SCAN, "File has %d streams\n", ctx->nb_streams);
Expand Down Expand Up @@ -748,10 +744,6 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi)
DPRINTF(E_DBG, L_SCAN, "Picked up %d tags with extra md_map\n", ret);
}

#if LIBAVFORMAT_VERSION_MAJOR < 53
av_metadata_conv(ctx, NULL, ctx->iformat->metadata_conv);
#endif

ret = extract_metadata(mfi, ctx, audio_stream, video_stream, md_map_generic);
mdcount += ret;

Expand Down
6 changes: 0 additions & 6 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL;
#include "remote_pairing.h"
#include "player.h"
#include "worker.h"
#if LIBAVFORMAT_VERSION_MAJOR < 53
# include "ffmpeg_url_evbuffer.h"
#endif

#ifdef LASTFM
# include "lastfm.h"
Expand Down Expand Up @@ -592,9 +589,6 @@ main(int argc, char **argv)
avformat_network_init();
#endif
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);
Expand Down

0 comments on commit 2d8a6a7

Please sign in to comment.