Exploring the Universal Plug and Play Architecture

Custom Connections

© designalldone, Fotolia

© designalldone, Fotolia

Article from Issue 97/2008
Author(s):

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).

Figure 1: Basic communication scheme for UPnP audio/video devices.

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:

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Video Streaming

    Thanks to protocols such as UPnP and DLNA, video, audio, and photos are distributed to TVs, gaming consoles, PCs, and smartphones without the need for configuration. Linux as a central media server is a welcome guest.

  • Seamless Integration Intro

    Yes, you can do that with Linux… Even if you want to live in an open source world, it's still full of Windows. This month we study strategies for Windows integration.

  • Qt for Maemo

    Write your own smartphone apps with Qt's toolkit for the Maemo platform.

  • Media Centers

    Beyond MythTV and VDR are media centers that take a new approach – or at least make the beaten track look a little different.

  • Free Media Centers

    Free and commercial media center programs promise streaming HD videos, television, music, picture galleries, and a few extra tricks for Linux PCs and the Raspberry Pi – all from the comfort of your living room.

comments powered by Disqus
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.

Learn More

News