Advertisement
powerponch

11/09/2015: my jsSIP script

Sep 11th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. function registerUA() {
  2.  
  3. console.log("Iniciando creación del UA SIP....");
  4.  
  5. //Configuración de conexión
  6. var configuration = {
  7. uri: "sip:1001@"+webserver,
  8. password: xxxx,
  9. ws_servers: "ws://"+webserver+":8088/asterisk/ws",
  10. display_name: "UA WebRTC",
  11. authorization_user: null,
  12. register: null,
  13. register_expires: null,
  14. no_answer_timeout: null,
  15. trace_sip: true,
  16. stun_servers: null,
  17. turn_servers: null,
  18. use_preloaded_route: null,
  19. connection_recovery_min_interval: null,
  20. connection_recovery_max_interval: null,
  21. hack_via_tcp: null,
  22. hack_ip_in_contact: true
  23. };
  24.  
  25. //Registrar el softphone
  26. ua = new JsSIP.UA(configuration);
  27. ua.start();
  28. }
  29.  
  30. ////////////////////////////////////////////////////
  31. //Hace una llamada al número en el cuadro de texto//
  32. ////////////////////////////////////////////////////
  33. function callAsterisk() {
  34. console.log("Intentando hacer una llamada ....");
  35.  
  36. var numTel = document.getElementById('txtNumero').value;
  37. console.log(numTel);
  38.  
  39. //DOM de contenedores de video
  40. var myMultimedia = document.getElementById('myMultimedia');
  41.  
  42. var theirMultimedia = document.getElementById('theirMultimedia');
  43.  
  44. // Register callbacks to desired call events
  45. var eventH = {
  46. 'progress': function (e) {
  47. console.log('LLAMADA EN PROGRESO ...........');
  48. },
  49. 'failed': function (e) {
  50. console.log('LA LLAMADA FALLÓ DEBIDO A: ' + e.data.cause);
  51. },
  52. 'ended': function (e) {
  53. console.log('YA TERMINÓ LA LLAMADA: ');
  54. },
  55. 'confirmed': function (e) {
  56. local_stream = session.connection.getLocalStreams()[0];
  57. console.log('LLAMADA CONFIRMADA');
  58. console.log(local_stream);
  59. // Attach local stream to selfView
  60. //myMultimedia = JsSIP.rtcninja.attachMediaStream(myMultimedia, local_stream);
  61. console.log(local_stream);
  62. },
  63. 'addstream': function (e) {
  64. remote_stream = e.stream;
  65. console.log('FLUJO REMOTO RECIBIDO');
  66. console.log(remote_stream);
  67. // Attach remote stream to remoteView
  68. theirMultimedia = JsSIP.rtcninja.attachMediaStream(theirMultimedia, remote_stream);
  69. console.log(remote_stream);
  70. }
  71. };
  72.  
  73.  
  74. //parámetros de la llamada
  75. var options = {
  76. 'eventHandlers': eventH,
  77. 'mediaConstraints': {
  78. 'audio': true,
  79. 'video': false
  80. }
  81. };
  82.  
  83. //Llamando
  84. session = ua.call('sip:' + numTel + '@'+webserver, options);
  85. console.log("Marcando ....");
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement