From d9fb350487ebc3af01498d352de66248b9b26907 Mon Sep 17 00:00:00 2001 From: Sandro Kalatozishvili Date: Wed, 6 Nov 2024 17:13:32 +0400 Subject: [PATCH] Better way to detect new API --- src/encoder.c | 10 +++++----- src/encoder.h | 4 ++++ src/stdinc.h | 13 ++++++------- src/version.h | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/encoder.c b/src/encoder.c index cafa80f..8791719 100644 --- a/src/encoder.c +++ b/src/encoder.c @@ -114,7 +114,7 @@ XSTATUS XEncoder_RestartCodec(xencoder_t *pEncoder, int nStreamIndex) xstatus_t *pStatus = &pEncoder->status; xstream_t *pStream = XStreams_GetByDstIndex(&pEncoder->streams, nStreamIndex); - XASSERT(pStream, XStat_ErrCb(pStatus, "Stream is not found: %s", nStreamIndex)); + XASSERT(pStream, XStat_ErrCb(pStatus, "Stream is not found: dst(%d)", nStreamIndex)); if (pStream->pCodecCtx != NULL) { @@ -385,7 +385,7 @@ XSTATUS XEncoder_FixTS(xencoder_t *pEncoder, AVPacket *pPacket, xstream_t *pStre if (pStream == NULL) { pStream = XStreams_GetByDstIndex(&pEncoder->streams, pPacket->stream_index); - XASSERT(pStream, XStat_ErrCb(pStatus, "Stream is not found: %d", pPacket->stream_index)); + XASSERT(pStream, XStat_ErrCb(pStatus, "Stream is not found: dst(%d)", pPacket->stream_index)); } if (pEncoder->nTSFix && @@ -414,8 +414,8 @@ XSTATUS XEncoder_WritePacket(xencoder_t *pEncoder, AVPacket *pPacket) XASSERT(pEncoder->bOutputOpen, XStat_ErrCb(pStatus, "Output context is not open")); xstream_t *pStream = XStreams_GetByDstIndex(&pEncoder->streams, pPacket->stream_index); - XASSERT(pStream, XStat_ErrCb(pStatus, "Stream is not found: %d", pPacket->stream_index)); - XASSERT(pStream->pAvStream, XStat_ErrCb(pStatus, "Stream is not open: %d", pStream->nDstIndex)); + XASSERT(pStream, XStat_ErrCb(pStatus, "Stream is not found: dst(%d)", pPacket->stream_index)); + XASSERT(pStream->pAvStream, XStat_ErrCb(pStatus, "Stream is not open: dst(%d)", pStream->nDstIndex)); /* Rescale timestamps and fix non motion PTS/DTS if detected */ XEncoder_RescaleTS(pEncoder, pPacket, pStream); @@ -425,7 +425,7 @@ XSTATUS XEncoder_WritePacket(xencoder_t *pEncoder, AVPacket *pPacket) pStream->nLastDTS = pPacket->dts; pStatus->nAVStatus = av_interleaved_write_frame(pEncoder->pFmtCtx, pPacket); - XASSERT((pStatus->nAVStatus >= 0), XStat_ErrCb(pStatus, "Failed to write packet")); + XASSERT((pStatus->nAVStatus >= 0), XStat_ErrCb(pStatus, "Failed to write packet: dst(%d)", pPacket->stream_index)); pStream->nPacketCount++; return XSTDOK; diff --git a/src/encoder.h b/src/encoder.h index a364163..4498506 100644 --- a/src/encoder.h +++ b/src/encoder.h @@ -24,12 +24,16 @@ extern "C" { 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); +<<<<<<< HEAD #ifdef __APPLE__ 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); #endif +======= +typedef int(*xmuxer_cb_t)(void *pUserCtx, const uint8_t *pData, int nSize); +>>>>>>> 58494e1 (Better way to detect new API) #define XENCODER_IO_SIZE (1024 * 64) diff --git a/src/stdinc.h b/src/stdinc.h index aa6fe13..bf988e4 100644 --- a/src/stdinc.h +++ b/src/stdinc.h @@ -29,19 +29,18 @@ #include #include -/* - If FF_API_OLD_CHANNEL_LAYOUT is defined, that means 'channel' and - 'channel_layout' members of AVCodecContext structure are deprecated - and we need to use the new AVChannelLayout structure instead. -*/ +#define XMEDIA_AVCODEC_VER_AT_LEAST(major,minor) (LIBAVCODEC_VERSION_MAJOR > major || \ + (LIBAVCODEC_VERSION_MAJOR == major && \ + LIBAVCODEC_VERSION_MINOR >= minor)) + #ifndef XCODEC_USE_NEW_CHANNEL - #if defined(FF_API_OLD_CHANNEL_LAYOUT) || defined(__APPLE__) + #if XMEDIA_AVCODEC_VER_AT_LEAST(5, 7) #define XCODEC_USE_NEW_CHANNEL 1 #endif #endif #ifndef XCODEC_USE_NEW_FIFO - #if defined(FF_API_FIFO_OLD_API) || defined(__APPLE__) + #if XMEDIA_AVCODEC_VER_AT_LEAST(5, 7) #define XCODEC_USE_NEW_FIFO 1 #endif #endif diff --git a/src/version.h b/src/version.h index 3011000..2a31bbf 100644 --- a/src/version.h +++ b/src/version.h @@ -14,7 +14,7 @@ #define XMEDIA_VERSION_MAX 1 #define XMEDIA_VERSION_MIN 2 -#define XMEDIA_BUILD_NUMBER 14 +#define XMEDIA_BUILD_NUMBER 15 #ifdef __cplusplus extern "C" {