Exploring the Universal Plug and Play Architecture
Universal Plug and Play provides an easy framework for seamless integration of network devices. Learn how to build your own UPnP solution using the open source BRisa framework.
The arrival of consumer electronic devices such as PDAs, cell phones, and Internet tablets has placed new emphasis on techniques for connecting and sharing information . The Universal Plug and Play (UPnP) standard  is a good candidate to provide pervasive services for a new generation of electronic devices.
The original concept of Plug and Play focused on dynamically attaching devices directly to a computer. A device driver controlled by the operating system detected the peripheral and made it available to the user via system calls. The new Universal Plug and Play standard offers a radically different approach: Devices operate on a network and are detected with the use of network protocols. The system calls used in the previous plug and play architecture are replaced by remote method invocation with the use of SOAP web services.
A UPnP network is a collection of interconnected computers, network appliances, and wireless devices that use UPnP to discover, advertise, and access network services. The goal is to provide an easy-to-use framework for creating tools to support the communication of network-based devices. UPnP achieves this goal by defining and publishing UPnP device control protocols built on open, Internet-based communication standards . As you might expect, UPnP supports connections for devices such as cell phones or MP3 players, but UPnP also offers benefits for connecting to conventional peripherals such as printers, as well as wireless household electronic gadgets for controlling appliances, lights, doors, and curtains.
An example of a UPnP standard is the UPnP AV specification , released in the middle of 2002 and updated in 2006. UPnP AV supports UPnP-enabled devices that share multimedia content and services. The UPnP AV standard defines protocols for discovering, sharing, and playing multimedia content.
In this article, I will explain how to create a simple multimedia application based on the UPnP architecture. To build this simple solution, I will use the BRisa framework , which is an open source framework for developing custom UPnP applications.
The UPnP AV Specification
UPnP Audio and Video (AV) is a specification within the UPnP standard supervised by the Digital Living Network Alliance (DLNA) . DLNA supports a vision of a wired and wireless interoperable network of personal computers, consumer electronics, and mobile devices sharing multimedia content and services in a seamless environment.
The UPnP AV specification defines a system of three UPnP devices:
- Media server – a component that shares multimedia items, such as audio (.mp3, .wma, .ogg), video (.mpeg, .wmv, .fla), image (.gif, .jpg, .png), and remote multimedia streaming, such as Internet radio stations and online photo albums.
- Media renderer – responsible for reproducing all multimedia data shared by any UPnP media server and providing mechanisms that allow remote devices to play, pause, stop, and seek a multimedia item.
- Multimedia control point – a small device, such as a cell phone or Internet tablet, that gives the user control over media servers and renderers.
Figure 1 illustrates the UPnP device discovery and service consumption process. When the control point is started, it sends a multicast message to the network asking for media servers and media renderers (Step 1). When the UPnP devices receive the multicast message sent by the UPnP control point, each device responds to the control point requester (Step 2).
At this point, the UPnP control point knows about all of the connected UPnP devices. The user, operating through the interface provided on the control point, browses and selects any multimedia item listed by the UPnP media server (Step 3). After selecting a multimedia item, the user chooses a media renderer that will process (play) the multimedia item (Step 4). After selecting a media server and a media renderer, the user simply clicks on the Play button of the UPnP control point, and the media renderer starts to play the multimedia stream sent by the media server.
Any UPnP-compatible device from any vendor can dynamically join a UPnP network through the following process:
- Step 0 – Addressing: devices obtain an IP address
- Step 1 – Discovery: devices advertise their services to control points on the network
- Step 2 – Description: Devices convey capabilities on request from control points, learning about the presence and capabilities of other devices
- Step 3 – Control: Devices provide services, and control points can send actions to these services
- Step 4 – Eventing: whenever requested, the control points register to remote devices' events
- Step 5 – Presentation: device may provide a presentation web page for a control point, allowing a user to control the remote device and view the device status
Regardless of the steps and states of a UPnP device, the device can leave the network automatically without leaving any unwanted state information behind.
BRisa UPnP Framework
BRisa is an open source framework written in Python that supports the development of UPnP devices and services.
The BRisa framework consists of the following:
- core UPnP classes that allow the development of new devices and services,
- the control point API,
- three end-user applications: the BRisa configuration tool, the media server, and the media renderer.
The BRisa media server and media renderer are developed on top of the BRisa UPnP framework, providing a reference implementation for the UPnP media server and media renderer specifications. These sample UPnP devices demonstrate the power and flexibility of the BRisa UPnP framework; you can modify and extend these examples to offer new network services based on other UPnP specifications.
The UPnP Control Point API included with the BRisa framework lets developers consume UPnP services for discovering devices, browsing for multimedia content, sending jobs to printers, turning home lights on or off, retrieving temperature information from temperature monitors, and controlling the motion of window curtains. As an example of what you can do with the BRisa framework, I will describe a BRisa UPnP AV scenario that shows how to create a BRisa control point. I will also demonstrate to customize the BRisa media server by creating a media server plugin.
For more information on programming with the BRisa UPnP framework, visit the documentation section of the BRisa project website .
Setting Up the Environment
Consult the BRisa end-user documentation  for details on how to install the BRisa framework through your favorite Linux distribution (such as Debian, Fedora, Gentoo, or Ubuntu).
Regardless of which Linux package manager you use, the BRisa project provides a portable mechanism for installing the core infrastructure in any Python-enabled system. To set up the BRisa framework, you'll need to install a few additional Python packages. See the box titled "BRisa Dependencies."
Before setting up BRisa, install the following Python packages:
- Python 2.5+ – http://python.org/
- GStreamer 0.10 – http://gstreamer.freedesktop.org/download
- GStreamer Plugins 0.10 – http://gstreamer.freedesktop.org/download
- Python GStreamer – http://gstreamer.freedesktop.org/modules/gst-python.html
- Python pyinotify – http://pyinotify.sourceforge.net/
- Python Mutagen – http://pypi.python.org/pypi/mutagen/1.12
Buy this article as PDF
But if you are not using the latest Linux kernel, your system is insecure.
Home routers will give room for custom firmware but still comply with FCC rules
Frank Karlitschek will continue to lead the open source ownCloud project
“Xenial Xerus” comes with a new packages format and several improvements for the enterprise.
Linux users can now download and install the Windows code editor
New initiative will address security and interoperability concerns around container technology.
Developers can use RHEL as a development platform without a subscription fee.
Windows users will soon have native access to the Bash shell.
Improvements to SMTP will provide better guarantee of confidentiality
Graphics vendor embraces new reality in Linux graphics