Example Code

Private WebCam server

Code and Documents



Company: HILASE
Author(s): Saulius Pakalnis
NI Product(s) Used: Labview 2017 Professional Development System

The Challenge (15-40 words)

Privacy is about respecting individuals and their personal life. Internet privacy is a subcategory of data privacy. And data privacy issues can arise in response to information from a wide range of sources. In computer networking, Point-to-Point Protocol connects two routers directly without any host or any other networking device in between. What is if you are at home and are your router administrator, but your remote person has no right to access his remote router? That is a typical situation then he is on way.


The Solution (15-40 words)

The Idea of this project was to build synchronous private direct video and audio data stream from the host computer to client Web browser (computer, Tablet, or cell phone) for the people who would like to share his sensitive information only with a certain person. For example, you would like to show something private to your wife, family doctor, lawyer or a journalist who is far away from the office or home. You also can grab some part of your screen, comment it and stream it over the internet to your remote friend PC, tablet or phone. A football game from the local network, as an example.


The Private WebCam server streams images from a USB WebCam and audio from default microphone directly to client computer Web browser over the Internet. Server-side is written in Labview 2017 without using Labview WWW server or Ni_Vision package (Ni_Imaq, Ni_ImaqDx, Ni_Imaq I/O). The Server calls DirectShowLib-2005.dll for capturing images from WebCam and WaveIO.dll for getting an audio stream from the microphone. There is an option to capture and stream some part of the monitor screen instead of WebCam. The Client-side is a single web page in HTML, CSS and JavaScript. Just run standard Web browser like Chrome, Firefox, or Microsoft Edge and set the server IP address. Video and audio streaming over the Internet employs WebSocket protocol. The streaming video, audio, and messages are encrypted by password.


Application Description

The Labview project includes ready to run the solution. All necessary *.dll-s are included. The installer can be compiled from the project with Labview 2017 under Windows 10.

You must manually configure your router to enable your public internet address access for ports of Private WebCam server. Search Google for "Router port forwarding".

Run the Private WebCam server.vi from the project, or Private WebCam server.exe from an installed directory. See blinking buttons. Set WebCam resolution and web page password. The server makes the only external call to http://bot.whatismyipaddress.com/ to get your PC public address. No other requests to external servers are made. This prevents you from leaking any information to third party servers. Now the connection between Host (Private WebCam server) and remote internet Client (Web Browser) can be established. Send your public internet address and password to the client using a different kind of communication, possibly by mobile phone message. The client puts the address to a web browser and gets the first static page with a password request. Then the password is encrypted with SHA-256 and send back to Private WebCam server. There is no way to recover real password from SHA-256 code. If password SHA-256 code matches, the server sends the main webpage which opens secure WebSocket connection with SHA-512 masked video, audio, and messages. No SHA-512 mask and no password is sent during this communication.  On client side Web Browser the entered password is transferred directly between both HTML pages.


This example shows the synthesis of LabView software and Internet languages programming in a single project. LabView, HTML, CSS, JavaScript sources are available for discovery and the methods shown in the project are useful for students who would like to build their own unique Internet Labview projects.



Author Contact Details

Saulius Pakalnis: saulius.pakalnis@hilase.cz, personal email mumris@gmail.com

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.