diff --git a/android.sh b/android.sh index ed3ae8c..b8289fe 100755 --- a/android.sh +++ b/android.sh @@ -158,6 +158,14 @@ while [ ! $# -eq 0 ]; do EXTRA_LDFLAGS=$(echo $1 | sed -e 's/^--extra-ldflags=//g') export EXTRA_LDFLAGS="${EXTRA_LDFLAGS}" ;; + --version-*) + CUSTOM_VERSION_KEY=$(echo $1 | sed -e 's/^--version-//g;s/=.*$//g') + CUSTOM_VERSION_VALUE=$(echo $1 | sed -e 's/^--version-.*=//g') + + echo -e "INFO: Custom version detected: ${CUSTOM_VERSION_KEY} ${CUSTOM_VERSION_VALUE}\n" 1>>"${BASEDIR}"/build.log 2>&1 + + generate_custom_version_environment_variables "${CUSTOM_VERSION_KEY}" "${CUSTOM_VERSION_VALUE}" + ;; *) print_unknown_option "$1" ;; @@ -190,7 +198,7 @@ if [[ -n ${BUILD_FULL} ]]; then fi # DISABLE SPECIFIED LIBRARIES -for disabled_library in ${disabled_libraries[@]}; do +for disabled_library in "${disabled_libraries[@]}"; do set_library "${disabled_library}" 0 done @@ -371,7 +379,9 @@ if [[ -n ${ANDROID_ARCHITECTURES} ]]; then # BUILD NATIVE LIBRARY if [[ ${SKIP_ffmpeg_kit} -ne 1 ]]; then - if [ "$(is_darwin_arm64)" == "1" ]; then + + # NDK >= 24.0 DOES NOT REQUIRE arch -x86_64 ON DARWIN ARM64 HOSTS + if [[ "$(is_darwin_arm64)" == "1" ]] && [[ $(compare_versions "$DETECTED_NDK_VERSION" "24.0") -lt 1 ]]; then arch -x86_64 "${ANDROID_NDK_ROOT}"/ndk-build -B 1>>"${BASEDIR}"/build.log 2>&1 else "${ANDROID_NDK_ROOT}"/ndk-build -B 1>>"${BASEDIR}"/build.log 2>&1 diff --git a/android/ffmpeg-kit-android-lib/src/main/cpp/ffmpeg_context.h b/android/ffmpeg-kit-android-lib/src/main/cpp/ffmpeg_context.h index 8ec27ce..81d9a89 100644 --- a/android/ffmpeg-kit-android-lib/src/main/cpp/ffmpeg_context.h +++ b/android/ffmpeg-kit-android-lib/src/main/cpp/ffmpeg_context.h @@ -20,16 +20,15 @@ #ifndef FFMPEG_CONTEXT_H #define FFMPEG_CONTEXT_H -#if HAVE_TERMIOS_H -#include -#endif - #include "fftools_ffmpeg.h" #include "libavformat/avio.h" #include "libavutil/dict.h" extern __thread BenchmarkTimeStamps current_time; +#if HAVE_TERMIOS_H +#include extern __thread struct termios oldtty; +#endif extern __thread int restore_tty; extern __thread volatile int received_sigterm; extern __thread volatile int received_nb_signals; diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 771d299..64f9a59 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -57,7 +57,7 @@ include $(BUILD_SHARED_LIBRARY) $(call import-module, cpu-features) -MY_SRC_FILES := ffmpegkit.c ffprobekit.c ffmpegkit_exception.c fftools_cmdutils.c fftools_ffmpeg.c fftools_ffprobe.c fftools_ffmpeg_mux.c fftools_ffmpeg_mux_init.c fftools_ffmpeg_demux.c fftools_ffmpeg_enc.c fftools_ffmpeg_dec.c fftools_ffmpeg_opt.c fftools_opt_common.c fftools_ffmpeg_hw.c fftools_ffmpeg_filter.c fftools_objpool.c fftools_sync_queue.c fftools_thread_queue.c android_support.c +MY_SRC_FILES := ffmpegkit.c ffprobekit.c ffmpegkit_exception.c fftools_cmdutils.c fftools_ffmpeg.c fftools_ffprobe.c fftools_ffmpeg_mux.c fftools_ffmpeg_mux_init.c fftools_ffmpeg_demux.c fftools_ffmpeg_enc.c fftools_ffmpeg_dec.c fftools_ffmpeg_opt.c fftools_opt_common.c fftools_ffmpeg_hw.c fftools_ffmpeg_filter.c fftools_objpool.c fftools_sync_queue.c fftools_thread_queue.c android_support.c ffmpeg_context.c MY_CFLAGS := -Wall -Werror -Wno-unused-parameter -Wno-switch -Wno-sign-compare MY_LDLIBS := -llog -lz -landroid diff --git a/apple/src/FFmpegKit.m b/apple/src/FFmpegKit.m index d4f76c3..26e77c8 100644 --- a/apple/src/FFmpegKit.m +++ b/apple/src/FFmpegKit.m @@ -17,12 +17,12 @@ * along with FFmpegKit. If not, see . */ -#import "FFmpegKit.h" +#import "fftools_ffmpeg.h" #import "ArchDetect.h" #import "AtomicLong.h" +#import "FFmpegKit.h" #import "FFmpegKitConfig.h" #import "Packages.h" -#import "fftools_ffmpeg.h" @implementation FFmpegKit diff --git a/apple/src/FFprobeKit.m b/apple/src/FFprobeKit.m index 22b9da7..8fe56e8 100644 --- a/apple/src/FFprobeKit.m +++ b/apple/src/FFprobeKit.m @@ -17,10 +17,10 @@ * along with FFmpegKit. If not, see . */ -#import "FFprobeKit.h" +#import "fftools_ffmpeg.h" #import "FFmpegKit.h" #import "FFmpegKitConfig.h" -#import "fftools_ffmpeg.h" +#import "FFprobeKit.h" @implementation FFprobeKit diff --git a/apple/src/Log.h b/apple/src/Log.h index 35512f9..65ecf62 100644 --- a/apple/src/Log.h +++ b/apple/src/Log.h @@ -27,7 +27,7 @@ */ @interface Log : NSObject -- (instancetype)init:(long)sessionId:(int)level:(NSString *)message; +- (instancetype)init:(long)sessionId :(int)level :(NSString *)message; - (long)getSessionId; diff --git a/apple/src/Log.m b/apple/src/Log.m index 8a5d3e5..f970cb6 100644 --- a/apple/src/Log.m +++ b/apple/src/Log.m @@ -25,7 +25,7 @@ NSString *_message; } -- (instancetype)init:(long)sessionId:(int)level:(NSString *)message { +- (instancetype)init:(long)sessionId :(int)level :(NSString *)message { self = [super init]; if (self) { _sessionId = sessionId; diff --git a/apple/src/ffmpeg_context.h b/apple/src/ffmpeg_context.h index 8ec27ce..81d9a89 100644 --- a/apple/src/ffmpeg_context.h +++ b/apple/src/ffmpeg_context.h @@ -20,16 +20,15 @@ #ifndef FFMPEG_CONTEXT_H #define FFMPEG_CONTEXT_H -#if HAVE_TERMIOS_H -#include -#endif - #include "fftools_ffmpeg.h" #include "libavformat/avio.h" #include "libavutil/dict.h" extern __thread BenchmarkTimeStamps current_time; +#if HAVE_TERMIOS_H +#include extern __thread struct termios oldtty; +#endif extern __thread int restore_tty; extern __thread volatile int received_sigterm; extern __thread volatile int received_nb_signals; diff --git a/ios.sh b/ios.sh index b30200d..f1b86df 100755 --- a/ios.sh +++ b/ios.sh @@ -169,6 +169,14 @@ while [ ! $# -eq 0 ]; do EXTRA_LDFLAGS=$(echo $1 | sed -e 's/^--extra-ldflags=//g') export EXTRA_LDFLAGS="${EXTRA_LDFLAGS}" ;; + --version-*) + CUSTOM_VERSION_KEY=$(echo $1 | sed -e 's/^--version-//g;s/=.*$//g') + CUSTOM_VERSION_VALUE=$(echo $1 | sed -e 's/^--version-.*=//g') + + echo -e "INFO: Custom version detected: ${CUSTOM_VERSION_KEY} ${CUSTOM_VERSION_VALUE}\n" 1>>"${BASEDIR}"/build.log 2>&1 + + generate_custom_version_environment_variables "${CUSTOM_VERSION_KEY}" "${CUSTOM_VERSION_VALUE}" + ;; *) print_unknown_option "$1" ;; diff --git a/linux.sh b/linux.sh index 22ad107..579d1b9 100755 --- a/linux.sh +++ b/linux.sh @@ -124,6 +124,14 @@ while [ ! $# -eq 0 ]; do EXTRA_LDFLAGS=$(echo $1 | sed -e 's/^--extra-ldflags=//g') export EXTRA_LDFLAGS="${EXTRA_LDFLAGS}" ;; + --version-*) + CUSTOM_VERSION_KEY=$(echo $1 | sed -e 's/^--version-//g;s/=.*$//g') + CUSTOM_VERSION_VALUE=$(echo $1 | sed -e 's/^--version-.*=//g') + + echo -e "INFO: Custom version detected: ${CUSTOM_VERSION_KEY} ${CUSTOM_VERSION_VALUE}\n" 1>>"${BASEDIR}"/build.log 2>&1 + + generate_custom_version_environment_variables "${CUSTOM_VERSION_KEY}" "${CUSTOM_VERSION_VALUE}" + ;; *) print_unknown_option "$1" ;; diff --git a/linux/src/Makefile.am b/linux/src/Makefile.am index 62b8f86..fb630f9 100644 --- a/linux/src/Makefile.am +++ b/linux/src/Makefile.am @@ -19,6 +19,7 @@ libffmpegkit_la_SOURCES = \ ReturnCode.cpp \ Statistics.cpp \ StreamInformation.cpp \ + ffmpeg_context.c \ ffmpegkit_exception.cpp \ fftools_cmdutils.c \ fftools_ffmpeg.c \ @@ -63,6 +64,7 @@ include_HEADERS = \ Statistics.h \ StatisticsCallback.h \ StreamInformation.h \ + ffmpeg_context.h \ ffmpegkit_exception.h \ fftools_cmdutils.h \ fftools_ffmpeg.h \ diff --git a/linux/src/ffmpeg_context.h b/linux/src/ffmpeg_context.h index 8ec27ce..81d9a89 100644 --- a/linux/src/ffmpeg_context.h +++ b/linux/src/ffmpeg_context.h @@ -20,16 +20,15 @@ #ifndef FFMPEG_CONTEXT_H #define FFMPEG_CONTEXT_H -#if HAVE_TERMIOS_H -#include -#endif - #include "fftools_ffmpeg.h" #include "libavformat/avio.h" #include "libavutil/dict.h" extern __thread BenchmarkTimeStamps current_time; +#if HAVE_TERMIOS_H +#include extern __thread struct termios oldtty; +#endif extern __thread int restore_tty; extern __thread volatile int received_sigterm; extern __thread volatile int received_nb_signals; diff --git a/macos.sh b/macos.sh index 7e888a7..8d7d348 100755 --- a/macos.sh +++ b/macos.sh @@ -161,6 +161,14 @@ while [ ! $# -eq 0 ]; do EXTRA_LDFLAGS=$(echo $1 | sed -e 's/^--extra-ldflags=//g') export EXTRA_LDFLAGS="${EXTRA_LDFLAGS}" ;; + --version-*) + CUSTOM_VERSION_KEY=$(echo $1 | sed -e 's/^--version-//g;s/=.*$//g') + CUSTOM_VERSION_VALUE=$(echo $1 | sed -e 's/^--version-.*=//g') + + echo -e "INFO: Custom version detected: ${CUSTOM_VERSION_KEY} ${CUSTOM_VERSION_VALUE}\n" 1>>"${BASEDIR}"/build.log 2>&1 + + generate_custom_version_environment_variables "${CUSTOM_VERSION_KEY}" "${CUSTOM_VERSION_VALUE}" + ;; *) print_unknown_option "$1" ;; diff --git a/scripts/function-android.sh b/scripts/function-android.sh index 1927e1b..ff160c3 100755 --- a/scripts/function-android.sh +++ b/scripts/function-android.sh @@ -94,9 +94,9 @@ APP_ALLOW_MISSING_DEPS := true APP_PLATFORM := android-${API} -APP_CFLAGS := -O3 -DANDROID ${LTS_BUILD_FLAG}${BUILD_DATE} -Wall -Wno-deprecated-declarations -Wno-pointer-sign -Wno-switch -Wno-unused-result -Wno-unused-variable ${USES_FFMPEG_KIT_PROTOCOLS} ${FFMPEG_KIT_DEBUG} +APP_CFLAGS := -O3 -DANDROID ${LTS_BUILD_FLAG}${BUILD_DATE} -Wall -Wno-deprecated-declarations -Wno-pointer-sign -Wno-switch -Wno-unused-result -Wno-unused-variable ${USES_FFMPEG_KIT_PROTOCOLS} ${FFMPEG_KIT_DEBUG} ${EXTRA_CFLAGS} -APP_LDFLAGS := -Wl,--hash-style=both +APP_LDFLAGS := -Wl,--hash-style=both ${EXTRA_LDFLAGS} EOF } diff --git a/scripts/function.sh b/scripts/function.sh index 5d991c6..704af38 100755 --- a/scripts/function.sh +++ b/scripts/function.sh @@ -924,6 +924,7 @@ display_help_advanced_options() { echo -e " --reconf-LIBRARY\t\trun autoreconf before building LIBRARY [no]" echo -e " --redownload-LIBRARY\t\tdownload LIBRARY even if it is detected as already downloaded [no]" echo -e " --rebuild-LIBRARY\t\tbuild LIBRARY even if it is detected as already built [no]" + echo -e " --version-LIBRARY=n\t\toverride default LIBRARY version []" if [ -n "$1" ]; then echo -e "$1" fi @@ -2416,6 +2417,21 @@ initialize_folder() { } fail_operation() { - echo -e "failed\n" - echo -e "See build.log for the details\n" + if [[ "$?" -ne 0 ]]; then + echo -e "failed\n" + echo -e "See build.log for the details\n" + fi +} + +# +# 1. key +# 2. value +# +generate_custom_version_environment_variables() { + VERSION_KEY=$(echo "VERSION_$1" | sed "s/\-/\_/g" | tr '[A-Z]' '[a-z]') + VERSION_VALUE="$2" + + export "${VERSION_KEY}"="${VERSION_VALUE}" + + echo -e "INFO: Custom version env variable generated: ${VERSION_KEY}=${VERSION_VALUE}\n" 1>>"${BASEDIR}"/build.log 2>&1 } diff --git a/scripts/source.sh b/scripts/source.sh index b7aad85..e23fe8b 100755 --- a/scripts/source.sh +++ b/scripts/source.sh @@ -273,7 +273,12 @@ get_library_source() { echo "${SOURCE_REPO_URL}" ;; 2) - echo "${SOURCE_ID}" + CUSTOM_VERSION_FLAG=$(echo "version_$1" | sed "s/\-/\_/g") + if [[ ! -z "${!CUSTOM_VERSION_FLAG}" ]]; then + echo "${!CUSTOM_VERSION_FLAG}" + else + echo "${SOURCE_ID}" + fi ;; 3) echo "${SOURCE_TYPE}" diff --git a/tvos.sh b/tvos.sh index dc69c19..fc7b472 100755 --- a/tvos.sh +++ b/tvos.sh @@ -164,6 +164,14 @@ while [ ! $# -eq 0 ]; do EXTRA_LDFLAGS=$(echo $1 | sed -e 's/^--extra-ldflags=//g') export EXTRA_LDFLAGS="${EXTRA_LDFLAGS}" ;; + --version-*) + CUSTOM_VERSION_KEY=$(echo $1 | sed -e 's/^--version-//g;s/=.*$//g') + CUSTOM_VERSION_VALUE=$(echo $1 | sed -e 's/^--version-.*=//g') + + echo -e "INFO: Custom version detected: ${CUSTOM_VERSION_KEY} ${CUSTOM_VERSION_VALUE}\n" 1>>"${BASEDIR}"/build.log 2>&1 + + generate_custom_version_environment_variables "${CUSTOM_VERSION_KEY}" "${CUSTOM_VERSION_VALUE}" + ;; *) print_unknown_option "$1" ;;