@siteed/expo-audio-stream 1.13.2 → 1.14.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/CHANGELOG.md +6 -3
- package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +1 -0
- package/build/ExpoAudioStream.types.d.ts +1 -0
- package/build/ExpoAudioStream.types.d.ts.map +1 -1
- package/build/ExpoAudioStream.types.js.map +1 -1
- package/build/ExpoAudioStream.web.d.ts.map +1 -1
- package/build/ExpoAudioStream.web.js +1 -0
- package/build/ExpoAudioStream.web.js.map +1 -1
- package/ios/AudioStreamManager.swift +250 -94
- package/ios/ExpoAudioStreamModule.swift +1 -0
- package/package.json +1 -1
- package/src/ExpoAudioStream.types.ts +1 -0
- package/src/ExpoAudioStream.web.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -8,10 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
## [1.
|
|
11
|
+
## [1.14.0] - 2025-02-12
|
|
12
12
|
|
|
13
|
+
## [1.13.2] - 2025-02-10
|
|
14
|
+
- fix: ensure foreground service starts within required timeframe ([60dad52](https://github.com/deeeed/expo-audio-stream/commit/60dad5237c11b9a60e6239701317d52c56625d6e))
|
|
13
15
|
## [1.13.1] - 2025-02-10
|
|
14
|
-
|
|
16
|
+
- readme update with latest demos
|
|
15
17
|
## [1.13.0] - 2025-02-09
|
|
16
18
|
- Audiodecode (#104) ([173f589](https://github.com/deeeed/expo-audio-stream/commit/173f589ebe8763f7361088d150bba1d4bd2c4154))
|
|
17
19
|
- fix: resolve background recording issues and improve status checking (#103) ([a174d50](https://github.com/deeeed/expo-audio-stream/commit/a174d50932b2ee4682f4bd6edb3eaa9a7d579bfc))
|
|
@@ -109,7 +111,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
109
111
|
- Feature: Audio features extraction during recording.
|
|
110
112
|
- Feature: Consistent WAV PCM recording format across all platforms.
|
|
111
113
|
|
|
112
|
-
[unreleased]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-stream@1.
|
|
114
|
+
[unreleased]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-stream@1.14.0...HEAD
|
|
115
|
+
[1.14.0]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-stream@1.13.2...@siteed/expo-audio-stream@1.14.0
|
|
113
116
|
[1.13.2]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-stream@1.13.1...@siteed/expo-audio-stream@1.13.2
|
|
114
117
|
[1.13.1]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-stream@1.13.0...@siteed/expo-audio-stream@1.13.1
|
|
115
118
|
[1.13.0]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-stream@1.12.3...@siteed/expo-audio-stream@1.13.0
|
|
@@ -572,6 +572,7 @@ class AudioRecorderManager(
|
|
|
572
572
|
"sampleRate" to recordingConfig.sampleRate,
|
|
573
573
|
"size" to fileSize,
|
|
574
574
|
"mimeType" to mimeType,
|
|
575
|
+
"createdAt" to System.currentTimeMillis(),
|
|
575
576
|
"compression" to if (compressedFile != null) bundleOf(
|
|
576
577
|
"size" to compressedFile?.length(),
|
|
577
578
|
"mimeType" to if (recordingConfig.compressedFormat == "aac") "audio/aac" else "audio/opus",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAudioStream.types.d.ts","sourceRoot":"","sources":["../src/ExpoAudioStream.types.ts"],"names":[],"mappings":"AACA,OAAO,EACH,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACvB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAE7C,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,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E,eAAe,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAA;IACrE,aAAa,EAAE,MAAM,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACnD,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACpC,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,eAAe,CAAA;IAC7B,YAAY,CAAC,EAAE,aAAa,CAAA;IAC5B,sBAAsB,CAAC,EAAE,CAAC,CAAC,EAAE,0BAA0B,KAAK,IAAI,CAAA;CACnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAudioStream.types.js","sourceRoot":"","sources":["../src/ExpoAudioStream.types.ts"],"names":[],"mappings":"","sourcesContent":["// packages/expo-audio-stream/src/ExpoAudioStream.types.ts\nimport {\n AmplitudeAlgorithm,\n AudioAnalysis,\n AudioFeaturesOptions,\n} from './AudioAnalysis/AudioAnalysis.types'\nimport { AudioAnalysisEvent } from './events'\n\nexport interface CompressionInfo {\n size: number\n mimeType: string\n bitrate: number\n format: string\n compressedFileUri?: string\n}\n\nexport interface AudioStreamStatus {\n isRecording: boolean\n isPaused: boolean\n durationMs: number\n size: number\n interval: number\n mimeType: string\n compression?: CompressionInfo\n}\n\nexport interface AudioDataEvent {\n data: string | Float32Array\n position: number\n fileUri: string\n eventDataSize: number\n totalSize: number\n compression?: CompressionInfo & {\n data?: string | Blob // Base64 (native) or Float32Array (web) encoded compressed data chunk\n }\n}\n\nexport type EncodingType = 'pcm_32bit' | 'pcm_16bit' | 'pcm_8bit'\nexport type SampleRate = 16000 | 44100 | 48000\nexport type BitDepth = 8 | 16 | 32\n\nexport type ConsoleLike = {\n log: (message: string, ...args: unknown[]) => void\n debug: (message: string, ...args: unknown[]) => void\n warn: (message: string, ...args: unknown[]) => void\n error: (message: string, ...args: unknown[]) => void\n}\n\nexport interface Chunk {\n text: string\n timestamp: [number, number | null]\n}\n\nexport interface TranscriberData {\n id: string\n isBusy: boolean\n text: string\n startTime: number\n endTime: number\n chunks: Chunk[]\n}\n\nexport interface AudioRecording {\n fileUri: string\n filename: string\n durationMs: number\n size: number\n mimeType: string\n channels: number\n bitDepth: BitDepth\n sampleRate: SampleRate\n transcripts?: TranscriberData[]\n analysisData?: AudioAnalysis // Analysis data for the recording depending on enableProcessing flag\n compression?: CompressionInfo & {\n compressedFileUri: string\n }\n}\n\nexport interface StartRecordingResult {\n fileUri: string\n mimeType: string\n channels?: number\n bitDepth?: BitDepth\n sampleRate?: SampleRate\n compression?: CompressionInfo & {\n compressedFileUri: string\n }\n}\n\nexport interface AudioSessionConfig {\n category?:\n | 'Ambient'\n | 'SoloAmbient'\n | 'Playback'\n | 'Record'\n | 'PlayAndRecord'\n | 'MultiRoute'\n mode?:\n | 'Default'\n | 'VoiceChat'\n | 'VideoChat'\n | 'GameChat'\n | 'VideoRecording'\n | 'Measurement'\n | 'MoviePlayback'\n | 'SpokenAudio'\n categoryOptions?: (\n | 'MixWithOthers'\n | 'DuckOthers'\n | 'InterruptSpokenAudioAndMixWithOthers'\n | 'AllowBluetooth'\n | 'AllowBluetoothA2DP'\n | 'AllowAirPlay'\n | 'DefaultToSpeaker'\n )[]\n}\n\nexport interface IOSConfig {\n audioSession?: AudioSessionConfig\n}\n\n// Add new type for interruption reasons\nexport type RecordingInterruptionReason =\n | 'audioFocusLoss'\n | 'audioFocusGain'\n | 'phoneCall'\n | 'phoneCallEnded'\n\n// Add new interface for interruption events\nexport interface RecordingInterruptionEvent {\n reason: RecordingInterruptionReason\n isPaused: boolean\n}\n\nexport interface RecordingConfig {\n // Sample rate for recording (16000, 44100, or 48000 Hz)\n sampleRate?: SampleRate\n\n // Number of audio channels (1 for mono, 2 for stereo)\n channels?: 1 | 2\n\n // Encoding type for the recording (pcm_32bit, pcm_16bit, pcm_8bit)\n encoding?: EncodingType\n\n // Interval in milliseconds at which to emit recording data\n interval?: number\n\n // Keep the device awake while recording (default is false)\n keepAwake?: boolean\n\n // Show a notification during recording (default is false)\n showNotification?: boolean\n\n // Show waveform in the notification (Android only, when showNotification is true)\n showWaveformInNotification?: boolean\n\n // Configuration for the notification\n notification?: NotificationConfig\n\n // Enable audio processing (default is false)\n enableProcessing?: boolean\n\n // iOS-specific configuration\n ios?: IOSConfig\n\n // Number of data points to extract per second of audio (default is 1000)\n pointsPerSecond?: number\n\n // Algorithm to use for amplitude computation (default is \"rms\")\n algorithm?: AmplitudeAlgorithm\n\n // Feature options to extract (default is empty)\n features?: AudioFeaturesOptions\n\n // Callback function to handle audio stream\n onAudioStream?: (_: AudioDataEvent) => Promise<void>\n\n // Callback function to handle audio features extraction results\n onAudioAnalysis?: (_: AudioAnalysisEvent) => Promise<void>\n\n compression?: {\n enabled: boolean\n format: 'aac' | 'opus' | 'mp3'\n bitrate?: number\n }\n\n // Whether to automatically resume recording after an interruption (default is false)\n autoResumeAfterInterruption?: boolean\n\n // Optional callback to handle recording interruptions\n onRecordingInterrupted?: (_: RecordingInterruptionEvent) => void\n\n // Optional output configuration\n outputDirectory?: string // If not provided, uses default app directory\n filename?: string // If not provided, uses UUID\n}\n\nexport interface NotificationConfig {\n // Title of the notification\n title?: string\n\n // Main text content of the notification\n text?: string\n\n // Icon to be displayed in the notification (resource name or URI)\n icon?: string\n\n // Android-specific notification configuration\n android?: {\n // Unique identifier for the notification channel\n channelId?: string\n\n // User-visible name of the notification channel\n channelName?: string\n\n // User-visible description of the notification channel\n channelDescription?: string\n\n // Unique identifier for this notification\n notificationId?: number\n\n // List of actions that can be performed from the notification\n actions?: NotificationAction[]\n\n // Configuration for the waveform visualization in the notification\n waveform?: WaveformConfig\n\n // Color of the notification LED (if device supports it)\n lightColor?: string\n\n // Priority of the notification (affects how it's displayed)\n priority?: 'min' | 'low' | 'default' | 'high' | 'max'\n\n // Accent color for the notification (used for the app icon and buttons)\n accentColor?: string\n }\n\n // iOS-specific notification configuration\n ios?: {\n // Identifier for the notification category (used for grouping similar notifications)\n categoryIdentifier?: string\n }\n}\n\nexport interface NotificationAction {\n // Display title for the action\n title: string\n\n // Unique identifier for the action\n identifier: string\n\n // Icon to be displayed for the action (Android only)\n icon?: string\n}\n\nexport interface WaveformConfig {\n color?: string // The color of the waveform (e.g., \"#FFFFFF\" for white)\n opacity?: number // Opacity of the waveform (0.0 - 1.0)\n strokeWidth?: number // Width of the waveform line (default: 1.5)\n style?: 'stroke' | 'fill' // Drawing style: \"stroke\" for outline, \"fill\" for solid\n mirror?: boolean // Whether to mirror the waveform (symmetrical display)\n height?: number // Height of the waveform view in dp (default: 64)\n}\n\nexport interface UseAudioRecorderState {\n startRecording: (_: RecordingConfig) => Promise<StartRecordingResult>\n stopRecording: () => Promise<AudioRecording | null>\n pauseRecording: () => Promise<void>\n resumeRecording: () => Promise<void>\n isRecording: boolean\n isPaused: boolean\n durationMs: number // Duration of the recording\n size: number // Size in bytes of the recorded audio\n compression?: CompressionInfo\n analysisData?: AudioAnalysis // Analysis data for the recording depending on enableProcessing flag\n onRecordingInterrupted?: (_: RecordingInterruptionEvent) => void\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoAudioStream.types.js","sourceRoot":"","sources":["../src/ExpoAudioStream.types.ts"],"names":[],"mappings":"","sourcesContent":["// packages/expo-audio-stream/src/ExpoAudioStream.types.ts\nimport {\n AmplitudeAlgorithm,\n AudioAnalysis,\n AudioFeaturesOptions,\n} from './AudioAnalysis/AudioAnalysis.types'\nimport { AudioAnalysisEvent } from './events'\n\nexport interface CompressionInfo {\n size: number\n mimeType: string\n bitrate: number\n format: string\n compressedFileUri?: string\n}\n\nexport interface AudioStreamStatus {\n isRecording: boolean\n isPaused: boolean\n durationMs: number\n size: number\n interval: number\n mimeType: string\n compression?: CompressionInfo\n}\n\nexport interface AudioDataEvent {\n data: string | Float32Array\n position: number\n fileUri: string\n eventDataSize: number\n totalSize: number\n compression?: CompressionInfo & {\n data?: string | Blob // Base64 (native) or Float32Array (web) encoded compressed data chunk\n }\n}\n\nexport type EncodingType = 'pcm_32bit' | 'pcm_16bit' | 'pcm_8bit'\nexport type SampleRate = 16000 | 44100 | 48000\nexport type BitDepth = 8 | 16 | 32\n\nexport type ConsoleLike = {\n log: (message: string, ...args: unknown[]) => void\n debug: (message: string, ...args: unknown[]) => void\n warn: (message: string, ...args: unknown[]) => void\n error: (message: string, ...args: unknown[]) => void\n}\n\nexport interface Chunk {\n text: string\n timestamp: [number, number | null]\n}\n\nexport interface TranscriberData {\n id: string\n isBusy: boolean\n text: string\n startTime: number\n endTime: number\n chunks: Chunk[]\n}\n\nexport interface AudioRecording {\n fileUri: string\n filename: string\n durationMs: number\n size: number\n mimeType: string\n channels: number\n bitDepth: BitDepth\n sampleRate: SampleRate\n createdAt?: number\n transcripts?: TranscriberData[]\n analysisData?: AudioAnalysis // Analysis data for the recording depending on enableProcessing flag\n compression?: CompressionInfo & {\n compressedFileUri: string\n }\n}\n\nexport interface StartRecordingResult {\n fileUri: string\n mimeType: string\n channels?: number\n bitDepth?: BitDepth\n sampleRate?: SampleRate\n compression?: CompressionInfo & {\n compressedFileUri: string\n }\n}\n\nexport interface AudioSessionConfig {\n category?:\n | 'Ambient'\n | 'SoloAmbient'\n | 'Playback'\n | 'Record'\n | 'PlayAndRecord'\n | 'MultiRoute'\n mode?:\n | 'Default'\n | 'VoiceChat'\n | 'VideoChat'\n | 'GameChat'\n | 'VideoRecording'\n | 'Measurement'\n | 'MoviePlayback'\n | 'SpokenAudio'\n categoryOptions?: (\n | 'MixWithOthers'\n | 'DuckOthers'\n | 'InterruptSpokenAudioAndMixWithOthers'\n | 'AllowBluetooth'\n | 'AllowBluetoothA2DP'\n | 'AllowAirPlay'\n | 'DefaultToSpeaker'\n )[]\n}\n\nexport interface IOSConfig {\n audioSession?: AudioSessionConfig\n}\n\n// Add new type for interruption reasons\nexport type RecordingInterruptionReason =\n | 'audioFocusLoss'\n | 'audioFocusGain'\n | 'phoneCall'\n | 'phoneCallEnded'\n\n// Add new interface for interruption events\nexport interface RecordingInterruptionEvent {\n reason: RecordingInterruptionReason\n isPaused: boolean\n}\n\nexport interface RecordingConfig {\n // Sample rate for recording (16000, 44100, or 48000 Hz)\n sampleRate?: SampleRate\n\n // Number of audio channels (1 for mono, 2 for stereo)\n channels?: 1 | 2\n\n // Encoding type for the recording (pcm_32bit, pcm_16bit, pcm_8bit)\n encoding?: EncodingType\n\n // Interval in milliseconds at which to emit recording data\n interval?: number\n\n // Keep the device awake while recording (default is false)\n keepAwake?: boolean\n\n // Show a notification during recording (default is false)\n showNotification?: boolean\n\n // Show waveform in the notification (Android only, when showNotification is true)\n showWaveformInNotification?: boolean\n\n // Configuration for the notification\n notification?: NotificationConfig\n\n // Enable audio processing (default is false)\n enableProcessing?: boolean\n\n // iOS-specific configuration\n ios?: IOSConfig\n\n // Number of data points to extract per second of audio (default is 1000)\n pointsPerSecond?: number\n\n // Algorithm to use for amplitude computation (default is \"rms\")\n algorithm?: AmplitudeAlgorithm\n\n // Feature options to extract (default is empty)\n features?: AudioFeaturesOptions\n\n // Callback function to handle audio stream\n onAudioStream?: (_: AudioDataEvent) => Promise<void>\n\n // Callback function to handle audio features extraction results\n onAudioAnalysis?: (_: AudioAnalysisEvent) => Promise<void>\n\n compression?: {\n enabled: boolean\n format: 'aac' | 'opus' | 'mp3'\n bitrate?: number\n }\n\n // Whether to automatically resume recording after an interruption (default is false)\n autoResumeAfterInterruption?: boolean\n\n // Optional callback to handle recording interruptions\n onRecordingInterrupted?: (_: RecordingInterruptionEvent) => void\n\n // Optional output configuration\n outputDirectory?: string // If not provided, uses default app directory\n filename?: string // If not provided, uses UUID\n}\n\nexport interface NotificationConfig {\n // Title of the notification\n title?: string\n\n // Main text content of the notification\n text?: string\n\n // Icon to be displayed in the notification (resource name or URI)\n icon?: string\n\n // Android-specific notification configuration\n android?: {\n // Unique identifier for the notification channel\n channelId?: string\n\n // User-visible name of the notification channel\n channelName?: string\n\n // User-visible description of the notification channel\n channelDescription?: string\n\n // Unique identifier for this notification\n notificationId?: number\n\n // List of actions that can be performed from the notification\n actions?: NotificationAction[]\n\n // Configuration for the waveform visualization in the notification\n waveform?: WaveformConfig\n\n // Color of the notification LED (if device supports it)\n lightColor?: string\n\n // Priority of the notification (affects how it's displayed)\n priority?: 'min' | 'low' | 'default' | 'high' | 'max'\n\n // Accent color for the notification (used for the app icon and buttons)\n accentColor?: string\n }\n\n // iOS-specific notification configuration\n ios?: {\n // Identifier for the notification category (used for grouping similar notifications)\n categoryIdentifier?: string\n }\n}\n\nexport interface NotificationAction {\n // Display title for the action\n title: string\n\n // Unique identifier for the action\n identifier: string\n\n // Icon to be displayed for the action (Android only)\n icon?: string\n}\n\nexport interface WaveformConfig {\n color?: string // The color of the waveform (e.g., \"#FFFFFF\" for white)\n opacity?: number // Opacity of the waveform (0.0 - 1.0)\n strokeWidth?: number // Width of the waveform line (default: 1.5)\n style?: 'stroke' | 'fill' // Drawing style: \"stroke\" for outline, \"fill\" for solid\n mirror?: boolean // Whether to mirror the waveform (symmetrical display)\n height?: number // Height of the waveform view in dp (default: 64)\n}\n\nexport interface UseAudioRecorderState {\n startRecording: (_: RecordingConfig) => Promise<StartRecordingResult>\n stopRecording: () => Promise<AudioRecording | null>\n pauseRecording: () => Promise<void>\n resumeRecording: () => Promise<void>\n isRecording: boolean\n isPaused: boolean\n durationMs: number // Duration of the recording\n size: number // Size in bytes of the recorded audio\n compression?: CompressionInfo\n analysisData?: AudioAnalysis // Analysis data for the recording depending on enableProcessing flag\n onRecordingInterrupted?: (_: RecordingInterruptionEvent) => void\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAudioStream.web.d.ts","sourceRoot":"","sources":["../src/ExpoAudioStream.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM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aAAa,CAAQ;gBAE1B,EACR,eAAe,EACf,mBAAmB,EACnB,MAAM,EACN,aAAmB,GACtB,EAAE,uBAAuB;IAiCpB,cAAc;IAUd,cAAc,CAChB,eAAe,GAAE,eAAoB,GACtC,OAAO,CAAC,oBAAoB,CAAC;IA4FhC,cAAc,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,mBAAmB;IAgC7D,aAAa,IAAI,OAAO,CAAC,cAAc,CAAC;IAoExC,cAAc;IAad,eAAe;IAarB,MAAM;CAqBT"}
|
|
@@ -214,6 +214,7 @@ export class ExpoAudioStreamWeb extends LegacyEventEmitter {
|
|
|
214
214
|
fileUri,
|
|
215
215
|
filename, // This will now use our custom filename
|
|
216
216
|
bitDepth: this.bitDepth,
|
|
217
|
+
createdAt: this.recordingStartTime,
|
|
217
218
|
channels: this.recordingConfig?.channels ?? 1,
|
|
218
219
|
sampleRate: this.recordingConfig?.sampleRate ?? 44100,
|
|
219
220
|
durationMs: this.currentDurationMs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAudioStream.web.js","sourceRoot":"","sources":["../src/ExpoAudioStream.web.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAWtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAwB/D,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IACtD,cAAc,CAAoB;IAClC,WAAW,CAAgB;IAC3B,WAAW,CAAS;IACpB,QAAQ,CAAS;IACjB,kBAAkB,CAAQ;IAC1B,UAAU,CAAQ;IAClB,iBAAiB,CAAQ;IACzB,WAAW,CAAQ;IACnB,eAAe,CAAQ;IACvB,eAAe,CAAQ;IACvB,eAAe,CAAQ;IACvB,0BAA0B,CAAQ;IAClC,UAAU,CAAe;IACzB,SAAS,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,CAAA;QACrB,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,CAAA;IAC3D,CAAC;IAED,qBAAqB;IACrB,MAAM;QACF,MAAM,MAAM,GAAsB;YAC9B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,IAAI,CAAC,iBAAiB;YAClC,IAAI,EAAE,IAAI,CAAC,WAAW;YACtB,QAAQ,EAAE,IAAI,CAAC,eAAe;YAC9B,QAAQ,EAAE,SAAS,IAAI,CAAC,SAAS,EAAE;YACnC,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,EAAE,OAAO;gBACnD,CAAC,CAAC;oBACI,IAAI,EAAE,IAAI,CAAC,mBAAmB;oBAC9B,QAAQ,EAAE,YAAY;oBACtB,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,MAAM,IAAI,MAAM;oBACzD,OAAO,EACH,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,OAAO,IAAI,MAAM;oBACtD,iBAAiB,EAAE,GAAG,IAAI,CAAC,UAAU,OAAO;iBAC/C;gBACH,CAAC,CAAC,SAAS;SAClB,CAAA;QACD,OAAO,MAAM,CAAA;IACjB,CAAC;CACJ","sourcesContent":["// src/ExpoAudioStreamModule.web.ts\nimport { LegacyEventEmitter } from 'expo-modules-core'\n\nimport { AudioAnalysis } from './AudioAnalysis/AudioAnalysis.types'\nimport {\n AudioRecording,\n AudioStreamStatus,\n BitDepth,\n ConsoleLike,\n RecordingConfig,\n StartRecordingResult,\n} from './ExpoAudioStream.types'\nimport { WebRecorder } from './WebRecorder.web'\nimport { AudioEventPayload } from './events'\nimport { encodingToBitDepth } from './utils/encodingToBitDepth'\n\nexport interface EmitAudioEventProps {\n data: Float32Array\n position: number\n compression?: {\n data: Blob\n size: number\n totalSize: number\n mimeType: string\n format: string\n bitrate: number\n }\n}\nexport type EmitAudioEventFunction = (_: EmitAudioEventProps) => void\nexport type EmitAudioAnalysisFunction = (_: AudioAnalysis) => void\n\nexport interface ExpoAudioStreamWebProps {\n logger?: ConsoleLike\n audioWorkletUrl: string\n featuresExtratorUrl: string\n maxBufferSize?: number // Maximum number of chunks to keep in memory\n}\n\nexport class ExpoAudioStreamWeb extends LegacyEventEmitter {\n customRecorder: WebRecorder | null\n audioChunks: Float32Array[]\n isRecording: boolean\n isPaused: boolean\n recordingStartTime: number\n pausedTime: number\n currentDurationMs: number\n currentSize: number\n currentInterval: number\n lastEmittedSize: number\n lastEmittedTime: number\n lastEmittedCompressionSize: number\n streamUuid: string | null\n extension: 'webm' | 'wav' = 'wav' // Default extension is 'wav'\n recordingConfig?: RecordingConfig\n bitDepth: BitDepth // Bit depth of the audio\n audioWorkletUrl: string\n featuresExtratorUrl: string\n logger?: ConsoleLike\n latestPosition: number = 0\n totalCompressedSize: number = 0\n private readonly maxBufferSize: number\n\n constructor({\n audioWorkletUrl,\n featuresExtratorUrl,\n logger,\n maxBufferSize = 100, // Default to storing last 100 chunks (1 chunk = 0.5 seconds)\n }: ExpoAudioStreamWebProps) {\n const mockNativeModule = {\n addListener: () => {\n // Not used on web\n },\n removeListeners: () => {\n // Not used on web\n },\n }\n super(mockNativeModule) // Pass the mock native module to the parent class\n\n this.logger = logger\n this.customRecorder = null\n this.audioChunks = []\n this.isRecording = false\n this.isPaused = false\n this.recordingStartTime = 0\n this.pausedTime = 0\n this.currentDurationMs = 0\n this.currentSize = 0\n this.bitDepth = 32 // Default\n this.currentInterval = 1000 // Default interval in ms\n this.lastEmittedSize = 0\n this.lastEmittedTime = 0\n this.latestPosition = 0\n this.lastEmittedCompressionSize = 0\n this.streamUuid = null // Initialize UUID on first recording start\n this.audioWorkletUrl = audioWorkletUrl\n this.featuresExtratorUrl = featuresExtratorUrl\n this.maxBufferSize = maxBufferSize\n }\n\n // Utility to handle user media stream\n async getMediaStream() {\n try {\n return await navigator.mediaDevices.getUserMedia({ audio: true })\n } catch (error) {\n this.logger?.error('Failed to get media stream:', error)\n throw error\n }\n }\n\n // Start recording with options\n async startRecording(\n recordingConfig: RecordingConfig = {}\n ): Promise<StartRecordingResult> {\n if (this.isRecording) {\n throw new Error('Recording is already in progress')\n }\n\n this.bitDepth = encodingToBitDepth({\n encoding: recordingConfig.encoding ?? 'pcm_32bit',\n })\n\n const audioContext = new (window.AudioContext ||\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Allow webkitAudioContext for Safari\n window.webkitAudioContext)()\n const stream = await this.getMediaStream()\n\n const source = audioContext.createMediaStreamSource(stream)\n\n this.customRecorder = new WebRecorder({\n logger: this.logger,\n audioContext,\n source,\n recordingConfig,\n audioWorkletUrl: this.audioWorkletUrl,\n emitAudioEventCallback: ({\n data,\n position,\n compression,\n }: EmitAudioEventProps) => {\n // Keep only the latest chunks based on maxBufferSize\n this.audioChunks.push(new Float32Array(data))\n if (this.audioChunks.length > this.maxBufferSize) {\n this.audioChunks.shift() // Remove oldest chunk\n }\n this.currentSize += data.byteLength\n this.emitAudioEvent({ data, position, compression })\n this.lastEmittedTime = Date.now()\n this.lastEmittedSize = this.currentSize\n this.lastEmittedCompressionSize = compression?.size ?? 0\n },\n emitAudioAnalysisCallback: (audioAnalysisData: AudioAnalysis) => {\n this.logger?.log(`Emitted AudioAnalysis:`, audioAnalysisData)\n this.emit('AudioAnalysis', audioAnalysisData)\n },\n })\n await this.customRecorder.init()\n this.customRecorder.start()\n\n // // Set a timer to stop recording after 5 seconds\n // setTimeout(() => {\n // logger.log(\"AUTO Stopping recording\");\n // this.customRecorder?.stopAndPlay();\n // this.isRecording = false;\n // }, 3000);\n\n this.isRecording = true\n this.recordingConfig = recordingConfig\n this.recordingStartTime = Date.now()\n this.pausedTime = 0\n this.isPaused = false\n this.lastEmittedSize = 0\n this.lastEmittedTime = 0\n this.lastEmittedCompressionSize = 0\n\n // Use custom filename if provided, otherwise fallback to timestamp\n if (recordingConfig.filename) {\n // Remove any existing extension from the filename\n this.streamUuid = recordingConfig.filename.replace(/\\.[^/.]+$/, '')\n } else {\n this.streamUuid = Date.now().toString()\n }\n\n const fileUri = `${this.streamUuid}.${this.extension}`\n const streamConfig: StartRecordingResult = {\n fileUri,\n mimeType: `audio/${this.extension}`,\n bitDepth: this.bitDepth,\n channels: recordingConfig.channels ?? 1,\n sampleRate: recordingConfig.sampleRate ?? 44100,\n compression: recordingConfig.compression\n ? {\n ...recordingConfig.compression,\n bitrate: recordingConfig.compression?.bitrate ?? 128000,\n size: 0,\n mimeType: 'audio/webm',\n format: recordingConfig.compression?.format ?? 'opus',\n compressedFileUri: '',\n }\n : undefined,\n }\n return streamConfig\n }\n\n emitAudioEvent({ data, position, compression }: EmitAudioEventProps) {\n const fileUri = `${this.streamUuid}.${this.extension}`\n if (compression?.size) {\n this.lastEmittedCompressionSize = compression.size\n this.totalCompressedSize = compression.totalSize\n }\n this.latestPosition = position\n this.currentDurationMs = position * 1000 // Convert position (in seconds) to ms\n\n const audioEventPayload: AudioEventPayload = {\n fileUri,\n mimeType: `audio/${this.extension}`,\n lastEmittedSize: this.lastEmittedSize,\n deltaSize: data.byteLength,\n position,\n totalSize: this.currentSize,\n buffer: data,\n streamUuid: this.streamUuid ?? '',\n compression: compression\n ? {\n data: compression?.data,\n totalSize: this.totalCompressedSize,\n eventDataSize: compression?.size ?? 0,\n position,\n }\n : undefined,\n }\n\n this.emit('AudioData', audioEventPayload)\n }\n\n // Stop recording\n async stopRecording(): Promise<AudioRecording> {\n if (!this.customRecorder) {\n throw new Error('Recorder is not initialized')\n }\n\n this.logger?.debug('[Stop] Starting stop process')\n const startTime = performance.now()\n\n try {\n this.logger?.debug('[Stop] Stopping recorder')\n const { compressedBlob } = await this.customRecorder.stop()\n\n this.isRecording = false\n this.isPaused = false\n this.currentDurationMs = Date.now() - this.recordingStartTime\n\n let compression: AudioRecording['compression']\n let fileUri = `${this.streamUuid}.${this.extension}`\n let mimeType = `audio/${this.extension}`\n\n if (compressedBlob && this.recordingConfig?.compression?.enabled) {\n const compressedUri = URL.createObjectURL(compressedBlob)\n compression = {\n compressedFileUri: compressedUri,\n size: compressedBlob.size,\n mimeType: 'audio/webm',\n format: 'opus',\n bitrate: this.recordingConfig.compression.bitrate ?? 128000,\n }\n // Use compressed values when compression is enabled\n fileUri = compressedUri\n mimeType = 'audio/webm'\n }\n\n this.logger?.debug(\n `[Stop] Completed stop process in ${performance.now() - startTime}ms`,\n {\n durationMs: this.currentDurationMs,\n compressedSize: compression?.size,\n }\n )\n\n // Use the stored streamUuid (which contains our custom filename) for the final filename\n const filename = `${this.streamUuid}.${this.extension}`\n const result: AudioRecording = {\n fileUri,\n filename, // This will now use our custom filename\n bitDepth: this.bitDepth,\n channels: this.recordingConfig?.channels ?? 1,\n sampleRate: this.recordingConfig?.sampleRate ?? 44100,\n durationMs: this.currentDurationMs,\n size: this.currentSize,\n mimeType,\n compression,\n }\n\n // Reset after creating the result\n this.streamUuid = null\n\n return result\n } catch (error) {\n this.logger?.error('[Stop] Error stopping recording:', error)\n throw error\n }\n }\n\n // Pause recording\n async pauseRecording() {\n if (!this.isRecording || this.isPaused) {\n throw new Error('Recording is not active or already paused')\n }\n\n if (this.customRecorder) {\n this.customRecorder.pause()\n }\n this.isPaused = true\n this.pausedTime = Date.now()\n }\n\n // Resume recording\n async resumeRecording() {\n if (!this.isPaused) {\n throw new Error('Recording is not paused')\n }\n\n if (this.customRecorder) {\n this.customRecorder.resume()\n }\n this.isPaused = false\n this.recordingStartTime += Date.now() - this.pausedTime\n }\n\n // Get current status\n status() {\n const status: AudioStreamStatus = {\n isRecording: this.isRecording,\n isPaused: this.isPaused,\n durationMs: this.currentDurationMs,\n size: this.currentSize,\n interval: this.currentInterval,\n mimeType: `audio/${this.extension}`,\n compression: this.recordingConfig?.compression?.enabled\n ? {\n size: this.totalCompressedSize,\n mimeType: 'audio/webm',\n format: this.recordingConfig.compression.format ?? 'opus',\n bitrate:\n this.recordingConfig.compression.bitrate ?? 128000,\n compressedFileUri: `${this.streamUuid}.webm`,\n }\n : undefined,\n }\n return status\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoAudioStream.web.js","sourceRoot":"","sources":["../src/ExpoAudioStream.web.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAWtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAwB/D,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IACtD,cAAc,CAAoB;IAClC,WAAW,CAAgB;IAC3B,WAAW,CAAS;IACpB,QAAQ,CAAS;IACjB,kBAAkB,CAAQ;IAC1B,UAAU,CAAQ;IAClB,iBAAiB,CAAQ;IACzB,WAAW,CAAQ;IACnB,eAAe,CAAQ;IACvB,eAAe,CAAQ;IACvB,eAAe,CAAQ;IACvB,0BAA0B,CAAQ;IAClC,UAAU,CAAe;IACzB,SAAS,GAAmB,KAAK,CAAA,CAAC,6BAA6B;IAC/D,eAAe,CAAkB;IACjC,QAAQ,CAAU,CAAC,yBAAyB;IAC5C,eAAe,CAAQ;IACvB,mBAAmB,CAAQ;IAC3B,MAAM,CAAc;IACpB,cAAc,GAAW,CAAC,CAAA;IAC1B,mBAAmB,GAAW,CAAC,CAAA;IACd,aAAa,CAAQ;IAEtC,YAAY,EACR,eAAe,EACf,mBAAmB,EACnB,MAAM,EACN,aAAa,GAAG,GAAG,EAAE,6DAA6D;MAC5D;QACtB,MAAM,gBAAgB,GAAG;YACrB,WAAW,EAAE,GAAG,EAAE;gBACd,kBAAkB;YACtB,CAAC;YACD,eAAe,EAAE,GAAG,EAAE;gBAClB,kBAAkB;YACtB,CAAC;SACJ,CAAA;QACD,KAAK,CAAC,gBAAgB,CAAC,CAAA,CAAC,kDAAkD;QAE1E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IA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;oBACtB,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,MAAM,IAAI,MAAM;oBACzD,OAAO,EACH,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,OAAO,IAAI,MAAM;oBACtD,iBAAiB,EAAE,GAAG,IAAI,CAAC,UAAU,OAAO;iBAC/C;gBACH,CAAC,CAAC,SAAS;SAClB,CAAA;QACD,OAAO,MAAM,CAAA;IACjB,CAAC;CACJ","sourcesContent":["// src/ExpoAudioStreamModule.web.ts\nimport { LegacyEventEmitter } from 'expo-modules-core'\n\nimport { AudioAnalysis } from './AudioAnalysis/AudioAnalysis.types'\nimport {\n AudioRecording,\n AudioStreamStatus,\n BitDepth,\n ConsoleLike,\n RecordingConfig,\n StartRecordingResult,\n} from './ExpoAudioStream.types'\nimport { WebRecorder } from './WebRecorder.web'\nimport { AudioEventPayload } from './events'\nimport { encodingToBitDepth } from './utils/encodingToBitDepth'\n\nexport interface EmitAudioEventProps {\n data: Float32Array\n position: number\n compression?: {\n data: Blob\n size: number\n totalSize: number\n mimeType: string\n format: string\n bitrate: number\n }\n}\nexport type EmitAudioEventFunction = (_: EmitAudioEventProps) => void\nexport type EmitAudioAnalysisFunction = (_: AudioAnalysis) => void\n\nexport interface ExpoAudioStreamWebProps {\n logger?: ConsoleLike\n audioWorkletUrl: string\n featuresExtratorUrl: string\n maxBufferSize?: number // Maximum number of chunks to keep in memory\n}\n\nexport class ExpoAudioStreamWeb extends LegacyEventEmitter {\n customRecorder: WebRecorder | null\n audioChunks: Float32Array[]\n isRecording: boolean\n isPaused: boolean\n recordingStartTime: number\n pausedTime: number\n currentDurationMs: number\n currentSize: number\n currentInterval: number\n lastEmittedSize: number\n lastEmittedTime: number\n lastEmittedCompressionSize: number\n streamUuid: string | null\n extension: 'webm' | 'wav' = 'wav' // Default extension is 'wav'\n recordingConfig?: RecordingConfig\n bitDepth: BitDepth // Bit depth of the audio\n audioWorkletUrl: string\n featuresExtratorUrl: string\n logger?: ConsoleLike\n latestPosition: number = 0\n totalCompressedSize: number = 0\n private readonly maxBufferSize: number\n\n constructor({\n audioWorkletUrl,\n featuresExtratorUrl,\n logger,\n maxBufferSize = 100, // Default to storing last 100 chunks (1 chunk = 0.5 seconds)\n }: ExpoAudioStreamWebProps) {\n const mockNativeModule = {\n addListener: () => {\n // Not used on web\n },\n removeListeners: () => {\n // Not used on web\n },\n }\n super(mockNativeModule) // Pass the mock native module to the parent class\n\n this.logger = logger\n this.customRecorder = null\n this.audioChunks = []\n this.isRecording = false\n this.isPaused = false\n this.recordingStartTime = 0\n this.pausedTime = 0\n this.currentDurationMs = 0\n this.currentSize = 0\n this.bitDepth = 32 // Default\n this.currentInterval = 1000 // Default interval in ms\n this.lastEmittedSize = 0\n this.lastEmittedTime = 0\n this.latestPosition = 0\n this.lastEmittedCompressionSize = 0\n this.streamUuid = null // Initialize UUID on first recording start\n this.audioWorkletUrl = audioWorkletUrl\n this.featuresExtratorUrl = featuresExtratorUrl\n this.maxBufferSize = maxBufferSize\n }\n\n // Utility to handle user media stream\n async getMediaStream() {\n try {\n return await navigator.mediaDevices.getUserMedia({ audio: true })\n } catch (error) {\n this.logger?.error('Failed to get media stream:', error)\n throw error\n }\n }\n\n // Start recording with options\n async startRecording(\n recordingConfig: RecordingConfig = {}\n ): Promise<StartRecordingResult> {\n if (this.isRecording) {\n throw new Error('Recording is already in progress')\n }\n\n this.bitDepth = encodingToBitDepth({\n encoding: recordingConfig.encoding ?? 'pcm_32bit',\n })\n\n const audioContext = new (window.AudioContext ||\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Allow webkitAudioContext for Safari\n window.webkitAudioContext)()\n const stream = await this.getMediaStream()\n\n const source = audioContext.createMediaStreamSource(stream)\n\n this.customRecorder = new WebRecorder({\n logger: this.logger,\n audioContext,\n source,\n recordingConfig,\n audioWorkletUrl: this.audioWorkletUrl,\n emitAudioEventCallback: ({\n data,\n position,\n compression,\n }: EmitAudioEventProps) => {\n // Keep only the latest chunks based on maxBufferSize\n this.audioChunks.push(new Float32Array(data))\n if (this.audioChunks.length > this.maxBufferSize) {\n this.audioChunks.shift() // Remove oldest chunk\n }\n this.currentSize += data.byteLength\n this.emitAudioEvent({ data, position, compression })\n this.lastEmittedTime = Date.now()\n this.lastEmittedSize = this.currentSize\n this.lastEmittedCompressionSize = compression?.size ?? 0\n },\n emitAudioAnalysisCallback: (audioAnalysisData: AudioAnalysis) => {\n this.logger?.log(`Emitted AudioAnalysis:`, audioAnalysisData)\n this.emit('AudioAnalysis', audioAnalysisData)\n },\n })\n await this.customRecorder.init()\n this.customRecorder.start()\n\n // // Set a timer to stop recording after 5 seconds\n // setTimeout(() => {\n // logger.log(\"AUTO Stopping recording\");\n // this.customRecorder?.stopAndPlay();\n // this.isRecording = false;\n // }, 3000);\n\n this.isRecording = true\n this.recordingConfig = recordingConfig\n this.recordingStartTime = Date.now()\n this.pausedTime = 0\n this.isPaused = false\n this.lastEmittedSize = 0\n this.lastEmittedTime = 0\n this.lastEmittedCompressionSize = 0\n\n // Use custom filename if provided, otherwise fallback to timestamp\n if (recordingConfig.filename) {\n // Remove any existing extension from the filename\n this.streamUuid = recordingConfig.filename.replace(/\\.[^/.]+$/, '')\n } else {\n this.streamUuid = Date.now().toString()\n }\n\n const fileUri = `${this.streamUuid}.${this.extension}`\n const streamConfig: StartRecordingResult = {\n fileUri,\n mimeType: `audio/${this.extension}`,\n bitDepth: this.bitDepth,\n channels: recordingConfig.channels ?? 1,\n sampleRate: recordingConfig.sampleRate ?? 44100,\n compression: recordingConfig.compression\n ? {\n ...recordingConfig.compression,\n bitrate: recordingConfig.compression?.bitrate ?? 128000,\n size: 0,\n mimeType: 'audio/webm',\n format: recordingConfig.compression?.format ?? 'opus',\n compressedFileUri: '',\n }\n : undefined,\n }\n return streamConfig\n }\n\n emitAudioEvent({ data, position, compression }: EmitAudioEventProps) {\n const fileUri = `${this.streamUuid}.${this.extension}`\n if (compression?.size) {\n this.lastEmittedCompressionSize = compression.size\n this.totalCompressedSize = compression.totalSize\n }\n this.latestPosition = position\n this.currentDurationMs = position * 1000 // Convert position (in seconds) to ms\n\n const audioEventPayload: AudioEventPayload = {\n fileUri,\n mimeType: `audio/${this.extension}`,\n lastEmittedSize: this.lastEmittedSize,\n deltaSize: data.byteLength,\n position,\n totalSize: this.currentSize,\n buffer: data,\n streamUuid: this.streamUuid ?? '',\n compression: compression\n ? {\n data: compression?.data,\n totalSize: this.totalCompressedSize,\n eventDataSize: compression?.size ?? 0,\n position,\n }\n : undefined,\n }\n\n this.emit('AudioData', audioEventPayload)\n }\n\n // Stop recording\n async stopRecording(): Promise<AudioRecording> {\n if (!this.customRecorder) {\n throw new Error('Recorder is not initialized')\n }\n\n this.logger?.debug('[Stop] Starting stop process')\n const startTime = performance.now()\n\n try {\n this.logger?.debug('[Stop] Stopping recorder')\n const { compressedBlob } = await this.customRecorder.stop()\n\n this.isRecording = false\n this.isPaused = false\n this.currentDurationMs = Date.now() - this.recordingStartTime\n\n let compression: AudioRecording['compression']\n let fileUri = `${this.streamUuid}.${this.extension}`\n let mimeType = `audio/${this.extension}`\n\n if (compressedBlob && this.recordingConfig?.compression?.enabled) {\n const compressedUri = URL.createObjectURL(compressedBlob)\n compression = {\n compressedFileUri: compressedUri,\n size: compressedBlob.size,\n mimeType: 'audio/webm',\n format: 'opus',\n bitrate: this.recordingConfig.compression.bitrate ?? 128000,\n }\n // Use compressed values when compression is enabled\n fileUri = compressedUri\n mimeType = 'audio/webm'\n }\n\n this.logger?.debug(\n `[Stop] Completed stop process in ${performance.now() - startTime}ms`,\n {\n durationMs: this.currentDurationMs,\n compressedSize: compression?.size,\n }\n )\n\n // Use the stored streamUuid (which contains our custom filename) for the final filename\n const filename = `${this.streamUuid}.${this.extension}`\n const result: AudioRecording = {\n fileUri,\n filename, // This will now use our custom filename\n bitDepth: this.bitDepth,\n createdAt: this.recordingStartTime,\n channels: this.recordingConfig?.channels ?? 1,\n sampleRate: this.recordingConfig?.sampleRate ?? 44100,\n durationMs: this.currentDurationMs,\n size: this.currentSize,\n mimeType,\n compression,\n }\n\n // Reset after creating the result\n this.streamUuid = null\n\n return result\n } catch (error) {\n this.logger?.error('[Stop] Error stopping recording:', error)\n throw error\n }\n }\n\n // Pause recording\n async pauseRecording() {\n if (!this.isRecording || this.isPaused) {\n throw new Error('Recording is not active or already paused')\n }\n\n if (this.customRecorder) {\n this.customRecorder.pause()\n }\n this.isPaused = true\n this.pausedTime = Date.now()\n }\n\n // Resume recording\n async resumeRecording() {\n if (!this.isPaused) {\n throw new Error('Recording is not paused')\n }\n\n if (this.customRecorder) {\n this.customRecorder.resume()\n }\n this.isPaused = false\n this.recordingStartTime += Date.now() - this.pausedTime\n }\n\n // Get current status\n status() {\n const status: AudioStreamStatus = {\n isRecording: this.isRecording,\n isPaused: this.isPaused,\n durationMs: this.currentDurationMs,\n size: this.currentSize,\n interval: this.currentInterval,\n mimeType: `audio/${this.extension}`,\n compression: this.recordingConfig?.compression?.enabled\n ? {\n size: this.totalCompressedSize,\n mimeType: 'audio/webm',\n format: this.recordingConfig.compression.format ?? 'opus',\n bitrate:\n this.recordingConfig.compression.bitrate ?? 128000,\n compressedFileUri: `${this.streamUuid}.webm`,\n }\n : undefined,\n }\n return status\n }\n}\n"]}
|
|
@@ -124,8 +124,13 @@ class AudioStreamManager: NSObject {
|
|
|
124
124
|
switch type {
|
|
125
125
|
case .began:
|
|
126
126
|
Logger.debug("Audio session interruption began")
|
|
127
|
-
|
|
127
|
+
// Store the pause start time if not already paused
|
|
128
|
+
if !wasSuspended {
|
|
129
|
+
currentPauseStart = Date()
|
|
130
|
+
pauseRecording()
|
|
131
|
+
}
|
|
128
132
|
|
|
133
|
+
// Always notify delegate of interruption
|
|
129
134
|
delegate?.audioStreamManager(
|
|
130
135
|
self,
|
|
131
136
|
didReceiveInterruption: [
|
|
@@ -135,19 +140,48 @@ class AudioStreamManager: NSObject {
|
|
|
135
140
|
)
|
|
136
141
|
|
|
137
142
|
case .ended:
|
|
138
|
-
Logger.debug("Audio session interruption ended")
|
|
143
|
+
Logger.debug("Audio session interruption ended - autoResume: \(autoResumeAfterInterruption), wasSuspended: \(wasSuspended)")
|
|
139
144
|
if let optionsValue = userInfo[AVAudioSessionInterruptionOptionKey] as? UInt {
|
|
140
145
|
let options = AVAudioSession.InterruptionOptions(rawValue: optionsValue)
|
|
146
|
+
Logger.debug("Interruption options - shouldResume: \(options.contains(.shouldResume))")
|
|
147
|
+
|
|
148
|
+
// Calculate pause duration if we have a pause start time
|
|
149
|
+
if let pauseStart = currentPauseStart {
|
|
150
|
+
let pauseDuration = Date().timeIntervalSince(pauseStart)
|
|
151
|
+
totalPausedDuration += pauseDuration
|
|
152
|
+
currentPauseStart = nil
|
|
153
|
+
Logger.debug("Added interruption pause duration: \(pauseDuration), total paused: \(totalPausedDuration)")
|
|
154
|
+
}
|
|
141
155
|
|
|
142
|
-
//
|
|
143
|
-
if autoResumeAfterInterruption &&
|
|
144
|
-
// Add a
|
|
145
|
-
DispatchQueue.main.asyncAfter(deadline: .now() + 0
|
|
156
|
+
// For phone calls, we should auto-resume if enabled, regardless of previous pause state
|
|
157
|
+
if autoResumeAfterInterruption && isRecording {
|
|
158
|
+
// Add a longer delay for phone calls and ensure proper session setup
|
|
159
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) { [weak self] in
|
|
146
160
|
guard let self = self else { return }
|
|
147
|
-
|
|
161
|
+
Logger.debug("Attempting to auto-resume recording after phone call")
|
|
162
|
+
|
|
163
|
+
// Configure audio session
|
|
164
|
+
do {
|
|
165
|
+
let session = AVAudioSession.sharedInstance()
|
|
166
|
+
try session.setActive(false, options: .notifyOthersOnDeactivation)
|
|
167
|
+
try session.setCategory(.playAndRecord, mode: .default, options: [.allowBluetooth, .mixWithOthers])
|
|
168
|
+
try session.setActive(true, options: .notifyOthersOnDeactivation)
|
|
169
|
+
|
|
170
|
+
// Resume if we're still recording and paused
|
|
171
|
+
if self.isRecording && self.isPaused {
|
|
172
|
+
Logger.debug("Resuming recording after phone call interruption")
|
|
173
|
+
self.resumeRecording()
|
|
174
|
+
} else {
|
|
175
|
+
Logger.debug("Cannot resume - recording state invalid: isRecording=\(self.isRecording), isPaused=\(self.isPaused)")
|
|
176
|
+
}
|
|
177
|
+
} catch {
|
|
178
|
+
Logger.debug("Failed to reactivate audio session: \(error)")
|
|
179
|
+
self.delegate?.audioStreamManager(self, didFailWithError: "Failed to auto-resume: \(error.localizedDescription)")
|
|
180
|
+
}
|
|
148
181
|
}
|
|
149
182
|
}
|
|
150
183
|
|
|
184
|
+
// Always notify delegate of interruption end
|
|
151
185
|
delegate?.audioStreamManager(
|
|
152
186
|
self,
|
|
153
187
|
didReceiveInterruption: [
|
|
@@ -252,16 +286,21 @@ class AudioStreamManager: NSObject {
|
|
|
252
286
|
return lastDuration
|
|
253
287
|
}
|
|
254
288
|
|
|
255
|
-
guard let settings = recordingSettings
|
|
289
|
+
guard let settings = recordingSettings,
|
|
290
|
+
let startTime = self.startTime else { return 0 }
|
|
291
|
+
|
|
292
|
+
let now = Date()
|
|
293
|
+
var duration = now.timeIntervalSince(startTime)
|
|
256
294
|
|
|
257
|
-
//
|
|
258
|
-
|
|
259
|
-
let channels = Double(settings.numberOfChannels)
|
|
260
|
-
let bytesPerSample = Double(settings.bitDepth) / 8.0
|
|
295
|
+
// Subtract total paused duration
|
|
296
|
+
duration -= TimeInterval(totalPausedDuration)
|
|
261
297
|
|
|
262
|
-
|
|
298
|
+
// If we're currently in a pause (including background pause for !keepAwake), subtract that too
|
|
299
|
+
if let pauseStart = currentPauseStart {
|
|
300
|
+
duration -= now.timeIntervalSince(pauseStart)
|
|
301
|
+
}
|
|
263
302
|
|
|
264
|
-
return
|
|
303
|
+
return duration
|
|
265
304
|
}
|
|
266
305
|
|
|
267
306
|
private func cleanupNotificationObservers() {
|
|
@@ -292,6 +331,11 @@ class AudioStreamManager: NSObject {
|
|
|
292
331
|
|
|
293
332
|
@objc private func handleAppDidEnterBackground(_ notification: Notification) {
|
|
294
333
|
if isRecording {
|
|
334
|
+
// If keepAwake is false, we should track this as a pause
|
|
335
|
+
if let settings = recordingSettings, !settings.keepAwake {
|
|
336
|
+
currentPauseStart = Date()
|
|
337
|
+
}
|
|
338
|
+
|
|
295
339
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
|
|
296
340
|
self?.notificationManager?.showInitialNotification()
|
|
297
341
|
}
|
|
@@ -300,6 +344,14 @@ class AudioStreamManager: NSObject {
|
|
|
300
344
|
|
|
301
345
|
@objc private func handleAppWillEnterForeground(_ notification: Notification) {
|
|
302
346
|
if isRecording {
|
|
347
|
+
// If we were paused due to background and keepAwake was false, calculate pause duration
|
|
348
|
+
if let settings = recordingSettings, !settings.keepAwake, let pauseStart = currentPauseStart {
|
|
349
|
+
let pauseDuration = Date().timeIntervalSince(pauseStart)
|
|
350
|
+
totalPausedDuration += pauseDuration
|
|
351
|
+
currentPauseStart = nil
|
|
352
|
+
Logger.debug("Added background pause duration: \(pauseDuration), total paused: \(totalPausedDuration)")
|
|
353
|
+
}
|
|
354
|
+
|
|
303
355
|
notificationManager?.stopUpdates()
|
|
304
356
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
|
|
305
357
|
guard let self = self else { return }
|
|
@@ -387,8 +439,17 @@ class AudioStreamManager: NSObject {
|
|
|
387
439
|
Logger.debug("Using default directory: \(baseDirectory.path)")
|
|
388
440
|
}
|
|
389
441
|
|
|
390
|
-
//
|
|
391
|
-
let baseFilename
|
|
442
|
+
// Generate or reuse UUID for filename
|
|
443
|
+
let baseFilename: String
|
|
444
|
+
if let existingFilename = recordingSettings?.filename {
|
|
445
|
+
baseFilename = existingFilename
|
|
446
|
+
} else if let existingUUID = recordingUUID {
|
|
447
|
+
baseFilename = existingUUID.uuidString
|
|
448
|
+
} else {
|
|
449
|
+
let newUUID = UUID()
|
|
450
|
+
recordingUUID = newUUID
|
|
451
|
+
baseFilename = newUUID.uuidString
|
|
452
|
+
}
|
|
392
453
|
Logger.debug("Using base filename: \(baseFilename)")
|
|
393
454
|
|
|
394
455
|
// Remove any existing extension from the filename
|
|
@@ -522,9 +583,18 @@ class AudioStreamManager: NSObject {
|
|
|
522
583
|
// Store settings first before doing anything else
|
|
523
584
|
recordingSettings = settings
|
|
524
585
|
|
|
525
|
-
//
|
|
526
|
-
|
|
527
|
-
|
|
586
|
+
// Reset audio session before starting new recording
|
|
587
|
+
do {
|
|
588
|
+
let session = AVAudioSession.sharedInstance()
|
|
589
|
+
try session.setActive(false, options: .notifyOthersOnDeactivation)
|
|
590
|
+
Thread.sleep(forTimeInterval: 0.1) // Brief pause to ensure clean state
|
|
591
|
+
try session.setActive(true, options: .notifyOthersOnDeactivation)
|
|
592
|
+
} catch {
|
|
593
|
+
Logger.debug("Failed to reset audio session: \(error)")
|
|
594
|
+
delegate?.audioStreamManager(self, didFailWithError: "Failed to reset audio session: \(error.localizedDescription)")
|
|
595
|
+
return nil
|
|
596
|
+
}
|
|
597
|
+
|
|
528
598
|
// Update auto-resume preference from settings
|
|
529
599
|
autoResumeAfterInterruption = settings.autoResumeAfterInterruption
|
|
530
600
|
|
|
@@ -566,36 +636,41 @@ class AudioStreamManager: NSObject {
|
|
|
566
636
|
newSettings.sampleRate = settings.sampleRate // Keep original sample rate
|
|
567
637
|
}
|
|
568
638
|
|
|
569
|
-
//
|
|
639
|
+
// Get base configuration from user settings or defaults
|
|
640
|
+
var category: AVAudioSession.Category = .playAndRecord
|
|
641
|
+
var mode: AVAudioSession.Mode = .default
|
|
642
|
+
var options: AVAudioSession.CategoryOptions = [.allowBluetooth, .mixWithOthers]
|
|
643
|
+
|
|
570
644
|
if let audioSessionConfig = settings.ios?.audioSession {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
645
|
+
category = audioSessionConfig.category
|
|
646
|
+
mode = audioSessionConfig.mode
|
|
647
|
+
options = audioSessionConfig.categoryOptions
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// Append necessary options for background recording if keepAwake is enabled
|
|
651
|
+
if settings.keepAwake {
|
|
652
|
+
Logger.debug("keepAwake enabled - configuring for background recording")
|
|
653
|
+
// Add background audio option
|
|
654
|
+
options.insert(.mixWithOthers)
|
|
655
|
+
try session.setActive(true, options: .notifyOthersOnDeactivation)
|
|
579
656
|
} else {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
.allowBluetooth,
|
|
584
|
-
.defaultToSpeaker,
|
|
585
|
-
.mixWithOthers,
|
|
586
|
-
.allowBluetoothA2DP,
|
|
587
|
-
.allowAirPlay
|
|
588
|
-
]
|
|
589
|
-
|
|
590
|
-
try session.setCategory(defaultCategory, mode: defaultMode, options: defaultOptions)
|
|
591
|
-
Logger.debug("""
|
|
592
|
-
Audio Session Configuration (Default):
|
|
593
|
-
- Category: \(defaultCategory)
|
|
594
|
-
- Mode: \(defaultMode)
|
|
595
|
-
- Options: \(defaultOptions)
|
|
596
|
-
""")
|
|
657
|
+
Logger.debug("keepAwake disabled - using standard session configuration")
|
|
658
|
+
// If keepAwake is false, don't add background audio options
|
|
659
|
+
try session.setActive(true)
|
|
597
660
|
}
|
|
598
661
|
|
|
662
|
+
// Apply the final configuration
|
|
663
|
+
try session.setCategory(category, mode: mode, options: options)
|
|
664
|
+
try session.setActive(true, options: .notifyOthersOnDeactivation)
|
|
665
|
+
|
|
666
|
+
Logger.debug("""
|
|
667
|
+
Audio session configured:
|
|
668
|
+
- category: \(category)
|
|
669
|
+
- mode: \(mode)
|
|
670
|
+
- options: \(options)
|
|
671
|
+
- keepAwake: \(settings.keepAwake)
|
|
672
|
+
""")
|
|
673
|
+
|
|
599
674
|
try session.setPreferredSampleRate(settings.sampleRate)
|
|
600
675
|
try session.setPreferredIOBufferDuration(1024 / Double(settings.sampleRate))
|
|
601
676
|
try session.setActive(true)
|
|
@@ -642,36 +717,44 @@ class AudioStreamManager: NSObject {
|
|
|
642
717
|
if settings.enableCompressedOutput {
|
|
643
718
|
do {
|
|
644
719
|
let compressedSettings: [String: Any] = [
|
|
645
|
-
AVFormatIDKey:
|
|
646
|
-
AVSampleRateKey: settings.sampleRate,
|
|
720
|
+
AVFormatIDKey: kAudioFormatMPEG4AAC,
|
|
721
|
+
AVSampleRateKey: Float64(settings.sampleRate),
|
|
647
722
|
AVNumberOfChannelsKey: settings.numberOfChannels,
|
|
648
|
-
AVEncoderBitRateKey: settings.compressedBitRate,
|
|
649
|
-
AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
|
|
650
|
-
AVEncoderBitDepthHintKey: 16
|
|
723
|
+
AVEncoderBitRateKey: settings.compressedBitRate ?? 24000,
|
|
724
|
+
AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
|
|
651
725
|
]
|
|
652
726
|
|
|
653
727
|
Logger.debug("Initializing compressed recording with settings: \(compressedSettings)")
|
|
654
728
|
|
|
655
|
-
// Use createRecordingFile for consistency in file handling
|
|
656
729
|
compressedFileURL = createRecordingFile(isCompressed: true)
|
|
657
730
|
|
|
658
731
|
if let url = compressedFileURL {
|
|
659
732
|
Logger.debug("Using compressed file URL: \(url.path)")
|
|
660
733
|
|
|
661
|
-
// Initialize recorder
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
let
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
734
|
+
// Initialize recorder with proper error handling
|
|
735
|
+
do {
|
|
736
|
+
compressedRecorder = try AVAudioRecorder(url: url, settings: compressedSettings)
|
|
737
|
+
if let recorder = compressedRecorder {
|
|
738
|
+
recorder.delegate = self // Add this line to get recording callbacks
|
|
739
|
+
|
|
740
|
+
if !recorder.prepareToRecord() {
|
|
741
|
+
Logger.debug("Failed to prepare recorder")
|
|
742
|
+
throw NSError(domain: "AudioStreamManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "Failed to prepare recorder"])
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
if !recorder.record() {
|
|
746
|
+
Logger.debug("Failed to start recorder")
|
|
747
|
+
throw NSError(domain: "AudioStreamManager", code: -2, userInfo: [NSLocalizedDescriptionKey: "Failed to start recorder"])
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
Logger.debug("Compressed recording started successfully")
|
|
751
|
+
compressedFormat = "aac"
|
|
752
|
+
compressedBitRate = settings.compressedBitRate ?? 24000
|
|
753
|
+
}
|
|
754
|
+
} catch {
|
|
755
|
+
Logger.debug("Failed to initialize compressed recorder: \(error)")
|
|
756
|
+
compressedFileURL = nil
|
|
757
|
+
compressedRecorder = nil
|
|
675
758
|
}
|
|
676
759
|
}
|
|
677
760
|
} catch {
|
|
@@ -914,6 +997,8 @@ class AudioStreamManager: NSObject {
|
|
|
914
997
|
func stopRecording() -> RecordingResult? {
|
|
915
998
|
guard isRecording else { return nil }
|
|
916
999
|
|
|
1000
|
+
Logger.debug("Stopping recording...")
|
|
1001
|
+
|
|
917
1002
|
disableWakeLock()
|
|
918
1003
|
audioEngine.stop()
|
|
919
1004
|
audioEngine.inputNode.removeTap(onBus: 0)
|
|
@@ -943,72 +1028,126 @@ class AudioStreamManager: NSObject {
|
|
|
943
1028
|
self.remoteCommandCenter?.playCommand.isEnabled = false
|
|
944
1029
|
self.notificationView?.nowPlayingInfo = nil
|
|
945
1030
|
}
|
|
946
|
-
|
|
947
|
-
// Clean up audio session
|
|
948
|
-
try? audioSession?.setActive(false)
|
|
949
1031
|
}
|
|
950
1032
|
|
|
1033
|
+
// Reset audio session
|
|
1034
|
+
do {
|
|
1035
|
+
try AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)
|
|
1036
|
+
} catch {
|
|
1037
|
+
Logger.debug("Error deactivating audio session: \(error)")
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
// Reset audio engine
|
|
1041
|
+
audioEngine.reset()
|
|
1042
|
+
|
|
951
1043
|
guard let fileURL = recordingFileURL,
|
|
952
1044
|
let settings = recordingSettings else {
|
|
953
1045
|
Logger.debug("Recording or file URL is nil.")
|
|
954
1046
|
return nil
|
|
955
1047
|
}
|
|
956
1048
|
|
|
957
|
-
//
|
|
958
|
-
let
|
|
959
|
-
|
|
960
|
-
// Calculate the total size of audio data written to the file
|
|
961
|
-
let filePath = fileURL.path
|
|
1049
|
+
// Validate WAV file
|
|
1050
|
+
let wavPath = fileURL.path
|
|
962
1051
|
do {
|
|
963
|
-
|
|
964
|
-
let
|
|
1052
|
+
// Check if WAV file exists
|
|
1053
|
+
let wavFileAttributes = try FileManager.default.attributesOfItem(atPath: wavPath)
|
|
1054
|
+
let wavFileSize = wavFileAttributes[FileAttributeKey.size] as? Int64 ?? 0
|
|
1055
|
+
|
|
1056
|
+
Logger.debug("""
|
|
1057
|
+
WAV File validation:
|
|
1058
|
+
- Path: \(wavPath)
|
|
1059
|
+
- Exists: true
|
|
1060
|
+
- Size: \(wavFileSize) bytes
|
|
1061
|
+
- Duration: \(finalDuration) seconds
|
|
1062
|
+
- Expected minimum size: 44 bytes (WAV header)
|
|
1063
|
+
""")
|
|
965
1064
|
|
|
966
|
-
// Return nil if the file is too small
|
|
967
|
-
if
|
|
1065
|
+
// Return nil if the file is too small
|
|
1066
|
+
if wavFileSize <= 44 {
|
|
968
1067
|
Logger.debug("Recording file is too small (≤ 44 bytes), likely no audio data was recorded")
|
|
969
1068
|
return nil
|
|
970
1069
|
}
|
|
971
1070
|
|
|
972
1071
|
// Update the WAV header with the correct file size
|
|
973
|
-
updateWavHeader(fileURL: fileURL, totalDataSize:
|
|
1072
|
+
updateWavHeader(fileURL: fileURL, totalDataSize: wavFileSize - 44)
|
|
974
1073
|
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1074
|
+
// Validate compressed file if enabled
|
|
1075
|
+
var compression: CompressedRecordingInfo?
|
|
1076
|
+
if let compressedURL = compressedFileURL {
|
|
1077
|
+
let compressedPath = compressedURL.path
|
|
1078
|
+
if FileManager.default.fileExists(atPath: compressedPath) {
|
|
1079
|
+
let compressedAttributes = try FileManager.default.attributesOfItem(atPath: compressedPath)
|
|
1080
|
+
let compressedSize = compressedAttributes[FileAttributeKey.size] as? Int64 ?? 0
|
|
1081
|
+
|
|
1082
|
+
Logger.debug("""
|
|
1083
|
+
Compressed File validation:
|
|
1084
|
+
- Path: \(compressedPath)
|
|
1085
|
+
- Format: \(compressedFormat ?? "unknown")
|
|
1086
|
+
- Size: \(compressedSize) bytes
|
|
1087
|
+
- Bitrate: \(compressedBitRate ?? 0) bps
|
|
1088
|
+
""")
|
|
1089
|
+
|
|
1090
|
+
if compressedSize > 0 {
|
|
1091
|
+
compression = CompressedRecordingInfo(
|
|
1092
|
+
compressedFileUri: compressedURL.absoluteString,
|
|
1093
|
+
mimeType: compressedFormat == "aac" ? "audio/aac" : "audio/opus",
|
|
1094
|
+
bitrate: compressedBitRate,
|
|
1095
|
+
format: compressedFormat,
|
|
1096
|
+
size: compressedSize
|
|
1097
|
+
)
|
|
1098
|
+
} else {
|
|
1099
|
+
Logger.debug("Warning: Compressed file exists but is empty")
|
|
1100
|
+
}
|
|
1101
|
+
} else {
|
|
1102
|
+
Logger.debug("Warning: Compressed file not found at path: \(compressedPath)")
|
|
1103
|
+
}
|
|
987
1104
|
}
|
|
988
|
-
|
|
1105
|
+
|
|
1106
|
+
let durationMs = Int64(finalDuration * 1000)
|
|
1107
|
+
|
|
989
1108
|
let result = RecordingResult(
|
|
990
1109
|
fileUri: fileURL.absoluteString,
|
|
991
1110
|
filename: fileURL.lastPathComponent,
|
|
992
1111
|
mimeType: mimeType,
|
|
993
1112
|
duration: durationMs,
|
|
994
|
-
size:
|
|
1113
|
+
size: wavFileSize,
|
|
995
1114
|
channels: settings.numberOfChannels,
|
|
996
1115
|
bitDepth: settings.bitDepth,
|
|
997
1116
|
sampleRate: settings.sampleRate,
|
|
998
1117
|
compression: compression
|
|
999
1118
|
)
|
|
1000
1119
|
|
|
1001
|
-
|
|
1120
|
+
Logger.debug("""
|
|
1121
|
+
Recording completed successfully:
|
|
1122
|
+
- WAV file: \(fileURL.lastPathComponent)
|
|
1123
|
+
- Size: \(wavFileSize) bytes
|
|
1124
|
+
- Duration: \(durationMs)ms
|
|
1125
|
+
- Sample rate: \(settings.sampleRate)Hz
|
|
1126
|
+
- Bit depth: \(settings.bitDepth)-bit
|
|
1127
|
+
- Channels: \(settings.numberOfChannels)
|
|
1128
|
+
- Compressed: \(compression != nil ? "yes" : "no")
|
|
1129
|
+
""")
|
|
1130
|
+
|
|
1131
|
+
// Additional cleanup
|
|
1002
1132
|
recordingFileURL = nil
|
|
1003
1133
|
lastBufferTime = nil
|
|
1004
1134
|
lastValidDuration = nil
|
|
1005
1135
|
compressedRecorder = nil
|
|
1006
1136
|
compressedFileURL = nil
|
|
1137
|
+
recordingSettings = nil
|
|
1138
|
+
startTime = nil
|
|
1139
|
+
totalPausedDuration = 0
|
|
1140
|
+
currentPauseStart = nil
|
|
1141
|
+
lastEmissionTime = nil
|
|
1142
|
+
lastEmittedSize = 0
|
|
1143
|
+
lastEmittedCompressedSize = 0
|
|
1144
|
+
accumulatedData.removeAll()
|
|
1145
|
+
recordingUUID = nil
|
|
1007
1146
|
|
|
1008
1147
|
return result
|
|
1009
1148
|
|
|
1010
1149
|
} catch {
|
|
1011
|
-
Logger.debug("Failed to
|
|
1150
|
+
Logger.debug("Failed to validate recording files: \(error)")
|
|
1012
1151
|
return nil
|
|
1013
1152
|
}
|
|
1014
1153
|
}
|
|
@@ -1496,3 +1635,20 @@ extension AudioStreamManager: UNUserNotificationCenterDelegate {
|
|
|
1496
1635
|
}
|
|
1497
1636
|
}
|
|
1498
1637
|
}
|
|
1638
|
+
|
|
1639
|
+
// Add AVAudioRecorderDelegate conformance
|
|
1640
|
+
extension AudioStreamManager: AVAudioRecorderDelegate {
|
|
1641
|
+
func audioRecorderDidFinishRecording(_ recorder: AVAudioRecorder, successfully flag: Bool) {
|
|
1642
|
+
Logger.debug("Compressed recording finished - success: \(flag)")
|
|
1643
|
+
if !flag {
|
|
1644
|
+
delegate?.audioStreamManager(self, didFailWithError: "Compressed recording failed to complete")
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
func audioRecorderEncodeErrorDidOccur(_ recorder: AVAudioRecorder, error: Error?) {
|
|
1649
|
+
if let error = error {
|
|
1650
|
+
Logger.debug("Compressed recording encode error: \(error)")
|
|
1651
|
+
delegate?.audioStreamManager(self, didFailWithError: "Compressed recording encode error: \(error.localizedDescription)")
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
@@ -222,6 +222,7 @@ public class ExpoAudioStreamModule: Module, AudioStreamManagerDelegate {
|
|
|
222
222
|
"bitDepth": recordingResult.bitDepth,
|
|
223
223
|
"sampleRate": recordingResult.sampleRate,
|
|
224
224
|
"mimeType": recordingResult.mimeType,
|
|
225
|
+
"createdAt": Date().timeIntervalSince1970 * 1000,
|
|
225
226
|
]
|
|
226
227
|
|
|
227
228
|
// Add compression info if available
|
package/package.json
CHANGED
|
@@ -69,6 +69,7 @@ export interface AudioRecording {
|
|
|
69
69
|
channels: number
|
|
70
70
|
bitDepth: BitDepth
|
|
71
71
|
sampleRate: SampleRate
|
|
72
|
+
createdAt?: number
|
|
72
73
|
transcripts?: TranscriberData[]
|
|
73
74
|
analysisData?: AudioAnalysis // Analysis data for the recording depending on enableProcessing flag
|
|
74
75
|
compression?: CompressionInfo & {
|
|
@@ -282,6 +282,7 @@ export class ExpoAudioStreamWeb extends LegacyEventEmitter {
|
|
|
282
282
|
fileUri,
|
|
283
283
|
filename, // This will now use our custom filename
|
|
284
284
|
bitDepth: this.bitDepth,
|
|
285
|
+
createdAt: this.recordingStartTime,
|
|
285
286
|
channels: this.recordingConfig?.channels ?? 1,
|
|
286
287
|
sampleRate: this.recordingConfig?.sampleRate ?? 44100,
|
|
287
288
|
durationMs: this.currentDurationMs,
|