Monday, March 23, 2015

Now Webrtc SIP Client works on IE and Safari | Temasys Plugin Integration with JSSIP

Temasys Plugin Integration with JSSIP


Plugin Required to Install On Client system:- Temasys Webrtc Plugin v0.8.826


Update Exist WEBRTC Code to Use this Plugin:-

1) Need to attach adapter.js provided by Temasys.

2) Need to add code on start of the script to get media using Temasys Plugin:-.

var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
// At least Safari 3+: "[object HTMLElementConstructor]"
var isChrome = !!window.chrome && !isOpera; // Chrome 1+
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6

if(isSafari || isIE)
{
AdapterJS.onwebrtcready = function(isUsingPlugin) {
// The WebRTC API is ready.
//isUsingPlugin: true is the WebRTC plugin is being used, false otherwise
getUserMedia(constraints, successCb, failCb);
};
}


3) Need to update gui.js script:-

case "trying":
call.removeClass();
call.addClass("call trying");
status_text.text(description || "trying...");

// unhide HTML Video Elements
//$('#remoteView').attr('hidden', false);
//$('#selfView').attr('hidden', false);

// Set background image
//$('#remoteView').attr('poster', "images/logo.png");

// Hide DTMF box.
dtmf_box.hide();
break;

---------------------------------------------------------------------------------------------------------

call.on('started',function(e){
//Attach the streams to the views if it exists.
if ( call.getLocalStreams().length > 0) {
if(isSafari || isIE)
{
attachMediaStream(selfView, call.getLocalStreams()[0]);
}
else
{
selfView.src = window.URL.createObjectURL(call.getLocalStreams()[0]);
}
//selfView.src = window.URL.createObjectURL(call.getLocalStreams()[0]);
selfView.volume = 0;
}

if ( call.getRemoteStreams().length > 0) {
if(isSafari || isIE)
{
attachMediaStream(remoteView, call.getRemoteStreams()[0]);
}
else
{
remoteView.src = window.URL.createObjectURL(call.getRemoteStreams()[0]);
}
//remoteView.src = window.URL.createObjectURL(call.getRemoteStreams()[0]);
}

GUI.setCallSessionStatus(session, 'answered');
});



Plugin Guide Link:- https://temasys.atlassian.net/wiki/display/TWPP/WebRTC+Plugins

Saturday, February 28, 2015

MySql Query to find longest matching prefix

SELECT num_prefix FROM nums
  WHERE '12684041234' LIKE CONCAT(num_prefix,'%')
  ORDER BY num_prefix DESC
  LIMIT 1
;

Friday, February 6, 2015

Set ulimit To Increase Concurrent Call On Asterisk.

Increase the number of file descriptors (FDs) ie. “Max number of open files” using ulimit command to allow asterisk to handle more than 200 concurrent calls

To increase FDs permanently, go to /etc/security/limits.conf
root             soft   nofile          20000
root             hard   nofile          25000

Reboot your system and check the limits
#ulimit –n    It returns SOFT limit
#ulimit –n –H   It return HARD limit

You also have to use ‘ulimit –n <number of FDs>’ in asterisk startup script

#vi /etc/init.d/asterisk

                -------

                ---------

                                                ulimit –n 20000

                                                /usr/sbin/asterisk

It is always a good idea to check if your asterisk process is really using the ulimit specified by you or not. You can check that by looking into the process itself.  Check the field ‘Max Open Files’.

                #cat /proc/`pidof asterisk`/limits

Note:  `pidof asterisk` returns PID(Process ID) of asterisk



Two SIP listening ports for single Asterisk

There is no way to make a single instance of Asterisk listen on multiple ports. However, you can use an iptables REDIRECT to achieve the same functionality.
To redirect a single port with iptables:

 iptables -t nat -A PREROUTING -i eth0 -p udp --dport 5062 -j REDIRECT --to-ports 5060
 
 
This example redirects UPD port 5062 to port 5060, which effectively allows Asterisk to listen on both of them.
Remember to save the rule so that it would survive a reboot:


/etc/init.d/iptables save

 

Asterisk Patch To Stop Calling externnotify On VoicemailMain

Go to asterisk source code apps folder then

Patch On app_voicemail.c module:-

Comment run_externnotify(vmu->context, vmu->mailbox, NULL); on vm_execmain() function

Then make and make install your asterisk source.

Tuesday, January 7, 2014

How to Convert wav file to ulaw for asterik.

Create convert.sh file, which content:-

#!/bin/bash
for f in *.wav
do
OUTF=`echo "$f" | sed s/\.wav$/.ulaw/g`
echo $OUTF
sox -V $f -r 8000 -c 1 -t ul -w $OUTF
done

rm -rf *.wav

rm -rf *.sh

Just copy paste this Script in your wav files folder.

and open termnal go in your wav files folder using cd command.

and run this script use this command "sh convert.sh".

then all converted files are available in your wav file folder.

Convert Wav File to Asterisk GSM file format.

Create convert.sh file, which content:-

#!/bin/bash
for f in *.wav
do
OUTF=`echo "$f" | sed s/\.wav$/.gsm/g`
echo $OUTF
sox -V $f -r 8000 -c 1 $OUTF resample -ql
done

rm -rf *.wav

rm -rf *.sh

Just copy paste this Script in your wav files folder.

and open termnal go in your wav files folder using cd command.

and run this script use this command "sh convert.sh".

then all converted files are available in your wav file folder.