Wednesday, 8 April 2015

Web RTC : Strongest Api of HTML5 Part -ii

Holla amigos In my last blog i shared the power of web rtc and the first api getUserMedia of the web Rtc . This article will be focus on the Peer to Peer connection of the Web Rtc. Let me explain you first what is Peer-to-Peer connection exactly is ? The P2P connection is communication between two browser (AKA peer) through stream. The stream can be video or audio.But for sending and receiving data it need a mechanism which we calls signaling in general.Peer to Peer connection does not provide the signaling or any signaling rule so here as a developer you have free hand to use any signaling method like SIP, XAMPP or any other.In my case i used Socket.io from the npm library on the node server. webRTC uses signaling for three purpose.
1. To get over the control on initialization or termination of communication.This signaling will send message to other node the request for the communication and a message about termination.
2. Network Config : Network configuration means my IP address. IP address is kind of unique thing which we all dev understand.
3. Media config : As we all know different browser have different support for codec.The resolution of machine also vary.So it is very important to be aware of the Browser capability of other end.
  1. var signalingChannel = createSignalingChannel();
  2. var pc;
  3. var configuration = …;
  4. // run start(true) to initiate a call function start(isCaller) {
  5. pc = new RTCPeerConnection(configuration);
  6. // send any ice candidates to the other peer
  7. pc.onicecandidate = function (evt) {
  8. signalingChannel.send(JSON.stringify({ “candidate”: evt.candidate }));
  9. };
  10. // once remote stream arrives, show it in the remote video element
  11. pc.onaddstream = function (evt) {
  12. remoteView.src = URL.createObjectURL(evt.stream);
  13. };
  14. // get the local stream, show it in the local video element and send it
  15. navigator.getUserMedia({ “audio”: true, “video”: true }, function (stream) {
  16. selfView.src = URL.createObjectURL(stream);
  17. pc.addStream(stream);
  18. if (isCaller)
  19. pc.createOffer(gotDescription);
  20. else
  21. pc.createAnswer(pc.remoteDescription, gotDescription);
  22. function gotDescription(desc) {
  23. pc.setLocalDescription(desc);
  24. signalingChannel.send(JSON.stringify({ “sdp”: desc }));
  25. }
  26. }); }
  27. signalingChannel.onmessage = function
  28. (evt) {
  29. if (!pc)
  30. start(false);
  31. var signal = JSON.parse(evt.data);
  32. if (signal.sdp)
  33. pc.setRemoteDescription(new RTCSessionDescription(signal.sdp));
  34. else
  35. pc.addIceCandidate(new RTCIceCandidate(signal.candidate)); };
The above code is from w3c werking draft.So what is exactly happening here.
When A want to communicate with B.A create an onicecandidate and send it to the B through signaling protocall. When B receive the signal it calls addIceCandidate and add remote server description.Now the peer connection has been created. The browser capability of the media handling also needed to be share among the peer.So A createOffer() and add the call setLocalDescription .One thing is important here the P2P connection does not start collecting data before setLocalDescription(). The reason behind this is the number of rules are there on each SDP line.Finally the setRemoteDescription() add the description of the remote node on the SDP.
This is it for this blog. Adios for now.
For such more Blogs you can visit to http://findnerd.com/NerdDigest

Tuesday, 7 April 2015

Cost of a bug

Suppose you do a typo, a simple spelling mistake in your code. What is the cost of the bug?
If it is caught:
  • at development environment - 1 min of developer's time
  • at code review - Reviewer's time and developer's time .
  • at testing environment - Build time, tester's time, developer's time.
  • at staging environment - Tester's time, developer's time, testing environment build and re-test time, staging environment build and re-test time.
  • at production environment - Tester's time, developer's time, testing environment build and re-test time, staging environment build and re-test time, production environment build and re-test time, bad name in the memory of users who has already noticed the typo.
  • by client - Start preparing for another project/job.

Think about it!!!!

- For such more Blogs you can visit to http://findnerd.com/NerdDigest

