An advanced ApiRTC call
This part is almost identical to the first example, except that we also include jQuery in order to manage our buttons.
The initialization still has to be done, just as in the previous example.
For clarity, we use a named function for onReady parameters : sessionReadyHandler. This will be the executed sessionReadyHandler() function.
Session object is defined in ApiCC library: ApiCCSession.
Adding audio & video support – WebRTC Support
As in example 1, WebRTC support on your application is added by a webRTCClient creation on your session. This is done on the onReady function handler “sessionReadyHandler” as a session needs to be established before webRTCClient creation.
The only difference is that in this case, we don’t provide any command div descriptor as it will be managed on Web side. In order to be able to get call state of your phone and be able to customize our command buttons, we will add events listeners before the webRTCClient creation.
Associated handlers to theses events listeners have to be defined : In incomingCallHandler(), we add a new event listener on “remoteHangup” to be informed when the other person of the call hangs up. In this example we then modify the buttons appearance, enabling one and disabling the other.
In userMediaErrorHandler(), we are informed that the user has not granted access to the media so we modify again the buttons activation.
In remoteHangupHandler(), we are informed that the other person hung up the phone, so we modify the buttons activation if it was the latest established calls (several simultaneous calls are possible on a conference use case).
The last bits of code to add, in order to finish a complete phone, are the functions executed when the user clicks on our buttons.
On “call” button click : we execute the call() function of our webRTCClient in order to call the number present in the input element and we also modify the buttons activation.
On “hangup” button click : we execute the hangUp() function of our webRTCClient in order to hangup all the established calls and we modify buttons activation.
WebRTC Client object is defined in ApiCC library: ApiCCWebRTCClient.
Complete description of all available features are included in the API description. For instance to set the media routing mode to turn, you simply have to use setMediaRoutingMode() function.