@cloudfort/callum-voice 0.0.3
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/README.md +672 -0
- package/android/build.gradle +38 -0
- package/android/src/main/AndroidManifest.xml +9 -0
- package/android/src/main/java/com/callumvoice/CallumVoiceModule.kt +289 -0
- package/android/src/main/java/com/callumvoice/CallumVoicePackage.kt +32 -0
- package/callum-voice.podspec +21 -0
- package/ios/CallumVoiceBridge.m +7 -0
- package/ios/CallumVoiceModule-Bridging-Header.h +7 -0
- package/ios/CallumVoiceModule.swift +198 -0
- package/lib/VoiceClient.d.ts +104 -0
- package/lib/VoiceClient.d.ts.map +1 -0
- package/lib/VoiceClient.js +493 -0
- package/lib/VoiceClient.js.map +1 -0
- package/lib/VoiceClientState.d.ts +16 -0
- package/lib/VoiceClientState.d.ts.map +1 -0
- package/lib/VoiceClientState.js +21 -0
- package/lib/VoiceClientState.js.map +1 -0
- package/lib/VoiceConfig.d.ts +32 -0
- package/lib/VoiceConfig.d.ts.map +1 -0
- package/lib/VoiceConfig.js +11 -0
- package/lib/VoiceConfig.js.map +1 -0
- package/lib/VoiceEventListener.d.ts +49 -0
- package/lib/VoiceEventListener.d.ts.map +1 -0
- package/lib/VoiceEventListener.js +4 -0
- package/lib/VoiceEventListener.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/package.json +48 -0
- package/src/VoiceClient.ts +568 -0
- package/src/VoiceClientState.ts +21 -0
- package/src/VoiceConfig.ts +58 -0
- package/src/VoiceEventListener.ts +66 -0
- package/src/index.ts +6 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Copyright Cloudfort. All Rights Reserved.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for connecting to the voice chat service.
|
|
5
|
+
*/
|
|
6
|
+
export interface VoiceConfig {
|
|
7
|
+
/** Server address (e.g. "callem.cloudfort.ir"). Do NOT include scheme or port. */
|
|
8
|
+
server: string;
|
|
9
|
+
|
|
10
|
+
/** API key obtained from account registration (vc_live_...) */
|
|
11
|
+
apiKey: string;
|
|
12
|
+
|
|
13
|
+
/** Unique identifier for this peer / user */
|
|
14
|
+
peerId: string;
|
|
15
|
+
|
|
16
|
+
/** Use WSS (TLS) instead of WS. Auto-detected when undefined. */
|
|
17
|
+
useTls?: boolean;
|
|
18
|
+
|
|
19
|
+
/** Audio sample rate in Hz (default 48000) */
|
|
20
|
+
sampleRate: number;
|
|
21
|
+
|
|
22
|
+
/** Automatically reconnect on unexpected disconnect (default true) */
|
|
23
|
+
autoReconnect: boolean;
|
|
24
|
+
|
|
25
|
+
/** Maximum reconnection attempts before giving up (default 5) */
|
|
26
|
+
maxReconnectAttempts: number;
|
|
27
|
+
|
|
28
|
+
/** Delay between reconnection attempts in milliseconds (default 2000) */
|
|
29
|
+
reconnectDelayMs: number;
|
|
30
|
+
|
|
31
|
+
/** Enable platform echo cancellation (default true) */
|
|
32
|
+
echoCancellation: boolean;
|
|
33
|
+
|
|
34
|
+
/** Enable platform noise suppression (default true) */
|
|
35
|
+
noiseSuppression: boolean;
|
|
36
|
+
|
|
37
|
+
/** Enable platform automatic gain control (default true) */
|
|
38
|
+
autoGainControl: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Create a VoiceConfig with sensible defaults.
|
|
43
|
+
*/
|
|
44
|
+
export function createVoiceConfig(overrides: Partial<VoiceConfig>): VoiceConfig {
|
|
45
|
+
return {
|
|
46
|
+
server: '',
|
|
47
|
+
apiKey: '',
|
|
48
|
+
peerId: '',
|
|
49
|
+
sampleRate: 48000,
|
|
50
|
+
autoReconnect: true,
|
|
51
|
+
maxReconnectAttempts: 5,
|
|
52
|
+
reconnectDelayMs: 2000,
|
|
53
|
+
echoCancellation: true,
|
|
54
|
+
noiseSuppression: true,
|
|
55
|
+
autoGainControl: true,
|
|
56
|
+
...overrides,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright Cloudfort. All Rights Reserved.
|
|
2
|
+
|
|
3
|
+
import { VoiceClientState } from './VoiceClientState';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Callback interface for receiving voice client events.
|
|
7
|
+
*
|
|
8
|
+
* Implement only the methods you need — all methods have no-op defaults.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const listener: VoiceEventListener = {
|
|
13
|
+
* onConnected: () => console.log('Connected!'),
|
|
14
|
+
* onPeerSpeaking: (peerId) => console.log(`${peerId} speaking`),
|
|
15
|
+
* };
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export interface VoiceEventListener {
|
|
19
|
+
/** Connection established */
|
|
20
|
+
onConnected?(): void;
|
|
21
|
+
|
|
22
|
+
/** Connection lost */
|
|
23
|
+
onDisconnected?(): void;
|
|
24
|
+
|
|
25
|
+
/** Reconnection attempt in progress */
|
|
26
|
+
onReconnecting?(attempt: number): void;
|
|
27
|
+
|
|
28
|
+
/** Authentication failed */
|
|
29
|
+
onAuthFailed?(reason: string): void;
|
|
30
|
+
|
|
31
|
+
/** Joined a room */
|
|
32
|
+
onRoomJoined?(roomId: string): void;
|
|
33
|
+
|
|
34
|
+
/** Left a room */
|
|
35
|
+
onRoomLeft?(roomId: string): void;
|
|
36
|
+
|
|
37
|
+
/** New peer joined the room */
|
|
38
|
+
onPeerJoined?(peerId: string): void;
|
|
39
|
+
|
|
40
|
+
/** Peer left the room */
|
|
41
|
+
onPeerLeft?(peerId: string): void;
|
|
42
|
+
|
|
43
|
+
/** Peer started speaking */
|
|
44
|
+
onPeerSpeaking?(peerId: string): void;
|
|
45
|
+
|
|
46
|
+
/** Peer stopped speaking */
|
|
47
|
+
onPeerStopped?(peerId: string): void;
|
|
48
|
+
|
|
49
|
+
/** Microphone enabled */
|
|
50
|
+
onMicEnabled?(): void;
|
|
51
|
+
|
|
52
|
+
/** Microphone disabled */
|
|
53
|
+
onMicDisabled?(): void;
|
|
54
|
+
|
|
55
|
+
/** Speaker enabled */
|
|
56
|
+
onSpeakerEnabled?(): void;
|
|
57
|
+
|
|
58
|
+
/** Speaker disabled */
|
|
59
|
+
onSpeakerDisabled?(): void;
|
|
60
|
+
|
|
61
|
+
/** Error occurred */
|
|
62
|
+
onError?(error: Error): void;
|
|
63
|
+
|
|
64
|
+
/** Connection state changed */
|
|
65
|
+
onStateChanged?(newState: VoiceClientState): void;
|
|
66
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Copyright Cloudfort. All Rights Reserved.
|
|
2
|
+
|
|
3
|
+
export { VoiceClientState } from './VoiceClientState';
|
|
4
|
+
export { VoiceConfig, createVoiceConfig } from './VoiceConfig';
|
|
5
|
+
export { VoiceEventListener } from './VoiceEventListener';
|
|
6
|
+
export { VoiceClient } from './VoiceClient';
|