@ray-js/ray-ipc-utils 1.1.0-beta-10 → 1.1.0-beta-12
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/lib/index.d.ts +2 -2
- package/lib/kit/ipc/index.d.ts +2 -2
- package/lib/kit/ipc/index.js +2 -0
- package/lib/service/index.js +64 -54
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ declare const IpcUtils: {
|
|
|
19
19
|
getDpIdByCode: <T_12>(deviceId: string, dpCode: string) => Promise<import("./kit/interface").IRes<T_12>>;
|
|
20
20
|
goToMiniProgramByShortLink: <T_13>(url: string, position?: string) => Promise<import("./kit/interface").IRes<T_13>>;
|
|
21
21
|
getVideoBitrateKbps: <T_14>(deviceId: string, extendParam?: {}) => Promise<import("./kit/interface").IRes<T_14>>;
|
|
22
|
-
networkStatusDidChangedEvent: (callback: any) => void;
|
|
23
|
-
offNetworkStatusDidChangedEvent: (callback: any) => void;
|
|
22
|
+
networkStatusDidChangedEvent: (callback: (res: any) => void) => void;
|
|
23
|
+
offNetworkStatusDidChangedEvent: (callback: (res: any) => void) => void;
|
|
24
24
|
getMobileOrientation: <T_15>() => Promise<import("./kit/interface").IRes<T_15>>;
|
|
25
25
|
jumpToWebView: <T_16>(url: string) => Promise<import("./kit/interface").IRes<T_16>>;
|
|
26
26
|
setScreenOrientation: <T_17>(pageOrientation: string) => Promise<import("./kit/interface").IRes<T_17>>;
|
package/lib/kit/ipc/index.d.ts
CHANGED
|
@@ -55,8 +55,8 @@ export declare const goToMiniProgramByShortLink: <T>(url: string, position?: str
|
|
|
55
55
|
* @returns
|
|
56
56
|
*/
|
|
57
57
|
export declare const getVideoBitrateKbps: <T>(deviceId: string, extendParam?: {}) => Promise<IRes<T>>;
|
|
58
|
-
export declare const networkStatusDidChangedEvent: (callback: any) => void;
|
|
59
|
-
export declare const offNetworkStatusDidChangedEvent: (callback: any) => void;
|
|
58
|
+
export declare const networkStatusDidChangedEvent: (callback: (res: any) => void) => void;
|
|
59
|
+
export declare const offNetworkStatusDidChangedEvent: (callback: (res: any) => void) => void;
|
|
60
60
|
/**
|
|
61
61
|
* 获取手机当前横竖屏状态
|
|
62
62
|
* 需引入IPCKit,且在>=1.0.0-TTT432.1版本才可使用
|
package/lib/kit/ipc/index.js
CHANGED
|
@@ -80,12 +80,14 @@ export const setNativeStorage = (key, data) => {
|
|
|
80
80
|
key,
|
|
81
81
|
data,
|
|
82
82
|
success: res => {
|
|
83
|
+
console.log(res, '______');
|
|
83
84
|
resolve({
|
|
84
85
|
code: 0,
|
|
85
86
|
data: res
|
|
86
87
|
});
|
|
87
88
|
},
|
|
88
89
|
fail: err => {
|
|
90
|
+
console.log(err, '___________');
|
|
89
91
|
resolve({
|
|
90
92
|
code: -1,
|
|
91
93
|
msg: err
|
package/lib/service/index.js
CHANGED
|
@@ -147,75 +147,84 @@ export const getCameraConfigInfo = async deviceId => {
|
|
|
147
147
|
})) {
|
|
148
148
|
// 非虚拟机设备,请求接口
|
|
149
149
|
if (!isVirtualDevice) {
|
|
150
|
-
var
|
|
151
|
-
const
|
|
150
|
+
var _microphoneStorage$da, _intercomStorage$data, _resolutionStorage$da, _maxZoomSettingsStora;
|
|
151
|
+
const rtcInfo = await getIpcConfigInfo(deviceId);
|
|
152
|
+
if (rtcInfo.code === 0) {
|
|
153
|
+
var _rtcApiResult$audioAt, _rtcApiResult$audioAt2, _rtcApiResult$audioAt3;
|
|
154
|
+
const rtcApiResult = rtcInfo.data;
|
|
155
|
+
// 1. 拾音器模块
|
|
156
|
+
const isMicrophoneSupported = rtcApiResult === null || rtcApiResult === void 0 || (_rtcApiResult$audioAt = rtcApiResult.audioAttributes) === null || _rtcApiResult$audioAt === void 0 || (_rtcApiResult$audioAt = _rtcApiResult$audioAt.hardwareCapability) === null || _rtcApiResult$audioAt === void 0 ? void 0 : _rtcApiResult$audioAt.includes(1);
|
|
157
|
+
// 拾音器默认声音都为关闭, 若接口返回不支持,则将缓存值设置为关闭
|
|
158
|
+
microphoneSettings.isMicrophoneSupported = isMicrophoneSupported;
|
|
159
|
+
const muteStatus = isMicrophoneSupported ? microphoneSettings.cachedMuteMode : defaultMuteMode;
|
|
160
|
+
microphoneSettings.cachedMuteMode = muteStatus; // 设置默认值
|
|
152
161
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
intercomInfo.supportedIntercomModes = supportedIntercomModes.map(mode => intercomCallMode[mode]);
|
|
169
|
-
// 获取APP当前存储的对讲模式, 因目前设置页对讲设置使用的还是原生页面,需要读取APP缓存保持一致
|
|
170
|
-
const appIntercomCached = await getCurrentSupportedTalkMode(deviceId);
|
|
171
|
-
if (appIntercomCached.code !== 0) {
|
|
172
|
-
throw appIntercomCached.msg;
|
|
162
|
+
// 2. 对讲功能模块
|
|
163
|
+
const isIntercomSupported = rtcApiResult === null || rtcApiResult === void 0 || (_rtcApiResult$audioAt2 = rtcApiResult.audioAttributes) === null || _rtcApiResult$audioAt2 === void 0 || (_rtcApiResult$audioAt2 = _rtcApiResult$audioAt2.hardwareCapability) === null || _rtcApiResult$audioAt2 === void 0 ? void 0 : _rtcApiResult$audioAt2.includes(2);
|
|
164
|
+
intercomInfo.isIntercomSupported = isIntercomSupported;
|
|
165
|
+
// 获取支持的对讲方式
|
|
166
|
+
const supportedIntercomModes = rtcApiResult === null || rtcApiResult === void 0 || (_rtcApiResult$audioAt3 = rtcApiResult.audioAttributes) === null || _rtcApiResult$audioAt3 === void 0 ? void 0 : _rtcApiResult$audioAt3.callMode;
|
|
167
|
+
if (isIntercomSupported && supportedIntercomModes.length > 0) {
|
|
168
|
+
var _appIntercomCached$da;
|
|
169
|
+
intercomInfo.defaultIntercomMode = intercomCallMode[supportedIntercomModes[0]];
|
|
170
|
+
intercomInfo.supportedIntercomModes = supportedIntercomModes.map(mode => intercomCallMode[mode]);
|
|
171
|
+
// 获取APP当前存储的对讲模式, 因目前设置页对讲设置使用的还是原生页面,需要读取APP缓存保持一致
|
|
172
|
+
const appIntercomCached = await getCurrentSupportedTalkMode(deviceId);
|
|
173
|
+
if (appIntercomCached.code !== 0) {
|
|
174
|
+
throw appIntercomCached.msg;
|
|
175
|
+
}
|
|
176
|
+
intercomInfo.cachedIntercomMode = intercomCallMode[appIntercomCached === null || appIntercomCached === void 0 || (_appIntercomCached$da = appIntercomCached.data) === null || _appIntercomCached$da === void 0 ? void 0 : _appIntercomCached$da.talkbackMode];
|
|
173
177
|
}
|
|
174
|
-
intercomInfo.cachedIntercomMode = intercomCallMode[appIntercomCached === null || appIntercomCached === void 0 || (_appIntercomCached$da = appIntercomCached.data) === null || _appIntercomCached$da === void 0 ? void 0 : _appIntercomCached$da.talkbackMode];
|
|
175
|
-
}
|
|
176
178
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
// 4. 最大倍数模块
|
|
183
|
-
maxZoomSettings = (rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.maxZoomInTimes) !== 0 ? rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.maxZoomInTimes : 6;
|
|
184
|
-
}
|
|
179
|
+
// 3. 视频分辨率模块
|
|
180
|
+
videoResolution.defaultResolution = videoResolutionMode[rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.vedioClarity];
|
|
181
|
+
console.log(rtcApiResult, 'rtcApiResult');
|
|
182
|
+
const supportedVideoClarity = rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.vedioClaritys;
|
|
183
|
+
videoResolution.availableResolutions = supportedVideoClarity.map(mode => videoResolutionMode[mode]);
|
|
185
184
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
185
|
+
// 4. 最大倍数模块
|
|
186
|
+
maxZoomSettings = (rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.maxZoomInTimes) !== 0 ? rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.maxZoomInTimes : 6;
|
|
187
|
+
}
|
|
188
|
+
// 由于utils为统一返回,多加了一层data,所以需要取data.data
|
|
189
|
+
// 1. 设置拾音器缓存
|
|
190
|
+
const microphoneStorageData = microphoneStorage === null || microphoneStorage === void 0 || (_microphoneStorage$da = microphoneStorage.data) === null || _microphoneStorage$da === void 0 ? void 0 : _microphoneStorage$da.data;
|
|
191
|
+
if (!microphoneStorageData) {
|
|
192
|
+
setNativeStorage(`${deviceId}_microphone`, microphoneSettings);
|
|
193
|
+
}
|
|
194
|
+
// 2. 设置对讲缓存
|
|
195
|
+
const intercomStorageData = intercomStorage === null || intercomStorage === void 0 || (_intercomStorage$data = intercomStorage.data) === null || _intercomStorage$data === void 0 ? void 0 : _intercomStorage$data.data;
|
|
196
|
+
if (!intercomStorageData) {
|
|
197
|
+
setNativeStorage(`${deviceId}_intercom`, intercomInfo);
|
|
198
|
+
}
|
|
194
199
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
200
|
+
// 3. 设置视频清晰度缓存
|
|
201
|
+
const resolutionStorageData = resolutionStorage === null || resolutionStorage === void 0 || (_resolutionStorage$da = resolutionStorage.data) === null || _resolutionStorage$da === void 0 ? void 0 : _resolutionStorage$da.data;
|
|
202
|
+
if (!resolutionStorageData) {
|
|
203
|
+
setNativeStorage(`${deviceId}_resolution`, videoResolution);
|
|
204
|
+
}
|
|
199
205
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
206
|
+
// 4. 设置最大倍数缓存
|
|
207
|
+
const maxZoomSettingsStorageData = maxZoomSettingsStorage === null || maxZoomSettingsStorage === void 0 || (_maxZoomSettingsStora = maxZoomSettingsStorage.data) === null || _maxZoomSettingsStora === void 0 ? void 0 : _maxZoomSettingsStora.data;
|
|
208
|
+
if (!maxZoomSettingsStorageData) {
|
|
209
|
+
setNativeStorage(`${deviceId}_maxZoomSettings`, maxZoomSettings);
|
|
210
|
+
}
|
|
203
211
|
}
|
|
204
212
|
} else {
|
|
205
|
-
var _appIntercomCached$da2,
|
|
213
|
+
var _intercomStorage$data2, _appIntercomCached$da2, _resolutionStorage$da2, _microphoneStorage$da2, _maxZoomSettingsStora2;
|
|
206
214
|
// 对于对讲缓存的方式每次需从APP获取更新
|
|
207
|
-
|
|
215
|
+
const intercomStorageData = intercomStorage === null || intercomStorage === void 0 || (_intercomStorage$data2 = intercomStorage.data) === null || _intercomStorage$data2 === void 0 ? void 0 : _intercomStorage$data2.data;
|
|
216
|
+
intercomInfo = intercomStorageData;
|
|
208
217
|
const appIntercomCached = await getCurrentSupportedTalkMode(deviceId);
|
|
209
218
|
if (appIntercomCached.code !== 0) {
|
|
210
219
|
throw appIntercomCached.msg;
|
|
211
220
|
}
|
|
212
221
|
intercomInfo.cachedIntercomMode = intercomCallMode[appIntercomCached === null || appIntercomCached === void 0 || (_appIntercomCached$da2 = appIntercomCached.data) === null || _appIntercomCached$da2 === void 0 ? void 0 : _appIntercomCached$da2.talkbackMode];
|
|
213
|
-
if (
|
|
222
|
+
if (intercomStorageData.cachedIntercomMode !== intercomInfo.cachedIntercomMode) {
|
|
214
223
|
setNativeStorage(`${deviceId}_intercom`, intercomInfo);
|
|
215
224
|
}
|
|
216
|
-
videoResolution = resolutionStorage.data;
|
|
217
|
-
microphoneSettings = microphoneStorage.data;
|
|
218
|
-
maxZoomSettings = maxZoomSettingsStorage.data;
|
|
225
|
+
videoResolution = resolutionStorage === null || resolutionStorage === void 0 || (_resolutionStorage$da2 = resolutionStorage.data) === null || _resolutionStorage$da2 === void 0 ? void 0 : _resolutionStorage$da2.data;
|
|
226
|
+
microphoneSettings = microphoneStorage === null || microphoneStorage === void 0 || (_microphoneStorage$da2 = microphoneStorage.data) === null || _microphoneStorage$da2 === void 0 ? void 0 : _microphoneStorage$da2.data;
|
|
227
|
+
maxZoomSettings = maxZoomSettingsStorage === null || maxZoomSettingsStorage === void 0 || (_maxZoomSettingsStora2 = maxZoomSettingsStorage.data) === null || _maxZoomSettingsStora2 === void 0 ? void 0 : _maxZoomSettingsStora2.data;
|
|
219
228
|
}
|
|
220
229
|
const ipcConfig = {
|
|
221
230
|
videoResolution,
|
|
@@ -228,13 +237,14 @@ export const getCameraConfigInfo = async deviceId => {
|
|
|
228
237
|
data: ipcConfig
|
|
229
238
|
});
|
|
230
239
|
} catch (err) {
|
|
240
|
+
console.log(err, 'err');
|
|
231
241
|
ty.showToast({
|
|
232
242
|
title: I18n.t('get_ipc_config_info_api_err'),
|
|
233
243
|
icon: 'error'
|
|
234
244
|
});
|
|
235
245
|
return Promise.resolve({
|
|
236
246
|
code: -1,
|
|
237
|
-
msg: String(err)
|
|
247
|
+
msg: err.errorMsg ? err.errorMsg : String(err)
|
|
238
248
|
});
|
|
239
249
|
}
|
|
240
250
|
};
|