WebRTC code used for Public Safety Communications Research
WebRTC is a technology, not a service. But WebRTC can form the basis of a service. WebRTC allows browsers to behave in ways that they were not able to before. WebRTC enables real-time communication between browsers for free and without any plugins or downloads! All you need to communicate for free is a computer, internet, and a compatible browser.
At PSCR we are using WebRTC in testing vendor equipment to ensure they uphold functionality specified in the standards. This is done using our in-lab 4G LTE network and generating traffic of specific QoS parameters with WebRTC.
I will describe the setup of my development environment on OSX:
- Download the .zip or clone this repository onto your local machine.
- Set up the Apache server on your Mac, here is what I used: Apache server setup for OSX
- Go to where you downloaded or cloned the code. Open the Terminal and
cdinto thewebrtc-4-qosdirectory, then select all the files and folders in this directory, copy them and then paste directly into theSitesfolder you created when setting up the Apache server. If youcdinto theSitesfolder you should seeindex.html,serve_index.js,twoWayVideoWithChat.html,_assetsfolder,cssfolder etc. - Download Node.js.
- Open the Terminal and
cdinto yourSitesfolder and type:npm install socket.ionpm install node-staticnpm install websocketnpm install express
Prerequisite: Before the code can be run, you must open index.html, serve_index.js, twoWayAudioWithChat.html, and twoWayVideoWithChat.html to change the host IP address to the IP of your local machine. At the top of the prior mentioned files there are comments that will tell you how many places in that file that you need to change IP addresses. The example code below is from index.html which tells you there are 5 places in that file where the IP address needs to be changed. And all spots will be denoted by this style of comment block:
<!-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
PUT YOUR IP ADDRESS IN PLACE OF '10.10.10.10' -->
<li data-filtertext=""><a href="http://10.10.10.10:3000/QCI1" class="contentUpdate" style="color:#E60000">Voice Call (QCI 1)</a></li>
<li data-filtertext=""><a href="http://10.10.10.10:3000/QCI2" class="contentUpdate" style="color:#E60000">Video Call (QCI 2)</a></li>
<li data-filtertext=""><a href="#QCI3" class="contentUpdate" style="">Real-time Gaming (QCI 3)</a></li>
<li data-filtertext=""><a href="http://10.10.10.10:3000/QCI4" class="contentUpdate" style="color:#E60000">Buffered Video (QCI 4)</a></li>
<li data-filtertext=""><a href="#QCI5" class="contentUpdate" style="">IMS Signaling (QCI 5)</a></li>
<li data-filtertext=""><a href="http://10.10.10.10:3000/QCI6" class="contentUpdate" style="color:#E60000">TCP, Chat (QCI 6)</a></li>
<li data-filtertext=""><a href="#QCI7" class="contentUpdate" style="">Live Video Stream (QCI 7)</a></li>
<li data-filtertext=""><a href="http://10.10.10.10:3000/QCI6" class="contentUpdate" style="color:#E60000">TCP, Chat (QCI 8 + 9)</a></li>
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -->Once the IP addresses have been changed...
Open the Terminal and cd into the Sites folder.
- Start the Apache server by typing:
sudo apachectl start - Open a new tab or window for the Terminal,
cdinto theSitesfolder and type:node serve_index.js - Open your browser (preferably Chrome or Firefox) and type
localhostin the url bar at the top. - Explore the webpage and click on the WebRTC Demos tab and pick a demo!
- Learn and Enjoy!
We now have Apache serving the main index page and Node will be serving all the WebRTC pages and signaling.
- Don't forget to kill the servers when you are done. Type
sudo apachectl stopto kill the Apache server, and type Ctrl-C to kill the node server.
- After Apache is serving the main index page, if you type
localhostin the url bar of Chrome or Firefox you should see the following page displayed:
- Navigate around the page to the
WebRTC Demostab:
- After typing
node serve_index.jsand the node server is listening on port 3000 (or whatever port you set it to), then the signaling is occuring for WebRTC to make the connections. So now you can click on one of the demo links which will take you to a different page where you can choose to share your webcam and/or microphone and then connect to a peer by sharing the exact url. Only difference is where the host can saylocalhost, when you share the url link, you must replacelocalhostwith the hosts IP address. The screen shot below is taken from the peer's browser joining the host. Notice in the peer's url barlocalhostis replaced by the hosts IP address.
THE NATIONAL TELECOMMUNICATIONS AND INFORMATION ADMINISTRATION, INSTITUTE
FOR TELECOMMUNICATION SCIENCES ("NTIA/ITS") DOES NOT MAKE ANY WARRANTY OF
ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING, WITHOUT LIMITATION,
THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
NON-INFRINGEMENT AND DATA ACCURACY. THIS SOFTWARE IS PROVIDED "AS IS."
NTIA/ITS does not warrant or make any representations regarding the use of
the software or the results thereof, including but not limited to the
correctness, accuracy, reliability or usefulness of the software or the
results.
You can use, copy, modify, and redistribute the NTIA/ITS developed software upon your acceptance of these terms and conditions and upon your express agreement to provide appropriate acknowledgments of NTIA's ownership of and development of the software by keeping this exact text present in any copied or derivative works.
The user of this Software ("Collaborator") agrees to hold the U.S. Government harmless and indemnifies the U.S. Government for all liabilities, demands, damages, expenses, and losses arising out of the use by the Collaborator, or any party acting on its behalf, of NTIA/ITS' Software, or out of any use, sale, or other disposition by the Collaborator, or others acting on its behalf, of products made by the use of NTIA/ITS' Software.


