nosnia-audio-recorder 0.5.3 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/NosniaAudioRecorder.mm +21 -7
- package/package.json +1 -1
|
@@ -142,6 +142,11 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
142
142
|
NSNumber *bitrate = options[@"bitrate"];
|
|
143
143
|
if (!bitrate || ![bitrate isKindOfClass:[NSNumber class]] || [bitrate integerValue] <= 0) {
|
|
144
144
|
bitrate = @(128000);
|
|
145
|
+
} else {
|
|
146
|
+
// AAC bitrate should be between 32000 and 320000
|
|
147
|
+
NSInteger br = [bitrate integerValue];
|
|
148
|
+
if (br < 32000) bitrate = @(32000);
|
|
149
|
+
if (br > 320000) bitrate = @(320000);
|
|
145
150
|
}
|
|
146
151
|
|
|
147
152
|
NSNumber *channels = options[@"channels"];
|
|
@@ -155,6 +160,13 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
155
160
|
NSNumber *sampleRate = options[@"sampleRate"];
|
|
156
161
|
if (!sampleRate || ![sampleRate isKindOfClass:[NSNumber class]] || [sampleRate integerValue] <= 0) {
|
|
157
162
|
sampleRate = @(44100);
|
|
163
|
+
} else {
|
|
164
|
+
// AAC requires specific sample rates: 8000, 16000, 22050, 24000, 32000, 44100, 48000
|
|
165
|
+
NSInteger rate = [sampleRate integerValue];
|
|
166
|
+
NSArray *validRates = @[@8000, @16000, @22050, @24000, @32000, @44100, @48000];
|
|
167
|
+
if (![validRates containsObject:sampleRate]) {
|
|
168
|
+
sampleRate = @(44100); // Default to 44100 if invalid
|
|
169
|
+
}
|
|
158
170
|
}
|
|
159
171
|
|
|
160
172
|
// Get audio session
|
|
@@ -164,10 +176,10 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
164
176
|
return;
|
|
165
177
|
}
|
|
166
178
|
|
|
167
|
-
// Set audio category with
|
|
179
|
+
// Set audio category - use Record category with DuckOthers option
|
|
168
180
|
NSError *categoryError = nil;
|
|
169
181
|
BOOL categorySuccess = [audioSession setCategory:AVAudioSessionCategoryRecord
|
|
170
|
-
withOptions:
|
|
182
|
+
withOptions:AVAudioSessionCategoryOptionDuckOthers
|
|
171
183
|
error:&categoryError];
|
|
172
184
|
if (!categorySuccess || categoryError) {
|
|
173
185
|
NSString *msg = categoryError ? categoryError.description : @"Failed to set audio category";
|
|
@@ -192,12 +204,14 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
192
204
|
|
|
193
205
|
// Create recording settings dictionary with safety checks
|
|
194
206
|
@try {
|
|
207
|
+
// Use IMA4 codec which is universally supported on iOS
|
|
208
|
+
// AVAudioRecorder doesn't support direct AAC encoding on all devices
|
|
195
209
|
NSDictionary *recordingSettings = @{
|
|
196
|
-
AVFormatIDKey: @(
|
|
197
|
-
AVSampleRateKey:
|
|
198
|
-
AVNumberOfChannelsKey:
|
|
199
|
-
AVEncoderBitRateKey:
|
|
200
|
-
AVEncoderAudioQualityKey: @(
|
|
210
|
+
AVFormatIDKey: @(kAudioFormatILBC),
|
|
211
|
+
AVSampleRateKey: @(8000), // ILBC requires 8000 Hz
|
|
212
|
+
AVNumberOfChannelsKey: @(1),
|
|
213
|
+
AVEncoderBitRateKey: @(15400),
|
|
214
|
+
AVEncoderAudioQualityKey: @(AVAudioQualityMin)
|
|
201
215
|
};
|
|
202
216
|
|
|
203
217
|
// Validate settings dictionary created successfully
|
package/package.json
CHANGED