Wednesday, November 26, 2014

Google's webRTC AECM for Android Mobile devices in C++

Now a days many of mobile devices comes with built-in hardware echo canceler.  But the low end devices that cost little doesn't have this feature integrated. And moreover the previous older android devices doesn't have the echo canceler. In my journey of echo cancellation I have came across a valuable library that will do everything for you , if you provide it the necessary gasoline .

I have tested this echo canceler tool with my HTC desire 610. Which is pretty cheap and doesn't have any built-in hardware echo canceler.  I have designed an algorithm for capture and playback, which uses ring-buffer, calculate the delay and use the webRTC aecm modules API.

Here we go --


    Set the clock cycle rate.
    Set the echo tail length.
    Set the channel count.
    Set the byte per sample. // it's 2 byte per sample


    Calculate sample per frame.
           sampleperframe = byte per sample * (clock cycle rate) / 100

    Set the output latency. // device play-out latecny

    Calculate the frame play delay.
            frameplaydelay = output latency * 3 / 4

    Initiate the webRTC echo module with clock cycle rate.

        Calculate Audio Play time.
            ptime = sampleperframe * 1000 / clock cycle rate

    Calculate latency buffer size.   
            lateframecount = frameplaydelay / ptime

    Add these late frame in latency buffer with filling demo audio data (with zero).


        Store the played frame in the delay buffer (it will be a FIFO ringbuffer
        with your estimated size).

        Now need to remove the demo frame from latency buffer and add real frame
        to the latency buffer.       
        if the latency buffer not filled with real data
                fetch the data from delay buffer and add it to the latency buffer
                and remove it from delay buffer.
            nothing to do.

        if latency buffer not full with real playe frame data
                nothing to do.

            fetch the data from latency buffer and do the echo cancellation by
            setting this frame as far-end and current capture data as the input.
            remove the used frame data from latency buffer.
            if the delay buffer is not empty
                    fetch the frame data from delay buffer and add it to the
                    latency buffer.

                store a demo frame in the latency buffer. 


Wednesday, October 29, 2014

Make CentOS 6.x an AD member of Windows IIS 2012 R2

Making a CentOS 6.x PC a domain member of an active directory is a tiresome work. I came across this painful task for several time and comes in a conclusion that atleast I will make a document which will be helpful to me in near future. On the meantime if anybody take this step for their use, I wouldn't mind.

So I will go to the task step now --

i) First of all we need some basic (latest) software for making this task possible.
They are --

1. Samba
2. Samba-client
3. Samba-winbind
4. Krb5-workstation
5. Policycoreutils-python

command for the task on console --

yum install -y ntpdate samba samba-client samba-winbind krb5-workstation policycoreutils-python

  ii) Now it's time to make the windows active directory reachable from the centos PC. For that we need to add the active directory FQDN and IP address on resolv.conf

So do it by opening file  /etc/resolv.conf and add the following --

    domain ad.local

if ad.local is pingable from console then our work is done for resolving AD.

 iii) Now we need to sync the time of AD and CentOS PC, so that they can authenticate in kerborus mechanism. It can be done by following --

crontab -e
Now add the following on the opening file --

 0 */4 * * * /usr/sbin/ntpdate >/dev/null 2>&1

Now synchronize the time by --

 We will see the synced time and date on console.

iv) Now we ned to edit the samba configuration file --

    workgroup = AD
    server string = Samba Server Version %v
    security = ads
    realm = AD.LOCAL
    domain master = no
    local master = no
    preferred master = no
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072
    use sendfile = true
    idmap config * : backend = tdb
    idmap config * : range = 100000-299999
    idmap config AD : backend = rid
    idmap config AD : range = 10000-99999
    winbind separator = +
    winbind enum users = yes
    winbind enum groups = yes
    winbind use default domain = yeswhen I again have the same issue.
    winbind nested groups = yes
    winbind refresh tickets = yes
    template homedir = /home/%D/%U
    template shell = /bin/bash
    client use spnego = yes
    client ntlmv2 auth = yes
    encrypt passwords = yes
    restrict anonymous = 6
    log file = /var/log/samba/log.%m
    max log size = 50    

v) Edit krb5.conf file for authentication --

    default = FILE:/var/log/krb5libs.log
    kdc = FILE:/var/log/krb5kdc.log
    admin_server = FILE:/var/log/kadmind.log
    default_realm = AD.LOCAL
    ticket_lifetime = 24h
    forwardable = yes
    pam = {
    debug = false
    ticket_lifetime = 36000
    renew_lifetime = 36000
    forwardable = true
    krb4_convert = false
           .ad.local = AD.LOCAL 
            ad.local = AD.LOCAL

vi) Now we update nss configuration file by opening file  /etc/nsswitch.conf .

    passwd: files winbind
    group: files winbind
 We are done.

vii) It's the last step to make centos an AD member of a windows system. Lets over with it by --

 net ads join -U administrator

Will ask for password. Give it and viola!!



Thursday, August 21, 2014

