call-live-sdk1 0.0.9 → 0.0.10

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.
@@ -82768,7 +82768,7 @@ const useCallStore = create$c()(
82768
82768
  token: "",
82769
82769
  // RTC令牌
82770
82770
  // LoginResponseData 字段
82771
- nickname: "头痛",
82771
+ nickname: "",
82772
82772
  // 用户昵称
82773
82773
  rtc_userid: "",
82774
82774
  // RTC用户ID
@@ -82947,7 +82947,9 @@ const useCallStore = create$c()(
82947
82947
  nickname,
82948
82948
  token: token2,
82949
82949
  rule,
82950
- waiting_mode
82950
+ waiting_mode,
82951
+ isVideoEnabled,
82952
+ isAudioEnabled
82951
82953
  } = callConfig;
82952
82954
  if (isUserExists(rtc_userid || "")) {
82953
82955
  console.warn(`本地用户 ${rtc_userid} 已存在,跳过添加`);
@@ -82964,8 +82966,8 @@ const useCallStore = create$c()(
82964
82966
  ...initCallUser,
82965
82967
  // 根据enter_muted配置设置初始音频状态
82966
82968
  // enter_muted: 0-否(音频开启) 1-是(音频关闭/静音)
82967
- isAudioEnabled: true,
82968
- isVideoEnabled: false,
82969
+ isAudioEnabled: isAudioEnabled ?? true,
82970
+ isVideoEnabled: isVideoEnabled ?? false,
82969
82971
  joinTime: Date.now(),
82970
82972
  waiting_mode_state: rule === "main" || !waiting_mode ? 0 : 1
82971
82973
  /* WAITING */
@@ -83025,6 +83027,17 @@ const useCallStore = create$c()(
83025
83027
  callCurrentUser: void 0,
83026
83028
  layoutMode: "main_plus_list",
83027
83029
  callUsersCurrentPageRef: 1,
83030
+ callConfig: {
83031
+ ...callConfig,
83032
+ isCall: false,
83033
+ // 连麦是否开启
83034
+ isAudioEnabled: true,
83035
+ // 音频是否开启
83036
+ isScreenEnabled: false,
83037
+ // 屏幕共享是否开启
83038
+ isVideoEnabled: false
83039
+ // 视频是否开启
83040
+ },
83028
83041
  mainCanvasId: callConfig.rule === "main" ? (callConfig == null ? void 0 : callConfig.drawing_board_id) || "" : ""
83029
83042
  });
83030
83043
  if (rtc) {
@@ -194938,7 +194951,7 @@ class RtcClient {
194938
194951
  * @param {string} userId - 用户ID
194939
194952
  * @param {Function} callback - 回调函数,返回创建结果和设备状态
194940
194953
  */
194941
- async createLocalStream(userId, callback, renderMode = VideoRenderMode.RENDER_MODE_FIT) {
194954
+ async createLocalStream(userId, callback, { video = true, audio = true, renderMode = VideoRenderMode.RENDER_MODE_FIT }) {
194942
194955
  const devices = await this.getDevices();
194943
194956
  this.devicesSettings = devices.cameraId = devices.videoInputs[0].deviceId;
194944
194957
  this.devicesSettings = devices.microphoneId = devices.audioInputs[0].deviceId;
@@ -194986,24 +194999,26 @@ class RtcClient {
194986
194999
  contentHint: "motion"
194987
195000
  // 屏幕采集场景,流畅度优先
194988
195001
  });
194989
- if (this.streamOptions.audio && devices.audioInputs.length) {
195002
+ if (this.streamOptions.audio && devices.audioInputs.length && audio) {
194990
195003
  await this.engine.startAudioCapture(this.devicesSettings.microphoneId);
195004
+ await this.engine.publishStream(MediaType$1.AUDIO);
194991
195005
  } else {
194992
195006
  devicesStatus["audio"] = 0;
194993
195007
  this.engine.unpublishStream(MediaType$1.AUDIO);
194994
195008
  }
194995
- if (this.streamOptions.video && devices.videoInputs.length) {
195009
+ if (this.streamOptions.video && devices.videoInputs.length && video) {
194996
195010
  await this.engine.startVideoCapture(this.devicesSettings.cameraId);
195011
+ await this.engine.setLocalVideoMirrorType(MirrorType.MIRROR_TYPE_RENDER);
195012
+ this.engine.setLocalVideoPlayer(StreamIndex$1.STREAM_INDEX_MAIN, {
195013
+ renderDom: userId,
195014
+ userId,
195015
+ renderMode
195016
+ });
195017
+ await this.engine.publishStream(MediaType$1.VIDEO);
194997
195018
  } else {
194998
195019
  devicesStatus["video"] = 0;
194999
195020
  this.engine.unpublishStream(MediaType$1.VIDEO);
195000
195021
  }
195001
- await this.engine.setLocalVideoMirrorType(MirrorType.MIRROR_TYPE_RENDER);
195002
- this.engine.setLocalVideoPlayer(StreamIndex$1.STREAM_INDEX_MAIN, {
195003
- renderDom: userId,
195004
- userId,
195005
- renderMode
195006
- });
195007
195022
  if (callback) {
195008
195023
  callback({
195009
195024
  code: 0,
@@ -289436,7 +289451,7 @@ const ChatComponent = () => {
289436
289451
  if (res.success) {
289437
289452
  setLoading(false);
289438
289453
  setCurrent(res.data.pagination.current);
289439
- setInteractionList((list) => [...list, ...res.data.list]);
289454
+ setInteractionList(res.data.list);
289440
289455
  if (res.data.list.length < 10 || res.data.list.length === res.data.pagination.total || res.data.list.length + interactionList.length >= res.data.pagination.total) {
289441
289456
  setFinished(true);
289442
289457
  }
@@ -292039,7 +292054,6 @@ const RtcJoomRoom = reactExports.memo(({
292039
292054
  callCurrentUser,
292040
292055
  callUsers,
292041
292056
  callAudioMixing,
292042
- updateCallConfig,
292043
292057
  leaveRemoteUser,
292044
292058
  joinCallUser,
292045
292059
  updateCallUser,
@@ -292050,7 +292064,27 @@ const RtcJoomRoom = reactExports.memo(({
292050
292064
  handleRemoteUserPublishScreen,
292051
292065
  handleRemoteUserUnpublishScreen,
292052
292066
  getCallConfig
292053
- } = useCallStore();
292067
+ } = useCallStore((state) => ({
292068
+ callConfig: state.callConfig,
292069
+ rtc: state.rtc,
292070
+ getter: state.getter,
292071
+ setRtc: state.setRtc,
292072
+ mainCanvasId: state.mainCanvasId,
292073
+ callCurrentUser: state.callCurrentUser,
292074
+ callUsers: state.callUsers,
292075
+ callAudioMixing: state.callAudioMixing,
292076
+ updateCallConfig: state.updateCallConfig,
292077
+ leaveRemoteUser: state.leaveRemoteUser,
292078
+ joinCallUser: state.joinCallUser,
292079
+ updateCallUser: state.updateCallUser,
292080
+ leave: state.leave,
292081
+ toggleVideo: state.toggleVideo,
292082
+ toggleAudio: state.toggleAudio,
292083
+ setMainCanvasId: state.setMainCanvasId,
292084
+ handleRemoteUserPublishScreen: state.handleRemoteUserPublishScreen,
292085
+ handleRemoteUserUnpublishScreen: state.handleRemoteUserUnpublishScreen,
292086
+ getCallConfig: state.getCallConfig
292087
+ }));
292054
292088
  const playStatus = reactExports.useRef({});
292055
292089
  const errorMessageCache = reactExports.useRef({});
292056
292090
  const ERROR_DEBOUNCE_TIME = 3e3;
@@ -292123,15 +292157,16 @@ const RtcJoomRoom = reactExports.memo(({
292123
292157
  }
292124
292158
  }, [originalInviteData, handleInviteConfirm, hideInviteConfirm, setInviteLoading]);
292125
292159
  const handleUserPublishStream = reactExports.useCallback(async (stream) => {
292126
- var _a2, _b, _c2;
292127
- console.log("handleUserPublishStream");
292160
+ var _a2, _b, _c2, _d2, _e2;
292161
+ console.log("发布流", stream);
292128
292162
  const userId = stream.userId;
292129
292163
  if (stream.mediaType & MediaType$1.VIDEO) {
292164
+ await ((_b = (_a2 = getter().rtc) == null ? void 0 : _a2.engine) == null ? void 0 : _b.subscribeStream(userId, MediaType$1.VIDEO));
292130
292165
  updateCallUser(userId, {
292131
- isPublishStream: true
292166
+ isVideoEnabled: true
292132
292167
  });
292133
292168
  if (callConfig.rule === "main") {
292134
- await ((_a2 = getter().rtc) == null ? void 0 : _a2.engine.sendRoomMessage(JSON.stringify({
292169
+ await ((_c2 = getter().rtc) == null ? void 0 : _c2.engine.sendRoomMessage(JSON.stringify({
292135
292170
  type: "users",
292136
292171
  data: {
292137
292172
  users: callUsers.map((user) => ({
@@ -292149,10 +292184,9 @@ const RtcJoomRoom = reactExports.memo(({
292149
292184
  if (stream.mediaType & MediaType$1.AUDIO) {
292150
292185
  const cuser = callUsers.find((user) => user.rtc_userid === callConfig.rtc_userid);
292151
292186
  if ((cuser == null ? void 0 : cuser.waiting_mode_state) !== WaitingModeState.WAITING) {
292152
- console.log("当前不是等待用户 订阅 音频流", userId);
292153
- await ((_c2 = (_b = getter().rtc) == null ? void 0 : _b.engine) == null ? void 0 : _c2.subscribeStream(userId, MediaType$1.AUDIO));
292187
+ await ((_e2 = (_d2 = getter().rtc) == null ? void 0 : _d2.engine) == null ? void 0 : _e2.subscribeStream(userId, MediaType$1.AUDIO));
292154
292188
  updateCallUser(userId, {
292155
- isSubscribeAudio: true
292189
+ isAudioEnabled: true
292156
292190
  });
292157
292191
  if (callConfig.rule === "main") {
292158
292192
  setTimeout(() => {
@@ -292202,7 +292236,7 @@ const RtcJoomRoom = reactExports.memo(({
292202
292236
  });
292203
292237
  };
292204
292238
  const rtcJoin = async () => {
292205
- var _a2, _b, _c2, _d2;
292239
+ var _a2, _b, _c2;
292206
292240
  const localUser = joinCallUser();
292207
292241
  const {
292208
292242
  rtc_room_id,
@@ -292213,7 +292247,7 @@ const RtcJoomRoom = reactExports.memo(({
292213
292247
  rtc_userid,
292214
292248
  token: token2,
292215
292249
  appid
292216
- } = callConfig;
292250
+ } = getter().callConfig;
292217
292251
  if (!localUser) {
292218
292252
  staticMethods.error("加入房间失败,本地用户不存在");
292219
292253
  return;
@@ -292228,7 +292262,7 @@ const RtcJoomRoom = reactExports.memo(({
292228
292262
  camera: isVideoEnabled ?? false
292229
292263
  }), {
292230
292264
  // 自动发布本地音视频流
292231
- isAutoPublish: true,
292265
+ isAutoPublish: false,
292232
292266
  // 自动订阅房间内其他用户的音频流
292233
292267
  isAutoSubscribeAudio: false,
292234
292268
  // 自动订阅房间内其他用户的视频流
@@ -292247,15 +292281,14 @@ const RtcJoomRoom = reactExports.memo(({
292247
292281
  if (code === -1) {
292248
292282
  window.confirm(`创建本地流失败:${msg2}`);
292249
292283
  }
292250
- }, VideoRenderMode.RENDER_MODE_HIDDEN));
292284
+ }, {
292285
+ video: isVideoEnabled,
292286
+ audio: isAudioEnabled,
292287
+ renderMode: VideoRenderMode.RENDER_MODE_HIDDEN
292288
+ }));
292251
292289
  if (callConfig.rule === "sub" && callConfig.enter_muted) {
292252
292290
  await toggleAudio(false);
292253
- } else {
292254
- updateCallConfig({
292255
- isReady: true
292256
- });
292257
292291
  }
292258
- await ((_d2 = getter().rtc) == null ? void 0 : _d2.publishStream());
292259
292292
  if (callConfig.rule === "main") {
292260
292293
  console.log("主播 发布 音视频流 ");
292261
292294
  callAudioMixing();
@@ -292304,14 +292337,25 @@ const RtcJoomRoom = reactExports.memo(({
292304
292337
  video: callConfig.isVideoEnabled ?? false
292305
292338
  },
292306
292339
  handleUserPublishStream,
292307
- handleUserUnpublishStream: (event) => {
292308
- var _a2;
292340
+ handleUserUnpublishStream: async (event) => {
292341
+ var _a2, _b, _c2;
292342
+ console.log("取消发布流", event);
292309
292343
  const {
292310
292344
  userId,
292311
292345
  mediaType
292312
292346
  } = event;
292313
292347
  if (mediaType & MediaType$1.VIDEO) {
292314
292348
  (_a2 = getter().rtc) == null ? void 0 : _a2.setRemoteVideoPlayer(userId, void 0);
292349
+ await ((_b = getter().rtc) == null ? void 0 : _b.engine.unsubscribeStream(userId, MediaType$1.VIDEO));
292350
+ updateCallUser(userId, {
292351
+ isVideoEnabled: false
292352
+ });
292353
+ }
292354
+ if (mediaType & MediaType$1.AUDIO) {
292355
+ await ((_c2 = getter().rtc) == null ? void 0 : _c2.engine.unsubscribeStream(userId, MediaType$1.AUDIO));
292356
+ updateCallUser(userId, {
292357
+ isAudioEnabled: false
292358
+ });
292315
292359
  }
292316
292360
  },
292317
292361
  handleUserStartVideoCapture: (event) => {
@@ -292539,10 +292583,10 @@ const RtcJoomRoom = reactExports.memo(({
292539
292583
  }, [callConfig.isCall, callConfig.rtc_room_id, callConfig.rule]);
292540
292584
  reactExports.useEffect(() => {
292541
292585
  const handleAdmittedUser = async () => {
292542
- var _a2, _b, _c2, _d2, _e2;
292586
+ var _a2, _b, _c2, _d2, _e2, _f2;
292543
292587
  if (!mainCanvasId) {
292544
292588
  try {
292545
- await ((_a2 = getter().rtc) == null ? void 0 : _a2.createLocalStream(callConfig.rtc_userid, (res) => {
292589
+ await ((_c2 = getter().rtc) == null ? void 0 : _c2.createLocalStream(callConfig.rtc_userid, (res) => {
292546
292590
  const {
292547
292591
  code,
292548
292592
  msg: msg2
@@ -292550,13 +292594,17 @@ const RtcJoomRoom = reactExports.memo(({
292550
292594
  if (code === -1) {
292551
292595
  window.confirm(`创建本地流失败:${msg2}`);
292552
292596
  }
292553
- }, VideoRenderMode.RENDER_MODE_HIDDEN));
292597
+ }, {
292598
+ video: (_a2 = getter().callConfig) == null ? void 0 : _a2.isVideoEnabled,
292599
+ audio: (_b = getter().callConfig) == null ? void 0 : _b.isAudioEnabled,
292600
+ renderMode: VideoRenderMode.RENDER_MODE_HIDDEN
292601
+ }));
292554
292602
  } catch (error2) {
292555
292603
  console.error("准入 本地流创建失败:", error2);
292556
292604
  }
292557
292605
  } else {
292558
- await ((_b = getter().rtc) == null ? void 0 : _b.setLocalVideoPlayer(callConfig.rtc_userid, callConfig.rtc_userid, callConfig.rtc_userid, (callCurrentUser == null ? void 0 : callCurrentUser.device) === "mobile" ? VideoRenderMode.RENDER_MODE_HIDDEN : VideoRenderMode.RENDER_MODE_FIT));
292559
- await ((_c2 = getter().rtc) == null ? void 0 : _c2.setLocalVideoPlayer(callConfig.rtc_userid, callConfig.rtc_userid + "self", callConfig.rtc_userid + "self", VideoRenderMode.RENDER_MODE_FILL));
292606
+ await ((_d2 = getter().rtc) == null ? void 0 : _d2.setLocalVideoPlayer(callConfig.rtc_userid, callConfig.rtc_userid, callConfig.rtc_userid, (callCurrentUser == null ? void 0 : callCurrentUser.device) === "mobile" ? VideoRenderMode.RENDER_MODE_HIDDEN : VideoRenderMode.RENDER_MODE_FIT));
292607
+ await ((_e2 = getter().rtc) == null ? void 0 : _e2.setLocalVideoPlayer(callConfig.rtc_userid, callConfig.rtc_userid + "self", callConfig.rtc_userid + "self", VideoRenderMode.RENDER_MODE_FILL));
292560
292608
  access == null ? void 0 : access();
292561
292609
  }
292562
292610
  callUsers.forEach((user) => {
@@ -292571,13 +292619,7 @@ const RtcJoomRoom = reactExports.memo(({
292571
292619
  toggleAudio(false);
292572
292620
  }
292573
292621
  try {
292574
- await ((_d2 = getter().rtc) == null ? void 0 : _d2.publishStream());
292575
- console.log("准入 发布本地流成功");
292576
- } catch (error2) {
292577
- console.error("准入 发布本地流失败:", error2);
292578
- }
292579
- try {
292580
- await ((_e2 = getter().rtc) == null ? void 0 : _e2.engine.sendRoomMessage(JSON.stringify({
292622
+ await ((_f2 = getter().rtc) == null ? void 0 : _f2.engine.sendRoomMessage(JSON.stringify({
292581
292623
  type: "change_user",
292582
292624
  data: {
292583
292625
  user: {
@@ -294806,7 +294848,6 @@ const MobileLive = reactExports.memo(({ className = "" }) => {
294806
294848
  const { setStatus } = useGuestStore((state) => ({
294807
294849
  setStatus: state.setStatus
294808
294850
  }));
294809
- useSdkStore((state) => state.callConfig.title);
294810
294851
  const [isBackCamera, setIsBackCamera] = reactExports.useState(false);
294811
294852
  const [showDeviceSettings, setShowDeviceSettings] = reactExports.useState(false);
294812
294853
  const [isDeviceSelected, setIsDeviceSelected] = reactExports.useState({