Skip to content

Commit 0a64272

Browse files
committed
libav* autodetection
I’ll give it another shot. ffmpeg’s doc/developer.texi states their micro version always starts at 100 for this very reason. Use that to detect ffmpeg and guess its version by looking at major and minor version numbers. Let’s hope this works.
1 parent 947b381 commit 0a64272

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

Makefile

+1-23
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ LIBDIR:=${PREFIX}/lib
66
INCDIR:=${PREFIX}/include
77
MANDIR:=${PREFIX}/share/man
88
DYNLINK:=0
9-
# Choose the libav implementation your system is using by uncommenting one line
10-
# below. These versions are supported:
11-
#LIBAV:=ffmpeg2.2
12-
#LIBAV:=ffmpeg2.1
13-
#LIBAV:=ffmpeg1.2
14-
#LIBAV:=libav10
15-
#LIBAV:=libav9
169

1710
# Respect environment variables set by user; does not work with :=
1811
ifeq (${CFLAGS},)
@@ -92,25 +85,10 @@ LIBGCRYPT_LDFLAGS:=-lgcrypt
9285
LIBJSONC_CFLAGS:=$(shell pkg-config --cflags json-c 2>/dev/null || pkg-config --cflags json)
9386
LIBJSONC_LDFLAGS:=$(shell pkg-config --libs json-c 2>/dev/null || pkg-config --libs json)
9487

95-
# libav* quirks
96-
ifeq (${LIBAV}, ffmpeg2.2)
97-
EXTRA_CFLAGS:=-DHAVE_AVFILTER_GRAPH_SEND_COMMAND
98-
else ifeq (${LIBAV}, ffmpeg2.1)
99-
EXTRA_CFLAGS:=
100-
else ifeq (${LIBAV}, ffmpeg1.2)
101-
EXTRA_CFLAGS:=-DHAVE_AV_BUFFERSINK_GET_BUFFER_REF -DHAVE_LIBAVFILTER_AVCODEC_H
102-
else ifeq (${LIBAV}, libav10)
103-
EXTRA_CFLAGS:=
104-
else ifeq (${LIBAV}, libav9)
105-
EXTRA_CFLAGS:=
106-
else
107-
$(error Please choose a valid libav implementation at the top of this file)
108-
endif
109-
11088
# combine all flags
11189
ALL_CFLAGS:=${CFLAGS} -I ${LIBPIANO_INCLUDE} -I ${LIBWAITRESS_INCLUDE} \
11290
${LIBAV_CFLAGS} ${LIBGNUTLS_CFLAGS} \
113-
${LIBGCRYPT_CFLAGS} ${LIBJSONC_CFLAGS} ${EXTRA_CFLAGS}
91+
${LIBGCRYPT_CFLAGS} ${LIBJSONC_CFLAGS}
11492
ALL_LDFLAGS:=${LDFLAGS} -lao -lpthread -lm \
11593
${LIBAV_LDFLAGS} ${LIBGNUTLS_LDFLAGS} \
11694
${LIBGCRYPT_LDFLAGS} ${LIBJSONC_LDFLAGS}

src/player.c

+20
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ THE SOFTWARE.
3131
#include <assert.h>
3232
#include <arpa/inet.h>
3333

34+
/* ffmpeg/libav quirks
35+
* ffmpeg’s micro versions always start at 100, that’s how we can distinguish
36+
* ffmpeg and libav */
37+
#include <libavfilter/version.h>
38+
/* ffmpeg 2.2 */
39+
#if LIBAVFILTER_VERSION_MAJOR == 4 && \
40+
LIBAVFILTER_VERSION_MINOR <= 2 && \
41+
LIBAVFILTER_VERSION_MICRO >= 100
42+
#define HAVE_AVFILTER_GRAPH_SEND_COMMAND
43+
#endif
44+
45+
/* ffmpeg 1.2 */
46+
#if LIBAVFILTER_VERSION_MAJOR == 3 && \
47+
LIBAVFILTER_VERSION_MINOR <= 42 && \
48+
LIBAVFILTER_VERSION_MINOR > 32 && \
49+
LIBAVFILTER_VERSION_MICRO >= 100
50+
#define HAVE_AV_BUFFERSINK_GET_BUFFER_REF
51+
#define HAVE_LIBAVFILTER_AVCODEC_H
52+
#endif
53+
3454
#include <ao/ao.h>
3555
#include <libavcodec/avcodec.h>
3656
#include <libavformat/avformat.h>

0 commit comments

Comments
 (0)