本文记录DLNA、SAT2IP以及UPnP相关协议、实现理解
开源代码
- gmediarender
- gmrender-resurrect – DMR
- libupnp-1.6.25 – lib
- minidlna-1.2.1 – DMS
- xbmc
- vlc – DMP
- libsatip
- minisatip – SAT2IP
- satip-client
- tvheadend
协议资料
- UPnP-arch-DeviceArchitecture-v1.1.pdf
- UPnP-arch-DeviceArchitecture-v2.0.pdf
- DLNA Guidelines June 2016 - Part 1-1 Architectures and Protocols.pdf
- DLNA Guidelines June 2016 - Part 1-2 XDMR.pdf
- DLNA Guidelines June 2016 - Part 5 Device Profiles.pdf
- satip_specification_version_1_2_2.pdf
upnp
内容包含了ssdp、soap和GENA,主要过程包括发现、描述、控制、事件和展示
设备分为两类:
device,Logical device. A container. May embed other logical devices. Embeds one or more services. Advertises its presence on network(s).Root device, A logical device that is not embedded in any other logical device.embedded device
control point, Retrieves device and service descriptions, sends actions to services, polls for service state variables, and receives events
from services.
一个UPnP 设备可以是多个服务的载体和多个子设备的嵌套集。而控制点 CP指的是可以发现并控制其它设备的设备。逻辑关系如下:

控制使用SOAP逻辑如下:

事件逻辑如下:

DLNA 与 SAT2IP 图

Discovery阶段,SAT2IP存在DEVICE ID NegotiationDescription阶段,DLNA存在SCPDURL、controlURL和eventSubURLMedia Transport,DLNA中HTTP是必选,RTP是可选;而SAT2IP相反
DLNA
UPnP AV Architecture 定义了UPnP AV设备间媒体传送以及和CP间的交互。UPnP AV也定义了两种UPnP AV设备:UPnP AV MediaServer Device(MSD)和UPnP AV MediaRenderer Device(MRD),同时定义了可以提供的四种服务:[DLNA1-1 4.4]
AVTransport Service(可控制多屏设备上的媒体 play,pause,seek,stop 等)RenderingControl Service(可调节多屏设备上的音量,声音,静音等)ContentDirectory Service(可获取多屏设备上可访问的媒体内容)ConnectionManager Service(可提供所支持的传输协议信息及多屏设备的 MIME 格式信息)
DMS
A UPnP AV MediaServer shall identify in the Device Description Document the
ContentDirectory service and the ConnectionManager service using serviceType and serviceId
elements with the values given in Table 10.

minidlna通过扫描指定目录并监控变化来提供服务
DMR
A UPnP AV MediaRenderer shall identify in the Device Description Document the
AVTransport service, the RenderingControl service, and the ConnectionManager service using
serviceType and serviceId elements with the values given in Table 9.

gmrender-resurrect使用GStream来提供render服务
DMP
DLNA Device Class having home network environmental characteristics, with the role of finding
content exposed by a DMS or M-DMS and rendering the content locally
相比于另外一个Rendering Endpoint:DMR多个主动搜索DMS功能,通过发送M-SEARCH来发现DMS
DMC
A Digital Media Controller (DMC) with the role of finding content exposed by a DMS and
matching it to the rendering capacities of a DMR and setting up the connections between the
DMS and DMR.
用于在DMS和DMR建立连接并控制
常见系统拓扑结构
客户端播放软件
minidlna为DMS,VLC为DMP,通过搜索DMS并浏览目录来播放文件,逻辑如下
- Invoke UPnP actions to browse and select content.
- Request the content for playback.
- Transport the content to the DMP or the M-DMP.

手机推送到 DMR
手机为DMS/DMC?,gmrender-resurrect为DMR,手机发送SOAP ACTION来完成控制,然后DMR从DMS获取数据进行播放
SAT2IP
结构图

SAT2IP Server
SAT>IP Servers 处理 SAT>IP Clients的请求并将电视直播节目转发给 SAT>IP ClientsServer将Tuner数据编码为RTSP数据进行发送,参考minisatip
SAT2IP Client
vlc实现了SAT2IP Client,同时支持DMP
总结
本章总结DMS、DMP、DMR、SAT2IP Server以及SAT2IP Client相同与差异点
DMP=DMR+DMC,DMR是被动状态,等待其他设备的控制;而DMP会主动搜索DMS进行操作。一个是推,一个是拉DMP与SAT2IP Client均存在交互界面,根据界面选取内容进行控制播放等。在VLC中整合为同一个功能upnp.c,区别在于发现的server类型不同,其中SAT2IP存在协商过程DLNA与SAT2IP,设备发现及描述一致,需要upnp使用各自协议中规定字段DLNA与SAT2IP设备控制不一样,DLNA使用HTTP/SOAP,SAT2IP使用RTSPDMS与SAT2IP Server,SAT2IP仅提供大网信号,且打包为RTSP进行传输;而DMS一般会提供多种格式文件,使用HTTP GET/POST