Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
ISO/IEC 29341-3-12:2011 specifies the ContentDirectory:3 service, the component that transforms a UPnP media server from a simple file server into an intelligent media library. The CDS organizes media items (tracks, videos, images, playlists) into a hierarchical container structure, enriches them with standardized metadata, and exposes powerful browsing and search capabilities to UPnP control points. It is the most complex and feature-rich service in the UPnP AV architecture.
At its core, the CDS manages a tree of objects, where each object is either a container (a grouping node) or an item (a leaf representing actual media content). Both containers and items carry metadata expressed in the DIDL-Lite XML schema, which maps Dublin Core elements (title, creator, date), UPnP AV-specific properties (class, genre, album, artist), and resource descriptors (bitrate, resolution, sample rate, protocol info).
The Browse() action is the primary mechanism for content navigation. It accepts parameters: ObjectID (the container to browse), BrowseFlag (BrowseDirectChildren or BrowseMetadata), Filter (comma-separated list of desired metadata fields), StartingIndex and RequestedCount (for pagination), and SortCriteria. The response includes the result XML (DIDL-Lite fragment), NumberReturned, TotalMatches, and an UpdateID for cache invalidation.
| Browse Parameter | Values | Description |
|---|---|---|
| ObjectID | “0” (root), container UUID | Identifier of the container to browse |
| BrowseFlag | BrowseDirectChildren, BrowseMetadata | Child enumeration vs. container metadata |
| Filter | dc:title, res, upnp:class, * | Requested metadata fields (wildcard supported) |
| StartingIndex | 0, 1, 2, … | Zero-based offset for paginated results |
| RequestedCount | 0 (all), positive integer | Maximum number of entries to return |
| SortCriteria | +dc:title, -upnp:date | Sort order (+ ascending, – descending) |
While Browse() navigates the static container hierarchy, Search() performs dynamic queries across the entire content tree. The search criteria use a simple search expression language with operators: = (equals), != (not equals), <, >, <=, >=, contains, doesNotContain, derivedfrom, and exists. Multiple criteria can be combined with and and or. The SearchClass parameter restricts searches to a specific content class hierarchy.
dc:title, upnp:artist, and upnp:album. The Search() action on a naive filesystem traversal can take seconds; an indexed SQLite backend returns results in milliseconds.Implementing a high-performance CDS requires careful architectural decisions. The container hierarchy should be backed by a database schema that supports efficient subtree queries. The nested set model (using left/right indices) is preferred over the adjacency list model because it enables single-query subtree retrieval — critical for the Browse() action with BrowseDirectChildren. For embedded devices with flash storage, an in-memory cache of frequently accessed containers (e.g., root, “All Music”, “All Videos”) reduces database access latency.
State change notification is another critical aspect. The ContainerUpdateIDs and SystemUpdateID state variables provide change tracking for subscribed control points. When content changes (a new track is added, metadata is edited), the CDS increments SystemUpdateID and emits an event containing the changed container IDs. Control points use this to refresh only the affected portions of their UI rather than re-browsing the entire tree.
ContainerUpdateIDs format is a comma-separated list of “containerID,updateCount” pairs. If multiple containers change simultaneously, all affected IDs must be included in a single event. The control point should coalesce rapid successive events (within 200ms) to avoid UI thrashing.Metadata extensibility is handled through the createClass and addClass mechanisms. Vendors can define custom content classes (e.g., object.item.audioTrack.digitalBook) by deriving from standard UPnP classes. Custom metadata properties can be introduced using a vendor-specific XML namespace, prefixed with a unique identifier to avoid naming collisions.
StartingIndex and RequestedCount) must be used. The recommended page size is 50-100 items for responsive UI performance.SystemUpdateID and updates the ContainerUpdateIDs for each affected container. Subscribed control points receive a GENA event and can refresh their caches.derivedfrom criterion matches items that are derived from a specified class. For example, searching with upnp:class derivedfrom "object.item.audioItem" returns all audio items including subclasses like audioTrack, audioBook, and audioBroadcast.