Skip to content

Commit 8799c0f

Browse files
authored
Merge pull request #2860 from GetStream/develop
Next Release
2 parents bf6ee2b + d43a7b1 commit 8799c0f

File tree

7 files changed

+520
-370
lines changed

7 files changed

+520
-370
lines changed

examples/ExpoMessaging/yarn.lock

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,14 +1881,6 @@
18811881
find-up "^5.0.0"
18821882
js-yaml "^4.1.0"
18831883

1884-
"@gorhom/bottom-sheet@^4.6.4":
1885-
version "4.6.4"
1886-
resolved "https://registry.yarnpkg.com/@gorhom/bottom-sheet/-/bottom-sheet-4.6.4.tgz#387d0f0f21e3470eb8575498cb81ce96f5108e79"
1887-
integrity sha512-0itLMblLBvepE065w3a60S030c2rNUsGshPC7wbWDm31VyqoaU2xjzh/ojH62YIJOcobBr5QoC30IxBBKDGovQ==
1888-
dependencies:
1889-
"@gorhom/portal" "1.0.14"
1890-
invariant "^2.2.4"
1891-
18921884
"@gorhom/bottom-sheet@^5.0.6":
18931885
version "5.0.6"
18941886
resolved "https://registry.yarnpkg.com/@gorhom/bottom-sheet/-/bottom-sheet-5.0.6.tgz#f20736502399c7bcf8c73ea09e6b571dc07fe0eb"
@@ -7034,24 +7026,6 @@ [email protected], stream-buffers@~2.2.0:
70347026
version "0.0.0"
70357027
uid ""
70367028

7037-
7038-
version "5.44.1"
7039-
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.44.1.tgz#0c4629ba01390574dabb963e2e805eb38602d2d4"
7040-
integrity sha512-cJqfsogmiTwK93kpPQhwaOl+whkH05JFl4k501r0VJbm6xlzv5eVb3NZfi6bX1z2xrILYHC5BFabM0RsX/xL/Q==
7041-
dependencies:
7042-
"@gorhom/bottom-sheet" "^4.6.4"
7043-
dayjs "1.10.5"
7044-
emoji-regex "^10.3.0"
7045-
i18next "^21.6.14"
7046-
intl-pluralrules "^2.0.1"
7047-
linkifyjs "^4.1.1"
7048-
lodash-es "4.17.21"
7049-
mime-types "^2.1.34"
7050-
path "0.12.7"
7051-
react-native-markdown-package "1.8.2"
7052-
react-native-url-polyfill "^1.3.0"
7053-
stream-chat "8.46.0"
7054-
70557029
"stream-chat-react-native-core@link:../../package":
70567030
version "0.0.0"
70577031
uid ""

