react-native-audio-api 0.10.0-nightly-c815c40-20251026 → 0.11.0-alpha.0
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 +5 -9
- package/android/build.gradle +3 -33
- 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 +94 -28
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +28 -14
- 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 +33 -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 +431 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +112 -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 +237 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +46 -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/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/effects/BiquadFilterNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +80 -18
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +15 -6
- package/common/cpp/audioapi/core/AudioParam.cpp +2 -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 +102 -49
- package/common/cpp/audioapi/core/inputs/AudioRecorder.h +46 -28
- 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/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/test/CMakeLists.txt +0 -3
- package/ios/audioapi/ios/AudioAPIModule.h +1 -2
- package/ios/audioapi/ios/AudioAPIModule.mm +0 -2
- package/ios/audioapi/ios/core/IOSAudioFileOptions.h +35 -0
- package/ios/audioapi/ios/core/IOSAudioFileOptions.mm +135 -0
- package/ios/audioapi/ios/core/IOSAudioFileWriter.h +38 -0
- package/ios/audioapi/ios/core/IOSAudioFileWriter.mm +187 -0
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +18 -10
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +70 -28
- package/ios/audioapi/ios/core/NativeAudioRecorder.h +2 -6
- package/ios/audioapi/ios/core/NativeAudioRecorder.m +5 -73
- 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 -134
- package/lib/commonjs/api.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 +157 -12
- package/lib/commonjs/core/AudioRecorder.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +25 -16
- 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 +50 -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/module/api.js +15 -15
- package/lib/module/api.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 +157 -12
- package/lib/module/core/AudioRecorder.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +26 -17
- 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 +46 -0
- 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/typescript/api.d.ts +17 -18
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/core/AudioRecorder.d.ts +58 -6
- package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
- 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 +39 -3
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +75 -4
- 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/package.json +4 -7
- package/src/api.ts +18 -44
- package/src/core/AudioContext.ts +2 -3
- package/src/core/AudioRecorder.ts +190 -20
- package/src/core/BaseAudioContext.ts +60 -44
- package/src/core/OfflineAudioContext.ts +2 -2
- package/src/events/types.ts +18 -0
- package/src/interfaces.ts +47 -4
- package/src/types.ts +86 -4
- package/src/utils/bitEnums.ts +51 -0
- package/src/utils/index.ts +2 -22
- package/common/cpp/audioapi/libs/ffmpeg/relinking.md +0 -24
- 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/scripts/download-prebuilt-binaries.sh +0 -52
- package/scripts/rnaa_utils.rb +0 -8
- package/scripts/validate-worklets-version.js +0 -28
package/RNAudioAPI.podspec
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require "json"
|
|
2
|
-
require_relative './scripts/rnaa_utils'
|
|
3
2
|
|
|
4
3
|
package_json = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
5
4
|
|
|
@@ -9,8 +8,6 @@ folly_flags = "-DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-
|
|
|
9
8
|
fabric_flags = $new_arch_enabled ? '-DRCT_NEW_ARCH_ENABLED' : ''
|
|
10
9
|
version_flag = "-DAUDIOAPI_VERSION=#{package_json['version']}"
|
|
11
10
|
|
|
12
|
-
worklets_preprocessor_flag = check_if_worklets_enabled() ? '-DRN_AUDIO_API_ENABLE_WORKLETS=1' : ''
|
|
13
|
-
|
|
14
11
|
Pod::Spec.new do |s|
|
|
15
12
|
s.name = "RNAudioAPI"
|
|
16
13
|
s.version = package_json["version"]
|
|
@@ -38,10 +35,9 @@ Pod::Spec.new do |s|
|
|
|
38
35
|
|
|
39
36
|
s.compiler_flags = "#{folly_flags}"
|
|
40
37
|
|
|
41
|
-
s.prepare_command = <<-CMD
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
CMD
|
|
38
|
+
# s.prepare_command = <<-CMD TODO: re-add when we have prebuilt libs put somewhere public
|
|
39
|
+
# ruby -r './scripts/download-audioapi-libs.rb'
|
|
40
|
+
# CMD
|
|
45
41
|
|
|
46
42
|
# Assumes Pods dir is nested under ios project dir
|
|
47
43
|
ios_dir = File.join(Pod::Config.instance.project_pods_root, '..')
|
|
@@ -72,8 +68,8 @@ s.pod_target_xcconfig = {
|
|
|
72
68
|
$(PODS_TARGET_SRCROOT)/#{external_dir_relative}/include/vorbis
|
|
73
69
|
$(PODS_TARGET_SRCROOT)/#{external_dir_relative}/ffmpeg_include
|
|
74
70
|
].join(" "),
|
|
75
|
-
'OTHER_CFLAGS' => "$(inherited) #{folly_flags} #{fabric_flags} #{version_flag}
|
|
76
|
-
'OTHER_CPLUSPLUSFLAGS' => "$(inherited) #{folly_flags} #{fabric_flags} #{version_flag}
|
|
71
|
+
'OTHER_CFLAGS' => "$(inherited) #{folly_flags} #{fabric_flags} #{version_flag}",
|
|
72
|
+
'OTHER_CPLUSPLUSFLAGS' => "$(inherited) #{folly_flags} #{fabric_flags} #{version_flag}"
|
|
77
73
|
}
|
|
78
74
|
|
|
79
75
|
s.user_target_xcconfig = {
|
package/android/build.gradle
CHANGED
|
@@ -74,30 +74,6 @@ def resolveReactNativeWorkletsDirectory() {
|
|
|
74
74
|
return null;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
def validateWorkletsVersion() {
|
|
78
|
-
def validationScript = file("${projectDir}/../scripts/validate-worklets-version.js")
|
|
79
|
-
if (!validationScript.exists()) {
|
|
80
|
-
logger.error("[AudioAPI] Worklets validation script not found at ${validationScript.absolutePath}")
|
|
81
|
-
return false
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
def process = ["node", validationScript.absolutePath].execute()
|
|
86
|
-
process.waitForProcessOutput(System.out, System.err)
|
|
87
|
-
def exitCode = process.exitValue()
|
|
88
|
-
|
|
89
|
-
if (exitCode == 0) {
|
|
90
|
-
return true
|
|
91
|
-
} else {
|
|
92
|
-
logger.warn("[AudioAPI] Worklets version validation failed")
|
|
93
|
-
return false
|
|
94
|
-
}
|
|
95
|
-
} catch (Exception e) {
|
|
96
|
-
logger.error("[AudioAPI] Failed to validate worklets version: ${e.message}")
|
|
97
|
-
return false
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
77
|
def toPlatformFileString(String path) {
|
|
102
78
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
103
79
|
path = path.replace(File.separatorChar, '/' as char)
|
|
@@ -116,7 +92,7 @@ static def supportsNamespace() {
|
|
|
116
92
|
|
|
117
93
|
def reactNativeRootDir = resolveReactNativeDirectory()
|
|
118
94
|
def reactNativeWorkletsRootDir = resolveReactNativeWorkletsDirectory()
|
|
119
|
-
def isWorkletsAvailable = reactNativeWorkletsRootDir != null
|
|
95
|
+
def isWorkletsAvailable = reactNativeWorkletsRootDir != null
|
|
120
96
|
|
|
121
97
|
def reactProperties = new Properties()
|
|
122
98
|
file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
|
|
@@ -147,7 +123,7 @@ android {
|
|
|
147
123
|
defaultConfig {
|
|
148
124
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
149
125
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
150
|
-
|
|
126
|
+
|
|
151
127
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
152
128
|
buildConfigField "boolean", "RN_AUDIO_API_ENABLE_WORKLETS", "${isWorkletsAvailable}"
|
|
153
129
|
|
|
@@ -301,16 +277,10 @@ def assertMinimalReactNativeVersion = task assertMinimalReactNativeVersionTask {
|
|
|
301
277
|
}
|
|
302
278
|
}
|
|
303
279
|
|
|
304
|
-
task downloadPrebuiltBinaries(type: Exec) {
|
|
305
|
-
commandLine 'chmod', '+x', '../scripts/download-prebuilt-binaries.sh'
|
|
306
|
-
commandLine 'bash', '../scripts/download-prebuilt-binaries.sh'
|
|
307
|
-
args 'android'
|
|
308
|
-
}
|
|
309
|
-
|
|
310
280
|
// Make preBuild depend on the download task
|
|
311
281
|
tasks.preBuild {
|
|
312
282
|
dependsOn assertMinimalReactNativeVersion
|
|
313
|
-
dependsOn
|
|
283
|
+
// dependsOn downloadStaticPrebuiltLibraries TODO: re-add when we have prebuilt libs put somewhere public
|
|
314
284
|
}
|
|
315
285
|
|
|
316
286
|
task cleanCmakeCache() {
|
|
@@ -51,7 +51,6 @@ void AudioAPIModule::registerNatives() {
|
|
|
51
51
|
makeNativeMethod(
|
|
52
52
|
"invokeHandlerWithEventNameAndEventBody",
|
|
53
53
|
AudioAPIModule::invokeHandlerWithEventNameAndEventBody),
|
|
54
|
-
makeNativeMethod("closeAllContexts", AudioAPIModule::closeAllContexts),
|
|
55
54
|
});
|
|
56
55
|
}
|
|
57
56
|
|
|
@@ -102,8 +101,4 @@ void AudioAPIModule::invokeHandlerWithEventNameAndEventBody(
|
|
|
102
101
|
eventName->toStdString(), body);
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
|
-
|
|
106
|
-
void AudioAPIModule::closeAllContexts() {
|
|
107
|
-
AudioAPIModuleInstaller::closeAllContexts();
|
|
108
|
-
}
|
|
109
104
|
} // namespace audioapi
|
|
@@ -34,7 +34,6 @@ class AudioAPIModule : public jni::HybridClass<AudioAPIModule> {
|
|
|
34
34
|
|
|
35
35
|
void injectJSIBindings();
|
|
36
36
|
void invokeHandlerWithEventNameAndEventBody(jni::alias_ref<jni::JString> eventName, jni::alias_ref<jni::JMap<jstring, jobject>> eventBody);
|
|
37
|
-
void closeAllContexts();
|
|
38
37
|
|
|
39
38
|
private:
|
|
40
39
|
friend HybridBase;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
#include <android/log.h>
|
|
1
2
|
#include <audioapi/android/core/AndroidAudioRecorder.h>
|
|
3
|
+
#include <audioapi/android/core/utils/AndroidFileWriterBackend.h>
|
|
4
|
+
#include <audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h>
|
|
5
|
+
#include <audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h>
|
|
2
6
|
#include <audioapi/core/sources/RecorderAdapterNode.h>
|
|
3
7
|
#include <audioapi/core/utils/Constants.h>
|
|
4
8
|
#include <audioapi/events/AudioEventHandlerRegistry.h>
|
|
@@ -10,22 +14,23 @@
|
|
|
10
14
|
namespace audioapi {
|
|
11
15
|
|
|
12
16
|
AndroidAudioRecorder::AndroidAudioRecorder(
|
|
13
|
-
float sampleRate,
|
|
14
|
-
int bufferLength,
|
|
15
17
|
const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry)
|
|
16
|
-
: AudioRecorder(
|
|
18
|
+
: AudioRecorder(audioEventHandlerRegistry) {
|
|
17
19
|
AudioStreamBuilder builder;
|
|
20
|
+
|
|
18
21
|
builder.setSharingMode(SharingMode::Exclusive)
|
|
19
22
|
->setDirection(Direction::Input)
|
|
20
23
|
->setFormat(AudioFormat::Float)
|
|
21
24
|
->setFormatConversionAllowed(true)
|
|
22
25
|
->setPerformanceMode(PerformanceMode::None)
|
|
23
|
-
->setChannelCount(1)
|
|
24
26
|
->setSampleRateConversionQuality(SampleRateConversionQuality::Medium)
|
|
25
27
|
->setDataCallback(this)
|
|
26
|
-
->setSampleRate(static_cast<int>(sampleRate))
|
|
27
28
|
->openStream(mStream_);
|
|
28
29
|
|
|
30
|
+
streamSampleRate_ = mStream_->getSampleRate();
|
|
31
|
+
streamChannelCount_ = mStream_->getChannelCount();
|
|
32
|
+
streamMaxBufferSizeInFrames_ = mStream_->getBufferSizeInFrames();
|
|
33
|
+
|
|
29
34
|
nativeAudioRecorder_ = jni::make_global(NativeAudioRecorder::create());
|
|
30
35
|
}
|
|
31
36
|
|
|
@@ -40,52 +45,113 @@ AndroidAudioRecorder::~AndroidAudioRecorder() {
|
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
void AndroidAudioRecorder::start() {
|
|
43
|
-
if (
|
|
48
|
+
if (isRecording()) {
|
|
44
49
|
return;
|
|
45
50
|
}
|
|
46
51
|
|
|
47
|
-
if (mStream_) {
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
if (!mStream_ || !nativeAudioRecorder_) {
|
|
53
|
+
__android_log_print(
|
|
54
|
+
ANDROID_LOG_ERROR,
|
|
55
|
+
"AndroidAudioRecorder",
|
|
56
|
+
"Audio stream is not initialized.\n");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (usesFileOutput()) {
|
|
61
|
+
fileWriter_->openFile(
|
|
62
|
+
streamSampleRate_, streamChannelCount_, streamMaxBufferSizeInFrames_);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (usesCallback()) {
|
|
66
|
+
// TODO: create circular buffer and converter?
|
|
50
67
|
}
|
|
51
68
|
|
|
69
|
+
if (isConnected()) {
|
|
70
|
+
// TODO: set adapter node properties?
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
nativeAudioRecorder_->start();
|
|
74
|
+
mStream_->requestStart();
|
|
52
75
|
isRunning_.store(true);
|
|
53
76
|
}
|
|
54
77
|
|
|
55
|
-
|
|
56
|
-
if (!
|
|
57
|
-
return;
|
|
78
|
+
std::string AndroidAudioRecorder::stop() {
|
|
79
|
+
if (!isRecording()) {
|
|
80
|
+
return "";
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!mStream_ || !nativeAudioRecorder_) {
|
|
84
|
+
__android_log_print(
|
|
85
|
+
ANDROID_LOG_ERROR,
|
|
86
|
+
"AndroidAudioRecorder",
|
|
87
|
+
"Audio stream is not initialized.\n");
|
|
88
|
+
return "";
|
|
58
89
|
}
|
|
59
90
|
|
|
91
|
+
nativeAudioRecorder_->stop();
|
|
92
|
+
mStream_->requestStop();
|
|
60
93
|
isRunning_.store(false);
|
|
61
94
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
95
|
+
// TODO: sendRemainingData() ?
|
|
96
|
+
|
|
97
|
+
if (usesFileOutput()) {
|
|
98
|
+
return fileWriter_->closeFile();
|
|
65
99
|
}
|
|
66
100
|
|
|
67
|
-
|
|
101
|
+
return "";
|
|
68
102
|
}
|
|
69
103
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
104
|
+
void AndroidAudioRecorder::enableFileOutput(
|
|
105
|
+
float sampleRate,
|
|
106
|
+
size_t channelCount,
|
|
107
|
+
size_t bitRate,
|
|
108
|
+
size_t iosFlags,
|
|
109
|
+
size_t androidFlags) {
|
|
110
|
+
uint8_t format = static_cast<uint8_t>(androidFlags & 0xF);
|
|
111
|
+
|
|
112
|
+
if (format == 1) {
|
|
113
|
+
fileWriter_ = std::make_shared<MiniAudioFileWriter>(
|
|
114
|
+
sampleRate, channelCount, bitRate, androidFlags);
|
|
115
|
+
} else {
|
|
116
|
+
fileWriter_ = std::make_shared<FFmpegAudioFileWriter>(
|
|
117
|
+
sampleRate, channelCount, bitRate, androidFlags);
|
|
77
118
|
}
|
|
78
119
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
120
|
+
fileOutputEnabled_.store(true);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
void AndroidAudioRecorder::disableFileOutput() {
|
|
124
|
+
fileOutputEnabled_.store(false);
|
|
125
|
+
fileWriter_ = nullptr;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
void AndroidAudioRecorder::pause() {}
|
|
82
129
|
|
|
83
|
-
|
|
130
|
+
void AndroidAudioRecorder::resume() {}
|
|
84
131
|
|
|
85
|
-
|
|
132
|
+
DataCallbackResult AndroidAudioRecorder::onAudioReady(
|
|
133
|
+
oboe::AudioStream *oboeStream,
|
|
134
|
+
void *audioData,
|
|
135
|
+
int32_t numFrames) {
|
|
136
|
+
if (usesFileOutput()) {
|
|
137
|
+
fileWriter_->writeAudioData(audioData, numFrames);
|
|
86
138
|
}
|
|
87
139
|
|
|
88
140
|
return DataCallbackResult::Continue;
|
|
89
141
|
}
|
|
90
142
|
|
|
91
143
|
} // namespace audioapi
|
|
144
|
+
|
|
145
|
+
// if (isRunning_.load()) {
|
|
146
|
+
// auto *inputChannel = static_cast<float *>(audioData);
|
|
147
|
+
// writeToBuffers(inputChannel, numFrames);
|
|
148
|
+
// }
|
|
149
|
+
|
|
150
|
+
// while (circularBuffer_->getNumberOfAvailableFrames() >= bufferLength_) {
|
|
151
|
+
// auto bus = std::make_shared<AudioBus>(bufferLength_, 1, sampleRate_);
|
|
152
|
+
// auto *outputChannel = bus->getChannel(0)->getData();
|
|
153
|
+
|
|
154
|
+
// circularBuffer_->pop_front(outputChannel, bufferLength_);
|
|
155
|
+
|
|
156
|
+
// invokeOnAudioReadyCallback(bus, bufferLength_);
|
|
157
|
+
// }
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#include <oboe/Oboe.h>
|
|
6
6
|
#include <functional>
|
|
7
7
|
#include <memory>
|
|
8
|
+
#include <string>
|
|
8
9
|
|
|
9
10
|
#include <audioapi/android/core/NativeAudioRecorder.hpp>
|
|
10
11
|
|
|
@@ -13,28 +14,41 @@ namespace audioapi {
|
|
|
13
14
|
using namespace oboe;
|
|
14
15
|
|
|
15
16
|
class AudioBus;
|
|
17
|
+
class CircularAudioArray;
|
|
18
|
+
class AndroidFileWriterBackend;
|
|
19
|
+
class AudioEventHandlerRegistry;
|
|
16
20
|
|
|
17
21
|
class AndroidAudioRecorder : public AudioStreamDataCallback, public AudioRecorder {
|
|
18
22
|
public:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry
|
|
22
|
-
);
|
|
23
|
+
explicit AndroidAudioRecorder(const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry);
|
|
24
|
+
~AndroidAudioRecorder() override;
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
void start() override;
|
|
27
|
+
std::string stop() override;
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
void enableFileOutput(
|
|
30
|
+
float sampleRate,
|
|
31
|
+
size_t channelCount,
|
|
32
|
+
size_t bitRate,
|
|
33
|
+
size_t iosFlags,
|
|
34
|
+
size_t androidFlags) override;
|
|
35
|
+
void disableFileOutput() override;
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
void *audioData,
|
|
32
|
-
int32_t numFrames) override;
|
|
37
|
+
void pause() override;
|
|
38
|
+
void resume() override;
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
DataCallbackResult onAudioReady(
|
|
41
|
+
AudioStream *oboeStream,
|
|
42
|
+
void *audioData,
|
|
43
|
+
int32_t numFrames) override;
|
|
36
44
|
|
|
37
|
-
|
|
45
|
+
private:
|
|
46
|
+
std::shared_ptr<AndroidFileWriterBackend> fileWriter_;
|
|
47
|
+
std::shared_ptr<AudioStream> mStream_;
|
|
48
|
+
facebook::jni::global_ref<NativeAudioRecorder> nativeAudioRecorder_;
|
|
49
|
+
int32_t streamSampleRate_;
|
|
50
|
+
int32_t streamChannelCount_;
|
|
51
|
+
int32_t streamMaxBufferSizeInFrames_;
|
|
38
52
|
};
|
|
39
53
|
|
|
40
54
|
} // namespace audioapi
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
#include <audioapi/core/utils/Constants.h>
|
|
5
5
|
#include <audioapi/utils/AudioArray.h>
|
|
6
6
|
#include <audioapi/utils/AudioBus.h>
|
|
7
|
-
#include <jni.h>
|
|
8
7
|
|
|
9
8
|
namespace audioapi {
|
|
10
9
|
|
|
@@ -50,8 +49,7 @@ bool AudioPlayer::openAudioStream() {
|
|
|
50
49
|
|
|
51
50
|
bool AudioPlayer::start() {
|
|
52
51
|
if (mStream_) {
|
|
53
|
-
|
|
54
|
-
[this]() { nativeAudioPlayer_->start(); });
|
|
52
|
+
nativeAudioPlayer_->start();
|
|
55
53
|
auto result = mStream_->requestStart();
|
|
56
54
|
return result == oboe::Result::OK;
|
|
57
55
|
}
|
|
@@ -61,7 +59,7 @@ bool AudioPlayer::start() {
|
|
|
61
59
|
|
|
62
60
|
void AudioPlayer::stop() {
|
|
63
61
|
if (mStream_) {
|
|
64
|
-
|
|
62
|
+
nativeAudioPlayer_->stop();
|
|
65
63
|
mStream_->requestStop();
|
|
66
64
|
}
|
|
67
65
|
}
|
|
@@ -22,15 +22,15 @@ class NativeAudioRecorder : public jni::JavaClass<NativeAudioRecorder> {
|
|
|
22
22
|
return newInstance();
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
void start() {
|
|
26
|
+
static const auto method = javaClassStatic()->getMethod<void()>("start");
|
|
27
|
+
method(self());
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
void stop() {
|
|
31
|
+
static const auto method = javaClassStatic()->getMethod<void()>("stop");
|
|
32
|
+
method(self());
|
|
33
|
+
}
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
} // namespace audioapi
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <memory>
|
|
5
|
+
|
|
6
|
+
namespace audioapi {
|
|
7
|
+
|
|
8
|
+
class AndroidFileWriterBackend {
|
|
9
|
+
public:
|
|
10
|
+
AndroidFileWriterBackend(
|
|
11
|
+
float sampleRate,
|
|
12
|
+
size_t channelCount,
|
|
13
|
+
size_t bitRate,
|
|
14
|
+
size_t androidFlags) {}
|
|
15
|
+
|
|
16
|
+
virtual ~AndroidFileWriterBackend() = default;
|
|
17
|
+
|
|
18
|
+
virtual void openFile(int32_t streamSampleRate, int32_t streamChannelCount, int32_t streamMaxBufferSize) = 0;
|
|
19
|
+
virtual std::string closeFile() = 0;
|
|
20
|
+
|
|
21
|
+
virtual bool writeAudioData(void *data, int numFrames) = 0;
|
|
22
|
+
|
|
23
|
+
std::string getFilePath() const { return filePath_; }
|
|
24
|
+
|
|
25
|
+
protected:
|
|
26
|
+
std::string filePath_{""};
|
|
27
|
+
|
|
28
|
+
int32_t streamSampleRate_{0};
|
|
29
|
+
int32_t streamChannelCount_{0};
|
|
30
|
+
int32_t streamMaxBufferSize_{0};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
} // namespace audioapi
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
#include <audioapi/utils/AudioArray.h>
|
|
6
6
|
#include <audioapi/utils/AudioBus.h>
|
|
7
7
|
|
|
8
|
-
#define MINIAUDIO_IMPLEMENTATION
|
|
9
8
|
#include <audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.h>
|
|
10
9
|
#include <audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.h>
|
|
11
10
|
#include <audioapi/libs/miniaudio/miniaudio.h>
|
|
@@ -99,11 +98,6 @@ std::shared_ptr<AudioBuffer> AudioDecoder::decodeWithFilePath(
|
|
|
99
98
|
sizeof(customBackends) / sizeof(customBackends[0]);
|
|
100
99
|
|
|
101
100
|
if (ma_decoder_init_file(path.c_str(), &config, &decoder) != MA_SUCCESS) {
|
|
102
|
-
__android_log_print(
|
|
103
|
-
ANDROID_LOG_ERROR,
|
|
104
|
-
"AudioDecoder",
|
|
105
|
-
"Failed to initialize decoder for file: %s",
|
|
106
|
-
path.c_str());
|
|
107
101
|
ma_decoder_uninit(&decoder);
|
|
108
102
|
return nullptr;
|
|
109
103
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
namespace audioapi::android::fileutils {
|
|
6
|
+
|
|
7
|
+
enum class FileDirectory {
|
|
8
|
+
FILES_DIR,
|
|
9
|
+
CACHE_DIR,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
enum class FileFormat {
|
|
13
|
+
WAV,
|
|
14
|
+
CAF,
|
|
15
|
+
M4A,
|
|
16
|
+
FLAC,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
enum class BitDepth {
|
|
20
|
+
BIT_16,
|
|
21
|
+
BIT_24,
|
|
22
|
+
BIT_32,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
bool createDirectoryIfNotExists(const std::string &directoryPath);
|
|
26
|
+
std::string getTimestampString();
|
|
27
|
+
std::string getISODateString();
|
|
28
|
+
FileFormat formatFromFlags(size_t flags);
|
|
29
|
+
FileDirectory directoryFromFlags(size_t flags);
|
|
30
|
+
BitDepth bitDepthFromFlags(size_t flags);
|
|
31
|
+
std::string getDirectory(FileDirectory dir);
|
|
32
|
+
std::string getFilePath(const FileDirectory &directory, const std::string &baseFileName, const std::string &extension);
|
|
33
|
+
|
|
34
|
+
} // namespace audioapi::android::fileutils
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
|
|
2
|
+
#include <android/log.h>
|
|
3
|
+
#include <audioapi/android/core/utils/FileUtils.h>
|
|
4
|
+
#include <audioapi/android/system/NativeFileInfo.hpp>
|
|
5
|
+
#include <chrono>
|
|
6
|
+
#include <filesystem>
|
|
7
|
+
#include <format>
|
|
8
|
+
#include <iostream>
|
|
9
|
+
|
|
10
|
+
namespace audioapi::android::fileutils {
|
|
11
|
+
|
|
12
|
+
bool createDirectoryIfNotExists(const std::string &directoryPath) {
|
|
13
|
+
std::error_code ec;
|
|
14
|
+
|
|
15
|
+
if (!std::filesystem::exists(directoryPath, ec)) {
|
|
16
|
+
bool created = std::filesystem::create_directories(directoryPath, ec);
|
|
17
|
+
|
|
18
|
+
if (ec) {
|
|
19
|
+
__android_log_print(
|
|
20
|
+
ANDROID_LOG_ERROR,
|
|
21
|
+
"FileUtils",
|
|
22
|
+
"Error creating directory at path: %s, error: %s",
|
|
23
|
+
directoryPath.c_str(),
|
|
24
|
+
ec.message().c_str());
|
|
25
|
+
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return created;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (ec) {
|
|
33
|
+
__android_log_print(
|
|
34
|
+
ANDROID_LOG_ERROR,
|
|
35
|
+
"FileUtils",
|
|
36
|
+
"Error checking existence of directory at path: %s, error: %s",
|
|
37
|
+
directoryPath.c_str(),
|
|
38
|
+
ec.message().c_str());
|
|
39
|
+
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
std::string getTimestampString() {
|
|
47
|
+
auto tNow = std::chrono::system_clock::now();
|
|
48
|
+
return std::format(
|
|
49
|
+
"{:%Y%m%d_%H%M%S}", std::chrono::floor<std::chrono::seconds>(tNow));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
std::string getISODateString() {
|
|
53
|
+
auto tNow = std::chrono::system_clock::now();
|
|
54
|
+
return std::format(
|
|
55
|
+
"{:%Y-%m-%d}", std::chrono::floor<std::chrono::days>(tNow));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
FileFormat formatFromFlags(size_t flags) {
|
|
59
|
+
uint8_t formatFlag = static_cast<uint8_t>(flags & 0xF);
|
|
60
|
+
|
|
61
|
+
switch (formatFlag) {
|
|
62
|
+
case 1:
|
|
63
|
+
return FileFormat::WAV;
|
|
64
|
+
case 2:
|
|
65
|
+
return FileFormat::CAF;
|
|
66
|
+
case 3:
|
|
67
|
+
return FileFormat::M4A;
|
|
68
|
+
case 4:
|
|
69
|
+
return FileFormat::FLAC;
|
|
70
|
+
default:
|
|
71
|
+
return FileFormat::M4A;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
FileDirectory directoryFromFlags(size_t flags) {
|
|
76
|
+
uint8_t directoryFlag = static_cast<uint8_t>((flags >> 4) & 0xF);
|
|
77
|
+
|
|
78
|
+
switch (directoryFlag) {
|
|
79
|
+
case 1:
|
|
80
|
+
return FileDirectory::FILES_DIR;
|
|
81
|
+
case 2:
|
|
82
|
+
return FileDirectory::CACHE_DIR;
|
|
83
|
+
default:
|
|
84
|
+
return FileDirectory::CACHE_DIR;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
BitDepth bitDepthFromFlags(size_t flags) {
|
|
89
|
+
uint8_t bitDepthFlag = static_cast<uint8_t>((flags >> 8) & 0xF);
|
|
90
|
+
|
|
91
|
+
switch (bitDepthFlag) {
|
|
92
|
+
case 1:
|
|
93
|
+
return BitDepth::BIT_16;
|
|
94
|
+
case 2:
|
|
95
|
+
return BitDepth::BIT_24;
|
|
96
|
+
case 3:
|
|
97
|
+
return BitDepth::BIT_32;
|
|
98
|
+
default:
|
|
99
|
+
return BitDepth::BIT_32;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
std::string getDirectory(FileDirectory dir) {
|
|
104
|
+
switch (dir) {
|
|
105
|
+
case FileDirectory::FILES_DIR:
|
|
106
|
+
return NativeFileInfo::getFilesDir();
|
|
107
|
+
case FileDirectory::CACHE_DIR:
|
|
108
|
+
return NativeFileInfo::getCacheDir();
|
|
109
|
+
default:
|
|
110
|
+
return NativeFileInfo::getCacheDir();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
std::string getFilePath(
|
|
115
|
+
const FileDirectory &directory,
|
|
116
|
+
const std::string &baseFileName,
|
|
117
|
+
const std::string &extension) {
|
|
118
|
+
std::string basePath = getDirectory(directory);
|
|
119
|
+
std::string subDirectory = getISODateString();
|
|
120
|
+
std::string fileTimestamp = getTimestampString();
|
|
121
|
+
|
|
122
|
+
std::string subDirectoryPath =
|
|
123
|
+
std::format("{}/AudioAPI/{}", basePath, subDirectory);
|
|
124
|
+
|
|
125
|
+
if (!createDirectoryIfNotExists(subDirectoryPath)) {
|
|
126
|
+
return "";
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return std::format(
|
|
130
|
+
"{}/{}_{}.{}", subDirectoryPath, baseFileName, fileTimestamp, extension);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
} // namespace audioapi::android::fileutils
|