Skip to content

Commit

Permalink
Libavformat version guard for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Kalatozishvili committed Nov 23, 2024
1 parent 131daea commit dc7a88d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion example/xmedia.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static void clear_cb(xarray_data_t *pArrData)
free(pArrData->pData);
}

#if XMEDIA_AVCODEC_VER_AT_LEAST(60, 31)
#if XMEDIA_AVFORMAT_AT_LEAST(60, 16) && !defined FF_API_AVIO_WRITE_NONCONST
static int muxer_cb(void *pCtx, const uint8_t *pData, int nSize)
#else
static int muxer_cb(void *pCtx, uint8_t *pData, int nSize)
Expand Down
2 changes: 1 addition & 1 deletion src/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ typedef void(*xencoder_stat_cb_t)(void *pUserCtx, const char *pStatus);
typedef void(*xencoder_err_cb_t)(void *pUserCtx, const char *pErrStr);
typedef int(*xencoder_pkt_cb_t)(void *pUserCtx, AVPacket *pPacket);

#if XMEDIA_AVCODEC_VER_AT_LEAST(60, 31)
#if XMEDIA_AVFORMAT_AT_LEAST(60, 31) && !defined FF_API_AVIO_WRITE_NONCONST
typedef int(*xmuxer_cb_t)(void *pUserCtx, const uint8_t *pData, int nSize);
#else
typedef int(*xmuxer_cb_t)(void *pUserCtx, uint8_t *pData, int nSize);
Expand Down
14 changes: 9 additions & 5 deletions src/stdinc.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,22 @@
#include <libswresample/swresample.h>
#include <libavutil/opt.h>

#define XMEDIA_AVCODEC_VER_AT_LEAST(major,minor) (LIBAVCODEC_VERSION_MAJOR > major || \
(LIBAVCODEC_VERSION_MAJOR == major && \
LIBAVCODEC_VERSION_MINOR >= minor))
#define XMEDIA_AVCODEC_AT_LEAST(major,minor) (LIBAVCODEC_VERSION_MAJOR > major || \
(LIBAVCODEC_VERSION_MAJOR == major && \
LIBAVCODEC_VERSION_MINOR >= minor))

#define XMEDIA_AVFORMAT_AT_LEAST(major,minor) (LIBAVFORMAT_VERSION_MAJOR > major || \
(LIBAVFORMAT_VERSION_MAJOR == major && \
LIBAVFORMAT_VERSION_MINOR >= minor))

#ifndef XCODEC_USE_NEW_CHANNEL
#if XMEDIA_AVCODEC_VER_AT_LEAST(59, 24)
#if XMEDIA_AVCODEC_AT_LEAST(59, 24)
#define XCODEC_USE_NEW_CHANNEL 1
#endif
#endif

#ifndef XCODEC_USE_NEW_FIFO
#if XMEDIA_AVCODEC_VER_AT_LEAST(59, 24)
#if XMEDIA_AVCODEC_AT_LEAST(59, 24)
#define XCODEC_USE_NEW_FIFO 1
#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#define XMEDIA_VERSION_MAX 1
#define XMEDIA_VERSION_MIN 2
#define XMEDIA_BUILD_NUMBER 17
#define XMEDIA_BUILD_NUMBER 18

#ifdef __cplusplus
extern "C" {
Expand Down

0 comments on commit dc7a88d

Please sign in to comment.