Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
ISO/IEC 29341-17-11 defines the ConnectionManager service, a fundamental component of the UPnP AV architecture that manages the establishment, supervision, and teardown of connections between media sources and sinks. In a typical UPnP AV deployment, the ConnectionManager acts as the orchestration layer — it does not transport media data itself but instead negotiates the parameters under which media transport occurs, ensuring that both the sending device (e.g., a MediaServer) and the receiving device (e.g., a MediaRenderer) agree on transfer protocols, data formats, and connection semantics before any media bytes cross the network.
The ConnectionManager service is hosted on both MediaServer and MediaRenderer devices. On the server side, it advertises which protocols and content formats the server can deliver. On the renderer side, it advertises which protocols and formats the renderer can accept. A control point queries both ends, selects a compatible combination, and invokes the PrepareForConnection action to establish the media pipeline. This negotiation-centric design ensures that UPnP AV devices from different manufacturers can interoperate without prior knowledge of each other’s capabilities.
The protocol negotiation process begins with the GetProtocolInfo action. This action returns two lists: Source (protocols and formats the device can send) and Sink (protocols and formats the device can receive). For a MediaServer, the Source list is populated and Sink may be empty (or contain only loopback protocols). For a MediaRenderer, the Sink list is populated and Source may be empty. The protocolInfo strings follow a strict format — protocol:network:contentFormat:additionalInfo — where protocol identifies the transport mechanism (e.g., http-get, rtsp, internal), network specifies the network type (e.g., *, 239.255.255.250:1900), contentFormat identifies the MIME type or UPnP class, and additionalInfo carries optional parameters like packetization mode or clock frequency.
Once compatible protocols are identified, the control point invokes PrepareForConnection to establish a connection. This action returns a ConnectionID that identifies the connection throughout its lifetime, and optionally an AVTransportID and RenderingControlID if the connection is associated with specific transport and rendering instances. The connection can be of three direction types: Input (the device receives content), Output (the device sends content), or Direction (bidirectional). After use, the control point calls ConnectionComplete to tear down the connection and free associated resources.
| Action | Description | Key Parameters | Error Conditions |
|---|---|---|---|
| GetProtocolInfo | Retrieve supported protocols and formats | Out: Source, Sink (comma-separated protocolInfo list) | None — always succeeds if service is available |
| PrepareForConnection | Establish a media connection | In: RemoteProtocolInfo, PeerConnectionManager, PeerConnectionID, Direction; Out: ConnectionID, AVTransportID, RenderingControlID | 702 (No Such Connection) if resources exhausted |
| ConnectionComplete | Terminate an active connection | In: ConnectionID | 702 (No Such Connection) if ID is invalid |
| GetCurrentConnectionInfo | Retrieve connection details | In: ConnectionID; Out: ConnectionInfo structure | 702 (No Such Connection) if ID is unknown |
| GetCurrentConnectionIDs | List all active connection IDs | Out: ConnectionIDs (comma-separated list) | None |
Implementing a robust ConnectionManager requires meticulous attention to resource management. Each active connection consumes memory for state tracking and may reserve hardware resources such as decoder pipelines, DMA channels, or network socket buffers. The standard does not specify a maximum number of concurrent connections — this is implementation-defined — but a well-engineered device should enforce a configurable connection limit and reject new connection requests with a clear error code when the limit is reached.
The ConnectionID is an opaque identifier that must remain valid for the lifetime of the connection. Engineers should implement ConnectionID as a monotonically increasing unsigned integer or a UUID, never reusing IDs from terminated connections during the device’s uptime. Reusing IDs can cause subtle bugs in control points that cache connection state and fail to detect that a previous connection’s ID now refers to a completely different media stream.
Thread safety is another critical concern. The ConnectionManager must handle concurrent PrepareForConnection and ConnectionComplete invocations without race conditions. A common implementation pattern uses a connection table protected by a reader-writer lock: query actions (GetCurrentConnectionIDs, GetCurrentConnectionInfo) acquire a shared read lock, while mutation actions (PrepareForConnection, ConnectionComplete) acquire an exclusive write lock. This pattern maintains consistency while allowing concurrent queries.
Error handling deserves particular attention. When PrepareForConnection fails due to incompatible protocols, the action should return error code 702 (No Such Connection) with a descriptive error message — not a generic SOAP fault. Control points use the specific error code to determine whether to fall back to an alternative protocol or notify the user about the incompatibility.