rtcManage

rtcManage

音视频管理

rtcManage.initRTCEngine(params) ⇒ null

发起端发起音视频呼叫

Kind: static method of rtcManage

Param Type Description
params object 初始化参数
params.server string RTC服务器地址
params.id number 音视频用户id
params.name string 音视频用户名称
params.receiver number 音视频用户对方id
params.caller boolean 是否为呼叫发起者
params.secret string 创建的房间操作密码
params.pin string 创建的房间加入pin码
params.hasVideo boolean 是否存在视频流
params.hasAudio boolean 是否存在音频流
params.width number 视频流画面宽度
params.height number 视频流画面高度
params.localVideo string 本地video标签id
params.remoteVideo string 远程video标签id
params.remoteAudio string 远程audio标签id
params.getThrough boolean 音视频通话是否接通
params.hangupCall boolean 音视频通话是否挂断

Example

this.refreshUserInfo(this.getSid);
this.$store.getters.im.rtcManage.initRTCEngine({
  server: this.$store.state.im.sysManage.getServers(app_id).rtc,
  id: this.$store.state.im.userManage.getUid(),
  name: rInfo.nick_name || rInfo.username,
  receiver: this.getSid,
  caller: true,
  callId: this.getCallId,
  secret: this.randomString(8),
  pin: this.randomString(8),
  hasVideo: false,
  hasAudio: true,
  remoteAudio: document.getElementById('roster_remote_only_audio'),
  getThrough: this.getThrough,
  hangupCall: this.hangupCall
});
this.startPhoneRing();
this.refreshUserInfo(this.getSid);
this.$store.getters.im.rtcManage.initRTCEngine({
  server: this.$store.state.im.sysManage.getServers(app_id).rtc,
  id: this.$store.state.im.userManage.getUid(),
  name: rInfo.nick_name || rInfo.username,
  receiver: this.getSid,
  caller: true,
  callId: this.getCallId,
  secret: this.randomString(8),
  pin: this.randomString(8),
  hasVideo: true,
  hasAudio: true,
  width: 360,
  height: 640,
  localVideo: document.getElementById('roster_local_video'),
  remoteVideo: document.getElementById('roster_remote_video'),
  remoteAudio: document.getElementById('roster_remote_audio'),
  getThrough: this.getThrough,
  hangupCall: this.hangupCall
});
this.startPhoneRing();

rtcManage.destroy() ⇒ null

销毁操作(在关闭音视频界面时使用)

Kind: static method of rtcManage

Type
null

Example

if (!this.doHangup) {
  this.hangupCall(false);
}
this.$store.getters.im.rtcManage.destroy();
if (!this.doHangup) {
  this.hangupCall(false);
}
this.$store.getters.im.rtcManage.destroy();

rtcManage.sendRTCMessage(msg) ⇒ number

发送音视频消息

Kind: static method of rtcManage
Returns: number - 客户端生成的消息ID

Param Type Description
msg object 消息体
msg.uid string 接收者ID
msg.content string 消息内容
msg.config string | object 扩展字段

Example

