WARNING: This text is deprecated and refers to an old version of ØMQ. It remains here for historical interest. DO NOT USE THIS TO LEARN ØMQ.
This example is a follow-up to the instant messaging example. With instant messaging example, you've learned how to emulate classic broker-based architecture on top of broker-less ØMQ infrastructure.
Videoconferencing example goes one step further and shows how to build similar application (conference over the network) in peer-to-peer fashion, omitting the broker altogether.
There are two distinct types of components in the videoconferencing example. One of them is sender, component used to capture the feed from webcam and send it to the network. The other one is receiver used to subscribe to a particular video feed and display it in a window.
Following diagram shows message flow between three participants of the conference. Each participant starts a sender (to capture feed from his webacam) and two receivers (to see the remaining participants of the conference).
Note the zmq_server on the top. It is used as a directory service so that individual applications can remain agnostic about each other's location, however, once the connections between components are established zmq_server doesn't participate in the message flow.
The wire format for messages sent from sender to receiver is <width, height, frame data>:
- uint32_t: frame width in pixels (network byte order)
- uint32_t: frame height in pixels (network byte order)
- frame data
- RGB24 frame data (R, G, B: 3 octets per pixel)
Note that videoconferencing example is dependent on Linux video capturing libraries. Consequently you won't be able to compile it on different operating systems.
To build the code you need to have the SDL development libraries (libsdl1.2-dev in Debian) and the Unicap library from http://www.unicap-imaging.org installed.
To build the example use --with-camera option with configure:
$ ./configure --with-camera $ make
First, start zmq_server:
Then start sender component. On the command line, supply the location of zmq_server (video.foobar.com), your name and network interface and port to publish your video-feed on:
$ ./sender video.foobar.com Beethoven 10.0.0.1:5555 Opened video capture device: STV0680  Trying video format: BGR 24bpp Using video format: BGR 24bpp [320x240]
From now on, anybody can connect to your video-feed using receiver component:
$ ./receiver video.foobar.com Beethoven
Run multiple video-feeds and receive each of them on multiple boxes. Check that everything woks OK.
Videoconferencing example demonstrates how to write genuine broker-less application. There isn't any kind of messaging broker running on the network and still the participants of the teleconference are able to see each other. Even more importantly, it takes only a single network hop for messages to get from sender to receiver, meaning that latency is approximately one half of what it would be if broker-based architecture was used.
If you found this page useful, please rate it up so others will find it.
Who's watching this page?Dominic Luciano
Fernando J Quintero
... and more