Fixed avcodec version test.
@@ -876,7 +876,7 @@ find_feature(FAAC ${FAAC_FEATURE_TYPE} ${FAAC_FEATURE_PURPOSE} ${FAAC_FEATURE_DE
find_feature(GSSAPI ${GSSAPI_FEATURE_TYPE} ${GSSAPI_FEATURE_PURPOSE} ${GSSAPI_FEATURE_DESCRIPTION})
-if (WITH_FFMPEG AND NOT FFMPEG_FOUND)
+if ((WITH_FFMPEG OR WITH_DSP_FFMPEG) AND NOT FFMPEG_FOUND)
message(FATAL_ERROR "FFMPEG support requested but not detected")
endif()
set(WITH_FFMPEG ${FFMPEG_FOUND})
@@ -886,11 +886,24 @@ set(WITH_FFMPEG ${FFMPEG_FOUND})
if (WITH_DSP_FFMPEG)
# Deactivate FFmpeg backend for sound, if the version is too old.
# See libfreerdp/codec/dsp_ffmpeg.h
- check_symbol_exists(LIBAVCODEC_VERSION_MAJOR "libavcodec/version.h" AVCODEC_VERSION_MAJOR)
- check_symbol_exists(LIBAVCODEC_VERSION_MINOR "libavcodec/version.h" AVCODEC_VERSION_MINOR)
- check_symbol_exists(LIBAVCODEC_VERSION_MICRO "libavcodec/version.h" AVCODEC_VERSION_MICRO)
- if (AVCODEC_VERSION_MAJOR LESS 57 OR AVCODEC_VERSION_MINOR LESS 48 OR AVCODEC_VERSION_MICRO LESS 101)
- message("FFmpeg version detected ${}.${}.${} is too old. (Require at least 57.48.101 for sound). Deactivating")
+ file(STRINGS "${AVCODEC_INCLUDE_DIR}/libavcodec/version.h" AV_VERSION_FILE REGEX "LIBAVCODEC_VERSION_M[A-Z]+[\t ]*[0-9]+")
+ FOREACH(item ${AV_VERSION_FILE})
+ STRING(REGEX MATCH "LIBAVCODEC_VERSION_M[A-Z]+[\t ]*[0-9]+" litem ${item})
+ IF(litem)
+ string(REGEX REPLACE "[ \t]+" ";" VSPLIT_LINE ${litem})
+ list(LENGTH VSPLIT_LINE VSPLIT_LINE_LEN)
+ if (NOT "${VSPLIT_LINE_LEN}" EQUAL "2")
+ message(ERROR "invalid entry in libavcodec version header ${item}")
+ endif(NOT "${VSPLIT_LINE_LEN}" EQUAL "2")
+ list(GET VSPLIT_LINE 0 VNAME)
+ list(GET VSPLIT_LINE 1 VVALUE)
+ set(${VNAME} ${VVALUE})
+ ENDIF(litem)
+ ENDFOREACH(item ${AV_VERSION_FILE})
+
+ set(AVCODEC_VERSION "${LIBAVCODEC_VERSION_MAJOR}.${LIBAVCODEC_VERSION_MINOR}.${LIBAVCODEC_VERSION_MICRO}")
+ if (AVCODEC_VERSION VERSION_LESS "57.48.101")
+ message(WARNING "FFmpeg version detected (${AVCODEC_VERSION}) is too old. (Require at least 57.48.101 for sound). Deactivating")
set(WITH_DSP_FFMPEG OFF)
endif()
endif (WITH_DSP_FFMPEG)