[ffmpeg] ffmpeg-2.2 patch for relocation R_X86_64_PC32 against symbol error


ffmpeg-2.2 patch for relocation R_X86_64_PC32 against symbol error when compile in x64-bit

Patch Link:

Download: V1.0

Scope of Issue:

When ffmpeg is built for static library and this compiled static library is linked with another dynamic library then the final linking failed with error --

ffmpeg/libavcodec/libavcodec.a(xx_yyyy.o): relocation R_X86_64_PC32 against symbol `ff_xx_yy_zz_qq' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status


x64-bit Linux, Unix, may be windows 64-bit

How to fix:

Use the ffmpeg-2.2.patch in your FFmpeg-n2.2 release source.

How to apply patch:

  1. Copy the downloaded patch to your FFmpeg-n2.2 folder.
  2. Test the patch compatibility with your ffmpeg source by --
patch --dry-run -p1 -i  ffmpeg-2.2.patch
giving this command inside your ffmpeg source folder.
  1. If the test returns no fail patch file then you are good to patch.
  2. Now patch by following command --
patch -p1 -i ffmpeg-2.2.patch
  1. Now enjoy linking with your any other project library !!
Note: I am not in blame for any other issue and any other copyright law , if ffmpeg have any for this. This is only a remedy for the group who suffers from this compilation errors.

Wednesday, August 13, 2014

[eAskGitHub]Simple C++ console for all github repo release API


Simple console for all github repo release API.


It is a c++ application with a binary. It is created to make the life simple for github repository API user. It uses curl.


1. It can receive any lenght of response from github.
2. It has it's own simple JSON parser method.
3. It is powerfull tool to know your github release download count.
4. Makefile application.


1. Need libcurl.
2. Need Centos/Linux.
3. Not tested with windows(Hopefully it will work after windows curl library installation).


1. Implement every API of [GitHub API](


In console just give command -


Then just follow the hints available on console or answer the querry.

Test Result:


Welcome to github metadata fetcher eAskGitHub v1.0 !!
It's a very simple command line app who will try to
fill your all want for github metadata(THE API).

Please enter github username: robelsharma
Please enter your one repository name: videoconference
Your querry Succeeded :)
Project Title:=>  Chat and Video call simultaneously
Creators' Login Name:=>  robelsharma
User Privilege:=>  User
Are you an Admin for this site?:=> No
Create Date:=>  2014-08-09T08:04:29Z
Publish Date:=>  2014-08-09T08:15:36Z
Project Binary:=>
Uploader Login Name:=>  robelsharma
User Privilege:=>  User
Are you an Admin for this site?:=> No
Binary Package Type:=>  application/zip
|Downloaded: 6 times|
Create Date:=>  2014-08-11T05:50:48Z
Binary Package updated at:=>  2014-08-11T05:50:54Z
Download Link:=>

Want to continue ?(y/n):n

Friday, August 8, 2014

Jabsimul with SASL Integration is a benchmarking tool for Jabber/XMPP Servers which have SASL authentication


Jabsimul with SASL Integration is a benchmarking tool for Jabber/XMPP Servers which have SASL authentication.
It also has the support for *starttls*.

Special Note:

The SASL and starttls implementation is mine. Other than this project is not mine.


I have implemented the protocol named XEP-0034: SASL Integration.

Extra Feature:

Other then jabsimul benchmark feature it has the extra feature of XMPP SASL authentication. I have enabled the SASL plain mechanism of authentication for xmpp login.

With that now you can have the benchmark of jabsimul with SASL authentication.

As list:

1. Implemented “XMPP TLS” from
2. Implemented “SASL AUTH” from

Source code is available in here .


First start a TCP connection to the XMPP server. Then convert this TCP connection to TLS with *starttls* schema request.
Then select the *SASL* auth mechanism and start the the XMPP communication with TLS. The TLS connection holds when the SASL mechanism complete a successful handshake.

1. Protocol Messaging Details with sequence -


<stream:stream to="" xmlns="jabber:client" xmlns:stream="">


<stream:stream xmlns:stream='' xmlns='jabber:client' id='ojTsAaoSvVKdKfmW' from=''  version='1.0'>
  <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required/></starttls>
  <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">

<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>

<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>

Implementation details are available [here](

How To's:

cd jabsimul/jab_simul/
vi jab_simul.xml

Change *<server>jabber.localhost</server>* to your XMPP server address. Fill the xml file with you necessary configuration.

Compile it:


Now you can execute it:


Wednesday, May 28, 2014

[WebRTC] Overview and analysis of webRTC media transmission and security with DTLS-SRTP Part - 1

What is webRTC?

WebRTC is an API definition being drafted by the World Wide Web Consortium to enable browser-to-browser applications for voice calling, video chat, and P2P file sharing without plugins.

In short webRTC make you independent from any messenger type application/plug-in that you need to use for a audio/video call.

Call Mechanism in WebRTC:  

Call Attributes:
  • Signaling (SIP/XMPP/Other)
  • ICE (ICE LITE rfc5245)
  • DTLS
  • SRTP
  • PCMU/OPUS for Audio
  • VP8 for Video

This  attribute is necessary for advertising someones' SDP or ICE-Candidate to remote buddy for a call. This can be done by many IETF standard protocol such as - SIP, XMPP or any other protocol.


Lite ice is a must for webRTC. Because lite ice support aggressive nomination of ice candidate selection. Which enable a call more faster then any other call. Because the endpoint doesn't need to wait for all the ICE check completion before sending any media. This enables less handshake and early media technique.


DTLS is a transport layer security over datagram (UDP). Its' basically used for SRTP key and certificate negotiation between 2 clients. It is specified on webRTC standard that the SRTP SDES key that are transmitted over websocket is less secure then DTLS SRTP key negotiation. Because in DTLS negotiation SRTP keying material is collected in the time of negotiation and after a certificate fingerprint verification.     

In webRTC call mechanism with SDP a certain other attribute called a=fingerprint: is negotiated with SDP.

o=Mozilla-SIPUA-27.0.1 25262 1 IN IP4
s=Robel Sharma - firefox
t=0 0
a=fingerprint:sha-256 28:99:57:E4:CE:6F:C6:E4:A2:21:A6:9E:9C:52:EA:A3:FE:99:01:8C:68:31:8B:C3:83:16:3A:92:37:C8:5B:24
m=audio 52345 UDP/TLS/RTP/SAVPF 109 101

This finger print  attribute contain the sha-256 fingerprint value of a valid certificate. Later this value is used for verification.

Tuesday, March 18, 2014

[CENTOS] How to take screen shot on Centos 6.x

ISSUE: Screen shot is a necessary part of developers life. So you must know how to take screen shot in any OS. When taking screen shot by "Prnt Scrn" button centos give error like -

There was an error running "gnome-screenshot":
Failed to execute child process "gnome-screenshot" (No such file or directory).

Fix: This issue arise due to gnome util's  unavailability. So just install it by yum as a root -

yum install gnome-utils

and enjoy screening.

[SOCKET] On udp recvfrom peer address return

ISSUE: When using udp socket it is necessary to know the remote peer address from where the data is received. In future this can be used for sending and tracking messages. If you are ICE or STUN ,TURN developer then its a must.

char recv_data[1024];
int sin_size;
struct sockaddr_in remote_addr;
int bytes_recv = recvfrom(mySock, recv_data,1024,0,(struct sockaddr *)&remote_addr,(socklen_t*)&sin_size);

printf("got packet from IP:Port :: %s:%d\n",inet_ntoa(remote_addr.sin_addr), ntohs(remote_addr.sin_port));  

In receiving data which returns remote port and IP as

Fix: Its happen because the sin_size is not initialize as it takes garbage bellow from system. So just initialize the sin_size will fix that.

 sin_size = sizeof(remote_addr);

So enjoy socket programming :)

Thursday, March 13, 2014

[Asterik] configure: WARNING: *** Please install the SQLite3 development package. on Asterik

ISSUE: Asterik need SQLITE3 , when it doesn't find this then shows the following warnings -

configure: WARNING: *** Asterisk now uses SQLite3 for the internal Asterisk database.
configure: WARNING: *** Please install the SQLite3 development package.
And the configure fails.


yum install sqlite, sqlite-devel

And you are done.

[ASTERIK] configure: error: *** uuid support not found (this typically means the uuid development package is missing)

ISSUE: Build error on Asterik , when you want test webrtc feature :)

checking for uuid_generate_random in -luuid... no
checking for uuid_generate_random in -le2fs-uuid... no
checking for uuid_generate_random... no
configure: error: *** uuid support not found (this typically means the uuid development package is missing)

Fix: This issue arises due to missing of UUID generator specified by rfc4122 .


sudo apt-get install uuid-dev 

yum -y install libuuid-devel

Asterik comes with lots of helpful script available on - asterisk/contrib/scripts/ folder of your ASTERIK source.

So just use the following command on UNIX console to run the asterik pre-requisite script.

contrib/scripts/install_prereq install

And you are done! configuring.

Now --

Make Asterik.

Tuesday, February 11, 2014

[My fun] with webrtc for websocket support in SIP server.

I have started to play around with webRtc. My first work is to implement websocket support in our existing SIP server of our company. Which is going public right now as named as SIP.ANYFIREWALL.COM. One of our company's webrtc support is allready running on cloud for TURN/STUN or as Relay server. This can be found on TURN.ANYFIREWALL.COM .

So I have implemented the Web SIP support (WebSocket with SIP protocol support) and seen some interesting output when I tested it 's webrtc client. I feel pleasure to say that it's working fine when I tested some Video call.

So feel free to test your websocket SIP client with our Web SIP server when it goes public. :)

Our Test Result:

Thursday, January 9, 2014

Another MySQL daemon already running with the same unix socket in centos

Issue: When using mysql in centos and System got rebooted or restarted for some reason this issue arise.


Just give the following command

mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.old
service mysqld start