Here i will show you how to execute very simple WebRTC demo served by Apache web server . The example is how to get the media stream of the local device. I will take as an example the WebRTC “getUserMedia” example from the book “Real-Time Communication with WebRTC by Salvatore Loreto and Simon Pietro(O’Reilly)”. You can find the source code on the book’s GitHub page. Follow these steps:
- Create a folder for your WebRTC project: # mkdir /var/www/html/webrtc
- Open Apache configuration file “/etc/httpd/conf/httpd.conf” and add this line:
Alias /webc /var/www/html/webrtc
Restart Apache: # systemctl restart httpd.service
- Copy the file “getUserMedia.html” to “/var/www/html/webrtc“
- Copy the file “getUserMedia_2.js” to /var/www/html/webrtc/js
- Browse to ” http://Your-IP-Address/webc/getUserMedia.html”
You can use jsfiddle framework to write, save, validate, and run your application online.
- Update your browser (bug fixes). Using the developer edition is a good choice (e.g. Firefox Developer Edition).
- Test your application on different browsers