Voximplant SDK for Unity Documentation

init(Action<bool> callback)
Initialize the SDK
Arguments
callback : Action<bool>
This callback will be called after SDK is initialized. It receives 'true' boolean argument if initialization is successful.
closeConnection()
Close connection to the Voximplant cloud that was previously established via 'connect' call
connect()
Initiate connection to the Voximplant cloud. After successful connection a "login" method should be called
login(String username, String password)
Login into Voximplant cloud. Should be called after "connect" in the "OnConnectionSuccessful" handler
Arguments
username : String
Username is a fully-qualified string that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com"
password : String
Plain text user password. Use loginUsingOneTimeKey for the better security
createCall(String number, Bool videoCall, String customData)
Creates new call
Arguments
number : String
Number to call. For SIP compatibility reasons number should be a non-empty string even if the number itself is not used by a Voximplant cloud scenario
videoCall : Bool
If 'true', video will will be sent and received for the call. Video can also be enabled or disabled dynamically during the createCall
customData : String
Custom data to send alongside call into Voximplant JavaScript cloud scenario
startCall(String callId, Dictionary<string, string> headers)
Start outgoing call
Arguments
callId : String
Call identifier
headers : Dictionary<string, string>
Optional SIP headers to send alongside the call
answer(String callId, Dictionary headers)
Answer incoming call. Should be called from the "OnIncomingCall" handler
Arguments
callId : String
Call identifier
headers : Dictionary
Optional SIP headers set by a info sender
declineCall(String callId, Dictionary headers)
Decline an incoming call. Should be called from the "OnIncomingCall" handler
Arguments
callId : String
Call identifier
headers : Dictionary
Optional SIP headers set by a info sender
hangup(String callId, Dictionary headers)
Deprecated. Use disconnectCall instead. Hang up the call in progress.
Arguments
callId : String
Call identifier
headers : Dictionary
Optional SIP headers set by a info sender
setMute(Boolean isMute)
Mute or unmute microphone. This is reset after audio interruption
Arguments
isMute : Boolean
'true' to set mute status, 'false' to remove it
sendVideo(Boolean isVideo)
Enable or disable video stream transfer during the call
Arguments
isVideo : Boolean
'true' to enable video stream, 'false' to disable it
setCamera(Camera cameraPosition)
Select a cameraPosition to use for the video call
Arguments
cameraPosition : Camera
A cameraPosition to use: 'Camera.CAMERA_FACING_FRONT', 'Camera.CAMERA_FACING_BACK'
disconnectCall(String callId, Dictionary headers)
Disconnect the specified call
Arguments
callId : String
Call identifier
headers : Dictionary
Optional SIP headers set by a info sender
enableDebugLogging()
If called before any other SDK methods, enables debug logging into target platform default debug log facility
loginUsingOneTimeKey(String username, String hash)
Login using a hash created from one-time key requested via 'requestOneTimeKey' and password. The has can be calculated on your backend so Voximplant password is never used in the application. Hash is calculated as 'MD5(one-time-key + "|" + MD5(vox-user + ":voximplant.com:" + vox-pass))'
Arguments
username : String
Username is a fully-qualified string that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com"
hash : String
Hash to authenticate. Note that hash is created not from a fully-qualified username, but from a bare user login, without the "@app.acc.voximplant.com" part
requestOneTimeKey(String pName)
Request a one-time key that can be used on your backend to create a login hash for the 'loginUsingOneTimeKey'. Key is returned via 'OnOneTimeKeyGenerated' event
Arguments
pName : String
Fully-qualified user name to get a one-time key for. Format is 'user@app.acc.voximplant.com'
sendDTMF(String callId, String digit)
Send DTMF signal to the specified call
Arguments
callId : String
Call identifier
digit : String
DTMF digit number (0-9, 10 for '*', 11 for '#')
sendInfo(String callid, String mimeType, String content, Dictionary<string, string> headers)
Send arbitrary data to Voximplant cloud. Data can be received in VoxEngine scenario by subscribing to the 'CallEvents.InfoReceived' event. Optional SIP headers can be automatically passed to second call via VoxEngine 'easyProcess()' method
Arguments
callid : String
Call identifier
mimeType : String
Data MIME type string
content : String
Data string
headers : Dictionary<string, string>
Optional SIP headers list as an array of 'PairKeyValue' objects with 'key' and 'value' properties
sendMessage(String callId, String message, <Dictionary<string, string> headers)
Simplified version of 'sendInfo' that uses predefined MIME type to send a text message. Message can be received in VoxEngine scenario by subscribing to the 'CallEvents.MessageReceived' event. Optional SIP headers can be automatically passed to second call via VoxEngine 'easyProcess()' method
Arguments
callId : String
Call identifier
message : String
Message string
headers : <Dictionary<string, string>
Optional SIP headers list as an array of 'PairKeyValue' objects with 'key' and 'value' properties
setCameraResolution(Int width, Int height)
Set local cameraPosition resolution. Increasing resolution increases video quality, but also uses more cpu and bandwidth
Arguments
width : Int
Width in pixels
height : Int
Height in pixels
setUseLoudspeaker(Bool isLoudSpeaker)
Enable or disable loud speaker, if available
Arguments
isLoudSpeaker : Bool
'true' to enable loud speaker, 'false' to disable it
beginUpdatingTextureWithVideoStream(String callId, VideoStream stream, Action<Texture2D> callback)
Execute specified callback, passing it every texture created for receiving local video preview or a remote video stream.
Arguments
callId : String
Call identifier
stream : VideoStream
"VoximplantSDK.VideoStream.Local" for a local camera preview video or "VoximplantSDK.VideoStream.Remote" for a remote video.
callback : Action<Texture2D>
This method will be called with each video frame. Note that given texture should be assigned to same obect, since previous one is destroyed by a native code.
useCameraVideoStreamForCall(String callId, UnityEngine.Camera Camera)
Attach specified Unity camera as video source for not yet started call.
Arguments
callId : String
Call identifier
Camera : UnityEngine.Camera
to be used as video source.
endSendingCameraVideoStreamForCall(String callId)
Stop sending camera video stream to call.
Arguments
callId : String
Call identifier
NetStatsReceived(String callId, Int loss)
Called when packet loss data is received from the Voximplant cloud
Arguments
callId : String
Call identifier
loss : Int
Packet loss from 0 (no loss) to 100 (all lost)
MessageReceivedInCall(String callId, String text)
Called if Voximplant-specified 'message' is recived. It's a specialized type of a more general SIP 'info' message
Arguments
callId : String
Call identifier
text : String
Message text
SIPInfoReceivedInCall(String callId, String type, String content, Dictionary headers)
Called if SIP 'info' message is received. That message can be sent from a Voximplant cloud scenario or forwarded from a caller
Arguments
callId : String
Call identifier
type : String
Data MIME type string
content : String
Data string
headers : Dictionary
Optional SIP headers set by a info sender
IncomingCall(String callId, String from, String name, Bool isVideo, Dictionary headers)
Called when Voximplant directs a new call to a user logged in from this SDK instance. SDK can handle multiple incoming and/or outgoing calls at once and target specified createCall via the 'callId' string returned by 'createCall()' method and received by this event
Arguments
callId : String
Call identifier
from : String
Caller SIP URI
name : String
Caller display name
isVideo : Bool
'true' if incoming call is a video createCall. Video can be enabled or disabled during a createCall
headers : Dictionary
Optional SIP headers that was set by a caller
CallAudioStarted(String callId)
Called when Voximplant cloud connects audio source to the call. If client previously played a progress tone, it should be stopped
Arguments
callId : String
Call identifier, previously returned by the call() function
CallFailed(String callId, Int code, String reason, Dictionary headers)
Called when Voximplant cloud rejects a call
Arguments
callId : String
Call identifier, previously returned by the call() function
code : Int
Status code
reason : String
Text description while call failed
headers : Dictionary
Optional SIP headers that was sent by Voximplant while call was rejected
CallRinging(String callId, Dictionary headers)
Called when Voximplant cloud sends RINGING SIP notificatoin via 'call.ring()' method. As response to that event client can play some "ringing" sounds or inform user about "createCall in progress" some other way
Arguments
callId : String
Call identifier, previously returned by the call() function
headers : Dictionary
Optional SIP headers that was sent by Voximplant as an argument to the 'call.ring()' method createCall
CallDisconnected(String callId, Dictionary headers)
Called after call is gracefully disconnected from the Voximplant cloud
Arguments
callId : String
Call identifier, previously returned by the call() function
headers : Dictionary
Optional SIP headers that was sent by Voximplant while disconnecting the call
CallConnected(String callId, Dictionary headers)
Called after call() method successfully established a createCall with the Voximplant cloud
Arguments
callId : String
Connected call identifier. It's same identifier returned by the createCall() function and it can be used in other function to specify one of multiple calls
headers : Dictionary
Optional SIP headers that was sent by Voximplant while accepting the call
ConnectionFailedWithError(String error)
Called if connect() failed to establish a Voximplant cloud connection
Arguments
error : String
Error message
ConnectionClosed()
Called after connection to Voximplant cloud is closed for any reason
ConnectionSuccessful()
Called after connect() successfully connects to Voximplant cloud
OneTimeKeyGenerated(String key)
Called after key requested with 'requestOneTimeKey' is requested and returned from the Voximplant cloud
Arguments
key : String
Key string that should be used in a hash for the 'loginUsingOneTimeKey'
LoginFailed(String error)
Called if login() call results in the failed login
Arguments
error : String
Failure reason
LoginSuccessful(String username)
Called if login() call results in the successful login
Arguments
username : String
Display name of logged in user
StartCall(String callId)
Called when you start call
Arguments
callId : String
Call identifier, previously returned by the call() function