this.$store.getters.im.rtcManage.sendRTCMessage({
  uid: fromUid,
  content: 'busy',
  config: JSON.stringify({
    action: 'hangup',
    callId: config.callId,
    initiator: config.initiator,
    pushMessageLocKey: 'callee_busy'
  })
});
let pickupTime = this.getCallPickupTime;
let content = '';
let pushlocKey = 'call_duration';
let callTime = [0, 0];
if (pickupTime) {
  content = (Date.now() - this.getCallPickupTime).toString();
  let intervalMsec = parseInt(content);
  let intervalSec = intervalMsec / 1000;
  callTime[0] = parseInt(intervalSec / 60);
  callTime[1] = parseInt(intervalSec - callTime[0] * 60);
} else {
  if (timeout) {
    content = 'timeout';
    pushlocKey = 'callee_not_responding';
  } else {
    content = 'canceled';
    pushlocKey = 'call_canceled_by_caller';
  }
}
this.$store.getters.im.rtcManage.sendRTCMessage({
  uid: this.userInfo.user_id,
  content: content,
  config: JSON.stringify({
    action: 'hangup',
    callId: this.getCallId,
    initiator: toNumber(this.getCallId.split('_')[0...
this.isGetThrough = true;
this.$store.getters.im.rtcManage.sendRTCMessage({
  uid: this.userInfo.user_id,
  content: '',
  config: JSON.stringify({
    action: 'pickup',
    callId: this.getCallId
  })
});
this.$store.dispatch('contact/actionSetCallPickupTime', Date.now());
this.stopPhoneRing();
setInterval(this.calculateDisplayTime, 1000);
this.$store.getters.im.rtcManage.sendRTCMessage({
  uid: this.userInfo.user_id,
  content: 'rejected',
  config: JSON.stringify({
    action: 'hangup',
    callId: this.getCallId,
    initiator: toNumber(this.getCallId.split('_')[0]),
    pushMessageLocKey: 'call_rejected_by_callee'
  })
});
this.stopPhoneRing();
this.$store.dispatch('layer/actionSetShowing', '');
this.$store.dispatch('layer/actionSetShowmask', false);
this.$store.dispatch('contact/actionSetCallInviteInfo', null);
this.$store.dispatch('contact/actionSetCallId', '');
this.$store.dispatch('contact/actionSetCallPickupTime', 0);
this.$store.dispatch('setting/actionSetCallStatus', false);
let pickupTime = this.getCallPickupTime;
let content = '';
let pushlocKey = 'call_duration';
let callTime = [0, 0];
if (pickupTime) {
  content = (Date.now() - this.getCallPickupTime).toString();
  let intervalMsec = parseInt(content);
  let intervalSec = intervalMsec / 1000;
  callTime[0] = parseInt(intervalSec / 60);
  callTime[1] = parseInt(intervalSec - callTime[0] * 60);
} else {
  if (timeout) {
    content = 'timeout';
    pushlocKey = 'callee_not_responding';
  } else {
    content = 'canceled';
    pushlocKey = 'call_canceled_by_caller';
  }
}
this.$store.getters.im.rtcManage.sendRTCMessage({
  uid: this.userInfo.user_id,
  content: content,
  config: JSON.stringify({
    action: 'hangup',
    callId: this.getCallId,
    initiator: toNumber(this.getCallId.split('_')[0...
this.isGetThrough = true;
this.$store.getters.im.rtcManage.sendRTCMessage({
  uid: this.userInfo.user_id,
  content: '',
  config: JSON.stringify({
    action: 'pickup',
    callId: this.getCallId
  })
});
this.$store.dispatch('contact/actionSetCallPickupTime', Date.now());
this.stopPhoneRing();
setInterval(this.calculateDisplayTime, 1000);

rtcManage.joinRoom(params) ⇒ null

加入房间操作

Kind: static method of rtcManage

Param Type Description
params object 初始化参数

Example

this.refreshUserInfo(info.initiator);
this.$store.getters.im.rtcManage.joinRoom({
  server: this.$store.state.im.sysManage.getServers(app_id).rtc,
  id: this.$store.state.im.userManage.getUid(),
  roomId: info.roomId,
  caller: false,
  pin: info.pin,
  hasVideo: false,
  hasAudio: true,
  remoteAudio: document.getElementById('roster_remote_only_audio'),
  getThrough: this.getThrough,
  hangupCall: this.hangupCall
});
this.refreshUserInfo(info.initiator);
this.$store.getters.im.rtcManage.joinRoom({
  server: this.$store.state.im.sysManage.getServers(app_id).rtc,
  id: this.$store.state.im.userManage.getUid(),
  roomId: info.roomId,
  caller: false,
  pin: info.pin,
  hasVideo: true,
  hasAudio: true,
  width: 360,
  height: 640,
  localVideo: document.getElementById('roster_local_video'),
  remoteVideo: document.getElementById('roster_remote_video'),
  remoteAudio: document.getElementById('roster_remote_audio'),
  getThrough: this.getThrough,
  hangupCall: this.hangupCall
});

rtcManage.leaveRoom() ⇒ null

离开加入房间操作

Kind: static method of rtcManage

Type
null

Example

if (active) {
  let pickupTime = this.getCallPickupTime;
  let content = '';
  let pushlocKey = 'call_duration';
  let callTime = [0, 0];
  if (pickupTime) {
    content = (Date.now() - this.getCallPickupTime).toString();
    let intervalMsec = parseInt(content);
    let intervalSec = intervalMsec / 1000;
    callTime[0] = parseInt(intervalSec / 60);
    callTime[1] = parseInt(intervalSec - callTime[0] * 60);
  } else {
    if (timeout) {
      content = 'timeout';
      pushlocKey = 'callee_not_responding';
    } else {
      content = 'canceled';
      pushlocKey = 'call_canceled_by_caller';
    }
  }
  this.$store.getters.im.rtcManage.sendRTCMessage({
    uid: this.userInfo.user_id,
    content: content,
    config: JSON.stringify({
      action: 'hangup',
      callId: this.getCallId,
      initiator: toNumber(this.ge...
if (active) {
  let pickupTime = this.getCallPickupTime;
  let content = '';
  let pushlocKey = 'call_duration';
  let callTime = [0, 0];
  if (pickupTime) {
    content = (Date.now() - this.getCallPickupTime).toString();
    let intervalMsec = parseInt(content);
    let intervalSec = intervalMsec / 1000;
    callTime[0] = parseInt(intervalSec / 60);
    callTime[1] = parseInt(intervalSec - callTime[0] * 60);
  } else {
    if (timeout) {
      content = 'timeout';
      pushlocKey = 'callee_not_responding';
    } else {
      content = 'canceled';
      pushlocKey = 'call_canceled_by_caller';
    }
  }
  this.$store.getters.im.rtcManage.sendRTCMessage({
    uid: this.userInfo.user_id,
    content: content,
    config: JSON.stringify({
      action: 'hangup',
      callId: this.getCallId,
      initiator: toNumber(this.ge...

rtcManage.publish(type, hasVideo, hasAudio) ⇒ null

发布本地流操作

Kind: static method of rtcManage

Param Type Description
type enum 禁止标记
hasVideo boolean 是否发布视频
hasAudio boolean 是否发布音频

Example

rtcManage.unPublish() ⇒ null

取消发布流操作

Kind: static method of rtcManage

Type
null

Example

rtcManage.subscribe(sources) ⇒ null

订阅流信息操作

Kind: static method of rtcManage

Param Type
sources Array

Example

rtcManage.unSubscribe(id) ⇒ null

取消订阅流操作

Kind: static method of rtcManage

Param Type Description
id number 取消订阅的流id

Example

rtcManage.muteLocalAudio(mute) ⇒ null

禁止本地发布音频流操作

Kind: static method of rtcManage

Param Type Description
mute boolean 禁止标记

Example

this.mic = !this.mic;
console.log('micChangeStatus ' + this.mic);
this.$store.getters.im.rtcManage.muteLocalAudio(!this.mic);
this.mic = !this.mic;
this.$store.getters.im.rtcManage.muteLocalAudio(!this.mic);

rtcManage.muteLocalVideo(mute) ⇒ null

禁止本地发布视频流操作

Kind: static method of rtcManage

Param Type Description
mute boolean 禁止标记

Example

this.camera = !this.camera;
this.$store.getters.im.rtcManage.muteLocalVideo(!this.camera);

rtcManage.muteRemoteAudio(stream, mute) ⇒ null

禁止远程订阅音频流操作

Kind: static method of rtcManage

Param Type Description
stream object 订阅流对象
mute boolean 禁止标记

Example

rtcManage.muteRemoteVideo(stream, mute) ⇒ null

禁止远程订阅视频流操作

Kind: static method of rtcManage

Param Type Description
stream object 订阅流对象
mute boolean 禁止标记

Example

rtcManage.getJanusObject() ⇒ object

获取Janus对象句柄

Kind: static method of rtcManage

Type
null

Example

rtcManage.getPublishHandler() ⇒ object

获取发布操作对象句柄

Kind: static method of rtcManage

Type
null

Example

rtcManage.getSubscribeHandler() ⇒ object

获取订阅操作对象句柄

Kind: static method of rtcManage

Type
null

Example

© 2019-2023 美信拓扑 | 官网 该文件修订时间: 2023-06-16 17:55:18

results matching ""

    No results matching ""