package/expo-package/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
getPhotos,
1212
iOS14RefreshGallerySelection,
1313
oniOS14GalleryLibrarySelectionChange,
14+
overrideAudioRecordingConfiguration,
1415
pickDocument,
1516
pickImage,
1617
saveFile,
@@ -31,6 +32,7 @@ registerNativeHandlers({
3132
getPhotos,
3233
iOS14RefreshGallerySelection,
3334
oniOS14GalleryLibrarySelectionChange,
35+
overrideAudioRecordingConfiguration,
3436
pickDocument,
3537
pickImage,
3638
saveFile,
Lines changed: 38 additions & 232 deletions
Original file line numberDiff line numberDiff line change
@@ -1,216 +1,13 @@
1-
import { AudioComponent, RecordingObject } from './AudioVideo';
2-
3-
export enum AndroidOutputFormat {
4-
DEFAULT = 0,
5-
THREE_GPP = 1,
6-
MPEG_4 = 2,
7-
AMR_NB = 3,
8-
AMR_WB = 4,
9-
AAC_ADIF = 5,
10-
AAC_ADTS = 6,
11-
RTP_AVP = 7,
12-
MPEG2TS = 8,
13-
WEBM = 9,
14-
}
15-
16-
// @docsMissing
17-
export enum AndroidAudioEncoder {
18-
DEFAULT = 0,
19-
AMR_NB = 1,
20-
AMR_WB = 2,
21-
AAC = 3,
22-
HE_AAC = 4,
23-
AAC_ELD = 5,
24-
}
25-
26-
export enum IOSOutputFormat {
27-
LINEARPCM = 'lpcm',
28-
AC3 = 'ac-3',
29-
'60958AC3' = 'cac3',
30-
APPLEIMA4 = 'ima4',
31-
MPEG4AAC = 'aac ',
32-
MPEG4CELP = 'celp',
33-
MPEG4HVXC = 'hvxc',
34-
MPEG4TWINVQ = 'twvq',
35-
MACE3 = 'MAC3',
36-
MACE6 = 'MAC6',
37-
ULAW = 'ulaw',
38-
ALAW = 'alaw',
39-
QDESIGN = 'QDMC',
40-
QDESIGN2 = 'QDM2',
41-
QUALCOMM = 'Qclp',
42-
MPEGLAYER1 = '.mp1',
43-
MPEGLAYER2 = '.mp2',
44-
MPEGLAYER3 = '.mp3',
45-
APPLELOSSLESS = 'alac',
46-
MPEG4AAC_HE = 'aach',
47-
MPEG4AAC_LD = 'aacl',
48-
MPEG4AAC_ELD = 'aace',
49-
MPEG4AAC_ELD_SBR = 'aacf',
50-
MPEG4AAC_ELD_V2 = 'aacg',
51-
MPEG4AAC_HE_V2 = 'aacp',
52-
MPEG4AAC_SPATIAL = 'aacs',
53-
AMR = 'samr',
54-
AMR_WB = 'sawb',
55-
AUDIBLE = 'AUDB',
56-
ILBC = 'ilbc',
57-
DVIINTELIMA = 0x6d730011,
58-
MICROSOFTGSM = 0x6d730031,
59-
AES3 = 'aes3',
60-
ENHANCEDAC3 = 'ec-3',
61-
}
62-
63-
export enum IOSAudioQuality {
64-
MIN = 0,
65-
LOW = 0x20,
66-
MEDIUM = 0x40,
67-
HIGH = 0x60,
68-
MAX = 0x7f,
69-
}
1+
import {
2+
AndroidAudioEncoder,
3+
AndroidOutputFormat,
4+
ExpoAudioRecordingConfiguration as AudioRecordingConfiguration,
5+
IOSAudioQuality,
6+
IOSOutputFormat,
7+
ExpoRecordingOptions as RecordingOptions,
8+
} from 'stream-chat-react-native-core';
709

71-
export type RecordingOptionsAndroid = {
72-
/**
73-
* The desired audio encoder. See the [`AndroidAudioEncoder`](#androidaudioencoder) enum for all valid values.
74-
*/
75-
audioEncoder: AndroidAudioEncoder | number;
76-
/**
77-
* The desired file extension. Example valid values are `.3gp` and `.m4a`.
78-
* For more information, see the [Android docs](https://developer.android.com/guide/topics/media/media-formats)
79-
* for supported output formats.
80-
*/
81-
extension: string;
82-
/**
83-
* The desired file format. See the [`AndroidOutputFormat`](#androidoutputformat) enum for all valid values.
84-
*/
85-
outputFormat: AndroidOutputFormat | number;
86-
/**
87-
* The desired bit rate.
88-
*
89-
* Note that `prepareToRecordAsync()` may perform additional checks on the parameter to make sure whether the specified
90-
* bit rate is applicable, and sometimes the passed bitRate will be clipped internally to ensure the audio recording
91-
* can proceed smoothly based on the capabilities of the platform.
92-
*
93-
* @example `128000`
94-
*/
95-
bitRate?: number;
96-
/**
97-
* The desired maximum file size in bytes, after which the recording will stop (but `stopAndUnloadAsync()` must still
98-
* be called after this point).
99-
*
100-
* @example `65536`
101-
*/
102-
maxFileSize?: number;
103-
/**
104-
* The desired number of channels.
105-
*
106-
* Note that `prepareToRecordAsync()` may perform additional checks on the parameter to make sure whether the specified
107-
* number of audio channels are applicable.
108-
*
109-
* @example `1`, `2`
110-
*/
111-
numberOfChannels?: number;
112-
/**
113-
* The desired sample rate.
114-
*
115-
* Note that the sampling rate depends on the format for the audio recording, as well as the capabilities of the platform.
116-
* For instance, the sampling rate supported by AAC audio coding standard ranges from 8 to 96 kHz,
117-
* the sampling rate supported by AMRNB is 8kHz, and the sampling rate supported by AMRWB is 16kHz.
118-
* Please consult with the related audio coding standard for the supported audio sampling rate.
119-
*
120-
* @example 44100
121-
*/
122-
sampleRate?: number;
123-
};
124-
125-
export type RecordingOptionsIOS = {
126-
/**
127-
* The desired audio quality. See the [`IOSAudioQuality`](#iosaudioquality) enum for all valid values.
128-
*/
129-
audioQuality: IOSAudioQuality | number;
130-
/**
131-
* The desired bit rate.
132-
*
133-
* @example `128000`
134-
*/
135-
bitRate: number;
136-
/**
137-
* The desired file extension.
138-
*
139-
* @example `'.caf'`
140-
*/
141-
extension: string;
142-
/**
143-
* The desired number of channels.
144-
*
145-
* @example `1`, `2`
146-
*/
147-
numberOfChannels: number;
148-
/**
149-
* The desired sample rate.
150-
*
151-
* @example `44100`
152-
*/
153-
sampleRate: number;
154-
/**
155-
* The desired bit depth hint.
156-
*
157-
* @example `16`
158-
*/
159-
bitDepthHint?: number;
160-
/**
161-
* The desired bit rate strategy. See the next section for an enumeration of all valid values of `bitRateStrategy`.
162-
*/
163-
bitRateStrategy?: number;
164-
/**
165-
* The desired PCM bit depth.
166-
*
167-
* @example `16`
168-
*/
169-
linearPCMBitDepth?: number;
170-
/**
171-
* A boolean describing if the PCM data should be formatted in big endian.
172-
*/
173-
linearPCMIsBigEndian?: boolean;
174-
/**
175-
* A boolean describing if the PCM data should be encoded in floating point or integral values.
176-
*/
177-
linearPCMIsFloat?: boolean;
178-
/**
179-
* The desired file format. See the [`IOSOutputFormat`](#iosoutputformat) enum for all valid values.
180-
*/
181-
outputFormat?: string | IOSOutputFormat | number;
182-
};
183-
184-
// @docsMissing
185-
export type RecordingOptionsWeb = {
186-
bitsPerSecond?: number;
187-
mimeType?: string;
188-
};
189-
190-
export type RecordingOptions = {
191-
/**
192-
* Recording options for the Android platform.
193-
*/
194-
android: RecordingOptionsAndroid;
195-
/**
196-
* Recording options for the iOS platform.
197-
*/
198-
ios: RecordingOptionsIOS;
199-
/**
200-
* Recording options for the Web platform.
201-
*/
202-
web: RecordingOptionsWeb;
203-
/**
204-
* A boolean that determines whether audio level information will be part of the status object under the "metering" key.
205-
*/
206-
isMeteringEnabled?: boolean;
207-
/**
208-
* A boolean that hints to keep the audio active after `prepareToRecordAsync` completes.
209-
* Setting this value can improve the speed at which the recording starts. Only set this value to `true` when you call `startAsync`
210-
* immediately after `prepareToRecordAsync`. This value is automatically set when using `Audio.recording.createAsync()`.
211-
*/
212-
keepAudioActiveHint?: boolean;
213-
};
10+
import { AudioComponent, RecordingObject } from './AudioVideo';
21411

21512
const sleep = (ms: number) =>
21613
new Promise<void>((resolve) => {
@@ -221,6 +18,29 @@ const sleep = (ms: number) =>
22118

22219
class _Audio {
22320
recording: typeof RecordingObject | null = null;
21+
audioRecordingConfiguration: AudioRecordingConfiguration = {
22+
mode: {
23+
allowsRecordingIOS: true,
24+
playsInSilentModeIOS: true,
25+
},
26+
options: {
27+
android: {
28+
audioEncoder: AndroidAudioEncoder.AAC,
29+
extension: '.aac',
30+
outputFormat: AndroidOutputFormat.AAC_ADTS,
31+
},
32+
ios: {
33+
audioQuality: IOSAudioQuality.HIGH,
34+
bitRate: 128000,
35+
extension: '.aac',
36+
numberOfChannels: 2,
37+
outputFormat: IOSOutputFormat.MPEG4AAC,
38+
sampleRate: 44100,
39+
},
40+
isMeteringEnabled: true,
41+
web: {},
42+
},
43+
};
22444

22545
startRecording = async (recordingOptions: RecordingOptions, onRecordingStatusUpdate) => {
22646
try {
@@ -242,28 +62,10 @@ class _Audio {
24262
if (!permissionsGranted) {
24363
throw new Error('Missing audio recording permission.');
24464
}
245-
await AudioComponent.setAudioModeAsync({
246-
allowsRecordingIOS: true,
247-
playsInSilentModeIOS: true,
248-
});
249-
const androidOptions = {
250-
audioEncoder: AndroidAudioEncoder.AAC,
251-
extension: '.aac',
252-
outputFormat: AndroidOutputFormat.AAC_ADTS,
253-
};
254-
const iosOptions = {
255-
audioQuality: IOSAudioQuality.HIGH,
256-
bitRate: 128000,
257-
extension: '.aac',
258-
numberOfChannels: 2,
259-
outputFormat: IOSOutputFormat.MPEG4AAC,
260-
sampleRate: 44100,
261-
};
65+
await AudioComponent.setAudioModeAsync(this.audioRecordingConfiguration.mode);
26266
const options = {
26367
...recordingOptions,
264-
android: androidOptions,
265-
ios: iosOptions,
266-
web: {},
68+
...this.audioRecordingConfiguration.options,
26769
};
26870

26971
// This is a band-aid fix for this (still unresolved) issue on Expo's side:
@@ -303,4 +105,8 @@ class _Audio {
303105
};
304106
}
305107

108+
export const overrideAudioRecordingConfiguration = (
109+
audioRecordingConfiguration: AudioRecordingConfiguration,
110+
) => audioRecordingConfiguration;
111+
306112
export const Audio = AudioComponent ? new _Audio() : null;

package/native-package/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
getPhotos,
1313
iOS14RefreshGallerySelection,
1414
oniOS14GalleryLibrarySelectionChange,
15+
overrideAudioRecordingConfiguration,
1516
pickDocument,
1617
pickImage,
1718
saveFile,
@@ -32,6 +33,7 @@ registerNativeHandlers({
3233
getPhotos,
3334
iOS14RefreshGallerySelection,
3435
oniOS14GalleryLibrarySelectionChange,
36+
overrideAudioRecordingConfiguration,
3537
pickDocument,
3638
pickImage,
3739
saveFile,

0 commit comments

Comments
 (0)