diff --git a/linux.sh b/linux.sh index 7e0eeaa..02656fb 100755 --- a/linux.sh +++ b/linux.sh @@ -203,3 +203,17 @@ for run_arch in {0..12}; do done fi done + +# BUILD FFMPEG-KIT BUNDLE +if [[ -n ${TARGET_ARCH_LIST[0]} ]]; then + + echo -e -n "\nCreating the bundle under prebuilt: " + + echo -e "DEBUG: Creating the bundle directory\n" 1>>"${BASEDIR}"/build.log 2>&1 + + initialize_folder "${BASEDIR}/prebuilt/$(get_bundle_directory)" + + create_linux_bundle + + echo -e "ok\n" +fi diff --git a/linux/configure b/linux/configure index f29ea8e..b954761 100755 --- a/linux/configure +++ b/linux/configure @@ -6220,7 +6220,7 @@ CFLAGS="$cflags_bckup" FFMPEG_LIBS="-lavcodec -lavfilter -lavformat -lavutil -lswscale -lswresample" -VERSION_INFO="5:5:1" +VERSION_INFO="9:1:5" case `pwd` in diff --git a/linux/configure.ac b/linux/configure.ac index cac0cef..14a4dbd 100644 --- a/linux/configure.ac +++ b/linux/configure.ac @@ -27,7 +27,7 @@ CFLAGS="$cflags_bckup" FFMPEG_LIBS="-lavcodec -lavfilter -lavformat -lavutil -lswscale -lswresample" AC_SUBST(FFMPEG_LIBS) -VERSION_INFO="5:5:1" +VERSION_INFO="9:1:5" AC_SUBST(VERSION_INFO) LT_INIT diff --git a/linux/src/FFmpegKit.cpp b/linux/src/FFmpegKit.cpp index 75b02d1..a6c1a42 100644 --- a/linux/src/FFmpegKit.cpp +++ b/linux/src/FFmpegKit.cpp @@ -17,7 +17,9 @@ * along with FFmpegKit. If not, see . */ -#include "fftools_ffmpeg.h" +extern "C" { + #include "fftools_ffmpeg.h" +} #include "ArchDetect.h" #include "FFmpegKit.h" #include "FFmpegKitConfig.h" diff --git a/linux/src/FFmpegKitConfig.cpp b/linux/src/FFmpegKitConfig.cpp index d729d1e..3b18766 100644 --- a/linux/src/FFmpegKitConfig.cpp +++ b/linux/src/FFmpegKitConfig.cpp @@ -19,9 +19,11 @@ #include #include -#include "libavutil/ffversion.h" -#include "libavutil/bprint.h" -#include "fftools_ffmpeg.h" +extern "C" { + #include "libavutil/ffversion.h" + #include "libavutil/bprint.h" + #include "fftools_ffmpeg.h" +} #include "ArchDetect.h" #include "FFmpegKit.h" #include "FFmpegKitConfig.h" @@ -91,12 +93,22 @@ __thread volatile long globalSessionId = 0; /** Holds the default log level */ int configuredLogLevel = ffmpegkit::LevelAVLogInfo; +#ifdef __cplusplus +extern "C" { +#endif + /** Forward declaration for function defined in fftools_ffmpeg.c */ int ffmpeg_execute(int argc, char **argv); /** Forward declaration for function defined in fftools_ffprobe.c */ int ffprobe_execute(int argc, char **argv); +void ffmpegkit_log_callback_function(void *ptr, int level, const char* format, va_list vargs); + +#ifdef __cplusplus +} +#endif + static std::once_flag ffmpegKitInitializerFlag; void* ffmpegKitInitialize(); @@ -391,12 +403,16 @@ static void removeSession(long sessionId) { std::atomic_store(&sessionMap[sessionId % SESSION_MAP_SIZE], 0); } +#ifdef __cplusplus +extern "C" { +#endif + /** * Adds a cancel session request to the session map. * * @param sessionId session id */ -static void cancelSession(long sessionId) { +void cancelSession(long sessionId) { std::atomic_store(&sessionMap[sessionId % SESSION_MAP_SIZE], 2); } @@ -406,7 +422,7 @@ static void cancelSession(long sessionId) { * @param sessionId session id * @return 1 if exists, false otherwise */ -static int cancelRequested(long sessionId) { +int cancelRequested(long sessionId) { if (std::atomic_load(&sessionMap[sessionId % SESSION_MAP_SIZE]) == 2) { return 1; } else { @@ -414,6 +430,10 @@ static int cancelRequested(long sessionId) { } } +#ifdef __cplusplus +} +#endif + /** * Resets the number of messages in transmit for this session. * @@ -1182,6 +1202,8 @@ std::shared_ptr ffmpegkit::FFmpegKitConfig::getLastCompleted return session; } } + + return nullptr; } std::shared_ptr>> ffmpegkit::FFmpegKitConfig::getSessions() { diff --git a/scripts/function-apple.sh b/scripts/function-apple.sh index 1d74b93..0d69d3e 100755 --- a/scripts/function-apple.sh +++ b/scripts/function-apple.sh @@ -182,23 +182,6 @@ is_apple_architecture_variant_supported() { echo "${SUPPORTED}" } -# -# 1. folder path -# -initialize_folder() { - rm -rf "$1" 1>>"${BASEDIR}"/build.log 2>&1 - if [[ $? -ne 0 ]]; then - return 1 - fi - - mkdir -p "$1" 1>>"${BASEDIR}"/build.log 2>&1 - if [[ $? -ne 0 ]]; then - return 1 - fi - - return 0 -} - # # 1. architecture variant # diff --git a/scripts/function-linux.sh b/scripts/function-linux.sh index 494544b..901d0b4 100755 --- a/scripts/function-linux.sh +++ b/scripts/function-linux.sh @@ -9,7 +9,7 @@ enable_default_linux_architectures() { } get_ffmpeg_kit_version() { - local FFMPEG_KIT_VERSION=$(grep '#define FFMPEG_KIT_VERSION' "${BASEDIR}"/linux/src/main/cpp/ffmpegkit.h | grep -Eo '\".*\"' | sed -e 's/\"//g') + local FFMPEG_KIT_VERSION=$(grep -Eo 'FFmpegKitVersion = .*' "${BASEDIR}/linux/src/FFmpegKitConfig.h" 2>>"${BASEDIR}"/build.log | grep -Eo ' \".*' | tr -d '"; ') echo "${FFMPEG_KIT_VERSION}" } @@ -90,6 +90,72 @@ enable_lts_build() { export FFMPEG_KIT_LTS_BUILD="1" } +install_pkg_config_file() { + local FILE_NAME="$1" + local SOURCE="${INSTALL_PKG_CONFIG_DIR}/${FILE_NAME}" + local DESTINATION="${FFMPEG_KIT_BUNDLE_PKG_CONFIG_DIRECTORY}/${FILE_NAME}" + + # DELETE OLD FILE + rm -f "$DESTINATION" 2>>"${BASEDIR}"/build.log + if [[ $? -ne 0 ]]; then + echo -e "failed\n\nSee build.log for details\n" + exit 1 + fi + + # INSTALL THE NEW FILE + cp "$SOURCE" "$DESTINATION" 2>>"${BASEDIR}"/build.log + if [[ $? -ne 0 ]]; then + echo -e "failed\n\nSee build.log for details\n" + exit 1 + fi + + # UPDATE PATHS + ${SED_INLINE} "s|${LIB_INSTALL_BASE}/ffmpeg-kit|${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit|g" "$DESTINATION" 1>>"${BASEDIR}"/build.log 2>&1 || return 1 + ${SED_INLINE} "s|${LIB_INSTALL_BASE}/ffmpeg|${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit|g" "$DESTINATION" 1>>"${BASEDIR}"/build.log 2>&1 || return 1 +} + +get_bundle_directory() { + local LTS_POSTFIX="" + if [[ -n ${FFMPEG_KIT_LTS_BUILD} ]]; then + LTS_POSTFIX="-lts" + fi + + echo "bundle-linux${LTS_POSTFIX}" +} + +create_linux_bundle() { + set_toolchain_paths "" + + local FFMPEG_KIT_VERSION=$(get_ffmpeg_kit_version) + + local FFMPEG_KIT_BUNDLE_DIRECTORY="${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit" + local FFMPEG_KIT_BUNDLE_INCLUDE_DIRECTORY="${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/include" + local FFMPEG_KIT_BUNDLE_LIB_DIRECTORY="${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/lib" + local FFMPEG_KIT_BUNDLE_PKG_CONFIG_DIRECTORY="${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/pkgconfig" + + initialize_folder "${FFMPEG_KIT_BUNDLE_INCLUDE_DIRECTORY}" + initialize_folder "${FFMPEG_KIT_BUNDLE_LIB_DIRECTORY}" + initialize_folder "${FFMPEG_KIT_BUNDLE_PKG_CONFIG_DIRECTORY}" + + # COPY HEADERS + cp -r -P "${LIB_INSTALL_BASE}"/ffmpeg-kit/include/* "${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/include" 2>>"${BASEDIR}"/build.log + cp -r -P "${LIB_INSTALL_BASE}"/ffmpeg/include/* "${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/include" 2>>"${BASEDIR}"/build.log + cp -r -P ${FFMPEG_KIT_TMPDIR}/source/rapidjson/include/rapidjson "${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/include" 2>>"${BASEDIR}"/build.log + + # COPY LIBS + cp -P "${LIB_INSTALL_BASE}"/ffmpeg-kit/lib/* "${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/lib" 2>>"${BASEDIR}"/build.log + cp -P "${LIB_INSTALL_BASE}"/ffmpeg/lib/* "${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/lib" 2>>"${BASEDIR}"/build.log + + install_pkg_config_file "libavformat.pc" + install_pkg_config_file "libswresample.pc" + install_pkg_config_file "libswscale.pc" + install_pkg_config_file "libavdevice.pc" + install_pkg_config_file "libavfilter.pc" + install_pkg_config_file "libavcodec.pc" + install_pkg_config_file "libavutil.pc" + install_pkg_config_file "ffmpeg-kit.pc" +} + get_cmake_system_processor() { case ${ARCH} in x86-64) @@ -309,6 +375,25 @@ prefix = '${LIB_INSTALL_PREFIX}' EOF } +create_ffmpegkit_package_config() { + local FFMPEGKIT_VERSION="$1" + + cat >"${INSTALL_PKG_CONFIG_DIR}/ffmpeg-kit.pc" <>"${BASEDIR}"/build.log + cp "$1" "$2" 2>>"${BASEDIR}"/build.log } # @@ -2438,3 +2438,20 @@ command_exists() { echo 1 fi } + +# +# 1. folder path +# +initialize_folder() { + rm -rf "$1" 1>>"${BASEDIR}"/build.log 2>&1 + if [[ $? -ne 0 ]]; then + return 1 + fi + + mkdir -p "$1" 1>>"${BASEDIR}"/build.log 2>&1 + if [[ $? -ne 0 ]]; then + return 1 + fi + + return 0 +} diff --git a/scripts/linux/ffmpeg-kit.sh b/scripts/linux/ffmpeg-kit.sh index 4548d16..b419f7c 100755 --- a/scripts/linux/ffmpeg-kit.sh +++ b/scripts/linux/ffmpeg-kit.sh @@ -61,6 +61,9 @@ make -j$(get_cpu_count) 1>>"${BASEDIR}"/build.log 2>&1 make install 1>>"${BASEDIR}"/build.log 2>&1 +# CREATE PACKAGE CONFIG MANUALLY +create_ffmpegkit_package_config "$(get_ffmpeg_kit_version)" || return 1 + if [ $? -eq 0 ]; then echo "ok" else diff --git a/scripts/linux/ffmpeg.sh b/scripts/linux/ffmpeg.sh index e330a1e..b708339 100755 --- a/scripts/linux/ffmpeg.sh +++ b/scripts/linux/ffmpeg.sh @@ -449,6 +449,15 @@ if [[ $? -ne 0 ]]; then exit 1 fi +# MANUALLY COPY PKG-CONFIG FILES +overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libavformat.pc "${INSTALL_PKG_CONFIG_DIR}/libavformat.pc" || return 1 +overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libswresample.pc "${INSTALL_PKG_CONFIG_DIR}/libswresample.pc" || return 1 +overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libswscale.pc "${INSTALL_PKG_CONFIG_DIR}/libswscale.pc" || return 1 +overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libavdevice.pc "${INSTALL_PKG_CONFIG_DIR}/libavdevice.pc" || return 1 +overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libavfilter.pc "${INSTALL_PKG_CONFIG_DIR}/libavfilter.pc" || return 1 +overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libavcodec.pc "${INSTALL_PKG_CONFIG_DIR}/libavcodec.pc" || return 1 +overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libavutil.pc "${INSTALL_PKG_CONFIG_DIR}/libavutil.pc" || return 1 + # MANUALLY ADD REQUIRED HEADERS mkdir -p "${FFMPEG_LIBRARY_PATH}"/include/libavutil/x86 1>>"${BASEDIR}"/build.log 2>&1 mkdir -p "${FFMPEG_LIBRARY_PATH}"/include/libavutil/arm 1>>"${BASEDIR}"/build.log 2>&1