react-native-audio-api 0.10.0-nightly-971a6b4-20251009 → 0.10.0-nightly-2ae2776-20251011
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/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/core/sources/StreamerNode.cpp +16 -6
- package/common/cpp/audioapi/core/sources/StreamerNode.h +3 -1
- 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/libavcodec +0 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/Info.plist +5 -5
- 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/libavformat +0 -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/libavutil +0 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/Info.plist +5 -5
- 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/libswresample +0 -0
- package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +1 -1
- package/common/cpp/test/CMakeLists.txt +7 -4
- package/common/cpp/test/RunTests.sh +2 -2
- package/common/cpp/test/{AudioParamTest.cpp → src/AudioParamTest.cpp} +1 -1
- package/common/cpp/test/src/ConstantSourceTest.cpp +64 -0
- package/common/cpp/test/{GainTest.cpp → src/GainTest.cpp} +11 -10
- package/common/cpp/test/{MockAudioEventHandlerRegistry.h → src/MockAudioEventHandlerRegistry.h} +4 -2
- package/common/cpp/test/{OscillatorTest.cpp → src/OscillatorTest.cpp} +6 -4
- package/common/cpp/test/{StereoPannerTest.cpp → src/StereoPannerTest.cpp} +1 -1
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +2 -1
- package/package.json +1 -1
|
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
|
|
@@ -44,10 +44,14 @@ bool StreamerNode::initialize(const std::string &input_url) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
if (!openInput(input_url)) {
|
|
47
|
+
if (VERBOSE)
|
|
48
|
+
printf("Failed to open input\n");
|
|
47
49
|
return false;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
if (!findAudioStream() || !setupDecoder() || !setupResampler()) {
|
|
53
|
+
if (VERBOSE)
|
|
54
|
+
printf("Failed to find/setup audio stream\n");
|
|
51
55
|
cleanup();
|
|
52
56
|
return false;
|
|
53
57
|
}
|
|
@@ -56,6 +60,8 @@ bool StreamerNode::initialize(const std::string &input_url) {
|
|
|
56
60
|
frame_ = av_frame_alloc();
|
|
57
61
|
|
|
58
62
|
if (pkt_ == nullptr || frame_ == nullptr) {
|
|
63
|
+
if (VERBOSE)
|
|
64
|
+
printf("Failed to allocate packet or frame\n");
|
|
59
65
|
cleanup();
|
|
60
66
|
return false;
|
|
61
67
|
}
|
|
@@ -119,29 +125,24 @@ void StreamerNode::streamAudio() {
|
|
|
119
125
|
while (streamFlag.load()) {
|
|
120
126
|
if (pendingFrame_ != nullptr) {
|
|
121
127
|
if (!processFrameWithResampler(pendingFrame_)) {
|
|
122
|
-
cleanup();
|
|
123
128
|
return;
|
|
124
129
|
}
|
|
125
130
|
} else {
|
|
126
131
|
if (av_read_frame(fmtCtx_, pkt_) < 0) {
|
|
127
|
-
cleanup();
|
|
128
132
|
return;
|
|
129
133
|
}
|
|
130
134
|
if (pkt_->stream_index == audio_stream_index_) {
|
|
131
135
|
if (avcodec_send_packet(codecCtx_, pkt_) != 0) {
|
|
132
|
-
cleanup();
|
|
133
136
|
return;
|
|
134
137
|
}
|
|
135
138
|
if (avcodec_receive_frame(codecCtx_, frame_) != 0) {
|
|
136
|
-
cleanup();
|
|
137
139
|
return;
|
|
138
140
|
}
|
|
139
141
|
if (!processFrameWithResampler(frame_)) {
|
|
140
|
-
cleanup();
|
|
141
142
|
return;
|
|
142
143
|
}
|
|
143
|
-
av_packet_unref(pkt_);
|
|
144
144
|
}
|
|
145
|
+
av_packet_unref(pkt_);
|
|
145
146
|
}
|
|
146
147
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
147
148
|
}
|
|
@@ -174,6 +175,13 @@ std::shared_ptr<AudioBus> StreamerNode::processNode(
|
|
|
174
175
|
(maxBufferSize_ - offsetLength) * sizeof(float));
|
|
175
176
|
}
|
|
176
177
|
bufferedBusIndex_ -= offsetLength;
|
|
178
|
+
} else {
|
|
179
|
+
if (VERBOSE)
|
|
180
|
+
printf(
|
|
181
|
+
"Buffer underrun: have %zu, need %zu\n",
|
|
182
|
+
bufferedBusIndex_,
|
|
183
|
+
(size_t)framesToProcess);
|
|
184
|
+
processingBus->zero();
|
|
177
185
|
}
|
|
178
186
|
|
|
179
187
|
return processingBus;
|
|
@@ -273,6 +281,8 @@ bool StreamerNode::setupDecoder() {
|
|
|
273
281
|
|
|
274
282
|
void StreamerNode::cleanup() {
|
|
275
283
|
streamFlag.store(false);
|
|
284
|
+
// cleanup cannot be called from the streaming thread so there is no need to
|
|
285
|
+
// check if we are in the same thread
|
|
276
286
|
streamingThread_.join();
|
|
277
287
|
if (swrCtx_ != nullptr) {
|
|
278
288
|
swr_free(&swrCtx_);
|
|
@@ -28,6 +28,8 @@ extern "C" {
|
|
|
28
28
|
#include <string>
|
|
29
29
|
#include <atomic>
|
|
30
30
|
|
|
31
|
+
static bool constexpr VERBOSE = false;
|
|
32
|
+
|
|
31
33
|
namespace audioapi {
|
|
32
34
|
|
|
33
35
|
class AudioBus;
|
|
@@ -94,7 +96,7 @@ class StreamerNode : public AudioScheduledSourceNode {
|
|
|
94
96
|
|
|
95
97
|
/**
|
|
96
98
|
* @brief Open the input stream
|
|
97
|
-
* @param
|
|
99
|
+
* @param inputUrl The URL of the input stream
|
|
98
100
|
* @return true if successful, false otherwise
|
|
99
101
|
* @note This function initializes the FFmpeg libraries and opens the input stream
|
|
100
102
|
*/
|
|
Binary file
|
|
Binary file
|
|
@@ -8,32 +8,32 @@
|
|
|
8
8
|
<key>BinaryPath</key>
|
|
9
9
|
<string>libavformat.framework/libavformat</string>
|
|
10
10
|
<key>LibraryIdentifier</key>
|
|
11
|
-
<string>ios-
|
|
11
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
12
12
|
<key>LibraryPath</key>
|
|
13
13
|
<string>libavformat.framework</string>
|
|
14
14
|
<key>SupportedArchitectures</key>
|
|
15
15
|
<array>
|
|
16
16
|
<string>arm64</string>
|
|
17
|
+
<string>x86_64</string>
|
|
17
18
|
</array>
|
|
18
19
|
<key>SupportedPlatform</key>
|
|
19
20
|
<string>ios</string>
|
|
21
|
+
<key>SupportedPlatformVariant</key>
|
|
22
|
+
<string>simulator</string>
|
|
20
23
|
</dict>
|
|
21
24
|
<dict>
|
|
22
25
|
<key>BinaryPath</key>
|
|
23
26
|
<string>libavformat.framework/libavformat</string>
|
|
24
27
|
<key>LibraryIdentifier</key>
|
|
25
|
-
<string>ios-
|
|
28
|
+
<string>ios-arm64</string>
|
|
26
29
|
<key>LibraryPath</key>
|
|
27
30
|
<string>libavformat.framework</string>
|
|
28
31
|
<key>SupportedArchitectures</key>
|
|
29
32
|
<array>
|
|
30
33
|
<string>arm64</string>
|
|
31
|
-
<string>x86_64</string>
|
|
32
34
|
</array>
|
|
33
35
|
<key>SupportedPlatform</key>
|
|
34
36
|
<string>ios</string>
|
|
35
|
-
<key>SupportedPlatformVariant</key>
|
|
36
|
-
<string>simulator</string>
|
|
37
37
|
</dict>
|
|
38
38
|
</array>
|
|
39
39
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
Binary file
|
package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/libavutil
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -8,32 +8,32 @@
|
|
|
8
8
|
<key>BinaryPath</key>
|
|
9
9
|
<string>libswresample.framework/libswresample</string>
|
|
10
10
|
<key>LibraryIdentifier</key>
|
|
11
|
-
<string>ios-
|
|
11
|
+
<string>ios-arm64</string>
|
|
12
12
|
<key>LibraryPath</key>
|
|
13
13
|
<string>libswresample.framework</string>
|
|
14
14
|
<key>SupportedArchitectures</key>
|
|
15
15
|
<array>
|
|
16
16
|
<string>arm64</string>
|
|
17
|
-
<string>x86_64</string>
|
|
18
17
|
</array>
|
|
19
18
|
<key>SupportedPlatform</key>
|
|
20
19
|
<string>ios</string>
|
|
21
|
-
<key>SupportedPlatformVariant</key>
|
|
22
|
-
<string>simulator</string>
|
|
23
20
|
</dict>
|
|
24
21
|
<dict>
|
|
25
22
|
<key>BinaryPath</key>
|
|
26
23
|
<string>libswresample.framework/libswresample</string>
|
|
27
24
|
<key>LibraryIdentifier</key>
|
|
28
|
-
<string>ios-
|
|
25
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
29
26
|
<key>LibraryPath</key>
|
|
30
27
|
<string>libswresample.framework</string>
|
|
31
28
|
<key>SupportedArchitectures</key>
|
|
32
29
|
<array>
|
|
33
30
|
<string>arm64</string>
|
|
31
|
+
<string>x86_64</string>
|
|
34
32
|
</array>
|
|
35
33
|
<key>SupportedPlatform</key>
|
|
36
34
|
<string>ios</string>
|
|
35
|
+
<key>SupportedPlatformVariant</key>
|
|
36
|
+
<string>simulator</string>
|
|
37
37
|
</dict>
|
|
38
38
|
</array>
|
|
39
39
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
Binary file
|
|
@@ -62,12 +62,15 @@ target_include_directories(rnaudioapi PUBLIC
|
|
|
62
62
|
target_include_directories(rnaudioapi_libs PUBLIC
|
|
63
63
|
${ROOT}/packages/react-native-audio-api/common/cpp
|
|
64
64
|
)
|
|
65
|
+
|
|
66
|
+
file(GLOB_RECURSE test_src
|
|
67
|
+
CONFIGURE_DEPENDS
|
|
68
|
+
"src/*.cpp"
|
|
69
|
+
)
|
|
70
|
+
|
|
65
71
|
add_executable(
|
|
66
72
|
tests
|
|
67
|
-
|
|
68
|
-
GainTest.cpp
|
|
69
|
-
AudioParamTest.cpp
|
|
70
|
-
StereoPannerTest.cpp
|
|
73
|
+
${test_src}
|
|
71
74
|
)
|
|
72
75
|
|
|
73
76
|
add_compile_definitions(AUDIO_API_TEST_SUITE)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#include <audioapi/core/OfflineAudioContext.h>
|
|
2
|
+
#include <audioapi/core/sources/ConstantSourceNode.h>
|
|
3
|
+
#include <audioapi/core/utils/worklets/SafeIncludes.h>
|
|
4
|
+
#include <audioapi/utils/AudioArray.h>
|
|
5
|
+
#include <audioapi/utils/AudioBus.h>
|
|
6
|
+
#include <gtest/gtest.h>
|
|
7
|
+
#include <test/src/MockAudioEventHandlerRegistry.h>
|
|
8
|
+
|
|
9
|
+
using namespace audioapi;
|
|
10
|
+
|
|
11
|
+
class ConstantSourceTest : public ::testing::Test {
|
|
12
|
+
protected:
|
|
13
|
+
std::shared_ptr<IAudioEventHandlerRegistry> eventRegistry;
|
|
14
|
+
std::unique_ptr<OfflineAudioContext> context;
|
|
15
|
+
static constexpr int sampleRate = 44100;
|
|
16
|
+
|
|
17
|
+
void SetUp() override {
|
|
18
|
+
eventRegistry = std::make_shared<MockAudioEventHandlerRegistry>();
|
|
19
|
+
context = std::make_unique<OfflineAudioContext>(
|
|
20
|
+
2, 5 * sampleRate, sampleRate, eventRegistry, RuntimeRegistry{});
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
class TestableConstantSourceNode : public ConstantSourceNode {
|
|
25
|
+
public:
|
|
26
|
+
explicit TestableConstantSourceNode(BaseAudioContext *context)
|
|
27
|
+
: ConstantSourceNode(context) {}
|
|
28
|
+
|
|
29
|
+
void setOffsetParam(float value) {
|
|
30
|
+
getOffsetParam()->setValue(value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
std::shared_ptr<AudioBus> processNode(
|
|
34
|
+
const std::shared_ptr<AudioBus> &processingBus,
|
|
35
|
+
int framesToProcess) override {
|
|
36
|
+
return ConstantSourceNode::processNode(processingBus, framesToProcess);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
TEST_F(ConstantSourceTest, ConstantSourceCanBeCreated) {
|
|
41
|
+
auto constantSource = context->createConstantSource();
|
|
42
|
+
ASSERT_NE(constantSource, nullptr);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
TEST_F(ConstantSourceTest, ConstantSourceOutputsConstantValue) {
|
|
46
|
+
static constexpr int FRAMES_TO_PROCESS = 4;
|
|
47
|
+
|
|
48
|
+
auto bus =
|
|
49
|
+
std::make_shared<audioapi::AudioBus>(FRAMES_TO_PROCESS, 1, sampleRate);
|
|
50
|
+
auto constantSource =
|
|
51
|
+
std::make_shared<TestableConstantSourceNode>(context.get());
|
|
52
|
+
constantSource->start(context->getCurrentTime());
|
|
53
|
+
auto resultBus = constantSource->processNode(bus, FRAMES_TO_PROCESS);
|
|
54
|
+
|
|
55
|
+
for (int i = 0; i < FRAMES_TO_PROCESS; ++i) {
|
|
56
|
+
EXPECT_FLOAT_EQ((*resultBus->getChannel(0))[i], 1.0f);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
constantSource->setOffsetParam(0.5f);
|
|
60
|
+
resultBus = constantSource->processNode(bus, FRAMES_TO_PROCESS);
|
|
61
|
+
for (int i = 0; i < FRAMES_TO_PROCESS; ++i) {
|
|
62
|
+
EXPECT_FLOAT_EQ((*resultBus->getChannel(0))[i], 0.5f);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -4,34 +4,35 @@
|
|
|
4
4
|
#include <audioapi/utils/AudioArray.h>
|
|
5
5
|
#include <audioapi/utils/AudioBus.h>
|
|
6
6
|
#include <gtest/gtest.h>
|
|
7
|
-
#include
|
|
7
|
+
#include <test/src/MockAudioEventHandlerRegistry.h>
|
|
8
|
+
|
|
9
|
+
using namespace audioapi;
|
|
8
10
|
|
|
9
11
|
class GainTest : public ::testing::Test {
|
|
10
12
|
protected:
|
|
11
|
-
std::shared_ptr<
|
|
12
|
-
std::unique_ptr<
|
|
13
|
+
std::shared_ptr<IAudioEventHandlerRegistry> eventRegistry;
|
|
14
|
+
std::unique_ptr<OfflineAudioContext> context;
|
|
13
15
|
static constexpr int sampleRate = 44100;
|
|
14
16
|
|
|
15
17
|
void SetUp() override {
|
|
16
18
|
eventRegistry = std::make_shared<MockAudioEventHandlerRegistry>();
|
|
17
|
-
context = std::make_unique<
|
|
19
|
+
context = std::make_unique<OfflineAudioContext>(
|
|
18
20
|
2, 5 * sampleRate, sampleRate, eventRegistry, RuntimeRegistry{});
|
|
19
21
|
}
|
|
20
22
|
};
|
|
21
23
|
|
|
22
|
-
class TestableGainNode : public
|
|
24
|
+
class TestableGainNode : public GainNode {
|
|
23
25
|
public:
|
|
24
|
-
explicit TestableGainNode(
|
|
25
|
-
: audioapi::GainNode(context) {}
|
|
26
|
+
explicit TestableGainNode(BaseAudioContext *context) : GainNode(context) {}
|
|
26
27
|
|
|
27
28
|
void setGainParam(float value) {
|
|
28
29
|
getGainParam()->setValue(value);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
std::shared_ptr<
|
|
32
|
-
const std::shared_ptr<
|
|
32
|
+
std::shared_ptr<AudioBus> processNode(
|
|
33
|
+
const std::shared_ptr<AudioBus> &processingBus,
|
|
33
34
|
int framesToProcess) override {
|
|
34
|
-
return
|
|
35
|
+
return GainNode::processNode(processingBus, framesToProcess);
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
38
|
|
package/common/cpp/test/{MockAudioEventHandlerRegistry.h → src/MockAudioEventHandlerRegistry.h}
RENAMED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
#include <string>
|
|
7
7
|
#include <memory>
|
|
8
8
|
|
|
9
|
-
using
|
|
9
|
+
using namespace audioapi;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
using EventMap = std::unordered_map<std::string, EventValue>;
|
|
12
|
+
|
|
13
|
+
class MockAudioEventHandlerRegistry : public IAudioEventHandlerRegistry {
|
|
12
14
|
public:
|
|
13
15
|
MOCK_METHOD(uint64_t, registerHandler,
|
|
14
16
|
(const std::string &eventName, const std::shared_ptr<facebook::jsi::Function> &handler), (override));
|
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
#include <audioapi/core/sources/OscillatorNode.h>
|
|
3
3
|
#include <audioapi/core/utils/worklets/SafeIncludes.h>
|
|
4
4
|
#include <gtest/gtest.h>
|
|
5
|
-
#include
|
|
5
|
+
#include <test/src/MockAudioEventHandlerRegistry.h>
|
|
6
|
+
|
|
7
|
+
using namespace audioapi;
|
|
6
8
|
|
|
7
9
|
class OscillatorTest : public ::testing::Test {
|
|
8
10
|
protected:
|
|
9
|
-
std::shared_ptr<
|
|
10
|
-
std::unique_ptr<
|
|
11
|
+
std::shared_ptr<IAudioEventHandlerRegistry> eventRegistry;
|
|
12
|
+
std::unique_ptr<OfflineAudioContext> context;
|
|
11
13
|
static constexpr int sampleRate = 44100;
|
|
12
14
|
|
|
13
15
|
void SetUp() override {
|
|
14
16
|
eventRegistry = std::make_shared<MockAudioEventHandlerRegistry>();
|
|
15
|
-
context = std::make_unique<
|
|
17
|
+
context = std::make_unique<OfflineAudioContext>(
|
|
16
18
|
2, 5 * sampleRate, sampleRate, eventRegistry, RuntimeRegistry{});
|
|
17
19
|
}
|
|
18
20
|
};
|
|
@@ -18,7 +18,8 @@ class IOSAudioRecorder : public AudioRecorder {
|
|
|
18
18
|
IOSAudioRecorder(
|
|
19
19
|
float sampleRate,
|
|
20
20
|
int bufferLength,
|
|
21
|
-
const std::shared_ptr<AudioEventHandlerRegistry>
|
|
21
|
+
const std::shared_ptr<AudioEventHandlerRegistry>
|
|
22
|
+
&audioEventHandlerRegistry);
|
|
22
23
|
|
|
23
24
|
~IOSAudioRecorder() override;
|
|
24
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-audio-api",
|
|
3
|
-
"version": "0.10.0-nightly-
|
|
3
|
+
"version": "0.10.0-nightly-2ae2776-20251011",
|
|
4
4
|
"description": "react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification",
|
|
5
5
|
"bin": {
|
|
6
6
|
"setup-rn-audio-api-web": "./scripts/setup-rn-audio-api-web.js"
|