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.caller boolean 是否为呼叫发起者
params.receiver number 音视频用户对方id
params.pin string 房间加入pin码(caller为true时发起者需要创建新的pin码)
params.hasVideo boolean 是否存在视频流
params.hasAudio boolean 是否存在音频流
params.attachStream function 音视频通话信息流处理函数
params.getThrough function 音视频通话是否接通
params.hangupCall function 音视频通话是否挂断
params.getHangUpStatus function 获取挂断状态函数 以下是caller为 true 的必须参数(被呼叫者必须参数)
params.roomId number 被呼叫者邀请加入的 room id 以下是caller为 true 的必须参数(呼叫者必须参数)
params.secret string 创建的房间操作密码
params.callId string 创建音视频呼叫时音视频 callid 以下时视频会话必须的参数(视频宽度和高度设置函数)
params.width number 视频流画面宽度
params.height number 视频流画面高度

Example

const app_id = this.$store.state.im.userManage.getAppid();
const info = this.getCallInviteInfo;
if (info) {
  this.caller = false;
  this.refreshUserInfo(info.initiator);
} else {
  this.caller = true;
  this.refreshUserInfo(this.getSid);
  this.startPhoneRing();
}
document.getElementById('roster_remote_only_audio').muted = false;
this.$store.getters.im.rtcManage.initRTCEngine({
  server: this.$store.state.im.sysManage.getServers(app_id).rtc,
  id: this.$store.state.im.userManage.getUid(),
  caller: this.caller,
  receiver: this.caller ? this.getSid : info.initiator,
  roomId: this.caller ? 0 : info.roomId,
  secret: this.caller ? this.randomString(8) : '',
  callId: this.caller ? this.getCallId : '',
  pin: this.caller ? this.randomString(8) : info.pin,
  hasVideo: false,
  hasAudio: true,
  getThrough: this.getThrough,
  hangupCall: this.hangupCall,
  getHangUpStatus: this.getHang...
const app_id = this.$store.state.im.userManage.getAppid();
const info = this.getCallInviteInfo;
if (info) {
  this.caller = false;
  this.refreshUserInfo(info.initiator);
} else {
  this.caller = true;
  this.refreshUserInfo(this.getSid);
  this.startPhoneRing();
}
document.getElementById('roster_remote_audio').muted = false;
this.$store.getters.im.rtcManage.initRTCEngine({
  server: this.$store.state.im.sysManage.getServers(app_id).rtc,
  id: this.$store.state.im.userManage.getUid(),
  caller: this.caller,
  receiver: this.caller ? this.getSid : info.initiator,
  roomId: this.caller ? 0 : info.roomId,
  secret: this.caller ? this.randomString(8) : '',
  callId: this.caller ? this.getCallId : '',
  pin: this.caller ? this.randomString(8) : info.pin,
  hasVideo: true,
  hasAudio: true,
  width: 360,
  height: 640,
  getThrough: this.getThrough,
  hangupCall: this.hangupCall,
...

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.$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.camera = !this.camera;
this.$store.getters.im.rtcManage.muteLocalVideo(!this.camera);
this.$store.getters.im.rtcManage.sendRTCMessage({
  uid: this.userInfo.user_id,
  content: '',
  ext: JSON.stringify({
    callId: this.getCallId,
    mute_video: !this.camera
  })
});
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...

rtcManage.joinRoom(params) ⇒ null

加入房间操作

Kind: static method of rtcManage

Param Type Description
params object 初始化参数

Example

this.$store.getters.im.rtcManage.joinRoom();

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;
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);
this.$store.getters.im.rtcManage.sendRTCMessage({
  uid: this.userInfo.user_id,
  content: '',
  ext: JSON.stringify({
    callId: this.getCallId,
    mute_video: !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 美信拓扑 | 官网 该文件修订时间: 2024-05-28 07:16:11

results matching ""

    No results matching ""