<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[VideolinkPlatform Blog]]></title>
  <link href="http://videolinkplatform.com/atom.xml" rel="self"/>
  <link href="http://videolinkplatform.com/"/>
  <updated>2015-06-11T16:53:41+02:00</updated>
  <id>http://videolinkplatform.com/</id>
  <author>
    <name><![CDATA[Your Name]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Is it time for WebRTC 2.0?]]></title>
    <link href="http://videolinkplatform.com/is-it-time-for-webrtc-2-dot-0"/>
    <updated>2015-06-11T00:00:00+02:00</updated>
    <id>http://videolinkplatform.com/is-it-time-for-webrtc-2-dot-0</id>
    <content type="html"><![CDATA[<p>WebRTC is already around for quite some time. Even though it’s hard to believe, first version of Chrome with WebRTC support (enabled by default) has been released almost 3 years ago. During all these years browser vendors have been trying to reach maximal compatibility with specification, and developers have been struggling with different implementations. We all were curious about big players’ reaction regarding new technology and when (or if) they are going to join the movement. But there were no doubts that sooner or later WebRTC will be supported everywhere.</p>

<p>So what do we have after 3 years of evolving? Well, the current situation is not so good as most of optimists expected. But at least, it’s more clear now what might happen in the future.</p>

<p>Browser vendors divided into 3 tribes:
 - those who already implemented WebRTC according to specification (at least enough to be compatible with others). Here we have Firefox and all Webkit based browsers, such as Chrome (including version for Android), Chromium and Opera.
 - Microsoft didn’t surprise anybody with idea to make it’s own, “better” WebRTC.
 - Apple has just ignored this “hipster” movement.</p>

<p>It doesn’t look good, does it? So how can companies deliver the software, which uses WebRTC, to their customers now?</p>

<p>Most of them decided to follow an easy way and just ask users to use Chrome or Firefox. Even though it sounds lame, that’s pretty smart solution, when taking into consideration latest browser usage statistics.</p>

<p style="text-align:center"><img width="500" src="https://dl.dropboxusercontent.com/u/178301/dont_remove/vlp-blog/chart.png" alt="WebRTC browsers statistics 2015" alt="WebRTC browsers statistics 2015"/></p>


<p>According to <a href="http://gs.statcounter.com/#desktop-browser-ww-monthly-201505-201506-bar">StatCounter</a> research (based on desktop users statistics), 70% of the market share belongs to the WebRTC supported browsers. Also we can assume that at least biggest part of other 30% users will be able to setup Chrome or FF, if needed. So actually, the situation is not that bad and it may have quite promising outcome.</p>

<p>From the other hand, WebRTC by itself isn’t a Holy Grail, but just a tool, which provides developers with the great power of bringing communication into their products. But here the important question pops-up: do the features (natively provided by WebRTC) cover all user needs?</p>

<p>Definitely no! So far most of WebRTC frameworks provide only video/audio calling with some interface for direct data transfers, but we believe this pause in evolution is just temporal.</p>

<p>The same way as old good Web became a basement for rich and talkative Web 2.0, WebRTC shall begin more advanced communication era — WebRTC 2.0. The number of features that can be built on top of WebRTC is only limited by human mind: file transfer, remote photo demonstration, presentations, Internet of Things etc. Peer-to-peer data transfers play key role here, since they take huge load out of service provider shoulders and eliminate high costs of keeping complicated infrastructure distributed around the globe. It cuts the price of service for end user as well.</p>

<p>WebRTC 2.0 will bring real life communication experience to web. For example, let’s imagine that during conversation you decided to show photos from last holiday to your friend. Important here is word <strong>“show”</strong>. It doesn’t mean sending bunch of files in zip, but showing picture by picture and telling the story at the same time. So as in real life conversation. Also it’s not a secret that with WebRTC we can transfer data directly (even without quality loss), securely, and provide synchronised demonstration. So in the end it will look like you are showing the photos in person. Here’s a short video trailer of such service prototype.</p>

<p align="center"><iframe width="853" height="480" src="https://www.youtube.com/embed/63YjilORXy0?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe></p>


<p>Amazing, right? And that’s only beginning! I believe, that Web can go further than just writing comments and chatting, especially when having such great technology in disposal. And since the Web is becoming more and more about communication, WebRTC can be good platform for a new era.</p>

<p>There are already some projects that built rich functionality on top of WebRTC: CDN networks, Internet of Things communication frameworks and even games (<a href="https://www.cubeslam.com">CubeSlam</a> is good example).</p>

<p>So the next years are going to be even more exciting!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Building Secure Peer-to-peer File Sharing with WebRTC]]></title>
    <link href="http://videolinkplatform.com/building-secure-peer-to-peer-file-sharing-with-webrtc"/>
    <updated>2015-01-28T00:00:00+01:00</updated>
    <id>http://videolinkplatform.com/building-secure-peer-to-peer-file-sharing-with-webrtc</id>
    <content type="html"><![CDATA[<p>One of the base features of WebRTC is an ability to transfer data between peers <strong>secure and on high speed</strong>. Data exchange is realized via Data Channel (also called RTCDataChannel) API.</p>

<p>Data channel is basically a one direction stream which is used to share data in peer-to-peer connection. For example during video call data is sent via <strong>2 channels</strong>: one for outgoing video stream and other for audio. Optionally we can create additional data channels (up to 65535 per connection), for instance to send file to other peers.</p>

<!-- more -->


<h3>How does it work?</h3>

<p>After establishing peer-to-peer connection, application creates at least one data channel to share video, audio or pure data. By default data channel uses SRTP (Secure Real-time Transport Protocol), which doesn&rsquo;t require packet retransmission, so stream continues as fast as connection permits; in the other side when we need to share reliable data like an image or a file, data channel can transport information through SCTP (Stream Control Transmission Protocol) which has control over packet retransmission and ordering. Both protocol works over UDP.</p>

<p><img src="https://dl.dropboxusercontent.com/u/178301/dont_remove/vlp-blog/datachannel-layers.png"></p>

<h3>Is that secure?</h3>

<p>Security is one of the most important topics in WebRTC, no matter which transport protocol we use, both implement DTLS (Datagram Transport Layer Security) to encrypt data, which is similar to SSL/HTTPS but for UDP instead of TCP.</p>

<h3>How can I use data channels without diving into WebRTC specification?</h3>

<p>Abstraction of data channels is <strong>already implemented in VideoLinkPlatform API</strong>, so you can only use simple API functions to transfer data directly between peers.</p>

<h3>tl;dr</h3>

<p><strong>RTC data channel</strong> provides the way to share data in peer-to-peer connection. All data is sent over UDP (which makes communication fast) and depending on kind of data we need to share, channel will transport everything over SRTP or SCTP. First one doesn&rsquo;t require packet retransmission when a packet is lost, which is useful when we need to share a video or audio stream (so <strong>realtime</strong> is more important than <strong>reliability</strong>), when the other protocol (SCTP) guarantees data delivery by requesting packet retransmission (when needed) and keeps ordering, so is useful when all packets <strong>must</strong> be received in the <strong>same order</strong> they were sent (for example file transmission).</p>

<p>Data channels are supported by almost all modern browsers and VideoLinkPlatform API provides a simple way to use them as well as seamless fallback for old ones.</p>

<h3>Let’s make simple javascript web app that will provide peer-to-peer file sharing via WebRTC</h3>

<p><img src="https://dl.dropboxusercontent.com/u/178301/dont_remove/vlp-blog/sample-file-sharing.png"></p>

<p>First let&rsquo;s make sure to have VideoLinkPlatform JS SDK included into your page</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'><span class="nt">&lt;script </span><span class="na">src=</span><span class="s">&quot;//cdn.videolinkplatform.com/vl_api.js&quot;</span><span class="nt">&gt;&lt;/script&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Then you need to initialize connector object with <a href="http://videolinkplatform.com/prices.html">own API key</a> and desired connection type (which determines what kind of data we’re going to work with). All available  parameters can be found in <a href="http://videolinkplatform.com/apidocs.html#VideolinkPlatformConnector">documentation</a>.</p>

<p>Connector object establishes connection to <em>VideolinkPlatform Signaling Cloud</em> and provides API for managing rooms.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='js'><span class='line'><span class="k">new</span> <span class="nx">VideolinkPlatformConnector</span><span class="p">({</span>
</span><span class='line'>  <span class="nx">apiKey</span><span class="o">:</span> <span class="s1">&#39;&lt;your API key&gt;&#39;</span><span class="p">,</span>
</span><span class='line'>  <span class="nx">connectionType</span><span class="o">:</span> <span class="s1">&#39;chat-only&#39;</span>
</span><span class='line'><span class="p">},</span> <span class="kd">function</span> <span class="nx">success</span><span class="p">(</span><span class="nx">connector</span><span class="p">){...},</span> <span class="kd">function</span> <span class="nx">failure</span><span class="p">(</span><span class="nx">error</span><span class="p">){...})</span>
</span></code></pre></td></tr></table></div></figure>


<p>Constructor takes  success callback as second argument, that will receive initialized connector when it’s ready. As soon as we get connector object we can create a room:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='js'><span class='line'><span class="nx">connector</span><span class="p">.</span><span class="nx">createRoom</span><span class="p">({</span><span class="nx">name</span><span class="o">:</span> <span class="s1">&#39;file-share&#39;</span><span class="p">},</span> <span class="kd">function</span><span class="p">(</span><span class="nx">room</span><span class="p">){</span>
</span><span class='line'>  <span class="nx">vlpRoom</span> <span class="o">=</span> <span class="nx">room</span><span class="p">;</span> <span class="c1">//we can use object vlpRoom to access room API</span>
</span><span class='line'>  <span class="p">...</span>
</span></code></pre></td></tr></table></div></figure>


<p>All peers should join room with the same name (in our case &ldquo;file-share&rdquo;) to be able to exchange data.</p>

<p>Files are shared via <em>FileSharingService</em> which is also used to work with file sharing events and can be retrieved from room object:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='js'><span class='line'><span class="kd">var</span> <span class="nx">fileSharingService</span> <span class="o">=</span> <span class="nx">vlpRoom</span><span class="p">.</span><span class="nx">getFileSharingService</span><span class="p">();</span>
</span></code></pre></td></tr></table></div></figure>


<p>There are plenty number of events in the file sharing process (as you can see <a href="http://videolinkplatform.com/file-sharing.html">here</a>), but for this example we just need to handle <a href="http://videolinkplatform.com/file-sharing.html#onFileRequest">onFileRequest</a> and <a href="http://videolinkplatform.com/file-sharing.html#onDownloadCompleted">onDownloadCompleted</a>.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='js'><span class='line'> <span class="nx">fileSharingService</span><span class="p">.</span><span class="nx">onFileRequest</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">fileTransferId</span><span class="p">,</span> <span class="nx">name</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">if</span> <span class="p">(</span><span class="nx">confirm</span><span class="p">(</span><span class="s1">&#39;Would you like to download file: &#39;</span> <span class="o">+</span> <span class="nx">name</span><span class="p">))</span> <span class="p">{</span>
</span><span class='line'>      <span class="nx">fileSharingService</span><span class="p">.</span><span class="nx">acceptFileSharingRequest</span><span class="p">(</span><span class="nx">fileTransferId</span><span class="p">);</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>  <span class="p">});</span>
</span><span class='line'>  <span class="nx">fileSharingService</span><span class="p">.</span><span class="nx">onDownloadCompleted</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">fileId</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">fileData</span><span class="p">,</span> <span class="nx">type</span><span class="p">,</span> <span class="nx">mime</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>    <span class="nx">addDownloadedFile</span><span class="p">(</span><span class="nx">fileId</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">fileData</span><span class="p">,</span> <span class="nx">type</span><span class="p">,</span> <span class="nx">mime</span><span class="p">);</span>
</span><span class='line'>  <span class="p">});</span>
</span></code></pre></td></tr></table></div></figure>


<p>Now, when we have room and file sharing events configured, we just need to pass selected file to  fileSharingService.startFileSharing(file) to start sharing:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='js'><span class='line'><span class="kd">function</span> <span class="nx">sendP2PFile</span> <span class="p">(</span><span class="nx">file</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">if</span> <span class="p">(</span><span class="o">!!</span><span class="nx">vlpRoom</span><span class="p">){</span>
</span><span class='line'>    <span class="kd">var</span> <span class="nx">fileSharingService</span> <span class="o">=</span> <span class="nx">vlpRoom</span><span class="p">.</span><span class="nx">getFileSharingService</span><span class="p">();</span>
</span><span class='line'>    <span class="nx">fileSharingService</span><span class="p">.</span><span class="nx">startFileSharing</span><span class="p">(</span><span class="nx">file</span><span class="p">);</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>And that&rsquo;s it, we have our file sharing js app.</p>

<p>Here&rsquo;s full source code with some comments:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
<span class='line-number'>50</span>
<span class='line-number'>51</span>
<span class='line-number'>52</span>
<span class='line-number'>53</span>
<span class='line-number'>54</span>
<span class='line-number'>55</span>
<span class='line-number'>56</span>
<span class='line-number'>57</span>
<span class='line-number'>58</span>
<span class='line-number'>59</span>
<span class='line-number'>60</span>
<span class='line-number'>61</span>
<span class='line-number'>62</span>
<span class='line-number'>63</span>
<span class='line-number'>64</span>
<span class='line-number'>65</span>
<span class='line-number'>66</span>
<span class='line-number'>67</span>
<span class='line-number'>68</span>
</pre></td><td class='code'><pre><code class='js'><span class='line'><span class="nx">$</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>    <span class="c1">//We will save File Sharing Service to this variable as soon as room will be created</span>
</span><span class='line'>    <span class="kd">var</span> <span class="nx">fileSharingService</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>    <span class="cm">/**</span>
</span><span class='line'><span class="cm">     * This method is called by Drag&#39;n&#39;drop interface when user droped file into container</span>
</span><span class='line'><span class="cm">     * and receives selected files as argument.</span>
</span><span class='line'><span class="cm">     * (it can also be called when file is selected in &lt;input type=&quot;file&quot;&gt;)</span>
</span><span class='line'><span class="cm">     */</span>
</span><span class='line'>    <span class="kd">function</span> <span class="nx">sendP2PFile</span><span class="p">(</span><span class="nx">file</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>        <span class="k">if</span> <span class="p">(</span> <span class="o">!!</span> <span class="nx">fileSharingService</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>            <span class="nx">fileSharingService</span><span class="p">.</span><span class="nx">startFileSharing</span><span class="p">(</span><span class="nx">file</span><span class="p">);</span>
</span><span class='line'>        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
</span><span class='line'>            <span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;File Sharing Service is not ready yet&#39;</span><span class="p">);</span>
</span><span class='line'>        <span class="p">}</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>    <span class="cm">/**</span>
</span><span class='line'><span class="cm">     * Called by onDownloadCompleted event, to show info about downloaded file</span>
</span><span class='line'><span class="cm">     */</span>
</span><span class='line'>    <span class="kd">function</span> <span class="nx">addDownloadedFile</span><span class="p">(</span><span class="nx">fileId</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">fileData</span><span class="p">,</span> <span class="nx">type</span><span class="p">,</span> <span class="nx">mime</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>        <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#transmited-files&#39;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="s1">&#39;&lt;a target=&quot;_blank&quot; href=&quot;&#39;</span> <span class="o">+</span> <span class="nx">fileData</span> <span class="o">+</span>
</span><span class='line'>            <span class="s1">&#39;&quot; class=&quot;file-thumbnail col-sm-3&quot;&gt;&lt;i class=&quot;glyphicon glyphicon-file&quot;&gt;&lt;/i&gt; Open &#39;</span> <span class="o">+</span>
</span><span class='line'>            <span class="nx">name</span> <span class="o">+</span> <span class="s1">&#39;&lt;/a&gt;&#39;</span><span class="p">);</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>    <span class="cm">/**</span>
</span><span class='line'><span class="cm">     * Initialize connection to VideolinkPlatform Signaling Cloud and</span>
</span><span class='line'><span class="cm">     * establish text/data connection (so no video and audio stream will be sent)</span>
</span><span class='line'><span class="cm">     */</span>
</span><span class='line'>    <span class="kd">var</span> <span class="nx">vlpConnector</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">VideolinkPlatformConnector</span><span class="p">({</span>
</span><span class='line'>        <span class="nx">apiKey</span><span class="o">:</span> <span class="s1">&#39;58109df59af3c725f8ed0f2a0c65e341&#39;</span><span class="p">,</span>
</span><span class='line'>        <span class="nx">connectionType</span><span class="o">:</span> <span class="s1">&#39;chat-only&#39;</span>
</span><span class='line'>    <span class="p">},</span> <span class="kd">function</span><span class="p">(</span><span class="nx">connector</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>        <span class="cm">/**</span>
</span><span class='line'><span class="cm">         * Create room with name &quot;file-share&quot;. If room already exists we will just join it,</span>
</span><span class='line'><span class="cm">         * otherwise it will be created first.</span>
</span><span class='line'><span class="cm">         */</span>
</span><span class='line'>        <span class="kd">var</span> <span class="nx">roomName</span> <span class="o">=</span> <span class="s1">&#39;file-share&#39;</span><span class="p">;</span>
</span><span class='line'>        <span class="nx">connector</span><span class="p">.</span><span class="nx">createRoom</span><span class="p">({</span>
</span><span class='line'>            <span class="nx">name</span><span class="o">:</span> <span class="nx">roomName</span>
</span><span class='line'>        <span class="p">},</span> <span class="kd">function</span><span class="p">(</span><span class="nx">room</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>            <span class="cm">/**</span>
</span><span class='line'><span class="cm">             * Room is ready, so we can retrieve File Sharing Service and prepare to file transfer</span>
</span><span class='line'><span class="cm">             */</span>
</span><span class='line'>            <span class="nx">fileSharingService</span> <span class="o">=</span> <span class="nx">room</span><span class="p">.</span><span class="nx">getFileSharingService</span><span class="p">();</span>
</span><span class='line'>
</span><span class='line'>            <span class="cm">/**</span>
</span><span class='line'><span class="cm">             * This event is fired when remote peer initiates file transfer</span>
</span><span class='line'><span class="cm">             */</span>
</span><span class='line'>            <span class="nx">fileSharingService</span><span class="p">.</span><span class="nx">onFileRequest</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">fileTransferId</span><span class="p">,</span> <span class="nx">name</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>                <span class="k">if</span> <span class="p">(</span><span class="nx">confirm</span><span class="p">(</span><span class="s1">&#39;Would you like to download file: &#39;</span> <span class="o">+</span> <span class="nx">name</span><span class="p">))</span> <span class="p">{</span>
</span><span class='line'>                    <span class="nx">fileSharingService</span><span class="p">.</span><span class="nx">acceptFileSharingRequest</span><span class="p">(</span><span class="nx">fileTransferId</span><span class="p">);</span>
</span><span class='line'>                <span class="p">}</span>
</span><span class='line'>            <span class="p">});</span>
</span><span class='line'>
</span><span class='line'>            <span class="cm">/**</span>
</span><span class='line'><span class="cm">             * This event is fired when download is completed and we can show file info</span>
</span><span class='line'><span class="cm">             */</span>
</span><span class='line'>            <span class="nx">fileSharingService</span><span class="p">.</span><span class="nx">onDownloadCompleted</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">fileId</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">fileData</span><span class="p">,</span> <span class="nx">type</span><span class="p">,</span> <span class="nx">mime</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>                <span class="nx">addDownloadedFile</span><span class="p">(</span><span class="nx">fileId</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">fileData</span><span class="p">,</span> <span class="nx">type</span><span class="p">,</span> <span class="nx">mime</span><span class="p">);</span>
</span><span class='line'>            <span class="p">});</span>
</span><span class='line'>
</span><span class='line'>        <span class="p">})</span>
</span><span class='line'>    <span class="p">},</span> <span class="kd">function</span><span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>        <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">error</span><span class="p">);</span>
</span><span class='line'>    <span class="p">})</span>
</span><span class='line'><span class="p">})</span>
</span></code></pre></td></tr></table></div></figure>