Monday, 6 April 2015

Unsharp Mask Filter

This video tutorial may help you to understand the functionality of unsharp mask filter. Unsharp Mask filter, adjusts the contrast of the edge detail and creates the illusion of a more focused image.

Sunday, 5 April 2015

How to open and close div using css



Hello! readers,
There is an example to show a div on click using only css. You can use it as popup box also.

--css--

copytext

     .show , .hide{color:#FC6}
      #contain {display: none; border:1px solid #999;padding:10px;width:200px;margin-top:10px}
      .show:focus + .hide {display: inline; }
      .show:focus + .hide + #cont {display: block;}

--html--

       <div>
            <a href="#show" class="show">Show</a>
            <a href="#hide" class="hide">Hide</a>
            <div id="contain">
                This is hidden text
            </div>
       </div>

For such more blogs kindly visit to http://findnerd.com/NerdDigest/

CSS3 Pseudo-elements

Hello readers !

In this blog i'll explain what is Pseudo-elements and how can we use it.

What is pseudo-classes ?

- Pseudo-classes are some special classes which are used to for special effect.
You can also use it with css class.
For example:-

selector:pseudo-element {property:value;}
There are some example of pseudo-element

:visited - (eg- a:visited)You can select all visited anchor tag

:link - You can select all unvisited anchor tag

:hover - You can select mouse over anchor tag

:active - You can select active anchor tag

:focus - You can select input element which one is focused

:first-line - (eg- p:first-line)- You can select first line of all paragraph

:first-letter (eg- p:first-letter)- You can select first letter of all paragraph

:first-child - (eg- li:first-child)- You can select first child of its parent

:after - (eg- li:after)- You can add some content after all lis.

:before - (eg- li:before)- You can add some content (as image also) before all lis.

:lang(language) - You can select every element with same lang attribute
Some other example of pseudo-element

element:nth-child(an + b) { style properties }

tr:nth-child(even) - You can select the even rows of a HTML table.

tr:nth-child(odd) - You can select the odd rows of a HTML table.

tr:nth-child(2n) - You can select the even rows of a HTML table.

tr:nth-child(2n+1) - You can select the odd rows of a HTML table.

span:nth-child(0n+1) - You can select a span element which is the first child of its parent;

this is the same as the :first-child selector.

span:nth-child(1) - You can select Equivalent to the above.

span:nth-child(-n+3) - Matches if the element is one of the first three children of its parent

and also a span.

For such more Blogs you can visit to http://findnerd.com/NerdDigest

Thursday, 2 April 2015

THE BASIC STRUCTURE OF THE PAGE



        <html><br>
        <head><br>
        <title>My Home Page</title><br>
        </head><br>
        <body><br>
        <h1>This is a heading</h1><br>
        <p>Document description goes here.....</p><br>
        </body><br>
        </html><br><br>

    HTML files have a basic structure that you MUST work within. HTML files are text files

which contain the code of a web page.HTML is a format that tells a computer how to display a

web page.
    The documents themselves are plain text files with special "tags" or codes that a web

browser uses to interpret and display information on your computer screen. The text/bracket

combinations are called tags.
    Note they come in pairs. There is always a beginning tag () and an end tag (). The

beginning tag signals Netscape / Internet Explorer that a new tag/task is starting. The end

tag tells Netscape / Internet Explorer that the tag/task has ended. Save the above file to the

desk top of your computer as: home.html. Make sure to add the extension ".html" to the end of

the file.For such more Blogs just visit the link-http://findnerd.com/NerdDigest/

Wednesday, 1 April 2015

Adding tooltip on a div using built-in ellipsis

Here is a way of adding tooltip on a div using built-in ellipsis

copytext

    $('.mydiv')
        .bind('mouseenter', function () {
        var $this = $(this);
        if (this.offsetWidth < this.scrollWidth && !$this.attr('title'))
            $this.attr('title', $this.text()); });

For more Details Kindly visit http://findnerd.com/NerdDigest