react-native-audio-api 0.8.0-nightly-5a12f24-20250901 → 0.8.0-nightly-daaceff-20250902
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 +15 -6
- package/android/build.gradle +10 -1
- package/android/src/main/cpp/audioapi/CMakeLists.txt +21 -5
- 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/HostObjects/BaseAudioContextHostObject.h +11 -0
- package/common/cpp/audioapi/HostObjects/StreamerNodeHostObject.h +30 -0
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +9 -0
- package/common/cpp/audioapi/core/BaseAudioContext.h +2 -0
- package/common/cpp/audioapi/core/sources/StreamerNode.cpp +299 -0
- package/common/cpp/audioapi/core/sources/StreamerNode.h +123 -0
- package/common/cpp/audioapi/external/arm64-v8a/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libssl.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libssl.a +0 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/ac3_parser.h +36 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/adts_parser.h +37 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/avcodec.h +2947 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/avdct.h +88 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/bsf.h +332 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec.h +367 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_desc.h +134 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_id.h +681 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_par.h +248 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/d3d11va.h +109 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/defs.h +359 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/dirac.h +135 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/dv_profile.h +82 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/dxva2.h +90 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/jni.h +67 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/mediacodec.h +103 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/packet.h +907 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/qsv.h +109 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/vdpau.h +138 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/version.h +45 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/version_major.h +55 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/videotoolbox.h +85 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/vorbis_parser.h +74 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/avformat.h +3004 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/avio.h +831 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/version.h +47 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/version_major.h +50 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/adler32.h +63 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/aes.h +69 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/aes_ctr.h +99 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/ambient_viewing_environment.h +72 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/attributes.h +175 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/audio_fifo.h +187 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avassert.h +120 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avconfig.h +6 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avstring.h +428 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avutil.h +364 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/base64.h +72 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/blowfish.h +82 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/bprint.h +254 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/bswap.h +105 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/buffer.h +322 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/camellia.h +70 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/cast5.h +80 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/channel_layout.h +762 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/common.h +589 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/container_fifo.h +130 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/cpu.h +150 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/crc.h +102 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/csp.h +192 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/des.h +81 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/detection_bbox.h +108 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/dict.h +242 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/display.h +109 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/dovi_meta.h +396 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/downmix_info.h +115 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/encryption_info.h +205 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/error.h +129 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/eval.h +140 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/executor.h +67 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/ffversion.h +5 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/fifo.h +242 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/file.h +62 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/film_grain_params.h +282 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/frame.h +1163 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hash.h +264 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hdr_dynamic_metadata.h +376 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hdr_dynamic_vivid_metadata.h +292 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hmac.h +99 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext.h +601 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_amf.h +46 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_cuda.h +74 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_d3d11va.h +178 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_d3d12va.h +142 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_drm.h +169 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_dxva2.h +75 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_mediacodec.h +61 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_oh.h +34 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_opencl.h +100 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_qsv.h +87 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_vaapi.h +117 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_vdpau.h +44 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_videotoolbox.h +106 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_vulkan.h +377 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/iamf.h +694 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/imgutils.h +377 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/intfloat.h +77 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/intreadwrite.h +677 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/lfg.h +81 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/log.h +427 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/lzo.h +66 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/macros.h +80 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/mastering_display_metadata.h +137 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/mathematics.h +300 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/md5.h +89 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/mem.h +607 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/motion_vector.h +57 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/murmur3.h +115 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/opt.h +1194 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/parseutils.h +197 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/pixdesc.h +440 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/pixelutils.h +51 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/pixfmt.h +797 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/random_seed.h +57 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/rational.h +225 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/rc4.h +69 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/refstruct.h +297 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/replaygain.h +50 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/ripemd.h +83 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/samplefmt.h +269 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/sha.h +90 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/sha512.h +92 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/spherical.h +243 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/stereo3d.h +325 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tdrdi.h +164 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tea.h +71 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/threadmessage.h +115 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/timecode.h +199 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/timestamp.h +85 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tree.h +137 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/twofish.h +70 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tx.h +210 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/uuid.h +146 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/version.h +119 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/video_enc_params.h +171 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/video_hint.h +107 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/xtea.h +94 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libswresample/swresample.h +587 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libswresample/version.h +46 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libswresample/version_major.h +31 -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/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/libavcodec.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/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/libssl.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libssl.a +0 -0
- package/common/cpp/audioapi/libs/ffmpeg/INSTRUCTIONS.md +26 -0
- package/common/cpp/audioapi/libs/ffmpeg/create_xcframework.sh +111 -0
- package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +360 -0
- package/common/cpp/test/CMakeLists.txt +5 -1
- package/lib/commonjs/api.js +7 -0
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +4 -0
- package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
- package/lib/commonjs/core/StreamerNode.js +15 -0
- package/lib/commonjs/core/StreamerNode.js.map +1 -0
- package/lib/module/api.js +1 -0
- package/lib/module/api.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +4 -0
- package/lib/module/core/BaseAudioContext.js.map +1 -1
- package/lib/module/core/StreamerNode.js +9 -0
- package/lib/module/core/StreamerNode.js.map +1 -0
- package/lib/typescript/api.d.ts +1 -0
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/core/BaseAudioContext.d.ts +2 -0
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/core/StreamerNode.d.ts +5 -0
- package/lib/typescript/core/StreamerNode.d.ts.map +1 -0
- package/lib/typescript/interfaces.d.ts +4 -0
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +1 -0
- package/src/core/BaseAudioContext.ts +5 -0
- package/src/core/StreamerNode.ts +8 -0
- package/src/interfaces.ts +5 -0
package/RNAudioAPI.podspec
CHANGED
|
@@ -35,10 +35,20 @@ Pod::Spec.new do |s|
|
|
|
35
35
|
|
|
36
36
|
s.compiler_flags = "#{folly_flags}"
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
41
41
|
|
|
42
|
+
external_dir = File.join(__dir__, "common/cpp/audioapi/external")
|
|
43
|
+
lib_dir = "#{external_dir}/$(PLATFORM_NAME)"
|
|
44
|
+
|
|
45
|
+
s.ios.vendored_frameworks = [
|
|
46
|
+
'common/cpp/audioapi/external/libavcodec.xcframework',
|
|
47
|
+
'common/cpp/audioapi/external/libavformat.xcframework',
|
|
48
|
+
'common/cpp/audioapi/external/libavutil.xcframework',
|
|
49
|
+
'common/cpp/audioapi/external/libswresample.xcframework'
|
|
50
|
+
]
|
|
51
|
+
|
|
42
52
|
s.pod_target_xcconfig = {
|
|
43
53
|
"USE_HEADERMAP" => "YES",
|
|
44
54
|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
@@ -49,6 +59,7 @@ s.pod_target_xcconfig = {
|
|
|
49
59
|
#{external_dir}/include
|
|
50
60
|
#{external_dir}/include/opus
|
|
51
61
|
#{external_dir}/include/vorbis
|
|
62
|
+
$(PODS_TARGET_SRCROOT)/common/cpp/audioapi/external/ffmpeg_include
|
|
52
63
|
].join(" "),
|
|
53
64
|
'OTHER_CFLAGS' => "$(inherited) #{folly_flags} #{fabric_flags} #{version_flag}"
|
|
54
65
|
}
|
|
@@ -67,6 +78,4 @@ s.user_target_xcconfig = {
|
|
|
67
78
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
68
79
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
69
80
|
install_modules_dependencies(s)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
end
|
package/android/build.gradle
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import com.android.Version
|
|
2
2
|
import org.apache.tools.ant.taskdefs.condition.Os
|
|
3
|
-
import com.android.build.gradle.tasks.ExternalNativeBuildJsonTask
|
|
4
3
|
|
|
5
4
|
buildscript {
|
|
6
5
|
repositories {
|
|
@@ -92,6 +91,11 @@ def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 100
|
|
|
92
91
|
def IS_NEW_ARCHITECTURE_ENABLED = isNewArchitectureEnabled()
|
|
93
92
|
|
|
94
93
|
android {
|
|
94
|
+
sourceSets {
|
|
95
|
+
main {
|
|
96
|
+
jniLibs.srcDirs = ['src/main/jniLibs']
|
|
97
|
+
}
|
|
98
|
+
}
|
|
95
99
|
if (supportsNamespace()) {
|
|
96
100
|
namespace "com.swmansion.audioapi"
|
|
97
101
|
|
|
@@ -125,6 +129,9 @@ android {
|
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
packagingOptions {
|
|
132
|
+
jniLibs {
|
|
133
|
+
useLegacyPackaging = false // enables 16KB alignment
|
|
134
|
+
}
|
|
128
135
|
excludes = [
|
|
129
136
|
"META-INF",
|
|
130
137
|
"META-INF/**",
|
|
@@ -230,8 +237,10 @@ def assertMinimalReactNativeVersion = task assertMinimalReactNativeVersionTask {
|
|
|
230
237
|
}
|
|
231
238
|
}
|
|
232
239
|
|
|
240
|
+
// Make preBuild depend on the download task
|
|
233
241
|
tasks.preBuild {
|
|
234
242
|
dependsOn assertMinimalReactNativeVersion
|
|
243
|
+
// dependsOn downloadStaticPrebuiltLibraries TODO: re-add when we have prebuilt libs put somewhere public
|
|
235
244
|
}
|
|
236
245
|
|
|
237
246
|
task cleanCmakeCache() {
|
|
@@ -3,17 +3,26 @@ cmake_minimum_required(VERSION 3.12.0)
|
|
|
3
3
|
file(GLOB_RECURSE ANDROID_CPP_SOURCES CONFIGURE_DEPENDS "${ANDROID_CPP_DIR}/audioapi/*.cpp")
|
|
4
4
|
file(GLOB_RECURSE COMMON_CPP_SOURCES CONFIGURE_DEPENDS "${COMMON_CPP_DIR}/audioapi/*.cpp" "${COMMON_CPP_DIR}/audioapi/*.c")
|
|
5
5
|
|
|
6
|
+
set(INCLUDE_DIR ${COMMON_CPP_DIR}/audioapi/external/include)
|
|
7
|
+
set(FFMPEG_INCLUDE_DIR ${COMMON_CPP_DIR}/audioapi/external/ffmpeg_include)
|
|
6
8
|
set(EXTERNAL_DIR ${COMMON_CPP_DIR}/audioapi/external)
|
|
7
|
-
set(
|
|
8
|
-
|
|
9
|
+
set(JNI_LIBS_DIR ${COMMON_CPP_DIR}/../../android/src/main/jniLibs)
|
|
10
|
+
|
|
11
|
+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-Bsymbolic")
|
|
12
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-Bsymbolic")
|
|
9
13
|
|
|
10
14
|
add_library(react-native-audio-api SHARED ${ANDROID_CPP_SOURCES} ${COMMON_CPP_SOURCES})
|
|
11
15
|
|
|
12
|
-
foreach(lib IN ITEMS opus opusfile ogg vorbis vorbisenc vorbisfile)
|
|
16
|
+
foreach(lib IN ITEMS opus opusfile ogg vorbis vorbisenc vorbisfile crypto ssl)
|
|
13
17
|
add_library(${lib} STATIC IMPORTED)
|
|
14
|
-
set_target_properties(${lib} PROPERTIES IMPORTED_LOCATION ${
|
|
18
|
+
set_target_properties(${lib} PROPERTIES IMPORTED_LOCATION ${EXTERNAL_DIR}/${ANDROID_ABI}/lib${lib}.a)
|
|
15
19
|
endforeach()
|
|
16
20
|
|
|
21
|
+
foreach (lib IN ITEMS avcodec avformat avutil swresample)
|
|
22
|
+
add_library(${lib} SHARED IMPORTED)
|
|
23
|
+
set_target_properties(${lib} PROPERTIES IMPORTED_LOCATION ${JNI_LIBS_DIR}/${ANDROID_ABI}/lib${lib}.so)
|
|
24
|
+
endforeach()
|
|
25
|
+
|
|
17
26
|
find_package(ReactAndroid REQUIRED CONFIG)
|
|
18
27
|
find_package(fbjni REQUIRED CONFIG)
|
|
19
28
|
find_package(oboe REQUIRED CONFIG)
|
|
@@ -25,7 +34,7 @@ target_include_directories(
|
|
|
25
34
|
"${ANDROID_CPP_DIR}"
|
|
26
35
|
"${INCLUDE_DIR}"
|
|
27
36
|
"${INCLUDE_DIR}/opus"
|
|
28
|
-
"${
|
|
37
|
+
"${FFMPEG_INCLUDE_DIR}"
|
|
29
38
|
"${REACT_NATIVE_DIR}/ReactCommon"
|
|
30
39
|
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
|
|
31
40
|
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
|
|
@@ -61,4 +70,11 @@ target_link_libraries(react-native-audio-api
|
|
|
61
70
|
vorbis
|
|
62
71
|
vorbisenc
|
|
63
72
|
vorbisfile
|
|
73
|
+
avcodec
|
|
74
|
+
avformat
|
|
75
|
+
avutil
|
|
76
|
+
swresample
|
|
77
|
+
crypto
|
|
78
|
+
ssl
|
|
79
|
+
z
|
|
64
80
|
)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
#include <audioapi/HostObjects/StereoPannerNodeHostObject.h>
|
|
15
15
|
#include <audioapi/HostObjects/AnalyserNodeHostObject.h>
|
|
16
16
|
#include <audioapi/HostObjects/RecorderAdapterNodeHostObject.h>
|
|
17
|
+
#include <audioapi/HostObjects/StreamerNodeHostObject.h>
|
|
17
18
|
|
|
18
19
|
#include <jsi/jsi.h>
|
|
19
20
|
#include <memory>
|
|
@@ -42,6 +43,7 @@ class BaseAudioContextHostObject : public JsiHostObject {
|
|
|
42
43
|
addFunctions(
|
|
43
44
|
JSI_EXPORT_FUNCTION(BaseAudioContextHostObject, createRecorderAdapter),
|
|
44
45
|
JSI_EXPORT_FUNCTION(BaseAudioContextHostObject, createOscillator),
|
|
46
|
+
JSI_EXPORT_FUNCTION(BaseAudioContextHostObject, createStreamer),
|
|
45
47
|
JSI_EXPORT_FUNCTION(BaseAudioContextHostObject, createGain),
|
|
46
48
|
JSI_EXPORT_FUNCTION(BaseAudioContextHostObject, createStereoPanner),
|
|
47
49
|
JSI_EXPORT_FUNCTION(BaseAudioContextHostObject, createBiquadFilter),
|
|
@@ -88,6 +90,15 @@ class BaseAudioContextHostObject : public JsiHostObject {
|
|
|
88
90
|
return jsi::Object::createFromHostObject(runtime, oscillatorHostObject);
|
|
89
91
|
}
|
|
90
92
|
|
|
93
|
+
JSI_HOST_FUNCTION(createStreamer) {
|
|
94
|
+
auto streamer = context_->createStreamer();
|
|
95
|
+
auto streamerHostObject =
|
|
96
|
+
std::make_shared<StreamerNodeHostObject>(streamer);
|
|
97
|
+
auto object = jsi::Object::createFromHostObject(runtime, streamerHostObject);
|
|
98
|
+
object.setExternalMemoryPressure(runtime, StreamerNode::getEstimatedSize());
|
|
99
|
+
return object;
|
|
100
|
+
}
|
|
101
|
+
|
|
91
102
|
JSI_HOST_FUNCTION(createGain) {
|
|
92
103
|
auto gain = context_->createGain();
|
|
93
104
|
auto gainHostObject = std::make_shared<GainNodeHostObject>(gain);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <audioapi/HostObjects/AudioScheduledSourceNodeHostObject.h>
|
|
4
|
+
#include <audioapi/HostObjects/AudioParamHostObject.h>
|
|
5
|
+
#include <audioapi/HostObjects/PeriodicWaveHostObject.h>
|
|
6
|
+
#include <audioapi/core/sources/StreamerNode.h>
|
|
7
|
+
|
|
8
|
+
#include <memory>
|
|
9
|
+
#include <string>
|
|
10
|
+
#include <vector>
|
|
11
|
+
|
|
12
|
+
namespace audioapi {
|
|
13
|
+
using namespace facebook;
|
|
14
|
+
|
|
15
|
+
class StreamerNodeHostObject : public AudioScheduledSourceNodeHostObject {
|
|
16
|
+
public:
|
|
17
|
+
explicit StreamerNodeHostObject(
|
|
18
|
+
const std::shared_ptr<StreamerNode> &node)
|
|
19
|
+
: AudioScheduledSourceNodeHostObject(node) {
|
|
20
|
+
addFunctions(JSI_EXPORT_FUNCTION(StreamerNodeHostObject, initialize));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
JSI_HOST_FUNCTION(initialize) {
|
|
24
|
+
auto streamerNode = std::static_pointer_cast<StreamerNode>(node_);
|
|
25
|
+
auto path = args[0].getString(runtime).utf8(runtime);
|
|
26
|
+
auto result = streamerNode->initialize(path);
|
|
27
|
+
return jsi::Value(result);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
} // namespace audioapi
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
#include <audioapi/core/sources/AudioBufferSourceNode.h>
|
|
10
10
|
#include <audioapi/core/sources/OscillatorNode.h>
|
|
11
11
|
#include <audioapi/core/sources/RecorderAdapterNode.h>
|
|
12
|
+
#include <audioapi/core/sources/StreamerNode.h>
|
|
12
13
|
#include <audioapi/core/utils/AudioDecoder.h>
|
|
13
14
|
#include <audioapi/core/utils/AudioNodeManager.h>
|
|
14
15
|
#include <audioapi/events/AudioEventHandlerRegistry.h>
|
|
@@ -69,6 +70,14 @@ std::shared_ptr<OscillatorNode> BaseAudioContext::createOscillator() {
|
|
|
69
70
|
return oscillator;
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
#ifndef AUDIO_API_TEST_SUITE
|
|
74
|
+
std::shared_ptr<StreamerNode> BaseAudioContext::createStreamer() {
|
|
75
|
+
auto streamer = std::make_shared<StreamerNode>(this);
|
|
76
|
+
nodeManager_->addSourceNode(streamer);
|
|
77
|
+
return streamer;
|
|
78
|
+
}
|
|
79
|
+
#endif
|
|
80
|
+
|
|
72
81
|
std::shared_ptr<GainNode> BaseAudioContext::createGain() {
|
|
73
82
|
auto gain = std::make_shared<GainNode>(this);
|
|
74
83
|
nodeManager_->addProcessingNode(gain);
|
|
@@ -31,6 +31,7 @@ class AnalyserNode;
|
|
|
31
31
|
class AudioEventHandlerRegistry;
|
|
32
32
|
class IAudioEventHandlerRegistry;
|
|
33
33
|
class RecorderAdapterNode;
|
|
34
|
+
class StreamerNode;
|
|
34
35
|
|
|
35
36
|
class BaseAudioContext {
|
|
36
37
|
public:
|
|
@@ -45,6 +46,7 @@ class BaseAudioContext {
|
|
|
45
46
|
|
|
46
47
|
std::shared_ptr<RecorderAdapterNode> createRecorderAdapter();
|
|
47
48
|
std::shared_ptr<OscillatorNode> createOscillator();
|
|
49
|
+
std::shared_ptr<StreamerNode> createStreamer();
|
|
48
50
|
std::shared_ptr<GainNode> createGain();
|
|
49
51
|
std::shared_ptr<StereoPannerNode> createStereoPanner();
|
|
50
52
|
std::shared_ptr<BiquadFilterNode> createBiquadFilter();
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file links to the FFmpeg library, which is licensed under the
|
|
3
|
+
* GNU Lesser General Public License (LGPL) version 2.1 or later.
|
|
4
|
+
*
|
|
5
|
+
* Our own code in this file is licensed under the MIT License, but note
|
|
6
|
+
* that linking with FFmpeg means you must comply with the terms of the
|
|
7
|
+
* LGPL for FFmpeg itself.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include <audioapi/core/BaseAudioContext.h>
|
|
11
|
+
#include <audioapi/core/sources/StreamerNode.h>
|
|
12
|
+
#include <audioapi/core/utils/Locker.h>
|
|
13
|
+
#include <audioapi/dsp/VectorMath.h>
|
|
14
|
+
#include <audioapi/utils/AudioArray.h>
|
|
15
|
+
#include <audioapi/utils/AudioBus.h>
|
|
16
|
+
#include <chrono>
|
|
17
|
+
|
|
18
|
+
namespace audioapi {
|
|
19
|
+
StreamerNode::StreamerNode(BaseAudioContext *context)
|
|
20
|
+
: AudioScheduledSourceNode(context),
|
|
21
|
+
fmtCtx_(nullptr),
|
|
22
|
+
codecCtx_(nullptr),
|
|
23
|
+
decoder_(nullptr),
|
|
24
|
+
codecpar_(nullptr),
|
|
25
|
+
pkt_(nullptr),
|
|
26
|
+
frame_(nullptr),
|
|
27
|
+
pendingFrame_(nullptr),
|
|
28
|
+
bufferedBus_(nullptr),
|
|
29
|
+
bufferedBusIndex_(0),
|
|
30
|
+
maxBufferSize_(0),
|
|
31
|
+
audio_stream_index_(-1),
|
|
32
|
+
swrCtx_(nullptr),
|
|
33
|
+
resampledData_(nullptr),
|
|
34
|
+
maxResampledSamples_(0) {}
|
|
35
|
+
|
|
36
|
+
StreamerNode::~StreamerNode() {
|
|
37
|
+
cleanup();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
bool StreamerNode::initialize(const std::string &input_url) {
|
|
41
|
+
if (isInitialized_) {
|
|
42
|
+
cleanup();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!openInput(input_url)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!findAudioStream() || !setupDecoder() || !setupResampler()) {
|
|
50
|
+
cleanup();
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
pkt_ = av_packet_alloc();
|
|
55
|
+
frame_ = av_frame_alloc();
|
|
56
|
+
|
|
57
|
+
if (pkt_ == nullptr || frame_ == nullptr) {
|
|
58
|
+
cleanup();
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
maxBufferSize_ = BUFFER_LENGTH_SECONDS * codecCtx_->sample_rate;
|
|
63
|
+
// If decoding is faster than playing, we buffer few seconds of audio
|
|
64
|
+
bufferedBus_ = std::make_shared<AudioBus>(
|
|
65
|
+
maxBufferSize_, codecpar_->ch_layout.nb_channels, codecCtx_->sample_rate);
|
|
66
|
+
|
|
67
|
+
channelCount_ = codecpar_->ch_layout.nb_channels;
|
|
68
|
+
audioBus_ = std::make_shared<AudioBus>(
|
|
69
|
+
RENDER_QUANTUM_SIZE, channelCount_, context_->getSampleRate());
|
|
70
|
+
|
|
71
|
+
streamingThread_ = std::thread(&StreamerNode::streamAudio, this);
|
|
72
|
+
streamFlag.store(true);
|
|
73
|
+
isInitialized_ = true;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
void StreamerNode::stop(double when) {
|
|
78
|
+
AudioScheduledSourceNode::stop(when);
|
|
79
|
+
streamFlag.store(false);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
bool StreamerNode::setupResampler() {
|
|
83
|
+
// Allocate resampler context
|
|
84
|
+
swrCtx_ = swr_alloc();
|
|
85
|
+
if (swrCtx_ == nullptr) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Set input parameters (from codec)
|
|
90
|
+
av_opt_set_chlayout(swrCtx_, "in_chlayout", &codecCtx_->ch_layout, 0);
|
|
91
|
+
av_opt_set_int(swrCtx_, "in_sample_rate", codecCtx_->sample_rate, 0);
|
|
92
|
+
av_opt_set_sample_fmt(swrCtx_, "in_sample_fmt", codecCtx_->sample_fmt, 0);
|
|
93
|
+
|
|
94
|
+
// Set output parameters (float)
|
|
95
|
+
av_opt_set_chlayout(swrCtx_, "out_chlayout", &codecCtx_->ch_layout, 0);
|
|
96
|
+
av_opt_set_int(swrCtx_, "out_sample_rate", context_->getSampleRate(), 0);
|
|
97
|
+
av_opt_set_sample_fmt(swrCtx_, "out_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);
|
|
98
|
+
|
|
99
|
+
// Initialize the resampler
|
|
100
|
+
if (swr_init(swrCtx_) < 0) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Allocate output buffer for resampled data
|
|
105
|
+
maxResampledSamples_ = INITIAL_MAX_RESAMPLED_SAMPLES;
|
|
106
|
+
int ret = av_samples_alloc_array_and_samples(
|
|
107
|
+
&resampledData_,
|
|
108
|
+
nullptr,
|
|
109
|
+
codecCtx_->ch_layout.nb_channels,
|
|
110
|
+
maxResampledSamples_,
|
|
111
|
+
AV_SAMPLE_FMT_FLTP,
|
|
112
|
+
0);
|
|
113
|
+
|
|
114
|
+
return ret >= 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
void StreamerNode::streamAudio() {
|
|
118
|
+
while (streamFlag.load()) {
|
|
119
|
+
if (pendingFrame_ != nullptr) {
|
|
120
|
+
if (!processFrameWithResampler(pendingFrame_)) {
|
|
121
|
+
cleanup();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
if (av_read_frame(fmtCtx_, pkt_) < 0) {
|
|
126
|
+
cleanup();
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (pkt_->stream_index == audio_stream_index_) {
|
|
130
|
+
if (avcodec_send_packet(codecCtx_, pkt_) != 0) {
|
|
131
|
+
cleanup();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (avcodec_receive_frame(codecCtx_, frame_) != 0) {
|
|
135
|
+
cleanup();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (!processFrameWithResampler(frame_)) {
|
|
139
|
+
cleanup();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
av_packet_unref(pkt_);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
void StreamerNode::processNode(
|
|
150
|
+
const std::shared_ptr<AudioBus> &processingBus,
|
|
151
|
+
int framesToProcess) {
|
|
152
|
+
size_t startOffset = 0;
|
|
153
|
+
size_t offsetLength = 0;
|
|
154
|
+
updatePlaybackInfo(processingBus, framesToProcess, startOffset, offsetLength);
|
|
155
|
+
// If we have enough buffered data, copy to output bus
|
|
156
|
+
if (bufferedBusIndex_ >= framesToProcess) {
|
|
157
|
+
Locker locker(mutex_);
|
|
158
|
+
for (int ch = 0; ch < processingBus->getNumberOfChannels(); ch++) {
|
|
159
|
+
memcpy(
|
|
160
|
+
processingBus->getChannel(ch)->getData(),
|
|
161
|
+
bufferedBus_->getChannel(ch)->getData(),
|
|
162
|
+
offsetLength * sizeof(float));
|
|
163
|
+
|
|
164
|
+
memmove(
|
|
165
|
+
bufferedBus_->getChannel(ch)->getData(),
|
|
166
|
+
bufferedBus_->getChannel(ch)->getData() + offsetLength,
|
|
167
|
+
(maxBufferSize_ - offsetLength) * sizeof(float));
|
|
168
|
+
}
|
|
169
|
+
bufferedBusIndex_ -= offsetLength;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
bool StreamerNode::processFrameWithResampler(AVFrame *frame) {
|
|
174
|
+
// Check if we need to reallocate the resampled buffer
|
|
175
|
+
int out_samples = swr_get_out_samples(swrCtx_, frame->nb_samples);
|
|
176
|
+
if (out_samples > maxResampledSamples_) {
|
|
177
|
+
av_freep(&resampledData_[0]);
|
|
178
|
+
av_freep(&resampledData_);
|
|
179
|
+
|
|
180
|
+
maxResampledSamples_ = out_samples;
|
|
181
|
+
int ret = av_samples_alloc_array_and_samples(
|
|
182
|
+
&resampledData_,
|
|
183
|
+
nullptr,
|
|
184
|
+
codecCtx_->ch_layout.nb_channels,
|
|
185
|
+
maxResampledSamples_,
|
|
186
|
+
AV_SAMPLE_FMT_FLTP,
|
|
187
|
+
0);
|
|
188
|
+
|
|
189
|
+
if (ret < 0) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Convert the frame
|
|
195
|
+
int converted_samples = swr_convert(
|
|
196
|
+
swrCtx_,
|
|
197
|
+
resampledData_,
|
|
198
|
+
maxResampledSamples_,
|
|
199
|
+
(const uint8_t **)frame->data,
|
|
200
|
+
frame->nb_samples);
|
|
201
|
+
|
|
202
|
+
if (converted_samples < 0) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Check if converted data fits in buffer
|
|
207
|
+
if (bufferedBusIndex_ + converted_samples > maxBufferSize_) {
|
|
208
|
+
pendingFrame_ = frame;
|
|
209
|
+
return true;
|
|
210
|
+
} else {
|
|
211
|
+
pendingFrame_ = nullptr;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Copy converted data to our buffer
|
|
215
|
+
Locker locker(mutex_);
|
|
216
|
+
for (int ch = 0; ch < codecCtx_->ch_layout.nb_channels; ch++) {
|
|
217
|
+
auto *src = reinterpret_cast<float *>(resampledData_[ch]);
|
|
218
|
+
float *dst = bufferedBus_->getChannel(ch)->getData() + bufferedBusIndex_;
|
|
219
|
+
memcpy(dst, src, converted_samples * sizeof(float));
|
|
220
|
+
}
|
|
221
|
+
bufferedBusIndex_ += converted_samples;
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
bool StreamerNode::openInput(const std::string &input_url) {
|
|
226
|
+
if (avformat_open_input(&fmtCtx_, input_url.c_str(), nullptr, nullptr) < 0) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
return avformat_find_stream_info(fmtCtx_, nullptr) >= 0;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
bool StreamerNode::findAudioStream() {
|
|
233
|
+
audio_stream_index_ = -1;
|
|
234
|
+
codecpar_ = nullptr;
|
|
235
|
+
|
|
236
|
+
for (int i = 0; i < fmtCtx_->nb_streams; ++i) {
|
|
237
|
+
if (fmtCtx_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
|
|
238
|
+
audio_stream_index_ = i;
|
|
239
|
+
codecpar_ = fmtCtx_->streams[i]->codecpar;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return audio_stream_index_ >= 0 && codecpar_ != nullptr;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
bool StreamerNode::setupDecoder() {
|
|
248
|
+
decoder_ = avcodec_find_decoder(codecpar_->codec_id);
|
|
249
|
+
if (decoder_ == nullptr) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
codecCtx_ = avcodec_alloc_context3(decoder_);
|
|
254
|
+
if (codecCtx_ == nullptr) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (avcodec_parameters_to_context(codecCtx_, codecpar_) < 0) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return avcodec_open2(codecCtx_, decoder_, nullptr) >= 0;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
void StreamerNode::cleanup() {
|
|
266
|
+
streamFlag.store(false);
|
|
267
|
+
streamingThread_.join();
|
|
268
|
+
if (swrCtx_ != nullptr) {
|
|
269
|
+
swr_free(&swrCtx_);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (resampledData_ != nullptr) {
|
|
273
|
+
av_freep(&resampledData_[0]);
|
|
274
|
+
av_freep(&resampledData_);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (frame_ != nullptr) {
|
|
278
|
+
av_frame_free(&frame_);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (pkt_ != nullptr) {
|
|
282
|
+
av_packet_free(&pkt_);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (codecCtx_ != nullptr) {
|
|
286
|
+
avcodec_free_context(&codecCtx_);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (fmtCtx_ != nullptr) {
|
|
290
|
+
avformat_close_input(&fmtCtx_);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
audio_stream_index_ = -1;
|
|
294
|
+
isInitialized_ = false;
|
|
295
|
+
decoder_ = nullptr;
|
|
296
|
+
codecpar_ = nullptr;
|
|
297
|
+
maxResampledSamples_ = 0;
|
|
298
|
+
}
|
|
299
|
+
} // namespace audioapi
|