@cometchat/calls-sdk-react-native 4.4.2-beta.1 → 5.0.0-beta.2
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 +85 -19
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +13 -12
- package/android/src/main/AndroidManifest.xml +15 -6
- package/android/src/main/java/com/callingv5/AudioDeviceHandlerConnectionService.java +185 -0
- package/android/src/main/java/com/callingv5/AudioDeviceHandlerGeneric.java +254 -0
- package/android/src/main/java/com/{CometChatCalls → callingv5}/AudioModeModule.java +93 -56
- package/android/src/main/java/com/callingv5/ConnectionService.java +451 -0
- package/android/src/main/java/com/callingv5/KeepAwakeModule.java +53 -0
- package/android/src/main/java/com/callingv5/MyAppPackage.java +35 -0
- package/android/src/main/java/com/callingv5/RNConnectionService.java +244 -0
- package/android/src/main/java/com/callingv5/ToastModule.java +29 -0
- package/android/src/main/java/com/callingv5/utils/CometChatLogger.java +88 -0
- package/cometchat-calls-sdk-react-native.podspec +9 -10
- package/dist/index.d.mts +4066 -0
- package/dist/index.d.ts +4066 -9
- package/dist/index.js +11116 -132
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +11085 -0
- package/dist/index.mjs.map +1 -0
- package/dist/polyfills/RTCPeerConnection.js +19 -0
- package/dist/polyfills/Storage.js +192 -0
- package/dist/polyfills/browser.js +337 -0
- package/dist/polyfills/index.js +1 -0
- package/dist/polyfills/ipv6utils.js +197 -0
- package/dist/polyfills/webrtc.js +11 -0
- package/ios/{JitsiAudioSession+Private.h → Audio/CometChatAudioSession+Private.h} +2 -3
- package/ios/{LogUtils.h → Audio/CometChatAudioSession.h} +9 -6
- package/ios/{JitsiAudioSession.m → Audio/CometChatAudioSession.m} +4 -3
- package/ios/{AudioMode.m → Modules/AudioMode.m} +15 -49
- package/ios/Modules/KeepAwake.h +4 -0
- package/ios/Modules/KeepAwake.m +29 -0
- package/package.json +24 -110
- package/LICENSE.md +0 -3
- package/android/src/main/java/com/CometChatCalls/AudioDeviceHandlerGeneric.java +0 -213
- package/android/src/main/java/com/CometChatCalls/AudioDeviceHandlerLegacy.java +0 -213
- package/android/src/main/java/com/CometChatCalls/BluetoothHeadsetMonitor.java +0 -187
- package/android/src/main/java/com/CometChatCalls/CallNotificationService.java +0 -93
- package/android/src/main/java/com/CometChatCalls/CallNotificationServiceModule.java +0 -48
- package/android/src/main/java/com/CometChatCalls/CometChatCallsPackage.java +0 -56
- package/android/src/main/java/com/CometChatCalls/CometChatCommonModule.java +0 -48
- package/android/src/main/java/com/CometChatCalls/PictureInPictureModule.java +0 -133
- package/android/src/main/res/drawable-mdpi/callingcomponent_icons_headphones_pluged.png +0 -0
- package/dist/CometChatErrorConstants.d.ts +0 -124
- package/dist/Constants.d.ts +0 -724
- package/dist/Helper copy.d.ts +0 -1
- package/dist/Helper.d.ts +0 -7
- package/dist/api/APIHandler.d.ts +0 -42
- package/dist/api/endpoints.d.ts +0 -7
- package/dist/api/helper.d.ts +0 -69
- package/dist/api/index.d.ts +0 -2
- package/dist/constants/CallConstants.d.ts +0 -136
- package/dist/constants/index.d.ts +0 -1
- package/dist/defaultCallsettings.d.ts +0 -2
- package/dist/models/CallAppSettings.d.ts +0 -42
- package/dist/models/CallGroup.d.ts +0 -14
- package/dist/models/CallLog.d.ts +0 -276
- package/dist/models/CallLogFilterParams.d.ts +0 -97
- package/dist/models/CallSettings.d.ts +0 -330
- package/dist/models/CallUser.d.ts +0 -14
- package/dist/models/CometChatCallLogs.d.ts +0 -193
- package/dist/models/CometChatCalls.d.ts +0 -110
- package/dist/models/CometChatCallsComponent.d.ts +0 -13
- package/dist/models/CometChatCallsComponentCore.d.ts +0 -18
- package/dist/models/CometChatCallsException.d.ts +0 -7
- package/dist/models/CometChatPresenterComponent.d.ts +0 -13
- package/dist/models/ErrorModel.d.ts +0 -11
- package/dist/models/Listner.d.ts +0 -69
- package/dist/models/ListnerHandler.d.ts +0 -10
- package/dist/models/MessageComponent.d.ts +0 -7
- package/dist/models/Participant.d.ts +0 -184
- package/dist/models/PresenterSettings.d.ts +0 -208
- package/dist/models/RTCUser.d.ts +0 -18
- package/dist/models/Recording.d.ts +0 -86
- package/dist/models/index.d.ts +0 -9
- package/dist/types/ICallAppSettings.d.ts +0 -6
- package/dist/types/ICallSettings.d.ts +0 -61
- package/dist/types/RTCUser.d.ts +0 -6
- package/dist/types/callEvents.d.ts +0 -54
- package/dist/types/common.d.ts +0 -18
- package/dist/types/index.d.ts +0 -2
- package/ios/AudioMode.h +0 -11
- package/ios/CometChatCommonModule.h +0 -6
- package/ios/CometChatCommonModule.m +0 -29
- package/ios/JitsiAudioSession.h +0 -17
- package/ios/react-native-calls2.xcodeproj/project.pbxproj +0 -269
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
import { RTCSessionDescription } from 'react-native-webrtc';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Synthesizes IPv6 addresses on iOS in order to support IPv6 NAT64 networks.
|
|
6
|
+
*
|
|
7
|
+
* @param {RTCSessionDescription} sdp - The RTCSessionDescription which
|
|
8
|
+
* specifies the configuration of the remote end of the connection.
|
|
9
|
+
* @private
|
|
10
|
+
* @returns {Promise}
|
|
11
|
+
*/
|
|
12
|
+
export function synthesizeIPv6Addresses(sdp) {
|
|
13
|
+
return (
|
|
14
|
+
new Promise(resolve => resolve(_synthesizeIPv6Addresses0(sdp)))
|
|
15
|
+
.then(({ ips, lines }) =>
|
|
16
|
+
Promise.all(Array.from(ips.values()))
|
|
17
|
+
.then(() => _synthesizeIPv6Addresses1(sdp, ips, lines))
|
|
18
|
+
));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* eslint-disable max-depth */
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Synthesizes an IPv6 address from a specific IPv4 address.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} ipv4 - The IPv4 address from which an IPv6 address is to be
|
|
27
|
+
* synthesized.
|
|
28
|
+
* @returns {Promise<?string>} A {@code Promise} which gets resolved with the
|
|
29
|
+
* IPv6 address synthesized from the specified {@code ipv4} or a falsy value to
|
|
30
|
+
* be treated as inability to synthesize an IPv6 address from the specified
|
|
31
|
+
* {@code ipv4}.
|
|
32
|
+
*/
|
|
33
|
+
const _synthesizeIPv6FromIPv4Address = (function() {
|
|
34
|
+
// POSIX.getaddrinfo
|
|
35
|
+
const { POSIX } = NativeModules;
|
|
36
|
+
|
|
37
|
+
if (POSIX) {
|
|
38
|
+
const { getaddrinfo } = POSIX;
|
|
39
|
+
|
|
40
|
+
if (typeof getaddrinfo === 'function') {
|
|
41
|
+
return ipv4 =>
|
|
42
|
+
getaddrinfo(/* hostname */ ipv4, /* servname */ undefined)
|
|
43
|
+
.then(([ { ai_addr: ipv6 } ]) => ipv6);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// NAT64AddrInfo.getIPv6Address
|
|
48
|
+
const { NAT64AddrInfo } = NativeModules;
|
|
49
|
+
|
|
50
|
+
if (NAT64AddrInfo) {
|
|
51
|
+
const { getIPv6Address } = NAT64AddrInfo;
|
|
52
|
+
|
|
53
|
+
if (typeof getIPv6Address === 'function') {
|
|
54
|
+
return getIPv6Address;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// There's no POSIX.getaddrinfo or NAT64AddrInfo.getIPv6Address.
|
|
59
|
+
return ip => Promise.resolve(ip);
|
|
60
|
+
})();
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Begins the asynchronous synthesis of IPv6 addresses.
|
|
64
|
+
*
|
|
65
|
+
* @param {RTCSessionDescription} sessionDescription - The RTCSessionDescription
|
|
66
|
+
* for which IPv6 addresses will be synthesized.
|
|
67
|
+
* @private
|
|
68
|
+
* @returns {{
|
|
69
|
+
* ips: Map,
|
|
70
|
+
* lines: Array
|
|
71
|
+
* }}
|
|
72
|
+
*/
|
|
73
|
+
function _synthesizeIPv6Addresses0(sessionDescription) {
|
|
74
|
+
const sdp = sessionDescription.sdp;
|
|
75
|
+
let start = 0;
|
|
76
|
+
const lines = [];
|
|
77
|
+
const ips = new Map();
|
|
78
|
+
|
|
79
|
+
do {
|
|
80
|
+
const end = sdp.indexOf('\r\n', start);
|
|
81
|
+
let line;
|
|
82
|
+
|
|
83
|
+
if (end === -1) {
|
|
84
|
+
line = sdp.substring(start);
|
|
85
|
+
|
|
86
|
+
// Break out of the loop at the end of the iteration.
|
|
87
|
+
start = undefined;
|
|
88
|
+
} else {
|
|
89
|
+
line = sdp.substring(start, end);
|
|
90
|
+
start = end + 2;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (line.startsWith('a=candidate:')) {
|
|
94
|
+
const candidate = line.split(' ');
|
|
95
|
+
|
|
96
|
+
if (candidate.length >= 10 && candidate[6] === 'typ') {
|
|
97
|
+
const ip4s = [ candidate[4] ];
|
|
98
|
+
let abort = false;
|
|
99
|
+
|
|
100
|
+
for (let i = 8; i < candidate.length; ++i) {
|
|
101
|
+
if (candidate[i] === 'raddr') {
|
|
102
|
+
ip4s.push(candidate[++i]);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
for (const ip of ip4s) {
|
|
108
|
+
if (ip.indexOf(':') === -1) {
|
|
109
|
+
ips.has(ip)
|
|
110
|
+
|| ips.set(ip, new Promise((resolve, reject) => {
|
|
111
|
+
const v = ips.get(ip);
|
|
112
|
+
|
|
113
|
+
if (v && typeof v === 'string') {
|
|
114
|
+
resolve(v);
|
|
115
|
+
} else {
|
|
116
|
+
_synthesizeIPv6FromIPv4Address(ip).then(
|
|
117
|
+
value => {
|
|
118
|
+
if (!value
|
|
119
|
+
|| value.indexOf(':') === -1
|
|
120
|
+
|| value === ips.get(ip)) {
|
|
121
|
+
ips.delete(ip);
|
|
122
|
+
} else {
|
|
123
|
+
ips.set(ip, value);
|
|
124
|
+
}
|
|
125
|
+
resolve(value);
|
|
126
|
+
},
|
|
127
|
+
reject);
|
|
128
|
+
}
|
|
129
|
+
}));
|
|
130
|
+
} else {
|
|
131
|
+
abort = true;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (abort) {
|
|
136
|
+
ips.clear();
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
line = candidate;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
lines.push(line);
|
|
145
|
+
} while (start);
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
ips,
|
|
149
|
+
lines
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* eslint-enable max-depth */
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Completes the asynchronous synthesis of IPv6 addresses.
|
|
157
|
+
*
|
|
158
|
+
* @param {RTCSessionDescription} sessionDescription - The RTCSessionDescription
|
|
159
|
+
* for which IPv6 addresses are being synthesized.
|
|
160
|
+
* @param {Map} ips - A Map of IPv4 addresses found in the specified
|
|
161
|
+
* sessionDescription to synthesized IPv6 addresses.
|
|
162
|
+
* @param {Array} lines - The lines of the specified sessionDescription.
|
|
163
|
+
* @private
|
|
164
|
+
* @returns {RTCSessionDescription} A RTCSessionDescription that represents the
|
|
165
|
+
* result of the synthesis of IPv6 addresses.
|
|
166
|
+
*/
|
|
167
|
+
function _synthesizeIPv6Addresses1(sessionDescription, ips, lines) {
|
|
168
|
+
if (ips.size === 0) {
|
|
169
|
+
return sessionDescription;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
for (let l = 0; l < lines.length; ++l) {
|
|
173
|
+
const candidate = lines[l];
|
|
174
|
+
|
|
175
|
+
if (typeof candidate !== 'string') {
|
|
176
|
+
let ip4 = candidate[4];
|
|
177
|
+
let ip6 = ips.get(ip4);
|
|
178
|
+
|
|
179
|
+
ip6 && (candidate[4] = ip6);
|
|
180
|
+
|
|
181
|
+
for (let i = 8; i < candidate.length; ++i) {
|
|
182
|
+
if (candidate[i] === 'raddr') {
|
|
183
|
+
ip4 = candidate[++i];
|
|
184
|
+
(ip6 = ips.get(ip4)) && (candidate[i] = ip6);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
lines[l] = candidate.join(' ');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return new RTCSessionDescription({
|
|
194
|
+
sdp: lines.join('\r\n'),
|
|
195
|
+
type: sessionDescription.type
|
|
196
|
+
});
|
|
197
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { registerGlobals } from 'react-native-webrtc';
|
|
2
|
+
|
|
3
|
+
import RTCPeerConnection from './RTCPeerConnection';
|
|
4
|
+
|
|
5
|
+
registerGlobals();
|
|
6
|
+
|
|
7
|
+
(global => {
|
|
8
|
+
// Override with ours.
|
|
9
|
+
// TODO: consider dropping our override.
|
|
10
|
+
global.RTCPeerConnection = RTCPeerConnection;
|
|
11
|
+
})(global || window || this); // eslint-disable-line no-invalid-this
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
/*
|
|
3
2
|
* Copyright @ 2017-present 8x8, Inc.
|
|
4
3
|
*
|
|
@@ -15,10 +14,10 @@
|
|
|
15
14
|
* limitations under the License.
|
|
16
15
|
*/
|
|
17
16
|
|
|
18
|
-
#import "
|
|
17
|
+
#import "CometChatAudioSession.h"
|
|
19
18
|
#import <WebRTC/WebRTC.h>
|
|
20
19
|
|
|
21
|
-
@interface
|
|
20
|
+
@interface CometChatAudioSession (Private)
|
|
22
21
|
|
|
23
22
|
+ (RTCAudioSession *)rtcAudioSession;
|
|
24
23
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright @
|
|
2
|
+
* Copyright @ 2017-present 8x8, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -14,10 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
#
|
|
18
|
-
#define JM_LOG_UTILS_H
|
|
17
|
+
#import <Foundation/Foundation.h>
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
static const DDLogLevel ddLogLevel = DDLogLevelVerbose;
|
|
19
|
+
@class AVAudioSession;
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
@interface CometChatAudioSession : NSObject
|
|
22
|
+
|
|
23
|
+
+ (void)activateWithAudioSession:(AVAudioSession *)session;
|
|
24
|
+
+ (void)deactivateWithAudioSession:(AVAudioSession *)session;
|
|
25
|
+
|
|
26
|
+
@end
|
|
@@ -14,10 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
#import "
|
|
18
|
-
#import "
|
|
17
|
+
#import "CometChatAudioSession.h"
|
|
18
|
+
#import "CometChatAudioSession+Private.h"
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
@implementation CometChatAudioSession
|
|
21
22
|
|
|
22
23
|
+ (RTCAudioSession *)rtcAudioSession {
|
|
23
24
|
return [RTCAudioSession sharedInstance];
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
#import <React/RCTLog.h>
|
|
21
21
|
#import <WebRTC/WebRTC.h>
|
|
22
22
|
|
|
23
|
-
#import "
|
|
23
|
+
#import "CometChatAudioSession+Private.h"
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
// Audio mode
|
|
@@ -32,7 +32,6 @@ typedef enum {
|
|
|
32
32
|
|
|
33
33
|
// Events
|
|
34
34
|
static NSString * const kDevicesChanged = @"org.jitsi.meet:features/audio-mode#devices-update";
|
|
35
|
-
static NSString * const kDevicesChangedCustom = @"org.jitsi.meet:features/audio-mode#devices-update-custom";
|
|
36
35
|
|
|
37
36
|
// Device types (must match JS and Java)
|
|
38
37
|
static NSString * const kDeviceTypeBluetooth = @"BLUETOOTH";
|
|
@@ -68,13 +67,12 @@ RCT_EXPORT_MODULE();
|
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
- (NSArray<NSString *> *)supportedEvents {
|
|
71
|
-
return @[ kDevicesChanged
|
|
70
|
+
return @[ kDevicesChanged ];
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
- (NSDictionary *)constantsToExport {
|
|
75
74
|
return @{
|
|
76
75
|
@"DEVICE_CHANGE_EVENT": kDevicesChanged,
|
|
77
|
-
@"DEVICE_CHANGE_EVENT_CUSTOM": kDevicesChangedCustom,
|
|
78
76
|
@"AUDIO_CALL" : [NSNumber numberWithInt: kAudioModeAudioCall],
|
|
79
77
|
@"DEFAULT" : [NSNumber numberWithInt: kAudioModeDefault],
|
|
80
78
|
@"VIDEO_CALL" : [NSNumber numberWithInt: kAudioModeVideoCall]
|
|
@@ -116,7 +114,7 @@ RCT_EXPORT_MODULE();
|
|
|
116
114
|
isSpeakerOn = NO;
|
|
117
115
|
isEarpieceOn = NO;
|
|
118
116
|
|
|
119
|
-
RTCAudioSession *session =
|
|
117
|
+
RTCAudioSession *session = CometChatAudioSession.rtcAudioSession;
|
|
120
118
|
[session addDelegate:self];
|
|
121
119
|
}
|
|
122
120
|
|
|
@@ -130,7 +128,7 @@ RCT_EXPORT_MODULE();
|
|
|
130
128
|
|
|
131
129
|
- (BOOL)setConfigWithoutLock:(RTCAudioSessionConfiguration *)config
|
|
132
130
|
error:(NSError * _Nullable *)outError {
|
|
133
|
-
RTCAudioSession *session =
|
|
131
|
+
RTCAudioSession *session = CometChatAudioSession.rtcAudioSession;
|
|
134
132
|
|
|
135
133
|
return [session setConfiguration:config error:outError];
|
|
136
134
|
}
|
|
@@ -138,7 +136,7 @@ RCT_EXPORT_MODULE();
|
|
|
138
136
|
- (BOOL)setConfig:(RTCAudioSessionConfiguration *)config
|
|
139
137
|
error:(NSError * _Nullable *)outError {
|
|
140
138
|
|
|
141
|
-
RTCAudioSession *session =
|
|
139
|
+
RTCAudioSession *session = CometChatAudioSession.rtcAudioSession;
|
|
142
140
|
[session lockForConfiguration];
|
|
143
141
|
BOOL success = [self setConfigWithoutLock:config error:outError];
|
|
144
142
|
[session unlockForConfiguration];
|
|
@@ -179,9 +177,9 @@ RCT_EXPORT_METHOD(setMode:(int)mode
|
|
|
179
177
|
RCT_EXPORT_METHOD(setAudioDevice:(NSString *)device
|
|
180
178
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
181
179
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
182
|
-
|
|
180
|
+
RCTLogInfo(@"[AudioMode] Selected device: %@", device);
|
|
183
181
|
|
|
184
|
-
RTCAudioSession *session =
|
|
182
|
+
RTCAudioSession *session = CometChatAudioSession.rtcAudioSession;
|
|
185
183
|
[session lockForConfiguration];
|
|
186
184
|
BOOL success;
|
|
187
185
|
NSError *error = nil;
|
|
@@ -201,7 +199,7 @@ RCT_EXPORT_METHOD(setAudioDevice:(NSString *)device
|
|
|
201
199
|
|
|
202
200
|
// Find the matching input device.
|
|
203
201
|
for (AVAudioSessionPortDescription *portDesc in _session.availableInputs) {
|
|
204
|
-
if ([portDesc.UID isEqualToString:device]
|
|
202
|
+
if ([portDesc.UID isEqualToString:device]) {
|
|
205
203
|
port = portDesc;
|
|
206
204
|
break;
|
|
207
205
|
}
|
|
@@ -234,7 +232,6 @@ RCT_EXPORT_METHOD(setAudioDevice:(NSString *)device
|
|
|
234
232
|
[session unlockForConfiguration];
|
|
235
233
|
|
|
236
234
|
if (success) {
|
|
237
|
-
[self sendEventWithName:kDevicesChangedCustom body:device];
|
|
238
235
|
resolve(nil);
|
|
239
236
|
} else {
|
|
240
237
|
reject(@"setAudioDevice", error != nil ? error.localizedDescription : @"", error);
|
|
@@ -245,30 +242,13 @@ RCT_EXPORT_METHOD(updateDeviceList) {
|
|
|
245
242
|
[self notifyDevicesChanged];
|
|
246
243
|
}
|
|
247
244
|
|
|
248
|
-
RCT_EXPORT_METHOD(releaseAudioSession)
|
|
249
|
-
{
|
|
250
|
-
RTCAudioSession *session = [RTCAudioSession sharedInstance];
|
|
251
|
-
[session lockForConfiguration];
|
|
252
|
-
NSError *error = nil;
|
|
253
|
-
[session setActive:NO error:&error];
|
|
254
|
-
[session unlockForConfiguration];
|
|
255
|
-
|
|
256
|
-
if (error) {
|
|
257
|
-
NSLog(@"Failed to release audio session: %@", error.localizedDescription);
|
|
258
|
-
} else {
|
|
259
|
-
NSLog(@"Audio session released successfully");
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
RCT_EXPORT_METHOD(removeListener) {
|
|
264
|
-
RTCAudioSession *session = [RTCAudioSession sharedInstance];
|
|
265
|
-
[session removeDelegate:self];
|
|
266
|
-
}
|
|
267
245
|
#pragma mark - RTCAudioSessionDelegate
|
|
268
246
|
|
|
269
247
|
- (void)audioSessionDidChangeRoute:(RTCAudioSession *)session
|
|
270
248
|
reason:(AVAudioSessionRouteChangeReason)reason
|
|
271
249
|
previousRoute:(AVAudioSessionRouteDescription *)previousRoute {
|
|
250
|
+
RCTLogInfo(@"[AudioMode] Route changed, reason: %lu", (unsigned long)reason);
|
|
251
|
+
|
|
272
252
|
// Update JS about the changes.
|
|
273
253
|
[self notifyDevicesChanged];
|
|
274
254
|
|
|
@@ -280,25 +260,16 @@ RCT_EXPORT_METHOD(removeListener) {
|
|
|
280
260
|
self->forceSpeaker = NO;
|
|
281
261
|
self->forceEarpiece = NO;
|
|
282
262
|
break;
|
|
283
|
-
case AVAudioSessionRouteChangeReasonCategoryChange:
|
|
284
|
-
// The category has changed
|
|
285
|
-
// needed.
|
|
286
|
-
RTCAudioSessionConfiguration *currentConfig = [self configForMode:self->activeMode];
|
|
287
|
-
if ([session.category isEqualToString:currentConfig.category]) {
|
|
288
|
-
// We are in the desired category, nothing to do here.
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
263
|
+
case AVAudioSessionRouteChangeReasonCategoryChange:
|
|
264
|
+
// The category has changed, re-apply our config.
|
|
291
265
|
break;
|
|
292
|
-
}
|
|
293
266
|
default:
|
|
294
267
|
return;
|
|
295
268
|
}
|
|
296
269
|
|
|
297
270
|
// We don't want to touch the category when in default mode.
|
|
298
|
-
// This is to play well with other components which could be integrated
|
|
299
|
-
// into the final application.
|
|
300
271
|
if (self->activeMode != kAudioModeDefault) {
|
|
301
|
-
|
|
272
|
+
RCTLogInfo(@"[AudioMode] Route changed, reapplying RTCAudioSession config");
|
|
302
273
|
RTCAudioSessionConfiguration *config = [self configForMode:self->activeMode];
|
|
303
274
|
[self setConfig:config error:nil];
|
|
304
275
|
if (self->forceSpeaker && !self->isSpeakerOn) {
|
|
@@ -311,7 +282,7 @@ RCT_EXPORT_METHOD(removeListener) {
|
|
|
311
282
|
}
|
|
312
283
|
|
|
313
284
|
- (void)audioSession:(RTCAudioSession *)audioSession didSetActive:(BOOL)active {
|
|
314
|
-
|
|
285
|
+
RCTLogInfo(@"[AudioMode] Audio session didSetActive:%d", active);
|
|
315
286
|
}
|
|
316
287
|
|
|
317
288
|
#pragma mark - Helper methods
|
|
@@ -355,17 +326,12 @@ RCT_EXPORT_METHOD(removeListener) {
|
|
|
355
326
|
}
|
|
356
327
|
|
|
357
328
|
- (void)notifyDevicesChanged {
|
|
358
|
-
NSLog(@"notifyDevicesChanged");
|
|
359
329
|
dispatch_async(_workerQueue, ^{
|
|
360
330
|
NSMutableArray *data = [[NSMutableArray alloc] init];
|
|
361
|
-
// Here we use AVAudioSession because RTCAudioSession doesn't expose availableInputs.
|
|
362
331
|
AVAudioSession *session = [AVAudioSession sharedInstance];
|
|
363
332
|
NSString *currentPort = @"";
|
|
364
333
|
AVAudioSessionRouteDescription *currentRoute = session.currentRoute;
|
|
365
334
|
|
|
366
|
-
// Check what the current device is. Because the speaker is somewhat special, we need to
|
|
367
|
-
// check for it first.
|
|
368
|
-
NSLog(@"notifyDevicesChanged %@", currentRoute);
|
|
369
335
|
if (currentRoute != nil) {
|
|
370
336
|
AVAudioSessionPortDescription *output = currentRoute.outputs.firstObject;
|
|
371
337
|
AVAudioSessionPortDescription *input = currentRoute.inputs.firstObject;
|
|
@@ -410,7 +376,7 @@ RCT_EXPORT_METHOD(removeListener) {
|
|
|
410
376
|
@"uid": kDeviceTypeSpeaker,
|
|
411
377
|
@"selected": [NSNumber numberWithBool:[kDeviceTypeSpeaker isEqualToString:currentPort]]
|
|
412
378
|
}];
|
|
413
|
-
|
|
379
|
+
|
|
414
380
|
[self sendEventWithName:kDevicesChanged body:data];
|
|
415
381
|
});
|
|
416
382
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#import "KeepAwake.h"
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
|
|
4
|
+
#import <React/RCTBridgeModule.h>
|
|
5
|
+
#import <React/RCTLog.h>
|
|
6
|
+
|
|
7
|
+
@implementation KeepAwakeModule
|
|
8
|
+
|
|
9
|
+
RCT_EXPORT_MODULE();
|
|
10
|
+
|
|
11
|
+
- (dispatch_queue_t)methodQueue {
|
|
12
|
+
return dispatch_get_main_queue();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
RCT_EXPORT_METHOD(activateKeepAwake) {
|
|
16
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
17
|
+
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
|
|
18
|
+
RCTLogInfo(@"Keep awake activated");
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
RCT_EXPORT_METHOD(deactivateKeepAwake) {
|
|
23
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
24
|
+
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
|
|
25
|
+
RCTLogInfo(@"Keep awake deactivated");
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@end
|
package/package.json
CHANGED
|
@@ -1,120 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cometchat/calls-sdk-react-native",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "5.0.0-beta.2",
|
|
4
|
+
"description": "CometChat Calls SDK for React Native provides voice and video calling capabilities for React Native applications.",
|
|
5
|
+
"private": false,
|
|
5
6
|
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.
|
|
7
|
-
"types": "dist/index.d.
|
|
8
|
-
"scripts": {
|
|
9
|
-
"start": "webpack --mode development",
|
|
10
|
-
"build": "webpack --mode production",
|
|
11
|
-
"test": "jest",
|
|
12
|
-
"typescript": "tsc --noEmit",
|
|
13
|
-
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
14
|
-
"release": "release-it",
|
|
15
|
-
"example": "yarn --cwd example",
|
|
16
|
-
"pods": "cd example && pod-install --quiet",
|
|
17
|
-
"bootstrap": "yarn example && yarn && yarn pods",
|
|
18
|
-
"buildold": "rm -rf package && tsc && cp src/calling.js package/calling.js"
|
|
19
|
-
},
|
|
7
|
+
"module": "dist/index.mjs",
|
|
8
|
+
"types": "dist/index.d.mts",
|
|
20
9
|
"files": [
|
|
21
|
-
"
|
|
22
|
-
"android
|
|
23
|
-
"dist/",
|
|
24
|
-
"ios/",
|
|
25
|
-
"cometchat-calls-sdk-react-native.podspec"
|
|
26
|
-
],
|
|
27
|
-
"keywords": [
|
|
28
|
-
"react-native",
|
|
10
|
+
"dist",
|
|
11
|
+
"android",
|
|
29
12
|
"ios",
|
|
30
|
-
"
|
|
13
|
+
"cometchat-calls-sdk-react-native.podspec"
|
|
31
14
|
],
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"homepage": "https://www.cometchat.com/docs/sdk/react-native/calling-overview",
|
|
36
|
-
"publishConfig": {
|
|
37
|
-
"registry": "https://registry.npmjs.org/"
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@types/react": "^17.0.53",
|
|
41
|
-
"babel-loader": "^8.0.4",
|
|
42
|
-
"esbuild-loader": "^2.19.0",
|
|
43
|
-
"react": "^17.0.2",
|
|
44
|
-
"react-native": "^0.66.5",
|
|
45
|
-
"ts-loader": "^9.4.2",
|
|
46
|
-
"typescript": "^4.9.5",
|
|
47
|
-
"typescript-declaration-webpack-plugin": "^0.2.2",
|
|
48
|
-
"webpack": "^5.75.0",
|
|
49
|
-
"webpack-cli": "^5.0.1"
|
|
50
|
-
},
|
|
15
|
+
"scripts": {},
|
|
16
|
+
"dependencies": {},
|
|
17
|
+
"devDependencies": {},
|
|
51
18
|
"peerDependencies": {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"react-native-url-polyfill": "*"
|
|
60
|
-
},
|
|
61
|
-
"jest": {
|
|
62
|
-
"preset": "react-native",
|
|
63
|
-
"modulePathIgnorePatterns": [
|
|
64
|
-
"<rootDir>/example/node_modules",
|
|
65
|
-
"<rootDir>/lib/"
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
"commitlint": {
|
|
69
|
-
"extends": [
|
|
70
|
-
"@commitlint/config-conventional"
|
|
71
|
-
]
|
|
72
|
-
},
|
|
73
|
-
"release-it": {
|
|
74
|
-
"git": {
|
|
75
|
-
"commitMessage": "chore: release ${version}",
|
|
76
|
-
"tagName": "v${version}"
|
|
77
|
-
},
|
|
78
|
-
"npm": {
|
|
79
|
-
"publish": true
|
|
80
|
-
},
|
|
81
|
-
"github": {
|
|
82
|
-
"release": true
|
|
83
|
-
},
|
|
84
|
-
"plugins": {
|
|
85
|
-
"@release-it/conventional-changelog": {
|
|
86
|
-
"preset": "angular"
|
|
87
|
-
}
|
|
88
|
-
}
|
|
19
|
+
"@xmldom/xmldom": "^0.8.11",
|
|
20
|
+
"abab": "^2.0.6",
|
|
21
|
+
"clsx": "^2.1.1",
|
|
22
|
+
"promise.allsettled": "^1.0.7",
|
|
23
|
+
"text-encoding": "^0.7.0",
|
|
24
|
+
"valibot": "^1.2.0",
|
|
25
|
+
"lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1790.0.0+311766e3/lib-jitsi-meet.tgz"
|
|
89
26
|
},
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"extends": [
|
|
93
|
-
"@react-native-community",
|
|
94
|
-
"prettier"
|
|
95
|
-
],
|
|
96
|
-
"rules": {
|
|
97
|
-
"prettier/prettier": [
|
|
98
|
-
"error",
|
|
99
|
-
{
|
|
100
|
-
"quoteProps": "consistent",
|
|
101
|
-
"singleQuote": true,
|
|
102
|
-
"tabWidth": 2,
|
|
103
|
-
"trailingComma": "es5",
|
|
104
|
-
"useTabs": false
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
}
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
108
29
|
},
|
|
109
|
-
"
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
"prettier": {
|
|
114
|
-
"quoteProps": "consistent",
|
|
115
|
-
"singleQuote": true,
|
|
116
|
-
"tabWidth": 2,
|
|
117
|
-
"trailingComma": "es5",
|
|
118
|
-
"useTabs": false
|
|
119
|
-
}
|
|
30
|
+
"repository": "https://github.com/cometchat/calls-sdk-react-native",
|
|
31
|
+
"author": "Cometchat Team (https://cometchat.com)",
|
|
32
|
+
"license": "https://www.cometchat.com/legal-terms-of-service",
|
|
33
|
+
"homepage": "https://www.cometchat.com/docs/sdk/react-native/calling-overview"
|
|
120
34
|
}
|
package/LICENSE.md
DELETED