<p>Now if we add some basic layout with ability to drag'n'drop files into web page, we&rsquo;ll get pretty cool file sharing service: <a href="http://rawgit.com/VideolinkPlatform/vlp-samples/master/file-sharing/index.html">http://rawgit.com/VideolinkPlatform/vlp-samples/master/file-sharing/index.html</a>.</p>

<p>So as you can see, apart of video and audio abilities, WebRTC also provides rich data transfer functionality, which simplifies life of developer, as supports security and different types of transfers out of the box.</p>

<p>Hope you enjoyed reading. Questions and suggestions in comments are appreciated.</p>

<p>Full source code (together with layout, styles and drag'n'drop) is available on <a href="https://github.com/VideolinkPlatform/vlp-samples/tree/master/file-sharing">GitHub</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[How to build simple video chatting web app with VideolinkPlatform]]></title>
    <link href="http://videolinkplatform.com/how-to-build-simple-video-chatting-web-app-with-angular-dot-js-and-videolinkplatform"/>
    <updated>2014-10-20T00:00:00+02:00</updated>
    <id>http://videolinkplatform.com/how-to-build-simple-video-chatting-web-app-with-angular-dot-js-and-videolinkplatform</id>
    <content type="html"><![CDATA[<p>Every day in-browser video communication getting more and more popular among web apps and services. Video calling and messaging makes old-fashioned contact form or support chat look modern and renewed as it brings new experience for instant communication — the same way as we ask shop assistant to help us with selecting new TV we can ask support engineer to help us with making purchase and describe delivery policy of web shop. And what is even more thrilling, is that this communication is just few clicks away.</p>

<!-- more -->


<p>Last generation video services created big overhead in call setup — all participants must have the same software (often even same version), installation of which is always a headache for regular users. So they thought twice before using online calls for contact.</p>

<p>But thankfully to fast evolving browsers and web technology, it’s not a problem anymore. With technologies like WebRTC, users can arrange calls directly in web browser, without installation of any additional software (just check Videolink2.me to see how easy it is). So now when client wants to contact support engineer of web shop, just few clicks needed to start it directly in browser without any hassle.</p>

<p>Last few years we were creating services with web based video conferences, and one day we decided to merge all our knowledge and experience into one tool, which is called <strong>VideolinkPlatform</strong>.</p>

<h3>What is VideolinkPlatform?</h3>

<p>VideolinkPlatform is a combination of tools and services for developers to simplify building of seamless video calling experience <strong>in web browser</strong>.</p>

<p>It basically consists of 2 parts: <em>Javascript SDK</em> and <em>Signalling Cloud</em>. First one runs in  web browser and receives instructions from web app, when Signalling Cloud is used to setup connection between all participants and manage the call.</p>

<p>The core communication technology that stands behind is <strong>WebRTC</strong>, which allows to setup peer-to-peer connections between multiple users and transfer audio/video and data streams over that connections. WebRTC is supported by majority of modern web browsers (Chrome, Firefox and Opera) and for browsers that don’t support it VideolinkPlatform provides fallback to peer-to-peer connections over <strong>Flash</strong>. Such solution lets us support <strong>all desktop browsers and recent Android devices</strong>.</p>

<p>Why does peer-to-peer matters? Problem of <strong>security and data privacy</strong> is very important these days. Keeping your personal and professional communication private becomes critical requirement for communication tools. That’s why using peer-to-peer connections is one of our core functionality. Such connection creates <strong>direct communication channel</strong> between web browsers of call participants and doesn&rsquo;t send important data trough other servers in a middle. So there is no way to intercept the call by hacking or getting access to servers of communication service provider, since <strong>all data travels directly from one participant to another</strong>.</p>

<h3><a name="start"></a>Let’s try it in action</h3>

<p>It’s always better to see once then hear 10 times. Example below demonstrates the easiest way to add video conference into your web page.</p>

<p>Let’s say that we have a container with id &ldquo;conference-scene&rdquo; where we want to put our conference. So page source code looks like:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'><span class="nt">&lt;html&gt;</span>
</span><span class='line'><span class="nt">&lt;head&gt;&lt;title&gt;</span>Video conference example<span class="nt">&lt;/title&gt;&lt;/head&gt;</span>
</span><span class='line'><span class="nt">&lt;body&gt;</span>
</span><span class='line'>     <span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;converence-scene&quot;</span><span class="nt">&gt;&lt;/div&gt;</span>
</span><span class='line'><span class="nt">&lt;/body&gt;</span>
</span><span class='line'><span class="nt">&lt;/html&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>To start using VideolinkPlatform we need to import library to our webpage, which is basically external javascript file:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'><span class="nt">&lt;script </span><span class="na">src=</span><span class="s">&quot;http://cdn.videolinkplatform.com/vl_api.js&quot;</span><span class="nt">&gt;&lt;/script&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>After that, we need to add javascript code, that will initialise VideolinkPlatform SDK after page is loaded. To run actions after page load is completed, we’ll use javascript “window.onload” event which will create connection to Signalling Cloud:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'><span class="nt">&lt;script&gt;</span>
</span><span class='line'>    <span class="nb">window</span><span class="p">.</span><span class="nx">onload</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>        <span class="k">new</span> <span class="nx">VideolinkPlatformConnector</span><span class="p">(</span>
</span><span class='line'>            <span class="p">{</span><span class="nx">container</span><span class="o">:</span> <span class="s1">&#39;conference-scene&#39;</span><span class="p">,</span> <span class="nx">apiKey</span><span class="o">:</span> <span class="s1">&#39;58109df59af3c725f8ed0f2a0c65e341&#39;</span><span class="p">},</span>
</span><span class='line'>            <span class="kd">function</span><span class="p">(</span><span class="nx">connector</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>                <span class="nx">vlRoom</span> <span class="o">=</span> <span class="nx">connector</span><span class="p">.</span><span class="nx">createRoom</span><span class="p">({</span><span class="nx">name</span><span class="o">:</span> <span class="s1">&#39;test room&#39;</span><span class="p">});</span>
</span><span class='line'>            <span class="p">}</span>
</span><span class='line'>        <span class="p">)</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'><span class="nt">&lt;/script&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>So at 2nd line we added “onload” event handler which connects to Signalling Cloud by creating VideolinkPlatformConnector object. In configuration of that object (line 4) we specified that video streams should be placed in container with id “conference-scene”. At lines 5-7 created conference room with name “test room” (if it haven&rsquo;t existed before) and immediately joined that room, after connection was established.</p>

<p>Here’s how initialisation process looks in terms of connections:</p>

<p><img src="https://dl.dropboxusercontent.com/u/178301/dont_remove/vlp-blog/connection.png"></p>

<p>This few lines of code is basically all what’s needed to create video conference on your page. Below you can find full source code:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'><span class="nt">&lt;html&gt;</span>
</span><span class='line'><span class="nt">&lt;head&gt;&lt;title&gt;</span>Video conference example<span class="nt">&lt;/title&gt;&lt;/head&gt;</span>
</span><span class='line'><span class="nt">&lt;body&gt;</span>
</span><span class='line'>    <span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;converence-scene&quot;</span><span class="nt">&gt;&lt;/div&gt;</span>
</span><span class='line'>
</span><span class='line'>    <span class="nt">&lt;script&gt;</span>
</span><span class='line'>        <span class="nb">window</span><span class="p">.</span><span class="nx">onload</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>            <span class="k">new</span> <span class="nx">VideolinkPlatformConnector</span><span class="p">(</span>
</span><span class='line'>                <span class="p">{</span><span class="nx">container</span><span class="o">:</span> <span class="s1">&#39;conference-scene&#39;</span><span class="p">,</span> <span class="nx">apiKey</span><span class="o">:</span> <span class="s1">&#39;58109df59af3c725f8ed0f2a0c65e341&#39;</span><span class="p">},</span>
</span><span class='line'>                <span class="kd">function</span><span class="p">(</span><span class="nx">connector</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>                    <span class="nx">vlRoom</span> <span class="o">=</span> <span class="nx">connector</span><span class="p">.</span><span class="nx">createRoom</span><span class="p">({</span><span class="nx">name</span><span class="o">:</span> <span class="s1">&#39;test room&#39;</span><span class="p">});</span>
</span><span class='line'>                <span class="p">}</span>
</span><span class='line'>            <span class="p">)</span>
</span><span class='line'>        <span class="p">}</span>
</span><span class='line'>    <span class="nt">&lt;/script&gt;</span>
</span><span class='line'><span class="nt">&lt;/body&gt;</span>
</span><span class='line'><span class="nt">&lt;/html&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>So as you can see, building video conferences is not as complicated as it used to be. The process doesn’t require any field specific skills anymore — just few lines of javascript code and a bit of configuration.</p>

<p>You can find more information about features of JS SDK in our API documentation: <a href="http://videolinkplatform.com/apidocs.html">http://videolinkplatform.com/apidocs.html</a></p>

<p>In this blog we’re going to write more about in-browser web conferencing and how VideolinkPlatform can make life of web developer a bit more easy. So if you’re interesting to receive updates, you can <a href="http://feeds.feedburner.com/VLPlatform">subscribe to RSS</a> or follow us in Twitter <a href="https://twitter.com/vlplatform">@VLPlatform</a>.</p>

<p>Also fill free to drop a comment below the post if you have any question or suggestion or contact us directly via email: <a href="mailto:info@videolink2.me">info@videolink2.me</a>.</p>
]]></content>
  </entry>
  
</feed>
