react-native-audio-api 0.10.0-nightly-e16d7ff-20251030 → 0.11.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RNAudioAPI.podspec +11 -16
- package/android/build.gradle +3 -33
- package/android/src/main/cpp/audioapi/CMakeLists.txt +0 -6
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +0 -5
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +0 -1
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +142 -28
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +40 -13
- package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +2 -4
- package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +9 -9
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +37 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.cpp +187 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.h +57 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp +0 -6
- package/android/src/main/cpp/audioapi/android/core/utils/FileUtils.h +34 -0
- package/android/src/main/cpp/audioapi/android/core/utils/FileUtilts.cpp +133 -0
- package/android/src/main/cpp/audioapi/android/core/utils/MiniaudioImplementation.cpp +3 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.cpp +154 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.h +41 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +429 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +113 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.cpp +47 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.h +28 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +269 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +47 -0
- package/android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp +31 -0
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +3 -29
- package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +9 -21
- package/android/src/main/java/com/swmansion/audioapi/system/LockScreenManager.kt +6 -27
- package/android/src/main/java/com/swmansion/audioapi/system/MediaNotificationManager.kt +0 -11
- package/android/src/main/java/com/swmansion/audioapi/system/NativeFileInfo.kt +18 -0
- package/android/src/main/jniLibs/arm64-v8a/libavcodec.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libavformat.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libavutil.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libswresample.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavcodec.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavformat.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavutil.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libswresample.so +0 -0
- package/android/src/main/jniLibs/x86/libavcodec.so +0 -0
- package/android/src/main/jniLibs/x86/libavformat.so +0 -0
- package/android/src/main/jniLibs/x86/libavutil.so +0 -0
- package/android/src/main/jniLibs/x86/libswresample.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavcodec.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavformat.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavutil.so +0 -0
- package/android/src/main/jniLibs/x86_64/libswresample.so +0 -0
- package/common/cpp/audioapi/AudioAPIModuleInstaller.h +2 -30
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +0 -18
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +0 -1
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +97 -18
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +18 -6
- package/common/cpp/audioapi/core/AudioNode.h +2 -3
- package/common/cpp/audioapi/core/AudioParam.cpp +2 -2
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +0 -10
- package/common/cpp/audioapi/core/BaseAudioContext.h +0 -2
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +32 -69
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +1 -37
- package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +36 -82
- package/common/cpp/audioapi/core/inputs/AudioRecorder.h +52 -31
- package/common/cpp/audioapi/core/sources/StreamerNode.cpp +58 -59
- package/common/cpp/audioapi/core/sources/StreamerNode.h +8 -37
- package/common/cpp/audioapi/core/utils/AudioNodeManager.cpp +0 -5
- package/common/cpp/audioapi/core/utils/Constants.h +1 -2
- package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +10 -0
- package/common/cpp/audioapi/dsp/AudioUtils.cpp +1 -1
- package/common/cpp/audioapi/dsp/FFT.cpp +26 -0
- package/common/cpp/audioapi/dsp/FFT.h +2 -26
- package/common/cpp/audioapi/external/arm64-v8a/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libogg.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libopus.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libssl.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libogg.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libopus.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libssl.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/avcodec.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_desc.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_id.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_par.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/avformat.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avutil.h +2 -2
- package/common/cpp/audioapi/external/iphoneos/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libogg.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libopus.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libssl.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libogg.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libopus.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libssl.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/Info.plist +44 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/libavcodec +0 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/libavcodec +0 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/Info.plist +44 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/libavformat +0 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/libavformat +0 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/Info.plist +44 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/libavutil +0 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/libavutil +0 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/Info.plist +44 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/libswresample +0 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/libswresample +0 -0
- package/common/cpp/audioapi/external/x86/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/x86/libogg.a +0 -0
- package/common/cpp/audioapi/external/x86/libopus.a +0 -0
- package/common/cpp/audioapi/external/x86/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/x86/libssl.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libogg.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libopus.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libssl.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp +3 -2
- package/common/cpp/audioapi/libs/ffmpeg/INSTRUCTIONS.md +32 -0
- package/common/cpp/audioapi/libs/ffmpeg/create_xcframework.sh +111 -0
- package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +391 -0
- package/common/cpp/audioapi/utils/AudioBus.cpp +0 -28
- package/common/cpp/audioapi/utils/AudioBus.h +0 -3
- package/common/cpp/audioapi/utils/ThreadPool.hpp +1 -59
- package/common/cpp/test/CMakeLists.txt +14 -19
- package/ios/audioapi/ios/AudioAPIModule.h +1 -2
- package/ios/audioapi/ios/AudioAPIModule.mm +0 -2
- package/ios/audioapi/ios/core/IOSAudioFileOptions.h +36 -0
- package/ios/audioapi/ios/core/IOSAudioFileOptions.mm +140 -0
- package/ios/audioapi/ios/core/IOSAudioFileWriter.h +51 -0
- package/ios/audioapi/ios/core/IOSAudioFileWriter.mm +223 -0
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +28 -10
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +117 -30
- package/ios/audioapi/ios/core/IOSRecorderCallback.h +57 -0
- package/ios/audioapi/ios/core/IOSRecorderCallback.mm +189 -0
- package/ios/audioapi/ios/core/NativeAudioRecorder.h +4 -9
- package/ios/audioapi/ios/core/NativeAudioRecorder.m +29 -71
- package/ios/audioapi/ios/core/utils/AudioDecoder.mm +1 -0
- package/ios/audioapi/ios/system/AudioEngine.mm +3 -3
- package/ios/audioapi/ios/system/AudioSessionManager.mm +0 -9
- package/ios/audioapi/ios/system/LockScreenManager.h +1 -0
- package/ios/audioapi/ios/system/LockScreenManager.mm +19 -6
- package/lib/commonjs/api.js +76 -141
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/api.web.js +0 -8
- package/lib/commonjs/api.web.js.map +1 -1
- package/lib/commonjs/core/AudioContext.js +1 -1
- package/lib/commonjs/core/AudioContext.js.map +1 -1
- package/lib/commonjs/core/AudioRecorder.js +171 -13
- package/lib/commonjs/core/AudioRecorder.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +25 -28
- package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
- package/lib/commonjs/core/OfflineAudioContext.js +1 -1
- package/lib/commonjs/core/OfflineAudioContext.js.map +1 -1
- package/lib/commonjs/types.js +46 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/bitEnums.js +33 -0
- package/lib/commonjs/utils/bitEnums.js.map +1 -0
- package/lib/commonjs/utils/index.js +21 -19
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/web-core/AudioContext.js +0 -12
- package/lib/commonjs/web-core/AudioContext.js.map +1 -1
- package/lib/commonjs/web-core/OfflineAudioContext.js +0 -12
- package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/module/api.js +15 -16
- package/lib/module/api.js.map +1 -1
- package/lib/module/api.web.js +0 -1
- package/lib/module/api.web.js.map +1 -1
- package/lib/module/core/AudioContext.js +2 -2
- package/lib/module/core/AudioContext.js.map +1 -1
- package/lib/module/core/AudioRecorder.js +171 -13
- package/lib/module/core/AudioRecorder.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +26 -29
- package/lib/module/core/BaseAudioContext.js.map +1 -1
- package/lib/module/core/OfflineAudioContext.js +2 -2
- package/lib/module/core/OfflineAudioContext.js.map +1 -1
- package/lib/module/types.js +45 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/bitEnums.js +27 -0
- package/lib/module/utils/bitEnums.js.map +1 -0
- package/lib/module/utils/index.js +2 -15
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/web-core/AudioContext.js +0 -12
- package/lib/module/web-core/AudioContext.js.map +1 -1
- package/lib/module/web-core/OfflineAudioContext.js +0 -12
- package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/typescript/api.d.ts +17 -19
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/api.web.d.ts +0 -1
- package/lib/typescript/api.web.d.ts.map +1 -1
- package/lib/typescript/core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/core/AudioRecorder.d.ts +62 -7
- package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
- package/lib/typescript/core/BaseAudioContext.d.ts +1 -3
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/events/types.d.ts +16 -0
- package/lib/typescript/events/types.d.ts.map +1 -1
- package/lib/typescript/interfaces.d.ts +42 -9
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +79 -8
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/bitEnums.d.ts +4 -0
- package/lib/typescript/utils/bitEnums.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +2 -5
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/lib/typescript/web-core/AudioContext.d.ts +0 -3
- package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/BaseAudioContext.d.ts +0 -2
- package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/OfflineAudioContext.d.ts +0 -3
- package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
- package/package.json +4 -7
- package/src/api.ts +18 -45
- package/src/api.web.ts +0 -1
- package/src/core/AudioContext.ts +2 -3
- package/src/core/AudioRecorder.ts +211 -24
- package/src/core/BaseAudioContext.ts +60 -67
- package/src/core/OfflineAudioContext.ts +2 -2
- package/src/events/types.ts +18 -0
- package/src/interfaces.ts +52 -16
- package/src/types.ts +90 -9
- package/src/utils/bitEnums.ts +51 -0
- package/src/utils/index.ts +2 -22
- package/src/web-core/AudioContext.tsx +0 -25
- package/src/web-core/BaseAudioContext.tsx +0 -2
- package/src/web-core/OfflineAudioContext.tsx +0 -25
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp +0 -47
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.h +0 -20
- package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +0 -210
- package/common/cpp/audioapi/core/effects/ConvolverNode.h +0 -55
- package/common/cpp/audioapi/dsp/Convolver.cpp +0 -213
- package/common/cpp/audioapi/dsp/Convolver.h +0 -45
- package/common/cpp/audioapi/libs/ffmpeg/relinking.md +0 -24
- package/common/cpp/audioapi/utils/AlignedAllocator.hpp +0 -50
- package/common/cpp/test/src/biquad/BiquadFilterChromium.cpp +0 -389
- package/common/cpp/test/src/biquad/BiquadFilterChromium.h +0 -64
- package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +0 -284
- package/common/cpp/test/src/biquad/BiquadFilterTest.h +0 -40
- package/lib/commonjs/core/ConvolverNode.js +0 -37
- package/lib/commonjs/core/ConvolverNode.js.map +0 -1
- package/lib/commonjs/web-core/ConvolverNode.js +0 -40
- package/lib/commonjs/web-core/ConvolverNode.js.map +0 -1
- package/lib/commonjs/web-core/ConvolverNodeOptions.js +0 -6
- package/lib/commonjs/web-core/ConvolverNodeOptions.js.map +0 -1
- package/lib/module/core/ConvolverNode.js +0 -31
- package/lib/module/core/ConvolverNode.js.map +0 -1
- package/lib/module/web-core/ConvolverNode.js +0 -34
- package/lib/module/web-core/ConvolverNode.js.map +0 -1
- package/lib/module/web-core/ConvolverNodeOptions.js +0 -4
- package/lib/module/web-core/ConvolverNodeOptions.js.map +0 -1
- package/lib/typescript/core/ConvolverNode.d.ts +0 -12
- package/lib/typescript/core/ConvolverNode.d.ts.map +0 -1
- package/lib/typescript/web-core/ConvolverNode.d.ts +0 -11
- package/lib/typescript/web-core/ConvolverNode.d.ts.map +0 -1
- package/lib/typescript/web-core/ConvolverNodeOptions.d.ts +0 -6
- package/lib/typescript/web-core/ConvolverNodeOptions.d.ts.map +0 -1
- package/scripts/download-prebuilt-binaries.sh +0 -52
- package/scripts/rnaa_utils.rb +0 -8
- package/scripts/validate-worklets-version.js +0 -28
- package/src/core/ConvolverNode.ts +0 -35
- package/src/web-core/ConvolverNode.tsx +0 -43
- package/src/web-core/ConvolverNodeOptions.tsx +0 -6
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# FFmpeg Mobile Architecture Build Script
|
|
4
|
+
# Builds shared ffmpeg binaries for iOS and Android architectures
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
SOURCE_DIR="/Users/michalsek/Documents/work/FFmpeg" # Change this to your FFmpeg source directory
|
|
8
|
+
if [ ! -d "${SOURCE_DIR}" ]; then
|
|
9
|
+
echo "FFmpeg source directory does not exist: ${SOURCE_DIR}"
|
|
10
|
+
exit 1
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
BUILD_DIR="$(pwd)/build"
|
|
14
|
+
OUTPUT_DIR="$(pwd)/output"
|
|
15
|
+
mkdir -p "${BUILD_DIR}"
|
|
16
|
+
mkdir -p "${OUTPUT_DIR}"
|
|
17
|
+
|
|
18
|
+
AVUTIL_VERSION="60.6.100"
|
|
19
|
+
AVCODEC_VERSION="62.8.100"
|
|
20
|
+
AVFORMAT_VERSION="62.1.103"
|
|
21
|
+
SWRRESAMPLE_VERSION="6.0.100"
|
|
22
|
+
|
|
23
|
+
COMMON_CONFIG="
|
|
24
|
+
--disable-programs
|
|
25
|
+
--disable-doc
|
|
26
|
+
--disable-htmlpages
|
|
27
|
+
--disable-manpages
|
|
28
|
+
--disable-podpages
|
|
29
|
+
--disable-txtpages
|
|
30
|
+
--disable-avdevice
|
|
31
|
+
--disable-swscale
|
|
32
|
+
--disable-avfilter
|
|
33
|
+
--disable-protocols
|
|
34
|
+
--disable-devices
|
|
35
|
+
--disable-filters
|
|
36
|
+
--disable-static
|
|
37
|
+
--enable-shared
|
|
38
|
+
--enable-small
|
|
39
|
+
--disable-debug
|
|
40
|
+
--disable-optimizations
|
|
41
|
+
--disable-everything
|
|
42
|
+
--disable-audiotoolbox
|
|
43
|
+
--disable-videotoolbox
|
|
44
|
+
--disable-hwaccels
|
|
45
|
+
--enable-protocol=https,tls,tcp,http
|
|
46
|
+
--enable-demuxer=hls
|
|
47
|
+
--enable-demuxer=mov
|
|
48
|
+
--enable-demuxer=mp3
|
|
49
|
+
--enable-parser=aac
|
|
50
|
+
--enable-decoder=aac
|
|
51
|
+
--enable-decoder=alac
|
|
52
|
+
--enable-decoder=mp3
|
|
53
|
+
--enable-decoder=flac
|
|
54
|
+
--enable-encoder=aac
|
|
55
|
+
--enable-encoder=flac
|
|
56
|
+
--enable-encoder=alac
|
|
57
|
+
--enable-encoder=pcm_s16le
|
|
58
|
+
--enable-muxer=wav
|
|
59
|
+
--enable-muxer=mp4
|
|
60
|
+
--enable-muxer=flac
|
|
61
|
+
--enable-muxer=caf
|
|
62
|
+
--enable-protocol=udp
|
|
63
|
+
--enable-protocol=file
|
|
64
|
+
--enable-pic
|
|
65
|
+
--disable-x86asm
|
|
66
|
+
--disable-inline-asm
|
|
67
|
+
"
|
|
68
|
+
|
|
69
|
+
build_arch() {
|
|
70
|
+
local ARCH=$1
|
|
71
|
+
local PLATFORM=$2
|
|
72
|
+
local CC=$3
|
|
73
|
+
local CXX=$4
|
|
74
|
+
local CFLAGS=$5
|
|
75
|
+
local LDFLAGS=$6
|
|
76
|
+
local EXTRA_CONFIG=$7
|
|
77
|
+
|
|
78
|
+
if [[ ${PLATFORM} == "android" ]]; then
|
|
79
|
+
PLATFORM_NAME="android"
|
|
80
|
+
if [[ ${ARCH} == "aarch64" ]]; then
|
|
81
|
+
ARCH_NAME="arm64-v8a"
|
|
82
|
+
elif [[ ${ARCH} == "armv7a" ]]; then
|
|
83
|
+
ARCH_NAME="armeabi-v7a"
|
|
84
|
+
else
|
|
85
|
+
ARCH_NAME=${ARCH}
|
|
86
|
+
fi
|
|
87
|
+
elif [[ ${PLATFORM} == "darwin" ]]; then
|
|
88
|
+
PLATFORM_NAME="ios"
|
|
89
|
+
ARCH_NAME="iphoneos"
|
|
90
|
+
elif [[ ${PLATFORM} == "darwinsim" ]]; then
|
|
91
|
+
PLATFORM_NAME="ios"
|
|
92
|
+
if [[ ${ARCH} == "x86_64" ]]; then
|
|
93
|
+
ARCH_NAME="iphonesimulator_x86_64"
|
|
94
|
+
else
|
|
95
|
+
ARCH_NAME="iphonesimulator_arm64"
|
|
96
|
+
fi
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
echo "Building FFmpeg for ${PLATFORM_NAME} ${ARCH_NAME}..."
|
|
100
|
+
|
|
101
|
+
SOURCE_PATH="${BUILD_DIR}/ffmpeg-${PLATFORM_NAME}-${ARCH_NAME}"
|
|
102
|
+
OUTPUT_PATH="${OUTPUT_DIR}/${PLATFORM_NAME}/${ARCH_NAME}"
|
|
103
|
+
|
|
104
|
+
mkdir -p "${OUTPUT_PATH}"
|
|
105
|
+
|
|
106
|
+
echo "Copying source for ${PLATFORM_NAME} ${ARCH_NAME}..."
|
|
107
|
+
rm -rf "${SOURCE_PATH}"
|
|
108
|
+
cp -r "${SOURCE_DIR}" "${SOURCE_PATH}"
|
|
109
|
+
|
|
110
|
+
cd "${SOURCE_PATH}"
|
|
111
|
+
|
|
112
|
+
make distclean 2>/dev/null || true
|
|
113
|
+
|
|
114
|
+
if [[ ${PLATFORM} == "darwinsim" ]]; then
|
|
115
|
+
PLATFORM="darwin"
|
|
116
|
+
fi
|
|
117
|
+
|
|
118
|
+
echo --enable-cross-compile --arch=${ARCH} --target-os=${PLATFORM} --cc="${CC}" --cxx="${CXX}" --extra-cflags="${CFLAGS}" --extra-ldflags="${LDFLAGS}" --prefix="${OUTPUT_PATH}" ${COMMON_CONFIG} ${EXTRA_CONFIG}
|
|
119
|
+
|
|
120
|
+
# Configure
|
|
121
|
+
./configure \
|
|
122
|
+
--enable-cross-compile \
|
|
123
|
+
--arch=${ARCH} \
|
|
124
|
+
--target-os=${PLATFORM} \
|
|
125
|
+
--cc="${CC}" \
|
|
126
|
+
--cxx="${CXX}" \
|
|
127
|
+
--extra-cflags="${CFLAGS}" \
|
|
128
|
+
--extra-ldflags="${LDFLAGS}" \
|
|
129
|
+
--prefix="${OUTPUT_PATH}" \
|
|
130
|
+
${COMMON_CONFIG} \
|
|
131
|
+
${EXTRA_CONFIG}
|
|
132
|
+
|
|
133
|
+
# Build
|
|
134
|
+
make -j10
|
|
135
|
+
make install
|
|
136
|
+
|
|
137
|
+
echo "Completed ${PLATFORM} ${ARCH}"
|
|
138
|
+
cd - > /dev/null
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
fix_dynamic_ios_linkage() {
|
|
142
|
+
local LIB_PATH=$1
|
|
143
|
+
|
|
144
|
+
# Get all dependencies that are not system libraries (including the library itself)
|
|
145
|
+
otool -L "${LIB_PATH}" | grep -v "/usr/lib/" | grep -v "/System/" | awk 'NR>1 {print $1}' | while read -r dep; do
|
|
146
|
+
if [[ -n "$dep" ]]; then
|
|
147
|
+
# Extract library name without any version numbers and extension for framework path
|
|
148
|
+
local lib_name=$(basename "$dep" | sed 's/\.dylib$//' | sed 's/\.[0-9][0-9.]*$//')
|
|
149
|
+
local framework_path="@rpath/${lib_name}.framework/${lib_name}"
|
|
150
|
+
echo "Changing dependency: $dep -> $framework_path"
|
|
151
|
+
install_name_tool -change "$dep" "$framework_path" "${LIB_PATH}"
|
|
152
|
+
fi
|
|
153
|
+
done
|
|
154
|
+
|
|
155
|
+
# Also update the library's own install name to use @rpath with framework structure
|
|
156
|
+
local lib_name=$(basename "${LIB_PATH}" | sed 's/\.dylib$//' | sed 's/\.[0-9][0-9.]*$//')
|
|
157
|
+
local framework_path="@rpath/${lib_name}.framework/${lib_name}"
|
|
158
|
+
echo "Updating install name for $(basename "${LIB_PATH}") -> $framework_path"
|
|
159
|
+
install_name_tool -id "$framework_path" "${LIB_PATH}"
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
# Check if source exists
|
|
163
|
+
if [ ! -d "${SOURCE_DIR}" ]; then
|
|
164
|
+
echo "FFmpeg source not found."
|
|
165
|
+
exit 1
|
|
166
|
+
fi
|
|
167
|
+
|
|
168
|
+
# Clean the source directory of any previous builds
|
|
169
|
+
cd "${SOURCE_DIR}"
|
|
170
|
+
make distclean 2>/dev/null || true
|
|
171
|
+
cd - > /dev/null
|
|
172
|
+
|
|
173
|
+
# Use NDK_ROOT if ANDROID_NDK_ROOT is not set
|
|
174
|
+
NDK_PATH="${ANDROID_NDK_ROOT:-$NDK_ROOT}"
|
|
175
|
+
|
|
176
|
+
if [ ! -d "$NDK_PATH" ]; then
|
|
177
|
+
echo "Android NDK not found. Please set ANDROID_NDK_ROOT or NDK_ROOT environment variable"
|
|
178
|
+
exit 1
|
|
179
|
+
fi
|
|
180
|
+
|
|
181
|
+
API_LEVEL=21
|
|
182
|
+
TOOLCHAIN_PATH="${NDK_PATH}/toolchains/llvm/prebuilt"
|
|
183
|
+
export ANDROID_NDK_ROOT=${NDK_PATH}
|
|
184
|
+
|
|
185
|
+
# Detect host OS for toolchain
|
|
186
|
+
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
187
|
+
HOST_TAG="darwin-x86_64"
|
|
188
|
+
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
189
|
+
HOST_TAG="linux-x86_64"
|
|
190
|
+
else
|
|
191
|
+
echo "Unsupported host OS for Android NDK"
|
|
192
|
+
exit 1
|
|
193
|
+
fi
|
|
194
|
+
|
|
195
|
+
TOOLCHAIN="${TOOLCHAIN_PATH}/${HOST_TAG}"
|
|
196
|
+
PATH=$TOOLCHAIN/bin:$PATH
|
|
197
|
+
|
|
198
|
+
OPENSSL_PREBUILT_FOLDER="$(pwd)/openssl-prebuilt"
|
|
199
|
+
if [ ! -d "$OPENSSL_PREBUILT_FOLDER" ]; then
|
|
200
|
+
echo "Cloning and building OpenSSL..."
|
|
201
|
+
if [ ! -d "openssl" ]; then
|
|
202
|
+
git clone https://github.com/openssl/openssl.git
|
|
203
|
+
fi
|
|
204
|
+
cd openssl
|
|
205
|
+
mkdir -p "${OPENSSL_PREBUILT_FOLDER}/include"
|
|
206
|
+
|
|
207
|
+
# ios-arm
|
|
208
|
+
./Configure ios64-xcrun no-shared no-asm no-tests
|
|
209
|
+
make build_libs -j10
|
|
210
|
+
mkdir -p ${OPENSSL_PREBUILT_FOLDER}/iphoneos && cp libcrypto.a libssl.a "${OPENSSL_PREBUILT_FOLDER}/iphoneos"
|
|
211
|
+
cp -r include/crypto include/openssl "${OPENSSL_PREBUILT_FOLDER}/include"
|
|
212
|
+
make clean
|
|
213
|
+
|
|
214
|
+
# arm-simulator
|
|
215
|
+
./Configure iossimulator-arm64-xcrun no-shared no-asm no-tests
|
|
216
|
+
make build_libs -j10
|
|
217
|
+
mkdir -p ${OPENSSL_PREBUILT_FOLDER}/iphonesimulator && cp libcrypto.a libssl.a "${OPENSSL_PREBUILT_FOLDER}/iphonesimulator"
|
|
218
|
+
make clean
|
|
219
|
+
|
|
220
|
+
# x86_64-simulator
|
|
221
|
+
./Configure iossimulator-x86_64-xcrun no-shared no-asm no-tests
|
|
222
|
+
make build_libs -j10
|
|
223
|
+
mkdir -p ${OPENSSL_PREBUILT_FOLDER}/iphonesimulator-x86_64 && cp libcrypto.a libssl.a "${OPENSSL_PREBUILT_FOLDER}/iphonesimulator-x86_64"
|
|
224
|
+
make clean
|
|
225
|
+
|
|
226
|
+
# arm64-v8a
|
|
227
|
+
./Configure android-arm64 no-shared no-asm no-tests -D__ANDROID_API__=${API_LEVEL}
|
|
228
|
+
make build_libs -j10
|
|
229
|
+
mkdir -p ${OPENSSL_PREBUILT_FOLDER}/arm64-v8a && cp libcrypto.a libssl.a "${OPENSSL_PREBUILT_FOLDER}/arm64-v8a"
|
|
230
|
+
make clean
|
|
231
|
+
|
|
232
|
+
# armeabi-v7a
|
|
233
|
+
./Configure android-arm no-shared no-asm no-tests -D__ANDROID_API__=${API_LEVEL}
|
|
234
|
+
make build_libs -j10
|
|
235
|
+
mkdir -p ${OPENSSL_PREBUILT_FOLDER}/armeabi-v7a && cp libcrypto.a libssl.a "${OPENSSL_PREBUILT_FOLDER}/armeabi-v7a"
|
|
236
|
+
make clean
|
|
237
|
+
|
|
238
|
+
./Configure android-x86 no-shared no-asm no-tests -D__ANDROID_API__=${API_LEVEL}
|
|
239
|
+
make build_libs -j10
|
|
240
|
+
mkdir -p ${OPENSSL_PREBUILT_FOLDER}/x86 && cp libcrypto.a libssl.a "${OPENSSL_PREBUILT_FOLDER}/x86"
|
|
241
|
+
make clean
|
|
242
|
+
|
|
243
|
+
./Configure android-x86_64 no-shared no-asm no-tests -D__ANDROID_API__=${API_LEVEL}
|
|
244
|
+
make build_libs -j10
|
|
245
|
+
mkdir -p ${OPENSSL_PREBUILT_FOLDER}/x86_64 && cp libcrypto.a libssl.a "${OPENSSL_PREBUILT_FOLDER}/x86_64"
|
|
246
|
+
make clean
|
|
247
|
+
|
|
248
|
+
cd .. && rm -rf openssl
|
|
249
|
+
fi
|
|
250
|
+
|
|
251
|
+
# iOS Architectures
|
|
252
|
+
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
253
|
+
echo "Building for iOS architectures..."
|
|
254
|
+
|
|
255
|
+
# iOS SDK paths
|
|
256
|
+
IOS_SDK_PATH=$(xcrun --sdk iphoneos --show-sdk-path)
|
|
257
|
+
IOS_SIM_SDK_PATH=$(xcrun --sdk iphonesimulator --show-sdk-path)
|
|
258
|
+
|
|
259
|
+
# iOS Device architecture
|
|
260
|
+
build_arch "arm64" "darwin" \
|
|
261
|
+
"$(xcrun --sdk iphoneos --find clang)" \
|
|
262
|
+
"$(xcrun --sdk iphoneos --find clang++)" \
|
|
263
|
+
"-I${OPENSSL_PREBUILT_FOLDER}/include -arch arm64 -mios-version-min=11.0 -isysroot ${IOS_SDK_PATH}" \
|
|
264
|
+
"-L${OPENSSL_PREBUILT_FOLDER}/iphoneos -arch arm64 -mios-version-min=11.0 -isysroot ${IOS_SDK_PATH}" \
|
|
265
|
+
"--disable-iconv --disable-zlib --enable-openssl --disable-securetransport"
|
|
266
|
+
|
|
267
|
+
fix_dynamic_ios_linkage "${OUTPUT_DIR}/ios/iphoneos/lib/libavcodec.${AVCODEC_VERSION}.dylib"
|
|
268
|
+
fix_dynamic_ios_linkage "${OUTPUT_DIR}/ios/iphoneos/lib/libavformat.${AVFORMAT_VERSION}.dylib"
|
|
269
|
+
fix_dynamic_ios_linkage "${OUTPUT_DIR}/ios/iphoneos/lib/libavutil.${AVUTIL_VERSION}.dylib"
|
|
270
|
+
fix_dynamic_ios_linkage "${OUTPUT_DIR}/ios/iphoneos/lib/libswresample.${SWRRESAMPLE_VERSION}.dylib"
|
|
271
|
+
|
|
272
|
+
rm -rf "${OUTPUT_DIR}/ios/iphoneos/share"
|
|
273
|
+
|
|
274
|
+
# iOS Simulator arm (Silicon Macs)
|
|
275
|
+
build_arch "arm64" "darwinsim" \
|
|
276
|
+
"$(xcrun --sdk iphonesimulator --find clang)" \
|
|
277
|
+
"$(xcrun --sdk iphonesimulator --find clang++)" \
|
|
278
|
+
"-I${OPENSSL_PREBUILT_FOLDER}/include -arch arm64 -mios-simulator-version-min=11.0 -isysroot ${IOS_SIM_SDK_PATH}" \
|
|
279
|
+
"-L${OPENSSL_PREBUILT_FOLDER}/iphonesimulator -arch arm64 -mios-simulator-version-min=11.0 -isysroot ${IOS_SIM_SDK_PATH}" \
|
|
280
|
+
"--disable-iconv --disable-zlib --enable-openssl --disable-securetransport"
|
|
281
|
+
|
|
282
|
+
fix_dynamic_ios_linkage "${OUTPUT_DIR}/ios/iphonesimulator_arm64/lib/libavcodec.${AVCODEC_VERSION}.dylib"
|
|
283
|
+
fix_dynamic_ios_linkage "${OUTPUT_DIR}/ios/iphonesimulator_arm64/lib/libavformat.${AVFORMAT_VERSION}.dylib"
|
|
284
|
+
fix_dynamic_ios_linkage "${OUTPUT_DIR}/ios/iphonesimulator_arm64/lib/libavutil.${AVUTIL_VERSION}.dylib"
|
|
285
|
+
fix_dynamic_ios_linkage "${OUTPUT_DIR}/ios/iphonesimulator_arm64/lib/libswresample.${SWRRESAMPLE_VERSION}.dylib"
|
|
286
|
+
|
|
287
|
+
rm -rf "${OUTPUT_DIR}/ios/iphonesimulator_arm64/share"
|
|
288
|
+
|
|
289
|
+
# iOS Simulator x86_64 (Intel Macs)
|
|
290
|
+
build_arch "x86_64" "darwinsim" \
|
|
291
|
+
"$(xcrun --sdk iphonesimulator --find clang)" \
|
|
292
|
+
"$(xcrun --sdk iphonesimulator --find clang++)" \
|
|
293
|
+
"-I${OPENSSL_PREBUILT_FOLDER}/include -arch x86_64 -mios-simulator-version-min=11.0 -isysroot ${IOS_SIM_SDK_PATH}" \
|
|
294
|
+
"-L${OPENSSL_PREBUILT_FOLDER}/iphonesimulator-x86_64 -arch x86_64 -mios-simulator-version-min=11.0 -isysroot ${IOS_SIM_SDK_PATH}" \
|
|
295
|
+
"--disable-iconv --disable-zlib --enable-openssl --disable-securetransport"
|
|
296
|
+
|
|
297
|
+
fix_dynamic_ios_linkage "${OUTPUT_DIR}/ios/iphonesimulator_x86_64/lib/libavcodec.${AVCODEC_VERSION}.dylib"
|
|
298
|
+
fix_dynamic_ios_linkage "${OUTPUT_DIR}/ios/iphonesimulator_x86_64/lib/libavformat.${AVFORMAT_VERSION}.dylib"
|
|
299
|
+
fix_dynamic_ios_linkage "${OUTPUT_DIR}/ios/iphonesimulator_x86_64/lib/libavutil.${AVUTIL_VERSION}.dylib"
|
|
300
|
+
fix_dynamic_ios_linkage "${OUTPUT_DIR}/ios/iphonesimulator_x86_64/lib/libswresample.${SWRRESAMPLE_VERSION}.dylib"
|
|
301
|
+
|
|
302
|
+
rm -rf "${OUTPUT_DIR}/ios/iphonesimulator_x86_64/share"
|
|
303
|
+
|
|
304
|
+
mkdir -p "${OUTPUT_DIR}/ios/iphonesimulator/lib"
|
|
305
|
+
# Create universal simulator libraries
|
|
306
|
+
lipo -create \
|
|
307
|
+
"${OUTPUT_DIR}/ios/iphonesimulator_arm64/lib/libavcodec.${AVCODEC_VERSION}.dylib" \
|
|
308
|
+
"${OUTPUT_DIR}/ios/iphonesimulator_x86_64/lib/libavcodec.${AVCODEC_VERSION}.dylib" \
|
|
309
|
+
-output "${OUTPUT_DIR}/ios/iphonesimulator/lib/libavcodec.${AVCODEC_VERSION}.dylib"
|
|
310
|
+
lipo -create \
|
|
311
|
+
"${OUTPUT_DIR}/ios/iphonesimulator_arm64/lib/libavformat.${AVFORMAT_VERSION}.dylib" \
|
|
312
|
+
"${OUTPUT_DIR}/ios/iphonesimulator_x86_64/lib/libavformat.${AVFORMAT_VERSION}.dylib" \
|
|
313
|
+
-output "${OUTPUT_DIR}/ios/iphonesimulator/lib/libavformat.${AVFORMAT_VERSION}.dylib"
|
|
314
|
+
|
|
315
|
+
lipo -create \
|
|
316
|
+
"${OUTPUT_DIR}/ios/iphonesimulator_arm64/lib/libavutil.${AVUTIL_VERSION}.dylib" \
|
|
317
|
+
"${OUTPUT_DIR}/ios/iphonesimulator_x86_64/lib/libavutil.${AVUTIL_VERSION}.dylib" \
|
|
318
|
+
-output "${OUTPUT_DIR}/ios/iphonesimulator/lib/libavutil.${AVUTIL_VERSION}.dylib"
|
|
319
|
+
|
|
320
|
+
lipo -create \
|
|
321
|
+
"${OUTPUT_DIR}/ios/iphonesimulator_arm64/lib/libswresample.${SWRRESAMPLE_VERSION}.dylib" \
|
|
322
|
+
"${OUTPUT_DIR}/ios/iphonesimulator_x86_64/lib/libswresample.${SWRRESAMPLE_VERSION}.dylib" \
|
|
323
|
+
-output "${OUTPUT_DIR}/ios/iphonesimulator/lib/libswresample.${SWRRESAMPLE_VERSION}.dylib"
|
|
324
|
+
|
|
325
|
+
mv "${OUTPUT_DIR}/ios/iphonesimulator/lib/libswresample.${SWRRESAMPLE_VERSION}.dylib" "${OUTPUT_DIR}/ios/iphonesimulator/lib/libswresample.dylib"
|
|
326
|
+
mv "${OUTPUT_DIR}/ios/iphonesimulator/lib/libavutil.${AVUTIL_VERSION}.dylib" "${OUTPUT_DIR}/ios/iphonesimulator/lib/libavutil.dylib"
|
|
327
|
+
mv "${OUTPUT_DIR}/ios/iphonesimulator/lib/libavformat.${AVFORMAT_VERSION}.dylib" "${OUTPUT_DIR}/ios/iphonesimulator/lib/libavformat.dylib"
|
|
328
|
+
mv "${OUTPUT_DIR}/ios/iphonesimulator/lib/libavcodec.${AVCODEC_VERSION}.dylib" "${OUTPUT_DIR}/ios/iphonesimulator/lib/libavcodec.dylib"
|
|
329
|
+
|
|
330
|
+
# create frameworks from binaries
|
|
331
|
+
bash ./create_xcframework.sh
|
|
332
|
+
|
|
333
|
+
echo "iOS builds completed!"
|
|
334
|
+
else
|
|
335
|
+
echo "Skipping iOS builds (requires macOS)"
|
|
336
|
+
fi
|
|
337
|
+
|
|
338
|
+
# Android Architectures
|
|
339
|
+
if [ -n "$ANDROID_NDK_ROOT" ] || [ -n "$NDK_ROOT" ]; then
|
|
340
|
+
echo "Building for Android architectures..."
|
|
341
|
+
|
|
342
|
+
# ARM64-v8a
|
|
343
|
+
build_arch "aarch64" "android" \
|
|
344
|
+
"${TOOLCHAIN}/bin/aarch64-linux-android${API_LEVEL}-clang" \
|
|
345
|
+
"${TOOLCHAIN}/bin/aarch64-linux-android${API_LEVEL}-clang++" \
|
|
346
|
+
"-I${OPENSSL_PREBUILT_FOLDER}/include -I${TOOLCHAIN}/sysroot/usr/include -fPIC -Wl,-Bsymbolic -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384" \
|
|
347
|
+
"-L${OPENSSL_PREBUILT_FOLDER}/arm64-v8a -L${TOOLCHAIN}/sysroot/usr/lib/aarch64-linux-android/${API_LEVEL} -fPIC -Wl,-Bsymbolic -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384" \
|
|
348
|
+
"--enable-openssl --extra-libs=-lz"
|
|
349
|
+
|
|
350
|
+
rm -rf ${OUTPUT_DIR}/android/arm64-v8a/share
|
|
351
|
+
|
|
352
|
+
# ARMv7a
|
|
353
|
+
build_arch "armv7a" "android" \
|
|
354
|
+
"${TOOLCHAIN}/bin/armv7a-linux-androideabi${API_LEVEL}-clang" \
|
|
355
|
+
"${TOOLCHAIN}/bin/armv7a-linux-androideabi${API_LEVEL}-clang++" \
|
|
356
|
+
"-I${OPENSSL_PREBUILT_FOLDER}/include -I${TOOLCHAIN}/sysroot/usr/include -fPIC -Wl,-Bsymbolic -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384" \
|
|
357
|
+
"-L${OPENSSL_PREBUILT_FOLDER}/armeabi-v7a -L${TOOLCHAIN}/sysroot/usr/lib/arm-linux-android/${API_LEVEL} -fPIC -Wl,-Bsymbolic -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384" \
|
|
358
|
+
"--enable-openssl --extra-libs=-lz"
|
|
359
|
+
|
|
360
|
+
rm -rf ${OUTPUT_DIR}/android/armeabi-v7a/share
|
|
361
|
+
|
|
362
|
+
# x86
|
|
363
|
+
build_arch "x86" "android" \
|
|
364
|
+
"${TOOLCHAIN}/bin/i686-linux-android${API_LEVEL}-clang" \
|
|
365
|
+
"${TOOLCHAIN}/bin/i686-linux-android${API_LEVEL}-clang++" \
|
|
366
|
+
"-I${OPENSSL_PREBUILT_FOLDER}/include -I${TOOLCHAIN}/darwin-x86_64/sysroot/usr/include -fPIC -Wl,-Bsymbolic -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384" \
|
|
367
|
+
"-L${OPENSSL_PREBUILT_FOLDER}/x86 -L${TOOLCHAIN}/darwin-x86_64/sysroot/usr/lib/i686-linux-android/${API_LEVEL} -fPIC -Wl,-Bsymbolic -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384" \
|
|
368
|
+
"--enable-openssl --extra-libs=-lz"
|
|
369
|
+
|
|
370
|
+
rm -rf ${OUTPUT_DIR}/android/x86/share
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
# x86_64
|
|
374
|
+
build_arch "x86_64" "android" \
|
|
375
|
+
"${TOOLCHAIN}/bin/x86_64-linux-android${API_LEVEL}-clang" \
|
|
376
|
+
"${TOOLCHAIN}/bin/x86_64-linux-android${API_LEVEL}-clang++" \
|
|
377
|
+
"-I${OPENSSL_PREBUILT_FOLDER}/include -I${TOOLCHAIN}/darwin-x86_64/sysroot/usr/include -fPIC -Wl,-Bsymbolic -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384" \
|
|
378
|
+
"-L${OPENSSL_PREBUILT_FOLDER}/x86_64 -L${TOOLCHAIN}/darwin-x86_64/sysroot/usr/lib/x86_64-linux-android/${API_LEVEL} -fPIC -Wl,-Bsymbolic -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384" \
|
|
379
|
+
"--enable-openssl --extra-libs=-lz"
|
|
380
|
+
|
|
381
|
+
rm -rf ${OUTPUT_DIR}/android/x86_64/share
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
echo "Android builds completed!"
|
|
385
|
+
else
|
|
386
|
+
echo "Skipping Android builds (ANDROID_NDK_ROOT or NDK_ROOT not set)"
|
|
387
|
+
fi
|
|
388
|
+
|
|
389
|
+
rm -rf "${BUILD_DIR}"
|
|
390
|
+
|
|
391
|
+
echo "All FFmpeg builds completed!"
|
|
@@ -34,34 +34,6 @@ AudioBus::AudioBus(const AudioBus &other) {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
AudioBus::AudioBus(AudioBus &&other) noexcept
|
|
38
|
-
: channels_(std::move(other.channels_)),
|
|
39
|
-
numberOfChannels_(other.numberOfChannels_),
|
|
40
|
-
sampleRate_(other.sampleRate_),
|
|
41
|
-
size_(other.size_) {
|
|
42
|
-
other.numberOfChannels_ = 0;
|
|
43
|
-
other.sampleRate_ = 0.0f;
|
|
44
|
-
other.size_ = 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
AudioBus &AudioBus::operator=(const AudioBus &other) {
|
|
48
|
-
if (this == &other) {
|
|
49
|
-
return *this;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
numberOfChannels_ = other.numberOfChannels_;
|
|
53
|
-
sampleRate_ = other.sampleRate_;
|
|
54
|
-
size_ = other.size_;
|
|
55
|
-
|
|
56
|
-
createChannels();
|
|
57
|
-
|
|
58
|
-
for (int i = 0; i < numberOfChannels_; i += 1) {
|
|
59
|
-
channels_[i] = std::make_shared<AudioArray>(*other.channels_[i]);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return *this;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
37
|
AudioBus::~AudioBus() {
|
|
66
38
|
channels_.clear();
|
|
67
39
|
}
|
|
@@ -24,11 +24,8 @@ class AudioBus {
|
|
|
24
24
|
ChannelSurroundRight = 5,
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
explicit AudioBus() = default;
|
|
28
27
|
explicit AudioBus(size_t size, int numberOfChannels, float sampleRate);
|
|
29
28
|
AudioBus(const AudioBus &other);
|
|
30
|
-
AudioBus(AudioBus &&other) noexcept;
|
|
31
|
-
AudioBus& operator=(const AudioBus& other);
|
|
32
29
|
|
|
33
30
|
~AudioBus();
|
|
34
31
|
|
|
@@ -20,11 +20,6 @@ class ThreadPool {
|
|
|
20
20
|
struct TaskEvent { audioapi::move_only_function<void()> task; };
|
|
21
21
|
using Event = std::variant<TaskEvent, StopEvent>;
|
|
22
22
|
|
|
23
|
-
struct Cntrl {
|
|
24
|
-
std::atomic<bool> waitingForTasks{false};
|
|
25
|
-
std::atomic<size_t> tasksScheduled{0};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
23
|
using Sender = channels::spsc::Sender<Event, channels::spsc::OverflowStrategy::WAIT_ON_FULL, channels::spsc::WaitStrategy::ATOMIC_WAIT>;
|
|
29
24
|
using Receiver = channels::spsc::Receiver<Event, channels::spsc::OverflowStrategy::WAIT_ON_FULL, channels::spsc::WaitStrategy::ATOMIC_WAIT>;
|
|
30
25
|
public:
|
|
@@ -43,30 +38,8 @@ public:
|
|
|
43
38
|
workerSenders.emplace_back(std::move(workerSender));
|
|
44
39
|
}
|
|
45
40
|
loadBalancerThread = std::thread(&ThreadPool::loadBalancerThreadFunc, this, std::move(receiver), std::move(workerSenders));
|
|
46
|
-
controlBlock_ = std::make_unique<Cntrl>();
|
|
47
|
-
}
|
|
48
|
-
ThreadPool(const ThreadPool&) = delete;
|
|
49
|
-
ThreadPool& operator=(const ThreadPool&) = delete;
|
|
50
|
-
ThreadPool(ThreadPool&& other):
|
|
51
|
-
loadBalancerThread(std::move(other.loadBalancerThread)),
|
|
52
|
-
workers(std::move(other.workers)),
|
|
53
|
-
loadBalancerSender(std::move(other.loadBalancerSender)),
|
|
54
|
-
controlBlock_(std::move(other.controlBlock_)) {}
|
|
55
|
-
ThreadPool& operator=(ThreadPool&& other) {
|
|
56
|
-
if (this != &other) {
|
|
57
|
-
loadBalancerThread = std::move(other.loadBalancerThread);
|
|
58
|
-
workers = std::move(other.workers);
|
|
59
|
-
loadBalancerSender = std::move(other.loadBalancerSender);
|
|
60
|
-
controlBlock_ = std::move(other.controlBlock_);
|
|
61
|
-
other.movedFrom_ = true;
|
|
62
|
-
}
|
|
63
|
-
return *this;
|
|
64
41
|
}
|
|
65
|
-
|
|
66
42
|
~ThreadPool() {
|
|
67
|
-
if (movedFrom_) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
43
|
loadBalancerSender.send(StopEvent{});
|
|
71
44
|
loadBalancerThread.join();
|
|
72
45
|
for (auto& worker : workers) {
|
|
@@ -86,47 +59,16 @@ public:
|
|
|
86
59
|
/// @note IMPORTANT: This function is not thread-safe and should be called from a single thread only.
|
|
87
60
|
template<typename Func, typename ... Args, typename = std::enable_if_t<std::is_invocable_r_v<void, Func, Args...>>>
|
|
88
61
|
void schedule(Func &&task, Args &&... args) noexcept {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
/// We know that lifetime of each worker thus spsc thus lambda is strongly bounded by ThreadPool lifetime
|
|
92
|
-
/// so we can safely capture control block pointer unsafely here
|
|
93
|
-
Cntrl *cntrl = controlBlock_.get();
|
|
94
|
-
auto boundTask = [cntrl, f= std::forward<Func>(task), ...capturedArgs = std::forward<Args>(args)]() mutable {
|
|
62
|
+
auto boundTask = [f = std::forward<Func>(task), ...capturedArgs = std::forward<Args>(args)]() mutable {
|
|
95
63
|
f(std::forward<Args>(capturedArgs)...);
|
|
96
|
-
size_t left = cntrl->tasksScheduled.fetch_sub(1, std::memory_order_acq_rel) - 1;
|
|
97
|
-
if (left == 0) {
|
|
98
|
-
cntrl->waitingForTasks.store(false, std::memory_order_release);
|
|
99
|
-
cntrl->waitingForTasks.notify_one();
|
|
100
|
-
}
|
|
101
64
|
};
|
|
102
65
|
loadBalancerSender.send(TaskEvent{audioapi::move_only_function<void()>(std::move(boundTask))});
|
|
103
66
|
}
|
|
104
67
|
|
|
105
|
-
/// @brief Waits for all scheduled tasks to complete
|
|
106
|
-
void wait() {
|
|
107
|
-
/// This logic might seem incorrect at first glance
|
|
108
|
-
/// Main principle for this is that there is only one thread scheduling tasks
|
|
109
|
-
/// If he is waiting for the tasks he CANNOT schedule new tasks so we can assume partial
|
|
110
|
-
/// synchronization here.
|
|
111
|
-
/// We first store true so if any task finishes at this moment he will flip it
|
|
112
|
-
/// Then we check if there are any tasks scheduled
|
|
113
|
-
/// If there are none we can return immediately
|
|
114
|
-
/// If there are some we wait until the last task flips the flag to false
|
|
115
|
-
controlBlock_->waitingForTasks.store(true, std::memory_order_release);
|
|
116
|
-
if (controlBlock_->tasksScheduled.load(std::memory_order_acquire) == 0) {
|
|
117
|
-
controlBlock_->waitingForTasks.store(false, std::memory_order_release);
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
controlBlock_->waitingForTasks.wait(true, std::memory_order_acquire);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
68
|
private:
|
|
125
69
|
std::thread loadBalancerThread;
|
|
126
70
|
std::vector<std::thread> workers;
|
|
127
71
|
Sender loadBalancerSender;
|
|
128
|
-
std::unique_ptr<Cntrl> controlBlock_;
|
|
129
|
-
bool movedFrom_ = false;
|
|
130
72
|
|
|
131
73
|
void workerThreadFunc(Receiver &&receiver) {
|
|
132
74
|
Receiver localReceiver = std::move(receiver);
|
|
@@ -12,44 +12,41 @@ FetchContent_Declare(
|
|
|
12
12
|
googletest
|
|
13
13
|
URL https://github.com/google/googletest/archive/3983f67e32fb3e9294487b9d4f9586efa6e5d088.zip
|
|
14
14
|
)
|
|
15
|
-
|
|
16
15
|
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
|
17
16
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
18
17
|
FetchContent_MakeAvailable(googletest)
|
|
19
18
|
|
|
20
19
|
enable_testing()
|
|
21
20
|
|
|
22
|
-
set(REACT_NATIVE_AUDIO_API_DIR "${ROOT}/node_modules/react-native-audio-api")
|
|
23
|
-
|
|
24
21
|
file(GLOB_RECURSE RNAUDIOAPI_SRC
|
|
25
22
|
CONFIGURE_DEPENDS
|
|
26
|
-
"${
|
|
27
|
-
"${
|
|
23
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/*.cpp"
|
|
24
|
+
"${ROOT}/node_modules/react-native-audio-api/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp"
|
|
28
25
|
)
|
|
29
26
|
|
|
30
27
|
# exclude HostObjects from tests
|
|
31
28
|
list(FILTER RNAUDIOAPI_SRC EXCLUDE REGEX ".*/audioapi/HostObjects/.*\\.cpp$")
|
|
32
29
|
|
|
33
30
|
list(REMOVE_ITEM RNAUDIOAPI_SRC
|
|
34
|
-
"${
|
|
35
|
-
"${
|
|
36
|
-
"${
|
|
37
|
-
"${
|
|
38
|
-
"${
|
|
39
|
-
"${
|
|
40
|
-
"${
|
|
41
|
-
"${
|
|
31
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/core/AudioContext.cpp"
|
|
32
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/core/effects/WorkletNode.cpp"
|
|
33
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/core/effects/WorkletProcessingNode.cpp"
|
|
34
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/core/sources/WorkletSourceNode.cpp"
|
|
35
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/core/sources/StreamerNode.cpp"
|
|
36
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/core/sources/StreamerNode.h"
|
|
37
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp"
|
|
38
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.h"
|
|
42
39
|
)
|
|
43
40
|
|
|
44
41
|
file(GLOB_RECURSE RNAUDIOAPI_LIBS
|
|
45
42
|
CONFIGURE_DEPENDS
|
|
46
|
-
"${
|
|
47
|
-
"${
|
|
43
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/*.c"
|
|
44
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/*.h"
|
|
48
45
|
)
|
|
49
46
|
|
|
50
47
|
list(REMOVE_ITEM RNAUDIOAPI_LIBS
|
|
51
|
-
"${
|
|
52
|
-
"${
|
|
48
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.c"
|
|
49
|
+
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.c"
|
|
53
50
|
)
|
|
54
51
|
|
|
55
52
|
add_library(rnaudioapi STATIC ${RNAUDIOAPI_SRC})
|
|
@@ -60,8 +57,6 @@ target_include_directories(rnaudioapi PUBLIC
|
|
|
60
57
|
${JSI_DIR}
|
|
61
58
|
"${REACT_NATIVE_DIR}/ReactCommon"
|
|
62
59
|
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
|
|
63
|
-
${gtest_SOURCE_DIR}/include
|
|
64
|
-
${gmock_SOURCE_DIR}/include
|
|
65
60
|
)
|
|
66
61
|
|
|
67
62
|
target_include_directories(rnaudioapi_libs PUBLIC
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
2
|
#import <React/RCTCallInvokerModule.h>
|
|
3
|
-
#import <React/RCTInvalidating.h>
|
|
4
3
|
#import <rnaudioapi/rnaudioapi.h>
|
|
5
4
|
#else // RCT_NEW_ARCH_ENABLED
|
|
6
5
|
#import <React/RCTBridgeModule.h>
|
|
@@ -15,7 +14,7 @@
|
|
|
15
14
|
|
|
16
15
|
@interface AudioAPIModule : RCTEventEmitter
|
|
17
16
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
18
|
-
<NativeAudioAPIModuleSpec, RCTCallInvokerModule
|
|
17
|
+
<NativeAudioAPIModuleSpec, RCTCallInvokerModule>
|
|
19
18
|
#else
|
|
20
19
|
<RCTBridgeModule>
|
|
21
20
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#ifndef __OBJC__ // when compiled as C++
|
|
4
|
+
typedef struct objc_object AVAudioFile;
|
|
5
|
+
typedef struct objc_object NSURL;
|
|
6
|
+
typedef struct objc_object AudioBufferList;
|
|
7
|
+
#endif // __OBJC__
|
|
8
|
+
|
|
9
|
+
namespace audioapi {
|
|
10
|
+
|
|
11
|
+
class IOSAudioFileOptions {
|
|
12
|
+
public:
|
|
13
|
+
IOSAudioFileOptions(float sampleRate, size_t channelCount, size_t bitRate, size_t flags);
|
|
14
|
+
~IOSAudioFileOptions() = default;
|
|
15
|
+
|
|
16
|
+
AudioFormatID getFormat() const;
|
|
17
|
+
NSInteger getQuality() const;
|
|
18
|
+
NSInteger getFlacCompressionLevel() const;
|
|
19
|
+
NSSearchPathDirectory getDirectory() const;
|
|
20
|
+
NSString *getFileExtension() const;
|
|
21
|
+
NSInteger getBitDepth() const;
|
|
22
|
+
NSDictionary *getFileSettings();
|
|
23
|
+
float getSampleRate();
|
|
24
|
+
|
|
25
|
+
private:
|
|
26
|
+
uint8_t format_;
|
|
27
|
+
uint8_t quality_;
|
|
28
|
+
uint8_t flacCompressionLevel_;
|
|
29
|
+
uint8_t directory_;
|
|
30
|
+
uint8_t bitDepth_;
|
|
31
|
+
float sampleRate_;
|
|
32
|
+
size_t channelCount_;
|
|
33
|
+
size_t bitRate_;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
} // namespace audioapi
|