Exploring the Universal Plug and Play Architecture
Custom Connections
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 [1]. The Universal Plug and Play (UPnP) standard [2] 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 [3]. 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 [4], 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 [5], 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) [6]. 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.
Joining Up
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 [7].
Setting Up the Environment
Consult the BRisa end-user documentation [8] 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."
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
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.