One-to-one video call(VOIP)

7.1 Get the StarRtc.StarRoomSDK instance and implement the callback function

function voipCallBack(data, status, oper)
{
var thisRoom = data.obj;
switch (status){
case "connect success":
//connect success
break;
case "connect failed":
case "connect closed":
//connect failed
break;
case "onWebrtcMessage":
//Video interface message
switch(data.type)
{
case "streamCreated":
//Create the local video stream,and the data.status == "success" means success
break;
case "voipStreamReady":
//Remote video stream preparation,nd the data.status == "success" means success
//Can let the data.streamObj be an object
break;
}
break;
case "onVoipMessage":
switch(data.type)
{
case "voipRefuse":
//The other party refused the call
break;
case "voipHangup":
//The other party hangs up the call
break;
case "voipConnect":
//voip has connected
break;
case "voipBusy":
//The other party is busy
break;
case "voipSingleMsg":
//receive a voip message
break;
}
break;
}
}

/**
* Create a voip room
* @param _oper Operation type: call, caller; response, responder
* @param _userCallback callback
* @param _userData Store the other party id information,and the structure is{"roomInfo":{"targetId":the other party id, "audioOnly":Whether only has audio chat(The parameter can not be passed in, the default value is false: video chat)}}
*/
currRoom = StarRtc.StarSDK.getVoipRoomSDK = function(_oper, _userCallback, _userData)

Sample
var starSDK = new StarRtc.StarSDK();
currRoom = starSDK.getVoipRoomSDK("call", voipCallBack, {"roomInfo":{"targetId":"", "audioOnly":true}});

7.2 The API Description of VOIP section in StarRtc.StarRoomSDK


/**
* Connect to the room
*/
StarRtc.StarRoomSDK.sigConnect = function ()

/**
* Disconnect to the super room
* @param flag The flag of Whether to disconnect actively, which is used to determine reconnection
*/
StarRtc.StarRoomSDK.sigDisconnect = function (_flag)

/**
* Create a local video stream
* @param streamOption Stream configurationResolution, etc.),such as{ "video": true, "audio": { deviceId: { ideal: ["default"] } } }, or{ "video": { width: { ideal: 640 }, height: { ideal: 480 }, frameRate: { ideal: 25 }, facingMode: { ideal: ["user"] } }, "audio": { deviceId: { ideal: ["default"] } }
}
*/
StarRtc.StarRoomSDK.createStream = function (streamOption)

/**
* Create a shared screen video stream
*/
StarRtc.StarRoomSDK.createScreenCaptureStream = function ()

/**
* Set the visibility of the stream (It will affect both local and far peer streams)
* @param config Stream visibility configuration{"video":true, "audio":true}
*/
StarRtc.StarRoomSDK.publishStream = function (config)

/**
* join the room
*/
StarRtc.StarRoomSDK.joinRoom = function ()

/**
* leave the room
* @param _flag Whether to leave the roomactively(optional)
*/
StarRtc.StarRoomSDK.leaveRoom = function (_flag)

/**
* Send voip message(IM one-to-one chat message)
* @param msg message
*/
StarRtc.StarRoomSDK.sendVoipMsg = function (msg)

/**
* Get the disconnect satus:active or passive?
StarRtc.StarRoomSDK.activeDisconnect = function()

7.3 The API Description of VOIP section in StarRtc.Instance

/**
* Send voip control message
* @param _targetId target Id
* @param _code code
*/
StarRtc.StarSDK.sendVoipCtrlMsg = function(_targetId,_code)

/**
* Send voip call message
* @param _targetId target user Id
* @param _ts Timestamp (optional)
* @param _flag Whether it is an audio call, the default flag is false (optional)
*/
StarRtc.StarSDK.sendVoipCallMsg = function (_targetId, _ts, _flag)

/**
* Send voip refuse message
* @param _targetId target user Id
*/
StarRtc.StarSDK.sendVoipRefuseMsg = function(_targetId)

/**
* Send voip hang up message
* @param _targetId target user Id
*/
StarRtc.StarSDK.sendVoipHungupMsg = function(_targetId)

/**
* Send voip hang up message
* @param _targetId target user Id
*/
StarRtc.StarSDK.sendVoipBusyMsg = function(_targetId)

/**
* Send voip message of agreeing to connect
* @param _targetId target user Id
*/
StarRtc.StarSDK.sendVoipConnectMsg = function(_targetId)

/**
* Set the callback to take over the onVoipMessage section of the login callback which be set in the login method
* @param _callback callback
*/
StarRtc.StarSDK.setIMExtraback = function(_callback)